[flang-rt] Initialize I/O unit storage read by short-circuit predicates (#221126)
ConnectionState and OpenFile hold common::optional members read through
predicates of the form `opt && x < *opt`, which never use an indeterminate
value in the abstract machine. Compilers do, however, routinely if-convert
the short-circuit && into a branchless compare and select, which speculates
the payload load; because these objects are placement-new'd into malloc'd
storage by UnitMap::Create(), a memory checker then reports a conditional
branch that depends on uninitialized memory. On AArch64 this fires for
every Fortran program that writes a record, giving two reports in
ExternalFileUnit::AdvanceRecord() from IsAfterEndfile() and IsAtEOF(),
while x86-64 is unaffected and libgfortran is clean on the same program and
host. The reports are false positives -- the engaged flag is 0, so both arms
of the select are 0 -- but they are unavoidable noise for anyone running
Valgrind on Fortran code.
Add common::ResetWithDefinedPayload(), which leaves an optional disengaged
while writing its payload storage, and call it at construction for the
optionals in ConnectionAttributes, ConnectionState and OpenFile. Also
[15 lines not shown]
[flang] Reclassify MVBITS, SPLIT, and TOKENIZE as SIMPLE (#205024)
F2023 makes MVBITS a simple elemental subroutine and SPLIT/TOKENIZE
simple subroutines.
This change:
- adds `simpleSubroutine` and `simpleElementalSubroutine` to
`IntrinsicClass`,
- reclassifies the MVBITS, SPLIT, and TOKENIZE intrinsic table entries,
- propagates `SIMPLE` through intrinsic resolution and procedure
characteristics.
MOVE_ALLOC is not included in this change.
[asan][test] Check that stack traces are not truncated (#221518)
Add a test that the access, free and malloc traces each name the whole
call
chain down to `main`, in order, and that each names its own call site in
`main`. A trace that stops early -- as every trace but the access one
does when
the fast unwinder runs on a target that chains no frames -- fails it.
`deep_stack_uaf.cpp` already covers trace depth, but it looks for three
individual frames anywhere in the trace, so it passes on a trace with
holes in
it, and it needs C++ name demangling to do that.
Split out of #220231 at reviewer request.
Assisted-by: Claude Code
[OptTable] Store Info strings in the string table (#218845)
Change HelpText, MetaVar, AliasArgs, and Values from `const char *` to
StringTable::offset, making the fields smaller, and removing dynamic
relocations in .data.rel.ro in PIC links.
Store them as StringTable::Offset, like the option names already are,
and return StringRef from getOptionHelpText() and getOptionMetaVar().
The 53 tables in the tree lose all 616 KB of .data.rel.ro, and sizeof(Info)
drops from 88 to 60; clang's table becomes 232 KB of .rodata.
An unset field and one explicitly set to the empty string, such as a
HelpText<"">, have to stay distinguishable, so the latter gets an empty
string of its own rather than offset zero.
Values declared with ValuesCode are only known to the generated code,
which supplies getOptionValuesCode() for OptTable to call; only clang has any.
Aided by Opus 5
MC: Move DisableIntegratedAS from TargetOptions to MCTargetOptions (#221547)
The integrated assembler is only meaningful in MC, so this field belongs
in MCTargetOptions alongside the other assembler options rather than in
the codegen-level TargetOptions.
Co-authored-by: Claude (Claude-Opus-4.8)
[SelectionDAG] Remove dead functions (NFC) (#221541)
SelectionDAG::getBitcastedSExtOrTrunc,
SelectionDAG::getBitcastedZExtOrTrunc: Added on August 11, 2023 in
commit d26a06728da84a7302875a99ea86e887f6bc425a without any callers.
Assisted-by: Antigravity
[mlir][affine] Implement PromotableRegionOpInterface for AffineForOp (#221123)
The `mem2reg` pass couldn't promote memory slots accessed within an
`affine.for` because `AffineForOp` did not implement
`PromotableRegionOpInterface`, leading to the stack allocation and its
accesses to not be eliminated.
This change implements `PromotableRegionOpInterface` for `AffineForOp`,
allowing `mem2reg` to promote memory slots through affine loops.
[ADT][MemProf] Optimize set_subtract with removed-set output and use in MemProf (#221372)
Add a 3-argument set_subtract(A, B, Removed) that computes A := A - B
and records elements of B removed from A (A ^ B) in Removed. When
A.size() < B.size(), B supports contains(), and A supports remove_if(),
we iterate over A via remove_if() instead of iterating over B, improving
efficiency.
Remove the legacy 4-argument set_subtract(A, B, Removed, Remaining),
which was only used by MemProfContextDisambiguation.cpp and is now
redundant since Remaining can be updated via a separate 2-argument
set_subtract.
Update MemProfContextDisambiguation to use the 3-argument set_subtract,
and update SetOperations unit tests.
[InstCombine] Fold scalbn libcalls to llvm.ldexp (#216573)
This canonicalizes `scalbn`, `scalbnf`, and `scalbnl` libcalls to the
`llvm.ldexp` intrinsic when the call does not access memory.
LLVM floating-point types use radix 2, so `scalbn(x, n)` and `ldexp(x,
n)` produce the same numeric result.
Calls that may access memory are left unchanged because the libcall may
set `errno`, while `llvm.ldexp` does not access memory.
Fixes #216467
[orc-rt] Split support sources into their own object library (#221442)
This allows support to be used by both bedrock and the upcoming SPIRE
library. Note that support is a CMake object library only, not an
archive or dylib. Clients will always target either Bedrock or SPIRE.
Moves some sources (Error, RTTI, Logging, Environment and the whole sys/
tree), and some headers (Environment.h, and the orc-rt/bedrock/sys
headers) to the support library.
The per-system source composition moves to lib/support/CMakeLists.txt.
An upcomming commit will update the unit tests to reflect this split.
DAGCombiner: Drop AllowFPOpFusion from visitFADDForFMACombine (#221436)
Rewrites fp-dp3.ll to use flags on individual patterns. It weirdly
used different triples for the fp-contract on and off cases, seemingly
an artifact of the ARM64 and AArch64 merge.
fp-contract.cu is essentially a bugfix, the local fp contract(on) pragma
wins over the global flag now.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
VE: Use splitAt in expandExtendStackPseudo
Replace the manual block-splitting in expandExtendStackPseudo with
MachineBasicBlock::splitAt. Reduces boilerplate, but there's some
block renumbering churn in the output.
Co-authored-by: Claude (Claude-Opus-4.8)
VE: Compute live-ins after splitting for EXTEND_STACK expansion
expandExtendStackPseudo splits its block but left the new blocks without
live-in lists, so their uses of registers live across the split are
rejected by -verify-machineinstrs.
Co-authored-by: Claude (Claude-Opus-4.8)
[IR] Unique attribute sets and lists in a UniquingSet. NFC (#221525)
Switch to UniquingSet to remove FoldingSetNodeID serialization overhead
on every AttributeSet::get and AttributeList::get.
Attribute and AttributeSet are single-pointer wrappers whose operator==
is pointer equality. Specializing `is_hashable_data` selects the fast
`hash_combine_range_impl` overload that calls `combine_bytes` directly,
skipping copying element by element.
`hash_combine_range` deduces its element type as `const T`, so
`is_hashable_data<const T>` now follows `is_hashable_data<T>` and a type
need only specialize the unqualified form.
Aided by Opus 5
VE: Fix ill-typed setjmp result in emitEHSjLjSetJmp
Partially fixes machine verifier failures in existing tests;
they still fail due to other issues.
emitEHSjLjSetJmp materialized the 0/1 return values with LEAzii, which
defines an i64 register, into vregs with the i32 result register class.
This ill-typed MIR is rejected by -verify-machineinstrs.
Materialize the values in i64 and copy the low 32 bits (sub_i32) into the
i32 result. NFC on the emitted code.
Co-authored-by: Claude (Claude-Opus-4.8)
MC: Move DisableIntegratedAS from TargetOptions to MCTargetOptions
The integrated assembler is only meaningful in MC, so this field belongs
in MCTargetOptions alongside the other assembler options rather than in
the codegen-level TargetOptions.
Co-authored-by: Claude (Claude-Opus-4.8)