[CIR] Lower constant NTTP objects (#194496)
Like my previous patch, this just stores an NTTP object as a global
(using the same code, with 1 level of indrection slipped off), and
initializes it as a const. This patch also fleshes out the
CIRGenExprConstant.cpp area, leaving just 2 'NYI's in the area, 1 of
which is the MSGuidAttr again.
[clang][modules-driver] Fix failing import-std regression test (#194502)
See
https://github.com/llvm/llvm-project/pull/194475#issuecomment-4331347690.
This constrains the test to not run on aarch64, where it fails on
`clang-aarch64-quick` and `llvm-clang-aarch64-darwin` builders.
The failing builders don't show any output, and the test will be
re-enabled for aarch64 in a later follow-up.
Co-authored-by: Naveen Seth Hanig <naveen.hanig at oulook.com>
[DataLayout] Add null pointer value infrastructure
Add support for specifying the null pointer bit representation per address space
in DataLayout via new pointer spec flags:
- 'z': null pointer is all-zeros
- 'o': null pointer is all-ones
When neither flag is present, the address space inherits the default set by the
new 'N<null-value>' top-level specifier ('Nz' or 'No'). If that is also absent,
the null pointer value is zero.
No target DataLayout strings are updated in this change. This is pure
infrastructure for a future ConstantPointerNull semantic change to support
targets with non-zero null pointers (e.g. AMDGPU).
Reland "[clang][modules-driver] Add support for C++ named modules and import std" (2nd attempt) (#194475)
This reverts #193857 and relands #193312.
This adds basic support for explicit C++ named module builds, managed
natively by the Clang driver, including support for use of the Standard
library modules. This follows #187606, which adds the same for Clang
modules.
Current limitations:
- Standard library modules are still compiled to object files instead of
using the provided shared library. (This will be addressed in a
follow-up soon.)
- Caching is not supported yet (but likely to be added during the
upcoming GSoC cycle).
- Importing C++ standard library modules into Clang modules is not
supported (and not expected in the near term).
RFC:
https://discourse.llvm.org/t/rfc-modules-support-simple-c-20-modules-use-from-the-clang-driver-without-a-build-system
[CIR] Handle DeclRefExpr's to NTTP Objects (#194482)
NTTP objects are represented as globals so that you can refer to
them/address of them/etc, but most access to them should result in
constant expressions. This patch implements the creation of these
globals, and allows compelation to continue.
This should fix up the last DeclRefExpr LValue that appears other than
MSGuids and named global registers, both of which are specific to
individual attributes.
[InlineSpiller] Fix live-range update in hoisting within bb (#193880)
The InlineSpiller tries to shorten the live-ranges used when storing a
value that is defined by a sibling register by performing the following
transformation:
```
a = copy b
store a
```
=>
```
store b
```
That is, it eliminates the copy and store the original value at the copy
location.
As far as `b`'s live-range is concerned, this transformation is neutral
as long as the store is inserted in place of the copy being removed.
[37 lines not shown]
[PowerPC] Simplify lowering for ldat intrinsics
This change defines 2 new output patterns, `PAIR8` and `EVEN8`,
and uses them to implement the lowering of the intrinsics
`int_ppc_amo_ldat` and `int_ppc_amo_ldat_cond` in TableGen.
As result, the generated instructions are much clearer, and the
C++ code is also simplified.
[asan_abi] Skip new __asan_get_report_* from ABI (#194463)
PR #181446 ("[asan] API for getting multiple pointer ranges") added five
new __asan_get_report_{dealloc,dest,first,second,src}_address entries to
compiler-rt/lib/asan/asan_interface.inc without updating
asan_abi_tbd.txt
or implementing them in compiler-rt/lib/asan_abi/asan_abi.cpp. This
broke
the AddressSanitizerABI-arm64-darwin ::
Darwin/llvm_interface_symbols.cpp
test, which diffs asan_interface.inc (minus asan_abi_tbd.txt) against
the
symbols actually exported by libclang_rt.asan_abi_osx.a.
List the new symbols alongside the existing __asan_get_report_* entries
so the stable-ABI test passes. The symbols remain unimplemented in the
stable ABI library; this change only reflects that they are
intentionally
not part of the stable ABI surface.
[5 lines not shown]
[VectorCombine] reject out-of-bounds extract indexes in foldExtractExtract (#194381)
Fixes #194355
`VectorCombine::foldExtractExtract()` matches any constant-index
`extractelement` operands, but it never verifies that they are in range
for a fixed-width vector.
lldb] Fix two issues causing TestEvents.py flakiness (#194438)
This PR fixes two issues that contribute to `TestEvents.py` being flaky
in CI:
1. `ProcessEventData::DoOnRemoval` runs the full stop-handling logic
(like `ShouldStop` and `RunStopHooks`) every time an event is consumed
from any listener. When the primary listener consumes an event and then
the shadow listener consumes the same event, the logic runs twice. The
second execution can race with subsequent event processing. Fix this by
incrementing `m_update_state` after the first successful run so
secondary listeners skip the full logic.
2. Target::RunStopHooks updates `m_latest_stop_hook_id` (marking a stop
as "handled") before checking whether any threads have stop reasons. If
the check fails and hooks don't run, the stop ID is already consumed,
preventing hooks from ever running for that stop. Fix this by deferring
the update until we're certain we'll actually run hooks.
[CIR] Fix failing tests after bool load change (#194468)
This fixes CIR tests that were failing as a result of the change in how
bool load values are truncated in
https://github.com/llvm/llvm-project/pull/193783
Reland "[llvm-profgen] Add support for ETM trace decoding" (#194465)
This relands commit e3bd61890e68303a33fdd33fbdd9abeda (#191584), which
was reverted in commit
ec9d7d18bdfe21c30c94c02f14f3613f7b69a17b (#194087) due to bot failures
on ppc64le and Windows.
This reland incorporates the following fixes:
1) Rename member variable InputFile to InputFilePath inside struct
InputFile to resolve MSVC shadow
conflicts.
2) Add arm-registered-target to ETM tests REQUIRES directive to prevent
failures on builders that do
not have the ARM target enabled.
[libc][test] Remove non-proxy header in sendmsg_recvmsg_test.cpp (#194467)
The header `include/llvm-libc-macros/linux/sys-socket-macros.h` should
be included via `hdr/sys_socket_macros.h` which proxies based on whether
LIBC_FULL_BUILD is enabled. Else we mix LLVM-libc internal headers and
system headers.
[lldb] Unify python shebangs (#187257)
As per PEP-0394[1], there is no real concensus over what binary names
Python has, specifically 'python' could be Python 3, Python 2, or not
exist.
However, everyone has a python3 interpreter and the scripts are all
written for Python 3. Unify the shebangs so that the ~50% of shebangs
that use python now use python3.
[1] https://peps.python.org/pep-0394/
[GIsel] Add constant-folding for more unary integer ops (#194265)
Generalize ConstantFoldCountOp to ConstantFoldUnaryIntOp including
G_ABS, G_BSWAP, G_BITREVERSE
[Offload][libsycl][clang-sycl-linker] Simplify SYCL Offload wrapping (#193876)
Replace the __sycl_tgt_bin_desc/__sycl_tgt_device_image-based fat binary
registration with a simpler OffloadBinary-native approach:
- __sycl_register_lib/__sycl_unregister_lib now take (BinaryStart, Size)
instead of a __sycl_tgt_bin_desc pointer; __sycl_unregister_lib only
needs BinaryStart since the runtime looks up the binary by its start
address.
- OffloadWrapper's SYCL wrapping is significantly simplified: the
__tgt_bin_desc/__tgt_device_image structs and the descriptor
construction code are replaced by a single embedded OffloadBinary blob
passed directly to the register/unregister entry points.
- clang-sycl-linker generates a single OffloadBinary, which contains
multiple images.
- ProgramAndKernelManager::registerFatBin parses the blob via
OffloadBinary::create, keying MDeviceImageManagers by BinaryStart to
eliminate the reparse on unregister.
- DeviceImageManager owns std::unique_ptr<OffloadBinary> instead of
[8 lines not shown]
[CIR] Eliminate SymbolTable::lookupSymbolIn hotspots (#193362)
mlir::SymbolTable::lookupSymbolIn is O(n) per lookup, so cumulative
symbol lookups during CIRGen are O(n^2) in the number of global symbols.
On template-heavy translation units this becomes a significant
compile-time hotspot.
Replace the SymbolTable lookup path with a per-CIRGenModule DenseMap
cache keyed by symbol name, giving O(1) lookups.
On a synthetic template-heavy stress test, end-to-end compile time on
`clang -fclangir -S -emit-llvm -O0` improves by ~11% on a 33K-LOC input
(5.86s -> 5.21s) and ~16% on a 67K-LOC input (16.09s -> 13.52s). The
super-linear growth of the win with input size confirms the O(n^2) ->
O(n) effect.
Similar to previous compile time fix, repro shape (scale records and
template instantiations into the hundreds/thousands to amplify):
[7 lines not shown]
[VPlan] Pass TTI + CostKind to spillCost instead of CostCtx (NFC) (#194417)
Instead of passing CostContext, directly pass the needed TTI and
CostKind. This makes the function easier to re-use in other places,
without the need of constructing VPCostContext.
Split off from https://github.com/llvm/llvm-project/pull/194267 as
suggested.
[NVPTX] Add reverseBranchCondition and CBranch inverted flag (#191889)
Add flag to `CBranch` instruction for inverted predicate branches (`@!p
bra`) and implement `reverseBranchCondition` to support branch condition
inversion.
This enables passes like branch folding to properly reverse branch
conditions, and is a prerequisite for SETP predicate inversion CSE.
Assisted-by: Cursor / Claude