15802 Commits

Author SHA1 Message Date
Kazu Hirata
99d2b3b0aa
[llvm-profgen] Avoid repeated hash lookups (NFC) (#130466) 2025-03-09 00:49:37 -08:00
Kazu Hirata
573df34ea0
[llvm-jitlink] Avoid repeated hash lookups (NFC) (#130465) 2025-03-09 00:49:13 -08:00
Douglas Yung
1d763f3833 Revert "Modify the localCache API to require an explicit commit on CachedFile… (#115331)"
This reverts commit ce9e1d3c15ed6290f1cb07b482939976fa8115cd.

The unittest added in this commit seems to be flaky causing random failure on buildbots:
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13235
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13232
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13228
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13224
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13220
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13210
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13208
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13207
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13202
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13196
and
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14266
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14254
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14250
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14245
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14244
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14226
2025-03-08 23:54:57 +00:00
Douglas Yung
49e585f4c4 Revert "[gold] Fix compilation (#130334)"
This reverts commit b0baa1d8bd68a2ce2f7c5f2b62333e410e9122a1.

Reverting follow-up commit to ce9e1d3c15ed6290f1cb07b482939976fa8115cd since the original commit test is flaky.
2025-03-08 23:53:38 +00:00
Peter Jung
3ac24236aa
[llvm-profdata] Fix typo in llvm-profdata (#114675)
Signed-off-by: Peter Jung <admin@ptr1337.dev>
2025-03-08 18:52:24 +00:00
Vitaly Buka
b0baa1d8bd
[gold] Fix compilation (#130334)
After #115331.
2025-03-07 12:06:03 -08:00
anjenner
ce9e1d3c15
Modify the localCache API to require an explicit commit on CachedFile… (#115331)
…Stream.

CachedFileStream has previously performed the commit step in its
destructor, but this means its only recourse for error handling is
report_fatal_error. Modify this to add an explicit commit() method, and
call this in the appropriate places with appropriate error handling for
the location.

Currently the destructor of CacheStream gives an assert failure in Debug
builds if commit() was not called. This will help track down any
remaining uses of the API that assume the old destructior behaviour. In
Release builds we fall back to the previous behaviour and call
report_fatal_error if the commit fails.
2025-03-07 17:58:36 +00:00
Zentrik
d7f409d39a
[JITListener] Fix build after Module::getTargetTriple() change (#130152)
Adjust for #129868.
2025-03-07 09:37:19 +01:00
Tejas Vipin
bd5f29c008
[llvm-strip] Let llvm-strip continue on encountering an error (#129531)
This change means that llvm-strip no longer exits immediately upon
encountering an error when modifying a file and will instead continue
modifying the other inputs. Fixes #129412
2025-03-07 08:34:29 +00:00
Daniel Paoliello
16e051f0b9
[win] NFC: Rename EHCatchret to EHCont to allow for EH Continuation targets that aren't catchret instructions (#129953)
This change splits out the renaming and comment updates from #129612 as a non-functional change.
2025-03-06 09:28:44 -08:00
Kazu Hirata
92dfc0ffc3
[llvm-jitlink] Avoid repeated hash lookups (NFC) (#129993) 2025-03-06 08:50:21 -08:00
Kazu Hirata
abcab4f7ba
[llvm-dwarfdump] Avoid repeated hash lookups (NFC) (#129991) 2025-03-06 08:50:00 -08:00
Nikita Popov
f7c0f33d6f [lto] Add TargetParser dependency
To fix the shared libs build after #129868.
2025-03-06 11:01:17 +01:00
Nikita Popov
979c275097
[IR] Store Triple in Module (NFC) (#129868)
The module currently stores the target triple as a string. This means
that any code that wants to actually use the triple first has to
instantiate a Triple, which is somewhat expensive. The change in #121652
caused a moderate compile-time regression due to this. While it would be
easy enough to work around, I think that architecturally, it makes more
sense to store the parsed Triple in the module, so that it can always be
directly queried.

For this change, I've opted not to add any magic conversions between
std::string and Triple for backwards-compatibilty purses, and instead
write out needed Triple()s or str()s explicitly. This is because I think
a decent number of them should be changed to work on Triple as well, to
avoid unnecessary conversions back and forth.

The only interesting part in this patch is that the default triple is
Triple("") instead of Triple() to preserve existing behavior. The former
defaults to using the ELF object format instead of unknown object
format. We should fix that as well.
2025-03-06 10:27:47 +01:00
lakshayk-nv
d61d219739
Adding support in llvm-exegesis for Aarch64 for handling FPR64/128, PPR16 and ZPR128 reg class. (#127564)
Current implementation (for Aarch64) in llvm-exegesis only supports
GRP32 and GPR64 bit register class, thus for opcodes variants which used
FPR64/128, PPR16 and ZPR128, llvm-exegesis throws warning "setReg is not
implemented". This code will handle the above register class and
initialize the registers using appropriate base instruction class.
2025-03-06 09:02:54 +00:00
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