[compiler-rt][libc][GPU] Fix 7 builtin unit test build failure for spirv64 targets (#236324)
When building compiler-rt builtin unit test for spirv64 target, we
encountered a bunch of build failure due to missing symbols from libm
and libc. This PR adds part of required symbols needed by those tests
which can make 7 failed unit tests to build pass.
Using following command to build llvm-project:
cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="clang"
-DRUNTIMES_spirv64-unknown-unknown_LLVM_ENABLE_RUNTIMES="compiler-rt;libc"
-DLLVM_RUNTIME_TARGETS="default;spirv64-unknown-unknown"
-DRUNTIMES_spirv64-unknown-unknown_COMPILER_RT_INCLUDE_TESTS=ON
-DRUNTIMES_spirv64-unknown-unknown_COMPILER_RT_EMULATOR=/bin/true
ninja all
ninja check-compiler-rt-spirv64-unknown-unknown
Before the fix, the build result was:
Total Discovered Tests: 275
Unsupported: 125 (45.45%)
Passed : 123 (44.73%)
Failed : 27 (9.82%)
[14 lines not shown]
Revise patch submission guidelines in Contributing.md (#235729)
There have been a few people who have been confused by the single commit
rule in this document.
Meaning they think they need to rebase/squash on every commit. This
hopefully clarifies it is only for the first commit. I also took the
liberty while in this file to just remove some duplication and link to
the actual areas that provide more detail.
[BOLT] Avoid temporary sections during symbol discovery (#237150)
`discoverFileObjects()` constructs a temporary `BinarySection` for every
candidate symbol merely to test allocation flags. This is expensive for
binaries with tens of millions of symbols (e.g. large RISC-V binaries
linked with `--emit-relocs,` which retain many local symbols referenced
by relocations needed to support linker relaxation). Inspect the ELF
section flags directly and reuse the retrieved symbol flags.
[SimplifyCFG] Thread loop header edges when the loop remains canonical (#232541)
When NeedCanonicalLoop is set, foldCondBranchOnValueKnownInPredecessor
rejected all loop headers to avoid redirecting a backedge into the
middle
of a loop and forming a cycle that bypasses the header.
Allow threading when every threaded predecessor is dominated by the
header and the destination cannot reach those predecessors without
passing through the header (e.g. a latch edge branching to a loop exit).
[clang][OpenMP] Don't declare HIP's ::min and ::max in an OpenMP TU (#225162)
`__clang_hip_math.h` declares templated `::min` and `::max` as a CUDA
source-compatibility extension. `openmp_wrappers/math.h` includes that
header inside the `amdgcn` declare variant, so the amdgcn device pass of
an *OpenMP* translation unit — ordinary C++ that never opted into HIP or
CUDA — also gets them.
An unqualified `min(a, b)` after `using namespace std` is then ambiguous
against `std::min`, so the TU fails to compile in the device pass while
compiling fine in the host pass:
```c++
#include <algorithm>
using namespace std;
long f(long a, long b) { return min(a, b); } // error: call to 'min' is ambiguous
```
`::min` and `::max` are not names the implementation may reserve in a
[17 lines not shown]
[NFC][AMDGPU] Don't create call site AACallEdges for direct calls (#237633)
`AAAMDGPUMinAGPRAlloc` and `AAAMDGPUNoLDSDMA` asked for a call site
`AACallEdges` for every call that is not an intrinsic, only to get its
callees. For a direct call whose callee has no callback metadata, that
callee is the only one, so use it directly, like `AACallEdgesFunction`
does since #232616. Calls to callback brokers still use `AACallEdges`,
because the broker also calls the callback target.
On a generated module with 2,001 functions and 15,986 calls,
`-passes=amdgpu-attributor` creates 2,001 instead of 11,987 abstract
attributes, and the median wall time goes from 95 ms to 84 ms.
This PR was assisted by AI but I reviewed all the changes.
[libc++][ranges] Implement LWG3904: `lazy_split_view::outer-iterator`'s const-converting constructor isn't setting `trailing_empty_` (#237550)
Copy `trailing_empty_` in `outer-iterator`'s const-converting
constructor. Previously, converting an iterator that points at the
trailing empty subrange (e.g. the second element of `"a,"` split by
`","`) made it compare equal to `default_sentinel`, so that subrange was
lost.
Fixes #105276
[lld] Migrate away from PointerUnion::dyn_cast in ICF.cpp (NFC) (#234844)
PointerUnion::dyn_cast has been soft-deprecated in favor of
llvm::dyn_cast and llvm::dyn_cast_if_present. This patch replaces it
with llvm::dyn_cast_if_present in ICF.cpp. Note that
Relocation::referent can be null when an external relocation
references a symbol defined in a section that is not split into
subsections, such as __DATA,__objc_imageinfo, for which
ObjFile::parseSymbols leaves the entry in ObjFile::symbols as nullptr.
Assisted-by: Antigravity
[Support][AArch64] detect more host CPU SME features. (#234870)
Add detaction for SME related features. The features align with the
handling in AArch64TargetInfo::computeFeatureLookup()
[lld][MachO] Don't collect FDEs twice in ICF (#236372)
`ld -r` emits __eh_frame as S_REGULAR instead of S_COALESCED, so ICF
treated it as foldable and collected each FDE again on top of its
function's unwind entry.
The test case was made by an LLM.
[lld][MachO] Drop dead inputs from __objc_methlist (#237185)
Category merging marks the method lists of merged categories and their
symbols dead, but they were still emitted by ObjCMethListSection, and
-map hit an assertion on their symbols.
[NFC][AMDGPU] Don't create call site AACallEdges for direct calls
AAAMDGPUMinAGPRAlloc and AAAMDGPUNoLDSDMA asked for a call site AACallEdges for
every call that is not an intrinsic, only to get its callees. For a direct call
whose callee has no callback metadata, that callee is the only one, so use it
directly, like AACallEdgesFunction does since #232616. Calls to callback brokers
still use AACallEdges, because thebroker also calls the callback target.
On a generated module with 2,001 functions and 15,986 calls,
-passes=amdgpu-attributor creates 2,001 instead of 11,987 abstract attributes,
and the median wall time goes from 95 ms to 84 ms.
This PR was assisted by AI but I reviewed all the changes.
[NFC][Attributor] Reach fixpoint in call site AACallEdges for direct calls (#237632)
A direct call whose callee has no callback metadata only calls its
callee, so its call site `AACallEdges` cannot change after
initialization. Add the edge in initialize and reach a fixpoint there,
instead of updating the attribute twice to find out.
`AACallEdgesFunction` already skips the call site attribute for such
calls since #232616; both now share `getOnlyCallee()`.
Other attributes still create call site AACallEdges for direct calls,
e.g., `AAInterFnReachability` and the AMDGPU attributor. On a generated
module with 2,001 functions and 15,986 calls, this removes all updates
of call site `AACallEdges`. The total number of updates goes from
304,263 to 272,291 with `-passes=attributor`, from 207,815 to 175,843
with `-passes=attributor-light`, and from 35,977 to 16,005 with
`-passes=amdgpu-attributor`. The wall time does not change measurably on
that module, because these updates are cheap.
This PR was assisted by AI but I reviewed all the changes.
[NFC][Attributor] Remove "See AbstractAttribute::..." comments
Most overridden methods have a comment like
`/// See AbstractAttribute::initialize(...).` that only points to the
base class declaration. Remove them, including those in OpenMPOpt and
AMDGPUAttributor.
This PR was assisted by AI but I reviewed all the changes.
[Clang][CodeGen] Update the TBAA info for potential aliases (#236701)
The stores were tagged as "unsigned long", but loads were tagged as
"float". TBAA reports no aliases if the store and loads went through
different pointers and GVN forwards a stale value.
Fix this by giving the "store" the "omnipotent char" tag, so that TBAA
treats it as aliasing every access to the destination's members. Using
that tag over "Dest.getTBAAInfo()" because it doesn't depend on how
CodeGenTBAA happens to tag struct and complex types.
Assisted-by: Claude for testcases.
[LV] Use loop guards for the maximum trip count from the SCEV range. (#237792)
Apply loop guards before computing the unsigned range, so the bound used
to clamp the VF and select the IC is as tight as possible.
This avoids choosing excessive VF/IC for loops where bounds refine the
max trip counts.
[LV] Generate SCEV runtime checks for outer loops. (#237780)
Update GenerateRTChecks::create to generate SCEV predicate checks for
outer loops as well. Memory checks are not supported yet, but we must
respect the SCEV predicates added to PSE.
[LV] Add tests with trip counts known less than VF x UF. (#237777)
Add tests where trip counts are known to be less than VF x UF, but we
still pick a VF that exceeds the trip count.