[CIR] Fix a crash when source location is unknown (#185059)
When we call `getLoc()` with an invalid `SourceLocation` and
`currSrcLoc` is also invalid, we were crashing or asserting. I tracked
down one case where this was happening (generating an argument in a
vtable thunk) and fixed that to provide a location. I also am updating
the `getLoc()` implementation so that it will use an unknown location in
release builds rather than crashing because the location isn't critical
for correct compilation.
[CIR] Add MLIR ABI Lowering design document
Design document for MLIR dialect-agnostic calling convention
lowering that builds on the LLVM ABI Lowering Library
(llvm/lib/ABI/) as the single source of truth for ABI
classification. Dialects use the library via an adapter layer:
ABITypeMapper maps dialect types to abi::Type*, the library
classifies arguments and returns, and a dialect-specific
ABIRewriteContext applies the decisions back to IR operations.
Targets x86_64 and AArch64, with parity against Classic Clang
CodeGen validated through differential testing.
[clang-doc] Fix benchmark not compiling (#185065)
CI didn't flag that the benchmark was using the outdated Ctx call
when landing the Mustache MD patch since this benchmark isn't tested.
Also added missing libraries in CMake that prevented me from building
the benchmark locally.
[AMDGPU] fix asyncmark soft waitcnt bug (#184851)
Asyncmarks record the current wait state and so should not allow waitcnts that occur after them to be merged into waitcnts that occur before.
[clang][CodeGen] Fix size calculation in vbptr split memory region in EmitNullBaseClassInitialization (#184558)
When splitting memory stores around multiple virtual base pointers
(vbptrs)
in the Microsoft ABI, the calculation for the size of the memory region
after
each vbptr was incorrect.
The bug/old calculation: SplitAfterSize = LastStoreSize -
SplitAfterOffset
This subtracts an absolute offset from a relative size, causing
incorrect (too small) sizes after the second vbptr.
The correct size should be:
SplitAfterSize = (LastStoreOffset + LastStoreSize) - SplitAfterOffset
Since all store regions extend to the end of the non-virtual portion
(NVSize),
this patch uses the simplified form:
[3 lines not shown]
builtins: adjust FP80 source management (#183871)
We would previously include the FP80 sources into the Windows build if
we built with the GNU driver rather than the `cl` driver.
[AArch64][PAC] Emit `!dbg` locations in `*_vfpthunk_` functions (#179688)
The usage of pointers to member functions with Pointer Authentication
requires generation of `*_vfpthunk_` functions. These thunk functions
can be later inlined and optimized by replacing the indirect call
instruction with a direct one and then inlining that function call.
In absence of `!dbg` metadata attached to the original call instruction,
such inlining ultimately results in an assertion "!dbg attachment points
at wrong subprogram for function" in the assertions-enabled builds. By
manually executing `opt` with `-verify-each` option on the LLVM IR
produced by the frontend, an actual issue can be observed: "inlinable
function call in a function with debug info must have a !dbg location"
after the replacement of indirect call instruction with the direct one
takes place.
This commit fixes the issue by attaching artificial `!dbg` locations to
the original call instruction (as well as most other instructions in
`*_vfpthunk_` function) the same way it is done for other
[3 lines not shown]
[clang][diagnostics] Stable IDs for Clang diagnostics (#168153)
Part of the implementation of [[RFC] Emitting Auditable SARIF Logs from
Clang](https://discourse.llvm.org/t/rfc-emitting-auditable-sarif-logs-from-clang/88624)
SARIF diagnostics require that each rule have a stable `id` property to
identify that rule across runs, even when the compiler or analysis tool
has changed. We were previously setting the `id` property to the numeric
value of the enum value for that diagnostic within the Clang
implementation; this value changes whenever an unrelated diagnostic is
inserted or removed earlier in the list.
This change sets the `id` property to the _text_ of that same enum
value. This value would only change if someone renames the enum value
for that diagnostic, which should happen much less frequently than
renumbering.
For now, we will just assume that renaming happens infrequently enough
that existing consumers of SARIF will not notice. In the future, we
[32 lines not shown]
[clang-repl] Create virtual files for `input_line_N` buffers (#182044)
Instead of using memory buffers without file backing, this patch
`input_line_N` buffers as virtual files.
This patch enables us to use input line numbers when verifying tests
`clang-repl`.
Co-authored-by: Vassil Vassilev <v.g.vassilev at gmail.com>
(cherry picked from commit 9cc0df99de853a3cdf778c0c33e4fb5050c46c5b)
[Hexagon] Avoid contracting predicates in createHvxPrefixPred (#183081)
The function createHvxPrefixPred should only need to expand a predicate
to match the result's bytes-per-bit. Otherwise, contracting of the
predicate may lead to an input that is shorter than 4 bytes, making it
unsuitable for VINSERTW0.
When calling createHvxPrefixPred for vector concatention, re-group the
inputs to the concat to make sure that the resulting inputs to
createHvxPrefixPred would not need contraction.
Fixes https://github.com/llvm/llvm-project/issues/181362
[Clang] Fix invalid sret addrspacecast for placement new on HIP (#183639)
When a HIP kernel uses placement new with a function returning an
aggregate via sret (e.g. `new (out) T(make_t())`), and the placement
destination is in global memory (addrspace 1), the sret pointer was
addrspacecast'd to addrspace 5 (private), producing an invalid pointer
that faults at runtime.
Instead of casting the caller's pointer directly, materialise a
temporary alloca in the callee's expected address space, pass that as
the sret argument, and copy the result back to the original destination
after the call.
[CIR] Fix array constant initialization with trailing zeros (#184933)
If an array is explicitly initialized with more than eight non-zero
values followed by a number of explicit zero initializers, CIR generates
a constant record initializer with a constant array that is declared as
the size of the non-zero initializers but with the explicit zero
initializers included in the array initialization attribute. This
resulted in an error when we tried to lower that attribute to LLVM IR.
This patch fixes that problem and adds a verifier to ConstantArrayAttr
to check for that condition.