916 Commits

Author SHA1 Message Date
Min-Yih Hsu
696ea11b94
[ELFDebugObjectPlugin] Do not wait for std::future in post-fixup phase in the absent of debug info (#178541)
If there is no debug information, we wouldn't call
`DebugObject::collectTargetAlloc` in the post-allocation phase.
Therefore, when it's in the post-fixup phase,
`DebugObject::awaitTargetMem` will fail with _"std::future_error: No
associated state"_ because the std::future was not even populated.
2026-01-29 18:24:25 +00:00
Lang Hames
92aa47a9f7
[JITLink][x86-64] Add testcase for ELF LinkGraph triple fix. (#176707)
Adds a testcase for the fix in ba6a59c8750.
2026-01-20 10:30:49 +11:00
hev
9c7904bac2
[JITLink][LoongArch] Add reloc types for LA32R/LA32S (#175353) 2026-01-14 18:03:56 +08:00
hev
c9cc782e0b
[llvm][LoongArch] Add PC-relative address materialization using pcadd instructions (#175358)
This patch adds support for PC-relative address materialization using
pcadd-class relocations, covering the HI20/LO12 pair and their GOT and
TLS variants (IE, LD, GD, and DESC).

Link:
https://gcc.gnu.org/pipermail/gcc-patches/2025-December/703312.html
2026-01-14 16:12:18 +08:00
Lang Hames
552a696a71
[llvm-jitlink] Remove flaky testcase. (#175680)
On some systems, backtraces contain addresses with their high bits set*.
These high bits prevent symbolication using the JIT symbol table. Since
this test is for a best-effort debugging / diagnosis tool it seems best
to remove the test until/unless we can get it passing on all systems, or
find some way to identify systems that will fail.

See discussion in https://github.com/llvm/llvm-project/pull/175537.

* Note that the test does not use PAC or pointer tagging -- the high
bits are coming from somewhere else. Possibly libunwind, but that is
just speculation.
2026-01-13 11:32:58 +11:00
anoopkg6
ab34189878
[JITLink] Add GOT indirection optimization for SystemZ (#171919)
Optimize the GOT and Stub relocations if the edge target address is in
range from call site - Indirect jump by plt stub can be replaced with
direct jump to target in post-allocation optimization.
2026-01-12 17:47:13 +01:00
Lang Hames
0275c9fa5f
[llvm-jitlink] Remove build_version directive. (#175523)
Fixes a warning on some bots.
2026-01-13 00:13:30 +11:00
Lang Hames
ce4fcfc9e4
[llvm-jitlink] Make -show-addrs work without -check, fix fallout. (#175491)
Ensures that the address scraping passes are added to the JIT linker pipeline
if either of the -check or -show-addrs are passed. Prior to this commit we only
considered -check, so passing -show-addrs on its own was printing an empty
(unpopulated) symbol table.

This change exposed bugs in RuntimeDyldChecker's `MemoryRegionInfo` type, aned
llvm-jitlink's symbol printing code:

 - `MemoryRegionInfo` was assuming that zero-sized symbols wouldn't be defined
   and was using Size == 0 as a proxy for "region info uninitialized". This was
   triggering assertions for valid LinkGraphs containing zero-sized symbols.

 - llvm-jitlink's symbol printing code was assuming that all defined symbols
   contained content, and was not correctly handling zero-fill / absolute
   symbols. This triggered assertions about requesting content addresses for
   non-content symbols.

This commit fixes the issues above, and adds both a generic testcase for the
-show-addrs option, and an ELF-specific testcase with a zero-sized symbol to
check that the option works for such symbols.
2026-01-13 00:13:12 +11:00
Lang Hames
187ca8609a
Reapply "[llvm-jitlink] Replace IR backtrace symbolication test..." (… (#175476)
…#175242)

This reapplies 451ca458cf51d553f5c49e67d841280e8166f933, which was
reverted in 25976e83606f1a7615e3725e6038bb53ee96c3d5 due to bot
failures.

The REQUIRES line has been further constrained to try to address the
failures.
2026-01-12 14:14:40 +11:00
Aiden Grossman
c11df52f9b Revert "[ORC] Add utilities for limited symbolication of JIT backtraces (#175099)"
This reverts commit 906b48616c03948a4df62a5a144f7108f3c455e8.

The forward fix for this got reverted in
25976e83606f1a7615e3725e6038bb53ee96c3d5, so reverting the original
commit given it is still broken and the forward fix that mitigated most
of the issues is no longer in tree.
2026-01-09 22:13:57 +00:00
Daniel Thornburgh
25976e8360
Revert "[llvm-jitlink] Replace IR backtrace symbolication testcase with asm." (#175242)
Reverts llvm/llvm-project#175117
2026-01-09 21:17:45 +00:00
Lang Hames
451ca458cf
[llvm-jitlink] Replace IR backtrace symbolication testcase with asm. (#175117)
Some builds (e.g.
https://lab.llvm.org/buildbot/#/builders/154/builds/26180) failed for
this testcase, for reasons that aren't immediately clear from the logs.

Since the options being tested are for debugging only, this commit
switches to testing Darwin/arm64 only.

Whne similar backtrace symbolication options are added to lli we can
reintroduce a generic testcase and start investigating these failures.
2026-01-09 16:45:11 +11:00
Lang Hames
906b48616c
[ORC] Add utilities for limited symbolication of JIT backtraces (#175099)
This patch adds tools for capturing symbol information from JIT'd code
and using it to symbolicate backtraces. This is useful for debugging
crashes in JIT-compiled code where traditional symbolication tools may
not have access to the JIT symbol table. These tools are not a general
solution to the JIT symbolication problem (that will require further
integration with system components like libunwind, the dynamic linker,
and/or crash tracing tools), but will aid in JIT debugging and
development until a general solution is available.

APIs Added:

1. SymbolTableDumpPlugin - A LinkGraphLinkingLayer::Plugin that captures
symbol information as code is JIT'd and writes it to a file.

- Create(StringRef Path) ->
Expected<std::shared_ptr<SymbolTableDumpPlugin>> Creates a plugin that
appends symbol information to the specified file.

- Symbol table format: "<link graph name>" <address> <symbol name>
<address> <symbol name> ...

The plugin uses a PostAllocationPass to write symbols after addresses
have
   been assigned but before the code is finalized.

2. DumpedSymbolTable - A class for symbolicating backtraces using a
previously dumped symbol table.

- Create(StringRef Path) -> Expected<DumpedSymbolTable> Loads and parses
a symbol table from a file.

- symbolicate(StringRef Backtrace) -> std::string Given text of a
backtrace, for rows ending with a hex address, adds the symbol name,
offset, and defining graph name.

New `llvm-jitlink` Command Line Options:

1. -write-symtab=<path> Enables the SymbolTableDumpPlugin to write
symbol information to the specified file as objects are JIT'd. The
symbol table can then be used to symbolicate backtraces from crashes or
signal handlers.

2. -symbolicate-with=<path> Runs llvm-jitlink in symbolication mode.
Reads the symbol table from <path> and symbolicates backtraces read from
stdin or input files.

Usage Examples:

$ llvm-jitlink -write-symtab=symbols.txt mycode.o

$ llvm-jitlink -symbolicate-with=symbols.txt - < backtrace.txt
2026-01-09 15:42:00 +11:00
Stefan Gränitz
1d8a9ed15c [lli] Run test for debug descriptors on Linux only (#167860) 2025-12-18 18:33:35 +01:00
Stefan Gränitz
bdc822d2cf
[lli] Honor --jit-linker-kind=rtdyld on platforms that default to jitlink (#167860)
So far, the setting enforced only jitlink but not rtdyld. We get better
test coverage now that we honor both cases. We drop EPC-based execution
on the way, because with ORC lli always executes in-process.
2025-12-18 13:53:31 +01:00
anoopkg6
7e43715477
[JITLINK] Disable ELF_ppc64_relocations.s on SystemZ host (#168939)
Mark ELF_ppc64_relocations.s as unsupported on SystemZ because of cross
build issue related to using dlsym for host symbols.
Test fails to resolve __tls_get_aadr on SystemZ host.

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-11-20 21:50:16 +01:00
Lang Hames
4b0d422753
[ORC] Support scanning "fallback" slices for interfaces. (#168472)
When scanning an interface source (dylib or TBD file), consider
"fallback" architectures (CPUType / CPUSubType pairs) in addition to the
process's CPUType / CPUSubType.

Background:

When dyld loads a dylib into a process it may load dylib or slice whose
CPU type / subtype isn't an exact match for the process's CPU type /
subtype. E.g. arm64 processes can load arm64e dylibs / slices.

When building an interface we need to follow the same logic, otherwise
we risk generating a spurious "does not contain a compatible slice"
error. E.g. If we're running an arm64 JIT'd program and loading an
interface from a TBD file, and if no arm64 slice is present in that
file, then we should fall back to looking for an arm64e slice.

rdar://164510783
2025-11-18 13:54:02 +11:00
Lang Hames
998dd1b233
[JITLink][MachO][AArch64] Specify endianness, fix name of testcase. (#168323)
The "MachO_ptrauth_noolloc_sections.yaml" testcase had a typo in the
name, and didn't explicitly specify its endianness. This was causing it
to fail when enabled on big endian platforms.

See conversation in https://github.com/llvm/llvm-project/pull/167902
2025-11-17 18:59:56 +11:00
anoopkg6
b07f8b0d98
[JITLINK] Fix large offset issue (#167600)
Removed large offset test. It caused issue with ARM 32-bit because of
large offset.

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-11-12 00:46:30 +01:00
anoopkg6
93b71e6162
Llvm jitlink build failure (#167561)
Fixed stub relocation test. Just need to check 32-bit.

---------

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-11-11 19:51:45 +01:00
anoopkg6
82180558fe
JITLink: Add initial SystemZ Support. (#144528)
Set up initial infrastructure for SystemZ architecture support in
JITLink. It includes features like GOT and PLT handling. Relaxation of
GOT/PLT and support for TLS were intentionally left out for the moment.

Support for TLS might require info regarding moduleID. This could
further mean changes to target independent part of JITLink and library
support.

---------

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-11-11 18:05:42 +01:00
Lang Hames
9173846640
Reapply "[ORC] Replace ORC's baked-in dependence ... (#163027)" with … (#164340)
…fixes.

This reapplies c8c86efbbb5, which was reverted in 13ca8723d1b due to bot
failures. Those failures were compilation errors exposed when LLVM is
built with LLVM_ENABLE_EXPENSIVE_CHECKS=On. They have been fixed in this
commit.
2025-10-20 17:40:01 -07:00
Lang Hames
13ca8723d1 Revert "[ORC] Replace ORC's baked-in dependence tracking ... (#163027)"
Reverts commit c8c86efbbb55e51597c1bd8feb2e947bc0de3422 while I investigate bot
failures, e.g. https://lab.llvm.org/buildbot/#/builders/187/builds/12743.
2025-10-20 16:20:37 -07:00
Lang Hames
c8c86efbbb
[ORC] Replace ORC's baked-in dependence tracking with WaitingOnGraph. (#163027)
WaitingOnGraph tracks waiting-on relationships between nodes (intended
to represent symbols in an ORC program) in order to identify nodes that
are *Ready* (i.e. are not waiting on any other nodes) or have *Failed*
(are waiting on some node that cannot be produced).

WaitingOnGraph replaces ORC's baked-in data structures that were
tracking the same information (EmissionDepUnit, EmissionDepUnitInfo,
...). Isolating this information in a separate data structure simplifies
the code, allows us to unit test it, and simplifies performance testing.

The WaitingOnGraph uses several techniques to improve performance
relative to the old data structures, including symbol coalescing
("SuperNodes") and symbol keys that don't perform unnecessary reference
counting (NonOwningSymbolStringPtr).

This commit includes unit tests for common dependence-tracking issues
that have led to ORC bugs in the past.
2025-10-20 15:59:56 -07:00
Lang Hames
05a49dac85
[llvm-jitlink] Use MachOObjectFile::getArchTriple for triple identifi… (#161799)
…cation.

Replaces a call to ObjectFile::makeTriple (still used for ELF and COFF)
with a call to MachOObjectFile::getArchTriple. The latter knows how to
build correct triples for different MachO CPU subtypes, e.g. arm64 vs
arm64e, which is important for selecting the right slice from universal
archives.
2025-10-03 17:45:16 +10:00
Lang Hames
a7016c43da
[JITLink] Add LinkGraph name / triple to debugging output. (#161772)
Adds the name and triple of the graph to LinkGraph::dump output before
the rest of the graph content. Calls from JITLinkGeneric.cpp to dump the
graph are updated to avoid redundantly naming the graph.
2025-10-03 15:24:29 +10:00
Zhijin Zeng
7a58e77143
[JITLink][RISC-V] Support R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128 (#153778)
Support bolt instrument the elf binary which has exception handling table.

Fixes #153775
2025-09-09 17:51:30 +08:00
Jamie Schmeiser
417bdb6672
Mark ExecutionEngine/JITLink and ExecutionEngine/Orc as unsupported on AIX (#156076)
Create ExecutionEngine/JitLink/lit.local.cfg and
ExecutionEngine/Orc/lit.local.cfg and use them to mark tests as
unsupported on AIX.
2025-09-02 09:38:41 -04:00
jeremyd2019
dfbf13cded
[LLVM] adjust lit.cfg.py for Cygwin (#151416)
Cygwin is like Windows in that it uses COFF, and doesn't emit
.debug_frame on 64-bit architectures.

However, if -elf is appended to the target triple on Cygwin MCJIT remote
tests fail due to `__register_frame` not being defined. Only one test
fails without -elf that succeeds with it, so mark just that test as
XFAIL on Cygwin.
2025-08-02 10:31:46 -07:00
Aiden Grossman
6ba25c1a56
[llvm] Remove uses of %T in tests (#151621)
This patch removes all uses of %T from within LLVM tests. %T has been
deprecated for about seven years and use is not advised given it is not
unique per test and can thus lead to races. The goal of this is to
eventually remove support for %T from lit.
2025-08-01 08:24:56 -07:00
Ami-zhang
4e35ae10c4
[RuntimeDyld][LoongArch] Support large code model (#148584)
Co-authored-by: Weining Lu <luweining@loongson.cn>
2025-07-21 09:28:24 +08:00
Maksim Panchenko
0c33799e37
[JITLink] Include target addend in out-of-range error (#145423)
When JITLink reports an out-of-range error, the underlying reason could
be hidden from the user if it's due to an excessively large target
addend. Add non-zero target addend to the message for clarity.
2025-06-23 22:46:15 -07:00
Lang Hames
d6a486c221
[ORC] Apply MachO::CPU_SUBTYPE_MASK to comparison in getDylibInterfac… (#145154)
…eFromDylib.

When comparing CPU subtypes from slices in a MachO universal binary we
need to apply the MachO::CPU_SUBTYPE_MASK to mask out any flags in the
high bits, otherwise we might fail to correctly match a slice and return
a spurious "does not contain slice" error.

rdar://153913779
2025-06-21 19:31:51 +10:00
Martin Storsjö
902d6894f5 [JITLink] [test] Add a trailing newline to a test file. NFC.
Otherwise, this shows up as an unrelated diff after editing the
file in some editors (like vim).
2025-06-10 12:08:24 +03:00
Martin Storsjö
f715ff4a9d
[JITLink] [test] Generalize UNSUPPORTED markings for Windows/arm64 (#142377)
Don't needlessly specify the vendor field as "pc"; in MinGW
configurations, the vendor field is often "w64".
2025-06-10 12:06:29 +03:00
Martin Storsjö
9b282afb8a
[JITLink] [test] Extend preexisting MinGW XFAILs to new tests (#142375)
This extends the preexisting XFAILs from
4c642b62b99fa128c180f28278637b32be5e5576 to these new tests from
6fa8657a622173c177d863b763550de4d388f73c.
2025-06-10 12:05:16 +03:00
jeremyd2019
d34b392dad
[LLVM][Tests] remove %exeext from lli-child-target parameter. (#143077)
Its presence seems to actively hinder the ToolSubst mechanism that was
supposed to fill in the path to the tool, which prevented these tests
from working on Cygwin.
2025-06-08 20:52:05 +03:00
Sam Elliott
65077c7ac7
[RISCV] Remove -riscv-asm-relax-branches flag (#142855)
This flag has been superseded by `.option exact`, as the test updates
show.

Given the flag was always hidden, it makes sense to me to remove it, and
move tests that required it to use `.option exact`.
2025-06-06 15:23:31 -07:00
Lang Hames
fe40f97afe [JITLink] Disable the all-load- tests on Windows/arm64.
We don't have a JITLink Windows/arm64 backend yet, so disable these tests
there.
2025-05-30 09:33:45 +10:00
Lang Hames
e2d646226c Re-apply "[ORC] Add optional context string to duplicate symbol definition..."
This reapplies b0979b8c65d, which was reverted in 370aecb9572 due to bot
failures. The failures were caused by typos in the testcase that are fixed in
this patch.
2025-05-28 10:38:18 +10:00
Lang Hames
6fa8657a62
[ORC] Refactor visit-members in StaticLibraryDefinitionGenerator. (#141546)
This refactor was motivated by two bugs identified in out-of-tree
builds:

1. Some implementations of the VisitMembersFunction type (often used to	
implement special loading semantics, e.g. -all_load or -ObjC) were assuming
that buffers for archive members were null-terminated, which they are not in
general. This was triggering occasional assertions.

2. Archives may include multiple members with the same file name, e.g.
when constructed by appending files with the same name:
  % llvm-ar crs libfoo.a foo.o
  % llvm-ar q libfoo.a foo.o
  % llvm-ar t libfoo.a foo.o
  foo.o

   While confusing, these members may be safe to link (provided that they're
   individually valid and don't define duplicate symbols). In ORC however, the
   archive member name may be used to construct an ORC initializer symbol,
   which must also be unique. In that case the duplicate member names lead to a
   duplicate definition error even if the members define unrelated symbols.

In addition to these bugs, StaticLibraryDefinitionGenerator had grown a
collection of all member buffers (ObjectFilesMap), a BumpPtrAllocator
that was redundantly storing synthesized archive member names (these are
copied into the MemoryBuffers created for each Object, but were never
freed in the allocator), and a set of COFF-specific import files.

To fix the bugs above and simplify StaticLibraryDefinitionGenerator this
patch makes the following changes:

1. StaticLibraryDefinitionGenerator::VisitMembersFunction is generalized
   to take a reference to the containing archive, and the index of the
   member within the archive. It now returns an Expected<bool> indicating
   whether the member visited should be treated as loadable, not loadable,
   or as invalidating the entire archive.
2. A static StaticLibraryDefinitionGenerator::createMemberBuffer method
   is added which creates MemoryBuffers with unique names of the form
   `<archive-name>[<index>](<member-name>)`. This defers construction of
   member names until they're loaded, allowing the BumpPtrAllocator (with
   its redundant name storage) to be removed.
3. The ObjectFilesMap (symbol name -> memory-buffer-ref) is replaced
   with a SymbolToMemberIndexMap (symbol name -> index) which should be
   smaller and faster to construct.
4. The 'loadability' result from VisitMemberFunctions is now taken into
   consideration when building the SymbolToMemberIndexMap so that members
   that have already been loaded / filtered out can be skipped, and do not
   take up any ongoing space.
5. The COFF ImportedDynamicLibraries member is moved out into the
   COFFImportFileScanner utility, which can be used as a
   VisitMemberFunction.

This fixes the bugs described above; and should lower memory consumption
slightly, especially for archives with many files and / or symbol where
most files are eventually loaded.
2025-05-27 20:58:53 +10:00
Michael Kruse
ddf1249842
[Test] Disable Linux perf test under WSL (#137822)
Linux perf_events is not implemented in WSL1, skip the test that
requires it.

There is just a single test that requires perf_events. It fails under
WSL1 with:
```sh
env JITDUMPDIR=/home/meinersbur/build/llvm-project/release/test/ExecutionEngine/JITLink/x86-64/Output/ELF_perf.s.tmp /home/meinersbur/build/llvm-project/release/bin/llvm-jitlink -perf-support /home/meinersbur/build/llvm-project/release/test/ExecutionEngine/JITLink/x86-64/Output/ELF_perf.s.tmp/ELF_x86-64_perf.o
llvm-jitlink error: PerfState not initialized
```

WSL environment detection logic follows
https://github.com/scivision/detect-windows-subsystem-for-linux/blob/main/is_wsl.py

Also see WSL issue: https://github.com/microsoft/WSL/issues/4595
2025-05-13 13:35:08 +02:00
JP Lehr
370aecb957 Revert "[ORC] Add optional context string to duplicate symbol definition errors."
Broke buildbots: https://lab.llvm.org/buildbot/#/builders/10/builds/5025

This reverts commit b0979b8c65d76cc1897e97b9ad091d8d99abdd18.
2025-05-09 04:18:02 -05:00
Lang Hames
b0979b8c65 [ORC] Add optional context string to duplicate symbol definition errors.
The context string can be added to indicate the source of the duplicate
definition. E.g. if the context is set to "foo2.o", then:

"Duplicate definition of symbol 'foo'"

becomes

"In foo2.o, duplicate definition of symbol 'foo'".

The JITDylib::defineImpl method is updated to use the name of the
MaterializationUnit being added as the context string for duplicate definition
errors. The JITDylib::defineMaterializing method is updated to use
"defineMaterializing operation" as the conext string.
2025-05-09 17:30:42 +10:00
Lang Hames
b972164f38 [JITLink] Rename 'i386' namespace and files to 'x86'.
When building on i386, both clang and gcc define a builtin 'i386' macro (see
discussion in https://github.com/llvm/llvm-project/pull/137063). This causes
build errors in the JITLink/i386 backend when attempting to build LLVM on i386.

This commit renames the 'i386' backend (namespaces, APIs and files) to 'x86' to
avoid this issue.
2025-05-08 11:35:14 +10:00
Lang Hames
32f514c68d [JITLink][i386] Support R_386_GOT32X using existing non-relaxable edge kind.
R_386_GOT32 was already handled by lowering to
EdgeKind_i386::RequestGOTAndTransformToDelta32FromGOT. R_386_GOT32X is just an
optionally relaxable version of R_386_GOT32, so we can lower to the same edge
kind.

I've left a TODO to add a relaxable edge kind and update the i386 relaxation
optimization in the future, though I'll probably leave this as an exercise for
any i386 aficionados out there. ;)
2025-05-08 10:07:44 +10:00
Martin Storsjö
724eea7654
[llvm][test] Change an XFAIL into a more correct REQUIRES (#137942)
As this test is about executing x86_64 code with "lli", we should only
try to do it if we actually execute on an x86_64 target. So instead of
XFAILing individual architectures that can't execute it, instead change
this into requiring an x86_64 target.

Also generalize the target triple form used; don't assume that the
vendor field is set to "pc" - many mingw toolchains use the vendor field
set to "w64".
2025-05-01 15:27:29 +03:00
Henry Jiang
7d3dfc862d
[JITLink][XCOFF] Setup initial build support for XCOFF (#127266)
This patch starts the initial implementation of JITLink for XCOFF (Object format for AIX).
2025-04-03 17:01:18 -04:00
Lang Hames
191e0622e8 [JITLink][MachO][arm64] Don't lower ptrauth edges in noalloc-lifetime sections.
Ptrauth relocations can only be fixed up in the executing process, but noalloc
sections do not have any memory in the executing process. Failure to skip
ptrauth edges results in signing instructions that operate on invalid addresses,
leading to segfaults or data corruption.

Ignoring noalloc sections for ptrauth lowering purposes allows the ptrauth
edges to persist until they reach the applyFixup method, at which point they
raise a useful error and cleanly terminate linking.
2025-04-01 22:18:00 +11:00
Lang Hames
14c36db16f [ORC] Generalize GetDylibInterface to support MachO Universal Binaries.
Also adds a testcase for dylib handling in llvm-jitlink`s -weak-lx and
-weak_library options.
2025-03-28 13:28:04 +11:00