2260 Commits

Author SHA1 Message Date
Sam Clegg
11c2613342
[WebAssembly] Add initial support for compact imports proposal (#176617)
This change adds initial support to libObject for reading compact
imports and support for writing compact imports in the linker.

There is minimal testing here since to tools like lllvm-readobj, and
obj2yaml don't currently report compact imports any differently.

See https://github.com/WebAssembly/compact-import-section
2026-02-10 10:57:45 -08:00
Mirko Brkušanin
20b5849e17
[AMDGPU] Define new target gfx1170 (#180185) 2026-02-06 14:38:50 +01:00
Yury Plyakhin
c43d1c5292
[Object][Offload] Fix OffloadBinary::create to explicitly move return value (#180011)
On older compilers (GCC 7), implicit move on return is not guaranteed,
causing the compiler to attempt copying the SmallVector of unique_ptr's,
which fails because unique_ptr has a deleted copy constructor.
Added explicit std::move() on both return paths to ensure move semantics
are used instead of copy, fixing compilation by GCC 7.
2026-02-05 13:30:09 -08:00
Yury Plyakhin
4d27530c69
[Offloading] Offload Binary Format V2: Support Multiple Entries (#169425)
This PR updates the OffloadBinary format from version 1 to version 2,
enabling support for multiple offloading entries in a single binary.
This allows combining multiple device images into a single binary with
common global metadata while maintaining backwards compatibility with
version 1 binaries.

# Key Changes
## Binary Format Enhancements
  **Version 2 Format Changes:**
  - Changed from single-entry to multi-entry design
  - Updated `Header` structure:
    - Renamed `EntryOffset` → `EntriesOffset` (offset to entries array)
    - Renamed `EntrySize` → `EntriesCount` (number of entries)
- Added `StringEntry::ValueSize` field to support explicit string value
sizes (enables non-null-terminated strings)
- Introduced `OffloadEntryFlags` enum with `OIF_Metadata` flag for
metadata-only entries (entries without binary images)

  **API Changes:**
- `OffloadBinary::create()` now returns
`Expected<SmallVector<std::unique_ptr<OffloadBinary>>>` instead of
single binary
- Added optional `Index` parameter to extract specific entry:
`create(Buffer, std::optional<uint64_t> Index)`
- `OffloadBinary::write()` now accepts `ArrayRef<OffloadingImage>`
instead of single image
  - Added `OffloadBinary::extractHeader()` for header extraction

  **Memory Management:**
- Implemented `SharedMemoryBuffer` class to enable memory sharing across
multiple `OffloadBinary` instances from the same file
- Multiple entries from a single serialized binary share the underlying
buffer

## Testing
  **Unit Tests (`unittests/Object/OffloadingTest.cpp`):**
- `checkMultiEntryBinaryExtraction`: Tests extracting all entries from a
multi-entry binary
- `checkIndexBasedExtraction`: Tests extracting specific entries by
index, including out-of-bounds validation
  - `checkEdgeCases`: Tests edge cases including:
    - Empty string metadata
    - Empty image data
    - Large string values (4KB)

  **Other Tests:**
- Updated `test/ObjectYAML/Offload/multiple_members.yaml` to include
metadata-only entry

---------

Co-authored-by: Joseph Huber <huberjn@outlook.com>
2026-02-05 07:46:57 -08:00
Sam Clegg
d6ca3d085e
[WebAssembly] Dump more info when printing symbols. NFC (#178328) 2026-01-28 12:17:13 -08:00
serge-sans-paille
cc04746802
[perf] Replace copy-assign by move-assign in llvm/lib/Object(YAML)/* (#178177) 2026-01-27 16:28:29 +00:00
Francesco Petrogalli
460c9b2db1
[RISC-V][Mach-O] Add assembler support for Mach-O relocations. (#177446)
This patch adds comprehensive assembler (MC layer) support for the
Mach-O object file format on RISC-V targets, enabling assembly and
disassembly of RISC-V code targeting Apple platforms.

Key changes:

- Define RISC-V-specific Mach-O relocation types in BinaryFormat/MachO.h
- Implement RISCVMachObjectWriter with full relocation handling for:
  - PCREL_HI/LO pairs for PC-relative addressing
  - GOT relocations for external symbols
  - Branch relocations (CALL, unconditional/conditional branches)
  - Data section relocations

Test files include llvm-otool dumps to verify the generated relocations.

This code is based on code originally written by Tim Northover.
2026-01-26 14:06:30 -08:00
Jameson Nash
d10b2b566a
[NFCI] replace getValueType with new getGlobalSize query (#177186)
Returns uint64_t to simplify callers. The goal is eventually replace
getValueType with this query, which should return the known minimum
reference-able size, as provided (instead of a Type) during create.
Additionally the common isSized query would be replaced with an
isExactKnownSize query to test if that size is an exact definition.
2026-01-22 13:55:53 -05:00
Mariusz Sikora
6de6f7b46b
[AMDGPU] Define gfx1310 target with ELF number 0x50 (#177355)
For now this is identical to gfx1250.

---------

Co-authored-by: Jay Foad <jay.foad@amd.com>
2026-01-22 17:08:38 +01:00
Daniel Thornburgh
567fe2bbca
[NFC][LTO] Move isPreservedName out of IRSymtab into LTO's Symbol as isLibcall (#177046)
This resolves the FIXME in IRSymtab and cleans up the semantics of the
IRSymtab. The list of preserved symbols really shouldn't be seen as a
property of the IR symbol table, since it's an LTO-specific concern, and
it's very tenuous to claim that this information is actually present in
the bitcode file to be exposed through its symbol table.

Instead, this PR moves this logic into LTO's view of the symbol, which
allows consumers to determine preserved-ness themselves. This was broken
out of #164916; this prevents that PR from introducing a circular
dependency, but it still seems like an independently good idea by virtue
of the above.
2026-01-21 11:32:33 -08:00
Joseph Huber
8a963dd58b
[Binary] Check size of string entries when creating Offload Binaries (#177029)
Summary:
Verify this just in case the input lists more strings than actually
exist.
2026-01-21 09:02:16 -06:00
Nikita Popov
7abe5b73b5
[llvm-readobj][offload] Fix llvm-readobj --all on MachO (#175912)
Currently running llvm-readobj --all on any MachO object asserts,
because it implies --offload, and the --offload extraction includes an
assert on the object format. Instead, we should be silently ignoring.

This regressed in https://github.com/llvm/llvm-project/pull/143342.
2026-01-15 11:55:51 +01:00
Rahul Joshi
d20f617ab8
[NFCI][LLVM] Remove raw_string_ostream::flush calls (#164086)
Remove calls to `flush()` on `raw_string_ostream` objects as they are not needed.
2026-01-13 08:44:48 -08:00
Francesco Petrogalli
75d025124a
[RISCV] Add basic Mach-O triple support. (#141682)
Based on a patch written by Tim Northover (https://github.com/TNorthover).
2026-01-05 23:18:48 +00:00
John Holdsworth
36bed4d0cd
[lld][MachO] Follow-up to use madvise() for threaded file page-in. (#157917)
Further to
https://github.com/llvm/llvm-project/pull/147134#discussion_r2337246489,
switch to use the madvise() api to page in mmap'd files and

1) All new code compiled in #if LLVM_ENABLE_THREADS is set so it can be
seen where the changes were from this PR.
2) The new PR moves to use madvise() instead of the ad-hoc page
referencing code I wrote which should avoid SIGSEGVs if the buffer is
deallocated.
3) A new property SerialBackgroundQueue().stopAllWork to be used to stop
background workers when there is no further call for them. Usually the
background "page-in" threads have completed first but it seems with this
troublesome test this is not always the case and buffers stored in the
static input file cache are being deallocated while being referenced.

---------

Co-authored-by: James Henderson <James.Henderson@sony.com>
2025-11-26 15:14:15 -08:00
Kazu Hirata
30e5f76d73
[llvm] Construct iterator_range with the conversion constructor (NFC) (#168674)
This patch simplifies iterator_range construction with the conversion
constructor.
2025-11-19 07:29:49 -08:00
Owen Anderson
cce852ff03
[Object] Add getRISCVVendorRelocationTypeName to render RISCV vendor-specific relocations to strings. (#168293)
This will be used in places like LLD to render them for error messages.
2025-11-16 16:21:46 -08:00
Kazu Hirata
7a8237bbb6
[llvm] Use llvm::copy (NFC) (#168182)
Identified with llvm-use-ranges.
2025-11-15 08:06:00 -08:00
quic-areg
682c8e22e6
[Hexagon] Add missing build attributes (#166992)
Attributes for v79 and 81 were recorded but ignored.
2025-11-07 15:09:25 -06:00
Greg Clayton
6601c384d3
Fix getting section info in large mach-o files. (#165940)
Mach-o has 32 bit file offsets in the MachO::section_64 structs. dSYM
files can contain sections whose start offset exceeds UINT32_MAX, which
means the MachO::section_64.offset will get truncated. We can calculate
when this happens and properly adjust the section offset to be 64 bit
safe. This means tools can get the correct section contents for large
dSYM files and allows tools that parse DWARF, like llvm-gsymutil, to be
able to load and convert these files correctly.
2025-11-04 09:36:54 -08:00
Jakub Kuderski
4c21d0cb14
[ADT] Prepare to deprecate variadic StringSwitch::Cases. NFC. (#166020)
Update all uses of variadic `.Cases` to use the initializer list
overload instead. I plan to mark variadic `.Cases` as deprecated in a
followup PR.

For more context, see https://github.com/llvm/llvm-project/pull/163117.
2025-11-02 00:12:33 +00:00
Rahman Lavaee
e9368a056d
[SHT_LLVM_BB_ADDR] Implement ELF and YAML support for Propeller CFG data in PGO analysis map. (#164914)
This PR implements the ELF support for PostLink CFG in PGO analysis map
as discussed in
[RFC](https://discourse.llvm.org/t/rfc-extending-the-pgo-analysis-map-with-propeller-cfg-frequencies/88617/2).

A later PR will implement the Codegen Support.
2025-10-30 13:12:06 -07:00
Prabhu Rajasekaran
b7c7083c1f
[llvm] Update call graph ELF section type. (#164461)
Make call graph section to have a dedicated type instead of the generic
progbits type.
2025-10-22 15:08:36 -07:00
wdx727
5eeae08f7e
Adding Matching and Inference Functionality to Propeller (#160706)
We have optimized the implementation of introducing the "matching and
inference" technique into Propeller. In this new implementation, we have
made every effort to avoid introducing new compilation parameters while
ensuring compatibility with Propeller's current usage. Instead of
creating a new profile format, we reused the existing one employed by
Propeller. This new implementation is fully compatible with Propeller's
current usage patterns and reduces the amount of code changes. For
detailed information, please refer to the following RFC:
https://discourse.llvm.org/t/rfc-adding-matching-and-inference-functionality-to-propeller/86238.
We plan to submit the relevant changes in several pull requests (PRs).
The current one is the first PR, which adds the basic block hash to the
SHT_LLVM_BB_ADDR_MAP section.

co-authors: lifengxiang1025 <lifengxiang@kuaishou.com>; zcfh
<wuminghui03@kuaishou.com>

Co-authored-by: lifengxiang1025 <lifengxiang@kuaishou.com>
Co-authored-by: zcfh <wuminghui03@kuaishou.com>
Co-authored-by: Rahman Lavaee <rahmanl@google.com>
2025-10-14 10:34:14 -07:00
小钟
e6358ab75c
Fix typo: IsGlobaLinkage -> IsGlobalLinkage in XCOFF (#161960)
Corrects the spelling of 'IsGlobaLinkage' to 'IsGlobalLinkage' in
XCOFF-related code, comments, and tests across the codebase.
2025-10-12 12:03:40 -07:00
小钟
10021c737a
Fix typo in comment: 'unit64_t' to 'uint64_t' (#162869)
Corrects a typo in comments within XCOFFObjectFile.cpp, changing
'unit64_t' to the correct type 'uint64_t' for clarity.
2025-10-10 17:50:33 +01:00
David Salinas
efda523188
Fix compress/decompress in LLVM Offloading API (#150064)
Co-authored-by: dsalinas_amdeng <david.salinas@amd.com>
2025-10-06 16:34:02 -04:00
Lang Hames
c06aa2e813 Revert "Reapply [MachO] Move getArchTriple impl... with fixes. (#161949)"
This reverts commit 54012102c4a8e8bba9b3b27291dab126e3521544 while I further
investigate bot failures. Apparently adding a dependence on BinaryFormat to
Object was insufficient to fix the original linker issues.
2025-10-04 19:15:08 +10:00
Lang Hames
54012102c4
Reapply [MachO] Move getArchTriple implementation..." with fixes. (#161949)
This reapplies cd32b9b6c3b, which was reverted in 25e02a43fe6 due to bot
failures.

The failures all appear to be link errors due to the Object library not
depending on BinaryFormat. This commit adds the missing dependence.
2025-10-04 18:46:35 +10:00
Lang Hames
25e02a43fe Revert "[MachO] Move getArchTriple implementation into BinaryFormat. (#161468)"
Reverts commit cd32b9b6c3b while I investigate some bot failures, e.g.
https://lab.llvm.org/buildbot/#/builders/10/builds/14784.
2025-10-04 16:59:55 +10:00
Lang Hames
cd32b9b6c3
[MachO] Move getArchTriple implementation into BinaryFormat. (#161468)
There's nothing ObjectFile specific about getArchTriple, so move it into
the BinaryFormat library so that clients can use it without taking a
dependence on libObject.

MachOObjectFile::getArchTriple is updated to call through to the moved
implementation.
2025-10-04 16:33:17 +10:00
Ruoyu Qiu
5cd3db3bed
[llvm][ELF]Add Shdr check for getBuildID (#126537)
Add Section Header check for getBuildID, fix crash with invalid Program
Header.

Fixes: #126418

---------

Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
Signed-off-by: Ruoyu Qiu <qiuruoyu@xiaomi.com>
Co-authored-by: Ruoyu Qiu <qiuruoyu@xiaomi.com>
Co-authored-by: James Henderson <James.Henderson@sony.com>
2025-10-03 10:02:36 +01:00
David Salinas
bdea159093
Revert "Revert "Fix memory leak in Offloading API" (#161465)" (#161573)
This reverts commit d392563433316e310edacf35a40fb2f9aa477acc.
2025-10-01 20:47:47 -04:00
ronlieb
d392563433
Revert "Fix memory leak in Offloading API" (#161465)
Reverts llvm/llvm-project#161430
2025-09-30 21:16:08 -04:00
David Salinas
b80b48d3e8
Fix memory leak in Offloading API (#161430)
Fix or the failing Sanitizer buildbots from PR:
https://github.com/llvm/llvm-project/pull/143342
2025-09-30 18:23:11 -04:00
David Salinas
07f8f088b4
Add --offoading option to llvm-readobj (#143342)
Utilize new extensions to LLVM Offloading API to
handle offloading fatbin Bundles.

The tool will output a list of available offload bundles
using URI syntax.

---------

Co-authored-by: dsalinas_amdeng <david.salinas@amd.com>
2025-09-29 17:16:29 -04:00
Jacek Caban
48a6f2f85c
[Object][Archive] Recompute headers and symbol map when switching from COFF to GNU64 (#160606)
COFF format has no 64-bit version, so we use GNU64 instead. Since this
changes the headers, we need to recalculate everything.

Fixes #160112.
2025-09-28 20:17:01 +02:00
joaosaffran
4ff986af63
[DirectX] Updating DXContainer logic to read version 1.2 of static samplers (#160184)
This PR is updating `Object/DXContainer.h` so that we can read data from
root signature version 1.2, which adds flags into static samplers.
2025-09-26 17:07:45 +00:00
Nico Weber
f847c2a0fa
[Object] Add a missing space to a diagnostic (#159826)
Follow-up to https://reviews.llvm.org/D46527
2025-09-20 13:49:40 -04:00
Joseph Huber
0fa3061c4e
Revert "[ELF][LLDB] Add an nvsass triple (#159459)" (#159879)
Summary:
This patch has broken the `libc` build bot. I could work around that but
the changes seem unnecessary.

This reverts commit 9ba844eb3a21d461c3adc7add7691a076c6992fc.
2025-09-19 20:13:48 -05:00
Walter Erquinigo
9ba844eb3a
[ELF][LLDB] Add an nvsass triple (#159459)
When handling CUDA ELF files via objdump or LLDB, the ELF parser in LLVM
needs to distinguish if an ELF file is sass or not, which requires a
triple for sass to exist in llvm. This patch includes all the necessary
changes for LLDB and objdump to correctly identify these files with the
correct triple.
2025-09-19 14:14:20 -04:00
Stanislav Mekhanoshin
e556dc0b23
[AMDGPU] Add gfx1251 subtarget (#159430) 2025-09-17 13:02:02 -07:00
Joseph Huber
dffd7f3d9a
[LLVM] Fix offload and update CUDA ABI for all SM values (#159354)
Summary:
Turns out the new CUDA ABI now applies retroactively to all the other
SMs if you upgrade to CUDA 13.0. This patch changes the scheme, keeping
all the SM flags consistent but using an offset.

Fixes: https://github.com/llvm/llvm-project/issues/159088
2025-09-17 14:39:39 -05:00
Daniel Kuts
e8028b2ecb
[llvm] Validate Parent object before dereference (#157460)
Fixes #157449
2025-09-17 07:54:41 +01:00
Matt Arsenault
67823469bd
MC: Add Triple overloads for more MC constructors (#157321)
Avoids more Triple->string->Triple round trip. This
is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
2025-09-08 03:41:22 +00:00
Rahman Lavaee
a61ff1487b
[SHT_LLVM_BB_ADDR_MAP] Change the callsite feature to emit end of callsites. (#155041)
This PR simply moves the callsite anchors from the beginning of
callsites to their end.

Emitting the end of callsites is more sensible as it allows breaking the
basic block into subblocks which end with control transfer instructions.
2025-08-25 10:17:29 -07:00
Matt Arsenault
65d12622fa
RuntimeLibcalls: Add entries for stackprotector globals (#154930)
Add entries for_stack_chk_guard, __ssp_canary_word, __security_cookie,
and __guard_local. As far as I can tell these are all just different
names for the same shaped functionality on different systems.

These aren't really functions, but special global variable names. They
should probably be treated the same way; all the same contexts that
need to know about emittable function names also need to know about
this. This avoids a special case check in IRSymtab.

This isn't a complete change, there's a lot more cleanup which
should be done. The stack protector configuration system is a
complete mess. There are multiple overlapping controls, used in
3 different places. Some of the target control implementations overlap
with conditions used in the emission points, and some use correlated
but not identical conditions in different contexts.

i.e. useLoadStackGuardNode, getIRStackGuard, getSSPStackGuardCheck and
insertSSPDeclarations are all used in inconsistent ways so I don't know
if I've tracked the intention of the system correctly.

The PowerPC test change is a bug fix on linux. Previously the manual
conditions were based around !isOSOpenBSD, which is not the condition
where __stack_chk_guard are used. Now getSDagStackGuard returns the
proper global reference, resulting in LOAD_STACK_GUARD getting a
MachineMemOperand which allows scheduling.
2025-08-23 10:21:00 +09:00
Matt Arsenault
3e5d8a1439 Reapply "RuntimeLibcalls: Generate table of libcall name lengths (#153… (#153864)
This reverts commit 334e9bf2dd01fbbfe785624c0de477b725cde6f2.

Check if llvm-nm exists before building the benchmark.
2025-08-16 09:53:50 +09:00
gulfemsavrun
334e9bf2dd
Revert "RuntimeLibcalls: Generate table of libcall name lengths (#153… (#153864)
…210)"

This reverts commit 9a14b1d254a43dc0d4445c3ffa3d393bca007ba3.

Revert "RuntimeLibcalls: Return StringRef for libcall names (#153209)"

This reverts commit cb1228fbd535b8f9fe78505a15292b0ba23b17de.

Revert "TableGen: Emit statically generated hash table for runtime
libcalls (#150192)"

This reverts commit 769a9058c8d04fc920994f6a5bbb03c8a4fbcd05.

Reverted three changes because of a CMake error while building llvm-nm
as reported in the following PR:
https://github.com/llvm/llvm-project/pull/150192#issuecomment-3192223073
2025-08-15 13:32:27 -07:00
Sterling-Augustine
5b0619e79b
Move function info word into its own data structure (#153627)
The sframe generator needs to construct this word separately from FDEs
themselves, so split them into a separate data structure.
2025-08-15 13:16:34 -07:00