544965 Commits

Author SHA1 Message Date
Nikita Popov
b0769aa290
[IR] Make intrinsic checks more efficient (NFC) (#148682)
Directly cast the callee operand instead of going through
getCalledFunction(). We can do this because for intrinsics the function
type between the call and the function is guaranteed to match.

This is a minor compile-time improvement as is, but has a much bigger
impact with a future change that makes getCalledFunction() more
expensive.

There is some code duplication between these four uses, but they are
each just different enough that representing one in terms of another
would be less efficient.
2025-07-15 09:30:38 +02:00
Fangrui Song
13d818806d MCFixup: Remove getTargetKind
MCFixupKind is now a type alias (fixup kinds are inherently
target-specific). getTargetKind is no longer necessary.
2025-07-15 00:27:33 -07:00
Matt Arsenault
16798ee7bf
MC: Use reportFatalUsageError for COFF with non-windows (#147911) 2025-07-15 16:27:09 +09:00
Fangrui Song
5ba458c559 MCFixup: Replace getTargetKind with getKind 2025-07-15 00:21:07 -07:00
Matt Arsenault
0991435fc3
RuntimeLibcalls: Mostly move x86 configuration into tablegen (#148575)
This is getting pretty ugly, but seems to be the worst of the
cases. Opting out of the base set of calls for the various windows
cases is really ugly. We need to apply that to the arm cases as well.

It also may make sense to go back to transposing the architecture
and operating system (i.e. make isOSWindows the SystemLibrary
and then modify based on architecture).
2025-07-15 16:18:34 +09:00
Corentin Jabot
acf07dc77c
[Clang] Do not treat Foo -> const Foo conversion sequences as perfect (#148613)
For implicit object arguments.
This fixes a regression introduced by the "perfect match" overload
resolution mechanism introduced in 8c5a307.

Note that GCC allows the ambiguity between a const and non-const
candidate to be resolved. But this patch focuses on restoring the Clang
20 behavior, and to fix the cases which we did resolve incorrectly.

Fixes #147374
2025-07-15 09:18:25 +02:00
Simon Pilgrim
dae72bc659 [X86] freeze-unary.ll - show tests failing to remove freeze from ISD::ABS node
Unlike the abs intrinsic, the ISD::ABS node defines ABS(INT_MIN) -> INT_MIN, not poison is generated
2025-07-15 08:09:30 +01:00
Fangrui Song
0b674f4c52 MCFixup: Replace getTargetKind with getKind
MCFixupKind is now a type alias (fixup kinds are inherently
target-specific). getTargetKind is no longer necessary.
2025-07-15 00:08:45 -07:00
Matt Arsenault
3d50e1f3e8
RuntimeLibcalls: Add some tests for OpenBSD stack protectors (#147888)
7dce16f69dc3e26cb74d5ad38b0648a6f47f9640 removed a libcall for
STACKPROTECTOR_CHECK_FAIL from OpenBSD but added no tests.

Add a basic test copied from RISCV into all the backends on
the OpenBSD page of supported architectures before I potentially
break in in RuntimeLibcalls refactoring.
2025-07-15 15:50:54 +09:00
quic_hchandel
0be51cff91
[RISCV] Add ISel patterns for Qualcomm uC Xqcicli extension (#148121)
Add CodeGen patterns for conditional load immediate instructions
2025-07-15 12:13:57 +05:30
Serge Pavlov
977cfea786
[Analysis] Avoid some warnings about exit from noreturn function (#144408)
Compiler sometimes issues warnings on exit from 'noreturn' functions, in
the code like:

    [[noreturn]] extern void nonreturnable();
    void (*func_ptr)();
    [[noreturn]] void foo() {
      func_ptr = nonreturnable;
      (*func_ptr)();
    }

where exit cannot take place because the function pointer is actually a
pointer to noreturn function.

This change introduces small data analysis that can remove some of the
warnings in the cases when compiler can prove that the set of reaching
definitions consists of noreturn functions only.
2025-07-15 12:56:11 +07:00
Owen Pan
da283b54d9 Revert "[clang-format] Fix an off-by-1 bug with -length option (#143302)"
This reverts commit 1fae5918b3d6fbed8ce6d8a2edf31bdf304ca8db because it may
break VSCode.

Closes #146036
2025-07-14 22:42:12 -07:00
Kazu Hirata
c06d3a7b72
[mlir] Remove unused includes (NFC) (#148769)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-07-14 22:19:23 -07:00
Kazu Hirata
7c83d66719
[llvm] Remove unused includes (NFC) (#148768)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-07-14 22:19:14 -07:00
Kazu Hirata
c8d3e61216
[DWARFCFIChecker] Use llvm::unique (NFC) (#148766)
While I am at it, this patch replaces resize with erase, which is a
lot shorter and idiomatic.
2025-07-14 22:19:07 -07:00
Kazu Hirata
c4450aa96e
[Lanai] Remove unnecessary casts (NFC) (#148765)
getInstrInfo() already returns const LanaiInstrInfo *.

Likewise, getRegisterInfo() already returns const LanaiRegisterInfo *.
2025-07-14 22:19:00 -07:00
Kazu Hirata
a869f7e821
[CodeGen] Remove an unnecessary cast (NFC) (#148764)
getExpression() already returns DIExpression *.
2025-07-14 22:18:51 -07:00
Kazu Hirata
7e7340d276
[AArch64] Remove an unnecessary cast (NFC) (#148763)
OpcA is already of unsigned.
2025-07-14 22:18:44 -07:00
Kazu Hirata
b1a25ce73c
[Sema] Remove unnecessary casts (NFC) (#148762)
getAsmLabel() already returns Expr *.
2025-07-14 22:18:37 -07:00
Kazu Hirata
769bd90f8b [flang] Fix a warning
This patch fixes:

  flang/lib/Lower/ConvertVariable.cpp:787:22: error: unused variable
  'fieldTy' [-Werror,-Wunused-variable]
2025-07-14 22:17:12 -07:00
Craig Topper
028dfd7756 [RISCV] Replace tab character. NFC 2025-07-14 21:53:55 -07:00
Valentin Clement (バレンタイン クレメン)
9e9fdd433a
[flang][cuda] Fix definition of CUFSetAllocatorIndex (#148778) 2025-07-14 21:26:43 -07:00
Craig Topper
9ba45c5c5e [RISCV] Move RISCVDAGToDAGISel::SelectAddrRegRegScale definition later. NFC
This function was placed between some static functions and their
callers. Reorder to keep the related code together.
2025-07-14 21:12:10 -07:00
Sam Elliott
3faaa5cdb0
[RISCV] Fix QC.E.LI -> C.LI with Bare Symbol Compression (#146763)
There's a long comment explaining this approach in RISCVInstrInfoXqci.td

This change also fixes some problems when fixups are able to be resolved for `qc.e.li` and `qc.li`.
2025-07-14 21:00:38 -07:00
Craig Topper
4923313727
[RISCV] Fix typo in comment. NFC (#148754)
'unsigned' was misspelled, but it seemed easier to write uimm9 than to
spell it out.
2025-07-14 20:56:07 -07:00
Craig Topper
31944ac45b
[RISCV] Render P-ext simm10_unsigned as a simm10 after parsing. (#148749)
Instead of allowing a parsed MCInst to have a either uimm10 or simm10,
always render as simm10. This avoids a mismatch between parsed MCInst
and disassembled MCInst when a uimm10 value is used.
2025-07-14 20:55:10 -07:00
Craig Topper
3265a36c55
[RISCV] Refactor RISCVDAGToDAGISel::selectSimm5Shl2. NFC (#148731)
Return from the for loop body instead of using a break and checking the
shift amount after.
2025-07-14 20:54:06 -07:00
Craig Topper
eea5c291bb
[DAGCombiner] Pass SDNodeFlags to getNode instead of modifying nodes. (#148744)
getNode has logic to intersect flags correctly if the new node happens
to CSE with an existing node. Setting node flags after getNode bypasses
this logic and may change the node for other uses where the flags don't
hold.
2025-07-14 20:53:14 -07:00
Craig Topper
9a9db2a39c
[RISCV] Prefix mcpu/mtune/march/mabi with '-' in comments. NFC (#148723) 2025-07-14 20:52:46 -07:00
Matt Arsenault
25b00c033c
AArch64: Fix asserting on unexpected triples (#147880) 2025-07-15 12:47:55 +09:00
Florian Mayer
be200e2b80
[SelectionDAG] improve error message for invalid op bundles (#148722) 2025-07-14 20:41:10 -07:00
Brian Cain
d2bcc51a5a
[LLD] Merge .hexagon.attributes sections (#148098)
Merge the attributes of object files being linked together. The
`.hexagon.attributes` section can be used by loaders and analysis tools.
This is similar to the .riscv.attributes, introduced in
8a900f2438b4a167b98404565ad4da2645cc9330 /
https://reviews.llvm.org/D138550.
2025-07-14 22:36:05 -05:00
Jim Lin
96148f9214 [RISCV] Use cond_code instead for PseudoCCNDS_BFOS and PseudoCCNDS_BFOZ. 2025-07-15 11:19:09 +08:00
Trevor Gross
10b5558b61
[X86] Update the fp128/i128 test to show stack alignment (NFC) (#148753)
Adding an extra argument before a `fp128` only changes the stack offset
by four bytes, while it should instead go in the next 16-aligned slot.
Add a test demonstrating the current behavior.

`no_x86_scrub_sp` is added because offset from the stack pointer is
needed to show the problem.

Relevant issue: https://github.com/llvm/llvm-project/issues/77401
2025-07-15 11:14:25 +08:00
tedwoodward
eb6da944af
[lldb] Improve disassembly of unknown instructions (#145793)
LLDB uses the LLVM disassembler to determine the size of instructions and
to do the actual disassembly. Currently, if the LLVM disassembler can't
disassemble an instruction, LLDB will ignore the instruction size, assume
the instruction size is the minimum size for that device, print no useful
opcode, and print nothing for the instruction.

This patch changes this behavior to separate the instruction size and
"can't disassemble". If the LLVM disassembler knows the size, but can't
dissasemble the instruction, LLDB will use that size. It will print out
the opcode, and will print "<unknown>" for the instruction. This is much
more useful to both a user and a script.

The impetus behind this change is to clean up RISC-V disassembly when
the LLVM disassembler doesn't understand all of the instructions.
RISC-V supports proprietary extensions, where the TD files don't know
about certain instructions, and the disassembler can't disassemble them.
Internal users want to be able to disassemble these instructions.

With llvm-objdump, the solution is to pipe the output of the disassembly
through a filter program. This patch modifies LLDB's disassembly to look
more like llvm-objdump's, and includes an example python script that adds
a command "fdis" that will disassemble, then pipe the output through a
specified filter program. This has been tested with crustfilt, a sample
filter located at https://github.com/quic/crustfilt .

Changes in this PR:
- Decouple "can't disassemble" with "instruction size".
  DisassemblerLLVMC::MCDisasmInstance::GetMCInst now returns a bool for
    valid disassembly, and has the size as an out paramter.
  Use the size even if the disassembly is invalid.
  Disassemble if disassemby is valid.

- Always print out the opcode when -b is specified.
  Previously it wouldn't print out the opcode if it couldn't disassemble.

- Print out RISC-V opcodes the way llvm-objdump does.
  Code for the new Opcode Type eType16_32Tuples by Jason Molenda.

- Print <unknown> for instructions that can't be disassembled, matching
  llvm-objdump, instead of printing nothing.

- Update max riscv32 and riscv64 instruction size to 8.

- Add example "fdis" command script.

- Added disassembly byte test for x86 with known and unknown instructions.
- Added disassembly byte test for riscv32 with known and unknown instructions,
  with and without filtering.
- Added test from Jason Molenda to RISC-V disassembly unit tests.
2025-07-14 21:50:22 -05:00
Connector Switch
91b3dbe273
[libc] Update some implementation status for search.h (#148414)
- `VISIT` was implemented in
https://github.com/llvm/llvm-project/pull/132746.
- `lsearch` was implemented in
https://github.com/llvm/llvm-project/pull/131431.

At first, I thought this would be updated automatically, but it seems
that the header status needs to be added manually.
2025-07-15 10:34:30 +08:00
Oliver Hunt
451a9ce9ff
[clang][ObjC][PAC] Add ptrauth protections to objective-c (#147899)
This PR introduces the use of pointer authentication to objective-c[++].

This includes:

* __ptrauth qualifier support for ivars
* protection of isa and super fields
* protection of SEL typed ivars
* protection of class_ro_t data
* protection of methodlist pointers and content
2025-07-14 19:32:18 -07:00
Valentin Clement (バレンタイン クレメン)
90ef114a33
[flang][cuda] Add cuf.set_allocator_idx for device component (#148750) 2025-07-14 19:31:44 -07:00
Oliver Hunt
7cde974233
[clang] Update diagnostics and documentation for type aware allocators (#148576)
Alas reflection pushed p2719 out of C++26, so this PR changes the
diagnostics to reflect that for now type aware allocation is
functionally a clang extension.
2025-07-14 19:20:36 -07:00
Peter Collingbourne
1ddb909a42 remote-exec: Detect and propagate signal death in the remote process.
If the remote process died with a signal, this will be exposed by ssh
as an exit code in the range 128 < rc < 160. We may be running under
`not --crash` which will expect us to also die with a signal, so send
the signal to ourselves so that wait4() in `not` will detect the signal.

Speculative fix for failing buildbot:
https://lab.llvm.org/buildbot/#/builders/193/builds/9070
2025-07-14 18:57:48 -07:00
Florian Mayer
14dc3e3d5f
[SelectionDAG] [KCFI] Allow "kcfi" on invoke (#148742)
This is handled in CallBase, so it is valid for both call and invoke
2025-07-14 18:55:09 -07:00
Deric C.
27b3b4a665
[DirectX] Move the scalarizer pass to before dxil-flatten-arrays (#146800)
Fixes #145924 and #140416
Depends on #146173 being merged first.

This PR moves the scalarizer pass to immediately before the
dxil-flatten-arrays pass to allow the dxil-flatten-arrays pass to turn
scalar GEPs (including i8 GEPs) into flattened array GEPs where
applicable.

A number of LLVM DirectX CodeGen tests have been edited to remove scalar
GEPs and also correct previously uncaught incorrectly-transformed GEPs.

No more validation errors of the form `Access to out-of-bounds memory is
disallowed` or `TGSM pointers must originate from an unambiguous TGSM
global variable` appear anymore after this PR when compiling DML
shaders.
2025-07-14 18:13:42 -07:00
Jim Lin
7ba0c98265 [RISCV] Rename the vector crypto intrinsic test vcpopv.c to vcpop.c. NFC.
To be consistent with https://github.com/riscv-non-isa/rvv-intrinsic-doc/tree/post-1.0-dev/auto-generated/vector-crypto/llvm-api-tests
2025-07-15 09:00:35 +08:00
Jim Lin
22707fd4a5
[RISCV] Add Andes XAndesBFHCvt (Andes Scalar BFLOAT16) extension (#148563)
The spec can be found at:

https://github.com/andestech/andes-v5-isa/releases/tag/ast-v5_4_0-release.

The extension includes only two instructions: one for converting from
f32 to f16, and another for converting from f16 to f32.

This patch only implements MC support for XAndesBFHCvt.
2025-07-15 08:59:00 +08:00
Stanislav Mekhanoshin
cbba8f0acb
[AMDGPU] Codegen support for v_fmaak_f64/f_fmamk_f64 (#148734) 2025-07-14 17:57:06 -07:00
Valentin Clement (バレンタイン クレメン)
2c6771889a
[flang][cuda] Introduce cuf.set_allocator_idx operation (#148717) 2025-07-14 17:23:18 -07:00
Valentin Clement (バレンタイン クレメン)
5eecec8e81
[flang] Fix use of __has_builtin and formatting (#148746)
`__has_builtin` is not available on all compilers. Make sure it works
when not defined.

Also fix some formatting issues: 
- Use brace initialization where possible
- Fix wrong capitalization of variables.
- Add `std::` for `unit64_t` and `int64_t` as it is mostly done in this
part of the codebase.
2025-07-14 17:21:09 -07:00
Konstantin Varlamov
49d2b5f1cd
[libc++][hardening] Introduce a dylib function to log hardening errors. (#148266)
Unlike `verbose_abort`, this function merely logs the error but does not
terminate execution. It is intended to make it possible to implement the
`observe` semantic for Hardening.
2025-07-14 17:04:33 -07:00
Matt Arsenault
ee5b9369cd
Hexagon: Add frexp intrinsic test (#148671) 2025-07-15 09:00:03 +09:00
Matt Arsenault
43206d1b2e
Hexagon: Add test for llvm.exp10 intrinsic (#148664)
This is mostly to test the libcall behavior
2025-07-15 08:56:35 +09:00