544594 Commits

Author SHA1 Message Date
Peter Waller
81ad8e6345
[BOLT] Force frame pointers off for runtimes (#148009)
Distributions are making the choice to turn frame pointers on by
default. Nixpkgs recently turned them on, and the method they use to do
so implies that everything is built with them on by default.

https://github.com/NixOS/nixpkgs/pull/399014

Assuming that a well behaved distribution doing this puts
`-fno-omit-frame-pointer` at the beginning of the compiler invocation,
we can still re-enable omission by supplying `-fomit-frame-pointer`
during compilation.

This fixes some segfaults from stack corruption in binaries rewritten by
bolt with `llvm-bolt -instrument`.

See also: #147569
Fixes: #148595
2025-07-14 11:03:35 +01:00
Hemang Gadhavi
0a357e92ca
[lldb] Update the String table offset based on the DWARF format (#147054)
This PR is updating the string table offset (DW_AT_str_offsets_base
which is introduced in `DWARF5`) based on the DWARF format, as per the
DWARF specification; For the 32-bit DWARF format, each offset is 4 bytes
long; for the 64-bit DWARF format, each offset is 8 bytes long.
2025-07-14 15:25:45 +05:30
Adrian Kuegel
6d4a50272f [ADT] Avoid ambiguity by using std::memcpy instead of memcpy (NFC). 2025-07-14 09:44:28 +00:00
David Spickett
d4516c7013 [llvm][release] Mark gh commands in package verify example 2025-07-14 09:26:26 +00:00
Tom Eccles
51d3bc67d0
[flang][tco] Add more flags for generating codegen tests (#148171)
Built on top of https://github.com/llvm/llvm-project/pull/146533

Adding some more options I use to generate minimal testcases for
MLIR->LLVMIR conversion.
Hopefully this will save us all some time when writing these tests.

The following options are added
- `-simplify-mlir` runs CSE and canonicalization at the end of the MLIR
pipeline
- `-enable-aa` allows toggling whether TBAA is enabled
- `-test-gen` is shorthand for `-emit-final-mlir -simplify-mlir
-enable-aa=false`
2025-07-14 10:24:58 +01:00
Matt Arsenault
ffb2da25c2
SPARC: Add gnu run line to sincos test (#147714)
Make sure we have tests that emit the sincos call instead of
the separate sin and cos.
2025-07-14 18:21:45 +09:00
Matt Arsenault
51c89f3854
SPARC: Start moving runtime libcall config to tablegen (#147672) 2025-07-14 18:17:59 +09:00
David Spickett
29d8c346c5
Reland "[flang] Avoid undefined behaviour when parsing format expressions (#147539)" (#148169)
This reverts commit e8e5d07767c444913f837dd35846a92fcf520eab.

This previously failed because the flang-rt build could not find the 
llvm header file. It passed on some machines but only because they
had globally installed copies of older llvm.

To fix this, I've copied the required routines from llvm into flang.

With the following justification:
* Flang can, and does, use llvm headers.
* Some Flang headers are also used in Flang-rt.
* Flang-rt cannot use llvm headers.
* Therefore any Flang header using in Flang-rt cannot use llvm headers
either.

To support that conclusion,
https://flang.llvm.org/docs/IORuntimeInternals.html
states:
"The Fortran I/O runtime support library is written in C++17, and uses
some C++17 standard library facilities, but it is intended to not have
any link-time dependences on the C++ runtime support library or any LLVM
libraries."

This talks about libraries but I assume it applies to llvm in general.

Nothing in flang/include/flang/Common, or flang/include/flang/Common
includes any llvm header, and I see some very similar headers there
that duplicate llvm functionality. Like float128.h.

I can only assume this means these files must remain free of
dependencies
on LLVM.

I have copied the two routines literally and put them in the
flang::common
namespace, for lack of a better place for them. So they don't clash with
something.

I have specialised the function to the 1 type flang needs, as it might
save a bit of compile time.
2025-07-14 10:14:04 +01:00
Matt Arsenault
df54961d16
SPARC: Remove subtarget checks on setLibcallImpl (#147667)
Remove the subtarget dependent useSoftMulDiv check on the mul/div
libcall configuration. The libcall still needs to exist with the
given ABI for the module regardless of the subtarget dependent
lowering decision which is separately controlled.

Also the f128<->i64 conversion calls were set twice, so eliminate
the redundant setting and always do it for sparc32.
2025-07-14 18:11:54 +09:00
Matthias Springer
695825589d
[mlir][TOSA] Do not access erased operation (#148374)
This commit fixes two occurrences where an erased op was accessed at a
later point of time. That won't work anymore in a One-Shot Dialect
Conversion and triggers a use-after-free sanitizer error.

After the One-Shot Dialect Conversion refactoring, a
`ConversionPatternRewriter` will behave more like a normal
`PatternRewriter`.

---------

Co-authored-by: Markus Böck <markus.boeck02@gmail.com>
2025-07-14 10:43:00 +02:00
Vikram Hegde
e091f264b7
[CodeGen][NPM] VirtRegRewriter: Set VirtReg flag (#148107)
same as https://github.com/llvm/llvm-project/pull/138660,

Co-authored-by : Oke, Akshat
<[Akshat.Oke@amd.com](mailto:Akshat.Oke@amd.com)>
2025-07-14 13:36:12 +05:30
Jim Lin
d64938b2ba [RISCV] Split the intrinsic test for vector crypto to seperate directory. NFC. 2025-07-14 16:03:09 +08:00
Florian Hahn
484417abe1
[Loads] Keep using constant max BTCs for loops w/o computable BTCs.
Follow-up to cad62df49a to preserve the existing behavior for early-exit
loops, to fix vec.stats.ll test failure.
2025-07-14 08:45:23 +01:00
Kunqiu Chen
a6e1700fa6
[Utils][Local] Preserve !nosanitize in combineMetadata when merging instructions (#148376)
`combineMetadata` helper currently drops `!nosanitize` metadata when
merging two instructions, even if both originally carried `!nosanitize`.

This is problematic because `!nosanitize` is a key mechanism used by
sanitizer (e.g., ASan) to suppress instrumentation. Removing it can lead
to unintended sanitizer behavior.

This patch adds `nosanitize` to the whitelist in combineMetadata,
preserving it only if both instructions carry `!nosanitize`; otherwise,
it is dropped. This patch also adds corresponding tests in a test file
and regenerates it.

---
### Details

**Example (see [Godbolt](https://godbolt.org/z/83P5eWczx) for
details**):

```llvm
%v1 = load i32, ptr %p, !nosanitize
%v2 = load i32, ptr %p, !nosanitize
```
When merged via `combineMetadata(%v1, %v2, ...)`, the resulting
instruction loses its `!nosanitize` metadata.

Tools such as UBSan and AFL rely on `nosanitize` to prevent unwanted
transformations or checks. However, the current implementation of
combineMetadata mistakenly drops !nosanitize. This may lead to
unintended behavior during optimization.

For example, under `-fsanitize=address,undefined -O2`, IR emitted by
UBSan may lose its `!nosanitize` metadata due to the incorrect metadata
merging in optimization. As a result, ASan could unexpectedly instrument
those instructions.
> Note: due to the current UBSan handlers having relatively
coarse-grained attributes, this specific case is difficult to reproduce
end-to-end from source code—UBSan currently inhibits such optimizations
(refer to #135135 for details).

Still, I believe it's necessary to fix this now, to support future
versions of UBSan that might allow such optimizations, and to support
third-party tools (such as AFL-based fuzzers) that rely on the presence
of !nosanitize.
2025-07-14 15:45:08 +08:00
Florian Hahn
cad62df49a
[Loads] Support dereferenceable assumption with variable size. (#128436)
Update isDereferenceableAndAlignedPointer to make use of dereferenceable
assumptions with variable sizes via SCEV.

To do so, factor out the logic to check via an assumption to a helper,
and use SE to check if the access size is less than the dereferenceable
size.

PR: https://github.com/llvm/llvm-project/pull/128436
2025-07-14 08:17:33 +01:00
Younan Zhang
040e7ad828
[Clang] Consider default template arguments when synthesizing CTAD guides (#147675)
We copy arguments from different template parameter lists depending on
the deducibility of the template parameters. In particular, we may lose
the default template argument from the original alias declaration, and
this patch helps preserve that.

Fixes https://github.com/llvm/llvm-project/issues/133132
2025-07-14 14:45:23 +08:00
Fangrui Song
8983b22ca1 ReleaseNotes: add lld/ELF notes
Move linker script changes to the middle and target-specific
options/behavior changes to the end.
2025-07-13 23:24:14 -07:00
Christian Ulmann
374d5da214
[MLIR][Interfaces] Remove negative branch weight verifier (#148234)
This commit removes the verifier that checked if branch weights are
negative. This check was too strict because weights are interpreted as
unsigned integers.

This showed up when running the verifier on LLVM dialect modules that
were imported from LLVM IR.
2025-07-14 07:34:29 +02:00
Finn Plummer
a6494a3bbf
[HLSL][RootSignature] Allow for multiple parsing errors in RootSignatureParser (#147832)
This pr implements returning multiple parsing errors at the granularity
of a `RootElement`

This is achieved by adding a new interface onto `RootSignatureParser`,
namely, `skipUntilExpectedToken`. This will be used to consume all the
intermediate tokens between when an error has occurred and when the next
`RootElement` begins.

At this granularity, the implementation is somewhat straight forward, as
we can just implement this `skip` function when we return from a
`parse[RootElement]` method and continue in the main `parse` loop. With
the exception that the `parseDescriptorTable` will also have to skip
ahead to the next expected closing `')'`.

If we want to provide any finer granularity, then the skip logic becomes
significantly more complicated. Skipping to the next root element will
provide a good ratio of user experience benefit to complexity of
implementation.

For more context see linked issue.

- Updates `HLSLRootSignatureParser` with a `skipUntilExpectedToken` and `skipUntilClosedParen`
interface
- Updates the `parse` loops to use the skip interface when an error is
found on parsing a root element
- Updates `parseDescriptorTable` to skip ahead to the next `')'` if it
was inside a clause
- Adds test-case to demonstrate multiple error being reported

Resolves: https://github.com/llvm/llvm-project/issues/145818
2025-07-13 22:22:46 -07:00
Kazu Hirata
ef48b7fae5
[libcxx] Fix a typo in documentation (#148557) 2025-07-13 22:20:03 -07:00
Jim Lin
03c540e360 [RISCV] Move intrinsic tests for Xsfvcp to sifive-intrinsics sub-directory. NFC. 2025-07-14 13:08:40 +08:00
Vikram Hegde
3d1140a5e4
[AMDGPU][NPM] Register AMDGPUWaitSGPRHazards pass (#148106)
this stack upstreams original stack of patches by @optimisan, same as
https://github.com/llvm/llvm-project/pull/138496 (original stack).

Co-authored-by : Oke, Akshat
<[Akshat.Oke@amd.com](mailto:Akshat.Oke@amd.com)>
2025-07-14 10:27:33 +05:30
Uday Bondhugula
3de59f79d8
[MLIR][Affine] Rename/update affine fusion test pass options to avoid confusion (#148320)
This test pass is meant to test various affine fusion utilities as
opposed to being a pass to perform valid fusion. Rename an option to
avoid confusion.

Fixes: https://github.com/llvm/llvm-project/issues/132172
2025-07-14 09:23:26 +05:30
Owen Pan
b79c763e91
[clang-format][NFC] Simplify some logic in BreakableLineCommentSection (#148324) 2025-07-13 20:35:45 -07:00
YongKang Zhu
e088334432
[BOLT][NFC] Add const qualifier to certain pointers to read-only objects (#148543) 2025-07-13 19:17:20 -07:00
Ryotaro Kasuga
16534d19bf
[DA] Add test cases where base ptr is not loop-invariant (#148240)
Add test cases where DA yields incorrect results because it makes an
assumption that the base pointer is loop-invariant, which doesn't hold
in these cases.

Will be fixed by #148241.
2025-07-14 10:51:21 +09:00
Shan Huang
089106fdfb
[DebugInfo][LoopStrengthReduce] Salvage the debug value of the dead cmp instruction (#147241)
Fix #147238
2025-07-14 09:45:37 +08:00
Tom Vijlbrief
60b168c146
[AVR] Simplify SPWRITE on XMEGA (#147210)
It is unnecessary to disable/restore interrupt when writing to the SPH/SPL
pair on XMEGA devices, as the manual indicates:

```
To prevent corruption when updating the stack pointer from software,
a write to SPL will automatically disable interrupts for up to four instructions
or until the next I/O memory write.
```
2025-07-14 09:40:37 +08:00
Jim Lin
2886d30dd6
[RISCV] Add short forward branch scheduling for Andes45 (#147890) 2025-07-14 09:26:19 +08:00
Eli Friedman
4f5d67b3e4
[AArch64] "Support" debug info for SVE types on Windows. (#147865)
There isn't any way to encode a variable in an SVE register, and there
isn't any way to encode a scalable offset, and as far as I know that's
unlikely to change in the near future. So suppress any debug info which
would require those encodings.

This isn't ideal, but we need to ship something which doesn't crash.

Alternatively, for Z registers, we could emit debug info assuming the
vector length is 128 bits, but that seems like it would lead to
unintuitive results.

The change to AArch64FrameLowering is needed to avoid a crash. But we
can't actually test that the returned offset is correct: LiveDebugValues
performs the query, then discards the result.
2025-07-13 16:06:27 -07:00
Eli Friedman
cffe7cb745
[clang] Fix isConstantInitializer handling of transparent init lists. (#148030)
Transparent InitListExprs have different semantics, so special-case them
in Expr::isConstantInitializer.

We probably should move away from isConstantInitializer, in favor of
relying more directly on constant evaluation, but this is an easy fix.

Fixes #147949
2025-07-13 16:02:52 -07:00
Aaron Puchert
bfb686bb5b Thread Safety Analysis: Move opcode comparison to Comparator (NFC)
The switch assumes that both operands have the same opcode, so it's
probably cleaner if we do the comparison there. This also deduplicates
the comparison.
2025-07-14 00:10:15 +02:00
Alex MacLean
86203b6b33
[NVPTX] Use PRMT more widely, and improve folding around this instruction (#148261)
Replace uses of BFE with PRMT when lowering v4i8 vectors. This will
generally lead to equivalent or better SASS and reduces the number of
target specific operations we need to represent.
(https://cuda.godbolt.org/z/M75W6f8xd) Also implement KnownBits tracking
for PRMT allowing elimination of redundant AND instructions when
lowering various i8 operations.
2025-07-13 15:06:53 -07:00
Owen Pan
c384ec431d
[clang-format] Add MacrosSkippedByRemoveParentheses option (#148345)
This allows RemoveParentheses to skip the invocations of function-like
macros.

Fixes #68354.
Fixes #147780.
2025-07-13 14:29:51 -07:00
Fangrui Song
1fbfa333f6 MCAlignFragment: Rename fields and use uint8_t FillLen
* Rename the vague `Value` to `Fill`.
* FillLen is at most 8. Making the field smaller to facilitate encoding
  MCAlignFragment as a MCFragment union member.
* Replace an unreachable report_fatal_error with assert.
2025-07-13 14:07:10 -07:00
Baranov Victor
b56aebaf82
[clang-tidy] Add filtering of check options by enabled checks in '--dump-config' (#147142)
Added function to filter out `CheckOptions` that come from
`ClangTidyOptions::getDefaults()`, but does not have a corresponding
check enabled in the `Checks` configuration.

Fixes https://github.com/llvm/llvm-project/issues/146693.
2025-07-13 23:44:30 +03:00
Kazu Hirata
cac806bcc5
[mlir] Remove unused includes (NFC) (#148535) 2025-07-13 13:13:01 -07:00
Kazu Hirata
3f78e91340
[SystemZ] Remove unnecessary casts (NFC) (#148534)
getInstrInfo() already returns const SystemZInstrInfo *.
2025-07-13 13:12:54 -07:00
Kazu Hirata
ebaadb1f16
[ARM] Remove unnecessary casts (NFC) (#148533)
Decoder is already of const MCDisassembler *.
2025-07-13 13:12:46 -07:00
Kazu Hirata
b97fad1b41
[AArch64] Remove an unnecessary cast (NFC) (#148532)
getRegisterInfo() already returns const AArch64RegisterInfo *.
2025-07-13 13:12:38 -07:00
Kazu Hirata
047552600b
[Sema] Remove an unnecessary cast (NFC) (#148531)
Dtor is already of CXXDestructorDecl *.
2025-07-13 13:12:31 -07:00
Florian Hahn
f4c7cc26b6
[LV] Use more precise isPredicatedInst in legacy CCH (NFC).
Legal::isMaskRequired may be overly conservative and also return true
when no mask is actually required.

Use isPredicatedInst from the cost model instead, which fixes a
cost-model divergence between legacy and VPlan cost model where the
legacy cost model incorrectly assumed some loads were predicated.

Fixes https://github.com/llvm/llvm-project/issues/148431.
2025-07-13 19:55:34 +01:00
Florian Hahn
f168175d01
[VPlan] Move using namespace VPlanPatternMatch to top level (NFC).
VPlanConstruction.cpp doesn't use IR pattern matching, so using
VPlanPatternMatch can be moved to the top-level, to slightly reduce the
diff in follow-up changes.
2025-07-13 19:22:13 +01:00
Finn Plummer
7ccdc595f8
[HLSL][RootSignature] Add basic parameter validations of Root Elements (#145795)
In this pr we go through and enforce the various bounded parameter
values for non-flag values and the valid flag combinations for
`RootDescriptor` and `DescriptorRange` flags.

For reference of the required checks, please see here:
https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#validations-in-sema.

- Updates `SemaHLSL` to iterate through `RootElement`s and verify that
all non-flag parameters are within their bounds
- Updates `SemaHLSL` to iterate through `RootElement`s and verify that
all flag parameters are a valid combination
- Extends `RootSignature-err.hlsl` with testcases for all invalid
specifications
- Adds `RootSignature-flags-err.hlsl` with testcase for invalid flag
specifications

Resolves: https://github.com/llvm/llvm-project/issues/129940
2025-07-13 10:23:38 -07:00
LLVM GN Syncbot
b6313b381a [gn build] Port 59b39c0031ed 2025-07-13 16:23:36 +00:00
Victor Chernyakin
59b39c0031
[clang-tidy] Add new check: readability-use-concise-preprocessor-directives (#146830)
Closes #132561.

This is a check that rewrites `#if`s and `#elif`s like so:

```cpp
#if  defined(MEOW) // -> #ifdef  MEOW
#if !defined(MEOW) // -> #ifndef MEOW
```

And, since C23 and C++23:

```cpp
#elif  defined(MEOW) // -> #elifdef  MEOW
#elif !defined(MEOW) // -> #elifndef MEOW
```
2025-07-13 19:23:27 +03:00
Matthias Springer
1db33f1034
[mlir][Transforms] Report all allowPatternRollback violations as fatal errors (#148416)
Report all `allowPatternRollback` API violations as fatal errors. If
violated, the IR is potentially in an invalid/inconsistent state from
which the driver cannot recover.
2025-07-13 17:41:21 +02:00
Benjamin Maxwell
43a9ec2ecd
[AArch64][SME] Instcombine llvm.aarch64.sme.in.streaming.mode() (#147930)
This can fold away in functions with known streaming modes.
2025-07-13 13:20:20 +01:00
Florian Hahn
cc65da0fb1
[LV] Update fmax tests to include ogt/olt/ole/ugt predicates.
Adjust and update tests as per feedback in
https://github.com/llvm/llvm-project/pull/146711.
2025-07-13 12:16:54 +01:00
Harald van Dijk
21491ed751
Turn off uninitialized warnings for GCC up to 14. (#147968)
Although the false positives that caused it to be disabled originally
may have been fixed in GCC 12, GCC also suffers from a problem where
-Wuninitialized may cause the build to hang on some platforms (GCC
#120729). This has been fixed in GCC 15, so turn on -Wuninitialized for
GCC 15+ instead of GCC 12+.
2025-07-13 10:44:21 +01:00