[clang][StaticAnalysis] Fix an false negative bug in handling '__builtin*overflow' (#214553)
For a binary operation 'A op B' and a result type 'T', these builtins
return true/false for whether the operation's result is a value 'T'
cannot hold. CSA models this by computing the operation's result in a
temporary type and comparing it against the bounds of 'T'. However, the
temporary type is only twice as wide as 'T', not the operands. When
either operand is wider than 'T's doubled width, the result of 'A op B'
can silently wrap around before the comparison, producing a false
negative.
The solution is to find the proper type to temporarily hold the result
of 'A op B' from types of 'A' and 'B'.
rdar://184263112
---------
Co-authored-by: Balázs Benics <benicsbalazs at gmail.com>
[flang][semantic] Implement semantic checks and new data structure for explicit-shape-bounds-spec (#203030)
Since Lower and large parts of Semantics depend on ShapeSpec being a scalar bound, implement a class RankOneBoundElement that does just this. Since there is no syntactic representation for this node kind, have both unparse.cpp and mod-file.cpp emit the original rank-1 integer array expression instead of scalarized versions.
Analyze does semantic checks, then repackages into an array of scalarized ShapeSpec pairs instead of a pair of arrays.
Lower implementation in follow-up stack PR.
Also, fix pre-existing bug where overriding dimension spec in entity-decl throws away and fails to type check the array-spec provided in dimension spec.
[CIR] Implement alwaysinline/noinline on call sites (#214789)
When these appear in an AttributedStmt, we have to annotate the call
with these attributes. This patch implements them for all of the
CallOpInterface types.
[LLVMCAS] libCASPluginTest should link libpthread (#214847)
Fix ppc build after #213331. libCASPluginTest should link libpthread
since the mock implementation uses a threadpool.
Revert "[AMDGPU] Reschedule loads in clauses to improve throughput" (#214836)
Reverts llvm/llvm-project#102595
we are seeing downstream breaks hpc2021 519 535 accel2023 453 460
aborts on device.
will work on a reproducer later today, and send to you, its fortran, you
will enjoy it
ARM TableGen Update (#208380)
- This PR replaces existing ARM builtin functions with TableGen.
- The `.td` file returns identical header names & type signatures as the
`.def` generated headers and types
- The change has been tested via the following:
- `check-clang-tablegen`
- `check-clang-sema`
- `check-clang-codegen-arm`
- `check-clang-codegen`
- `clang-check`
- `check-clang`
- None of the above returned errors or warnings
- The translation is mostly done via a translation script written in
Python
- [Link to translation
script](https://github.com/patricklapgar/python_scripts/blob/main/llvm/clang/arm_tablegen_mig.py)
- [Link to translation script test
suite](https://github.com/patricklapgar/python_scripts/blob/main/llvm/clang/test_arm_tablegen_mig.py)
- Disclaimer: Both the translation script and its test suite were made
w/ assistance from AI (IBM Bob)
[lldb] Let callers of GetSharedModule skip symbol locating (NFC) (#214829)
GetSharedModule falls back on the symbol locator plugins when the spec
does not already name a binary it can open, and it does so while holding
the global module list lock. Locating a binary or symbol file can
potentially be quite slow, so we should have the option to opt out of
that, for example, if we already did the search upfront.
[RISCV][NewPM] Add NewPM Codegen Pipeline Skeleton (#213129)
This follows what has been done for other targets. Follow-up commits
will port each pass and add them to this pipeline.
Assisted-by: AI
[mlir][affine] Add optional alignment attribute to affine load/store ops (#214532)
Give `affine.load`, `affine.store`, `affine.vector_load` and
`affine.vector_store` the same optional `alignment` attribute that
`memref.load`/`memref.store` and `vector.load`/`vector.store` already
carry, via the same `AlignmentAttrOpInterface` and `IntValidAlignment`
constraint, and keep it standing where those ops are rebuilt:
- `--lower-affine` forwards the alignment onto the `memref`/`vector`
access it creates (previously it was dropped, since the lowering
rebuilds the access without carrying attributes over).
- The map-composition canonicalizer (`SimplifyAffineOp`) carries the
alignment over when it rebuilds an access with a composed map.
**Motivation.** Without a way to state alignment on the affine ops, a
frontend that raises an under-aligned llvm access through affine and
back must either give up on raising it, or watch the alignment silently
upgrade to the element type's ABI alignment on the way back down. That
upgrade is a miscompile: clang emits `load i128, align 8` for a 16-byte
[19 lines not shown]
clang: Emit "long-double-type" module flag generically (#210819)
Move emission of the "long-double-type" module flag out of PowerPC
and into generic code, so it describes the long double format for all
targets.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
Reland "[Clang] Rebuild lambda captures in default member initializers while skipping body (#196597)"
This relands commit 50f30bedaa81919915049474f4350ef19c36b7ca, which was
reverted in 150aa53d48aa because it crashed CodeGen for lambda
init-captures in default member initializers.
This commit restores the original change unmodified; the crash is fixed
by the following commit, which re-runs the capture's initialization when
rebuilding the default member initializer.
[Clang] Re-run init-capture initialization when rebuilding default member initializers
When a default member initializer containing a lambda is rebuilt at its
point of use (CWG1815/CWG2631 aggregate initialization),
EnsureImmediateInvocationInDefaultArgs::TransformLambdaExpr transformed
each init-capture initializer with TransformInitializer but never
re-performed the capture's initialization.
TransformInitializer lowers an initializer to its syntactic form -- a
stripped source expression for copy-init, a ParenListExpr for
direct-init, or an InitListExpr for list-init -- and expects the
enclosing context to rebuild the initialization against the target
entity. Without that second step the rebuilt closure was left with a
bare capture initializer: CodeGen crashed for a trivially destructible
closure (aggregate-copy of a non-trivially copyable type) and silently
left the capture uninitialized otherwise.
Re-run buildLambdaInitCaptureInitialization on the transformed
initializer, as the canonical TreeTransform::TransformLambdaExpr does, so
[7 lines not shown]
Disable tail mem libcalls in swifterror functions (#214590)
Tail calls in functions with a swifterror parameter aren't supported yet
and there's a guard against this but the same guard is missing in the
memcpy/memmove/memset libcall paths, which caused a miscompile/crash.
Apply this guard in those places.
https://github.com/swiftlang/swift/issues/90477
rdar://181625760
[LifetimeSafety] Fix crash on explicit object member functions (#212154)
`-Wlifetime-safety` crashes on a call to an explicit object member
function whose object parameter is an rvalue reference, when the call
passes at least one further argument:
```c++
struct Foo {
template <typename T>
int get(this Foo &&self, T) { return self.field; }
int field;
};
void call() { Foo().get(0); }
```
`handleMovedArgsInCall` pairs `Args[I]` with `getParamDecl(I - 1)`,
assuming the object argument has no corresponding `ParmVarDecl`. An
explicit object parameter is a `ParmVarDecl`, so the offset misaligned
[11 lines not shown]
[Docs] Fix a DIExpression fragment example (#214839)
Use DW_OP_LLVM_fragment for the source-variable fragment example. The
previous DW_OP_bit_piece form is not valid in LLVM DIExpression metadata
- the other code was changed a bit ago, this is just some documentation
that didn't catch up.
[clang] Compute value dependence for references to structured bindings (#212368)
In some cases, a reference to a structured binding is value-dependent. I
think this has been possible since they were originally defined in
C++17. C++26 makes it easier to trigger issues, though.
CWG 2984 proposes a resolution to this issue, but the proposed
resolution makes a bunch of cases value-dependent where it isn't really
necessary. A comment in the code describes my alternative.
Fixes #211930