528927 Commits

Author SHA1 Message Date
Kai Sasaki
55f254726e
[mlir][math] Rsqrt math expand pass expects static shaped operand (#129006)
Similar to the issue reported in

https://github.com/llvm/llvm-project/pull/128299#pullrequestreview-2636142506,
ExpandMath pattern for rsqrt expects the static shaped operands.
Otherwise, it crashes due to the assertion violation.

See: https://github.com/llvm/llvm-project/pull/128299
2025-02-28 13:37:06 +09:00
Shilei Tian
746d8b0740
[Clang][AMDGPU] Use 32-bit index for SWMMAC builtins (#129101)
Currently, the index of SWMMAC builtins is of type `short`, likely based
on the
assumption that K can only be up to 32, meaning there are only 16
non-zero
elements. However, this is not future-proof. This patch updates all of
them to
`int`.

The intrinsics themselves don't need to be updated since they accept any
integer
type, and in the backend, they are already extended to 32-bit.
Additionally, the
tests already use various kinds of integers.

Partially fixes SWDEV-518183.
2025-02-27 23:28:48 -05:00
Lang Hames
8493467490 [JITLink][AArch64] Ensure that nulls remain null during ptrauth signing.
Signing a null pointer value can, and usually will, result in some high bits
being set, causing null checks to fail. E.g. in

extern void __attribute__((weak_import)) f(void);
void (*p) = &f;

if f is undefined then p should be null (left unsigned).

This patch updates lowerPointer64AuthEdgesToSigningFunction to check for
Pointer64Authenticated edges to null targets. Where found, these edges are
turned into plain Pointer64 edges (which we know from context will write a null
value to the fixup location), and signing instructions for these locations are
omitted from the signing function.
2025-02-28 15:19:41 +11:00
Owen Pan
80f34e2716
[clang-format] Change BracedInitializerIndentWidth to int (#128988)
Fixes #108526
2025-02-27 20:18:02 -08:00
Alexey Samsonov
bafd44bff5
[libc][bazel] Add py_binary rule to build hdrgen. (#129161) 2025-02-27 20:07:04 -08:00
Brian Cain
39c6c8be2f
[libc++] Fix the locale base API on Linux with musl (#128936)
Since `363bfd6090b0 ([libc++] Use the new locale base API on Linux
(#128007), 2025-02-24)`, musl targets will fail to build with errors
due to missing strtoll_l functions.

Co-authored-by: Pirama Arumuga Nainar <pirama@google.com>
2025-02-27 22:49:19 -05:00
Craig Topper
0b5bb12534
[RISCV] Move RISCV vector load/store searchable tables from RISCVISelDAGToDAG.cpp to RISCVBaseInfo.cpp. NFC (#129172)
llvm-mca needs some of them for #128978.

I'm relying on -ffunction-sections and -fdata-sections allowing these to
be stripped from tools that don't need them like llvm-mc.
2025-02-27 19:30:31 -08:00
Craig Topper
81387754c3
[RISCV] Add VL and VTYPE to implicit uses on MC vector instructions that also use FRM (#129130)
We accidentally overwote the VL, VTYPE uses from the base class on any
instruction that also uses FRM.

Not sure why the llvm-mca test changed cycle time.
2025-02-27 19:25:14 -08:00
Helena Kotas
14170b1602
[HLSL] Add HLSLResourceBindingAttr to default constant buffer numeric declarations ($Globals) (#128981)
Translates `register(c#`) annotations on numeric constants in the global
scope to `HLSLResourceBindingAttr`. Applies to scalar, vector and array
constants.

Fixes #128964
2025-02-27 19:04:18 -08:00
Philip Reames
4904728cab
[RISCV][TTI] Add shuffle costing for masked slide lowering (#128537)
This change adds the TTI costing corresponding to the recently added
isMaskedSlidePair lowering for vector shuffles. However, since the
existing costing code hadn't covered either slideup, slidedown, or the
(now removed) isElementRotate, the impact is larger in scope than just
that new lowering.

---------

Co-authored-by: Alexey Bataev <a.bataev@gmx.com>
Co-authored-by: Luke Lau <luke_lau@icloud.com>
2025-02-27 18:58:42 -08:00
Philip Reames
1bd13bceec
[RISCV][TTI] Fix a misuse of the getShuffleCost API [NFC] (#129137)
The getShuffleCost api, in concept, expects to only deal with non-length
changing shuffles. We were failing to extend the mask appropriately
before invoking it. This came up in
https://github.com/llvm/llvm-project/pull/128537 in discussion of a
potential invariant, but is otherwise unrelated.
2025-02-27 18:53:49 -08:00
Lang Hames
1b622a43c4 [ORC] Make callWrapperAsync forwards explicit in ExecutionSession. NFCI.
This change is intended to make the overloads of callWrapperAsync clearer
for clients that only look at the ExecutionSession API.

Previously we forwarded calls to the three callWrapperAsync overloads in
ExecutorProcessControl using one variadic template, but this obscures the
API for clients who only look at ExecutionSession.
2025-02-28 13:25:24 +11:00
sstipano
531c48546d
[AMDGPU][NFC] Move isXDL and isDGEMM to SIInstrInfo. (#129103) 2025-02-28 03:14:51 +01:00
Han-Chung Wang
28d7671471
[mlir] Add two clone methods about encoding to RankedTensorType. (#127709)
There are clone methods for shape and element type, but not for
encodings. The revision adds two clone method to RankedTensorType:
- dropEncoding(): Return a clone of this type without the encoding.
- cloneWithEncoding(Attribute encoding): Return a clone of this type
with the given new encoding and the same shape and element type as this
type.

Signed-off-by: hanhanW <hanhan0912@gmail.com>
2025-02-27 17:59:27 -08:00
Jonas Devlieghere
fb191efa70
[lldb-dap] Adaptor -> Adapter (NFC) (#129110)
Both spellings are considered correct and acceptable, with adapter being
more common in American English. Given that DAP stands for Debug Adapter
Protocol (with an e) let's go with that as the canonical spelling.
2025-02-27 19:56:56 -06:00
GkvJwa
1594fa8e5a
[asan][win] Fix CreateThread leak (#126738)
Fix #126541

Since ```t->Destroy``` cannot be called after ```start_routine```(When
calling standard thread_start in crt)

Intercept `ExitThread` and free the memory created by `VirtualAlloc'
2025-02-28 09:38:08 +08:00
Craig Topper
9e257b0abc [RISCV] Move RISCVVInversePseudosTable from RISCVMCTargetDesc.cpp to RISCVBaseInfo.cpp. NFC
RISCVMCTargetDesc contains the instruction, register, etc. descriptions
from TableGen. Other searchable tables in MCTargetDesc live in RISCVBaseInfo.cpp
2025-02-27 17:24:18 -08:00
KAWASHIMA Takahiro
0e56f6dc3e
[flang][docs][NFC] Fix Markdown /*comments*/ (#129018)
`*` in `/*comments*/` were interpreted as emphasis marks and were not
displayed in https://flang.llvm.org/docs/Extensions.html.
2025-02-28 10:18:37 +09:00
Mikołaj Piróg
6e7f04266c
[X86][AVX10.2] Add comments for the avx10_2convertintrin.h file (#120766)
As in title. I will create a sibling pr with comments to the 512
variant.
2025-02-28 08:29:20 +08:00
Heejin Ahn
da85b2a864
[WebAssembly] Generate __clang_call_terminate for Emscripten EH (#129020)
When an exception thrown ends up calling `std::terminate`, for example,
because an exception is thrown within a `noexcept` function or an
exception is thrown from `__cxa_end_catch` during handling the previous
exception, the libc++abi spec says we are supposed to call
`__cxa_begin_catch` before `std::terminate`:
https://libcxxabi.llvm.org/spec.html
> When the personality routine encounters a termination condition, it
will call `__cxa_begin_catch()` to mark the exception as handled and
then call `terminate()`, which shall not return to its caller.

The default Itanium ABI generates a call to `__clang_call_terminate()`,
which is a function that calls `__cxa_begin_catch` and then
`std::terminate`:
```ll
define void @__clang_call_terminate(ptr noundef %0) {
  %2 = call ptr @__cxa_begin_catch(ptr %0)
  call void @_ZSt9terminatev()
  unreachable
}
```

But we replaced this with just a call to `std::terminate` in
561abd83ff
because this caused some tricky transformation problems for Wasm EH. The
detailed explanation why is in the commit description, but the summary
is for Wasm EH it needed a `try` with both `catch` and `catch_all` and
it was tricky to deal with.

But that commit replaced `__clang_call_terminate` with `std::terminate`
for all Wasm programs and not only the ones that use Wasm EH. So
Emscripten EH was also affected by that commit. Emscripten EH is not
able to catch foreign exceptions anyway, so this is unnecessary
compromise.

This makes we use `__clang_call_terminate` as in the default Itanium EH
for Emscripten EH. We may later fix Wasm EH too but that requires more
efforts in the backend.

Related issue:
https://github.com/emscripten-core/emscripten/issues/23720
2025-02-27 16:23:18 -08:00
Peter Klausler
51dc52631c
[flang] Catch more defined I/O conflicts (#129115)
The code that checks for conflicts between type-bound defined I/O
generic procedures and non-type-bound defined I/O interfaces only works
when then procedures are defined in the same module as subroutines. It
doesn't catch conflicts when either are external procedures, procedure
pointers, dummy procedures, &c. Extend the checking to cover those cases
as well.

Fixes https://github.com/llvm/llvm-project/issues/128752.
2025-02-27 16:16:34 -08:00
Peter Klausler
abe1ecff54
[flang][runtime] Detect byte order reversal problems (#129093)
When reading an unformatted sequential file with variable-length
records, detect byte order reversal problems with the first record's
header and footer words, and emit a more detailed error message.
2025-02-27 16:16:15 -08:00
YongKang Zhu
5401c675eb
[BOLT][instr] Avoid WX segment (#128982)
BOLT instrumented binary today has a readable (R), writeable (W) and also
executable (X) segment, which Android system won't load due to its WX
attribute. Such RWX segment was produced because BOLT has a two step linking,
first for everything in the updated or rewritten input binary and next for
runtime library. Each linking will layout sections in the order of RX sections
followed by RO sections and then followed by RW sections. So we could end up
having a RW section `.bolt.instr.counters` surrounded by a number of RO and RX
sections, and a new text segment was then formed by including all RX sections
which includes the RW section in the middle, and hence the RWX segment. One
way to fix this is to separate the RW `.bolt.instr.counters` section into its
own segment by a). assigning the starting addresses for section
`.bolt.instr.counters` and its following section with regular page aligned
addresses and b). creating two extra program headers accordingly.
2025-02-27 16:13:57 -08:00
Min-Yih Hsu
30d7e21e4c [MCA][RISCV] Mark one of the internal CustomBehavior functions static. NFC
This function is only used in the same file.
2025-02-27 16:07:52 -08:00
Alex MacLean
85f8bd111f
[NVPTX] Combine addressing-mode variants of ld, st, wmma (#129102)
This change fold together the _ari, _ari64, and _asi variants of these
instructions into a single instruction capable of holding any address.
This allows for the removal of a lot of unnecessary code and moves us
towards a standard way of representing an address in NVPTX.
2025-02-27 16:05:30 -08:00
Peter Collingbourne
0ebf7b473a
IR, CodeGen: Add command line flags for dumping instruction addresses and debug locations.
As previously discussed [1], it is sometimes useful to be able to see
instruction addresses and debug locations as part of IR dumps. The
same applies to MachineInstrs which already dump debug locations but
not addresses. Therefore add some flags that can be used to enable
dumping of this information.

[1] https://discourse.llvm.org/t/small-improvement-to-llvm-debugging-experience/79914

Reviewers: rnk

Reviewed By: rnk

Pull Request: https://github.com/llvm/llvm-project/pull/127944
2025-02-27 15:45:55 -08:00
weiguozhi
11e65b98b3
[JumpThreading] Remove deleted BB from Unreachable (#126984)
Although an unreachable BB is skipped by processBlock, its successor can
still be handled by processBlock, and maybeMergeBasicBlockIntoOnlyPred
may merge the two BBs and delete the unreachable BB. Then the garbage
pointer is left in Unreachable set. This patch avoids merging a BB into 
unreachable predecessor.
2025-02-27 15:40:21 -08:00
Craig Topper
63ecb0135d [RISCV] Reduce dynamic relocations for RISCVOpcodesList table. NFC
Inline the strings directly into the table instead of storing a pointer.
Similar to what was done for other searchable tables in the last couple
months.
2025-02-27 14:59:55 -08:00
Craig Topper
f3b18491e8
[RISCV] Consolidate some DecoderNamespaces for standard extensions. (#128954)
First thing to know is that the subtarget feature checks used to block
accessing a decoder table are only a performance optimization and not
required for functionality. The tables have their own predicate checks.
I've removed them from all the standard extension tables.

-RV32 Zacas decoder namespace has been renamed to RV32GPRPair, I think
Zilsd(rv32 load/store pair) can go in here too.
-The RV32 Zdinx table has been renamed to also use RV32GPRPair.
-The Zfinx table has been renamed to remove superflous "RV" prefix.
-Zcmp and Zcmt tables have been combined into a ZcOverlap table. I think
 Zclsd(rv32 compressed load/store pair) can go in here too.
-All the extra standard extension tables are checked after the main
 standard extension table. This makes the common case of the main table
 matching occur earlier.
-Zicfiss is the exception to this as it needs to be checked before
 the main table since it overrides some encodings from Zcmop. This
can't be handled by a predicate based priority as Zicfiss only overrides
 a subset of Zcmop encodings.
2025-02-27 14:56:54 -08:00
Kazu Hirata
44c6616a4a [flang] Fix a warning
This patch fixes:

  flang/lib/Semantics/check-declarations.cpp:2009:15: error: unused
  variable 'kind' [-Werror,-Wunused-variable]
2025-02-27 14:48:13 -08:00
Peter Klausler
cbef629838
[flang] Catch type-bound generic with inherited indistinguishable spe… (#128980)
…cific

When checking generic procedures for indistinguishable specific
procedures, don't neglect to include specific procedures from any
accessible instance of the generic procedure inherited from its parent
type..

Fixes https://github.com/llvm/llvm-project/issues/128760.
2025-02-27 14:33:11 -08:00
Peter Klausler
c6dd9f4278
[flang] Catch usage of : and * lengths in array c'tors (#128974)
The definition of an array constructor doesn't preclude the use of
[character(:)::] or [character(*)::] directly, but there is language
elsewhere in the standard that restricts their use to specific contexts,
neither of which include explicitly typed array constructors.

Fixes https://github.com/llvm/llvm-project/issues/128755.
2025-02-27 14:32:50 -08:00
Peter Klausler
78acf7bb0a
[flang] Enforce C1503 (#128962)
Enforce an obscure constraint from the standard: an abstract interface
is not allowed to have the same name as an intrinsic type keyword. I
suspect this is meant to prevent a declaration like "PROCEDURE(REAL),
POINTER :: P" from being ambiguous.

Fixes https://github.com/llvm/llvm-project/issues/128744.
2025-02-27 14:32:30 -08:00
Peter Klausler
e843d514b1
[flang] Refine handling of SELECT TYPE associations in analyses (#128935)
A few bits of semantic checking need a variant of the
ResolveAssociations utility function that stops when hitting a construct
entity for a type or class guard. This is necessary for cases like the
bug below where the analysis is concerned with the type of the name in
context, rather than its shape or storage or whatever. So add a flag to
ResolveAssociations and GetAssociationRoot to make this happen, and use
it at the appropriate call sites.

Fixes https://github.com/llvm/llvm-project/issues/128608.
2025-02-27 14:32:12 -08:00
Peter Klausler
523537f0c9
[flang] Silence spurious error (#128777)
When checking for conflicts between type-bound generic defined I/O
procedures and non-type-bound defined I/O generic interfaces, don't
worry about conflicts where the type-bound generic interface is
inaccessible in the scope around the non-type-bound interface.

Fixes https://github.com/llvm/llvm-project/issues/126797.
2025-02-27 14:31:50 -08:00
Peter Klausler
8b7a90b84b
[flang] Accept proc ptr function result as actual argument without IN… (#128771)
…TENT

A dummy procedure pointer with no INTENT attribute may associate with an
actual argument that is the result of a reference to a function that
returns a procedure pointer, we think.

Fixes https://github.com/llvm/llvm-project/issues/126950.
2025-02-27 14:31:24 -08:00
Peter Klausler
e1ba1be787
[flang] Account for accessibility in extensibility check (#128765)
A derived type with a component of the same name as the type is not
extensible... unless the extension occurs in another module where the
conflicting component is inaccessible.

Fixes https://github.com/llvm/llvm-project/issues/126114.
2025-02-27 14:30:55 -08:00
Peter Klausler
161d002a09
[flang] Silence warnings from hermetic module files (#128763)
Modules read from module files must have their symbols tagged with the
ModFile flag to suppress all warnings messages that might be emitted for
their contents. (Actionable warnings will have been emitted when the
modules were originally compiled, so we don't want to repeat them later
when the modules are USE'd.) The module symbols of the additional
modules in hermetic module files were not being tagged with that flag;
fix.
2025-02-27 14:29:35 -08:00
Peter Klausler
fce29486ac
[flang] Fix bogus error on defined I/O procedure. (#125898)
The check that "v_list" be deferred shape is just wrong; there are no
deferred shape non-pointer non-allocatable dummy arguments in Fortran.
Correct to check for an assumed shape dummy argument. And de-split the
error messages that were split across multiple source lines, making them
much harder to find with grep.

Fixes https://github.com/llvm/llvm-project/issues/125878.
2025-02-27 14:29:00 -08:00
Peter Klausler
3e3855b0e5
[flang] Don't flag CLASS(*) ASSOCIATED() pointer or target as error (#125890)
As I read the standard, an unlimited polymorphic pointer or target
should be viewed as compatible with any data target or data pointer when
used in the two-argument form of the intrinsic function ASSOCIATED().

Fixes https://github.com/llvm/llvm-project/issues/125774.
2025-02-27 14:28:34 -08:00
Peter Klausler
29025a0600
[flang] Catch more semantic errors with coarrays (#125536)
Detect and report a bunch of uncaught semantic errors with coarray
declarations. Add more tests, and clean up bad usage in existing tests.
2025-02-27 14:28:08 -08:00
Peter Klausler
a21089a24b
[flang] Support COSHAPE() intrinsic function (#125286)
Enable COSHAPE in the intrinsics table and enable its test.
2025-02-27 14:27:46 -08:00
Peter Klausler
9a49a03dc9
[flang] Refine handling of NULL() actual to non-optional allocatable … (#116126)
…dummy

We presently allow a NULL() actual argument to associate with a
non-optional dummy allocatable argument only under INTENT(IN). This is
too strict, as it precludes the case of a dummy argument with default
intent. Continue to require that the actual argument be definable under
INTENT(OUT) and INTENT(IN OUT), and (contra XLF) interpret NULL() as
being an expression, not a definable variable, even when it is given an
allocatable MOLD.

Fixes https://github.com/llvm/llvm-project/issues/115984.
2025-02-27 14:27:19 -08:00
vporpo
4fcab8a587
[SandboxIR][Region][NFC] Fix windows build issue (#129082)
This should fix the issue reported here:

https://discourse.llvm.org/t/second-stage-of-build-on-windows-fails-in-sandboxir/84841
2025-02-27 14:25:06 -08:00
Andy Kaylor
3989b78fa9
[CIR] Upstream basic alloca and load support (#128792)
This change implements basic support in ClangIR for local variables
using the cir.alloca and cir.load operations.
2025-02-27 14:22:26 -08:00
Jonas Paulsson
72e00d628d
[SystemZ] Handle scalar to vector bitcasts. (#128628)
CSmith found a case where SROA produces bitcasts from scalar to vector.
This was previously asserted against in SystemZTTI, but now the BaseT
implementation takes care of it.
2025-02-27 23:16:30 +01:00
vporpo
32bcc9f0d3
[SandboxVec] Add option -sbvec-allow-file for bisection debugging (#129127)
This new option lets you specify an allow-list of source files and
disables vectorization if the IR is not in the list. This can be used
for debugging miscompiles.
2025-02-27 14:15:04 -08:00
Florian Mayer
db4dd333d0
[NFC] [clang] [sanitize] add autogen test for array-bounds debuginfo (#128976) 2025-02-27 14:00:15 -08:00
Nikolas Klauser
f896bd3670
[libc++] Diagnose when nullptrs are passed to string APIs (#122790)
This allows catching misuses of APIs that take a pointer to a
null-terminated string.
2025-02-27 22:57:19 +01:00
Nikolas Klauser
28851edf16
[libc++] Silence CMake's install messages in the CI (#128872)
Currently, there are a ton of `-- Installing:` and `-- Up-to-date:`
messages in the CI log, which just clutter the output. This disables
these messages to significantly shorten the CI logs, making them much
faster to load and easier to read.
2025-02-27 22:56:28 +01:00