platform/upstream/llvm.git
17 months ago[mlir][IR] Hash nesting structure in OperationFingerPrint
Matthias Springer [Wed, 24 May 2023 12:55:09 +0000 (14:55 +0200)]
[mlir][IR] Hash nesting structure in OperationFingerPrint

The following ops currently have the same finger print, even though they are different:
```
func.func @test() {
  "test.foo"() ({
    "test.bar"() : () -> ()
  }) : () -> ()
}
```
And:
```
func.func @test() {
  "test.bar"() : () -> ()
  "test.foo"() ({ }) : () -> ()
}
```

The SHA1 hash used in OperationFingerPrint is order-sensitive, but the ops are hashed in the same order (post-order traversal), so the hash is the same. Switching to pre-order traversal does not solve the issue; a similar example, where IR differs just in its nesting structure, can be constructed.

The problem is solved by hashing the parent op pointer. (Alternatively, a traversal over the IR that hashes scope markers (`{}`) could be used.)

Differential Revision: https://reviews.llvm.org/D151306

17 months ago[libc] Reduce the sizes of some math tests that take longest time.
Tue Ly [Tue, 23 May 2023 20:47:38 +0000 (16:47 -0400)]
[libc] Reduce the sizes of some math tests that take longest time.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D151256

17 months ago[clang][Sema] `-Wshadow` warns about shadowings by static local variables
Takuya Shimizu [Wed, 24 May 2023 12:11:56 +0000 (21:11 +0900)]
[clang][Sema] `-Wshadow` warns about shadowings by static local variables

This patch makes `-Wshadow` warn about the shadowings by static local variables.

Fixes https://github.com/llvm/llvm-project/issues/62850
Differential Revision: https://reviews.llvm.org/D151214

17 months agoReland: [clang][AST] Print name instead of type when diagnosing uninitialized subobje...
Takuya Shimizu [Wed, 24 May 2023 12:21:23 +0000 (21:21 +0900)]
Reland: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

This patch improves the diagnostic on uninitialized subobjects in constexpr variables by modifying the diagnostic message to display the subobject's name instead of its type.

Fixes https://github.com/llvm/llvm-project/issues/58601
Differential Revision: https://reviews.llvm.org/D146358

17 months ago[mlir] move PDL-related transform ops into an extension
Alex Zinenko [Mon, 22 May 2023 14:36:58 +0000 (14:36 +0000)]
[mlir] move PDL-related transform ops into an extension

The initial bring-up of the Transform dialect relied on PDL to provide
the default handle type (`!pdl.operation`) and the matching capability.
Both are now provided natively by the Transform dialect removing the
reason to have a hard dependency on the PDL dialect and its interpreter.
Move PDL-related transform operations into a separate extension.

This requires us to introduce a dialect state extension mechanism into
the Transform dialect so it no longer needs to know about PDL constraint
functions that may be injected by extensions similarly to operations and
types. This mechanism will be reused to connect pattern application
drivers and the Transform dialect.

This completes the restructuring of the Transform dialect to remove
overrilance on PDL.

Note to downstreams: flow that are using `!pdl.operation` with Transform
dialect operations will now require `transform::PDLExtension` to be
applied to the transform dialect in order to provide the transform
handle type interface for `!pdl.operation`.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D151104

17 months ago[AMDGPU] Add attribute to AMDGPU ctor / dtor to indicate single threadedness
Joseph Huber [Mon, 22 May 2023 20:50:55 +0000 (15:50 -0500)]
[AMDGPU] Add attribute to AMDGPU ctor / dtor to indicate single threadedness

We only expect these ctor / dtor functions to be called with a single
thread. Add the appropriate attributes to indicate this to the backend.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D151153

