[CIR] Accept a union whose members do not cover its declared size (#223594)
`union { unsigned Words[3]; void *Ptr; }` is 16 bytes because the
pointer's alignment rounds it up, and no member covers that size. The
pass refused to classify unions like that at all, so anything holding
one failed to compile. Tail padding doesn't change how an eightbyte
classifies, so this drops the precondition and classifies the union from
its own size.
[CI] Make updates to .ci actually test everything (#224125)
We ran into an issue where test failures in cross-project-tests were not
surfaced when bumping the image to Ubuntu 26.04 due to the script not
correctly calculating dependencies for changes to .ci and the premerge
workflow. This patch fixes that by ensuring the projects executed for
.ci/workflow changes are derived from everything else which means we do
not need to manually maintain the list and risk leaving it out of date.
[CAS] Read a CAS file's reserved size from st_blocks, not st_blksize (#224104)
FileSizeInfo reports how much disk a file already has, which
MappedFileRegionArena records so it knows how far ahead it has reserved.
However the file size was accidentally computed from st_blksize which is
the preferred I/O size, not the number of allocated blocks for the file.
The value is read when a database is created or reopened, so a reopened
database believed almost none of its disk was reserved and reserved it
again from near zero, a megabyte per allocation. Fix the problem by
using the correct size.
[WebAssembly] Use Single as the default Triple thread model (#223917)
Clang defaults WebAssembly to a single-threaded model unless atomics and
bulk-memory are enabled, whereas Triple::getDefaultThreadModel()
previously defaulted to POSIX for all targets. Because Clang only emits
the "thread-model" module flag when the active thread model differs from
the triple's default, single-threaded Wasm objects recorded
"thread-model"="single" while multithreaded objects omitted the flag.
When linking mixed objects in LTO, the merged module inherited "single",
causing passes like LICM and AtomicExpand to treat multithreaded
programs as single-threaded.
Change Triple::getDefaultThreadModel() to return ThreadModel::Single for
WebAssembly so that multithreaded objects explicitly record
"thread-model"= "posix" and single-threaded objects omit the flag.
Additionally, update WebAssemblyCoalesceFeaturesAndStripAtomics to set
the module thread model to POSIX when threading features are enabled and
no explicit module flag is present, ensuring backend passes like
AtomicExpandPass preserve atomics in raw IR modules compiled via llc.
Assisted-By: Gemini
[scudo] Do not trim the secondary cache if releasing is disabled. (#223881)
When the ReleaseInterval is set to less than zero, then releasing has
been disabled. In this case, honor this and do not trim the cache using
the MaxCacheResidentyBytes value.
Add a test to verify this behavior.
[CopyProf] Implement minimal CopyProf runtime. (#223458)
The runtime tracks object copies using shadow memory (with a 1:8
compression scale).
Each thread uses TLS to keep track of whether execution is currently
inside a special member function. Copy functions mark corresponding
shadow memory as a copy. Upon destruction, if an object was marked as a
copy and never modified, it is classified as an unnecessary copy, and a
report with a stack trace is generated.
RFC:
https://discourse.llvm.org/t/rfc-copysanitizer-csan-detecting-unneccessary-object-copies-at-runtime/91038
Previous PR: https://github.com/llvm/llvm-project/pull/207385
---------
Co-authored-by: jannewger <jannewger at google.com>
[bazel][libc] Be explicit about pic/nopic in startup_rules.bzl
Currently, this implementation gets object files from `OuputGroupInfo.compilation_outputs`, which isn't very well documented any will often just choose the PIC variant: [`cc_helper.bzl`](https://github.com/bazelbuild/rules_cc/blob/661b75de668c3b673f5550e0340e134ccf923956/cc/common/cc_helper.bzl#L192).
This PR updates `merge_relocatable_object` to propagate both pic/nopic variants of the merged object, and updates `libc_startup_object` to be explicit about its choice of pic/nopic.
The exact choice of how to handle pic/nopic may need to be updated in the future, but the changes in this PR is better than just using compilation_outputs verbatim.
[test][bazel][libc] Allow LLVM-libc tests to be run in full-build mode
This PR makes the required changes to run LLVM-libc full build tests in Bazel. After this PR, most tests pass:
```
bazel test @llvm-project//libc/test/... --config=ci --@llvm-project//libc:build_mode=full --keep_going
Executed 680 out of 853 tests: 681 tests pass and 172 fail to build.
```
Follow on PRs will fix specific tests that are failing (lots of missing deps etc).
This PR mostly involves propagating the correct dependencies and compiler/linker options from [`add_libc_hermetic`](https://github.com/llvm/llvm-project/blob/4098f568c46e06b6df470111868b4c165dd80f4d/libc/cmake/modules/LLVMLibCTestRules.cmake#L750). Slightly more involved changes:
- `BazelFilePath.cpp` also had to be fixed so that it doesn't depend on the non-namespaced `getenv` function. This PR models after https://github.com/llvm/llvm-project/commit/ee407f7e7069cccfdc1815de07e17cebf83d19f9 in order to conditionally use LLVM-libc's getenv under full-build mode.
- All tests have a dependency against `crt1.o` when run under full-build. This PR updates `merge_relocatable_object` so it also exposes a `CcInfo` with the merged object file and its transitive deps. In order to do so, this PR also makes the logic a little more careful about PIC vs non-PIC deps.
[Github] Use explicit --progress for large wget downloads (#224092)
Otherwise we get a log line every 50k which is exceedingly annoying as
it generates thousands of lines of output. Use mega/giga (3M/50M
respectively) depending upon the download size so we end up with about
20 lines of output.
[flang][OpenMP] Remove dependency on openmp-runtime where not needed,… (#224122)
… NFC
Several tests claimed dependence on openmp-runtime and had USE omp_lib
statements even though they didn't use anything from it.
Reland "[AMDGPU] PromoteAlloca: flatten homogeneous structs to vectors" (#221058)
This relands #217055
The original commit revealed a latent issue in eliminateFrameIndex in
SIRegisterInfo where SCC can be clobbered before reading it on
gfx900/gfx90a. This change itself has no known issues.
[AMDGPU] Don't spill an SGPR while SCC is live in frame index lowering
When SCC is live into a scalar frame index user, the scaling path avoids
SALU ops that write SCC by computing the address in a VGPR and reading it
back with V_READFIRSTLANE_B32. If the destination of that readfirstlane is
scavenged with spilling allowed, an AMDGPU SGPR spill writes inactive
lanes, so it flips EXEC with S_NOT_B64 and clobbers SCC. Instead, scavenge
that register with AllowSpill=false.
[AMDGPU] Only scale the frame register in place for the last frame index
When nothing can be scavenged, eliminateFrameIndex falls back to scaling
FrameReg in place and restoring it after MI. With two frame indices on
one instruction that fallback fires while lowering the first one, and
FrameReg is left scaled for everything that follows: the second frame
index is then scaled a second time from the already-scaled value, and any
emergency spill emitted in between uses it as its scratch offset.
[AMDGPU] Prevent SCC clobber in frame index lowering in scaling path
eliminateFrameIndex has two lowering strategies, but only one has the
proper handling for checking SCC-liveness to prevent clobbering. Unify
them with a helper function to ensure both paths handle the same