[GVN] Don't coerce forwarded byte values through integers (#226583)
GVN forwards a store to a load of a different type through an integer.
It casts the stored value to `iN`, then shifts and truncates it. For
byte values that cast is wrong, as it drops pointer provenance, and a
single `poison` bit makes the whole result `poison`.
Byte stores, and pointer stores that feed byte loads, no longer go
through an integer. GVN takes the loaded bits with `bitextract`,
bitcasting through `bN` where needed.
```llvm
store b32 %x, ptr %p
%v = load b8, ptr %q ; %q = %p + 1
```
```diff
-%1 = bitcast b32 %x to i32
-%2 = lshr i32 %1, 8
[17 lines not shown]
[InstSimplify] Simplify `bitinsert` and `bitextract` (#229125)
Simplify `bitinsert` and `bitextract` with non-constant operands.
- An out-of-range, `poison` or `undef` offset returns `poison`.
- A full-width byte `bitextract` or `bitinsert` at offset zero is a
no-op.
- Extracting the bits just inserted, at the same offset and type,
returns the inserted value.
- Reinserting byte bits extracted from the base, at the same offset,
returns the base.
```llvm
%a = bitextract b32, b32 %x, i32 0 ; %x
%b = bitinsert b32 %x, b32 %y, i32 0 ; %y
%c = bitextract ptr, b64 %w, i32 32 ; poison
%i = bitinsert b32 %x, i8 %z, i32 %n
%d = bitextract i8, b32 %i, i32 %n ; %z
[8 lines not shown]
Revert "[AArch64][MacroFusion] Check register overlap in WAW check" (#234172)
This reverts commit 77be0679c76d6763f8d2b348a7555d75891e2c09.
Restricting WAW check back to exact match of same dest, as overlap
should not generally be the default and should not have an existing
user.
[clangd] Make the --skip-preamble-build option take an enum (#229515)
Add a new value `never` allowing the preamble skipping to be
force-disabled, in addition to `modules` and `always`.
The default is `modules`, equivalent to the old behavior.
Closes #212403
[clang][test][NFC] Fix missing colons in FileCheck directives (#235342)
The `:` was missing from:
- `CHECK-NEXT` in `clang/test/AST/ast-dump-attr-type.cpp`.
- `CHECK-LABEL` in `clang/test/CodeGen/constantexpr-fneg.c`.
Also, in `clang/test/CodeGen/constantexpr-fneg.c`, adding the missing
`:` to `CHECK-LABEL` exposed that `clang -cc` (without an explicit
`-triple`) emits `define dso_local i32 @main()` on Linux, so `{{.*}}` is
added to match across targets.
Assisted-by: Gemini
[clang][Driver] Don't let -save-temps overwrite the input file
With -save-temps, an intermediate file named after the input can be the
input itself, e.g. the preprocessed output of a .s file on Darwin. The
driver catches this, but only checked for it when the output's name was
the input's file name. It missed two cases, and overwrote the input with
the preprocessed output:
- With -save-temps=obj, the output is in the output's directory, so
"clang -c -save-temps=obj sub/t.s -o sub/t.o" wrote "sub/t.s".
- On a case-insensitive file system, such as macOS's default, the
preprocessed output "t.s" of an input "t.S" is the same file.
Check whether the output is the same file as the input whenever temps
are saved.
Fixes #7002.
Assisted-by: Claude Opus 5.5
[NVPTX] Set default value of nvptx-allow-ftz-atomics to false (#231429)
This restores the strict FTZ default originally introduced in #200732 and temporarily relaxed in #206154.
Frontends can now explicitly opt in to native FTZ-mismatched atomics on a per-instruction basis using `!atomic.ignore.denormal.mode` metadata (#217585, #217586, #217587, #217588, #232725, #232726), which is supported in Clang, Flang, MLIR, and XLA. Users who need the previous behavior globally can still pass `-nvptx-allow-ftz-atomics=true`.
Update test cases to verify the new default disallow behavior.
[KnownFPClass] Combine fpext and fptrunc into a shared routine (#225188)
Implements https://github.com/llvm/llvm-project/issues/219847
Partially addresses https://github.com/llvm/llvm-project/issues/219300
Fixes:
- `DenormalMode` handling by `fptrunc`/`fpext`
- `fpext` no longer rules out `qNaN` if the input could be `sNaN`.
Changes:
- `fptrunc` now takes the input/output types.
- `fpext`/`fptrunc` take the `DenormalMode` of the source/destination
types.
I completely rewrote `fpext` and `fptrunc` to use a shared `fpconvert`
routine. Using an approach of starting from `fcAllFlags` and removing
classes instead of starting from `KnownSrc` and adding classes. This
rewrite also improves some deductions for `fptrunc`.
The internal `fpconvert` routine I added should also be able to handle
[13 lines not shown]
X86: Fix inconsistent dead flags when expanding MOV32ri64
The expansion added a live implicit-def of the 64-bit register and
kept the original dead flag on the 32-bit def. The implicit-def is
unnecessary since the 32-bit def covers the same register units.
Drop it, and only mark the 32-bit def dead if the instruction has no
other live def of it, matching what LiveVariables would produce.
Fixes #234931
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[X86][APX] Fix commuting SHLD/SHRD NF, NF_ND and EVEX variants (#233873)
All SHLD/SHRD rri8 variants are marked commutable, but
commuteInstructionImpl only rewrote the legacy and _ND opcodes as SHLD
B, C, I <-> SHRD C, B, (BitWidth - I). The _NF, _NF_ND and _EVEX
variants fell through to the generic commute, which only swaps the
sources and changes the result.
This is reachable when optimizeCompareInstr converts an EFLAGS clobber
to its NF form (e.g. SHLD16rri8_ND -> SHLD16rri8_NF_ND) and RA assigns
the destination to the second source: X86CompressEVEX commutes it to
drop the redundant NDD destination and emits the wrong shift. The
TwoAddressInstruction pass can hit the same bug when commuting the
non-NDD _NF and _EVEX forms.
Assisted-By: Claude Opus 5.5 <noreply at anthropic.com>
[ELF] Parallelize .eh_frame writing. NFC (#235391)
EhFrameSection::writeTo copies CIE/FDE and applies relocations on one
thread, leaving a long single-threaded tail in "Write sections".
Parallelize them, saving ~24ms when linking chromium x86-64.
[ELF] Scan .eh_frame relocations first. NFC (#235389)
.eh_frame is usually the largest item, so one thread scans it while the
others are idle. Hand it out first.
[LLDB] Skip Undef Symbol when resolving ReExportedSymbol
An undef symbol cannot be resolved. Skip it so that a symbol needs no
Resolve can pass. Without this, a symbol that needs no ReExport resolver
can choose the undef symbol incorrectly.
Assisted-by: Claude # Test