Commit Graph

545463 Commits

Author SHA1 Message Date
Kazu Hirata
c045caae86 [lldb] Proofread python-reference.rst (#149643) 2025-07-20 11:23:57 -07:00
Fangrui Song
7a42fb85df MCSectinELF: Delete setSectionName declaration 2025-07-20 11:12:45 -07:00
Fangrui Song
673e5422ea MC: Fix fragment-in-BSS check
* Handle non-zero fill values for `.fill` and `.org` directives.
* Restore the fragment type check
  (5ee34ff1e5 removed a reachable
  `llvm_unreachable`) to detect unintended API usage.

Remove virtual functions `getVirtualSectionKind` (added in
https://reviews.llvm.org/D78138) as they are unnecessary in diagnostics.
The a.out object file format has the BSS concept, which has been
inherited by COFF, XCOFF, Mach-O, and ELF object file formats.

Pull Request: https://github.com/llvm/llvm-project/pull/149721
2025-07-20 11:11:21 -07:00
Fangrui Song
ba6b705620 MC: Replace getOrCreateDataFragment with getCurrentFragment
Add an assert to ensure `CurFrag` is either null or an `FT_Data` fragment.

Follow-up to 39c8cfb70d.
Extracted from #149721
2025-07-20 11:02:26 -07:00
Fangrui Song
6201761e96 MC: Rename isVirtualSection to isBssSection
The term BSS (Block Started by Symbol) is a standard, widely recognized
term, available in the a.out object file format and adopted by formats
like COFF, XCOFF, Mach-O (called S_ZEROFILL while `__bss` is also used),
and ELF. To avoid introducing unfamiliar terms, we should use
isBSSSection instead of isVirtualSection.
2025-07-20 10:39:17 -07:00
Jasmine Tang
343f7475be [WebAssembly] Add support for memcmp expansion (#148298)
Fixes https://github.com/llvm/llvm-project/issues/61400

Added test case in llvm/test/CodeGen/WebAssembly/memcmp-expand.ll
2025-07-20 10:27:42 -07:00
Brian Cain
b42f96bc05 [lld] Add thunks for hexagon (#111217)
Without thunks, programs will encounter link errors complaining that the
branch target is out of range. Thunks will extend the range of branch
targets, which is a critical need for large programs. Thunks provide
this flexibility at a cost of some modest code size increase.

When configured with the maximal feature set, the hexagon port of the
linux kernel would often encounter these limitations when linking with
`lld`.

The relocations which will be extended by thunks are:

* R_HEX_B22_PCREL, R_HEX_{G,L}D_PLT_B22_PCREL, R_HEX_PLT_B22_PCREL
relocations have a range of ± 8MiB on the baseline
* R_HEX_B15_PCREL: ±65,532 bytes
* R_HEX_B13_PCREL: ±16,380 bytes
* R_HEX_B9_PCREL: ±1,020 bytes

Fixes #149689 

Co-authored-by: Alexey Karyakin <akaryaki@quicinc.com>

---------

Co-authored-by: Alexey Karyakin <akaryaki@quicinc.com>
2025-07-20 11:46:31 -05:00
Kazu Hirata
04f2114ab2 [memprof] Refactor readMemProf (NFC) (#149663)
This patch creates a helper function named handleAllocSite to handle
the allocation site.  It makes readMemProf a little bit shorter.

I'm planning to move the code to handle call sites in a subsequent
patch.  Doing so in this patch would make this patch a lot longer
because we need to move other things like CallSiteEntry and
CallSiteEntryHash.
2025-07-20 08:27:24 -07:00
Mikhail R. Gadelha
eb3e56f19e [libc] Disable bfloat16 test for full build mode (#149678)
This patch temporarily disables bfloat16_test for full build mode, until
the MPCommon target is updated so that mpfr_inc.h is not included in the
MPCommon.h header.

This should fix the rv32 buildbot failures.
2025-07-20 12:16:06 -03:00
Tom Vijlbrief
9f29007999 [AVR] Force to emit relocation slots for relative branch instructions (#145291)
fixes https://github.com/llvm/llvm-project/issues/133579
2025-07-20 22:10:31 +08:00
bd1976bris
bbbbc093fe [DTLTO][LLD][COFF] Add support for Integrated Distributed ThinLTO (#148594)
This patch introduces support for Integrated Distributed ThinLTO (DTLTO)
in COFF LLD.

DTLTO enables the distribution of ThinLTO backend compilations via
external distribution systems, such as Incredibuild, during the
traditional link step: https://llvm.org/docs/DTLTO.html.

Note: Bitcode members of non-thin archives are not currently supported.
This will be addressed in a future change. This patch is sufficient to
allow for self-hosting an LLVM build with DTLTO if thin archives are
used.

Testing:
- LLD `lit` test coverage has been added, using a mock distributor to
avoid requiring Clang.
- Cross-project `lit` tests cover integration with Clang.

For the design discussion of the DTLTO feature, see:
https://github.com/llvm/llvm-project/pull/126654
2025-07-20 14:47:00 +01:00
Simon Pilgrim
17c7c2ebe8 [DAG] Add missing Depth argument to isGuaranteedNotToBeUndefOrPoison calls inside SimplifyDemanded methods (#149550)
Ensure we don't exceed the maximum recursion depth
2025-07-20 13:06:55 +01:00
Maya Amrami
e138c95155 [mlir] ViewLikeInterface - verify ranks in verifyOffsetSizeAndStrideOp (#147926)
getMixedOffsets() calls getMixedValues() with `static_offsets` and
`offsets`. It is assumed that the number of dynamic offsets in
`static_offsets` equals the rank of `offsets`. Otherwise, we fail on
assert when trying to access an array out of its bounds.
The same applies to getMixedStrides() and getMixedOffsets().

A verification of this assumption is added to
verifyOffsetSizeAndStrideOp() and a clear assert is added in
getMixedValues().
2025-07-20 14:20:16 +03:00
LLVM GN Syncbot
89f09a887d [gn build] Port 6c257754d9 2025-07-20 09:23:47 +00:00
Nikolas Klauser
6c257754d9 [libc++] Refactor internal index_sequence API to match the public one (#149475)
The internal API is a lot more complicated than it actually needs to be.
This refactors the internal API to match the features and names of the
public one.
2025-07-20 11:23:31 +02:00
Timm Baeder
5b0935f1f0 [clang][bytecode] Reintroduce Pointer::elem() (#149693)
As a way of writing atIndex(I).deref<T>(), which creates an intermediate
Pointer, which in turn adds (and removes) that pointer from the pointer
list of the Block. This way we can avoid that.
2025-07-20 10:59:50 +02:00
Alex Bradbury
c58225f757 [RISCV] Add RISCV::SUBW to RISCVOptWInstrs::stripWSuffixes (#149071)
This is purely a benefit for reducing unnecessary diffs between RV32 and
RV64, as RVC does have a compressed form of SUBW (so SUB isn't more
compressible). This affects ~57.2k instructions in an rva22u64 build of
llvm-test-suite with SPEC CPU 2017 included.
2025-07-20 09:59:41 +01:00
Alex Bradbury
971bfbead2 [RISCV][NFC] Add NumTransformedToNonWInstrs statistic to RISCVOptWInstrs extend debug printing
RISCVOptWInstrs has a NumTransformedToWInstrs statistic, but didn't have
one for the W=>Non-W transform done by stripWSuffixes. It also didn't do
debug printing of the transformation. This patch addresses both issues.

Reviewed as part of <https://github.com/llvm/llvm-project/pull/149071>,
but landing separately.
2025-07-20 09:54:10 +01:00
Vassil Vassilev
6163b66e0a [clang-repl] Another try on system-z.
This patch should make msan happy as it found a real bug where we always try to
read an unsigned long long without respecting the underlying enum type.

Another follow-up on llvm/llvm-project#102858
2025-07-20 08:23:47 +00:00
LLVM GN Syncbot
0dfac65595 [gn build] Port d344c383e2 2025-07-20 08:14:16 +00:00
Hui
d344c383e2 [libc++][ranges] implement std::ranges::zip_transform_view (#79605)
Fixes #104977
Fixes #105035

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Co-authored-by: A. Jiang <de34@live.cn>
2025-07-20 09:13:59 +01:00
Fangrui Song
fd6d6a7c8d MC: Refactor FT_Align fragments when linker relaxation is enabled
Previously, two MCAsmBackend hooks were used, with
shouldInsertFixupForCodeAlign calling getWriter().recordRelocation
directly, bypassing generic code.

This patch:

* Introduces MCAsmBackend::relaxAlign to replace the two hooks.
* Tracks padding size using VarContentEnd (content is ignored).
* Move setLinkerRelaxable from MCObjectStreamer::emitCodeAlignment to the backends.

Pull Request: https://github.com/llvm/llvm-project/pull/149465
2025-07-20 00:55:54 -07:00
Fangrui Song
2ba5e0ad17 MC: Encode FT_Align in fragment's variable-size tail
Follow-up to #148544

Pull Request: https://github.com/llvm/llvm-project/pull/149030
2025-07-20 00:46:51 -07:00
Fangrui Song
5ee34ff1e5 MC: Optimize emitInstruction and simplify fragment-in-BSS check
Move the FT_Relaxable-in-BSS check from frequently-called
MCObjectStreamer::emitInstruction to MCAssembler::writeSectionData,
along with existing checks for other fragment types. For the uncommon
diagnostics, losing the location information is acceptable.
2025-07-20 00:09:24 -07:00
Yingwei Zheng
9e587ce6f0 [SCCP] Simplify [us]cmp(X, Y) into X - Y (#144717)
If the difference between [us]cmp's operands is not greater than 1, we
can simplify it into `X - Y`.
Alive2: https://alive2.llvm.org/ce/z/JS55so
llvm-opt-benchmark diff:
https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2464/files
2025-07-20 15:01:44 +08:00
Timm Baeder
51af47e53c [clang][bytecode] Use in Expr::tryEvaluateStrLen() (#149677)
Fixes #138475
2025-07-20 09:00:22 +02:00
Michał Górny
58c3affdaa [libclc] Expose prepare_builtins_* variables in top-level CMakeLists (#149657)
Fix `libclc/utils/CMakeLists.txt` to expose `prepare_builtins_*`
variables in parent scope. This was a regression introduced in #148815
where the code was moved into subdirectory, and the variables would no
longer be accessible to calls in top-level CMakeLists, resulting in
attempting to build targets with empty command:

```
[1566/1676] cd /var/tmp/portage/llvm-core/libclc-22.0.0.9999/work/libclc_build && -o /var/tmp/portage/llvm-core/libclc-22.0.0.9999/work/libclc_build/clspv--.bc /var/tmp/portage/llvm-core/libclc-22.0.0.9999/work/libclc_build/obj.libclc.dir/clspv--/builtins.opt.clspv--.bc
FAILED: clspv--.bc /var/tmp/portage/llvm-core/libclc-22.0.0.9999/work/libclc_build/clspv--.bc
cd /var/tmp/portage/llvm-core/libclc-22.0.0.9999/work/libclc_build && -o /var/tmp/portage/llvm-core/libclc-22.0.0.9999/work/libclc_build/clspv--.bc /var/tmp/portage/llvm-core/libclc-22.0.0.9999/work/libclc_build/obj.libclc.dir/clspv--/builtins.opt.clspv--.bc
/bin/sh: line 1: -o: command not found
```
2025-07-20 12:26:51 +09:00
Jasmine Tang
e7ac49977a [InstSimplify] Add poison propagation for trivially vectorizable intrinsics (#149243)
Fixes https://github.com/llvm/llvm-project/issues/146769

Test cases added to
`llvm/test/Transforms/InstSimplify/fold-intrinsics.ll`
2025-07-19 19:37:21 -07:00
Fangrui Song
d77ac81e93 X86AsmBackend: Remove some overhead from auto padding feature
MCObjectStreamer::emitInstructionImpl is hot.
Devirtualize allowEnhancedRelaxation introduced by
https://reviews.llvm.org/D76286
2025-07-19 18:51:47 -07:00
Craig Topper
ff0cbecb68 [RISCV] Add a non-template version of SelectAddrRegZextRegScale and move code there. NFC
The template versions now call the non-template version. This
avoids duplicating the code for each template.
2025-07-19 17:53:39 -07:00
Fangrui Song
39c8cfb70d MC: Optimize getOrCreateDataFragment
... by eagerly allocating an empty fragment when adding a fragment
with a variable-size tail.

X86AsmBackend, The JCC erratum mitigation and x86-pad-for-align set a
flag for FT_Relaxable, which needs to be moved to emitInstructionBegin.
```
  if (CF->getKind() == MCFragment::FT_Relaxable)
    CF->setAllowAutoPadding(canPadInst(Inst, OS));
```

Follow-up to #148544
2025-07-19 16:55:30 -07:00
Manas
54492c231c [clang][docs] Add all clang-tools-extra to 'ClangTools.rst' (#148622)
The 'Extra Clang Tools' section does not mention any other clang tool
except clang-tidy. This adds all missing extra tools to sync
documentation between this page and the main page of Extra Clang Tools.

Fixes #148538
2025-07-20 01:18:24 +03:00
Maksim Levental
6056f942ab [mlir][NFC] update LLVM create APIs (2/n) (#149667)
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-07-19 18:15:54 -04:00
Mikhail R. Gadelha
756e515ce3 [libc] Simplify fma handling for riscv (#149673)
This PR simplifies how we enable the different fma configs for riscv:

1. Removes __LIBC_RISCV_USE_FMA define
2. Checks if __riscv_flen is defined to set LIBC_TARGET_CPU_HAS_FMA

As a bonus, we enable *FMA_OPT tests for rv32, so any rv32 hardware that
doesn't implement the f/d extensions is also covered by the tests.
2025-07-19 19:10:52 -03:00
David Green
07100c6658 [AArch64] Clean up abd lowering. NFC
The neon ABD intrinsics are lowering to ISD::ABDS/ISD::ABDU nodes in SDAG. This
adds the same for GISel so that we can remove the AArch64sabd/AArch64uabd
PatFrags, reducing the number of patterns needed. Some very basic legalization
info is added for G_ABD nodes.
2025-07-19 22:13:13 +01:00
David Green
269e3091a6 [AArch64][GlobalISel] Add test coverage for some abd cases. NFC 2025-07-19 21:56:28 +01:00
Fangrui Song
52f56edccf WasmObjectWrier: Simplify fragment walk in .init_array
and reduce the reliance on the FT_Align/FT_Data layout,
which will be changed by #149030
2025-07-19 13:24:24 -07:00
eaeltsin
6eef978e1e Include <vector> in TemplatingUtils.h (#149671)
This is needed after 3ee0f97b95
2025-07-19 22:08:41 +02:00
Kyungwoo Lee
52bcc7b170 [NFC][RA] Refactor RABasic into a Separate Header (#149555)
This change refactors the RABasic type by moving it from
RegAllocBasic.cpp to a new header file, RegAllocBasic.h. This separation
of header and implementation aligns with the structure used by other
register allocators, such as RegAllocGreedy. The refactoring is intended
to facilitate future use of RABasic in other contexts.
2025-07-19 12:43:48 -07:00
Fangrui Song
dc89a910aa MCStreamer: Simplify with newFragment. NFC 2025-07-19 12:40:36 -07:00
Timm Baeder
fed6db45df [clang][bytecode] Diagnose dereferencing a null pointer (#149330) 2025-07-19 21:39:06 +02:00
Mikhail R. Gadelha
5753be4ea2 [libc] Fix utimes build when full_build=OFF (#149668)
We might pull a header from the host where tv_nsec is not a long, 
so compilation would fail with an implicit conversion error.
2025-07-19 16:37:42 -03:00
Florian Hahn
3fd53db858 [VPlan] Remove unneeded VPVectorPointer after narrowing to replicate.
The replicate recipes created when narrowing interleave groups don't
need a VPVectorPointer, they can simply use the existing pointer.
2025-07-19 20:18:04 +01:00
Mikhail R. Gadelha
4d76ff9d2e [libc] Fix setitimer build when full_build=OFF (#149665)
When we pull the headers from the system, we might get a suseconds_t
that's a long long, so add a cast to prevent a implicit conversion
error.
2025-07-19 16:03:09 -03:00
Vassil Vassilev
0a463bd43e [clang-repl] Mark asan and systemz as unsupported for now.
While waiting for the bot owners it seems that this is not a major issue due
to the big endianness of the systemz platform. Instead it looks like we are not
modelling something well for enum types. Probably `va_arg` has a bug for that
platform or similar.

The asan failure seems to be a crash in asan and maybe related to the issues
we've mentioned in llvm/llvm-project#102858.

This patch should appease the bots that were broken by llvm/llvm-project#148701
2025-07-19 17:45:56 +00:00
Maksim Levental
906295b8a3 [mlir] update affine+arith create APIs (1/n) (#149656)
This PR updates create APIs for arith and affine - specifically these
are the only in-tree dialects/ops with "custom" builders:

```
AffineDmaStartOp
AffineDmaWaitOp
ConstantIntOp
ConstantFloatOp
ConstantIndexOp
```

See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-07-19 12:37:39 -05:00
Corentin Jabot
c43f828d59 [Clang] Be less strict about diagnosing null pointer dereference. (#149648)
In #143667, we made constant evaluation fail on `*null_ptr`, as this is
UB. However, `&(*(foo*)0)` seems to be a common pattern, which made
#143667 too disruptive.

So instead of failing the evaluation, we note the UB, which let clang
recovers when checking for constant initialization.

Fixes #149500
2025-07-19 19:30:16 +02:00
Fangrui Song
1fcf49a35c MC: Replace FT_PseudoProbe with FT_LEB
The fragment type introduced by https://reviews.llvm.org/D91878 is
unnecessary and can be replaced with FT_LEB.
2025-07-19 10:15:25 -07:00
Fangrui Song
ecf0cbda18 MCFragment: Refactor LEB
* Deduplicate creation of SLEB128/ULEB128 with makeLEB.
* Call newFragment to prepare for removing getOrCreateDataFragment.
2025-07-19 09:59:27 -07:00
Hui
64220357b4 [libc++] constexpr flat_multimap (#148417)
Fixes #128674
2025-07-20 00:36:29 +08:00