[1/3][RegAlloc][LiveRegMatrix] Fix inconsistency in HoistSpillHelper delegates (#197773)
HoistSpillHelper's LiveRangeEdit delegate callbacks did not keep the
LiveRegMatrix consistent when eliminateDeadDefs triggered interval
shrinking and splitting during spill hoisting.
Three issues:
1. No LRE_WillShrinkVirtReg override: when eliminateDeadDefs shrinks a
vreg's interval via shrinkToUses, the matrix was not updated. Add an
override that unassigns the vreg from the matrix and records it in
PendingReassignments for later re-assignment.
2. LRE_DidCloneVirtReg called VRM.assignVirt2Phys without
Matrix->assign: when splitSeparateComponents creates new vregs, the
clones got VRM entries but were never inserted into the matrix. Fix by
consuming PendingReassignments and properly assigning both Old (shrunk)
and New (split) intervals to the matrix.
[15 lines not shown]
[flang][cuda] Lower c_devptr value arguments in bind(c) like c_ptr (#199316)
Treat `type(c_devptr), value` arguments in BIND(C) interfaces like
`type(c_ptr), value` by passing the nested raw address value instead of
the outer derived type ABI. This keeps call signatures consistent for
CUDA Fortran generic specifics that share a C binding label and avoids
argument misclassification at the x86_64 register/stack boundary.
[DSE] Restrict partial-overlap store merging to matching orderings. (#199728)
Partial-overlap store merging folds the later killing store into the
earlier dead store and erases the killing store. That is invalid if the
killing store is volatile or has stronger-than-unordered atomic
ordering, because erasing it drops an observable write. It is also invalid
if the killing and dead stores have different atomic orderings, because
the bytes originally written by the killing store would inherit the dead
store's atomicity after the merge -- silently dropping (or adding)
atomicity for those bytes.
Require both stores to be unordered (i.e. non-volatile with ordering at
most unordered) and to share the same ordering. This preserves the
existing fold for two simple stores or two unordered-atomic stores
(e.g. simple.ll's test43a) while leaving volatile, ordered-atomic, and
atomicity-mismatched cases in place.
This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply at anthropic.com>
[llvm][Object] Add COFF support to extractOffloadBundleFatBinary (#199574)
Use PointerToRawData from the COFF section header to compute the section
offset, replacing the previous stub that returned an error for all COFF
object files.
This enables llvm-objdump --offloading and llvm-readobj --offloading to
work on COFF fatbins produced by HIP on Windows.
---------
Co-authored-by: James Henderson <James.Henderson at sony.com>
Co-authored-by: Matt Arsenault <arsenm2 at gmail.com>
Require a selector when lowering WHEN
This patch ensure we don't have missing selector as unconditional in
lowering since `WHEN` requires a context-selector.
Added negative test to replace the positive test testing against missing
selector.
Preserve metadirective user condition scores
The user-condition path returned before getTraitScore was called, so a
score on condition(...) was silently ignored during variant selection.
Extract the score before dispatching user-condition handling, pass it to
the condition traits, and add a test where a scored true condition wins
over an unscored candidate.
Fix trait-property mapping and improve metadirective tests
- In processTraitProperties, restrict the device_isa___ANY fallback to
only isa selectors. Unknown properties under arch, kind, or vendor
now produce an invalid trait so the variant does not match. Previously,
device={arch("neon")} would incorrectly match via ISA target-feature
checking.
- Add metadirective-nothing tests for OpenMP version >= 5.1.
- Add explicit -triple flags to ISA tests so AArch64 features run
under an aarch64 triple and x86 features under an x86_64 triple.
- Split device={arch()} tests into metadirective-device-arch.f90
- Add omp.terminator checks for begin/end metadirective match cases.
- Remove begin-metadirective.f90 TODO test (now supported).
Assisted with copilot
Use selected variants in metadirective construct context
Construct traits gathered only from PFT parents miss constructs introduced
by an enclosing selected begin-metadirective variant. This can cause an
inner construct selector to reject a matching variant.
Use already-emitted enclosing OpenMP operations as the effective context,
falling back to PFT parents when no such operation exists. Add a test for
an inner selector matching target plus an outer-selected parallel.
Fix metadirective implicit-nothing candidate ordering
Preserve whether a metadirective variant was explicitly
specified so selection can distinguish explicit nothing
from an omitted directive variant. Order explicit candidates
before implicit nothing candidates when invoking the OpenMP
context scorer, matching the metadirective tie-break rule.
Add standalone and begin/end metadirective regression tests
where an implicit nothing candidate appears before an
otherwise-tied explicit directive variant.
Reference:
OpenMP 5.0 [2.3.4] says that if multiple when clauses have
compatible context selectors with the same highest score, and
at least one of them specifies a directive variant, "the first
directive variant specified in the lexical order of those when
clauses" replaces the metadirective.
[flang][OpenMP] Support lowering of metadirective (part 1)
This patch implements following feature in metadirective:
- implementation={vendor(...)}
- device={kind(...), isa(...), arch(...)}
- user={condition(<constant-expr>)}
- construct={parallel, target, teams}
- default, nothing, and otherwise clause
Dynamic user conditions, target_device, and loop-associated
variants are deferred to follow-up patches.
This patch is part of the feature work for #188820.
Assisted with copilot and GPT-5.4
[libc][ci] Improve full build precommit CIs caching keys. (#199742)
Currently full build precommit CIs only uses c_compiler as the cache's
key which will be the same for many of them listed in the matrix list.
We change to use the combination of (target + build_type + c_compiler)
as keys to uniquely distinguish them and the future gcc builds.
[clang-doc] Add option for compact JSON (#190822)
By default all JSON is serialized "pretty" with whitespace. This patch
adds an option to serialize JSON without whitespace. This trims the size
of the JSON folder for clang from around 1.3 GB to 785 MB, which is a
39.6% decrease.
[clang][SemaOpenACC] Reject VLA reduction (#199178)
`GenerateReductionInitRecipeExpr` only handled `ConstantArrayType` when
walking the operand type to build an InitListExpr. A VariableArrayType
`(int arr[i+1])` fell through to the final else branch and tripped
`assert(Ty->isScalarType())`.
Rather than silently accepting VLAs (which have no reasonable lowering.
unlike pointers, there is an expectation of initialized values,but we
cannot statically enumerate elements), reject them outright in
`CheckVarType` with a new diagnostic err_acc_reduction_vla. This is
consistent with the fact that neither codegen nor lowering currently
supports VLA reductions, and other compilers (GCC crashes, NVC++
silently ignores) do not meaningfully handle them either. The fix
upgrades the existing warning path for non-constant arrays in
`CheckVarType` to an error when the clause kind is Reduction, so VLAs
never reach `GenerateReductionInitRecipeExpr`.
Reproducer:
[18 lines not shown]
[lld][MachO] Fix SIGBUS crash in saveOrHardlinkBuffer (#198381)
This change removes a hardlink in saveOrHardlinkBuffer if the
hardlink already exists.
On Mac, -object_path_lto files are hardlinked to the cache when
possible. If the hardlink fails, the saveOrHardlinkBuffer method
falls back to saveBuffer instead.
saveBuffer() opens the file that is being written to as a
raw_fd_ostream object, which truncates a file when opening if the
file already exists.
Most of the time this is not an issue, however, if the hardlink
fails because it actually already exists, AND the hardlink exists
specifically between the -object_path_lto file and the cache file,
then when the file is opened and truncated, we also accidentally
truncate the file we are trying to read from.
[8 lines not shown]