[CIR] Fix use-after-free in BrOp::canonicalize (#229191)
BrOp::canonicalize took the branch's destination operands as an
OperandRange, erased the branch, and then passed the range to
mergeBlocks. The range points into the branch's operand storage, which
eraseOp frees, so mergeBlocks read freed memory whenever the merged
block had arguments. Valgrind reports it on the new test:
```
Invalid read of size 8
at mlir::ValueRange::dereference_iterator
by mlir::RewriterBase::inlineBlockBefore
by cir::BrOp::canonicalize
Address ... is 136 bytes inside a block of size 144 free'd
by mlir::RewriterBase::eraseOp
by cir::BrOp::canonicalize
```
It goes unnoticed with glibc malloc, which usually leaves the freed
operands intact. Copy the operands before erasing the branch.
Fix DHCP save, dotted interfaces and entry checks from review
Switching an interface to DHCP raised UnboundLocalError partway
through the save, because the interim start_static_network call used
locals that only the manual path set. The greyed out address entries
are now checked in DHCP mode too, and the call is skipped when they
hold no valid address.
rc.subr reads the settings of em0.10 from ifconfig_em0_10, and sysrc
refuses a name with a dot, so settings for dotted interfaces were
silently not saved. Add validate.rc_conf_interface(), which maps
".-/+" to "_" like get_if_var in network.subr, and use it for every
ifconfig_* variable written or read.
An IPv6 gateway zone must now name the interface being configured.
Search domains with more than one trailing dot are refused, and so is
a zero IPv4 netmask.
[msan][test] Add MSan case to clang/test/CodeGen/fake-use-sanitizer.cpp (#229564)
Regression test for https://github.com/llvm/llvm-project/issues/225425,
showing that MSan incorrectly strictly handles fake_use.
[mlir] Migrate AMDGPU/ROCDL to targets, not chipset versions (#223563)
**migration tl;dr:** Replace usages of `amdgpu::Chipset` with
`ROCDL::TargetInfo`, ideally move from `chipset=` to `arch=`. If you
don't use upstream pipelines, call
'TargetInfo::migrateArchFeaturesToModuleFlags` at the appropriate
location.
Further note: if you've got a build pipeline that's getting a `gfxXXX`
name from something like `rocm_agent_enumerator`, using a full triple
name like the ones you get from `rocminfo` is preferred.
`amdgpu::Chipset` was an awkward hack that was hard to keep up to date
with changes in the compiler/new architectures, and didn't properly
support generic targets (and has been strongly disfavored by the
compiler team).
This PR replaces `amdgpu::Chipset` with `ROCDL::TargetInfo`, a
structure that uses LLVM's TargetParser and the underlying LLVM
[47 lines not shown]
[Bazel] Add FlowSensitive/Models headers to clang:analysis (#229578)
Fixes bazel build failure introduced in commits e03123a63162 and
f0d6540d5307, where GtestModelHelpers.h was added to
lib/Analysis/FlowSensitive/Models and included in Models/*.cpp.
Take a different approach
HLASM derives the AMODE from the RMODE if no AMODE is explicitly
given. The same can be done in the GOFF writer, simplifying the
coding a lot.
[CodeGen] Drop dead SlotIndexes before allocation
SlotIndexes keeps the index list entry of an erased instruction and only
clears its instruction pointer. Live range sizes are measured in slot
indexes and greedy ranks ranges by size, so the leftovers inflate some
ranges more than others and reorder allocation, spilling heavily on
register-starved functions.
Add SlotIndexes::compactIndexes() to erase them. Erased entries are
unlinked, so LiveIntervals first reports the indexes it holds via
appendReferencedIndexes().
Off by default behind -greedy-compact-slot-indexes, since it changes
allocation across much of the test suite.
[libc] Add 'x' and 'e' mode support to fopen() (#224207)
Add exclusive creation (x) and close-on-exec (e) support to the fopen.
Also extended the related close-on-exec handling to fdopen() and to
freopen()
Fixes #223070
Assisted-by: Codex
[libc][locale] Fix nullptr argument handling in setlocale. (#229569)
`setlocale` function should accept `nullptr` as a possible value for the
second argument - in this case the
locale is not modified but queried. Make sure to return `C` locale in
this case (the only one supported by LLVM-libc).
Expand the unit test to verify `setlocale` behavior.
[CIR] Classify reference-to-pointer catch parameters in CIRGen
When a handler catches a reference to a pointer, __cxa_begin_catch returns
the caught pointer by value instead of the address of the exception object,
and how the reference is bound depends on whether the pointer points to a
class. The CIR type of the catch parameter cannot always tell whether it is
a reference to a pointer, or whether the pointee is a class.
CIRGen now records both facts from the AST in two new InitCatchKind values,
reference_to_pointer and reference_to_record_pointer. The Itanium EH
lowering switches on the kind alone, the way classic codegen does.
Assisted-by: Claude Code / Claude Opus 5.5
[AMDGPU] Account for gfx950 permlane hazards during scheduling (#229517)
The [CDNA4 ISA Reference Guide, §4.5, Table 11, p.
21](https://www.amd.com/content/dam/amd/en/documents/instinct-tech-docs/instruction-set-architectures/amd-instinct-cdna4-instruction-set-architecture.pdf#page=29)
requires 2 wait states between a VALU writing a VGPR and a permlane
reading it, and 4 between a `VCMPX` writing EXEC and a permlane. As far
as I know, this is GFX950 specific.
Right now the gfx950 scheduler does not query this existing hazard
check, so final hazard processing can insert avoidable `nop`s despite
available independent instructions.
This patch expose the existing permlane hazard check in
`getHazardType()`.
Also add MIR coverage for source dependencies, unrelated writes,
available fillers, and VCMPX scheduling boundaries.
Partially addresses: #228816
RuntimeLibcallsEmitter: Handle calling conv in per-library functions (#223760)
Pull handling of the default calling convention into the
setAvailableLibFuncs_<name> functions, so the library logic will be
fully contained.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[libc] Use sighandler_t typedef in public headers for all platforms. (#229508)
`signal` function from ANSI C takes an argument and returns value of
type `typeof(void(int))`.
While not strictly necessary, some libc implementations provide their
own convenience typedef for the signal handler type. LLVM-libc used
`sighandler_t` previously, but only on Linux systems. This change makes
this typedef used on other systems as well, the reasons being:
* convenience for the user code, which can rely on this typedef in the
signal-handling code;
* ability to fix a gross hdrgen workaround (YAML configs and
hdrgen-based generation doesn't really support a C-style syntax for
functions-returning-function-pointers)
* ability to fix a **bug** in the generated header - `__NOEXCEPT` suffix
is translated into `noexcept` in the C++ mode, with this qualifier
applied to the _returned function pointer type_ instead of the `signal`
function itself. The "proper" way to use noexcept would be to move it
[5 lines not shown]
[X86] Mark .lrodata for non-mergeable constants with SHF_X86_64_LARGE (#229279)
Under the large code model, a constant pool entry that is not mergeable
(a size other than 4, 8, 16 or 32 bytes, such as a 64-byte AVX-512
vector) is placed in .lrodata without SHF_X86_64_LARGE. Sections are
uniqued by name, so a large global emitted into .lrodata later in the
same module ends up in that unflagged section.
Assisted-By: Claude Opus 5.5
[flang] Add dummy intent attribute to the function signature (#229237)
Dummy intent is currently only on fir.declare in the callee body. A
function pass must not read that body, and a func.func private
declaration has no intent.
Lowering now adds `fir.fortran_attrs = #fir.var_attrs<intent_*>` to each
`func.func` argument that has an intent, including caller-created
declarations. Alias analysis reads that attribute, so an intent(out)
dummy is a write without the callee body.
The call no longer looks inside the callee. Intent is read only from the
func.func argument attribute fir.fortran_attrs, and the dummy type comes
from the function type.
[HLSL] Compatibility overloads for scalar min/max (#222746)
A lot of shaders fail with ambiguous overloads using int and float
together in min or max calls. This just adds the usual compatibility
overload with the usual warning for those including testing
[clang][Driver] Support Trailing Comments in Config Files (#213765)
Before this change, if users put trailing comments into a config file,
these would be added verbatim as processed arguments.
This change ensures that trailing comments after flags are not added to
the processed arguments. This means that comments in config files work
more closely to how comments in unix shell scripts work.
This change is only applied to config files (i.e. from `--config=file`),
and not GNU response files (i.e. from `@file`).
Co-authored-by: Fangrui Song <i at maskray.me>
[flang][OpenMP] Switch clause verification to descriptor-based
Delete all the scattered pieces of clause verification that are now
replaced by the unified handling.
[LV] Add tests for uniform inner loops in outer-loop path (NFC) (#227415)
Add tests for outer-loop vectorization, where the inner loop is uniform:
every lane computes the same inner latch condition.
Since #199632, the legality check accepts an inner-loop latch whose
condition is an icmp with both operands SCEV loop-uniform in the outer
loop. These tests document that new behaviour.