Joel E. Denny [Fri, 12 Jun 2020 13:27:03 +0000 (09:27 -0400)]
[lit] Fix handling of various keyword parse errors
In TestRunner.py, D78589 extracts a `_parseKeywords` function from
`parseIntegratedTestScript`, which then expects `_parseKeywords` to
always return a list of keyword/value pairs. However, the extracted
code sometimes returns an unresolved `lit.Test.Result` on a keyword
parsing error, which then produces a stack dump instead of the
expected diagnostic.
This patch fixes that, makes the style of those diagnostics more
consistent, and extends the lit test suite to cover them.
Reviewed By: ldionne
Differential Revision: https://reviews.llvm.org/D81665
Marco Elver [Fri, 12 Jun 2020 12:58:00 +0000 (14:58 +0200)]
[ASan][NFC] Refactor redzone size calculation
Refactor redzone size calculation. This will simplify changing the
redzone size calculation in future.
Note that AddressSanitizer.cpp violates the latest LLVM style guide in
various ways due to capitalized function names. Only code related to the
change here was changed to adhere to the style guide.
No functional change intended.
Reviewed By: andreyknvl
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81367
Haojian Wu [Thu, 23 Apr 2020 09:14:01 +0000 (11:14 +0200)]
[AST][RecoveryExpr] Build recovery expressions by default for C++.
Reland https://reviews.llvm.org/D76696
All known crashes have been fixed, another attemption.
We have rolled out this to all internal users for a while, didn't see
big issues, we consider it is stable enough.
Reviewed By: sammccall
Subscribers: rsmith, hubert.reinterpretcast, ebevhan, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78350
Xing GUO [Fri, 12 Jun 2020 13:10:14 +0000 (21:10 +0800)]
[ObjectYAML][DWARF] Add one helper function `writeInitialLength()`. NFC.
Kirstóf Umann [Wed, 27 May 2020 10:27:32 +0000 (12:27 +0200)]
[analyzer][NFC] Don't allow dependency checkers to emit diagnostics
The thrilling conclusion to the barrage of patches I uploaded lately! This is a
big milestone towards the goal set out in http://lists.llvm.org/pipermail/cfe-dev/2019-August/063070.html.
I hope to accompany this with a patch where the a coreModeling package is added,
from which package diagnostics aren't allowed either, is an implicit dependency
of all checkers, and the core package for the first time can be safely disabled.
Differential Revision: https://reviews.llvm.org/D78126
Erich Keane [Thu, 28 May 2020 17:25:53 +0000 (10:25 -0700)]
(PR46111) Properly handle elaborated types in an implicit deduction guide
As reported in PR46111, implicit instantiation of a deduction guide
causes us to have an elaborated type as the parameter, rather than the
dependent type.
After review and feedback from @rsmith, this patch solves this problem
by wrapping the value in an uninstantiated typedef/type-alias that is
instantiated when required later.
Differential Revision: https://reviews.llvm.org/D80743
Kirstóf Umann [Wed, 27 May 2020 10:29:47 +0000 (12:29 +0200)]
[analyzer] Introduce weak dependencies to express *preferred* checker callback evaluation order
Checker dependencies were added D54438 to solve a bug where the checker names
were incorrectly registered, for example, InnerPointerChecker would incorrectly
emit diagnostics under the name MallocChecker, or vice versa [1]. Since the
system over the course of about a year matured, our expectations of what a role
of a dependency and a dependent checker should be crystallized a bit more --
D77474 and its summary, as well as a variety of patches in the stack
demonstrates how we try to keep dependencies to play a purely modeling role. In
fact, D78126 outright forbids diagnostics under a dependency checkers name.
These dependencies ensured the registration order and enabling only when all
dependencies are satisfied. This was a very "strong" contract however, that
doesn't fit the dependency added in D79420. As its summary suggests, this
relation is directly in between diagnostics, not modeling -- we'd prefer a more
specific warning over a general one.
To support this, I added a new dependency kind, weak dependencies. These are not
as strict of a contract, they only express a preference in registration order.
If a weak dependency isn't satisfied, the checker may still be enabled, but if
it is, checker registration, and transitively, checker callback evaluation order
is ensured.
If you are not familiar with the TableGen changes, a rather short description
can be found in the summary of D75360. A lengthier one is in D58065.
[1] https://www.youtube.com/watch?v=eqKeqHRAhQM
Differential Revision: https://reviews.llvm.org/D80905
Simon Pilgrim [Fri, 12 Jun 2020 10:30:00 +0000 (11:30 +0100)]
[X86][SSE] combineX86ShuffleChain - combine INSERT_VECTOR_ELT patterns to INSERTPS
Noticed while trying to cleanup D66004 - if a shuffle operand came from a scalar, we're better off using INSERTPS vs UNPCKLPS as this is more likely to load fold later on. It also matches our existing BUILD_VECTOR lowering.
We can extend this to other PINSRB/D/Q/W cases in the future as the need arises.
Frederik Gossen [Fri, 12 Jun 2020 10:53:15 +0000 (10:53 +0000)]
[MLIR] Add missing traits and assembly format to `shape.from/to_extent_tensor`
Add `NoSideEffect` trait to `shape.to_extent_tensor` and
`shape.from_extent_tensor` and defined custom assembly format for the
operations.
Differential Revision: https://reviews.llvm.org/D81158
Florian Hahn [Fri, 12 Jun 2020 10:15:26 +0000 (11:15 +0100)]
[BreakCritEdges] Add option to opt-out of perserving loop-simplify.
This patch adds a new option to CriticalEdgeSplittingOptions to control
whether loop-simplify form must be preserved. It is them used by GVN to
indicate that loop-simplify form does not have to be preserved.
This fixes a crash exposed by
189efe295b6e.
If the critical edge we are splitting goes from a block inside a loop to
a block outside the loop, splitting the edge will create a new exit
block. As a result, the new block will branch to the original exit
block, which will add a non-loop predecessor, breaking loop-simplify
form. To preserve loop-simplify form, the predecessor blocks of the
original exit are split, but that does not work for blocks with
indirectbr terminators. If preserving loop-simplify form is requested,
bail out , before making any changes.
Reviewers: reames, hfinkel, davide, efriedma
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D81582
Kirstóf Umann [Sun, 31 May 2020 20:26:37 +0000 (22:26 +0200)]
[analyzer][NFC] Change checker dependency unit tests to check for the registration order
Exactly what it says on the tin! "Strong" dependencies are mentioned in contrast
to a new kind of dependency introduced in a followup patch.
Differential Revision: https://reviews.llvm.org/D80901
Xing GUO [Fri, 12 Jun 2020 09:55:27 +0000 (17:55 +0800)]
[ObjectYAML][test] Use a single test file to test the empty 'DWARF' entry.
This patch addresses comments in [D81450](https://reviews.llvm.org/D81450#inline-748745)
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D81529
Alex Bradbury [Fri, 12 Jun 2020 09:26:53 +0000 (10:26 +0100)]
[CodeGen] Increase applicability of ffine-grained-bitfield-accesses for targets with limited native integer widths
As pointed out in PR45708, -ffine-grained-bitfield-accesses doesn't
trigger in all cases you think it might for RISC-V. The logic in
CGRecordLowering::accumulateBitFields checks OffsetInRecord is a legal
integer according to the datalayout. RISC targets will typically only
have the native width as a legal integer type so this check will fail
for OffsetInRecord of 8 or 16 when you would expect the transformation
is still worthwhile.
This patch changes the logic to check for an OffsetInRecord of a at
least 1 byte, that fits in a legal integer, and is a power of 2. We
would prefer to query whether native load/store operations are
available, but I don't believe that is possible.
Differential Revision: https://reviews.llvm.org/D79155
Raphael Isemann [Fri, 12 Jun 2020 09:18:38 +0000 (11:18 +0200)]
Add missing IRBuilder include to IndirectThunks.h
This file didn't build with enabled modules.
Florian Hahn [Fri, 12 Jun 2020 09:16:03 +0000 (10:16 +0100)]
[VPlan] Reject loops without computable backedge taken counts
getOrCreateTripCount is used to generate code for the outer loop, but it
requires a computable backedge taken counts. Check that in the VPlan
native path.
Reviewers: Ayal, gilr, rengolin, sguggill
Reviewed By: sguggill
Differential Revision: https://reviews.llvm.org/D81088
Sebastian Neubauer [Wed, 25 Mar 2020 07:38:22 +0000 (08:38 +0100)]
[AMDGPU] Add G16 support to image instructions
Add G16 feature for GFX10 and support A16 and G16 in GlobalISel.
Differential Revision: https://reviews.llvm.org/D76836
Georgii Rymar [Thu, 11 Jun 2020 20:18:40 +0000 (23:18 +0300)]
[yaml2obj][MachO] - Fix PubName/PubType handling.
`PubName` and `PubType` are optional fields since D80722.
They are defined as:
Optional<PubSection> PubNames;
Optional<PubSection> PubTypes;
And initialized in the following way:
IO.mapOptional("debug_pubnames", DWARF.PubNames);
IO.mapOptional("debug_pubtypes", DWARF.PubTypes);
But problem is that because of the issue in `YAMLTraits.cpp`,
when there are no `debug_pubnames`/`debug_pubtypes` keys in a YAML description,
they are not initialized to `Optional::None` as the code expects, but they
are initialized to default `PubSection()` instances.
Because of this, the `if` condition in the following code is always true:
if (Obj.DWARF.PubNames)
Err = DWARFYAML::emitPubSection(OS, *Obj.DWARF.PubNames,
Obj.IsLittleEndian);
What means `emitPubSection` is always called and it writes few values.
This patch fixes the issue. I've reduced `sizeofcmds` by size of data
previously written because of this bug.
Differential revision: https://reviews.llvm.org/D81686
Raphael Isemann [Fri, 12 Jun 2020 08:08:08 +0000 (10:08 +0200)]
[lldb] Don't print IRForTarget errors directly to the console
Summary:
When we get an error back from IRForTarget we directly print that error to the
debugger output stream instead of putting it in the result object. The result
object only gets a vague "The expression could not be prepared to run in the
target" error message that doesn't actually tell the user what went wrong.
This patch just puts the IRForTarget errors into the status object that is
returned to the caller instead of directly printing it to the debugger. Also
updates one test that now can actually check for the error message it is
supposed to check for (instead of the default error which is all we had before).
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D81654
Chen Zheng [Fri, 12 Jun 2020 06:58:34 +0000 (02:58 -0400)]
[PowerPC] refactor convertToImmediateForm - NFC
This is a NFC patch to make convertToImmediateForm a light wrapper
for converting xform and imm form instructions on PowerPC.
Reviewed By: Steven.zhang
Differential Revision: https://reviews.llvm.org/D80907
Rainer Orth [Fri, 12 Jun 2020 07:56:42 +0000 (09:56 +0200)]
[cmake] Don't pass -z discard-unused to Illumos ld
I'm currently working to port `libc++` to Solaris. There exists a slightly
bitrotten port already, which was done on Illumos, an OpenSolaris
derivative. In order not to break that port with my work, I need to test
the result on both Solaris and Illumos. While doing so, it turned out that
Illumos `ld` doesn't support the `-z discard-sections=unused` option
currently used on SunOS unconditionally.
While there exists a patch
<https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/developer/clang-90/patches/02-cmake_modules_AddLLVM.cmake.patch>
for LLVM 9.0 in the OpenIndiana repository, it apparently hasn't been
submitted upstream and is completely wrong: it replaces
`-z discard-sections=unused` with `-z ignore`. In terms of the equivalent
`gld` options, this means replacing `--gc-sections` with `--as-needed`.
This patch instead tests if the linker actually supports the option before
using it.
Tested on `amd64-pc-solaris2.11` (all of Solaris 11.4, 11.3 and OpenIndiana
2020.04).
Differential Revision: https://reviews.llvm.org/D81545
Martin Boehme [Mon, 8 Jun 2020 13:37:44 +0000 (15:37 +0200)]
[clang] Rename Decl::isHidden() to isUnconditionallyVisible().
Also invert the sense of the return value.
As pointed out by the FIXME that this change resolves, isHidden() wasn't
a very accurate name for this function.
I haven't yet changed any of the strings that are output in
ASTDumper.cpp / JSONNodeDumper.cpp / TextNodeDumper.cpp in response to
whether isHidden() is set because
a) I'm not sure whether it's actually desired to change these strings
(would appreciate feedback on this), and
b) In any case, I'd like to get this pure rename out of the way first,
without any changes to tests. Changing the strings that are output in
the various ...Dumper.cpp files will require changes to quite a few
tests, and I'd like to make those in a separate change.
Differential Revision: https://reviews.llvm.org/D81392
Reviewed By: rsmith
EgorBo [Fri, 12 Jun 2020 07:08:17 +0000 (10:08 +0300)]
[InstCombine] "X - (X / C) * C == 0" to "X & C-1 == 0"
Summary:
"X % C == 0" is optimized to "X & C-1 == 0" (where C is a power-of-two)
However, "X % Y" can also be represented as "X - (X / Y) * Y" so if I rewrite the initial expression:
"X - (X / C) * C == 0" it's not currently optimized to "X & C-1 == 0", see godbolt: https://godbolt.org/z/KzuXUj
This is my first contribution to LLVM so I hope I didn't mess things up
Reviewers: lebedev.ri, spatel
Reviewed By: lebedev.ri
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D79369
EgorBo [Fri, 12 Jun 2020 07:01:21 +0000 (10:01 +0300)]
[NFC][InstCombine] Tests for "X - (X / C) * C == 0" pattern
See https://reviews.llvm.org/D79369
Jonas Devlieghere [Fri, 12 Jun 2020 07:01:54 +0000 (00:01 -0700)]
[llvm/Object] Reimplment basic_symbol_iterator in TapiFile
Use indices into the Symbols vector instead of casting the objects in
the vector and dereferencing std::vector::end().
This change is NFC modulo the Windows failure reported by
llvm-clang-x86_64-expensive-checks-win.
Differential revision: https://reviews.llvm.org/D81717
Kristof Beyls [Thu, 11 Jun 2020 08:23:15 +0000 (09:23 +0100)]
[AArch64] Extend AArch64SLSHardeningPass to harden BLR instructions.
To make sure that no barrier gets placed on the architectural execution
path, each
BLR x<N>
instruction gets transformed to a
BL __llvm_slsblr_thunk_x<N>
instruction, with __llvm_slsblr_thunk_x<N> a thunk that contains
__llvm_slsblr_thunk_x<N>:
BR x<N>
<speculation barrier>
Therefore, the BLR instruction gets split into 2; one BL and one BR.
This transformation results in not inserting a speculation barrier on
the architectural execution path.
The mitigation is off by default and can be enabled by the
harden-sls-blr subtarget feature.
As a linker is allowed to clobber X16 and X17 on function calls, the
above code transformation would not be correct in case a linker does so
when N=16 or N=17. Therefore, when the mitigation is enabled, generation
of BLR x16 or BLR x17 is avoided.
As BLRA* indirect calls are not produced by LLVM currently, this does
not aim to implement support for those.
Differential Revision: https://reviews.llvm.org/D81402
Mehdi Amini [Fri, 12 Jun 2020 05:00:47 +0000 (05:00 +0000)]
Revert "[mlir][spirv] Enhance structure type member decoration handling"
This reverts commit
5d74df5b03e46b7bd3700e3595c7008a6905b288.
This broke the MSVC build: <bits/stdint-uintn.h> isn't available on Windows
Yevgeny Rouban [Fri, 12 Jun 2020 04:55:15 +0000 (11:55 +0700)]
[JumpThreading] Handle zero !prof branch_weights
Avoid division by zero in updatePredecessorProfileMetadata().
Reviewers: yamauchi
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81499
Craig Topper [Fri, 12 Jun 2020 04:14:45 +0000 (21:14 -0700)]
[X86] Add a helper lambda to getIntelProcessorTypeAndSubtype to select feature bits from the correct 32-bit feature variable.
We have three 32 bit variables containing feature bits. But our
enum is a flat 96 bit space. So we need to pick which of the
variables to use based on the bit value. We used to do this
manually by mentioning the correct variable and subtracting an
offset from the enum. But this is error prone.
Vitaly Buka [Fri, 12 Jun 2020 01:56:20 +0000 (18:56 -0700)]
[StackSafety] Fix byval handling
We don't need process paramenters which marked as
byval as we are not going to pass interested allocas
without copying.
If we pass value into byval argument, we just handle that
as Load of corresponding type and stop that branch of analysis.
Alexander Shaposhnikov [Fri, 12 Jun 2020 02:55:04 +0000 (19:55 -0700)]
[llvm-objcopy][MachO] Fix cmdsize of LC_RPATH
Fix the calculation of the field cmdsize (in the function buildRPathLoadCommand)
to account for the null byte terminator.
Patch by Sameer Arora!
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D81575
Jonas Devlieghere [Fri, 12 Jun 2020 02:29:26 +0000 (19:29 -0700)]
[lldb/Test] Fix ASan/TSan workaround for Xcode Python 3
The Python 3 interpreter in Xcode has a relative RPATH and dyld fails to
load it when we copy it into the build directory.
This patch adds an additional check that the copied binary can be
executed. If it doesn't, we assume we're dealing with the Xcode python
interpreter and return the path to the real executable. That is
sufficient for the sanitizers because only system binaries need to be
copied to work around SIP.
This patch also moves all that logic out of LLDBTest and into the lit
configuration so that it's executed only once per test run, instead of
once for every test. Although I didn't benchmark the difference this
should result in a mild speedup.
Differential revision: https://reviews.llvm.org/D81696
Yonghong Song [Thu, 11 Jun 2020 02:13:37 +0000 (19:13 -0700)]
[BPF] fix incorrect type in BPFISelDAGToDAG readonly load optimization
In BPF Instruction Selection DAGToDAG transformation phase,
BPF backend had an optimization to turn load from readonly data
section to direct load of the values. This phase is implemented
before libbpf has readonly section support and before alu32
is supported.
This phase however may generate incorrect type when alu32 is
enabled. The following is an example,
-bash-4.4$ cat ~/tmp2/t.c
struct t {
unsigned char a;
unsigned char b;
unsigned char c;
};
extern void foo(void *);
int test() {
struct t v = {
.b = 2,
};
foo(&v);
return 0;
}
The compiler will turn local variable "v" into a readonly section.
During instruction selection phase, the compiler generates two
loads from readonly section, one 2 byte load or 1 byte load, e.g., for 2 loads,
t8: i32,ch = load<(dereferenceable load 2 from `i8* getelementptr inbounds
(%struct.t, %struct.t* @__const.test.v, i64 0, i32 0)`, align 1),
anyext from i16> t3, GlobalAddress:i64<%struct.t* @__const.test.v> 0, undef:i64
t9: ch = store<(store 2 into %ir.v1.sub1), trunc to i16> t3, t8,
FrameIndex:i64<0>, undef:i64
BPF backend changed t8 to i64 = Constant<2> and eventually the generated machine IR:
t10: i64 = MOV_ri TargetConstant:i64<2>
t40: i32 = SLL_ri_32 t10, TargetConstant:i32<8>
t41: i32 = OR_ri_32 t40, TargetConstant:i64<0>
t9: ch = STH32<Mem:(store 2 into %ir.v1.sub1)> t41, TargetFrameIndex:i64<0>,
TargetConstant:i64<0>, t3
Note that t10 in the above is not correct. The type should be i32 and instruction
should be MOV_ri_32. The reason for incorrect insn selection is BPF insn selection
generated an i64 constant instead of an i32 constant as specified in the original
load instruction. Such incorrect insn sequence eventually caused the following
fatal error when a COPY insn tries to copy a 64bit register to a 32bit subregister.
Impossible reg-to-reg copy
UNREACHABLE executed at ../lib/Target/BPF/BPFInstrInfo.cpp:42!
This patch fixed the issue by using the load result type instead of always i64
when doing readonly load optimization.
Differential Revision: https://reviews.llvm.org/D81630
Esme-Yi [Fri, 12 Jun 2020 02:23:52 +0000 (02:23 +0000)]
Revert "[PowerPC][NFC] Testing ROTL of v1i128."
This reverts commit
174192af0106be9764aeda34988f27dc2c1bd4c4.
Cyndy Ishida [Fri, 12 Jun 2020 01:32:45 +0000 (18:32 -0700)]
[llvm][llvm-nm] add TextAPI/MachO support
Summary:
This completes the needed glueing to support reading tbd files from nm.
This includes specifying which slice filtering with `--arch` and a new
option specifically for tbd files `--add-inlinedinfo` which will show
the reexported libraries that are appended in the tbd file.
Reviewers: ributzka, steven_wu, JDevlieghere, jhenderson
Reviewed By: JDevlieghere
Subscribers: hiraditya, MaskRay, dexonsmith, rupprecht, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81614
Alina Sbirlea [Fri, 12 Jun 2020 01:16:33 +0000 (18:16 -0700)]
Verify MemorySSA after all updates.
Verify after completing all updates.
Resolves PR46275.
Stella Laurenzo [Thu, 11 Jun 2020 21:01:52 +0000 (14:01 -0700)]
Install the MLIRTableGen static library.
Summary: * This library is special because of its dependencies so seems to have been inadvertently left out of installs.
Reviewers: antiagainst
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D81693
Mehdi Amini [Fri, 12 Jun 2020 00:34:35 +0000 (00:34 +0000)]
Enable FileCheck -enable-var-scope by default in MLIR test
This option avoids to accidentally reuse variable across -LABEL match,
it can be explicitly opted-in by prefixing the variable name with $
Differential Revision: https://reviews.llvm.org/D81531
Wen-Heng (Jack) Chung [Fri, 12 Jun 2020 00:15:16 +0000 (19:15 -0500)]
Use python3 in generate-test-checks.py.
Summary: Upgrade to python3 in generate-test-checks.py .
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D81701
HazemAbdelhafez [Wed, 10 Jun 2020 23:15:55 +0000 (19:15 -0400)]
[mlir][spirv] Enhance structure type member decoration handling
Modify structure type in SPIR-V dialect to support:
1) Multiple decorations per structure member
2) Key-value based decorations (e.g., MatrixStride)
This commit kept the Offset decoration separate from members'
decorations container for easier implementation and logical clarity.
As such, all references to Structure layoutinfo are now offsetinfo,
and any member layout defining decoration (e.g., RowMajor for Matrix)
will be add to the members' decorations container along with its
value if any.
Differential Revision: https://reviews.llvm.org/D81426
Eric Christopher [Thu, 11 Jun 2020 23:42:23 +0000 (16:42 -0700)]
Tidy up unsigned -> Register fixups.
Jacques Pienaar [Thu, 11 Jun 2020 23:45:37 +0000 (16:45 -0700)]
[mlir] Add additional header
Fix gcc10 build and closes: https://bugs.llvm.org/show_bug.cgi?id=45680
Eric Christopher [Thu, 11 Jun 2020 23:34:31 +0000 (16:34 -0700)]
Add a diagnostic string to an assert.
Matt Arsenault [Thu, 11 Jun 2020 23:19:13 +0000 (19:19 -0400)]
AMDGPU/GlobalISel: Fix select of private <2 x s16> load
Sanjay Patel [Thu, 11 Jun 2020 20:50:03 +0000 (16:50 -0400)]
[VectorCombine] remove unused parameters; NFC
Vitaly Buka [Thu, 11 Jun 2020 20:47:50 +0000 (13:47 -0700)]
[StackSafety,NFC] Fix use of CallBase API
Code does not need iterate arguments and can get ArgNo from
CallBase::getArgOperandNo.
Matt Arsenault [Thu, 11 Jun 2020 12:54:00 +0000 (08:54 -0400)]
AMDGPU/GlobalISel: Fix select of <8 x s64> scalar load
Akira Hatanaka [Wed, 3 Jun 2020 23:41:50 +0000 (16:41 -0700)]
[CodeGen] Simplify the way lifetime of block captures is extended
Rather than pushing inactive cleanups for the block captures at the
entry of a full expression and activating them during the creation of
the block literal, just call pushLifetimeExtendedDestroy to ensure the
cleanups are popped at the end of the scope enclosing the block
expression.
rdar://problem/
63996471
Differential Revision: https://reviews.llvm.org/D81624
Jonas Devlieghere [Thu, 11 Jun 2020 22:39:49 +0000 (15:39 -0700)]
[lldb/Test] Unify DYLD_INSERT_LIBRARIES solution for ASan and TSan
Add the same fix for loading the sanitizer runtime for TSan as we
currently have for ASan and unify the code with a helper function.
Matt Arsenault [Thu, 11 Jun 2020 22:28:31 +0000 (18:28 -0400)]
AMDGPU/GlobalISel: Set insert point when emitting control flow pseudos
This was implicitly assuming the branch instruction was the next after
the pseudo. It's possible for another non-terminator instruction to be
inserted between the intrinsic and the branch, so adjust the insertion
point. Fixes a non-terminator after terminator verifier error (which
without the verifier, manifested itself as an infinite loop in
analyzeBranch much later on).
George Mitenkov [Thu, 11 Jun 2020 22:46:09 +0000 (18:46 -0400)]
[MLIR][SPIRVToLLVM] Added conversion for SPIR-V comparison ops
Implemented `FComparePattern` and `IComparePattern` classes
that provide conversion of SPIR-V comparison ops (such as
`spv.FOrdGreaterThanEqual` and others) to LLVM dialect.
Also added tests in `comparison-ops-to-llvm.mlir`.
Differential Revision: https://reviews.llvm.org/D81487
Kirill Naumov [Thu, 11 Jun 2020 20:24:14 +0000 (20:24 +0000)]
[InlineCost] Preparational patch for creation of Printer pass.
- Renaming the printer class, flag
- Refactoring
- Changing some tests
This patch is a preparational stage for introducing a new printing pass and new
functionality to the existing Annotation Writer. I plan to extend
this functionality for this tool to be more useful when looking at the inline
process.
Fangrui Song [Thu, 11 Jun 2020 22:19:05 +0000 (15:19 -0700)]
[Support] Don't tie errs() to outs() by default
This reverts part of D81156.
Accessing errs() concurrently was safe before and racy after D81156.
(`errs() << 'a'` is always racy)
Accessing outs() and errs() concurrently was safe before and racy after D81156.
Don't tie errs() to outs() by default to fix the fallout.
llvm-dwarfdump is single-threaded and opting in the tie behavior is safe.
John McCall [Thu, 11 Jun 2020 22:09:36 +0000 (18:09 -0400)]
Set the LLVM FP optimization flags conservatively.
Functions can have local pragmas that override the global settings.
We set the flags eagerly based on global settings, but if we emit
an expression under the influence of a pragma, we clear the
appropriate flags from the function.
In order to avoid doing a ton of redundant work whenever we emit
an FP expression, configure the IRBuilder to default to global
settings, and only reconfigure it when we see an FP expression
that's not using the global settings.
Patch by Michele Scandale!
https://reviews.llvm.org/D80462
Stanislav Mekhanoshin [Thu, 11 Jun 2020 17:45:42 +0000 (10:45 -0700)]
Fixed assertion in SROA if block has ho successors
BasicBlock::isLegalToHoistInto() asserts if block does not
have successors. The case is degenarate but assertion still
needs to be avoided.
https://bugs.llvm.org/show_bug.cgi?id=46280
Differential Revision: https://reviews.llvm.org/D81674
Craig Topper [Thu, 11 Jun 2020 21:54:41 +0000 (14:54 -0700)]
[X86] Remove unnecessary #if around call to isCpuIdSupported in getHostCPUName.
The exact same #if is already inside isCpuIdSupported and causes
it to return true. The definition of isCpuIdSupported isn't
conditional so we should be able just rely on its body doing
the right thing.
Thomas Lively [Thu, 11 Jun 2020 22:11:45 +0000 (15:11 -0700)]
[WebAssembly] Make BR_TABLE non-duplicable
Summary:
After their range checks were removed in
7f50c15be5c0, br_tables
started being duplicated into their predecessors by tail
folding. Unfortunately, when the br_tables were in loops this
transformation introduced bad irreducible control flow which was later
expanded into even more br_tables. This commit abuses the
`isNotDuplicable` property to prevent this irreducible control flow
from being introduced. This change saves a few dozen bytes of code
size and has a negligible affect on performance for most of the large
Emscripten benchmarks, but can improve performance significantly on
microbenchmarks of switches in loops.
Reviewers: aheejin, dschuff
Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81628
Ilya Bukonkin [Thu, 11 Jun 2020 21:59:19 +0000 (14:59 -0700)]
[lldb] Check if thread was suspended during previous stop added.
Encountered the following situation: Let we started thread T1 and it hit
breakpoint on B1 location. We suspended T1 and continued the process.
Then we started thread T2 which hit for example the same location B1.
This time in a breakpoint callback we decided not to stop returning
false.
Expected result: process continues (as if T2 did not hit breakpoint) its
workflow with T1 still suspended. Actual result: process do stops (as if
T2 callback returned true).
Solution: We need invalidate StopInfo for threads that was previously
suspended just because something that is already inactive can not be the
reason of stop. Thread::GetPrivateStopInfo() may be appropriate place to
do it, because it gets called (through Thread::GetStopInfo()) every time
before process reports stop and user gets chance to change
m_resume_state again i.e if we see m_resume_state == eStateSuspended
it definitely means it was set during previous stop and it also means
this thread can not be stopped again (cos' it was frozen during
previous stop).
Differential revision: https://reviews.llvm.org/D80112
Diego Caballero [Thu, 11 Jun 2020 21:39:44 +0000 (14:39 -0700)]
[mlir][Affine] Revisit fusion candidates after successful fusion
This patch changes the fusion algorithm so that after fusing two loop nests
we revisit previously visited nodes so that they are considered again for
fusion in the context of the new fused loop nest.
Reviewed By: bondhugula
Differential Revision: https://reviews.llvm.org/D81609
Reid Kleckner [Thu, 11 Jun 2020 20:00:54 +0000 (13:00 -0700)]
Re-land "Migrate the rest of COFFObjectFile to Error"
This reverts commit
101fbc01382edd89ea7b671104c68b30b2446cc0.
Remove leftover debugging attribute.
Update LLDB as well, which was missed before.
Kadir Cetinkaya [Thu, 11 Jun 2020 20:49:52 +0000 (22:49 +0200)]
[clangd] Set CWD in semaCodeComplete
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81691
Alex Richardson [Thu, 11 Jun 2020 21:23:27 +0000 (22:23 +0100)]
Fix incorrect call to ExprResult::get()
Res is already a ExprResult, so if we call .get(), we will convert an
ExprError() result into an unset result. I discovered this in our downstream
CHERI target where this resulted in a crash due to a NULL-dereference.
It appears that this was introduced in SVN revision 201788 (
8690a6860a45ba36e39b4ff0dbe434195e125d11)
Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D81608
Fangrui Song [Thu, 11 Jun 2020 20:50:56 +0000 (13:50 -0700)]
[GlobalISel][test] Add REQUIRES: asserts after D76934
Jacques Pienaar [Thu, 11 Jun 2020 20:45:09 +0000 (13:45 -0700)]
[mlir] Remove Broadcastable ODS trait
Alias to ResultsBroadcastableShape ODS trait which matches C++ class.
Louis Dionne [Thu, 11 Jun 2020 19:41:38 +0000 (15:41 -0400)]
[libc++] Allow specifying arbitrary custom executors with the new format
The integration between CMake and executor selection in the new format
wasn't very flexible -- only the default executor and SSH executors were
supported.
This patch makes it possible to specify arbitrary executors with the new
format. With the new testing format, a custom executor is just a script
that gets called with a command-line to execute, and some arguments like
--env, --codesign_identity and --execdir. As such, the default executor
is just run.py.
Remote execution with the SSH executor can be achived by specifying
LIBCXX_EXECUTOR="<path-to-ssh.py> --host <host>". Similarly, arbitrary
scripts can be provided.
Alexander Belyaev [Thu, 11 Jun 2020 17:22:48 +0000 (19:22 +0200)]
[mlir] Fix some of the warnings in MLIR code.
Summary:
* extra ';' in the following files:
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/lib/Dialect/Shape/IR/Shape.cpp
* base class ‘mlir::ConvertVectorToSCFBase<ConvertVectorToSCFPass>’
should be explicitly initialized in the copy constructor [-Wextra] in
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
* warning: ‘bool Expression::operator==(const Expression&) const’
defined but not used [-Wunused-function] in
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
Differential Revision: https://reviews.llvm.org/D81673
Craig Topper [Thu, 11 Jun 2020 19:45:54 +0000 (12:45 -0700)]
[X86] Force VIA PadLock crypto instructions to emit a 0xF3 prefix when they encode to match what GNU as does.
The spec for these says they need 0xf3 but also mentions REP
before the mnemonic. But I don't think its fair to users to make
them write REP first. And gas doesn't make them. objdump seems to
disassemble with or without the prefix and just prints any 0xf3
as REP.
Aditya Nandakumar [Thu, 11 Jun 2020 19:29:12 +0000 (12:29 -0700)]
[GISel][NFC]: Add unit test for clarifying CSE behavior
Add a unit test that shows how CSE works if we install an observer
at the machine function level and not use the CSEMIRBuilder to build
instructions.
https://reviews.llvm.org/D81625
Erich Keane [Mon, 1 Jun 2020 19:14:34 +0000 (12:14 -0700)]
Add to the Coding Standard our that single-line bodies omit braces
This is a rule that seems to have been enforced for the better part of
the decade, so we should document it for new contributors.
Differential Revision: https://reviews.llvm.org/D80947
Bruno Ricci [Thu, 11 Jun 2020 16:36:28 +0000 (17:36 +0100)]
[clang] TextNodeDumper: Dump the trait spelling of {Type,ArrayType,Expression}TraitExpr
nodes using the new helper functions introduced
in
78e636b3f2f0b0487130b31fade4f95ab179a18c.
Bruno Ricci [Thu, 11 Jun 2020 16:29:15 +0000 (17:29 +0100)]
[clang][NFC] Assert that the enumerator value of {Type,ArrayType,UnaryExprOrType,Expression}Traits
is valid and does not overflow in the bit-field for its storage in more places.
This is a follow-up to
78e636b3f2f0b0487130b31fade4f95ab179a18c. NFC.
Bruno Ricci [Thu, 11 Jun 2020 16:24:04 +0000 (17:24 +0100)]
[clang][NFC] Remove two hard-coded lists of ArrayTypeTrait and ExpressionTrait
These two were missed in
78e636b3f2f0b0487130b31fade4f95ab179a18c.
Siva Chandra Reddy [Tue, 2 Jun 2020 21:04:57 +0000 (14:04 -0700)]
[libc] Add implementation of few floating point manipulation functions.
Implementations of copysign[f], frexp[f], logb[f], and modf[f] are added.
Reviewers: asteinhauser
Differential Revision: https://reviews.llvm.org/D81134
Craig Topper [Thu, 11 Jun 2020 19:18:52 +0000 (12:18 -0700)]
[X86] Replace TB with PS on instructions that are documented in the SDM with 'NP'
'NP' means that the instruction is not recognized with a 66, F2 or F3
prefix. It will either #UD or decode to a different instruction.
All of the cases are here should fall into the #UD variety since
we should be detecting the collision with other instructions when
we build the disassembler tables.
Eli Friedman [Thu, 11 Jun 2020 19:13:18 +0000 (12:13 -0700)]
[AArch64] Regenerate SVE test llvm-ir-to-intrinsic.ll.
Louis Dionne [Thu, 11 Jun 2020 17:50:40 +0000 (13:50 -0400)]
[libc++abi] Simplify the logic for finding libc++ from libc++abi
Since we have the monorepo, libc++abi's build requires a sibling checkout
of the libc++ sources. Hence, the logic for finding libc++ can be greatly
simplified.
Alexey Bataev [Thu, 11 Jun 2020 15:28:59 +0000 (11:28 -0400)]
[OPENMP50]Codegen for scan directive in simd loops.
Added codegen for scan directives in simd loop. The codegen transforms
original code:
```
int x = 0;
#pragma omp simd reduction(inscan, +: x)
for (..) {
<first part>
#pragma omp scan inclusive(x)
<second part>
}
```
into
```
int x = 0;
for (..) {
int x_priv = 0;
<first part>
x = x_priv + x;
x_priv = x;
<second part>
}
```
and
```
int x = 0;
#pragma omp simd reduction(inscan, +: x)
for (..) {
<first part>
#pragma omp scan exclusive(x)
<second part>
}
```
into
```
int x = 0;
for (..) {
int x_priv = 0;
<second part>
int temp = x;
x = x_priv + x;
x_priv = temp;
<first part>
}
```
Differential revision: https://reviews.llvm.org/D78232
sameeran joshi [Sun, 19 Apr 2020 11:10:37 +0000 (16:40 +0530)]
[flang] Semantics for SELECT TYPE
Summary:
Added support for all semantic checks except C1157
was previously implemented.
Address review comments.
Reviewers: PeteSteinfeld, tskeith, klausler, DavidTruby, kiranktp, anchu-rajendran, sscalpone
Subscribers: kiranchandramohan, llvm-commits, flang-commits
Tags: #llvm, #flang
Differential Revision: https://reviews.llvm.org/D79851
Leonard Chan [Thu, 11 Jun 2020 18:17:08 +0000 (11:17 -0700)]
[clang] Frontend components for the relative vtables ABI (round 2)
This patch contains all of the clang changes from D72959.
- Generalize the relative vtables ABI such that it can be used by other targets.
- Add an enum VTableComponentLayout which controls whether components in the
vtable should be pointers to other structs or relative offsets to those structs.
Other ABIs can change this enum to restructure how components in the vtable
are laid out/accessed.
- Add methods to ConstantInitBuilder for inserting relative offsets to a
specified position in the aggregate being constructed.
- Fix failing tests under new PM and ASan and MSan issues.
See D72959 for background info.
Differential Revision: https://reviews.llvm.org/D77592
Stanislav Mekhanoshin [Thu, 11 Jun 2020 17:50:12 +0000 (10:50 -0700)]
Regenerated SROA phi-gep.ll test. NFC.
hyd-dev [Thu, 11 Jun 2020 16:30:16 +0000 (12:30 -0400)]
[PCH] Support writing BuiltinBitCastExprs to PCHs
eee944e7f adds the new BuiltinBitCastExpr, but does not set the Code member of
ASTStmtWriter. This is not correct and causes an assertion failue in
ASTStmtWriter::emit() when building PCHs that contain __builtin_bit_cast. This
commit adds serialization::EXPR_BUILTIN_BIT_CAST and handles
ASTStmtWriter::Code properly.
Differential revision: https://reviews.llvm.org/D80360
jerryyin [Thu, 11 Jun 2020 15:10:21 +0000 (15:10 +0000)]
[mlir][rocdl] Fixing breakage of dim operator from
904f91db
Summary:
* Update the unit test dimOp index to be an operand
* Refactored the constant naming
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D81663
diggerlin [Thu, 11 Jun 2020 17:33:51 +0000 (13:33 -0400)]
[NFC] clean up the AsmPrinter::emitLinkage for AIX part
SUMMARY:
Since we deal with aix emitLinkage in the PPCAIXAsmPrinter::emitLinkage() in the patch https://reviews.llvm.org/D75866. It do not go to AsmPrinter::emitLinkage() any more, we clean up some aix related code in the AsmPrinter::emitLinkage()
Reviewers: Jason liu
Differential Revision: https://reviews.llvm.org/D81613
Jonas Devlieghere [Thu, 11 Jun 2020 16:35:19 +0000 (09:35 -0700)]
[lldb/Test] Ensure inline tests have a unique build directory
Inline tests have one method named 'test' which means that multiple
inline tests in the same file end up sharing the same build directory
per variant.
This patch overrides the getBuildDirBasename method for the InlineTest
class to include the test name.
Differential revision: https://reviews.llvm.org/D81516
Alexander Belyaev [Thu, 11 Jun 2020 10:40:18 +0000 (12:40 +0200)]
[mlir][shape] Add assemblyFormat for `shape.add`.
Differential Revision: https://reviews.llvm.org/D81644
Sanjay Patel [Wed, 10 Jun 2020 18:05:21 +0000 (14:05 -0400)]
[VectorCombine] add tests for compare scalarization; NFC
Petar Avramovic [Thu, 11 Jun 2020 15:55:59 +0000 (17:55 +0200)]
AMDGPU/GlobalISel: Fix lower for f64->f16 G_FPTRUNC
Put AND before ADD in LegalizerHelper::lowerFPTRUNC_F64_TO_F16
in order to match algorithm from AMDGPUTargetLowering::LowerFP_TO_FP16.
Differential Revision: https://reviews.llvm.org/D81666
Fangrui Song [Thu, 11 Jun 2020 16:05:59 +0000 (09:05 -0700)]
[llvm-objdump] Decrease instruction indentation for non-x86
Place the instruction at the 24th column (0-based indexing), matching
GNU objdump ARM/AArch64/powerpc/etc when the address is low.
This is beneficial for non-x86 targets which have short instruction
lengths.
```
// GNU objdump AArch64
0:
91001062 add x2, x3, #0x4
400078:
91001062 add x2, x3, #0x4
// llvm-objdump, with this patch
0: 62 10 00 91 add x2, x3, #4
400078: 62 10 00 91 add x2, x3, #4
// llvm-objdump, if we change to print a word instead of bytes in the future
0:
91001062 add x2, x3, #4
400078:
91001062 add x2, x3, #4
// GNU objdump Thumb
0: bf00 nop
// GNU objdump Power ISA 3.1 64-bit instruction
// 0: 00 00 10 04 plwa r3,0
// 4: 00 00 60 a4
```
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D81590
Alexey Bataev [Thu, 11 Jun 2020 15:22:14 +0000 (11:22 -0400)]
Revert "[OPENMP50]Codegen for scan directive in simd loops."
This reverts commit
fb80e67f10eea7177b0ff9c618c8231363b6f2fc to resolve
the issue with asan buildbots.
Mircea Trofin [Tue, 9 Jun 2020 21:33:46 +0000 (14:33 -0700)]
[llvm][NFC] Factor some common data in InlineAdvice
Summary:
Other derivations will all want to emit optimization remarks and, as
part of that, use debug info.
Additionally, drive-by const-ing.
Reviewers: davidxl, dblaikie
Subscribers: aprantl, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81507
Simon Pilgrim [Thu, 11 Jun 2020 14:38:39 +0000 (15:38 +0100)]
[X86] Fold vXi1 OR(KSHIFTL(X,NumElts/2),Y) -> KUNPCK
Convert shift+or bool vector patterns into CONCAT_VECTORS if we know this will be lowered to KUNPCK (which requires 16+ vector elements).
Fixes PR32547
jerryyin [Fri, 5 Jun 2020 16:53:41 +0000 (16:53 +0000)]
[mlir][rocdl] Adding vector to ROCDL dialect lowering
* Created the vector to ROCDL lowering pass
* The lowering pass lowers vector transferOps to rocdl mubufOps
* Added unit test and functional test
serge-sans-paille [Thu, 4 Jun 2020 07:13:39 +0000 (09:13 +0200)]
Fix return status of DataFlowSanitizer pass
Take into account added functions, global values and attribute change.
Differential Revision: https://reviews.llvm.org/D81239
Alexey Bataev [Mon, 25 May 2020 20:06:31 +0000 (16:06 -0400)]
[OPENMP50]Codegen for use_device_addr clauses.
Summary:
Added codegen for use_device_addr clause. The components of the list
items are mapped as a kind of RETURN components and then the returned
base address is used instead of the real address of the base declaration
used in the use_device_addr expressions.
Reviewers: jdoerfert
Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80730
Jay Foad [Mon, 18 May 2020 18:12:29 +0000 (19:12 +0100)]
[IR] Clean up dead instructions after simplifying a conditional branch
Change BasicBlock::removePredecessor to optionally return a vector of
instructions which might be dead. Use this in ConstantFoldTerminator to
delete them if they are dead.
Reapply with a bug fix: don't drop the "!KeepOneInputPHIs" argument when
removePredecessor calls PHINode::removeIncomingValue.
Differential Revision: https://reviews.llvm.org/D80206
Sam Parker [Thu, 11 Jun 2020 13:52:17 +0000 (14:52 +0100)]
[IR] Remove assert from ShuffleVectorInst
Which triggers on valid, but not useful, IR such as a undef mask.
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=46276
Differential Revision: https://reviews.llvm.org/D81634
LLVM GN Syncbot [Thu, 11 Jun 2020 13:36:59 +0000 (13:36 +0000)]
[gn build] Port
78e636b3f2f
Bruno Ricci [Thu, 11 Jun 2020 13:08:27 +0000 (14:08 +0100)]
[clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits...
...enumerations from TokenKinds.def and use the new macros from TokenKinds.def
to remove the hard-coded lists of traits.
All the information needed to generate these enumerations is already present
in TokenKinds.def. The motivation here is to be able to dump the trait spelling
without hard-coding the list in yet another place.
Note that this change the order of the enumerators in the enumerations (except
that in the TypeTrait enumeration all unary type traits are before all binary
type traits, and all binary type traits are before all n-ary type traits).
Apart from the aforementioned ordering which is relied upon, after this patch
no code in clang or in the various clang tools depend on the specific ordering
of the enumerators.
No functional changes intended.
Differential Revision: https://reviews.llvm.org/D81455
Reviewed By: aaron.ballman
Jay Foad [Thu, 11 Jun 2020 13:22:16 +0000 (14:22 +0100)]
Revert "[IR] Clean up dead instructions after simplifying a conditional branch"
This reverts commit
4494e45316a0bfaabb6bb1450fb0f49a0e6832af.
It caused problems for sanitizer buildbots.
Daniel Grumberg [Wed, 13 May 2020 16:07:47 +0000 (17:07 +0100)]
Add AST_SIGNATURE record to unhashed control block of PCM files
Summary:
This record is constructed by hashing the bytes of the AST block in a similiar
fashion to the SIGNATURE record. This new signature only means anything if the
AST block is fully relocatable, i.e. it does not embed absolute offsets within
the PCM file. This change ensure this does not happen by replacing these offsets
with offsets relative to the nearest relevant subblock of the AST block.
Reviewers: Bigcheese, dexonsmith
Subscribers: dexonsmith, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80383
Alexey Bataev [Fri, 5 Jun 2020 19:17:14 +0000 (15:17 -0400)]
[OPENMP50]Codegen for scan directive in simd loops.
Added codegen for scandirectives in simd loop. The codegen transforms
original code:
```
int x = 0;
#pragma omp simd reduction(inscan, +: x)
for (..) {
<first part>
#pragma omp scan inclusive(x)
<second part>
}
```
into
```
int x = 0;
for (..) {
int x_priv = 0;
<first part>
x = x_priv + x;
x_priv = x;
<second part>
}
```
and
```
int x = 0;
#pragma omp simd reduction(inscan, +: x)
for (..) {
<first part>
#pragma omp scan exclusive(x)
<second part>
}
```
into
```
int x = 0;
for (..) {
int x_priv = 0;
<second part>
int temp = x;
x = x_priv + x;
x_priv = temp;
<first part>
}
```
Differential revision: https://reviews.llvm.org/D78232