[flang][HLFIR] make copyin/copyout allocation inline (#224063)
This patch moves most allocations of copyin/copyout to the compiler so
that small buffers can be stack allocated, even when the loops are not
inlined. The main motivation is to allow better memory management when
the code ends-up in device region, but this also benefits CPU by giving
more control over allocations.
In the future, we may just consider inlining everything including
copyout, but very early attempts to do so showed that this increased WRF
compile times significantly at O2 for no benefits. Plus, I rather keep
the copy-out inside the runtime only while @eugeneepshteyn is working on
making it "copy on change".
Hence this patch just moves to use `ShallowCopyDirect` for the copy-in
and a new `CopyOutAssignDirect` for the copy-out (so that the new copy
on change policy can be integrated) for non assumed-rank non polymorphic
copy-in/copy-out, and does the allocation inline for the buffer
following the same rules as in `inlineHLFIRCopyin` (i.e. small buffers
[7 lines not shown]
[FastISel] Give PHI incoming materializations a debug location (#223677)
When a block only sets up a successor's PHI nodes before falling
through, nothing follows those materializations for flushLocalValueMap
to take a location from, so the loop's line got its first is_stmt entry
inside the header, which is also the back edge target. Use the
terminator's location instead (which branches to the PHI).
The motivation is to fix
https://github.com/llvm/llvm-project/issues/202065 where
compiler generated loops for Fortran array expressions caused
breakpoints on the statement to fire at each iteration inside the loop
body instead of once inside the header.
Assisted-by: AI
[ORC] Drive EPCGenericRTDyldMemoryManager via proxies (#224532)
Replace its three callSPSWrapper sites (reserve, initialize, release)
with a SimpleMemoryMapBindings handle, matching the memory manager
already used by EPCGenericJITLinkMemoryManager. Dispatch and callee
errors now arrive on a single channel, so the paired error checks
collapse into one.
ExecutionEngine: Compute the DataLayout from the triple and ABI
Avoid using TargetMachine::createDataLayout, which will eventually be
removed.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[MC] Remove unused pre-created .llvm.callgraph section (#224369)
getCallGraphSection always creates a per-function SHF_LINK_ORDER
section, so the pre-created one is unused. Its only effect is that
hand-written `.section .llvm.callgraph` silently gets
`SHT_LLVM_CALL_GRAPH`, while the same directive within a group (e.g.
`.pushsection .llvm.callgraph,"?"` after a group member) gets
SHT_PROGBITS.
Remove it so that an omitted type gives SHT_PROGBITS in both cases, like
GNU assembler. Specify `%llvm_call_graph` to get SHT_LLVM_CALL_GRAPH.
[BoundsSafety][test] Add late-parsed counted_by type-attribute coverage
New tests exercising the late-parse fill-in mechanism:
- Sema/attr-counted-by-weird-type-positions{,-late-parsed}.c: counted_by
in assorted type positions, nested pointers, and rejection cases.
- Sema/attr-bounds-safety-function-ptr-param.c: attributes on
function-pointer-typed members.
- Modules/ and PCH/ bounds-safety-attributed-type-late-parsed: the
resolved type round-trips through serialization.
- Sema/attr-counted-by-late-parsed-regressions.c: guards against the
double-free on a nested-record decl-spec attribute and the null-count
escape on a free-function parameter.
[BoundsSafety] Create incomplete counted_by types and wire up the refill
Activate late parsing for the counted_by family (counted_by / sized_by and
their _or_null variants) in type-attribute position, under
-fexperimental-late-parse-attributes, on top of the type-attribute handling,
the validation helper and the refill machinery added in the previous commits.
When such an attribute is seen during type construction and its argument
can't be resolved yet, build the CountAttributedType immediately with
getIncompleteCountAttributedType and record it against the enclosing record;
its count expression is filled in at the closing brace via the refill logic.
Because enclosing types refer to the node by pointer, completing it in place
leaves the type chain untouched -- no rebuild, no TypeLoc re-emission.
- Sema::ActOnLateParsedTypeAttr builds the incomplete node; the parser
callback stores it on the LateParsedTypeAttribute and records the
attribute in the record currently being parsed.
Parser::CompleteLateParsedTypeAttributes drains that list at the closing
brace; a nested anonymous record hands its pending attributes up to the
[9 lines not shown]
[BoundsSafety] Handle the counted_by family as a type attribute
counted_by / sized_by (and their _or_null variants) were handled in only one
way: a declaration-position attribute went through handleCountedByAttrField,
which validated it and then patched the field afterwards with
FieldDecl::setType. There was no type-position handling at all.
Build the type during type construction instead, from a single handler that
serves both positions:
- Add HandleCountedByAttrOnType and dispatch the counted_by family to it
from processTypeAttrs, going through the shared
validateBoundsAttrTypeForTypePosition leaf.
- Remove handleCountedByAttrField. Its FieldDecl-based type-shape checks in
Sema::CheckCountedByAttrOnField are superseded by
Sema::ValidateBoundsAttrTypeShape, added in the previous commit and now
reached from the type path, and are deleted; no diagnostic is dropped. The
checks that genuinely need the FieldDecl (union member, non-flexible
array, cross-struct count) stay in CheckCountedByAttrOnField and run from
[11 lines not shown]
18311 format: enable smatch
Reviewed by: Gordon Ross <Gordon.W.Ross at gmail.com>
Reviewed by: Andy Fiddaman <illumos at fiddaman.net>
Approved by: Dan McDonald <danmcd at oxide.computer>
[AMDGPU] Fold 24 bit multiply with zero low bits
Fold `MUL_I24` and `MUL_U24` to zero when either operand has known zero
low 24 bits.
For example:
```
llvm.amdgcn.mul.i24(x, 0x01000000) -> 0
```