15837 Commits

Author SHA1 Message Date
Lang Hames
b18e5b6a36 Re-apply "[ORC] Remove the Triple argument from LLJITBuilder::..." with fixes.
This re-applies f905bf3e1ef860c4d6fe67fb64901b6bbe698a91, which was reverted in
c861c1a046eb8c1e546a8767e0010904a3c8c385 due to compiler errors, with a fix for
MLIR.
2025-03-06 17:17:05 +11:00
Lang Hames
c861c1a046 Revert "[ORC] Remove the Triple argument from LLJITBuilder::ObjectLinking..."
This reverts commit f905bf3e1ef860c4d6fe67fb64901b6bbe698a91 while I fix
some compile errors reported on the buildbots (see e.g.
https://lab.llvm.org/buildbot/#/builders/53/builds/13369).
2025-03-06 16:22:39 +11:00
Lang Hames
f905bf3e1e [ORC] Remove the Triple argument from LLJITBuilder::ObjectLinkingLayerCreator.
ExecutionSession can provide the Triple, so this argument has been redundant
for a while, and no in-tree clients use it.
2025-03-06 16:13:10 +11:00
Mircea Trofin
5223ddd83f
[ctxprof] Prepare profile format for flat profiles (#129626)
The profile format has now a separate section called "Contexts" - there will be a corresponding one for flat profiles. The root has a separate tag because, in addition to not having a callsite ID as all the other context nodes have under it, it will have additional fields in subsequent patches.

The rest of this patch amounts to a bit of refactorings in the reader/writer (for better reuse later) and tests fixups.
2025-03-05 07:22:35 -08:00
Cyndy Ishida
b41baafbc7
[readtapi] Condense output when comparing tbd files with mismatched inlined libraries (#129754)
Previously, when an inlined library existed in TBD file A but not in file B, all of the inlined library's attributes were printed. This is noisy since the important detail is the complete contents are missing. Instead, only print the install name of the inlined library and the marker for which the input file exists in.
2025-03-04 17:05:01 -08:00
Mircea Trofin
2068a18c86
[ctxprof][nfc] Prepare CtxProfAnalysis for flat profiles (#129623)
Mostly remove the equivalence "no contexts == no CtxProfAnalysis result", and instead check explicitly there are no contextual profiles.
2025-03-04 16:42:47 -08:00
Nick Fitzgerald
6018930ef1
[lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942)
This commit adds support for WebAssembly's custom-page-sizes proposal to
`wasm-ld`. An overview of the proposal can be found
[here](https://github.com/WebAssembly/custom-page-sizes/blob/main/proposals/custom-page-sizes/Overview.md).
In a sentence, it allows customizing a Wasm memory's page size, enabling
Wasm to target environments with less than 64KiB of memory (the default
Wasm page size) available for Wasm memories.

This commit contains the following:

* Adds a `--page-size=N` CLI flag to `wasm-ld` for configuring the
linked Wasm binary's linear memory's page size.

* When the page size is configured to a non-default value, then the
final Wasm binary will use the encodings defined in the
custom-page-sizes proposal to declare the linear memory's page size.

* Defines a `__wasm_first_page_end` symbol, whose address points to the
first page in the Wasm linear memory, a.k.a. is the Wasm memory's page
size. This allows writing code that is compatible with any page size,
and doesn't require re-compiling its object code. At the same time,
because it just lowers to a constant rather than a memory access or
something, it enables link-time optimization.

* Adds tests for these new features.

r? @sbc100 

cc @sunfishcode
2025-03-04 09:39:30 -08:00
AnastasiyaChernikova
0fcbf148df
[Exegesis] Implemented strategy for load operation (#113458)
This fix helps to map operand memory to destination registers. If
instruction is load, we can self-alias it in case when instruction
overrides whole address register. For that we use provided scratch
memory.
2025-03-04 13:16:55 +03:00
Kazu Hirata
65330e20b1
[llvm-readobj] Avoid repeated hash lookups (NFC) (#129657) 2025-03-04 01:50:50 -08:00
Kazu Hirata
c61c888628
[llvm-mca] Avoid repeated hash lookups (NFC) (#129656) 2025-03-04 00:08:51 -08:00
chrisPyr
71f4c7dabe
[NFC]Make file-local cl::opt global variables static (#126486)
#125983
2025-03-03 13:46:33 +07:00
Akshat Oke
aa1fe57b19
[RegAlloc][NewPM] Plug Greedy RA in codegen pipeline (#120557)
Use `-passes="regallocgreedy<[all|sgpr|wwm|vgpr]>` to insert the greedy
RA with a filter and `-regalloc-npm=<type>` to control which RA to use
in existing pipeline.
2025-03-03 11:06:15 +05:30
Fangrui Song
60486292b7 [MC] Move MIPS-specific gprel/tprel/dtprel from MCStreamer to MipsTargetStreamer
https://reviews.llvm.org/D23669 inappropriately added MIPS-specific
dtprel/tprel directives to MCStreamer. In addition,
llvm-mc -filetype=null parsing these directives will crash.
This patch moves these functions to MipsTargetStreamer and fixes
-filetype=null.

gprel32 and gprel64, called by AsmPrinter, are moved to
MCTargetStreamer.
2025-03-02 14:59:21 -08:00
Kazu Hirata
4b3f0fa7e7
[llvm-jitlink] Avoid repeated hash lookups (NFC) (#129422) 2025-03-02 01:12:33 -08:00
Min Hsu
8c5cd77322 [Exegesis][RISCV] Add missing linked components
LLVMExegesisRISCV should link against MC and TargetParser as well.
2025-02-28 13:04:33 -08:00
Min-Yih Hsu
c253e5c991
[Exegesis][RISCV] Add initial RVV support (#128767)
This patch adds initial vector extension support to RISC-V's exegesis.
The strategy here is to enumerate all RVV _pseudo_ opcodes as their MC
opcode counterparts are kind of useless under this circumstance. We also
enumerate all possible VTYPE operands in each CodeTemplate
configuration. Various of MachineFunction Passes are used for post
processing the snippets, like inserting VSETVLI instructions.

See https://llvm.org/devmtg/2024-10/slides/techtalk/Hsu-RVV-Exegesis.pdf
for more technical details.
2025-02-28 11:23:16 -08:00
Fangrui Song
7c26356703
[llvm-objdump] Rework .gnu.version_d dumping
and fix crash when vd_aux is invalid (#86611).

vd_version, vd_flags, vd_ndx, and vd_cnt in Elf{32,64}_Verdef are
16-bit. Change VerDef to use uint16_t instead.

vda_name specifies a NUL-terminated string. Update getVersionDefinitions
to remove some `.c_str()`.

Pull Request: https://github.com/llvm/llvm-project/pull/128434
2025-02-28 09:38:48 -08:00
Lang Hames
5114b9b386 [ORC][llvm-jitlink] Extend weak-linking emulation to real dylibs.
Commit 253e11695ba added support for emulating weak-linking against dylibs
that are (under the emulation) absent at runtime. This commit extends emulated
weak linking support to allow a real dylib to supply the interface (i.e.
-weak-lx / -weak_library can be pointed at a dylib, in which case they should
be read as "weak-link against this dylib, behavining as if it weren't actually
present at runtime").
2025-02-25 19:53:31 +11:00
Vitaly Buka
e67cd152cf [llvm-size] Initialize Radix to correct value (#128447)
Without the patch, invalid --radix, makes Radix to be 0, and result
in invalid format specifier ` %#7 `, instead of e.g ` %#7x `.
2025-02-24 23:08:48 -08:00
Lang Hames
253e11695b [ORC][llvm-jitlink] Add support for emulating ld64 -weak-lx / -weak_library.
Linking libraries in ld64 with -weak-lx / -weak_library causes all references
to symbols in those libraries to be made weak, allowing the librarie to be
missing at runtime.

This patch extends EPCDynamicLibrarySearchGenerator with support for emulating
this behavior: If an instance is constructed with an Allow predicate but no
dylib handle then all symbols matching the predicate are immediately resolved
to null.

The llvm-jitlink tool is updated with -weak-lx / -weak_library options for
testing. Unlike their ld64 counterparts these options take a TBD file as input,
and always resolve all exports in the TBD file to null.
2025-02-25 13:54:17 +11:00
Hood Chatham
cc7f22ee6c
[object][WebAssembly] Add support for RUNTIME_PATH to yaml2obj and obj2yaml (#126080)
This is the first step of adding RPATH support for wasm. 

See corresponding update to the WebAssembly/tool-conventions repo on dynamic
linking: https://github.com/WebAssembly/tool-conventions/pull/246
2025-02-24 09:15:41 -08:00
Ruoyu Qiu
5a2bee04d0
[llvm-objdump]Correct .dynstr finding of getDynamicStrTab() (#127975)
The dynamic string table used by the dynamic section is referenced by
the sh_link field of that section, so we should use that directly,
rather than going via the dynamic symbol table.
More info:
https://github.com/llvm/llvm-project/pull/125679#discussion_r1961333454

Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
2025-02-24 10:39:40 +00:00
Kazu Hirata
929d70a38d
[llvm-jitlink] Avoid repeated hash lookups (NFC) (#128399) 2025-02-23 01:05:13 -08:00
Lang Hames
33f2686bed [llvm-jitlink] Only use candidate library extensions during library search.
While processing library link options that check search paths (-lx, -hidden-lx,
etc.) we shouldn't generate candidate paths with extensions that are invalid
for the option being visited (e.g. -hidden-lx only applies to archives, so we
shouldn't generate candidates with `.so` extensions).

Note: Candidate extensions should probably be further filtered based on the OS
of the executing process. This patch is a step in the right direction though.
2025-02-23 18:16:10 +11:00
ur4t
62c78919c6
[CMake] Fix some breakages when using ninja multi config (#65451)
When using multi-config generator to build `libLLVM.so` like `cmake -G
'Ninja Multi-Config' -Sllvm -B/tmp/out/ninja-multi
-DCMAKE_CONFIGURATION_TYPES='Debug;Release' -DLLVM_LINK_LLVM_DYLIB=on
-DLLVM_TARGETS_TO_BUILD=host && cmake --build /tmp/out/ninja-multi
--config Debug`, `lld` complains `error: cannot find version script
/tmp/out/ninja-multi/Debug/lib/tools/llvm-shlib/simple_version_script.map`.

This patch adds multi-config compatibility when configuring
`simple_version_script.map`.

Fixes #63800.


When using multi-config generator, clang's headers is not copied to
proper directories, which is fixed as well.
2025-02-22 09:52:53 -08:00
Kazu Hirata
b11e1baf22
[llvm-readtapi] Avoid repeated hash lookups (NFC) (#128131)
Dylibs is a StringMap, which takes StringRef as the key type, so
NormalizedPath.str() is good enough.  We don't need to create a null
terminated string.  Neither do we need to recompute the string length
as part of StringRef construction.
2025-02-21 11:09:16 -08:00
Lang Hames
e3c8408593 [llvm-jitlink] Apply symbol scope modifiers explicitly for -hidden-lx.
We had been abusing the setOverrideObjectFlagsWithResponsibilityFlags method to
do this. Handling it explicitly ensures that flags are only modified on the
intended files, and not accedintally modified elsewhere.
2025-02-21 16:55:49 +11:00
Javier Lopez-Gomez
4624087328
[llvm-dwarfdump] Print number of out-of-line functions described by DWARF (#127233)
Some of the functions in `#functions` may have several inlined
instances, but also an out-of-line definition.

Therefore, for complex enough DWARF input, `#functions` - `#inlined
functions` would not give us the number of out-of-line function
definitions.
`llvm-dwarfdump`, however, already keeps track of those; print it as
part of the statistics, as this number is useful in certain scenarios.
2025-02-19 15:27:16 +00:00
Fabian Ritter
8615f9aaff
[AMDGPU] Replace gfx940 and gfx941 with gfx942 in llvm (#126763)
gfx940 and gfx941 are no longer supported. This is one of a series of
PRs to remove them from the code base.

This PR removes all non-documentation occurrences of gfx940/gfx941 from
the llvm directory, and the remaining occurrences in clang.

Documentation changes will follow.

For SWDEV-512631
2025-02-19 10:20:48 +01:00
Kazu Hirata
86d82228a5
[dsymutil] Avoid repeated hash lookups (NFC) (#127449) 2025-02-16 23:44:26 -08:00
dyung
d1b95acad7
Revert "[llvm-jitlink] Explicit exports for builtin runtime functions in MinGW executables" (#127297)
Reverts llvm/llvm-project#107375

This was causing a build bot failure
(https://lab.llvm.org/buildbot/#/builders/201/builds/2954) and also
breaks building with VS2019. See
https://github.com/llvm/llvm-project/pull/107375#issuecomment-2660709198
for details.
2025-02-14 22:59:13 -05:00
Stefan Gränitz
085e21b832
[llvm-jitlink] Explicit exports for builtin runtime functions in MinGW executables (#107375)
Use explicit exports to fix the symbol resolution part of
https://github.com/llvm/llvm-project/issues/98714 in MinGW
2025-02-14 13:25:30 +01:00
Csanád Hajdú
a190f15d2b
[AArch64] Add support for SHF_AARCH64_PURECODE ELF section flag (1/3) (#125687)
Add support for the new SHF_AARCH64_PURECODE ELF section flag:
https://github.com/ARM-software/abi-aa/pull/304

The general implementation follows the existing one for ARM targets.
Generating object files with the `SHF_AARCH64_PURECODE` flag set is
enabled by the `+execute-only` target feature.

Related PRs:
* Clang: https://github.com/llvm/llvm-project/pull/125688
* LLD: https://github.com/llvm/llvm-project/pull/125689
2025-02-14 08:56:07 +00:00
joaosaffran
1ff5f328d9
[DXIL] Add support for root signature flag element in DXContainer (#123147)
Adding support for Root Signature Flags Element extraction and writing
to DXContainer.
- Adding an analysis to deal with RootSignature metadata definition
- Adding validation for Flag
- writing RootSignature blob into DXIL

Closes: [126632](https://github.com/llvm/llvm-project/issues/126632)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-02-13 14:16:01 -08:00
Kazu Hirata
4bda95304f
[llvm-profgen] Avoid repeated hash lookups (NFC) (#127028) 2025-02-13 09:12:33 -08:00
Lang Hames
84fe1f63b0
[ORC] Switch to singleton pattern for UnwindInfoManager. (#126691)
The find-dynamic-unwind-info callback registration APIs in libunwind
limit the number of callbacks that can be registered. If we use multiple
UnwindInfoManager instances, each with their own own callback function
(as was the case prior to this patch) we can quickly exceed this limit
(see https://github.com/llvm/llvm-project/issues/126611).

This patch updates the UnwindInfoManager class to use a singleton
pattern, with the single instance shared between all LLVM JITs in the
process.

This change does _not_ apply to compact unwind info registered through
the ORC runtime (which currently installs its own callbacks).

As a bonus this change eliminates the need to load an IR "bouncer"
module to supply the unique callback for each instance, so support for
compact-unwind can be extended to the llvm-jitlink tools (which does not
support adding IR).
2025-02-12 10:00:10 +11:00
Nick Sarnie
04589d1795
[SPIR-V] Add SPIR-V Linker (#126319)
I want to use `spirv-link` from `SPIR-V-Tools` in a test, so let's build
it if `LLVM_INCLUDE_SPIRV_TOOLS_TESTS` is set, as we do with the other
tools.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-02-11 15:11:02 +00:00
Aiden Grossman
808b1c11a2
[ELF] Add support for CREL to getSectionAndRelocations
This patch updates the getSectionAndRelocations function to also support
CREL relocation sections. Unit tests have been added. This patch also
updates consumers to say they explicitly do not support CREL format
relocations. Subsequent patches will make the consumers work with CREL
format relocations and also add in testing support.

Reviewers: red1bluelost, MaskRay, rlavaee

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/126445
2025-02-10 10:57:19 -08:00
Kazu Hirata
6228379a6c
[llvm-profgen] Avoid repeated hash lookups (NFC) (#126467) 2025-02-10 07:50:57 -08:00
zhijian lin
ec60e1d8e2
[XCOFF][llvm-readobj] Print symbol value kind when dumping symbols (#125861)
llvm-readobj print out symbol value name for xcoff symbol table.

reference doc:
https://www.ibm.com/docs/en/aix/7.2?topic=formats-xcoff-object-file-format#XCOFF__yaa3i18fjbau
2025-02-10 09:37:04 -05:00
Kazu Hirata
95922d8334
[dsymutil] Avoid repeated hash lookups (NFC) (#126190) (#126346) 2025-02-08 00:49:42 -08:00
joaosaffran
76985fd7ca
[DXIL] Adding support to RootSignatureFlags in obj2yaml (#122396)
This PR adds:
- `RootSignatureFlags` extraction from DXContainer using `obj2yaml`


This PR is part of: #121493

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-02-07 14:19:19 -08:00
Lang Hames
e2eaf8ded7 [ORC] Force eh-frame use for older Darwins on x86-64 in MachOPlatform, LLJIT.
The system libunwind on older Darwins does not support JIT registration of
compact-unwind. Since the CompactUnwindManager utility discards redundant
eh-frame FDEs by default we need to remove the compact-unwind section first
when targeting older libunwinds in order to preserve eh-frames.

While LLJIT was already doing this as of eae6d6d18bd, MachOPlatform was not.
This was causing buildbot failures in the ORC runtime (e.g. in
https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3479/).

This patch updates both LLJIT and MachOPlatform to check a bootstrap value,
"darwin-use-ehframes-only", to determine whether to forcibly preserve
eh-frame sections. If this value is present and set to true then compact-unwind
sections will be discarded, causing eh-frames to be preserved. If the value is
absent or set to false then compact-unwind will be used and redundant FDEs in
eh-frames discarded (FDEs that are needed by the compact-unwind section are
always preserved).

rdar://143895614
2025-02-07 17:04:05 +11:00
Ming-Yi Lai
a1984ec5ea
[llvm-readobj][ELF][RISCV] Dump .note.gnu.property section contents (#125642)
RISCV Zicfilp/Zicfiss extensions uses the `.note.gnu.property` section
to store flags indicating the adoption of features based on these
extensions. This patch enables the llvm-readobj/llvm-readelf tools to
dump these flags with the `--note` flag.
2025-02-07 13:55:16 +08:00
Anton Sidorenko
9cf8ee9145
[MCA] Do not allocate space for DependenceEdge by default in DependencyGraphNode (NFC) (#125080)
For each instruction from the input assembly sequence, DependencyGraph
has a dedicated node (DGNode). Outgoing edges (data, resource and memory
dependencies) are tracked as SmallVector<..., 8> for each DGNode in the
graph. However, it's unlikely that a usual input instruction will have
approximately eight dependent instructions. Below is my statistics for
several RISC-V input sequences:

```
Number of  | Number of nodes with
edges      | this # of edges
---------------------------------
         0 | 8239447
         1 | 464252
         2 | 6164
         3 | 6783
         4 | 939
         5 | 500
         6 | 545
         7 | 116
         8 | 2
         9 | 1
        10 | 1
```

Approximately the same distribution is produced by llvm-mca lit tests
for X86, AArch and RISC-V (even modified ones with extra dependencies
added).
On a rather big input asm sequences, the use of SmallVector<..., 8>
dramatically increases memory consumption without any need for it. In my
case, replacing it with SmallVector<...,0> reduces memory usage by ~28%
or ~1700% of input file size (2.2GB in absolute values).

There is no change in execution time, I verified it on mca lit-tests and
on my big test (execution time is ~30s in both cases).

This change was made with the same intention as #124904 and optimizes I
believe quite an unusual scenario. However, if there is no negative
impact on other known scenarios, I'd like to have the change in
llvm-project.
2025-01-31 15:45:05 +03:00
Anton Sidorenko
a5f237f3ec
[MCA] Optimize memory consumption in resource pressure view (NFC) (#124904)
ResourceUsage is a very sparse table. On large input asm sequences it
consumes a lot of memory utilizing only a few percents of it (~4% on my
benchmark). Reorganization of ResourceUsage to keep only used fields
allows saving up to 18% of total memory use by mca or ~850% of input
file size (~1.1GB in absolute values in my case).
2025-01-31 13:26:19 +03:00
Axel Sorenson
d3161defd6
[PassBuilder] VectorizerEnd Extension Points (#123494)
Added an extension point after vectorizer passes in the PassBuilder.
Additionally, added extension points before and after vectorizer passes
in `buildLTODefaultPipeline`. Credit goes to @mshockwave for guiding me
through my first LLVM contribution (and my first open source
contribution in general!) :)
- Implemented `registerVectorizerEndEPCallback`
- Implemented `invokeVectorizerEndEPCallbacks`
- Added `VectorizerEndEPCallbacks` SmallVector
- Added a command line option `passes-ep-vectorizer-end` to
`NewPMDriver.cpp`
- `buildModuleOptimizationPipeline` now calls
`invokeVectorizerEndEPCallbacks`
- `buildO0DefaultPipeline` now calls `invokeVectorizerEndEPCallbacks`
- `buildLTODefaultPipeline` now calls BOTH
`invokeVectorizerStartEPCallbacks` and `invokeVectorizerEndEPCallbacks`
- Added LIT tests to `new-pm-defaults.ll`, `new-pm-lto-defaults.ll`,
`new-pm-O0-ep-callbacks.ll`, and `pass-pipeline-parsing.ll`
- Renamed `CHECK-EP-Peephole` to `CHECK-EP-PEEPHOLE` in
`new-pm-lto-defaults.ll` for consistency.

This code is intended for developers that wish to implement and run
custom passes after the vectorizer passes in the PassBuilder pipeline.
For example, in #91796, a pass was created that changed the induction
variables of vectorized code. This is right after the vectorization
passes.
2025-01-29 11:24:03 -08:00
Lang Hames
9052b37ab1 [ORC][LLI] Remove redundant eh-frame registration plugin construction from lli.
As of d0052ebbe2e the setUpGenericLLVMIRPlatform function will automatically
add an instance of the EHFrameRegistrationPlugin (for LLJIT instances whose
object linking layers are ObjectLinkingLayers, not RTDyldObjectLinkingLayers).

This commit removes the redundant plugin creation in the object linking
layer constructor function in lli.cpp to prevent duplicate registration of
eh-frames, which is likely the cause of recent bot failures, e.g.
https://lab.llvm.org/buildbot/#/builders/108/builds/8685.
2025-01-29 04:41:31 +00:00
NAKAMURA Takumi
6a9d0e53ae [llvm-cov] Prevent assertion failure in sumMCDCPairs
Since #112694, MCDCRecord::isCondFolded() has returned true for
"partially folded" conditions. Besides,
isConditionIndependencePairCovered() returns true if the unfolded
condition is satisfied. This might break consistency
(CoveredPairs <= NumPairs).
2025-01-28 14:56:58 +09:00
Lou
970094d50b
[llvm-opt-report] Show scalable vectorization factors (#123367)
Scalable vectorization factors are printed as "vscale x VF" where VF is
the known minimum number of elements, a integer. Currently,
llvm-opt-report always expects a integer (like for vectorization with
fixed-sized vectors), and does not display any vectorization factor in
the output (just 'V', but without a number).

This patch adds support for scalable vectorization factors and prints
them as "VNx<VF>", so for example "VNx4". The "Nx" is used to
differentiate between fixed-sized and scalable factors, and is
consistent with the way LLVM mangles scalable vectors in other places.
2025-01-24 15:08:14 +01:00