CodeGen: Maintain the dominator tree in MachinePipeliner
LiveIntervals computes live ranges using the dominator tree, but the
modulo schedule expanders change the CFG without updating
it. Intervals computed later in the pass therefore see a tree missing
the new prolog, kernel and epilog blocks. This is latent today, but
reachability. The unregistered blocks would be incorrectly treated as
unreachable.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[clang][CodeGen] Fix missing terminator when a new-expression initializer starts with a loop (#230902)
Fixes #175427
`EmitCXXNewExpr` marks the point where the operator delete cleanup
becomes active with a placeholder `unreachable` and erases it once the
initializer is emitted. If the initializer starts with a loop or a
label, `EmitBlock` takes that terminator as the end of the block and
emits no fall-through branch, so erasing the placeholder leaves the
block unterminated and valid code fails with "Broken module found".
The marker only has to be an instruction that the deactivation can
insert a store before, while the rest of CodeGen assumes the current
block has no terminator until a real one is written. The placeholder is
now the `i1` load from null that the other cleanup markers already use,
so the block stays open and `EmitBlock` branches normally. The same
marker in `EmitDelegateCallArg` is switched for consistency.
LLM tools were used for this contribution.
[VPlan] Replace first lane for single-scalars in replicateByVF. (#237472)
If DefR is a single scalar, all lanes are equal and all scalar users can
use lane 0.
This fixes a crash due when trying to match an extract from a
single-scalar.
Fixes https://github.com/llvm/llvm-project/issues/237456
[RISCV][P-ext] Add isel pattern for maccu.w01/maccu.w11 (#237122)
`maccu.w01` multiplies the zero-extended lower word of rs1 by the
zero-extended upper word of rs2 and adds the product to rd. `maccu.w11`
does the same with the zero-extended upper words of both. Both are
RV64 only.
Previously, (srl X, 32) was selected as a separate srli feeding
`maccu.w00`. Match it directly so the shift is folded. As with
`maccu.w00`, the patterns require the multiply to have a single use.
[Clang][OpenMP] Fix crash on failed type substitution in declare reduction/mapper (#230059)
Fixes #223366
`VisitOMPDeclareReductionDecl` passed the substituted reduction type to
`ActOnOpenMPDeclareReductionType` without checking it, so a failed
substitution (null type) hit `assert(ParsedType.isUsable())`.
`-fms-compatibility` is not needed: `typename T::type` with `T = int`
crashes too. `declare mapper` had the same bug.
Both visitors now return early when the substituted type is null. The
error is already reported by `SubstType`.
I used AI tools for assistance!
RuntimeLibcalls: Add signatures for more runtime functions
Add type missing signatures for assorted functions which were missing
type information.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Use the correct target C long width for Long
Long and ULong were mapped to the int width, which is wrong on LP64
targets (e.g. scalbln was declared taking i32 on x86_64 linux) and on
16-bit targets where long is 32 bits.
Also fix strtoul, strtoull, and the unsigned long operator new/delete
variants to use the unsigned types.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add signext/zeroext attributes to libcall signatures
Try to match TargetLibraryInfo's behavior. Integer types narrower than
int are extended according to their signedness.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[clang][DepScan] Introduce API to find modulemaps without loading (#235845)
Introduce a way to batch look up the modulemap that defines each of a
set of module names.
`getModuleMapsForModules` builds a compiler instance from the same
command line as a by-name scan, then does every lookup in a separate
header search with lazy modulemap loading turned on and diagnostics
ignored.
* Modulemaps passed with `-fmodule-map-file` are parsed first, all other
modules are resolved by by-name header search.
The main use case is to let the Swift dependency scanner invalidate its
serialized dependency graph without the cost of loading the referenced
modules.
resolves clang side of: rdar://190131044
CodeGen: Maintain the dominator tree in MachinePipeliner
LiveIntervals computes live ranges using the dominator tree, but the
modulo schedule expanders change the CFG without updating
it. Intervals computed later in the pass therefore see a tree missing
the new prolog, kernel and epilog blocks. This is latent today, but
reachability. The unregistered blocks would be incorrectly treated as
unreachable.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang][Semantics] Check copy-out for each consequent-arg separately
CheckExplicitDataArg() runs once for each consequent-arg of a
conditional argument, but it decided whether copy-out is needed from the
whole argument. When the consequent-args differ in contiguity, the whole
argument needs a copy, so a contiguous VOLATILE consequent-arg got the
warning that a temporary copy is required, although passing it on its
own needs no copy.
When the whole argument needs copy-out, ask ActualArgNeedsCopy() again
for the consequent-arg being checked. The whole-argument answer, which
lowering also uses, is still checked first, so the tests for
ActualArgNeedsCopy() keep exercising it.
In ActualArgNeedsCopy(), add a TODO for the INTENT(IN) copy-out
suppression, which doesn't look into the consequent-args of a
conditional argument. Only lowering can observe that gap, and lowering
doesn't support conditional arguments yet.
[8 lines not shown]
Reapply "[LV] Model memory runtime checks for inner loops of loop (#237464)
This reverts commit 7a0edec33d6ae6a00f3b1c276efa4bf152210235 (#237453)
The recommitted version replaces an assertion with proper handling for
VPExpandSCEVRecipe.
They compare equal regardless of ExpandInIR, but if there is a mismatch,
only the one with ExpandInIR=false can be replaced by one with
ExpandInIR=true, not the other way around.
Original message:
Remove the restriction that kept the IR-generated memcheck block for
loops with a parent loop. When hoisting runtime checks, they are
rewritten so they hold across the outer loop and are expanded before the
entry block to the VPlan, using the regular IR expander.
This patch exposes getRuntimeCheckBounds, which does the rewrite, and
marks such rewritten bounds as requiring expansion in IR. VPSCEVExpander
takes a loop as optional argument and uses VPExpandSCEVRecipes for
expressions that are invariant in the loop.
[tsan] Calibrate jmp_buf pointer mangling (#216558)
glibc 2.44 moved the pointer guard out of the TCB and added the
x86-style rotation on other mangling targets. TSan hardcodes the old
guard locations and transformations, so longjmp interception can no
longer recover the saved stack pointer.
Derive the identity, XOR, or XOR-and-rotate scheme from two _setjmp
probes at different stack depths. This supports old and new glibc and
preserves bionic lazy initialization without depending on private guard
storage.
Developed with Fable/Sol. Tested locally on 64-bit Arch Linux, which
already ships glibc 2.44. Without this change, eight existing TSan tests
fail with `ThreadSanitizer: can't find longjmp buf`; with it, the full
`check-tsan` suite passes.
Fixes #216004.
[Matrix] Create the copy alloca once in getNonAliasingPointer (NFC). (#237455)
Both the different address space path and the runtime alias check path
create the same alloca in the entry block. Create it once up front.
[KnownFPClass][NFC] Apply denormal modes inside KnownFPClass functions (#237084)
Converts remaining `KnownFPClass` functions over to the
`applyInputDenormalMode` and `applyOutputDenormalMode` helpers. This
also switches `isKnownNeverLogicalZero(Mode)` to `isKnownNever(fcZero)`.
`KnownFPClass::canonicalize` will be handled in a separate PR.
[KnownFPClass] Rule out non-zero finite results for fmul and fdiv (#231052)
Follow up to https://github.com/llvm/llvm-project/pull/229638
A normal or subnormal result of `fmul`/`fdiv` requires both operands to
be non-zero finite values. In other words, we don't care if either side
could be zero, inf, or NaN when ruling out normal/subnormal values.
Revert "[LV] Model memory runtime checks for inner loops of loop nests in VPlan." (#237453)
Reverts llvm/llvm-project#232794
Breaks bots, see llvm/llvm-project#232794.