282954 Commits

Author SHA1 Message Date
AZero13
ffd2633061
[InstCombine] Fold mul (shr exact (X, N)), 2^N + 1 -> add (X , shr exact (X, N)) (#112407)
Alive2 Proofs:
https://alive2.llvm.org/ce/z/aJnxyp
https://alive2.llvm.org/ce/z/dyeGEv
2025-02-13 14:25:09 +08:00
Vitaly Buka
1032df6f60
[LTO][Pipelines][Coro] Handle coroutines in LTO pipeline (#126168)
ThinLTO delays handling of coroutines to ThinLTO backend.
However it's usually possible to use ThinLTO prelink objects for FullLTO.

In this case we have left-over coroutines which crash in codegen.

Issue #104525.
2025-02-12 21:39:32 -08:00
Lang Hames
9456e7fcdd [ORC] Silence unused variable warnings. 2025-02-13 15:24:43 +11:00
NAKAMURA Takumi
cdf45447ef Orc: Suppress a warning in #126691 2025-02-13 13:07:19 +09:00
Brad Smith
89d636ba91
[Support] Fix building on FreeBSD and OpenBSD (#127005)
Fix building after a6f7cb54d3c268ea4748a0ff783b4b030c3195d9.

Check for the function getauxval() instead of just the sys/auxv.h
header.
2025-02-12 22:55:22 -05:00
Thurston Dang
df07121d54
[hwasan][NFCI] Rename ClRandomSkipRate to ClRandomKeepRate (#126990)
The meaning of ClRandomSkipRate was inverted in
https://github.com/llvm/llvm-project/pull/88070 but the variable name
was not changed. This patch fixes it to avoid confusion.

Additionally, it elaborates the flag description to mention the
interaction between the random keep rate and hotness cutoff.
2025-02-12 18:43:00 -08:00
Tristan Ross
a6f7cb54d3
[Support] Prefer AUX vector for page size (#126863)
Prefers the page size to come from the AUX vector, `getpagesize` is
removed from POSIX.1-2001. Also throws in a couple asserts to ensure the
page size is a valid value.
2025-02-13 11:39:49 +11:00
Thurston Dang
51d8255203
[msan] Handle Arm NEON saturating extract and narrow (#125742)
This handles NEON saturating extract and narrow (Intrinsic::aarch64_neon_{sqxtn, sqxtun, uqxtn}) by (ab)using handleShadowOr() to perform the shadow cast. Previously, these were unknown intrinsics handled suboptimally by visitInstruction.

Updates the tests from https://github.com/llvm/llvm-project/pull/125288 and https://github.com/llvm/llvm-project/pull/125140
2025-02-12 16:22:49 -08:00
Robert Imschweiler
bcba3117c0
[AMDGPU] SelDAG: fix lowering of undefined workitem intrinsics (#126058)
GlobalISel already handles undefined workitem.id.{x,y,z} intrinsics,
SelDAG failed in AMDGPUISelLowering.cpp due to a failed assertion in
`AMDGPUTargetLowering::loadInputValue`: `Arg && "Attempting to load
missing argument"`. This commit changes the behavior of SelDAG to
instead use a zero constant.

This LLVM defect was identified via the AMD Fuzzing project.
2025-02-12 18:41:41 -05:00
vporpo
1c207f1b6e
[SandboxVec][DAG] Fix DAG when old interval is mem free (#126983)
This patch fixes a bug in `DependencyGraph::extend()` when the old
interval contains no memory instructions. When this is the case we
should do a full dependency scan of the new interval.
2025-02-12 15:06:30 -08:00
vporpo
31cb807537
[SanbdoxVec][BottomUpVec] Fix diamond shuffle with multiple vector inputs (#126965)
When the operand comes from multiple inputs then we need additional
packing code. When the operands are scalar then we can use a single
InsertElementInst. But when the operands are vectors then we need a
chain of ExtractElementInst and InsertElementInst instructions to insert
the vector value into the destination vector. This is what this patch
implements.
2025-02-12 14:33:05 -08:00
LLVM GN Syncbot
37952ef75f [gn build] Port 92f916faba13 2025-02-12 22:22:01 +00:00
Thurston Dang
c6a39697a9
[hwasan][NFCI] Add more test cases to llvm/test/Instrumentation/HWAddressSanitizer/pgo-opt-out.ll (#126980)
Add more combinations of parameters to test that the skip conditions are
OR'ed together
2025-02-12 14:20:23 -08:00
Jeffrey Byrnes
c5a4512d85
[AMDGPU] iglp.opt does not clobber memory operands (#126976)
I think it was an accident that this wasn't included.
2025-02-12 14:11:02 -08:00
Shubham Sandeep Rastogi
92f916faba
Add a pass to collect dropped var statistics for MIR (#126686)
This patch attempts to reland
https://github.com/llvm/llvm-project/pull/120780 while addressing the
issues that caused the patch to be reverted.

Namely:

1. The patch had included code from the llvm/Passes directory in the
llvm/CodeGen directory.

2. The patch increased the backend compile time by 2% due to adding a
very expensive include in MachineFunctionPass.h

The patch has been re-structured so that there is no dependency between
the llvm/Passes and llvm/CodeGen directory, by moving the base class,
`class DroppedVariableStats` to the llvm/IR directory.

The expensive include in MachineFunctionPass.h has been changed to
contain forward declarations instead of other header includes which was
pulling a ton of code into MachineFunctionPass.h and should resolve any
issues when it comes to compile time increase.
2025-02-12 14:08:18 -08:00
S. Bharadwaj Yadavalli
f2650c54c9
[DirectX] Set Shader Flag DisableOptimizations (#126813)
- Set the shader flag `DisableOptimizations` based on `optnone`
attribute of shader entry functions.

- Add DXIL Metadata Analysis pass as pre-requisite for Shader Flags pass
to obtain entry function information collected therein.

- Named module metadata `dx.disable_optimizations` is intended to
indicate disabling optimizations (`-O0`) via commandline flag. However,
its intent is fulfilled by `optnone` attribute of shader entry functions as 
implemented in a recent change, and thus not needed. Delete
generation of named metadata and corresponding test file
`disable_opt.ll`.

- Add tests to verify correctness of setting shader flag.

Closes #112263
2025-02-12 16:45:01 -05:00
Thurston Dang
0d95631a3a
[msan] Handle llvm.[us]cmp (starship operator) (#125804)
Apply handleShadowOr to llvm.[us]cmp. Previously, llvm.[su]cmp was correctly handled heuristically when each parameter type is the same as the return type (e.g., `call i8 @llvm.ucmp.i8.i8(i8 %x, i8 %y)`) but handled incorrectly by visitInstruction when the return type is different e.g., (`call i8 @llvm.ucmp.i8.i62(i62 %x, i62 %y)`, `call <4 x i8> @llvm.ucmp.v4i8.v4i32(<4 x i32> %x, <4 x i32> %y)`).

Updates the tests from https://github.com/llvm/llvm-project/pull/125790
2025-02-12 13:38:45 -08:00
Thurston Dang
e9e6ba6a5e
[msan] Handle single-parameter Arm NEON vector convert intrinsics (#126136)
This handles the following llvm.aarch64.neon intrinsics, which were suboptimally handled by visitInstruction:
- fcvtas, fcvtau
- fcvtms, fcvtmu
- fcvtns, fcvtnu
- fcvtps, fcvtpu
- fcvtzs, fcvtzu

The old instrumentation checked that the shadow of every element of the input vector was fully initialized, and aborted otherwise. The new instrumentation propagates the shadow: for each element of the output, the shadow is initialized iff the corresponding element of the input is *fully* initialized (since these are floating-point to integer conversions).

Updates the tests from https://github.com/llvm/llvm-project/pull/126095
2025-02-12 13:20:22 -08:00
Florian Hahn
82605285b8 [LAA] Also clear CheckingGroups in RuntimePointerChecking::reset.
This fixes a crash when trying to print access-info in the newly added
test cases.
2025-02-12 21:49:22 +01:00
Vasileios Porpodas
e75e61728e [SandboxVec] Fix warnings introduced by 7a7f9190d03e 2025-02-12 12:43:24 -08:00
Philip Reames
859c871184
[RISCV] Default to MicroOpBufferSize = 1 for scheduling purposes (#126608)
This change introduces a default schedule model for the RISCV target
which leaves everything unchanged except the MicroOpBufferSize. The
default value of this flag in NoSched is 0. Both configurations
represent in order cores (i.e. no reorder window), the difference
between them comes down to whether heuristics other than latency are
allowed to apply. (Implementation details below)

I left the processor models which explicitly set MicroOpBufferSize=0
unchanged in this patch, but strongly suspect we should change those
too. Honestly, I think the LLVM wide default for this flag should be
changed, but don't have the energy to manage the updates for all
targets.

Implementation wise, the effect of this change is that schedule units
which are ready to run *except that* one of their predecessors may not
have completed yet are added to the Available list, not the Pending one.
The result of this is that it becomes possible to chose to schedule a
node before it's ready cycle if the heuristics prefer. This is
essentially chosing to insert a resource stall instead of e.g.
increasing register pressure.

Note that I was initially concerned there might be a correctness aspect
(as in some kind of exposed pipeline design), but the generic scheduler
doesn't seem to know how to insert noop instructions. Without that, a
program wouldn't be guaranteed to schedule on an exposed pipeline
depending on the program and schedule model in question.

The effect of this is that we sometimes prefer register pressure in
codegen results. This is mostly churn (or small wins) on scalar because
we have many more registers, but is of major importance on vector -
particularly high LMUL - because we effectively have many fewer
registers and the relative cost of spilling is much higher. This is a
significant improvement on high LMUL code quality for default rva23u
configurations - or any non -mcpu vector configuration for that matter.

Fixes #107532
2025-02-12 12:31:39 -08:00
vporpo
7a7f9190d0
[SandboxVec][Legality] Fix mask on diamond reuse with shuffle (#126963)
This patch fixes a bug in the creation of shuffle masks when vectorizing
vectors in case of a diamond reuse with shuffle. The mask needs to
enumerate all elements of a vector, not treat the original vector value
as a single element. That is: if vectorizing two <2 x float> vectors
into a <4 x float> the mask needs to have 4 indices, not just 2.
2025-02-12 12:29:09 -08:00
Philip Reames
9478822f4f
[RISCV] Decompose single source shuffles (without exact VLEN) (#126951)
(This is a re-apply for what was 8374d42. The bug there was fairly 
major - despite the comments and review description, the code was 
using each register in the source register group, not only the first 
register. This was completely wrong.)

This is a continuation of the work started in
https://github.com/llvm/llvm-project/pull/125735 to lower selected VLA
shuffles in linear m1 components instead of generating O(LMUL^2) or
O(LMUL*Log2(LMUL) high LMUL shuffles.

This pattern focuses on shuffles where all the elements being used
across the entire destination register group come from a single register
in the source register group. Such cases come up fairly frequently via
e.g. spread(N), and repeat(N) idioms.

One subtlety to this patch is the handling of the index vector for
vrgatherei16.vv. Because the index and source registers can have
different EEW, the index vector for the Nth chunk of the destination is
not guaranteed to be register aligned. In fact, it is common for e.g. an
EEW=64 shuffle to have EEW=16 indices which are four chunks per source
register. Given this, we have to pay a cost for extracting these chunks
into the low position before performing each shuffle.

I'd initially expressed this as a naive extract sub-vector for each data
parallel piece. However, at high LMUL, this quickly caused register
pressure problems since we could at worst need 4x the temporary
registers for the index. Instead, this patch uses a repeating slidedown
chained from previous iterations. This increases critical path by at
worst 3 slides (SEW=64 is the worst case), but reduces register pressure
to at worst 2x - and only if the original index vector is reused
elsewhere. I view this as arguably a bit of a workaround (since our
scheduling should have done better with the plain extract variant), but
a probably necessary one.
2025-02-12 12:10:35 -08:00
vporpo
6d7a84d72b
[SandboxVec][Scheduler] Fix top of schedule (#126820)
This patch fixes the way the top-of-schedule variable gets set and
updated. Before this patch it used to get updated whenever we scheduled
a bundle, which is wrong, as the top-of-schedule needs to be maintained
across scheduling attempts.

It should get reset only when we clear the schedule or when we destroy
the current schedule and re-schedule.
2025-02-12 11:52:01 -08:00
Simon Pilgrim
f719d8ac1c [X86] vec-strict-cmp-128-fp16.ll - regenerate VMOVSH comments 2025-02-12 18:48:55 +00:00
Simon Pilgrim
689f79d0f8 [X86] vec-strict-cmp-512-skx.ll - regenerate checks
Appears to have been manually edited at some point
2025-02-12 18:48:55 +00:00
Simon Pilgrim
a6a4252a15 [X86] vec-strict-fptoint - regenerate VPTERNLOG comments 2025-02-12 18:48:54 +00:00
Harald van Dijk
23209eb1d9 Revert "[DebugInfo] Update DIBuilder insertion to take InsertPosition (#126059)"
This reverts commit 3ec9f7494b31f2fe51d5ed0e07adcf4b7199def6.
2025-02-12 17:50:39 +00:00
Harald van Dijk
3ec9f7494b
[DebugInfo] Update DIBuilder insertion to take InsertPosition (#126059)
After #124287 updated several functions to return iterators rather than
Instruction *, it was no longer straightforward to pass their result to
DIBuilder. This commit updates DIBuilder methods to accept an
InsertPosition instead, so that they can be called with an iterator
(preferred), or with a deprecation warning an Instruction *, or a
BasicBlock *. This commit also updates the existing calls to the
DIBuilder methods to pass in iterators.
2025-02-12 17:38:59 +00:00
Simon Pilgrim
b04a980b55 [X86] 2011-10-27-tstore.ll - regenerate checks 2025-02-12 17:19:19 +00:00
Kazu Hirata
e9e717f405
[Utils] Avoid repeated hash lookups (NFC) (#126856) 2025-02-12 08:48:16 -08:00
Evgenii Kudriashov
99816a5af4
[Xtensa] Add XtensaDesc dependency to LLVMXtensaDisassembler (#126904)
There is an undefined reference to checkRegister in shared lib builds

Suspecting #124656
2025-02-12 23:48:01 +07:00
Kazu Hirata
c15806aa5a
[SPIRV] Avoid repeated hash lookups (NFC) (#126854) 2025-02-12 08:47:26 -08:00
Kazu Hirata
2e8f89f048
[Object] Avoid repeated map lookups (NFC) (#126853) 2025-02-12 08:46:55 -08:00
Kazu Hirata
71cceb1439
[CodeGen] Avoid repeated hash lookups (NFC) (#126852) 2025-02-12 08:45:53 -08:00
Kazu Hirata
df09290407
[Analysis] Avoid repeated hash lookups (NFC) (#126851) 2025-02-12 08:45:27 -08:00
Nick Sarnie
cb3498c670
[OpenMP][OpenMPIRBuilder] Support SPIR-V device variant matches (#126801)
We should be able to use `spirv64` as a device variant match and it
should be considered a GPU.

Also add the triple to an RTTI check.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-02-12 16:40:05 +00:00
Philip Reames
c77d202759 Revert "[RISCV] Decompose single source shuffles (without exact VLEN) (#126108)"
This reverts commit 8374d421861cd3d47e21ae7889ba0b4c498e8d85.  A miscompile
was reported against the review thread, reverting while we investigate.
2025-02-12 08:33:20 -08:00
Rahul Joshi
bee9664970
[TableGen] Emit OpName as an enum class instead of a namespace (#125313)
- Change InstrInfoEmitter to emit OpName as an enum class
  instead of an anonymous enum in the OpName namespace.
- This will help clearly distinguish between values that are 
  OpNames vs just operand indices and should help avoid
  bugs due to confusion between the two.
- Rename OpName::OPERAND_LAST to NUM_OPERAND_NAMES.
- Emit declaration of getOperandIdx() along with the OpName
  enum so it doesn't have to be repeated in various headers.
- Also updated AMDGPU, RISCV, and WebAssembly backends
  to conform to the new definition of OpName (mostly
  mechanical changes).
2025-02-12 08:19:30 -08:00
Philip Reames
ff8f6abe20 Reapply "[RISCV] Allow undef prefix for local repeating VLA shuffle lowering (#126097)"
(With a fix to recently added code.)

Implement the first TODO from #125735, and minorly cleanup code using
same style as the recently landed strict prefix case.
2025-02-12 07:40:13 -08:00
Kazu Hirata
73509781b5
[X86] Avoid repeated hash lookups (NFC) (#126857) 2025-02-12 23:38:01 +08:00
Alex MacLean
a282b6c486
[NVPTX] Convert scalar function nvvm.annotations to attributes (#125908)
Replace some more nvvm.annotations with function attributes,
auto-upgrading the annotations as needed. These new attributes will be
more idiomatic and compile-time efficient than the annotations.

- !"maxclusterrank" / !"cluster_max_blocks" -> "nvvm.maxclusterrank"
- !"minctasm" -> "nvvm.minctasm"
- !"maxnreg" -> "nvvm.maxnreg"
2025-02-12 07:33:22 -08:00
Simon Pilgrim
fbf46dfe35 [X86] fp-fold.ll - regenerate checks 2025-02-12 15:32:08 +00:00
Yingwei Zheng
34534442a8
[Docs][LangRef] Fix broken ref to pointer capture. NFC (#126910) 2025-02-12 23:14:58 +08:00
Alexey Bataev
bb3d789dfe [SLP][NFC]Improve dump of the ScheduleData, NFC 2025-02-12 06:51:30 -08:00
Nico Weber
e5268191e6 [gn] port fc4d87100a0 2025-02-12 09:50:32 -05:00
Alexey Bataev
e1935a2b15 Revert "[SLP][NFC]Improve dump of the ScheduleData, NFC"
This reverts commit 108e6bca693e5f44d2d17da5a6e06203a0290de7 to fix
error revealed by buildbots https://lab.llvm.org/buildbot/#/builders/159/builds/15888.
2025-02-12 06:34:27 -08:00
Vy Nguyen
fc4d87100a
Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (#126746)
Background: 

Telemetry code isn't always built (controlled by this
LLVM_BUILD_TELEMETRY cmake flag)
This means users of the library may not have the library. So we're
definding the `-DLLVM_BUILD_TELEMETRY` to be used in ifdef.
2025-02-12 09:33:52 -05:00
Jason Eckhardt
96ce8cadf9
[NFC][Lanai][Hexagon] Define DEBUG_TYPE after including Debug.h. (#125440)
This patch fixes some warnings/errors that occur with certain
compilers-- due to existing code not following the idiom mentioned in
`Debug.h`:

```
// LLVM_DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo"
// specify that your debug code belongs to class "foo". **Be careful that you only
// do this after including Debug.h and not around any #include of headers.**
```
2025-02-12 08:32:59 -06:00
Nikita Popov
f085261b59 [IRBuilder] Add additional overload with in-place Inserter construction (NFC)
Currently, for IRBuilders that require an explicitly constructed
Folder, we also force Inserter to be constructed and then copied.
Provide a variant where the Inserter uses in-place default
construction, to support cases where it is self-referential.
2025-02-12 15:29:47 +01:00