38313 Commits

Author SHA1 Message Date
Benjamin Maxwell
5899bca6ba
[AArch64][SME] Resume streaming-mode on entry to exception handlers (#156638)
This patch adds a new `TargetLowering` hook `lowerEHPadEntry()` that is
called at the start of lowering EH pads in SelectionDAG. This allows the
insertion of target-specific actions on entry to exception handlers.

This is used on AArch64 to insert SME streaming-mode switches at landing
pads. This is needed as exception handlers are always entered with
PSTATE.SM off, and the function needs to resume the streaming mode of
the function body.
2025-09-04 12:55:12 +01:00
Diana Picus
018dc1b397
[AMDGPU] Tail call support for whole wave functions (#145860)
Support tail calls to whole wave functions (trivial) and from whole wave
functions (slightly more involved because we need a new pseudo for the
tail call return, that patches up the EXEC mask).

Move the expansion of whole wave function return pseudos (regular and
tail call returns) to prolog epilog insertion, since that's where we
patch up the EXEC mask.
2025-09-04 10:34:43 +02:00
Nikita Popov
3f757a39f2
[CodeGen] Remove ExpandInlineAsm hook (#156617)
This hook replaces inline asm with LLVM intrinsics. It was intended to
match inline assembly implementations of bswap in libc headers and
replace them more optimizable implementations.

At this point, it has outlived its usefulness (see
https://github.com/llvm/llvm-project/issues/156571#issuecomment-3247638412),
as libc implementations no longer use inline assembly for this purpose.

Additionally, it breaks the "black box" property of inline assembly,
which some languages like Rust would like to guarantee.

Fixes https://github.com/llvm/llvm-project/issues/156571.
2025-09-04 09:28:11 +02:00
Yingwei Zheng
0d29279465
[DAGCombine] Propagate nuw when evaluating sub with narrower types (#156710)
Proof: https://alive2.llvm.org/ce/z/cdbzSL
Closes https://github.com/llvm/llvm-project/issues/156559.
2025-09-04 10:17:45 +08:00
Amara Emerson
4829dedfa9
[GlobalISel] Add multi-way splitting support for wide scalar shifts. (#155353)
This patch implements direct N-way splitting for wide scalar shifts
instead
of recursive binary splitting. For example, an i512 G_SHL can now be
split
directly into 8 i64 operations rather than going through i256 -> i128 ->
i64.

The main motivation behind this is to alleviate (although not entirely
fix)
pathological compile time issues with huge types, like i4224. The
problem
we see is that the recursive splitting strategy combined with our messy
artifact combiner ends up with terribly long compiles as tons of
intermediate
artifacts are generated, and then attempted to be combined ad-nauseum.

Going directly from the large shifts to the destination types
short-circuits
a lot of these issues, but it's still an abuse of the backend and
front-ends
should never be doing this sort of thing.
2025-09-03 10:25:52 -07:00
Kane Wang
7d6e72f110
[RISCV][GlobalISel] Lower G_ATOMICRMW_SUB via G_ATOMICRMW_ADD (#155972)
RISCV does not provide a native atomic subtract instruction, so this
patch lowers `G_ATOMICRMW_SUB` by negating the RHS value and performing
an atomic add. The legalization rules in `RISCVLegalizerInfo` are
updated accordingly, with libcall fallbacks when `StdExtA` is not
available, and intrinsic legalization is extended to support
`riscv_masked_atomicrmw_sub`.

For example, lowering

`%1 = atomicrmw sub ptr %a, i32 1 seq_cst`

on riscv32a produces:

```
li      a1, -1
amoadd.w.aqrl   a0, a1, (a0)
```

On riscv64a, where the RHS type is narrower than XLEN, it currently
produces:

```
li      a1, 1
neg     a1, a1
amoadd.w.aqrl   a0, a1, (a0)
```

There is still a constant-folding or InstConbiner gap. For instance,
lowering

```
%b = sub i32 %x, %y
%1 = atomicrmw sub ptr %a, i32 %b seq_cst
```

generates:

```
subw    a1, a1, a2
neg     a1, a1
amoadd.w.aqrl   a0, a1, (a0)
```

This sequence could be optimized further to eliminate the redundant neg.
Addressing this may require improvements in the Combiner or Peephole
Optimizer in future work.

---------

Co-authored-by: Kane Wang <kanewang95@foxmail.com>
2025-09-03 08:42:31 -07:00
Frederik Harwath
47793f9a73
[AMDGPU] Implement IR expansion for frem instruction (#130988)
This patch implements a correctly rounded expansion of the frem
instruction in LLVM IR. This is useful for target architectures for
which such an expansion is too involved to be implement in ISel
Lowering. The expansion is based on the code from the AMD device libs
and has been tested successfully against the OpenCL conformance tests on
amdgpu. The expansion is implemented in the preexisting "expand-fp"
pass. It replaces the expansion of "frem" in ISel for the amdgpu target;
it is enabled for targets which do not directly support "frem" and for
which no matching "fmod" LibCall is available.

---------

Co-authored-by: Matt Arsenault <Matthew.Arsenault@amd.com>
2025-09-03 16:27:15 +02:00
David Sherwood
7da91fa801
[CodeGen] Fix failing assert in interleaved access pass (#156457)
In the InterleavedAccessPass the function getMask assumes that
shufflevector operations are always fixed width, which isn't true
because we use them for splats of scalable vectors. This patch fixes the
code by bailing out for scalable vectors.
2025-09-03 10:55:39 +01:00
Frederik Harwath
d0d79fd1ac
[AMDGPU] si-peephole-sdwa: reuse getOne{NonDBGUse,Def} (NFC) (#156455)
This patch changes the findSingleRegDef function from si-peephole-sdwa
to reuse MachineRegisterInfo::getOneDef and findSingleRefUse to use a
new MachineRegisterInfo::getOneNonDBGUse function.
2025-09-03 10:35:32 +02:00
Daniel Paoliello
f99b0f3de4
[NFC] RuntimeLibcalls: Prefix the impls with 'Impl_' (#153850)
As noted in #153256, TableGen is generating reserved names for
RuntimeLibcalls, which resulted in a build failure for Arm64EC since
`vcruntime.h` defines `__security_check_cookie` as a macro.

To avoid using reserved names, all impl names will now be prefixed with
`Impl_`.

`NumLibcallImpls` was lifted out as a `constexpr size_t` instead of
being an enum field.

While I was churning the dependent code, I also removed the TODO to move
the impl enum into its own namespace and use an `enum class`: I
experimented with using an `enum class` and adding a namespace, but we
decided it was too verbose so it was dropped.
2025-09-02 09:57:33 -07:00
Sam Tebbs
569d738d4e
[Intrinsics][AArch64] Add intrinsics for masking off aliasing vector lanes (#117007)
It can be unsafe to load a vector from an address and write a vector to
an address if those two addresses have overlapping lanes within a
vectorised loop iteration.

This PR adds intrinsics designed to create a mask with lanes disabled if
they overlap between the two pointer arguments, so that only safe lanes
are loaded, operated on and stored. The `loop.dependence.war.mask`
intrinsic represents cases where the store occurs after the load, and
the opposite for `loop.dependence.raw.mask`. The distinction between
write-after-read and read-after-write is important, since the ordering
of the read and write operations affects if the chain of those
instructions can be done safely.

Along with the two pointer parameters, the intrinsics also take an
immediate that represents the size in bytes of the vector element types.

This will be used by #100579.
2025-09-02 15:35:15 +01:00
zhijian lin
36cb33bbca
support branch hint for AtomicExpandImpl::expandAtomicCmpXchg (#152366)
The patch add branch hint for AtomicExpandImpl::expandAtomicCmpXchg, For
example: in PowerPC, it support branch hint as

```
loop:
    lwarx r6,0,r3   #  load and reserve
    cmpw r4,r6      #1st 2 operands equal? bne- exit  #skip if not
    bne- exit       #skip if not
    stwcx. r5,0,r3  #store new value if still res’ved bne- loop #loop if lost reservation
    bne- loop #loop if lost reservation
exit:
    mr  r4,r6       #return value from storage
```

`-`  hints not taken,
`+` hints taken,
2025-09-02 09:33:28 -04:00
Michael Buch
c6286b30bd
[llvm][DebugInfo] Support DW_AT_linkage_names that are different between declaration and definition (#154137)
This patch is motivated by
https://github.com/llvm/llvm-project/pull/149827, where we plan on using
mangled names on structor declarations to find the exact structor
definition that LLDB's expression evaluator should call.

So far LLVM expects the declaration and definition linkage names to be
identical (or the declaration to just not have a linkage name). But we
plan on attaching the GCC-style "unified" mangled name to declarations,
which will be different to linkage name on the definition. This patch
relaxes this restriction.
2025-09-01 15:24:06 +01:00
Haohai Wen
2e12299039
[PseudoProbe] Support emitting to COFF object (#123870)
RFC:
https://discourse.llvm.org/t/rfc-support-pseudo-probe-for-windows-coff/83820
Support emitting pseudo probe to .pseudo_probe and .pseudo_probe_desc
COFF sections.
2025-09-01 08:31:40 +08:00
Craig Topper
c65d6cb0a1
[SelectionDAG] Return std::optional<unsigned> from getValidShiftAmount and friends. NFC (#156224)
Instead of std::optional<uint64_t>. Shift amounts must be less than or
equal to our maximum supported bit widths which fit in unsigned. Most of
the callers already assumed it fit in unsigned.
2025-08-31 11:29:07 -07:00
Philip Reames
b062aad57a
[CodeGen] Drop disjoint flag when reassociating (#156218)
This fixes a latent miscompile. To understand why the flag can't be
preserved, consider the case where a0=0, a1=0, a2=-1, and s3=-1.
2025-08-31 11:23:15 -07:00
AZero13
2b4fff6521
[TargetLowering] Only freeze LHS and RHS if they are used multiple times in expandABD (#156193)
Not all paths in expandABD are using LHS and RHS twice.
2025-08-31 10:30:29 +00:00
Craig Topper
4a6435397b
[SelectionDAG] Add computeKnownBits for ISD::ROTL/ROTR. (#156142) 2025-08-30 21:25:56 -07:00
Kazu Hirata
fc925ed067
[CodeGen] Remove a dead assignment (NFC) (#156202)
TRI is set to the same value a couple of lines below.
2025-08-30 16:01:54 -07:00
Michael Buch
101216dfdd
Revert "Emit DW_OP_lit0/1 for constant boolean values" (#156172)
Reverts llvm/llvm-project#155539

Failing on buildbots with:
```
Step 7 (test-build-stage1-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: DebugInfo/debug-bool-const-location.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll -O3 -filetype=obj -o - | /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llvm-dwarfdump - | /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll # RUN: at line 2
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll -O3 -filetype=obj -o -
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llvm-dwarfdump -
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll:7:10: error: CHECK: expected string not found in input
; CHECK: {{.*}} DW_OP_lit0
         ^
<stdin>:27:54: note: scanning from here
 [0x0000000000000018, 0x0000000000000020): DW_OP_lit1, DW_OP_stack_value
                                                     ^
<stdin>:28:41: note: possible intended match here
 [0x0000000000000020, 0x0000000000000034): DW_OP_reg3 X3)
                                        ^

Input file: <stdin>
Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           .
           .
           .
          22:  DW_AT_decl_line (5) 
          23:  DW_AT_external (true) 
          24:  
          25: 0x0000003f: DW_TAG_variable 
          26:  DW_AT_location (0x00000000:  
          27:  [0x0000000000000018, 0x0000000000000020): DW_OP_lit1, DW_OP_stack_value 
check:7'0                                                          X~~~~~~~~~~~~~~~~~~~ error: no match found
          28:  [0x0000000000000020, 0x0000000000000034): DW_OP_reg3 X3) 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:7'1                                             ?                  possible intended match
          29:  DW_AT_name ("arg") 
check:7'0     ~~~~~~~~~~~~~~~~~~~~
          30:  DW_AT_decl_file ("test") 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
          31:  DW_AT_decl_line (5) 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~
          32:  DW_AT_type (0x0000004f "bool") 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          33:  
check:7'0     ~
           .
```
2025-08-30 11:44:21 +00:00
Laxman Sole
3aae4bd13d
Emit DW_OP_lit0/1 for constant boolean values (#155539)
Backends like NVPTX use -1 to indicate `true` and 0 to indicate `false`
for boolean values. Machine instruction `#DBG_VALUE` also uses -1 to
indicate a `true` boolean constant.

However, during the DWARF generation, booleans are treated as unsigned
variables, and the debug_loc expression, like `DW_OP_lit0; DW_OP_not` is
emitted for the `true` value.

This leads to the debugger printing `255` instead of `true` for constant
boolean variables.

This change emits `DW_OP_lit1` instead of `DW_OP_lot0; DW_OP_not`.
2025-08-30 09:07:14 +00:00
Vladislav Dzhidzhoev
8c1e62b628
[DwarfDebug] Avoid generating extra DW_TAG_subprogram entries (#154636)
The test llvm/test/DebugInfo/X86/pr12831.ll was added in 4d358b55fa to
fix the issue with emission of empty DW_TAG_subprogram tags
(https://bugs.llvm.org/show_bug.cgi?id=12831).

However, the test output is not checked properly, and it contains:
```
0x00000206:   DW_TAG_subprogram

0x00000207:   DW_TAG_reference_type
                DW_AT_type      (0x00000169 "class ")
```

The reason is that the DIE for the definition DISubprogram "writeExpr"
is created during the call to `getOrCreateSubprogramDIE(declaration of
writeExpr)`. Therefore, when `getOrCreateSubprogramDIE(definition of
writeExpr)` is first called, we get a recursive chain of calls:
```
getOrCreateSubprogramDIE(definition of writeExpr)
getOrCreateSubprogramDIE(declaration of writeExpr)
...
getOrCreateSubprogramDIE(definition of writeExpr)
```

The outer call doesn't expect that the DIE for the definition of
writeExpr will be created during the creation of declaration DIE. So,
another DIE is created for the same subprogram. In this PR, a check is
added to fix that.
2025-08-29 15:32:00 +02:00
Kyle Krüger
5d0294fcb6
[llvm] Support building with c++23 (#154372)
closes #154331 

This PR addresses all minimum changes needed to compile LLVM and MLIR
with the c++23 standard.
It is a work in progress and to be reviewed for better methods of
handling the parts of the build broken by c++23.
2025-08-29 12:52:07 +00:00
paperchalice
205d461a19
[IR][CodeGen] Remove "approx-func-fp-math" attribute (#155740)
Remove "approx-func-fp-math" attribute and related command line option,
users should always use afn flag in IR.
Resolve FIXME in `TargetMachine::resetTargetOptions` partially.
2025-08-29 09:52:07 +08:00
Craig Topper
cec0d5b217
[ValueTracking][SelectionDAG] Use KnownBits::reverseBits/byteSwap. NFC (#155847) 2025-08-28 13:26:32 -07:00
Craig Topper
9472225fa6
[KnownBits] Add operator<<=(unsigned) and operator>>=(unsigned). NFC (#155751)
Add operators to shift left or right and insert unknown bits.
2025-08-28 10:08:28 -07:00
Djordje Todorovic
9a99896387
[TargetLoweringObjectFile] Handle riscv BE (#155166)
Add DWARF exception handling support for riscv big-endian targets.
More CodeGen changes related to riscvbe are coming.
2025-08-28 17:04:47 +02:00
Pierre van Houtryve
8b9b0fdedf
[CodeGen][TLI] Allow targets to custom expand atomic load/stores (#154708)
Loads didn't have the `Expand` option in `AtomicExpandPass`. Stores had
`Expand` but it didn't defer to TLI and instead did an action directly.
Add a `CustomExpand` option and make it always map to the TLI hook for
all cases. The `Expand` option now refers to a generic expansion for all
targets.
2025-08-28 09:58:10 +02:00
daniel-trujillo-bsc
658a931c5b
[CodeGen][RISCV] Add support of RISCV nontemporal to vector predication instructions. (#153033)
This PR adds support for VP intrinsics to be aware of the nontemporal
metadata information.
2025-08-27 15:48:33 -07:00
Vladislav Dzhidzhoev
1b7915018b
[DebugInfo] Drop extra DIBuilder::finalizeSubprogram() calls (NFC) (#155618)
After #139914, `DIBilder::finalize()` finalizes both declaration and
definition DISubprograms.
Therefore, there is no need to call `DIBuilder::finalizeSubprogram()`
right before `DIBilder::finalize()`.
2025-08-27 17:58:29 +02:00
David Green
4ee80ca29e
[GlobalISel] Add support for scalarizing vector insert and extract elements (#153274)
This Adds scalarization handling for fewer vector elements of insert and
extract, so that i128 and fp128 types can be handled if they make it
past combines. Inserts are unmerged with the inserted element added to
the remerged vector, extracts are unmerged then the correct element is
copied into the destination. With a non-constant vector the usual stack
lowering is used.
2025-08-27 10:21:58 +01:00
Björn Pettersson
58f3b0dd8d
[CodeGen] Optimize/simplify finalizeBundle. NFC (#155448)
When tracking defs in finalizeBundle two sets are used. LocalDefs is
used to track defined virtual and physical registers, while LocalDefsP
is used to track defined register units for the physical registers.

This patch moves the updates of LocalDefsP to only iterate over regunits
when a new physical register is added to LocalDefs. When the physical
register already is present in LocalDefs, then the corresponding
register units are present in LocalDefsP. So it was a waste of time to
add them to the set again.
2025-08-27 08:54:02 +02:00
Yingwei Zheng
5d111a20c5
[DAGCombiner] Avoid double deletion when replacing multiple frozen/unfrozen uses (#155427)
Closes https://github.com/llvm/llvm-project/issues/155345.
In the original case, we have one frozen use and two unfrozen uses:
```
t73: i8 = select t81, Constant:i8<0>, t18
t75: i8 = select t10, t18, t73
t59: i8 = freeze t18 (combining)

t80: i8 = freeze t59 (another user of t59)
```

In `DAGCombiner::visitFREEZE`, we replace all uses of `t18` with `t59`.
After updating the uses, `t59: i8 = freeze t18` will be updated to `t59:
i8 = freeze t59` (`AddModifiedNodeToCSEMaps`) and CSEed into `t80: i8 =
freeze t59` (`ReplaceAllUsesWith`). As the previous call to
`AddModifiedNodeToCSEMaps` already removed `t59` from the CSE map,
`ReplaceAllUsesWith` cannot remove `t59` again.

For clarity, see the following call graph:
```
ReplaceAllUsesOfValueWith(t18, t59)
  ReplaceAllUsesWith(t18, t59)
    RemoveNodeFromCSEMaps(t73)
    update t73
    AddModifiedNodeToCSEMaps(t73)
    RemoveNodeFromCSEMaps(t75)
    update t75
    AddModifiedNodeToCSEMaps(t75)
    RemoveNodeFromCSEMaps(t59) <- first delection
    update t59
    AddModifiedNodeToCSEMaps(t59)
        ReplaceAllUsesWith(t59, t80)
            RemoveNodeFromCSEMaps(t59) <- second delection
                Boom!
```

This patch unfreezes all the uses first to avoid triggering CSE when
introducing cycles.
2025-08-27 11:21:22 +08:00
Miguel Saldivar
0a8acd2eb2
[DAG] ComputeNumSignBits - ISD::EXTRACT_ELEMENT needs to return at least 1 (#155455)
When going through the ISD::EXTRACT_ELEMENT case, `KnownSign - rIndex *
BitWidth`
could produce a negative. When a negative is produced, the lower bound
of the `std::clamp` is returned. Change that lower bound to one to avoid
potential underflows, because the expectation is that
`ComputeNumSignBits`
should always return at least 1.

Fixes #155452.
2025-08-26 14:28:02 -07:00
Min-Yih Hsu
acaa925cb2
[IA][RISCV] Recognize interleaving stores that could lower to strided segmented stores (#154647)
This is a sibling patch to #151612: passing gap masks to the renewal TLI
hooks for lowering interleaved stores that use shufflevector to do the
interleaving.
2025-08-26 13:22:42 -07:00
Benjamin Maxwell
a1937d2eb7
[ComplexDeinterleaving] Use LLVM ADTs (NFC) (#154754)
This swaps out STL types for their LLVM equivalents. This is recommended
in the LLVM coding standards: https://llvm.org/docs/CodingStandards.html#c-standard-library
2025-08-26 10:10:40 +01:00
Craig Topper
56289647be
[DAGCombiner] Preserve nuw when converting mul to shl. Use nuw in srl+shl combine. (#155043)
If the srl+shl have the same shift amount and the shl has the nuw flag,
we can remove both.

In the affected test, the InterleavedAccess pass will emit a udiv after
the `mul nuw`. We expect them to combine away. The remaining shifts on
the RV64 tests are because we didn't add the zeroext attribute to the
incoming evl operand.
2025-08-25 20:44:06 -07:00
Victor Mustya
6a5cb5afdc
[GISel] Fix crash in GlobalISel utils method (#153334)
The `getDefSrcRegIgnoringCopies` method in GlobalISel Utils crashed when
the first operand of the input instruction was not a register, e.g.,
the `INLINEASM` instruction has a non-register first operand.

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-08-25 12:59:01 -07:00
Rahman Lavaee
a61ff1487b
[SHT_LLVM_BB_ADDR_MAP] Change the callsite feature to emit end of callsites. (#155041)
This PR simply moves the callsite anchors from the beginning of
callsites to their end.

Emitting the end of callsites is more sensible as it allows breaking the
basic block into subblocks which end with control transfer instructions.
2025-08-25 10:17:29 -07:00
Alex MacLean
8ab917a241
Reland "[NVPTX] Legalize aext-load to zext-load to expose more DAG combines" (#155063)
The original version of this change inadvertently dropped
b6e19b35cd87f3167a0f04a61a12016b935ab1ea. This version retains that fix
as well as adding tests for it and an explanation for why it is needed.
2025-08-25 09:15:44 -07:00
Matt Arsenault
6b200e21ad
DAG: Avoid comparing Register to unsigned 0 (#155164) 2025-08-25 15:02:08 +09:00
Benjamin Maxwell
ee8c14be14
[LivePhysRegs] Use .asMCReg() rather than cast (NFC) (#155084)
Should fix MSVC buildbots:

https://lab.llvm.org/buildbot/#/builders/197/builds/8321
https://lab.llvm.org/buildbot/#/builders/211/builds/1549
2025-08-23 11:25:16 +01:00
Benjamin Maxwell
c44c325fa2
[LivePhysRegs] Make use of MBB.liveouts() (semi-NFC) (#154728)
This is done for consistency with LiveRegUnits (see #154325). This is
technically not an NFC, as `MBB.liveouts()` excludes runtime-defined
liveins, but no users currently depend on this.
2025-08-23 07:22:46 +01:00
Matt Arsenault
65d12622fa
RuntimeLibcalls: Add entries for stackprotector globals (#154930)
Add entries for_stack_chk_guard, __ssp_canary_word, __security_cookie,
and __guard_local. As far as I can tell these are all just different
names for the same shaped functionality on different systems.

These aren't really functions, but special global variable names. They
should probably be treated the same way; all the same contexts that
need to know about emittable function names also need to know about
this. This avoids a special case check in IRSymtab.

This isn't a complete change, there's a lot more cleanup which
should be done. The stack protector configuration system is a
complete mess. There are multiple overlapping controls, used in
3 different places. Some of the target control implementations overlap
with conditions used in the emission points, and some use correlated
but not identical conditions in different contexts.

i.e. useLoadStackGuardNode, getIRStackGuard, getSSPStackGuardCheck and
insertSSPDeclarations are all used in inconsistent ways so I don't know
if I've tracked the intention of the system correctly.

The PowerPC test change is a bug fix on linux. Previously the manual
conditions were based around !isOSOpenBSD, which is not the condition
where __stack_chk_guard are used. Now getSDagStackGuard returns the
proper global reference, resulting in LOAD_STACK_GUARD getting a
MachineMemOperand which allows scheduling.
2025-08-23 10:21:00 +09:00
XChy
fd330dedcb
[DAG] Constant fold ISD::FSHL/FSHR nodes (#154480)
Fixes #153612.
This patch handles trinary scalar integers for FSHL/R in
`FoldConstantArithmetic`.
Pending until #153790 is merged.
2025-08-23 10:08:21 +09:00
Joseph Huber
d439c9ea4a Revert "[NVPTX] Legalize aext-load to zext-load to expose more DAG combines (#154251)"
Causes failures in the LLVM libc test suite
https://lab.llvm.org/buildbot/#/builders/69/builds/26327/steps/12/logs/stdio.

This reverts commit a3ed96b899baddd4865f1ef09f01a83da011db5c.
2025-08-22 16:13:58 -05:00
Peter Collingbourne
97716d2e31 Revert "CodeGen: Respect function align attribute if less than preferred alignment."
This reverts commit 9878ef3abd2a48fcfb81357d581dac292b52ddb3.

Needs more discussion of the semantics of the align attribute. See:
https://discourse.llvm.org/t/rfc-enhancing-function-alignment-attributes/88019
2025-08-22 13:17:53 -07:00
Kazu Hirata
11b4f110e0
[llvm] Remove unused includes of SmallSet.h (NFC) (#154893)
We just replaced SmallSet<T *, N> with SmallPtrSet<T *, N>, bypassing
the redirection found in SmallSet.h.  With that, we no longer need to
include SmallSet.h in many files.
2025-08-22 10:33:46 -07:00
paperchalice
2014890c09
[SelectionDAG] Remove UnsafeFPMath in visitFP_ROUND (#154768)
Remove `UnsafeFPMath` in `visitFP_ROUND` part, it blocks some bugfixes
related to clang and the ultimate goal is to remove `resetTargetOptions`
method in `TargetMachine`, see FIXME in `resetTargetOptions`.
See also
https://discourse.llvm.org/t/rfc-honor-pragmas-with-ffp-contract-fast

https://discourse.llvm.org/t/allowfpopfusion-vs-sdnodeflags-hasallowcontract

Now all UnsafeFPMath uses are eliminated in LLVMCodeGen
2025-08-22 19:46:33 +08:00
paperchalice
945a186089
[DAGCombiner] Remove most UnsafeFPMath references (#146295)
This pull request removes all references to `UnsafeFPMath` in dag
combiner except FP_ROUND.
- Set fast math flags in some tests.
2025-08-22 15:27:25 +08:00