[ADT] Remove FoldingSet's void * insert position API (#219845)
FindNodeOrInsertPos/InsertNode/GetOrInsertNode/RemoveNode and the
encode/decode helpers behind them are gone; use
lookup/insert/getOrInsert/erase with FoldingSetInsertToken.
LLM-aided
[ORC] Drop redundant ExecutionSession& arg from lookupAndApply (#219797)
The ExecutionSession& can be retrieved from the first element of the
SearchOrder.
This changes behavior in a corner case: An empty SearchOrder always
fails on a non-empty PrepareFns list, even if all symbols added would
have been weakly referenced, because no ExecutionSession& is available
to intern the symbol names. An empty SearchOrder is pathological, so
this seems like a reasonable trade-off.
[RegAllocFast] Use getOneDef() in traceCopyChain(). NFC (#219850)
getUniqueVRegDef() finds one defining instruction, while getOneDef()
finds one def operand and is inlined.
(They differ for a register defined twice by one instruction but
RegAllocFast does not support that shape in defineVirtReg().)
[VPlan] Fold trivial bitcasts. (#219849)
Fold trivial bitcasts in VPlan. This avoids special handling when
constructing SCEV expressions (which folds such trivial casts), and
ensures we can close the gap between IR-based SCEV analysis and
VPlan-based SCEV analysis. This is important going forward to make sure
we can replace existing IR analysis without regressions.
[clang] Migrate remaining FoldingSet users to lookup/insert. NFC (#219844)
findSpecialization/AddSpecialization and their Decl.h wrappers stop
threading a `void *` through the AST, Sema, Serialization and CodeGen
callers. This is the last user of FoldingSet's `void *` insert position.
LLM-aided
[VPlan] Fix VPScalarIVStepsRecipe for FSub inductions. (#219214)
The lane offsets passed to the new VPScalarIVStepsRecipe always count
upwards (based on the canonical IV), independent of the induction
opcode.
Remove code incorrectly negating the lane offset for inductions with
FPSub opcode. The double negation caused incorrect results.
PR: https://github.com/llvm/llvm-project/pull/219214
[Clang][Driver] Revise Cygwin ToolChain to call linker directly (#147960)
...so that `libc++`, `compiler-rt`, and `libunwind` can be used by the
options: `-stdlib=libc++`, `-rtlib=compiler-rt`, and
`-unwindlib=libunwind` respectively. Along with this change, the test
for this driver is also trimmed a bit.
This is a followup patch for
https://github.com/llvm/llvm-project/commit/52924a2d7255cdd280b2b82dad8616e01fe065da.
---------
Signed-off-by: Takashi Yano <takashi.yano at nifty.ne.jp>
Co-authored-by: Jeremy Drake <github at jdrake.com>
Co-authored-by: Tomohiro Kashiwada <kikairoya at gmail.com>
[VPlan] Add tests for more address idioms not by VPlan's SCEV (NFC). (#219843)
Add tests gaps currently handled by IR based SCEV analysis, but not
VPlan-based SCEV analysis.
[ADT] Inline FoldingSet's equality dispatch (#219784)
FoldingSetBase compares nodes through a FoldingSetInfo table of function
pointers, which the compiler cannot inline through to the node's
Profile().
Add a probe() template taking the match test as a template parameter,
and build lookup, FindNodeOrInsertPos and getOrInsert on it in
FoldingSetImpl where the trait is known.
LLM-aided
[ValueTracking] Compute known bits for llvm.stepvector (#219779)
Teach ValueTracking to infer high zero bits for `llvm.stepvector` from
the
vector element count and a finite `vscale_range`.
Conservatively give up when the lane-count calculation overflows the
element
width, since `llvm.stepvector` truncates out-of-range lane indices.
This allows existing sign-bit reasoning to eliminate redundant
extensions for
bounded step vectors.
The regression tests cover scalable and fixed vectors, bounded and
unbounded
`vscale_range`, lane-index truncation, unconstrained inputs, and
signed-i32
boundary cases.
Fixes #219776.
[CodeGen] Migrate to FoldingSet's typed lookup/insert/erase. NFC (#219830)
Rename SelectionDAG::FindNodeOrInsertPos to lookupNode and use the new
FoldingSetInsertToken API in place of `void *`.
In SelectionDAG the token is named `InsertToken`, as Token there means
the chain operand (TokenFactor, EntryToken).
[SCCP] Fix missing worklist push for recursive calls that update lattice values (#219826)
For a recursive call, the call instruction itself is a user of the
function's arguments. Because I == CurI, I->comesBefore(CurI) is false,
and the condition triggers an early return. The recursive call
instruction was skipped and never pushed back onto the worklist, halting
the solver prematurely before reaching a fixpoint. This caused the
solver to incorrectly believe arguments were hardcoded constants rather
than a wider constant range, resulting in invalid branch folding.
The Fix: This patch updates the condition to explicitly check if I comes
strictly after CurI.
Fixes: https://github.com/llvm/llvm-project/issues/219503
[AArch64] Fix crash parsing an operand with both :specifier: and `@specifier` (#219737)
`add x3, x5, :lo12:sym at PAGEOFF` hits llvm_unreachable in applySpecifier:
Mach-O accepts both ELF style `:specifier:` and its own `@specifier`.
When an ELF-style :specifier already wraps the expression,
applySpecifier then receives an unexpected MCSpecifierExpr.
Parse `@specifier` only when no :specifier: is present.
[fuzzer] Restrict merge-sigusr.test to Linux (#216702)
The `fuzzer/merge-sigusr.test` test causes the whole `ninja check-all`
run on NetBSD to be killed with `SIGUSR2`.
It turns out the test is highly Linux-specific in at least two ways:
- The `setsid` command doesn't exist on any of Darwin, FreeBSD, and
NetBSD.
- `ps -o sess= <pid>` is highly unportable, too:
- FreeBSD `ps` doesn't have the `sess` keyword at all.
- NetBSD `ps` does, but with different semantics: it's the session
pointer, not the session id as on Linux, which leads to randomly killing
unrelated processes.
Therefore this patch restricts the test to Linux instead of simply
[6 lines not shown]
[sanitizer] Skip hanging tests on FreeBSD (#216703)
Three sanitizer tests hang indefinitely on FreeBSD:
```
MemorySanitizer-X86_64 :: fork.cpp
SanitizerCommon-tsan-x86_64-FreeBSD :: Posix/fork_threaded.c
ThreadSanitizer-x86_64 :: fork_multithreaded.cpp
```
All of them loop and don't time out, so they need to be terminated
manually for `ninja check-all` to complete. To avoid this, this patch
skips the affected tests.
Tested on `x86_64-pc-freebsd15.1`, `x86_64-pc-netbsd11.0` and
`x86_64-pc-linux-gnu`.
(cherry picked from commit cb2f67d1556c1232f99b4512a35129ec04f73c75)
[InstCombine] narrow select to match trunc condition operand size (#219794)
changed to matches the cmp handling and avoids some regressions from
https://github.com/llvm/llvm-project/pull/184182
[InstCombine] Don't change the size of a select if it would mismatch its trunc condition operand size (#219789)
Matching cmp handling and stops infinit loop for
https://github.com/llvm/llvm-project/pull/219794
[OpenMP] Make OpenMP version have separate type
It's unsigned now. Giving it a separate type would make the code clearer,
and it would make it easier to change the effective type if it's ever
needed.