Louis Dionne [Tue, 11 Oct 2022 18:53:14 +0000 (14:53 -0400)]
[libc++] Fix std::function's handling of blocks under Objc ARC
Previously, some uses of std::function with blocks would crash when ARC was enabled.
rdar://
100907096
Differential Revision: https://reviews.llvm.org/D135706
Joe Loser [Mon, 17 Oct 2022 00:47:26 +0000 (18:47 -0600)]
[libc++] Fix missing requires clause on variant operator<=>
`std::variant::operator<=>` is missing a requires clause ensuring that
`operator<=>` only exists when all of the types in the variant are
`three_way_comparable`.
Add the missing requires clause and adjust the existing test which was
incorrect.
Fixes https://github.com/llvm/llvm-project/issues/58192.
Differential Revision: https://reviews.llvm.org/D136050
Daniel Sanders [Mon, 17 Oct 2022 18:25:56 +0000 (11:25 -0700)]
[instsimplify] Move (extelt (inselt Vec, Value, Index), Index) -> Value from InstCombine
As requested in https://reviews.llvm.org/D135625#3858141
Differential Revision: https://reviews.llvm.org/D136099
Adrian Prantl [Fri, 14 Oct 2022 23:45:01 +0000 (16:45 -0700)]
Make sure Target::EvaluateExpression() passes up an error instead of silently dropping it.
When UserExpression::Evaluate() fails and doesn't return a ValueObject there is no vehicle for returning the error in the return value.
This behavior can be observed by applying the following patch:
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index
f1a311b7252c..
58c03ccdb068 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2370,6 +2370,7 @@ UserExpression *Target::GetUserExpressionForLanguage(
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options, ValueObject *ctx_obj,
Status &error) {
+ error.SetErrorStringWithFormat("Ha ha!"); return nullptr;
auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
if (auto err = type_system_or_err.takeError()) {
error.SetErrorStringWithFormat(
and then running
$ lldb -o "p 1"
(lldb) p 1
(lldb)
This patch fixes this by creating an empty result ValueObject that wraps the error.
Differential Revision: https://reviews.llvm.org/D135998
Jeremy Furtek [Mon, 17 Oct 2022 21:02:09 +0000 (14:02 -0700)]
[mlir][LLVMIR] Update LLVMIR fastmath to use EnumAttr tblgen classes
This diff updates the `fastmath` attribute in the LLVMIR dialect to use `tblgen`
classes that were developed after the initial LLVMIR `fastmath` implementation.
Using the `EnumAttr` `tblgen` classes brings the LLVMIR `fastmath` attribute in
line with other dialects, and eliminates some of the custom printing and parsing
code in the LLVMIR dialect.
Subsequent commits will further reduce the custom processing code for the LLVMIR
`fastmath` attribute by unifying printing/parsing functionality between the
LLVMIR and `arith` `fastmath` attributes. (The actual attributes will remain
separate, but the printing and parsing will be made generic, and will be usable
by other dialects/attributes.)
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D135289
Arthur Eubanks [Mon, 17 Oct 2022 21:29:30 +0000 (14:29 -0700)]
Revert "llvm-reduce: Color output of child processes"
This reverts commit
86e9181ded7c5b6aa67a3a84089fce850c84f27a.
Seems to be causing bot failures: https://lab.llvm.org/buildbot#builders/5/builds/28313
Plus as noted on D135632 it seems to interact badly with parallel reduction.
Xiang Li [Sun, 16 Oct 2022 00:36:29 +0000 (17:36 -0700)]
[HLSL] CodeGen hlsl resource binding.
''register(ID, space)'' like register(t3, space1) will be translated into
i32 3, i32 1 as the last 2 operands for resource annotation metadata.
NamedMetadata for CBuffers and SRVs are added as "hlsl.srvs" and "hlsl.cbufs".
Reviewed By: beanz
Differential Revision: https://reviews.llvm.org/D130951
Arthur Eubanks [Wed, 12 Oct 2022 23:18:44 +0000 (16:18 -0700)]
[lldb] Print newline between found types
Or else multiple entries end up overlapping on the same line.
Reviewed By: DavidSpickett
Differential Revision: https://reviews.llvm.org/D135827
Christian Kandeler [Mon, 17 Oct 2022 21:12:39 +0000 (17:12 -0400)]
[clangd] Implement semantic token modifier "definition"
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D127403
Jeremy Furtek [Mon, 17 Oct 2022 18:16:38 +0000 (11:16 -0700)]
[mlir][ods] Do not print default-valued attributes when the value is equal to the default
This diff causes the `tblgen`-erated print() function to skip printing a
`DefaultValuedAttr` attribute when the value is equal to the default.
This feature will reduce the amount of custom printing code that needs to be
written by users a relatively common scenario. As a motivating example, for the
fastmath flags in the LLVMIR dialect, we would prefer to print this:
```
%0 = llvm.fadd %arg0, %arg1 : f32
```
instead of this:
```
%0 = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath<none>} : f32
```
This diff makes the handling of print functionality for default-valued attributes
standard.
This is an updated version of https://reviews.llvm.org/D135398, without the per-attribute bit to control printing.
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D135993
Craig Topper [Mon, 17 Oct 2022 19:40:32 +0000 (12:40 -0700)]
[RISCV] Add basic support for the sifive-7-series short forward branch optimization.
sifive-7-series has macrofusion support to convert a branch over
a single instruction into a conditional instruction. This can be
an improvement if the branch is hard to predict.
This patch adds support for the most basic case, a branch over a
move instruction. This is implemented as a pseudo instruction so
we can hide the control flow until all code motion passes complete.
I've disabled a recent select optimization if this feature is enabled
in the subtarget.
Related gcc patch for the same optimization https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg211045.html
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D135814
Chia-hung Duan [Sat, 15 Oct 2022 20:34:51 +0000 (20:34 +0000)]
[scudo] Change region size from 1 MB to 2 MB in tests
In SizeClassAllocator64, the RegionBeg is determined by RegionBase +
random offset. The offset is n pages, where n is a random number less or
equal to 16. However, on certain platforms which have large page size,
it may end up immediately OOM without mapping any block pages. For
example,
PageSize = 64 KB, RegionSize = 1 MB
Suppose the random number n is 16, then the random offset will be
64 * 16 = 1024 KB which is equal to the RegionSize.
On most platforms we don't have such large page size and we have
different PRNG(pseudo random number generator) behaviors, thus we didn't
hit any failures before. Given that this now only affects the tests,
only increase the region size is enough.
Will revisit the logic of calculating the random offset.
Differential Revision: https://reviews.llvm.org/D136025
Matthias Braun [Mon, 12 Sep 2022 16:17:38 +0000 (09:17 -0700)]
ControlHeightReduction: Remove assert check in shouldApply
Remove assertion checking for non-empty `ProfileSummaryInfo`.
Differential Revision: https://reviews.llvm.org/D133706
Fangrui Song [Mon, 17 Oct 2022 20:09:39 +0000 (13:09 -0700)]
[ELF] Inline computeAddend. NFC
Florian Hahn [Mon, 17 Oct 2022 19:30:42 +0000 (20:30 +0100)]
[ConstraintElim] Use helper to allow overflow for coefficients of GEPs
If the arithmetic for indices of inbounds GEPs overflows, the result is
poison. This means it is also OK for the coefficients to overflow. GEP
decomposition is limited to cases where the index size is <= 64 bit,
which can be represented by int64_t used for the coefficients in the
constraint system.
Fangrui Song [Mon, 17 Oct 2022 18:57:17 +0000 (11:57 -0700)]
[ELF] Move ELFT-agnostic relocation code to processAux
Renaud Kauffmann [Mon, 17 Oct 2022 18:41:35 +0000 (11:41 -0700)]
Document for Aliasing analysis in FIR
Fangrui Song [Mon, 17 Oct 2022 18:44:28 +0000 (11:44 -0700)]
[ELF] Move ELFT-agnostic relocation code to processAux. NFC
Han Zhu [Thu, 22 Sep 2022 01:01:49 +0000 (18:01 -0700)]
[X86] Lower vector interleave into unpck and perm
[This Godbolt link](https://godbolt.org/z/s17Kv1s9T) shows different codegen between clang and gcc for a transpose operation.
clang result:
```
vmovdqu xmm0, xmmword ptr [rcx + rax]
vmovdqu xmm1, xmmword ptr [rcx + rax + 16]
vmovdqu xmm2, xmmword ptr [r8 + rax]
vmovdqu xmm3, xmmword ptr [r8 + rax + 16]
vpunpckhbw xmm4, xmm2, xmm0
vpunpcklbw xmm0, xmm2, xmm0
vpunpcklbw xmm2, xmm3, xmm1
vpunpckhbw xmm1, xmm3, xmm1
vmovdqu xmmword ptr [rdi + 2*rax + 48], xmm1
vmovdqu xmmword ptr [rdi + 2*rax + 32], xmm2
vmovdqu xmmword ptr [rdi + 2*rax], xmm0
vmovdqu xmmword ptr [rdi + 2*rax + 16], xmm4
```
gcc result:
```
vmovdqu ymm3, YMMWORD PTR [rdi+rax]
vpunpcklbw ymm1, ymm3, YMMWORD PTR [rsi+rax]
vpunpckhbw ymm0, ymm3, YMMWORD PTR [rsi+rax]
vperm2i128 ymm2, ymm1, ymm0, 32
vperm2i128 ymm1, ymm1, ymm0, 49
vmovdqu YMMWORD PTR [rcx+rax*2], ymm2
vmovdqu YMMWORD PTR [rcx+32+rax*2], ymm1
```
clang's code is roughly 15% slower than gcc's when evaluated on an internal compression benchmark.
The loop vectorizer generates the following shufflevector intrinsic:
```
%interleaved.vec = shufflevector <32 x i8> %a, <32 x i8> %b, <64 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
```
which is lowered to SelectionDAG:
```
t2: v32i8,ch = CopyFromReg t0, Register:v32i8 %0
t6: v64i8 = concat_vectors t2, undef:v32i8
t4: v32i8,ch = CopyFromReg t0, Register:v32i8 %1
t7: v64i8 = concat_vectors t4, undef:v32i8
t8: v64i8 = vector_shuffle<0,64,1,65,2,66,3,67,4,68,5,69,6,70,7,71,8,72,9,73,10,74,11,75,12,76,13,77,14,78,15,79,16,80,17,81,18,82,19,83,20,84,21,85,22,86,23,87,24,88,25,89,26,90,27,91,28,92,29,93,30,94,31,95> t6, t7
```
So far this `vector_shuffle` is good enough for us to pattern-match and transform, but as we go down the SelectionDAG pipeline, it got split into smaller shuffles. During dagcombine1, the shuffle is split by `foldShuffleOfConcatUndefs`.
```
// shuffle (concat X, undef), (concat Y, undef), Mask -->
// concat (shuffle X, Y, Mask0), (shuffle X, Y, Mask1)
t2: v32i8,ch = CopyFromReg t0, Register:v32i8 %0
t4: v32i8,ch = CopyFromReg t0, Register:v32i8 %1
t19: v32i8 = vector_shuffle<0,32,1,33,2,34,3,35,4,36,5,37,6,38,7,39,8,40,9,41,10,42,11,43,12,44,13,45,14,46,15,47> t2, t4
t15: ch,glue = CopyToReg t0, Register:v32i8 $ymm0, t19
t20: v32i8 = vector_shuffle<16,48,17,49,18,50,19,51,20,52,21,53,22,54,23,55,24,56,25,57,26,58,27,59,28,60,29,61,30,62,31,63> t2, t4
t17: ch,glue = CopyToReg t15, Register:v32i8 $ymm1, t20, t15:1
```
With `foldShuffleOfConcatUndefs` commented out, the vector is still split later by the type legalizer, which comes after dagcombine1, because v64i8 is not a legal type in AVX2 (64 * 8 = 512 bits while ymm = 256 bits). There doesn't seem to be a good way to avoid this split. Lowering the `vector_shuffle` into unpck and perm during dagcombine1 is too early. Therefore, although somewhat inconvenient, we decided to go with pattern-matching a pair vector shuffles later in the SelectionDAG pipeline, as part of `lowerV32I8Shuffle`.
The code looks at the two operands of the first shuffle it encounters, iterates through the users of the operands, and tries to find two shuffles that are consecutive interleaves. Once the pattern is found, it lowers them into unpcks and perms. It returns the perm for the shuffle that's currently being lowered (have ISel modify the DAG), and replaces the other shuffle in place.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D134477
Philip Reames [Mon, 17 Oct 2022 17:09:58 +0000 (10:09 -0700)]
[clang][RISCV] Set vscale_range attribute based on presence of "v" extension
This follows the path that AArch64 SVE has taken. Doing this via a function attribute set in the frontend is basically a workaround for the fact that several analyzes which need the information (i.e. known bits, lvi, scev) can't easily use TTI without significant amounts of plumbing changes.
This patch hard codes "v" numbers, and directly follows the SVE precedent as a result. In a follow up, I hope to drive this from RISCVISAInfo.h/cpp instead, but the MinVLen number being returned from that interface seemed to always be 0 (which is wrong), and I haven't figured out what's going wrong there.
Differential Revision: https://reviews.llvm.org/D135894
Zahira Ammarguellat [Mon, 17 Oct 2022 13:36:18 +0000 (09:36 -0400)]
Fix LIT test func-attr.c added by https://reviews.llvm.org/D135097.
Differential Revision: https://reviews.llvm.org/D136084
Fangrui Song [Mon, 17 Oct 2022 18:01:10 +0000 (11:01 -0700)]
[ELF] Make relocateAlloc target specific. NFC
The target-specific code (AArch64, PPC64) does not fit into the generic code and
adds virtual function overhead. Move relocateAlloc into ELF/Arch/ instead. This
removes many virtual functions (relaxTls*). In addition, this helps get rid of
getRelocTargetVA dispatch and many RelExpr members in the future.
Sjoerd Meijer [Mon, 17 Oct 2022 17:53:38 +0000 (23:23 +0530)]
Recommit "[LoopFlatten] Enable it by default"
The sanitizer bots turned green again after another change went in, i.e.
revert
26dd64ba9cfabe5474bb207f3b7099965f81fed7, so I don't think this
patch was causing the problems.
Arthur Eubanks [Mon, 17 Oct 2022 05:10:58 +0000 (22:10 -0700)]
[llvm-reduce] Reduce comdats
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D136054
Craig Topper [Mon, 17 Oct 2022 17:00:24 +0000 (10:00 -0700)]
[TargetLowering][RISCV][Sparc] Don't emit zero check in CTTZTableLookup for CTTZ_ZERO_UNDEF.
The code incorrectly checked for CTLZ_ZERO_UNDEF instead of
CTTZ_ZERO_UNDEF.
While I was there I flipped the condition into an early out.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D136010
Kazu Hirata [Mon, 17 Oct 2022 17:15:10 +0000 (10:15 -0700)]
[IR] Rename FuncletPadInst::getNumArgOperands to arg_size (NFC)
This patch renames FuncletPadInst::getNumArgOperands to arg_size for
consistency with CallBase, where getNumArgOperands was removed in
favor of arg_size in commit
3e1c787b3160bed4146d3b2b5f922aeed3caafd7
Differential Revision: https://reviews.llvm.org/D136048
Fangrui Song [Mon, 17 Oct 2022 17:08:47 +0000 (10:08 -0700)]
[ELF] Move PPC64 above. NFC
Prepare for a refactoring.
Fangrui Song [Mon, 17 Oct 2022 16:58:51 +0000 (16:58 +0000)]
[AArch64] Fix warnings
Sjoerd Meijer [Mon, 17 Oct 2022 16:41:41 +0000 (22:11 +0530)]
Revert "[LoopFlatten] Enable it by default"
This reverts commit
233659c7ae9b83b64a9f739d340736bca39c3d2e.
I see some sanitizer build bot failures. Not sure if it is change
causing it, but let's see if a revert returns the bots to green...
Paul Kirth [Thu, 6 Oct 2022 23:13:26 +0000 (23:13 +0000)]
[llvm-readobj] Improve JSON output
The current implementation outputs JSON in the following way:
[{'<filename>':{'FileSummary':{},...}}]
Using the filename as a key makes processing the JSON data awkward, and
should be avoided. This patch removes that outer key, since the
'FileSummary' data also includes a 'File' field, and so we lose no data.
Reviewed By: jhenderson, leonardchan
Differential Revision: https://reviews.llvm.org/D134843
Nathan Sidwell [Thu, 1 Sep 2022 17:21:24 +0000 (10:21 -0700)]
[modules] Fix callback argument thinko
VisbleModuleSet::setVisible takes a callback, to inform of modules
being made (transitively) visible. However, we were calling it as
'Vis(M)' from a recursive lambda, where 'M' is a capture of
setVisible's M, module parameter. Thus we can invoke the callback
multiple times, passing the same value to it each time.
Everywhere else in the lambda, we refer to V.M of the lambda's
Visiting parameter. We should be doing so for the callback. Thus
we'll pass the outermost module on the outermost recursive call, and
as we descend the imports, we'll pass each import to the callback.
Reviewed By: iains
Differential Revision: https://reviews.llvm.org/D135958
Jeff Niu [Mon, 17 Oct 2022 04:27:20 +0000 (21:27 -0700)]
[mlir] Remove assert from RegionBranchOpInterface verifier
This assert is erroneous because an op implementing
`RegionBranchOpInterface` can have variadic regions and in some cases
have zero regions, in which case the only possible control flow is
branching from the parent op to itself.
Reviewed By: rriddle, jpienaar
Differential Revision: https://reviews.llvm.org/D136052
Mingming Liu [Fri, 14 Oct 2022 22:26:04 +0000 (15:26 -0700)]
[AArch64]Enhance 'isBitfieldPositioningOp' to find pattern (shl(and(val,mask), N).
Before this patch (and D135844)
- Given DAG node shl(op, N), isBitfieldPositioningOp uses (optionally shifted [1] ) op as the Src (least significant bits of Src are inserted into DstLSB of Dst node).
After this patch
- If op is and(val, mask), isBitfieldPositioningOp tries to see through and and find if val is a simpler source than op.
It helps in a similar (probably symmetric) way how isSeveralBitsExtractOpFromShr [2] optimizes isBitfieldExtractOpFromShr
Existing test cases are improved without regressions.
[1] https://github.com/llvm/llvm-project/blob/
cbd8464595220b5ea76c70ac9965d84970c4b712/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp#L2546
[2] https://github.com/llvm/llvm-project/blob/
cbd8464595220b5ea76c70ac9965d84970c4b712/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp#L2057
Differential Revision: https://reviews.llvm.org/D135850
Ellis Hoag [Thu, 13 Oct 2022 23:38:02 +0000 (16:38 -0700)]
[clang] Fix crash with -funique-internal-linkage-names
Calling `getFunctionLinkage(CalleeInfo.getCalleeDecl())` will crash when the declaration does not have a body, e.g., `extern void foo();`. Instead, we can use `isExternallyVisible()` to see if the delcaration has internal linkage.
I believe using `!isExternallyVisible()` is correct because the clang linkage must be `InternalLinkage` or `UniqueExternalLinkage`, both of which are "internal linkage" in llvm.
https://github.com/llvm/llvm-project/blob/
9c26f51f5e178ac0fda98419e3a61d205d3b58b1/clang/include/clang/Basic/Linkage.h#L28-L40
Fixes https://github.com/llvm/llvm-project/issues/54139
Reviewed By: tmsriram
Differential Revision: https://reviews.llvm.org/D135926
Keith Walker [Thu, 13 Oct 2022 12:56:02 +0000 (13:56 +0100)]
[ARM] Add additional targets to divide tests.
The main motivation for these additional targets is to cover the
differences in the instructions available between Thumb2 and Thumb1.
Ths shows up in these test due to the lack of the following in
Thumb1:
- Mulitply and Subtract instruction (mls) - used when calculating
a remainder.
- Unsigned Muliple Long instruction (umull) - used in certain
cases when optimising division with a constant.
Differential Revision: https://reviews.llvm.org/D135875
Michał Górny [Sat, 8 Oct 2022 16:25:49 +0000 (18:25 +0200)]
[lldb] [MainLoopPosix] Fix crash upon adding lots of pending callbacks
If lots of pending callbacks are added while the main loop has exited
already, the trigger pipe buffer fills in, causing the write to fail
and the related assertion to fail. To avoid this, add a boolean member
indicating whether the callbacks have been triggered already.
If the trigger was done, avoid writing to the pipe until loops proceeds
to run them and resets the variable.
Besides fixing the issue, this also avoids writing to the pipe multiple
times if callbacks are added faster than the loop is able to process
them. Previously, this would lead to the loop performing multiple read
iterations from pipe unnecessarily.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D135516
Mark de Wever [Mon, 17 Oct 2022 15:42:00 +0000 (17:42 +0200)]
[libc++] Adds missing includes.
Fixes breakage of modular builds when including sort.h directly.
Alex Zinenko [Mon, 17 Oct 2022 12:47:03 +0000 (12:47 +0000)]
[mlir] add utilites for DiagnosedSilenceableFailure
This class adds helper functions similar to `emitError` for the
DiagnosedSilenceableFailure class in both the silenceable and definite
failure cases. These helpers simplify the use of said class and make
tranfsorm op application code idiomatic.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D136072
Peixin Qiao [Mon, 17 Oct 2022 15:27:17 +0000 (23:27 +0800)]
[flang] Fix the trivial type passed as value with bind(C)
In the callee side, the value cannot be used directly. For example, the
dummy argument is lhs variable or the dummy argument is passed to
another procedure as actual argument.
Fix this by allocating one temporary storage and store the value. Then
map the symbol of dummy argument to the `mlir::Value` of the temporary.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D136009
Nawrin Sultana [Fri, 30 Sep 2022 21:10:43 +0000 (16:10 -0500)]
[OpenMP] Add upper limit to TPAUSE exponential backoff time
Differential Revision: https://reviews.llvm.org/D135003
Simon Pilgrim [Mon, 17 Oct 2022 15:19:02 +0000 (16:19 +0100)]
[DAG] visitShiftByConstant - replace constant detection with FoldConstantArithmetic
Instead of checking that an operand is constant/opaque before calling getNode() and then checking that the result is a constant, just use FoldConstantArithmetic which will just early-out if the operands are not constant foldable.
Mingming Liu [Thu, 13 Oct 2022 00:49:04 +0000 (17:49 -0700)]
[AArch64][NFC]Refactor 'isBitfieldPositioningOp' so that DAG nodes with different Opcode are handled with separate helper functions.
Using different helper functions for DAG nodes with different Opcode allows specialization.
- 'isBitfieldExtractOp' [1] shows how specialization based on Opcode could catch more patterns.
- The refactor paves the way (e.g., makes diff clearer) for enhancement in {D135844,D135850,D135852}
[1] https://github.com/llvm/llvm-project/blob/
cbd8464595220b5ea76c70ac9965d84970c4b712/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp#L2163-L2202
Differential Revision: https://reviews.llvm.org/D135843
Alex Zinenko [Mon, 17 Oct 2022 13:37:09 +0000 (13:37 +0000)]
[mlir] stopgap for incorrect vector.contract lowering
`vector.contract` is being lowered to the default mul/add contraction
regardless if of the kind indicated. Stop the lowering completely in
this case until the correct one can be implemented.
Reviewed By: springerm, ThomasRaoux
Differential Revision: https://reviews.llvm.org/D136079
Sanjay Patel [Mon, 17 Oct 2022 14:12:24 +0000 (10:12 -0400)]
[VectorCombine] fix crashing on match of non-canonical fneg
We can't assume that operand 0 is the negated operand because
the matcher handles "fsub -0.0, X" (and also +0.0 with FMF).
By capturing the extract within the match, we avoid the bug
and make the transform more robust (can't assume that this
pass will only see canonical IR).
Nikita Popov [Mon, 17 Oct 2022 14:46:03 +0000 (16:46 +0200)]
[BasicAA] Add test for phi of geps of alloca (NFC)
Make sure we continue determining NoAlias in this case, where we
have a phi of constant index GEPs based on an alloca.
Nicola Lancellotti [Fri, 7 Oct 2022 11:14:50 +0000 (12:14 +0100)]
[AArch64] Canonicalize ZERO_EXTEND to VSELECT
Differential Revision: https://reviews.llvm.org/D135596
Simon Pilgrim [Mon, 17 Oct 2022 14:20:26 +0000 (15:20 +0100)]
Remove trailing whitespace. NFC.
Nikita Popov [Fri, 30 Sep 2022 10:13:40 +0000 (12:13 +0200)]
Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify
Relative to the previous attempt, this is rebased over the
InstSimplify fix in
ac74e7a7806480a000c9a3502405c3dedd8810de,
which addresses the miscompile reported in PR58401.
-----
foldOpIntoPhi() currently only folds operations into the phi if all
but one operands constant-fold. The two exceptions to this are freeze
and select, where we allow more general simplification.
This patch makes foldOpIntoPhi() generally simplification based and
removes all the instruction-specific logic. We just try to simplify
the instruction for each operand, and for the (potentially) one
non-simplified operand, we move it into the new block with adjusted
operands.
This fixes https://github.com/llvm/llvm-project/issues/57448, which
was my original motivation for the change.
Differential Revision: https://reviews.llvm.org/D134954
Simon Pilgrim [Mon, 17 Oct 2022 13:52:33 +0000 (14:52 +0100)]
[AMDGPU] Add regression test cases reported on D136042
Nikita Popov [Mon, 17 Oct 2022 13:43:11 +0000 (15:43 +0200)]
[InstSimplify] Only check self-simplify in simplifyInstruction()
InstSimplify currently checks whether the instruction simplifies
back to itself, and returns undef in that case. Generally, this
should only occur in unreachable code.
However, this was also done for the simplifyInstructionWithOperands()
API. In that case, the instruction only serves as a template that
provides the opcode and other non-operand data. In this case,
simplifying back to the same "instruction" may be expected. This
caused PR58401 in conjunction with D134954.
As such, move this check into simplifyInstruction() only. The only
other caller of simplifyInstructionWithOperands() also handles the
self-simplification case explicitly.
Jean Perier [Mon, 17 Oct 2022 13:40:39 +0000 (15:40 +0200)]
[flang] Add an enum attribute to carry Fortran attributes
Currently, Fortran attributes are mostly represented via the presence of
named attribute with special names (fir.target, fir.contiguous,
fir.optional...).
Create an enum so that these attributes can be more easily and safely
manipulated in FIR.
This patch does not add usages for it yet. It is planned to use in it in
the future HLFIR and fir.declare operations. This is added to FIR and
not HLFIR because it is intended to be used on fir.declare that will
be part of FIR, and seems also usefull for FIR operations.
Differential Revision: https://reviews.llvm.org/D135961
Simon Pilgrim [Mon, 17 Oct 2022 13:35:10 +0000 (14:35 +0100)]
[AMDGPU] Regenerate bfe-combine.ll and bfe-patterns.ll
Nikita Popov [Mon, 17 Oct 2022 13:36:28 +0000 (15:36 +0200)]
[InstCombine] Add test for PR58401 (NFC)
Oleksandr "Alex" Zinenko [Mon, 17 Oct 2022 13:28:36 +0000 (15:28 +0200)]
[mlir] fix markdown in VectorOps.td
Carlos Alberto Enciso [Mon, 17 Oct 2022 13:26:48 +0000 (14:26 +0100)]
Revert "[llvm-debuginfo-analyzer] (02/09) - Driver and documentation"
This reverts commit
fe7a3cedf77125a6309150d85cecbc20b1a31775.
Ivan Butygin [Tue, 11 Oct 2022 23:14:35 +0000 (01:14 +0200)]
[mlir][linalg] Fix canonicalizer crash for `linalg.generic` with mixed semantics
`EraseIdentityGenericOp` for `!hasBufferSemantics()` assumed fully tensor semantics and tried to access non-existent return values.
Differential Revision: https://reviews.llvm.org/D135725
Tobias Gysi [Mon, 17 Oct 2022 12:43:35 +0000 (15:43 +0300)]
[mlir][llvm] Add support for importing masked intrinsics from LLVM IR.
The revision adds support for importing the masked load/store and
gather/scatter intrinsics from LLVM IR. To enable the import, the
revision also includes an extension of the mlirBuilder code generation
to support variadic arguments.
Depends on D136057
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D136058
Carlos Alberto Enciso [Mon, 17 Oct 2022 12:46:55 +0000 (13:46 +0100)]
[llvm-debuginfo-analyzer] (02/09) - Driver and documentation
llvm-debuginfo-analyzer is a command line tool that processes debug
info contained in a binary file and produces a debug information
format agnostic “Logical View”, which is a high-level semantic
representation of the debug info, independent of the low-level
format.
The code has been divided into the following patches:
1) Interval tree
2) Driver and documentation
3) Logical elements
4) Locations and ranges
5) Select elements
6) Warning and internal options
7) Compare elements
8) ELF Reader
9) CodeView Reader
Full details:
https://discourse.llvm.org/t/llvm-dev-rfc-llvm-dva-debug-information-visual-analyzer/62570
This patch:
Driver and documentation
- Command line options.
- Full documentation.
- String Pool table.
Reviewed By: psamolysov, probinson
Differential Revision: https://reviews.llvm.org/D125777
Tobias Gysi [Mon, 17 Oct 2022 12:29:53 +0000 (15:29 +0300)]
[mlir][llvm] Use the tablegen error handling (NFC).
Use PrintError to extend the error message with location information in
LLVMIRConversionGen.cpp. Additionally, promote potentially user facing
error messages from assertions to real errors.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D136057
Florian Hahn [Mon, 17 Oct 2022 11:48:50 +0000 (12:48 +0100)]
Revert "Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify"
This reverts commit
333246b48ea4a70842e78c977cc92d365720465f.
It looks like this patch causes a mis-compile:
https://github.com/llvm/llvm-project/issues/58401
Fixes #58401.
Peixin Qiao [Mon, 17 Oct 2022 11:46:18 +0000 (19:46 +0800)]
[flang][OpenMP] Fix the use-associated bug in threadprivate directive lowering
The symbol may be used by use-association for multiple times such
as one in module specification part and one in module procedure.
Then in module procedure, the variable instantiation will be called
for multiple times. But we only need to threadprivatize it once and
use the threadprivatized value for the second time.
Fix #58379.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D136035
Sjoerd Meijer [Mon, 17 Oct 2022 09:06:30 +0000 (14:36 +0530)]
[LoopFlatten] Enable it by default
LoopFlatten has been in the code base off by default for years, but this
enables it to run by default. Downstream this has been running for
years, so it has been exposed to quite some code. Then around the time
we switched to the NPM, several fixes went in related to updating the
MemorySSA state and we moved it to a loop pass manager, which both
helped preventing rerunning certain analysis passes, and thus helped a
bit with compile-times.
About compile-times, adding a pass isn't free, but this should see only
very minor increases. The pass is relatively simple and there shouldn't
be anything algorithmically expensive because all it does is looking at
inner/outer loops and it checks assumptions on loop increments and
indices. If we see increases, I expect this to mainly come from
invalidation of analysis info, and perhaps subsequent passes to trigger
and do more. Despite its simplicity/restrictions, it triggers in most
code-bases, which makes it worth to enable this by default.
Differential Revision: https://reviews.llvm.org/D109958
Nathan Sidwell [Mon, 28 Feb 2022 18:13:44 +0000 (10:13 -0800)]
[demangler] Simplify OutputBuffer initialization
Every non-testcase use of OutputBuffer contains code to allocate an
initial buffer (using either 128 or 1024 as initial guesses). There's
now no need to do that, given recent changes to the buffer extension
heuristics -- it allocates a 1k(ish) buffer on first need.
Just pass in a buffer (if any) to the constructor. Thus the
OutputBuffer's ownership of the buffer starts at its own lifetime
start. We can reduce the lifetime of this object in several cases.
That new constructor takes a 'size_t *' for the size argument, as all
uses with a non-null buffer are passing through a malloc'd buffer from
their own caller in this manner.
The buffer reset member function is never used, and is deleted.
Some adjustment to a couple of uses is needed, due to the lazy buffer
creation of this patch.
a) the Microsoft demangler can demangle empty strings to nothing,
which it then memoizes. We need to avoid the UB of passing nullptr to
memcpy.
b) a unit test checks insertion of no characters into an empty buffer.
We need to avoid UB when converting that to std::string.
The original buffer initialization code would return a failure code if
that first malloc failed. Existing code either ignored that, called
std::terminate with a FIXME, or returned an error code.
But that's not foolproof anyway, as a subsequent buffer extension
failure ends up calling std::terminate. I am working on addressing
that unfortunate failure mode in a manner more consistent with the C++
ABI design.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D122604
David Spickett [Mon, 17 Oct 2022 10:55:50 +0000 (10:55 +0000)]
Revert "[llvm] Remove redundaunt typename (NFC)"
This reverts commit
3577e606dad0fa8f54e29e24673ff63bb7dfa880.
Due to buildbot failures on Arm and Arm64.
https://lab.llvm.org/buildbot/#/builders/96/builds/30231
David Spickett [Mon, 17 Oct 2022 10:55:19 +0000 (10:55 +0000)]
Revert "[lldb] Use std::underlying_type_t (NFC)"
This reverts commit
921a4d5be4bbe3c337419dfcc313b3eb892c2870.
Due to buildbot failures on Arm and Arm64.
https://lab.llvm.org/buildbot/#/builders/96/builds/30231
David Spickett [Tue, 11 Oct 2022 14:44:11 +0000 (14:44 +0000)]
[compiler-rt] Relax pthread_getaffinity test to account for cgroups/docker
Fixes #58283
When running in a docker container you can have fewer cores assigned
to you than get_nrpoc would suggest.
Since the test just wants to know that interception worked, allow
any result > 0 and <= the global core count.
Reviewed By: MaskRay, vitalybuka
Differential Revision: https://reviews.llvm.org/D135677
Alexander Belyaev [Fri, 14 Oct 2022 17:59:55 +0000 (19:59 +0200)]
[mlir] Simplify DestinationStyleOpInterface.
Differential Revision: https://reviews.llvm.org/D135348
Nikita Popov [Mon, 17 Oct 2022 10:34:55 +0000 (12:34 +0200)]
[BasicAA] Support loop phis in pointsToConstantMemory()
When looking for underlying objects, if we encounter one that we
have already seen, then we should skip it (as it has already been
checked) rather than bail out. In particular, this adds support
for the case where we have a loop use of a phi recurrence.
Nikita Popov [Mon, 17 Oct 2022 10:31:02 +0000 (12:31 +0200)]
[BasicAA] Add tests for constant memory with loop phi (NFC)
Jay Foad [Mon, 17 Oct 2022 10:01:56 +0000 (11:01 +0100)]
[AMDGPU] Common up some generated checks in fnearbyint.ll
Also remove -mattr=-flat-for-global which is not needed for generated
checks.
Jean Perier [Mon, 17 Oct 2022 07:57:16 +0000 (09:57 +0200)]
[flang] Introduce option to lower expression to HLFIR
Preliminary work on HLFIR. Introduce option that will allow testing
lowering via HLFIR until this is ready to replace the current expression
lowering.
See https://reviews.llvm.org/D134285 for more context about the plan.
Differential Revision: https://reviews.llvm.org/D135959
Chuanqi Xu [Mon, 17 Oct 2022 07:48:13 +0000 (15:48 +0800)]
[NFC] Judge if we have std c++ modules in RenderModulesOptions
This patch moves the judgement if the std c++ modules feature is enabled
into the RenderModulesOptions function. It simplify the code a little
bit further more. It also helps further patches.
Max Kazantsev [Mon, 17 Oct 2022 05:08:49 +0000 (12:08 +0700)]
[Test] Add tests showing that instcombine does not deal with freeze(load !range)
Max Kazantsev [Mon, 17 Oct 2022 05:07:46 +0000 (12:07 +0700)]
[Test][NFC] Regenerate test check using update_tests script
Chuanqi Xu [Mon, 17 Oct 2022 02:46:07 +0000 (10:46 +0800)]
[C++20] [Coroutines] Add ReleaseNotes about addressing thread identifiaction problems
The thread identification problems in coroutines are addressed now in
1cedc51ff5a2a4f51a4c7e8bb04bd. Although the original problem occurs in
LLVM optimizer. The C++ users have strong feeling about it. So it may be
necessary to add a ReleaseNote in clang for it.
Closes https://github.com/llvm/llvm-project/issues/47177
Closes https://github.com/llvm/llvm-project/issues/47179
Chuanqi Xu [Mon, 17 Oct 2022 02:22:43 +0000 (10:22 +0800)]
[Coroutines] Don't merge readnone calls in presplit coroutines
Another alternative to fix the thread identification problem in
coroutines.
We plan to fix this problem by unifying memory effecting attributes. See
https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579.
But it may be a long-term project. And it is a pity that the coroutines
can't resume in different threads for years. So this one is temporary
fix. It may cause unnecessary performance regression for coroutines. But
correctness are more important. And this one is planned to be reverted
after we are able to unify the memory effecting attributes actually.
Reviewed By: jdoerfert, rjmccall
Differential Revision: https://reviews.llvm.org/D135550
Ting Wang [Mon, 17 Oct 2022 02:01:47 +0000 (22:01 -0400)]
[clang][PowerPC] PPC64 VAArg fix right-alignment for aggregates fit in register
PPC64 ABI pass aggregates smaller than a register into the least
significant bits of the register. In the case of variadic functions,
they will end up right-aligned in their argument slots in the argument
area on big-endian targets. Apply right-alignment for these aggregates.
Fixes #55900.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D133338
Kazu Hirata [Sun, 16 Oct 2022 23:21:00 +0000 (16:21 -0700)]
[llvm] Use llvm::find (NFC)
Florian Hahn [Sun, 16 Oct 2022 22:24:06 +0000 (23:24 +0100)]
[ConstraintElim] Fix signed integer overflow for inbounds GEP.
For inbounds GEPs, signed overflow yields poison, so it is fine for the
coefficients to wrap as well. This fixes an UBSan failure.
rkayaith [Fri, 14 Oct 2022 18:21:44 +0000 (14:21 -0400)]
[mlir][ods] Support default-valued attributes in optional groups
Add support for default-valued attributes as optional-group anchors. The
attribute is considered present if it holds a non-default value.
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D134993
Florian Hahn [Sun, 16 Oct 2022 20:53:11 +0000 (21:53 +0100)]
[ConstraintElim] Replace custom GEP index handling by using existing code
Instead of duplicating the existing decomposition code for GEP indices
just use the existing code by calling the existing decompose function on
the index expression and multiply the result's coefficients by the scale of
the index.
This both reduces code duplication and generalizes the pattern we can
handle.
Fangrui Song [Sun, 16 Oct 2022 20:15:44 +0000 (13:15 -0700)]
[CMake] Remove CLANG_DEFAULT_STD_C/CLANG_DEFAULT_STD_CXX
When Clang is used as a cross compiler, it should respect the target
platform default. Defaulting to a configure-time CLANG_DEFAULT_STD_C/CLANG_DEFAULT_STD_CXX
does not make much sense.
When Clang is used as a single-platform compiler, we should use Clang
configuration file (https://discourse.llvm.org/t/configuration-files/42529
https://clang.llvm.org/docs/UsersManual.html#configuration-files).
The Gentoo needs from D34365 has been satisfied by a configuration file.
Reviewed By: mgorny
Differential Revision: https://reviews.llvm.org/D133375
Fangrui Song [Sun, 16 Oct 2022 19:39:37 +0000 (12:39 -0700)]
[ELF] Remove RelocationScanner::target. NFC
Kazu Hirata [Sun, 16 Oct 2022 19:33:47 +0000 (12:33 -0700)]
[clang] Use llvm::find (NFC)
Florian Hahn [Sun, 16 Oct 2022 19:24:16 +0000 (20:24 +0100)]
[ConstraintElim] Support `add nsw` for unsigned preds with positive ops.
If both operands of an `add nsw` are known positive, it can be treated
the same as `add nuw` and added to the unsigned system.
https://alive2.llvm.org/ce/z/6gprff
Roman Lebedev [Sun, 16 Oct 2022 18:38:59 +0000 (21:38 +0300)]
[NFC][X86] Test commit, add test with bad mask vector legalization
Inspired by codegen of `@test`
from `llvm/test/Analysis/CostModel/X86/masked-interleaved-*-i16.ll`.
Fangrui Song [Sun, 16 Oct 2022 19:19:57 +0000 (12:19 -0700)]
[ELF] Move R_TPREL/R_TPREL_NEG check into handleTlsRelocation
Fangrui Song [Sun, 16 Oct 2022 19:08:08 +0000 (12:08 -0700)]
[ELF] Set DF_STATIC_TLS for AArch64/PPC32/PPC64
Fangrui Song [Sun, 16 Oct 2022 18:55:38 +0000 (11:55 -0700)]
[ELF][test] Improve AArch64 TLS IE tests
Simon Pilgrim [Sun, 16 Oct 2022 17:15:44 +0000 (18:15 +0100)]
[BPF] Add (failing) testcase for Issue #57872
Kazu Hirata [Sun, 16 Oct 2022 17:11:29 +0000 (10:11 -0700)]
[clang] Use std::clamp (NFC)
Note that the constructor of MipsABIInfo guarantees that
MinABIStackAlignInBytes <= StackAlignInBytes, so we can use std::clamp
safely.
Kazu Hirata [Sun, 16 Oct 2022 16:19:09 +0000 (09:19 -0700)]
[AMDGPU] Use llvm::any_of (NFC)
Kazu Hirata [Sun, 16 Oct 2022 16:19:08 +0000 (09:19 -0700)]
[clang] Use llvm::is_contained (NFC)
bixia1 [Thu, 13 Oct 2022 15:34:36 +0000 (08:34 -0700)]
[mlir][sparse] Move routines for generating memref.alloca to CodegenUtils.
This is to allow the use of the routines in the rewrite pass.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D135890
Sanjay Patel [Sun, 16 Oct 2022 14:01:10 +0000 (10:01 -0400)]
[InstCombine] try to determine "exact" for sdiv
If the divisor is a power-of-2 or negative-power-of-2 and the dividend
is known to have >= trailing zeros than the divisor, the division is exact:
https://alive2.llvm.org/ce/z/UGBksM (general proof)
https://alive2.llvm.org/ce/z/D4yPS- (examples based on regression tests)
This isn't the most direct optimization (we could create ashr in these
examples instead of relying on existing folds for exact divides), but
it's possible that there's a more general constraint than just a pow2
divisor, so this might be extended in the future.
This should solve issue #58348.
Differential Revision: https://reviews.llvm.org/D135970
Sanjay Patel [Fri, 14 Oct 2022 16:23:16 +0000 (12:23 -0400)]
[InstCombine] add tests for sdiv with (neg)pow2 divisor; NFC
Sanjay Patel [Fri, 14 Oct 2022 14:47:16 +0000 (10:47 -0400)]
[InstCombine] use isKnownNonNegative() for readability; NFCI
This should be functionally equivalent - both calls are thin
wrappers around computeKnownBits(). We'll probably want to use
known-bits directly in follow-up patches because that could
determine "exact" for example (see issue #58348).
Florian Hahn [Sun, 16 Oct 2022 14:51:33 +0000 (15:51 +0100)]
[ConstraintElim] Add tests for add nsw with unsigned predicates.
bixia1 [Fri, 14 Oct 2022 23:39:54 +0000 (16:39 -0700)]
[mlir][sparse] Add readCOOElement for reading a sparse tensor element from files.
Use the routine for openSparseTensorCOO and getSparseTensorReaderNext.
Reviewed By: aartbik, wrengr
Differential Revision: https://reviews.llvm.org/D135732
Jan Sjodin [Wed, 12 Oct 2022 17:57:15 +0000 (13:57 -0400)]
[OpenMP][OpenMPIRBuilder] Migrate OffloadEntriesInfoManager from clang to OMPIRbuilder
This patch moves the implementation of the OffloadEntriesInfoManager
to the OMPIRbuilder. This class will later be used by flang as well.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D135786