[AMDGPU] Treat a bitcast between legal types as free
The generic cost model treats a bitcast as free only when both types
are integer types or both are not. AMDGPU keeps integer and
floating-point values in the same registers, so a bitcast between two
legal types is a no-op. A scalar bitcast from i32 to float cost 1, but
the vector bitcast from <2 x i32> to <2 x float> cost 0. The SLP
vectorizer counted this difference as a saving.
A bitcast that involves a type the target legalizes, such as a vector
of i8, keeps its cost, because the lanes may need repacking.
Assisted-by: Claude Opus
[SystemZ][z/OS] Unconditionally use DynamicNoPIC relocation model (#238087)
On z/OS, generated code is always position-independent, so -fpic and
-fno-pic have no effect. Previously, getEffectiveRelocModel() returned
the requested relocation model if one was provided. When -fpic was
passed, TargetMachine:: isPositionIndependent() returned true, enabling
optimizations such as relative lookup tables that generate 32-bit
relative offsets between globals. These are incompatible with the GOFF
binder's requirement for 8-byte relocations in C_WSA64.
This change forces getEffectiveRelocModel() to always return
Reloc::DynamicNoPIC on z/OS, regardless of what the frontend requests.
Assisted-by: IBM Bob
[AMDGPU][NFC] Add bitcast cost tests for legalized types and pointers
Add bitcasts that involve types the target legalizes, such as vectors
of i8, i24 and <2 x i24>, and bitcasts of pointers. Add a gfx7 RUN
line, where i16 and <2 x i16> are not legal.
Assisted-by: Claude Opus
menu(3x): Constification and voidification of pointer arguments.
libmenu has several functions that take a non-const char * argument
and then (effectively) strdup(3) it. I've changed it so that these
functions take a const char * argument. Modern GCC objects to string
literals being passed to these functions otherwise.
In other cases, a userptr allows some data to be associated with a
data structure, but its type is char *. I've changed it to void *.
Both of these changes are consistent with similar changes in ncurses,
although are inconsistent with SVR4 libmenu versions. libmenu has
unfortunately never been standardized.
"that is fine" - blymn@
[lldb][Windows] Lock DebuggerThread::m_process against the debug loop (#236560)
When the inferior exits before its initial stop, the debug loop resets
`DebuggerThread::m_process` but the launching thread copies it. Both
threads touch the same `shared_ptr`, which corrupts the heap, and
lldb-server dies with `0xC0000374`.
This causes `TestMissingDll.py` to fail with `"Sending vRun packet
failed"`.
This patch guards `m_process` with a mutex.
Tested on Windows with the race window widened: 21 of 800 launches
crashed before, 0 of 4800 after. `TestMissingDll.py` passed 1600 of 1600
runs.
rdar://191149207
[BoundsSafety][NFC] Add late-parsed type attribute lists to declarators (#224559)
This is groundwork for late-parsing type attributes in every type
position where an ordinary type attribute can appear, following the
direction set in https://github.com/llvm/llvm-project/pull/223267, which
allows a CountAttributedType's count to be filled in later.
Ordinary type attributes are kept on the DeclSpec, on each
DeclaratorChunk and on the
Declarator. Give late-parsed type attributes the same three homes, with
nothing producing or consuming them yet.
No functional change: no caller passes a list yet, so the lists stay
empty. The next commit populates them.
Assisted-by: Opus 5.5
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
Makefile.inc1: Fix bare $ characters
The '$' characters inside awk commands need to be $$ when appearing
inside a Makefile. Without this, we generate empty src and src-sys
packages.
Reported by: Stefan Grundmann
Fixes: a8be89928930 ("build: Support got")
MFC after: 1 day
[libc] Bound the decimal point check in simple_decimal_conversion (#238179)
HighPrecisionDecimal clamps the decimal point to 1 << 30, but
exp10_to_exp2
is only valid for inputs below 646456636. For larger decimal points the
result wrapped to a negative value, so the "too large" and "too small"
checks did not trigger and the shift loops ran tens of millions of
iterations until exp_2 overflowed (signed integer overflow).
Treat decimal points at or beyond the valid range of exp10_to_exp2 as
out of
range, and use add_overflow/sub_overflow for exp_2 in the shift loops so
that they stay well defined.
Assisted-by: Claude (Anthropic)
RuntimeLibcalls: Only apply vector math attributes to floating point vectors
i128 is now <2 x i64> on Win64, which made the vector type checks treat
integer helpers like __atomic_load_16 as vector math functions and mark
them nosync and nofree. Check for a floating point vector argument.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply at anthropic.com>
SelectionDAG: Use the memory type for atomic libcall actions
The atomic libcall selection is driven by the memory type, not the
legalized value type. Convert targets to use the LibCall action
instead of Expand.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[BoundsSafety][Docs] Add an index page and upstream status for -fbounds-safety (#238142)
Move -fbounds-safety docs into BoundsSafety/ without changing their
content.
Add BoundsSafety/index.md as the landing page for the -fbounds-safety
docs. It covers how to contribute, standardization efforts in WG14,
open-source adoption efforts, RFCs, and talks.
Add upstream status and the link #238453, which lists what is available
upstream, what is in progress, and what is planned, with links to the
relevant PRs and issues.
Leave a stub at the old BoundsSafety.html location so existing links
keep working.
Assisted-by: Opus 5.5
[clang][APFloat] Print floating-point literals in the shortest round-trip form (#218471)
StmtPrinter printed a `FloatingLiteral` at the maximum round-trip
precision, so `3.14` printed as `3.1400000000000001`. This patch adds
`APFloat::toStringShortest` and calls it from `PrintFloatingLiteral`.
NaN, infinity, and zero keep the old path.
`toStringShortest` computes the shortest digit count from the value's
rounding interval (Ryu's formulation with a Dragonbox-style grid anchor)
in exact APInt arithmetic, so every IEEEFloat semantics works. The
existing `toString` then formats at that count and the round trip is
verified. PPCDoubleDouble keeps a plain probe from precision 1.
Two cases keep the natural-precision form:
- An integer in fixed notation has exact digits; a shorter form would
only switch it to scientific notation. `100.0` prints as `100.`, not
`1.0E+2`.
- The largest value of a format with neither infinity nor NaN parses
back from any larger string by saturation, which is not a round trip.
[24 lines not shown]
RuntimeLibcalls: Declare vector libcall attributes in TableGen
Replace the type-based heuristics for vector math libcall attributes
with attributes declared on the libcall definitions, emitted with the
same attribute table helpers as intrinsics.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
TableGen: Move attribute set and sequence table helpers to a header
Move AttributeSetTable and AttributeSequenceTable out of
IntrinsicEmitter into a reusable header so the runtime libcall emitter
can use the same encoding.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Mark vector libcall out pointers dereferenceable
The whole vector width will be written, so mark the vector width. To
maintain the element width alignment for some functions, we need to
start explicitly tracking if the element alignment is used or not.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
TableGen: Unique intrinsic attribute tables by attribute value
Unique the intrinsic attribute tables by the attributes themselves
rather than by CodeGenIntrinsic, and separate the uniquing from the
emission in AttributeSetTable and AttributeSequenceTable so other
emitters can reuse them.
This also fixes MaxNumAttrs, which was computed from one representative
intrinsic per argument attribute sequence and could undercount.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Use <2 x i64> for i128 libcall types on Win64
Win64 passes __int128 by reference and returns it in XMM0. i128 uses
GPR pairs, and <2 x i64> uses the correct vector register. This
matches the type AtomicExpand and clang uses for these functions.
Also fix AtomicExpand to use the correct type for UEFI (which should
eventually use the type information in RuntimeLibcallsInfo).
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[SimpleLoopUnswitch] Do not let droppable instructions block trivial unswitching (#238292)
In a loop such as
```c
for (...) {
__builtin_assume(i < n);
if (c) break; // c is loop-invariant
...
}
```
the invariant exit should be unswitched trivially as `c` is checked once
before the loop with no copy of the loop. Instead, the assume stops
trivial unswitching since the pass gives up at any instruction that may
have side effects before the branch, and `llvm.assume` claims to write
memory so that it is not deleted as dead code. The loop then goes
through non-trivial unswitching, which duplicates the loop body.
Skip droppable instructions (`llvm.assume`, `llvm.pseudoprobe`,
`llvm.experimental.noalias.scope.decl`) in that check. LoopDeletion uses
the same principle.