8213 Commits

Author SHA1 Message Date
Matt Arsenault
2502e3b7ba
IR: Promote "denormal-fp-math" to a first class attribute (#174293)
Convert "denormal-fp-math" and "denormal-fp-math-f32" into a first
class denormal_fpenv attribute. Previously the query for the effective
denormal mode involved two string attribute queries with parsing. I'm
introducing more uses of this, so it makes sense to convert this
to a more efficient encoding. The old representation was also awkward
since it was split across two separate attributes. The new encoding
just stores the default and float modes as bitfields, largely avoiding
the need to consider if the other mode is set.

The syntax in the common cases looks like this:
  `denormal_fpenv(preservesign,preservesign)`
  `denormal_fpenv(float: preservesign,preservesign)`
  `denormal_fpenv(dynamic,dynamic float: preservesign,preservesign)`

I wasn't sure about reusing the float type name instead of adding a
new keyword. It's parsed as a type but only accepts float. I'm also
debating switching the name to subnormal to match the current
preferred IEEE terminology (also used by nofpclass and other
contexts).

This has a behavior change when using the command flag debug
options to set the denormal mode. The behavior of the flag
ignored functions with an explicit attribute set, per
the default and f32 version. Now that these are one attribute,
the flag logic can't distinguish which of the two components
were explicitly set on the function. Only one test appeared to
rely on this behavior, so I just avoided using the flags in it.

This also does not perform all the code cleanups this enables.
In particular the attributor handling could be cleaned up.

I also guessed at how to support this in MLIR. I followed
MemoryEffects as a reference; it appears bitfields are expanded
into arguments to attributes, so the representation there is
a bit uglier with the 2 2-element fields flattened into 4 arguments.
2026-02-05 13:31:26 +00:00
Jameson Nash
e8b7181762
[Evaluator] require invariant size to fully span the global (#179518)
Relying on the semantics of the type here is a bit potentially awkward,
since the full allocated space may be accessible to the user if desired,
since that space is defined to be a part of the type's sizeof
computation (e.g. for a `memcpy(gv, gv, sizeof(*gv))` or when making an
array of them). It also gets in the way of removing getAllocatedType
from AllocaInst entirely (they are converted to GlobalVariable
sometimes). It was originally added in
519561f418c77dcf46fd6d96d25d884fa07fd7da, though "correct size" is a
difficult thing to define.

The frontend (in clang) appears to always emit the full type size here,
so there seems like this shouldn't be visible change to clang users.

This is still a bit awkward though, since a global is defined to be any
size that is bigger than this unless it has a known initizalizer,
rendering the test still incomplete here against the IR semantics.
2026-02-04 13:08:06 -05:00
Fabian Ritter
2af18a17bb
[NFC][LowerMemIntrinsics] Consistent parameter name comments in function calls (#176751)
The `/*ParamName=*/foo` syntax is prescribed by the coding standards:
https://llvm.org/docs/CodingStandards.html#comment-formatting
2026-02-04 15:42:31 +01:00
Fabian Ritter
d24a6754ce
[LowerMemIntrinsics] Optimize memset lowering (#169040)
This patch changes the memset lowering to match the optimized memcpy lowering.
The memset lowering now queries TTI.getMemcpyLoopLoweringType for a preferred
memory access type. If that type is larger than a byte, the memset is lowered
into two loops: a main loop that stores a sufficiently wide vector splat of the
SetValue with the preferred memory access type and a residual loop that covers
the remaining bytes individually. If the memset size is statically known, the
residual loop is replaced by a sequence of stores.

This improves memset performance on gfx1030 (AMDGPU) in microbenchmarks by
around 7-20x.

I'm planning similar treatment for memset.pattern as a follow-up PR.

For SWDEV-543208.
2026-02-04 13:35:13 +01:00
Vladislav Dzhidzhoev
b9cecee3fb
Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)" (#165032)
This is an attempt to merge https://reviews.llvm.org/D144006 with LTO
fix.

The last merge attempt was
https://github.com/llvm/llvm-project/pull/75385.
The issue with it was investigated in
https://github.com/llvm/llvm-project/pull/75385#issuecomment-2386684121.
The problem happens when 
1. Several modules are being linked.
2. There are several DISubprograms that initially belong to different
modules but represent the same source code function (for example, a
function included from the same source code file).
3. Some of such DISubprograms survive IR linking. It may happen if one
of them is inlined somewhere or if the functions that have these
DISubprograms attached have internal linkage.
4. Each of these DISubprograms has a local type that corresponds to the
same source code type. These types are initially from different modules,
but have the same ODR identifier.

If the same (in the sense of ODR identifier/ODR uniquing rules) local
type is present in two modules, and these modules are linked together,
the type gets uniqued. A DIType, that happens to be loaded first,
survives linking, and the references on other types with the same ODR
identifier from the modules loaded later are replaced with the
references on the DIType loaded first. Since defintion subprograms, in
scope of which these types are located, are not deduplicated, the linker
output may contain multiple DISubprogram's having the same (uniqued)
type in their retainedNodes lists.
Further compilation of such modules causes crashes.

To tackle that,
* previous solution to handle LTO linking with local types in
retainedNodes is removed (cloneLocalTypes() function),
* for each loaded distinct (definition) DISubprogram, its retainedNodes
list is scanned after loading, and DITypes with a scope of another
subprogram are removed. If something from a Function corresponding to
the DISubprogram references uniqued type, we rely on cross-CU links.

Additionally:
* a check is added to Verifier to report about local types located in a
wrong retainedNodes list,

Original commit message follows.
---------

RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544

Similar to imported declarations, the patch tracks function-local types in
DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with
the aforementioned metadata change and provided a support of function-local
types scoped within a lexical block.

The patch assumes that DICompileUnit's 'enums field' no longer tracks local
types and DwarfDebug would assert if any locally-scoped types get placed there.

Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com>
Co-authored-by: Jeremy Morse <jeremy.morse@sony.com>
2026-02-04 00:34:52 +01:00
Abhay Kanhere
e39d2822bc
[CodeGen][AArch64] ptrauth intrinsic to safely construct relative ptr (#142047)
ptrauth intrinsic to safely construct relative ptr for swift coroutines.

A ptrauth intrinsic for swift co-routine support that allows creation of
signed pointer
 from offset stored at address relative to the pointer.

Following C-like pseudo code (ignoring keys,discriminators) explains its
operation:
      let rawptr = PACauth(inputptr);
return PACsign( rawptr + signextend64( *(int32*)(rawptr+addend) ))

What: Authenticate a signed pointer, load a 32bit value at offset
'addend' from pointer,
       add this value to pointer, sign this new pointer.
 builtin: __builtin_ptrauth_auth_load_relative_and_sign
 intrinsic: ptrauth_auth_resign_load_relative
2026-02-03 18:03:37 +01:00
Mingjie Xu
28a0cfa946
Reland "[BasicBlockUtils] Fix dominator tree update for entry block in splitBlockBefore() (#178895) (#179392)
https://github.com/llvm/llvm-project/pull/178895 caused a clang
crash(see https://lab.llvm.org/buildbot/#/builders/210/builds/8229),
reverted in 6d52d2683c2ceb9ab75810730c3ced2509c32bc5.

The crash is assertion `DT && "DT should be available to update
LoopInfo!"' failed.

ad8d5349d4/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp (L1106)

```
 #7 0x00007f5a380254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
 #8 0x0000563df5d8fde1 UpdateAnalysisInformation(llvm::BasicBlock*, llvm::BasicBlock*, llvm::ArrayRef<llvm::BasicBlock*>, llvm::DomTreeUpdater*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, bool, bool&) BasicBlockUtils.cpp:0:0
 #9 0x0000563df5d8f3bb llvm::splitBlockBefore(llvm::BasicBlock*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, false>, llvm::DomTreeUpdater*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, llvm::Twine const&)
#10 0x0000563df5d8cb08 llvm::SplitEdge(llvm::BasicBlock*, llvm::BasicBlock*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::MemorySSAUpdater*, llvm::Twine const&)
#11 0x0000563df4ff5b59 (anonymous namespace)::CodeGenPrepare::splitLargeGEPOffsets()::$_1::operator()(long, llvm::Value*, llvm::GetElementPtrInst*) const CodeGenPrepare.cpp:0:0
#12 0x0000563df4fc0ec8 (anonymous namespace)::CodeGenPrepare::_run(llvm::Function&) CodeGenPrepare.cpp:0:0
#13 0x0000563df4fbb36c (anonymous namespace)::CodeGenPrepareLegacyPass::runOnFunction(llvm::Function&) CodeGenPrepare.cpp:0:0
```

I think this happened when we get DominatorTree with `DT.get()` in
`splitLargeGEPOffsets()` but `DT.reset()` already setting it to nullptr
in
ad8d5349d4/llvm/lib/CodeGen/CodeGenPrepare.cpp (L660).
To fix this assertion failure, use `getDT()` for
`splitLargeGEPOffsets()` to build the DominatorTree if it is set to
nullptr by `DT.reset()`.

I don't have a RSIC-V environment, so no reproducer. Checked that the
crash is fixed by rerunning buildbot with this patch
https://lab.llvm.org/buildbot/#/builders/210/builds/8248
2026-02-03 22:38:41 +08:00
Mingjie Xu
6d52d2683c
Revert "[BasicBlockUtils] Fix dominator tree update for entry block in splitBlockBefore() (#178895)" (#179373)
This reverts commit ad8d5349d46734826aaeae4a2ebdc6f427a5bad8.

LLVM Buildbot detected a failure,
https://lab.llvm.org/buildbot/#/builders/210/builds/8229
2026-02-03 10:35:47 +08:00
Mingjie Xu
ad8d5349d4
[BasicBlockUtils] Fix dominator tree update for entry block in splitBlockBefore() (#178895)
06dfbb50d70eea4ae38d655842626a0b9b224d5c fixed dominator update for
entry block in `SplitBlockPredecessors()`, this patch fixes dominator
tree update for entry block in `splitBlockBefore()` with
`UpdateAnalysisInformation()`.
2026-02-03 09:23:17 +08:00
Nikita Popov
fd1e37b653
[IR] Remove Before argument from splitBlock APIs (NFC) (#179195)
We never need to use this conditionally (and it doesn't really make
sense, as the behavior is substantially different). Force the use of
separate APIs instead of a boolean argument.
2026-02-02 10:50:58 +00:00
Nikita Popov
cd91d3180a
[EntryExitInstrumenter] Mark CFG as preserved (#178875)
This pass does not change the CFG, so mark all CFG analyses as
preserved, instead of DT in particular. This matches what the NewPM
implementation does.

(This currently has no direct benefit as nearby passes end up
invalidating things anyway.)
2026-01-30 12:35:59 +00:00
dianqk
956770a9cb
[SimplifyCFG] Fix null pointer dereference in foldCondBranchOnValueKnownInPredecessorImpl (#178835) 2026-01-30 18:04:50 +08:00
Usama Hameed
28e980fbdd
[MTE][Darwin] This patch extends support for the stack frame history buffer to Darwin. (#178049)
Darwin reserves slot 231 for storing a pointer to the history ring
buffer. It also uses bits 60-62 to store the size of the ring buffer

rdar://168176496
2026-01-28 12:23:32 -08:00
Walter Lee
07ee61d59e
[LoopUnroll] Fix unused variable warning (#178490)
Fixes 362c39d36dd87c5659b0caa3115dfa67f592cdf6.
2026-01-28 19:38:46 +00:00
Marek Sedláček
362c39d36d
[LoopUnroll] Use branch probability in multi-exit loop unrolling (#164799)
This patch improves multi-exit loop unrolling by taking into account
branch probability and not only other exit being deopting one.

This implementation uses branch metadata directly because of unstable
state of BPI in this part of code (runtime unrolling invalidates the
state of the map and using BPI in my tests has caused errors).
If branch probability metadata are not present then the current deopt
heuristic is still used.

---------

Co-authored-by: Marek Sedlacek <msedlacek@azul.com>
2026-01-28 11:12:34 -05:00
int-zjt
a21001ab41
[JumpThreading] Avoid unnecessary map resizing in gatherIncomingValuesToPhi (#173596)
Previously, `gatherIncomingValuesToPhi` populated the `IncomingValues`
map with *all* non-undef incoming values from the PHI node. For PHI
nodes with a large number of incoming blocks, this caused the
`SmallDenseMap` to grow significantly, triggering expensive resizing and
rehashing operations, even when the caller
(`redirectValuesFromPredecessorsToPhi`) was only interested in a small
subset of predecessors.

This patch optimizes the logic to prevent this unnecessary map growth.

Instead of collecting all values, we now:
1. Initialize the `IncomingValues` map specifically for the blocks in
`BBPreds` (setting them to `nullptr` initially).
2. Iterate through the PHI node and update the map entries only if the
incoming block is already present in the map.

This ensures that the size of the map is bounded by the size of
`BBPreds`. Since `BBPreds` is typically small, this change keeps the map
within the `SmallDenseMap`'s inline storage in most cases, eliminating
heap allocations and resizing overhead for large PHI nodes.

The `selectIncomingValueForBlock` and `replaceUndefValuesInPhi` helpers
are also updated to handle map entries where the value is `nullptr`.
2026-01-28 09:17:21 +01:00
Jameson Nash
9d5d2eec21
[Mem2Reg] Remove extraneous getAllocatedType() check (#177438)
Replace uses of getAllocatedType() in PromoteMemoryToRegister.cpp with
type tracking from actual loads and stores. This makes the promotion
logic more semantic - it now checks that all loads/stores use a
consistent type rather than requiring them to match the alloca's
declared type.

Changes:
- isAllocaPromotable() now tracks the first load/store type seen and
ensures all subsequent accesses use the same type
- AllocaInfo gains a ValueType field populated during AnalyzeAlloca()
- PromoteMem2Reg tracks AllocaValueTypes alongside other per-alloca info
- PHI nodes and UndefValues are created using the tracked type

This is semantically more permissive - an alloca declared as i64 but
only accessed as i32 is now promotable. This is correct because the
alloca is just a blob of memory; what matters for Mem2Reg is consistent
access patterns.

Test changes:
- asan-stack-safety.ll: Changed loads/stores to volatile to prevent
promotion while preserving ASAN stack safety analysis behavior
- SPIRV pointer tests (array-skips-gep.ll, load-struct.ll,
store-struct.ll, store-to-array-first-element.ll): Added escape calls to
prevent alloca promotion, as these tests verify SPIRV backend handling
of Function-storage-class pointers

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:10:48 -05:00
serge-sans-paille
84cccfc828
[perf] Replace copy-assign by move-assign in llvm/lib/Transforms/* (#178178) 2026-01-27 16:29:35 +00:00
Abhishek Kaushik
e3284b9681
[LowerMemIntrinsics][AMDGPU] Propagate Debug Value (#178131)
Propagate debug value to expanded loops for `memcpy`, `memmove` and
`memset` intrinsics.
2026-01-27 14:46:14 +05:30
Jameson Nash
5188d2e745
[NFCI][MemoryTaggingSupport] Replace getAllocatedType with getAllocationSize (#177436)
Replace the `isSized()` and `isScalableTy()` type predicate checks with
a more direct `getAllocationSize()` query. The `isSized` check seems
unnecessary since the verifier already rejects unsized alloca.

For context, I'm working on deleting (or at least minimizing uses of)
the getAllocatedType function, since many optimizations need to destroy
that info and just produce byte sized allocas. It is for the same
reason that opaque pointers were introduced–memory doesn't inherently
have a provenience type, only uses (load and stores) do.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:44:51 -05:00
Florian Mayer
d139a31c0d
[HWASan] [MTE] allow lifetimes with multiple starts (#175608) 2026-01-26 19:47:49 +00:00
Florian Mayer
fc6a5ed1a4
[HWASan] [MTE] use precise lifetimes even if they don't cover all exits
Previously, for performance reasons, we would only use precise lifetimes
if they cover all reachable exits. Now, if they do not, we use precise
lifetimes in addition to untagging at every exit that is not dominated
by them.

This is the behavior of ASan.

Reviewers: vitalybuka, pcc

Pull Request: https://github.com/llvm/llvm-project/pull/174875
2026-01-26 10:25:31 -08:00
Miguel Saldivar
2c7cf896be
[llvm][UnifyLoopExits] Avoid optimization if no exit block is found (#165343)
If there is not an exit block, we should not try unify the loops.
Instead we should just return.

Fixes #165252
2026-01-26 01:31:28 +01:00
Nimit Sachdeva
2297e0d316
[MoveAutoInit] Fix for miscompilation for #150120 (#173961)
Fixes the miscompilation discussed for the PR #164882 as part of
generalizing the optimization for the issue #150120.

Without this commit, MoveAutoInit moves the store instruction to a
different branch which does not dominate the user dominator node. This
results in UB at runtime. The example in the test case is specifically
for an irreducible loop, in which all the predecessor may not dominate
user dominator head.

To fix this problem, we've introduced a new check to verify if the
predecessor of the user dominator node does in fact dominate user
dominator node before deciding that it is the node where the instruction
will be moved to.
2026-01-25 16:21:52 +01:00
Justin Fargnoli
7c8a13ab79
[LoopPeel] change peelLoop's return type from bool to void (#177488) 2026-01-23 10:49:03 -08:00
Jin Huang
e67f934c12
[profcheck] Fix profle metatdata propagation for Large Integer operations (#175862)
This PR improves the propagation of profile metadata within the
ExpandIRInsts pass. When lowering large integer division operations, the
pass now ensures that branch weights are correctly attached to the
generated control flow, preventing the loss of profile data during IR
expansion.

This PR improves signed and unsigned division/remainder for non-native
bit widths (e.g., `sdiv/udiv i129`, `srem/urem i129`) and implemented
Heuristic-Based Branch Weights labeling using established heuristics for
edge cases e.g., `Division-by-zero guards` and `Magnitude comparisons
between dividends and divisors`.

It also adds detailed comments within the expansion logic to explain the
rationale behind specific branch weight choices and the underlying
mathematical invariants.

Please refer to the implementation details in the source code for the
specific branch weight values and the logic governing their application.

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2026-01-23 10:29:20 -08:00
Lily Gorsheneva
daa98ac40a
inline assert-only variable from 17a17fa (#177602) 2026-01-23 16:26:50 +00:00
Nikolas Klauser
17a17fa81c
[PredicateInfo] Extract information from assume operand bundles (#177349) 2026-01-23 15:20:39 +01:00
Matt Arsenault
6934ed51b3
IR: Add !nofpclass metadata (#177140)
This adds the analogous metadata to the nofpclass attribute
to assert values are not a certain set of floating-point classes.
This allows the same information to be expressed if a function
argument is passed indirectly. This matches the bitmask encoding
of nofpclass.

I also think this should be allowed for stores to symmetrically handle
sret, but leave that for later.

Alternatively we could add a more expressive !fprange metadata,
but that would be much more complex. It's useful to match the attribute,
and more annotations can always be added.

Fixes #133560
2026-01-22 20:49:34 +01:00
Jameson Nash
d10b2b566a
[NFCI] replace getValueType with new getGlobalSize query (#177186)
Returns uint64_t to simplify callers. The goal is eventually replace
getValueType with this query, which should return the known minimum
reference-able size, as provided (instead of a Type) during create.
Additionally the common isSized query would be replaced with an
isExactKnownSize query to test if that size is an exact definition.
2026-01-22 13:55:53 -05:00
Alan Zhao
a1062d98bb
[profcheck] Print the function name in the error (#177264)
This is helpful for tests with a lot of test cases and grepping for
instructions with missing profile data isn't feasible because it doesn't
account for things like vectors which are exempt.

Tracking issue: #147390
2026-01-22 10:09:52 -08:00
Rux124
c91d5c76db
InjectTLIMappings: remove incompatible attributes from vector declarations. (#173206)
Some attributes (e.g., the signext attribute) are not supported on
vector types; adding them would cause the verifier pass to fail.
2026-01-22 13:39:10 +08:00
Jameson Nash
2458387ac1
[NFC] replace getValueType with more specific getFunctionType (#177175)
When trivially valid already, use the more specific method, instead of
casting the result of the less specific method.
2026-01-21 10:30:09 -05:00
Shilei Tian
597c4f16cf
[ControlFlowHub] Fix duplicate DomTree updates when branch successors are identical (#176620)
When a conditional branch has both successors pointing to the same block
(e.g., `br i1 %cond, label %bb, label %bb`), `ControlFlowHub::finalize`
generates duplicate `Delete` updates for the same CFG edge. This can
cause assertion in `fix-irreducible` pass.

Fixes #176553.
2026-01-21 00:44:30 +00:00
Craig Topper
e8a0b40d6c
[SCCP] Correct range calculation for get.vector.length to use getUnsignedMax instead of getUpper. (#176493)
getUpper returns 1 more than the maxium value included in the range.
This may be 0. We should not use this in a umin. Instead we should
get the maximum value included in the range and use that for the umin.
Then convert that to Upper for the new range by adding 1.

The test was manually reduced from a downstream failure, but I couldn't
get it behave exactly the same way without more instructions. It should
be enough to show an incorrect range being calculated.

Fixes #176471
2026-01-17 21:32:33 -08:00
Alexis Engelke
284ef1b4ac
[Support][NFCI] Store DomTree children as linked list (#176409)
Reduce the size of a DomTreeNodeBase from 80 to 56 bytes by not storing
the children in a SmallVector. Instead, store children as forward-linked
list. This also avoids extra allocations for nodes with many children.
Additionally, DomTreeNodeBase is now trivially destructible.

A lot of code depends on the order of nodes in the dominator tree, so
make sure that the order is the same when inserting nodes. (Not having
to do this would save 8 bytes per node.)

NewGVN uses the order of nodes in the dominator tree in a way that is
not entirely clear to me (https://reviews.llvm.org/D28129). I kept the
semantics as, but now this is the only external user of
addChild/removeChild, which actually should be private.

https://llvm-compile-time-tracker.com/compare.php?from=263802c56b4db3fc9b6ed9fd313499cb03ca44da&to=43e0c0c5b663b3a4067252fc0addbaccefd0014d&stat=instructions:u
2026-01-17 21:09:49 +01:00
Florian Hahn
3fb914d851
[SCEV] Add initial support for ptrtoaddr. (#158032)
Add initial support for PtrToAddr to SCEV, including a new
SCEVPtrToAddrExpr and SCEV expansion support for it.

PR: https://github.com/llvm/llvm-project/pull/158032
2026-01-16 11:58:04 +00:00
Szymon Sobieszek
5dccab0272
[LoopFusion] Removing dead code leftover after PR #171889 (NFC) (#176020)
Removed unused functions in order to fix 'unused function' warnings, as
mentioned in PR 171889. This involved the two original functions
```ControlConditions::isEquivalent(const ControlConditions &Other)
const``` and ```ControlConditions::collectControlConditions(const
llvm::BasicBlock&, const llvm::BasicBlock&, const llvm::DominatorTree&,
const llvm::PostDominatorTree&, unsigned int)``` plus all the functions
that became unused as the result of deleting the two original ones.

Co-authored-by: Szymon Sobieszek <szymon.sobieszek1@huawei.com>
2026-01-15 12:53:35 -05:00
Joel E. Denny
565591d8a4
[LoopUnroll] Do not copy !llvm.loop from latch to non-latch (#165635)
When LoopUnroll copies the original loop's latch to the corresponding
non-latch branch in an unrolled iteration, any `!llvm.loop` is copied
along with it, but `!llvm.loop` is useless and misleading there. This
patch discards it.

e06831a3b29d did the same for LoopPeel.
2026-01-14 10:40:31 -05:00
Graham Hunter
2abd6d6d7a
[LV] Vectorize conditional scalar assignments (#158088)
Based on Michael Maitland's previous work:
https://github.com/llvm/llvm-project/pull/121222

This PR uses the existing recurrences code instead of introducing a
new pass just for CSA autovec. I've also made recipes that are more
generic.
2026-01-14 14:59:18 +00:00
Ramkumar Ramachandra
d69335bac9
[LLVM] Clean up code using [not_]equal_to (NFC) (#175824)
Use llvm::[not_]equal_to landed in d2a521750 ([ADT] Introduce
bind_{front,back}, [not_]equal_to, #175056) across LLVM for cleaner
code.
2026-01-13 21:19:39 +00:00
Austin Jiang
e6cdfb75ac
Fix typos and spelling errors across codebase (#156270)
Corrected various spelling mistakes such as 'occurred', 'receiver',
'initialized', 'length', and others in comments, variable names,
function names, and documentation throughout the project. These
changes improve code readability and maintain consistency in naming
and documentation.

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2026-01-13 11:52:46 -05:00
Mircea Trofin
34603dba69
Fix dependencies after PR #174490 (#175793)
Added the missing direct dependency (it was already an indirect dependency due to `Analysis`)
2026-01-13 08:33:34 -08:00
Mircea Trofin
62f629a661
[LowerMemIntrinsics] Propagate value profile to branch weights (#174490)
If the mem intrinsics have value profile information associated, we can synthesize branch weights when converting them (the intrinsics) to loops.  
  
Issue #147390
2026-01-13 08:16:47 -08:00
Mircea Trofin
f9c561b561
[profcheck] Fix encoding of 0 loopEstimatedTrip count (#174896)
We currently encode an estimated trip count of 0 as the latch having branch probabilities 0-0. That's an invalid pair of weights. The probability of a branch is computed as a fraction of its corresponding weight and the sum of the weights. In fact, `BranchProbabilityInfo::calcMetadataWeights` will convert this to a 1-1, meaning 50% - 50%, which isn't quite what we want. To indicate the loop is never taken, we just need to initialize the exit probability to non-zero (hence, 1)

Related: https://reviews.llvm.org/D67905

Issue #147390
2026-01-12 17:12:35 -08:00
Sean Fertile
b6212a4caf
XCOFF associated metadata (#159096)
Add a new metadata node `!implicit.ref` to represent an implicit
dependency between 2 symbols. The metadata is unique to AIX and gets
lowered to a relocation that adds an explicit link between the section
the global that the metadata is placed on is allocated in, to the
asscoiated symbol. This relocation will cause the associated symbol to
remain live if the section is not garbage collected. This is used mainly
for compiler features where there is some hidden runtime dependency
between the symbols that isn't otherwise obvious to the linker.
2026-01-09 13:49:21 -05:00
Aleksandr Popov
f76417d21e
[IRCE] Prove predicates with and without loop-guarded SCEVs (#174843)
IRCE may fail to prove predicates when loop bounds are rewritten by
LoopConstrainer::applyLoopGuards(). In such cases, simple predicates
(e.g. %start < %limit) become obscured by strengthened SCEV expressions,
even though they are trivially implied by the guard in the loop
preheader.

See: https://github.com/llvm/llvm-project/issues/167827

This change makes IRCE attempt to prove predicates both on the original
SCEVs and on the guarded SCEVs, preventing incorrect rejection of loops
with safe bounds.
2026-01-08 15:16:55 +01:00
Florian Hahn
188507e542
[VPlan] Inline createFindLastIVReduction into its only caller. (NFC)
createFindLastIVReduction is only used for generating code for
ComputeFindIVResult. Inline the code there, in preparation for
https://github.com/llvm/llvm-project/pull/172569.
2026-01-04 13:31:47 +00:00
Craig Topper
715716f153
[SimplifyCFG] Use nullptr instead of 0 in a comment. NFC (#174262) 2026-01-03 15:26:26 -08:00
Mingjie Xu
9b8addffa7
[CloneFunction] Fix non-deterministic PHI cleanup using PHINode::removeIncomingValueIf() (#173975)
Previously, we use `std::map<BasicBlock *, unsigned> PredCount` to track
excess incoming blocks and removed them one by one using
`removeIncomingValue`.

Since `PredCount` use `BasicBlock *` as key, the iteration order depends
on the memory addresses of the blocks. With
`PHINode::removeIncomingValue()` changed to use the swapping strategy,
the order in which operands are removed affects the final order of the
remaining operands in the PHI node. This will cause non-determinism in
compiles.

This patch uses `PHINode::removeIncomingValueIf()` to remove invalid
incoming blocks that no longer go to `NewBB` block, fixes the
non-determinism.
2026-01-03 20:52:42 +08:00