17 months ago[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter
Michael Buch [Tue, 23 May 2023 23:01:47 +0000 (00:01 +0100)]
[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter

This mimicks the implementation of the libstdcpp std::unique_ptr
formatter.

This has been attempted several years ago in
`0789722d85cf1f1fdbe2ffb2245ea0ba034a9f94` but was reverted in
`e7dd3972094c2f2fb42dc9d4d5344e54a431e2ce`.

The difference to the original patch is that we now maintain
a `$$dereference$$` member and we only store weak pointers
to the other children inside the synthetic frontend. This is
what the libc++ formatters do to prevent the recursion mentioned
in the revert commit.

17 months ago[libc][bazel] Add log, log2, log10, log1p to bazel layout.
Tue Ly [Tue, 23 May 2023 20:20:47 +0000 (16:20 -0400)]
[libc][bazel] Add log, log2, log10, log1p to bazel layout.

Add log, log2, log10, log1p and their unit tests to bazel layout.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D151252

17 months ago[gn build] Port ced90d1ff64a
LLVM GN Syncbot [Wed, 24 May 2023 10:54:20 +0000 (10:54 +0000)]
[gn build] Port ced90d1ff64a

17 months ago[FuncSpec] Improve the accuracy of the cost model.
Alexandros Lamprineas [Thu, 11 May 2023 23:07:49 +0000 (00:07 +0100)]
[FuncSpec] Improve the accuracy of the cost model.

Instead of blindly traversing the use-def chain of constant arguments,
compute known constants along the way. Stop as soon as a user cannot
be replaced by a constant. Keep it light-weight by handling some basic
instruction types.

Differential Revision: https://reviews.llvm.org/D150464

17 months agoAdd OpenMPToLLVM conversion pattern for taskgroup
Kiran Chandramohan [Wed, 24 May 2023 08:34:47 +0000 (09:34 +0100)]
Add OpenMPToLLVM conversion pattern for taskgroup

Fixes part of the issue in https://github.com/llvm/llvm-project/issues/62013

Reviewed By: psoni2628

Differential Revision: https://reviews.llvm.org/D151206

17 months ago[mlir] [scf] Add RegionBranchOpInterface to scf.forall and scf.parallel op
donald chen [Wed, 24 May 2023 10:05:34 +0000 (12:05 +0200)]
[mlir] [scf] Add RegionBranchOpInterface to scf.forall and scf.parallel op

Add RegionBranchOpIntefface to scf.forall and scf.parallel op to make analysis trace through subregions.

Differential Revision: https://reviews.llvm.org/D151287

17 months ago[TOSA] Fold consecutive concats on same axis
Dominik Montada [Mon, 15 May 2023 09:51:30 +0000 (09:51 +0000)]
[TOSA] Fold consecutive concats on same axis

Consecutive concats that happen on the same axis can be folded into a
single, bigger concat. This patch implements this folding by
implementing the tosa::ConcatOp::fold method.

Differential Revision: https://reviews.llvm.org/D151210

17 months ago[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)
Sergei Barannikov [Wed, 24 May 2023 09:57:07 +0000 (12:57 +0300)]
[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)

D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
The only place where the assertion is currently triggering is in
CriticalAntiDepBreaker::ScanInstruction. Other places are changed
in case new assertions are added and should be harmless otherwise.

Differential Revision: https://reviews.llvm.org/D151288

17 months ago[compiler-rt] Always use INTERCEPTOR()+ALIAS()+WRAP() to create interceptor alias
Marco Elver [Wed, 24 May 2023 09:32:33 +0000 (11:32 +0200)]
[compiler-rt] Always use INTERCEPTOR()+ALIAS()+WRAP() to create interceptor alias

Do not open code creation of an interceptor alias to another
interceptor. Instead, use INTERCEPTOR() + ALIAS() + WRAP.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D151219

17 months ago[TSan] Remove unused setjmp definitions
Marco Elver [Wed, 24 May 2023 09:32:28 +0000 (11:32 +0200)]
[TSan] Remove unused setjmp definitions

The __interceptor_*setjmp() definitions appear to have been defined for
the purpose of TSAN_INTERCEPT(), but on non-Mac systems, it seems
TSAN_INTERCEPT() isn't even being used anymore for setjmp.

Remove them. Nothing should call them anyway (due to CHECK-fail), so
having the linker fail is better than failing at runtime.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D151218

17 months ago[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*
Marco Elver [Wed, 24 May 2023 09:32:21 +0000 (11:32 +0200)]
[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*

Use ASM_WRAPPER_NAME to produce the name of the __interceptor_*
functions.

NFC.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D151217

17 months ago[compiler-rt] Simplify ALIAS() attribute macro
Marco Elver [Wed, 24 May 2023 09:31:40 +0000 (11:31 +0200)]
[compiler-rt] Simplify ALIAS() attribute macro

Most uses of ALIAS() are in conjunction with WRAPPER_NAME().

Simplify the code and just make ALIAS() turn its argument into a string
(similar to Linux kernel's __alias macro). This in turn allows removing
WRAPPER_NAME().

NFC.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D151216

17 months ago[mlir][transform] Fix merge_handle asm format
Christian Ulmann [Wed, 24 May 2023 09:05:21 +0000 (09:05 +0000)]
[mlir][transform] Fix merge_handle asm format

This commit ensures that the merge_handles operation prints its
`deduplicate` attribute as an optional keyword instead of "unit".

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D151310

17 months ago[AggressiveInstCombine] Handle the nested GEP/BitCast scenario in Load Merge.
bipmis [Wed, 24 May 2023 09:36:11 +0000 (10:36 +0100)]
[AggressiveInstCombine] Handle the nested GEP/BitCast scenario in Load Merge.

This seems to be an issue currently where there are nested/chained GEP/BitCast Pointers.
The patch generates a new GEP for the wider load to avoid dominance problems.

Differential Revision: https://reviews.llvm.org/D150864

17 months ago[RISCV] Scalarize small fixed vector copies < XLEN
Luke Lau [Mon, 22 May 2023 14:34:51 +0000 (15:34 +0100)]
[RISCV] Scalarize small fixed vector copies < XLEN

For small fixed-length vector copies like
vsetivli   zero, 2, e16, m1, ta, ma
vle16.v    v8, (a0)
vse16.v    v8, (a1)

We can scalarize them if the total vector size < XLEN:
lw a0, 0(a0)
sw a0, 0(a1)

This patch adds a DAG combine to do so, reusing much of the existing
logic in https://reviews.llvm.org/D150717

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D151103

17 months ago[RISCV] Add test for small vector copies
Luke Lau [Mon, 22 May 2023 14:32:24 +0000 (15:32 +0100)]
[RISCV] Add test for small vector copies

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D151211

17 months ago[KnownBits] Reduce number of overflow checks for uadd/sub_sat (NFCI)
Nikita Popov [Wed, 24 May 2023 09:14:26 +0000 (11:14 +0200)]
[KnownBits] Reduce number of overflow checks for uadd/sub_sat (NFCI)

Only check for overflow on the min/max values, don't also check
for predicates in addition to that.

17 months ago[bazel] Fix build after 0bf120a82040f7ffaba0f0ab72a983f1cd9343ab
Benjamin Kramer [Wed, 24 May 2023 09:14:18 +0000 (11:14 +0200)]
[bazel] Fix build after 0bf120a82040f7ffaba0f0ab72a983f1cd9343ab

17 months ago[KnownBits] Use early return for unknown LHS for shifts (NFC)
Nikita Popov [Wed, 24 May 2023 09:02:16 +0000 (11:02 +0200)]
[KnownBits] Use early return for unknown LHS for shifts (NFC)

Make it clear that the leading/trailing zeros handling is only
relevant for the unknown LHS case, which is a fast path to avoid
the full shift amount loop in cases where it would not produce
better results.

17 months ago[ValueTracking] Check for known bits conflict for shl nsw (PR62908)
Nikita Popov [Wed, 24 May 2023 08:52:18 +0000 (10:52 +0200)]
[ValueTracking] Check for known bits conflict for shl nsw (PR62908)

I removed the conflict check from computeKnownBitsFromShiftOperator()
in D150648 assuming that this is now handled on the KnownBits side.
However, the nsw handling is still inside ValueTracking, so we
still need to handle conflicts there. Restore the check closer to
where it is relevant.

Fixes https://github.com/llvm/llvm-project/issues/62908.

17 months ago[InstCombine] Directly iterate over users (NFC)
Nikita Popov [Wed, 24 May 2023 08:39:32 +0000 (10:39 +0200)]
[InstCombine] Directly iterate over users (NFC)

After 3a223f1eafe331508d171b519df8a4984791ab48, it's no longer
necessary to put the users into a vector. We can directly iterate
them instead.

17 months ago[KnownBits] Check for conflict-freedom in exhaustive tests
Nikita Popov [Wed, 24 May 2023 08:32:20 +0000 (10:32 +0200)]
[KnownBits] Check for conflict-freedom in exhaustive tests

And make sure udiv() Exact does not produce conflicts.

17 months ago[gn build] Port 1c9a8004ed88
Nico Weber [Wed, 24 May 2023 08:25:56 +0000 (04:25 -0400)]
[gn build] Port 1c9a8004ed88

17 months ago[Clang][C++20] Error out if parameter types of a defaulted comparion operator are...
Jens Massberg [Tue, 23 May 2023 11:12:01 +0000 (13:12 +0200)]
[Clang][C++20] Error out if parameter types of a defaulted comparion operator are not all the same.

This fixes #62880

Differential Revision: https://reviews.llvm.org/D151200

17 months ago[LVI] Don't compute range on not guaranteed not to be undef condition in SelectInst
luxufan [Wed, 24 May 2023 07:46:44 +0000 (15:46 +0800)]
[LVI] Don't compute range on not guaranteed not to be undef condition in SelectInst

Fixes:https://github.com/llvm/llvm-project/issues/62901

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D151295

17 months ago[LoopUnroll] Peel iterations based on select conditions
Joshua Cao [Sun, 21 May 2023 20:30:26 +0000 (13:30 -0700)]
[LoopUnroll] Peel iterations based on select conditions

This also allows us to peel loops with a `select`:
```
for (int i = 0; i <= N; ++i);
  f3(i == 0 ? a : b); // select instruction
```
into:
```
f3(a); // peel one iteration
for (int i = 1; i <= N; ++i)
  f3(b);
```

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D151052

17 months ago[LoopUnroll] Add tests for peeling iterations based on select, and, or
Joshua Cao [Sat, 20 May 2023 20:07:19 +0000 (20:07 +0000)]
[LoopUnroll] Add tests for peeling iterations based on select, and, or
conditions

17 months ago[clangd] Fix add-using tweak on declrefs with template arguments
Kadir Cetinkaya [Wed, 24 May 2023 07:46:08 +0000 (09:46 +0200)]
[clangd] Fix add-using tweak on declrefs with template arguments

Differential Revision: https://reviews.llvm.org/D151303

17 months ago[InstCombine] Fix crash due to early extractvalue removal
Nikita Popov [Wed, 24 May 2023 07:52:43 +0000 (09:52 +0200)]
[InstCombine] Fix crash due to early extractvalue removal

Fixes the issue reported at https://github.com/llvm/llvm-project/commit/4b8320868c9e32d1448c81ca76dba2a6b9f374cd#commitcomment-114671248.

The extractvalue instructions may still be used by the calling code
in some cases. Rather than trying to figure out which extracts are
safe to remove and which aren't, add them to the worklist so they
will get DCEd by the main loop.

17 months agoValueTracking: Handle constrained_sqrt in computeKnownFPClass
Matt Arsenault [Thu, 13 Apr 2023 14:25:18 +0000 (10:25 -0400)]
ValueTracking: Handle constrained_sqrt in computeKnownFPClass

With this, the body of CannotBeNegativeZero can be dropped.

17 months agoAMDGPU: Drop FP_ROUND second value check
Matt Arsenault [Tue, 23 May 2023 10:04:39 +0000 (11:04 +0100)]
AMDGPU: Drop FP_ROUND second value check

This doesn't mean what I thought it meant and is an optimization
hint flag.

17 months agoInline: Convert test to generated checks
Matt Arsenault [Tue, 23 May 2023 14:48:38 +0000 (15:48 +0100)]
Inline: Convert test to generated checks

17 months agoConvert unit test to opaque pointers
Matt Arsenault [Tue, 23 May 2023 09:36:07 +0000 (10:36 +0100)]
Convert unit test to opaque pointers

17 months agoRecommit [C++20] [Modules] Serialize the evaluated constant values for VarDecl
Chuanqi Xu [Wed, 24 May 2023 02:13:31 +0000 (10:13 +0800)]
Recommit [C++20] [Modules] Serialize the evaluated constant values for VarDecl

Close https://github.com/llvm/llvm-project/issues/62796.

Previously, we didn't serialize the evaluated result for VarDecl. This
caused the compilation of template metaprogramming become slower than
expect. This patch fixes the issue.

This is a recommit tested with asan built clang.

17 months ago[mlir] [sroa] Add support for MemRef.
Théo Degioanni [Wed, 24 May 2023 07:25:02 +0000 (07:25 +0000)]
[mlir] [sroa] Add support for MemRef.

This patch implements SROA interfaces for MemRef, up to a given fixed
size.

Reviewed By: gysit, Dinistro

Differential Revision: https://reviews.llvm.org/D151102

17 months ago[AMDGPU] Check if register is non-null before calling isSubRegisterEq (NFCI)
Sergei Barannikov [Wed, 24 May 2023 05:10:35 +0000 (08:10 +0300)]
[AMDGPU] Check if register is non-null before calling isSubRegisterEq (NFCI)

D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D151289

17 months ago[IR] Use LLVMContext::MD_nontemporal (NFC)
Kazu Hirata [Wed, 24 May 2023 06:37:38 +0000 (23:37 -0700)]
[IR] Use LLVMContext::MD_nontemporal (NFC)

17 months ago[clang][X86] Add __cpuidex function to cpuid.h
Aiden Grossman [Wed, 24 May 2023 02:46:38 +0000 (02:46 +0000)]
[clang][X86] Add __cpuidex function to cpuid.h

MSVC has a `__cpuidex` function implemented to call the underlying cpuid
instruction which accepts a leaf, subleaf, and data array that the output
data is written into. This patch adds this functionality into clang
under the cpuid.h header. This also makes clang match GCC's behavior.
GCC has had `__cpuidex` in its cpuid.h since 2020.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D150646

17 months ago[gn build] Port bea2ff655068
LLVM GN Syncbot [Wed, 24 May 2023 05:58:04 +0000 (05:58 +0000)]
[gn build] Port bea2ff655068

17 months agoRevert "[C++20] [Modules] Serialize the evaluated constant values for VarDecl"
Chuanqi Xu [Wed, 24 May 2023 05:55:45 +0000 (13:55 +0800)]
Revert "[C++20] [Modules] Serialize the evaluated constant values for VarDecl"

This reverts commit c0d6f85e3ae8bcfdb7217d165314f01c1a4af9ae. The asan
bot detected a memory leak after this patch. Revert it for now.

17 months ago[libc++] Untangles invoke.
Mark de Wever [Thu, 20 Apr 2023 19:03:40 +0000 (21:03 +0200)]
[libc++] Untangles invoke.

The type traits parts are moved to a type_traits detail header.
This was discovered while working on modules.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D150538

17 months ago[libc++] Adds C++26 support.
Mark de Wever [Sat, 20 May 2023 10:38:57 +0000 (12:38 +0200)]
[libc++] Adds C++26 support.

Clang has been updated to support C++26, this adds the same support for
libc++. At the moment C++23 and C++26 are identical. During the next
plenary in June the first C++26 papers will be voted on.

Note like Clang this patch uses C++26 is the internal part and C++2c in
the user visible part.

Depends on D150795

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D151026

17 months agoRevert "[clang-format] Fix indentation for selective formatting"
Owen Pan [Wed, 24 May 2023 05:11:45 +0000 (22:11 -0700)]
Revert "[clang-format] Fix indentation for selective formatting"

This reverts commit 72ab89e3197cc1bee3b9774edb504690e3e43ed0.

Reverted due to bots failures e.g.
https://lab.llvm.org/buildbot/#/builders/139/builds/41339.

17 months ago[lldb] Fix typos in documentation
Kazu Hirata [Wed, 24 May 2023 05:10:59 +0000 (22:10 -0700)]
[lldb] Fix typos in documentation

17 months ago[libc++][NFC] Refactor helper method into the Lit test format
Louis Dionne [Tue, 23 May 2023 18:39:37 +0000 (11:39 -0700)]
[libc++][NFC] Refactor helper method into the Lit test format

Differential Revision: https://reviews.llvm.org/D151238

17 months ago[libc++] Complete refactor of tests for operator new
Louis Dionne [Thu, 11 May 2023 14:05:25 +0000 (10:05 -0400)]
[libc++] Complete refactor of tests for operator new

I stumbled upon the `operator new` and `operator new[]` tests while
investigating an issue with `operator new` when exceptions are disabled,
and I realized that our test coverage was incomplete. This patch refactors
all the `operator new` and `operator new[]` tests to add consistency and
better coverage for scenarios in which it should be possible to override
an operator indirectly by defining another one (for example new(size_t, nothrow)
should use new(size_t) if it has been provided).

This is intended to be a NFC setting up the terrain for some refactoring
work and bug fix in operator new.

Differential Revision: https://reviews.llvm.org/D150408

17 months ago[TableGen] Unify the priority of variables
wangpc [Wed, 24 May 2023 03:32:25 +0000 (11:32 +0800)]
[TableGen] Unify the priority of variables

In D148197, we have made `defvar` statement able to refer to class
template arguments. However, the priority of class/multiclass
template argument is higher than variables defined by `defvar`, which
is a little counterintuitive.

In this patch, we unify the priority of variables. Each pair of
braces introduces a new scope, which may contain some additional
variables like template arguments, loop iterators, etc. We can
define local variables inside this scope via `defvar` and these
variables are of higher priority than additional variables. This
means that `defvar` will shadow additional variables with the same
name. The scope can be nested, and we use the innermost variable.

This make variables defined by `defvar` prior to class/multiclass
template arguments, loop iterators, etc. The shadow rules now are:

* `V` in a record body shadows a global `V`.

* `V` in a record body shadows template argument `V`.

* `V` in template arguments shadows a global `V`.

* `V` in a `foreach` statement list shadows any `V` in surrounding record or global scopes.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D149016

17 months ago[BBUtils][NFC] Delete SplitBlockAndInsertIfThen with DT.
Joshua Cao [Fri, 28 Apr 2023 06:43:01 +0000 (23:43 -0700)]
[BBUtils][NFC] Delete SplitBlockAndInsertIfThen with DT.

The method is marked for deprecation. Delete the method and move all of
its consumers to use the DomTreeUpdater version.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D149428

17 months ago[NFC] Fix the warning for dangling pointer for c0d6f85e3ae8bc
Chuanqi Xu [Wed, 24 May 2023 03:41:26 +0000 (11:41 +0800)]
[NFC] Fix the warning for dangling pointer for c0d6f85e3ae8bc

The bot notes a warning-converted-error for the dangling pointer. And
the patch fixes that.

17 months ago[clang-format] Fix indentation for selective formatting
Sedenion [Wed, 24 May 2023 02:10:14 +0000 (19:10 -0700)]
[clang-format] Fix indentation for selective formatting

The problem was that the LevelIndentTracker remembered
the indentation level of previous deeper levels when
leaving a scope. Afterwards, when it entered again a
deeper level, it blindly reused the the previous
indentation level. In case of the --lines option
configured such that the previous deeper level was not
formatted, that previous level was whatever happened
to be there in the source code. The formatter simply
believed it.

This is fixed by letting the LevelIndentTracker forget
the previous deeper levels when stepping out of them
(=> change in LevelIndentTracker::nextLine()).
Note that this used to be the case until LLVM 14.0.6,
but was changed in
https://github.com/llvm/llvm-project/issues/56352 to
fix a crash. Our commit here essentially reverts that
crash fix. It seemed to have been incorrect. The proper
fix is to set the AnnotedLine::Level of joined lines
correctly (=> change in LineJoiner::join()).

See
https://github.com/llvm/llvm-project/issues/59178#issuecomment-1542637781
for some more details.

Fixes #58464.
Fixes #59178.

Differential Revision: https://reviews.llvm.org/D151047

17 months ago[C++20] [Modules] Serialize the evaluated constant values for VarDecl
Chuanqi Xu [Wed, 24 May 2023 02:13:31 +0000 (10:13 +0800)]
[C++20] [Modules] Serialize the evaluated constant values for VarDecl

Close https://github.com/llvm/llvm-project/issues/62796.

Previously, we didn't serialize the evaluated result for VarDecl. This
caused the compilation of template metaprogramming become slower than
expect. This patch fixes the issue.

17 months ago[LegalizeType][X86] Support WidenVecRes_AssertZext and SplitVecRes_AssertZext for...
Bing1 Yu [Wed, 24 May 2023 02:15:23 +0000 (10:15 +0800)]
[LegalizeType][X86] Support WidenVecRes_AssertZext and SplitVecRes_AssertZext for ISD::AssertZext during LegalizeType procedure

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D150941

17 months ago[Propeller] Add HasIndirectBranch to BBEntry::Metadata.
Rahman Lavaee [Wed, 24 May 2023 01:44:10 +0000 (01:44 +0000)]
[Propeller] Add HasIndirectBranch to BBEntry::Metadata.

This information helps to avoid considering cloning for blocks with indirect branches.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D150611

17 months ago[clang-format] Adjust braced list detection (reland 6dcde65)
Galen Elias [Tue, 23 May 2023 03:11:17 +0000 (20:11 -0700)]
[clang-format] Adjust braced list detection (reland 6dcde65)

This is a retry of https://reviews.llvm.org/D114583, which was backed
out for regressions.

Clang Format is detecting a nested scope followed by another open brace
as a braced initializer list due to incorrectly thinking it's matching a
braced initializer at the end of a constructor initializer list which is
followed by the body open brace.

Unfortunately, UnwrappedLineParser isn't doing a very detailed parse, so
it's not super straightforward to distinguish these cases given the
current structure of calculateBraceTypes. My current hypothesis is that
these can be disambiguated by looking at the token preceding the
l_brace, as initializer list parameters will be preceded by an
identifier, but a scope block generally will not (barring the MACRO
wildcard).

To this end, I am adding tracking of the previous token to the LBraceStack
to help scope this particular case.

TokenAnnotatorTests cherry picked from https://reviews.llvm.org/D150452.

Fixes #33891.
Fixes #52911.

Differential Revision: https://reviews.llvm.org/D150403

17 months ago[clang-format] Revert 6dcde65 due to missing commit message title
Owen Pan [Wed, 24 May 2023 01:33:37 +0000 (18:33 -0700)]
[clang-format] Revert 6dcde65 due to missing commit message title

This reverts commit 6dcde658b2380d7ca1451ea5d1099af3e294ea16.

17 months ago[mlir][sparse][gpu] fix F32 bug for SpMV and SpMM
Aart Bik [Tue, 23 May 2023 20:47:10 +0000 (13:47 -0700)]
[mlir][sparse][gpu] fix F32 bug for SpMV and SpMM

The alpha/beta variables, residing on the host, should have the
32-bit or 64-bit width of the result type. It was formerly always
passed as double.

Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D151255

17 months ago[compiler-rt] Allow 64-bit sanitizer allocator to be used if using RISCV64 and Fuchsia
Leonard Chan [Tue, 23 May 2023 23:38:29 +0000 (23:38 +0000)]
[compiler-rt] Allow 64-bit sanitizer allocator to be used if using RISCV64 and Fuchsia

This way, Fuchsia can use the 64-bit allocator settings in D151157 without changing the default behavior for others.

Differential Revision: https://reviews.llvm.org/D151159

17 months ago[CodeGen] Fix the type of the constant that is used to zero-initialize a
Akira Hatanaka [Tue, 23 May 2023 23:32:19 +0000 (16:32 -0700)]
[CodeGen] Fix the type of the constant that is used to zero-initialize a
flexible array member

A zero-element array type was incorrectly being used when an incomplete
array was being initialized with a non-empty initializer.

This fixes an assertion failure in AddInitializerToStaticVarDecl. See
the discussion here: https://reviews.llvm.org/D123649#4362210

Differential Revision: https://reviews.llvm.org/D151172

17 months ago[RISCV] Expand rotate by non-constant for XTHeadBb during lowering.
Craig Topper [Tue, 23 May 2023 23:31:22 +0000 (16:31 -0700)]
[RISCV] Expand rotate by non-constant for XTHeadBb during lowering.

Avoids multi instruction isel patterns and enables mask optimizations
on shift amount.

Reviewed By: philipp.tomsich

Differential Revision: https://reviews.llvm.org/D151263

17 months agoRevert "[lldb] Move PassthroughScriptedProcess to `lldb.scripted_process` module"
Med Ismail Bennani [Tue, 23 May 2023 23:01:39 +0000 (16:01 -0700)]
Revert "[lldb] Move PassthroughScriptedProcess to `lldb.scripted_process` module"

This reverts commit 273a2d337f675f3ee050f281b1fecc3e806b9a3c, since it
might be the cause for `TestStackCoreScriptedProcess` and
`TestInteractiveScriptedProcess` failures on GreenDragon:

https://green.lab.llvm.org/green/job/lldb-cmake/55460/`

17 months ago[flang][runtime] Complete partial output records when positioning/closing after non...
Peter Klausler [Mon, 22 May 2023 18:56:14 +0000 (11:56 -0700)]
[flang][runtime] Complete partial output records when positioning/closing after non-advancing output

Before positioning or closing a unit after a non-advancing output statement
has left a partial record in its buffer, complete the record by calling
AdvanceRecord().  Fixes https://github.com/llvm/llvm-project/issues/59761.

Differential Revision: https://reviews.llvm.org/D151134

17 months ago[mlir][sparse] extend unpack operation to unpack arbitrary encodings.
Peiming Liu [Sat, 20 May 2023 00:55:44 +0000 (00:55 +0000)]
[mlir][sparse] extend unpack operation to unpack arbitrary encodings.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D151174

17 months agoAdd support for salvaging debug info from icmp instrcuctions.
Shubham Sandeep Rastogi [Fri, 5 May 2023 00:48:19 +0000 (17:48 -0700)]
Add support for salvaging debug info from icmp instrcuctions.

salvageDebugInfo is a function that allows us to reatin debug info for
instructions that have been optimized out. Currently, it doesn't support
salvaging the debug information from icmp instrcutions, but DWARF
expressions can emulate an icmp by using the DWARF conditional
expressions. This patch adds support for salvaging debug information
from icmp instructions.

Differential Revision: https://reviews.llvm.org/D150216

17 months ago[bazel] Add clang-offload-packager and clang-linker-wrapper
Aaron Siddhartha Mondal [Tue, 23 May 2023 22:24:05 +0000 (00:24 +0200)]
[bazel] Add clang-offload-packager and clang-linker-wrapper

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D151131

17 months ago[lldb][NFCI] Remove unused member from ObjectFileMachO
Alex Langford [Tue, 23 May 2023 17:35:32 +0000 (10:35 -0700)]
[lldb][NFCI] Remove unused member from ObjectFileMachO

From what I can see, `m_mach_segments` is completely unused. Let's
remove it.

Differential Revision: https://reviews.llvm.org/D151236

17 months ago[flang][openacc][NFC] Add API to create acc.private.recipe from FIR type
Valentin Clement [Tue, 23 May 2023 22:08:27 +0000 (15:08 -0700)]
[flang][openacc][NFC] Add API to create acc.private.recipe from FIR type

Simply make the creation of acc.private.recipe accesible through an API.
This will be useful when we will implement passes like the implicit
privatization.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D151230

17 months ago[flang] Do not omit fir.ref in getTypeAsString
Valentin Clement [Tue, 23 May 2023 22:07:19 +0000 (15:07 -0700)]
[flang] Do not omit fir.ref in getTypeAsString

Do not omit fir.ref when creating the string representation to we can
have different representation for `!fir.ref<i32>` and `i32`.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D151261

17 months agoReland: [clang][ExprConstant] fix __builtin_object_size for flexible array members
Nick Desaulniers [Tue, 23 May 2023 21:41:43 +0000 (14:41 -0700)]
Reland: [clang][ExprConstant] fix __builtin_object_size for flexible array members

As reported by @kees, GCC treats __builtin_object_size of structures
containing flexible array members (aka arrays with incomplete type) not
just as the sizeof the underlying type, but additionally the size of the
members in a designated initializer list.

Fixes: https://github.com/llvm/llvm-project/issues/62789

Reviewed By: erichkeane, efriedma

Differential Revision: https://reviews.llvm.org/D150892

17 months ago[flang] Add IndexType support in getTypeAsString
Valentin Clement [Tue, 23 May 2023 21:14:59 +0000 (14:14 -0700)]
[flang] Add IndexType support in getTypeAsString

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D151250

17 months ago[mlir][Vector] Extend xfer drop unit dim patterns
Diego Caballero [Tue, 23 May 2023 20:51:09 +0000 (20:51 +0000)]
[mlir][Vector] Extend xfer drop unit dim patterns

This patch extends the transfer drop unit dim patterns to support cases where the vector shape should also be reduced
(e.g., transfer_read(memref<1x4x1xf32>, vector<1x4x1xf32>) -> transfer_read(memref<4xf32>, vector<4xf32>).

Reviewed By: hanchung, pzread

Differential Revision: https://reviews.llvm.org/D151007

17 months ago[llvm-debuginfo-analyzer] Support both Reference and Type attrs in single DIE
Scott Linder [Tue, 23 May 2023 20:31:18 +0000 (20:31 +0000)]
[llvm-debuginfo-analyzer] Support both Reference and Type attrs in single DIE

Relax the assumption that at most one Reference-or-Type-like attribute is
present on a DWARF DIE.

Add support for at most one Type attribute (i.e. DW_AT_import xor
DW_AT_type) and separately at most one Reference attribute (i.e.
DW_AT_specification xor DW_AT_abstract_origin xor ...).

Update comment describing old assumption and tag it as a "FIXME" to
reflect the fact that this is perhaps still not general enough.

Add a test based on the case which led me to encounter the bug in the
wild.

Reviewed By: CarlosAlbertoEnciso

Differential Revision: https://reviews.llvm.org/D150713

17 months ago[lld-macho] Add support for .so file discovery
Keith Smiley [Mon, 22 May 2023 20:28:42 +0000 (13:28 -0700)]
[lld-macho] Add support for .so file discovery

While not the recommended extension on macOS .so is supported by ld64.
This mirrors that behavior.

Related report: https://github.com/bazelbuild/bazel/issues/18464

Differential Revision: https://reviews.llvm.org/D151147

17 months ago[lld][ELF] Do not emit warning for NOLOAD output sections
Leonard Chan [Tue, 23 May 2023 20:40:22 +0000 (20:40 +0000)]
[lld][ELF] Do not emit warning for NOLOAD output sections

Much of NOLOAD's intended use is to explicitly change the type of an
output section, so we shouldn't flag these as warnings.

Differential Revision: https://reviews.llvm.org/D151144

17 months ago[libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes that we...
Nikolas Klauser [Tue, 23 May 2023 15:45:52 +0000 (08:45 -0700)]
[libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes that we have instantiated externally

To make sure all member functions that require it are marked `_LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION` I compared the output of `objdump --syms lib/libc++.1.0.dylib` before and after, ignoring addresses.

Reviewed By: #libc, ldionne

Spies: Mordante, libcxx-commits, ldionne, arichardson, mstorsjo

Differential Revision: https://reviews.llvm.org/D150896

17 months ago[TableGen] Filter duplicate predicates in PatternToMatch::getPredicateRecords.
Craig Topper [Tue, 23 May 2023 20:32:18 +0000 (13:32 -0700)]
[TableGen] Filter duplicate predicates in PatternToMatch::getPredicateRecords.

Recent changes to RISC-V cause the same predicate to appear in the
predicate list multiple times in some cases. This patch filters the
duplicates to reduce the number of predicate string variations.

17 months ago[X86] Use the CFA when appropriate for better variable locations around calls.
Kyle Huey [Tue, 23 May 2023 17:44:25 +0000 (17:44 +0000)]
[X86] Use the CFA when appropriate for better variable locations around calls.

Without frame pointers, the locations of variables on the stack are emitted
relative to the stack pointer (via the stack pointer being the value of
DW_AT_frame_base on the subprogram). If a call modifies the stack pointer
this results in the locations being wrong and the debugger displaying the
wrong values for variables.

By using DW_OP_call_frame_cfa in these situations the emitted location for
the variable will automatically handle changes in the stack pointer
(provided LLVM is emitting the correct CFI directives elsewhere, of course).
The CFA needs to be adjusted for the size of the stack frame (including the
return address) to allow the variable locations themselves to remain
unchanged by this patch.

Certain LLDB features cannot cope with DW_OP_call_frame_cfa, so this change
is heuristically limited to the cases where it's necessary for correctness
to minimize the fallout there.

Reviewed By: #debug-info, scott.linder, jryans, jmorse

Differential Revision: https://reviews.llvm.org/D143463

17 months ago[Sema] `setInvalidDecl` for error deduction declaration
Congcong Cai [Tue, 23 May 2023 20:14:10 +0000 (22:14 +0200)]
[Sema] `setInvalidDecl` for error deduction declaration

Fixed: https://github.com/llvm/llvm-project/issues/62408
`setInvalidDecl` for invalid `CXXDeductionGuideDecl` to
avoid crashes during semantic analysis.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D149516

17 months ago[MLIR] Update Bazel build to remove references to PybindUtils.cpp
Eugene Burmako [Tue, 23 May 2023 19:34:12 +0000 (12:34 -0700)]
[MLIR] Update Bazel build to remove references to PybindUtils.cpp

This file has been removed in https://reviews.llvm.org/D151167.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D151242

17 months ago[VPlan] Print IR flags for VPRecipeWithIRFlags.
Florian Hahn [Tue, 23 May 2023 19:36:15 +0000 (20:36 +0100)]
[VPlan] Print IR flags for VPRecipeWithIRFlags.

Now that IR flags are modeled as part of VPRecipeWithIRFlags, include
the flags when printing recipes.

Depends on D150027.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D150029

17 months ago[clang-tidy] Ignore implicit code in bugprone-branch-clone
Piotr Zegar [Tue, 23 May 2023 18:45:22 +0000 (18:45 +0000)]
[clang-tidy] Ignore implicit code in bugprone-branch-clone

Implicit code like, template instances, compiler generated
code are not excluded in this check by using
TK_IgnoreUnlessSpelledInSource.

Fixes #62693

Reviewed By: donat.nagy

Differential Revision: https://reviews.llvm.org/D151133

17 months ago[clang-tidy] Improve bugprone-branch-clone with support for fallthrough attribute
Piotr Zegar [Tue, 23 May 2023 18:44:55 +0000 (18:44 +0000)]
[clang-tidy] Improve bugprone-branch-clone with support for fallthrough attribute

Ignore duplicated switch cases with [[fallthrough]] attribute to reduce false positives.

Fixes: #47588

Reviewed By: donat.nagy

Differential Revision: https://reviews.llvm.org/D147889

17 months ago[RISCV] Add scalable vector cast cost model tests. NFC
Craig Topper [Tue, 23 May 2023 19:14:07 +0000 (12:14 -0700)]
[RISCV] Add scalable vector cast cost model tests. NFC

Reviewed By: fakepaper56

Differential Revision: https://reviews.llvm.org/D151132

17 months ago[CodeGen] Fix crash in CodeGenPrepare::optimizeGatherScatterInst.
Joshua Cranmer [Tue, 23 May 2023 19:00:19 +0000 (15:00 -0400)]
[CodeGen] Fix crash in CodeGenPrepare::optimizeGatherScatterInst.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D151141

17 months ago[ValueTracking] Use `select` condition to help determine if `select` is non-zero
Noah Goldstein [Tue, 23 May 2023 16:18:01 +0000 (11:18 -0500)]
[ValueTracking] Use `select` condition to help determine if `select` is non-zero

In `select c, x, y` the condition `c` dominates the resulting `x` or
`y` chosen by the `select`. This adds logic to `isKnownNonZero` to try
and use the `icmp` for the `c` condition to see if it implies the
select `x` or `y` are known non-zero.

For example in:
    ```
    %c = icmp ugt i8 %x, %C
    %r = select i1 %c, i8 %x, i8 %y
    ```
    The true arm of select `%x` is non-zero (when "returned" by the
    `select`) because `%c` being true implies `%x` is non-zero.

Alive2 Links (with `x {pred} C`):
    - EQ  iff `C != 0`:
        - https://alive2.llvm.org/ce/z/umLabn
    - NE  iff `C == 0`:
        - https://alive2.llvm.org/ce/z/DQvy8Y
    - UGT [always]:
        - https://alive2.llvm.org/ce/z/HBkjgQ
    - UGE iff `C != 0`:
        - https://alive2.llvm.org/ce/z/LDNifB
    - SGT iff `C s>= 0`:
        - https://alive2.llvm.org/ce/z/QzWDj3
    - SGE iff `C s> 0`:
        - https://alive2.llvm.org/ce/z/rR4g3D
    - SLT iff `C s<= 0`:
        - https://alive2.llvm.org/ce/z/uysayx
    - SLE iff `C s< 0`:
        - https://alive2.llvm.org/ce/z/2jYc7e

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D147900

17 months ago[ValueTracking] Add tests for using condition in select for non-zero analysis; NFC
Noah Goldstein [Sun, 30 Apr 2023 15:44:35 +0000 (10:44 -0500)]
[ValueTracking] Add tests for using condition in select for non-zero analysis; NFC

Differential Revision: https://reviews.llvm.org/D147899

17 months ago[ValueTracking] Use `KnownBits` functions for `computeKnownBits` of saturating add...
Noah Goldstein [Tue, 23 May 2023 16:11:23 +0000 (11:11 -0500)]
[ValueTracking] Use `KnownBits` functions for `computeKnownBits` of saturating add/sub functions

The knownbits implementation covers all the cases previously handled
by `uadd.sat`/`usub.sat` as well some additional ones. We previously
were not handling the `ssub.sat`/`sadd.sat` cases at all.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D150103

17 months ago[KnownBits] Add implementations for saturating add/sub functions
Noah Goldstein [Tue, 23 May 2023 16:13:13 +0000 (11:13 -0500)]
[KnownBits] Add implementations for saturating add/sub functions

These where previously missing. Even in the case where overflow is
indeterminate we can still deduce some of the low/high bits.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D150102

17 months ago[ValueTracking] Add tests for knownbits of saturating add/sub functions; NFC
Noah Goldstein [Tue, 23 May 2023 16:11:14 +0000 (11:11 -0500)]
[ValueTracking] Add tests for knownbits of saturating add/sub functions; NFC

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D150101

17 months ago[KnownBits] Improve implementation of `KnownBits::abs`
Noah Goldstein [Tue, 23 May 2023 16:11:09 +0000 (11:11 -0500)]
[KnownBits] Improve implementation of `KnownBits::abs`

`abs` preserves the lowest set bit, so if we know the lowest set bit,
set it in the output.

As well, implement the case where the operand is known negative.

Reviewed By: foad, RKSimon

Differential Revision: https://reviews.llvm.org/D150100

17 months ago[NFC][CLANG] Fix issue with dereference null return value found by Coverity static...
Manna, Soumi [Tue, 23 May 2023 18:41:28 +0000 (11:41 -0700)]
[NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

Reported by Coverity static analyzer tool:

Inside "ItaniumCXXABI.cpp" file, in <unnamed>::ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(clang::CodeGen::CodeGenFunction &, clang::Expr const *, clang::CodeGen::Address, llvm::Value *&, llvm::Value *, clang::MemberPointerType const *): Return value of function which returns null is dereferenced without checking.

   //returned_null: getAs returns nullptr (checked 130 out of 156 times).
   //var_assigned: Assigning: FPT = nullptr return value from getAs.
   const FunctionProtoType *FPT =
     MPT->getPointeeType()->getAs<FunctionProtoType>();
  auto *RD =
     cast<CXXRecordDecl>(MPT->getClass()->castAs<RecordType>()->getDecl());

  // Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr FPT when calling arrangeCXXMethodType.
   llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
       CGM.getTypes().arrangeCXXMethodType(RD, FPT, /*FD=*/nullptr));

This patch uses castAs instead of getAs which will assert if the type doesn't match.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D151054

17 months ago[gn build] Port f237513cda8e
LLVM GN Syncbot [Tue, 23 May 2023 18:40:17 +0000 (18:40 +0000)]
[gn build] Port f237513cda8e

17 months ago[LLDB] Add some declarations related to REPL support for mojo
walter erquinigo [Wed, 10 May 2023 20:41:07 +0000 (15:41 -0500)]
[LLDB] Add some declarations related to REPL support for mojo

This simple diff declares some enum values needed to create a REPL for the mojo language.

Differential Revision: https://reviews.llvm.org/D150303

17 months ago[RISCV][GlobalISel] Add lowerReturn for calling conv
Nitin John Raj [Tue, 23 May 2023 17:47:53 +0000 (10:47 -0700)]
[RISCV][GlobalISel] Add lowerReturn for calling conv

Add minimal support to lower return, and introduce an OutgoingValueHandler and an OutgoingValueAssigner for returns.

Supports return values with integer, pointer and aggregate types.

(Update of D69808 - avoiding commandeering that revision)

Co-authored By: lewis-revill

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D117318

17 months agohwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]
Thurston Dang [Fri, 19 May 2023 23:19:44 +0000 (23:19 +0000)]
hwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]

This patch does the bare minimum to import sanitizer_common_interceptors, but
without actually enabling any interceptors or meaningfully defining the
COMMON_INTERCEPT macros.

This will allow selectively enabling sanitizer_common interceptors (if the
appropriate macros are defined), as suggested by Vitaly in D149701.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D150708