758 Commits

Author SHA1 Message Date
Lang Hames
0bfa0bcd79
[ORC] Replace ThreadSafeContext::getContext with withContextDo. (#146819)
This removes ThreadSafeContext::Lock, ThreadSafeContext::getLock, and
ThreadSafeContext::getContext, and replaces them with a
ThreadSafeContext::withContextDo method (and const override).

The new method can be used to access an existing
ThreadSafeContext-wrapped LLVMContext in a safe way:

ThreadSafeContext TSCtx = ... ;
TSCtx.withContextDo([](LLVMContext *Ctx) {
  // this closure has exclusive access to Ctx.
});

The new API enforces correct locking, whereas the old APIs relied on
manual locking (which almost no in-tree code preformed, relying instead
on incidental exclusive access to the ThreadSafeContext).
2025-07-03 17:03:39 +10:00
Nikita Popov
0e268791c5 [SpeculativeJIT] Add missing include
Fix examples after 0faa181434cf959110651fe974bef31e7390eba8.
2025-06-26 09:56:36 +02:00
Lang Hames
0faa181434
[ORC] Extract MemoryAccess from ExecutorProcessControl, break up header. (#145671)
This moves the MemoryAccess interface out of the ExecutorProcessControl
class and splits implementation classes InProcessMemoryManager and
SelfExecutorProcessControl out of ExecutorProcessControl.h and into
their own headers.
2025-06-26 10:31:43 +10:00
Lang Hames
6cfa03f1f1
[ORC] Drop unused LinkGraphLinkingLayer::Plugin::notifyLoaded method. (#145457)
This method was included in the original Plugin API as a counterpart to
JITEventListener::notifyLoaded but was never used.
2025-06-24 19:00:24 +10:00
Lang Hames
ea709c7dcd [ORC] Fix examples after cd585864c0b.
cd585864c0b added a MemoryBuffer argument to the memory manager factory. This
patch updates the examples to reflect that change.
2025-06-06 13:36:32 +10:00
Karlo Basioli
cd585864c0
Pass memory buffer to RuntimeDyld::MemoryManager factory (#142930)
`RTDyldObjectLinkingLayer` is currently creating a memory manager
without any parameters.

In this PR I am passing the MemoryBuffer that will be emitted to the
MemoryManager so that the user can use it to configure the behaviour of
the MemoryManager.
2025-06-06 00:44:39 +01:00
Owen Rodley
d3d856ad84
Clean up external users of GlobalValue::getGUID(StringRef) (#129644)
See https://discourse.llvm.org/t/rfc-keep-globalvalue-guids-stable/84801
for context.

This is a non-functional change which just changes the interface of
GlobalValue, in preparation for future functional changes. This part
touches a fair few users, so is split out for ease of review. Future
changes to the GlobalValue implementation can then be focused purely on
that class.

This does the following:

* Rename GlobalValue::getGUID(StringRef) to
  getGUIDAssumingExternalLinkage. This is simply making explicit at the
  callsite what is currently implicit.
* Where possible, migrate users to directly calling getGUID on a
  GlobalValue instance.
* Otherwise, where possible, have them call the newly renamed
  getGUIDAssumingExternalLinkage, to make the assumption explicit.


There are a few cases where neither of the above are possible, as the
caller saves and reconstructs the necessary information to compute the
GUID themselves. We want to migrate these callers eventually, but for
this first step we leave them be.
2025-04-28 11:09:43 +10:00
Steven Hedges
eeebdb9711
[llvm] Fix Typo in Kaleidoscope BuildingAJIT Example (#134391)
Changed "precedecnce" to precedence.
2025-04-07 22:05:15 +01:00
Lang Hames
41b572b99c [ORC][examples] Simplify example -- LLJIT already has a mangleAndIntern method.
We don't need a separate MangleAndInterner here any more.
2025-03-23 11:25:01 +11:00
Nikita Popov
f137c3d592
[TargetRegistry] Accept Triple in createTargetMachine() (NFC) (#130940)
This avoids doing a Triple -> std::string -> Triple round trip in lots
of places, now that the Module stores a Triple.
2025-03-12 17:35:09 +01:00
Nikita Popov
d9af34f499 [Kaleidoscope] Adjust after Module Triple change
Adjust for #129868.
2025-03-06 11:52:51 +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
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
chrisPyr
71f4c7dabe
[NFC]Make file-local cl::opt global variables static (#126486)
#125983
2025-03-03 13:46:33 +07:00
Jeremy Morse
304a99091c [NFC][DebugInfo] Use iterators for insertion at some final callsites
These are the callsites that have materialised in the last three weeks
since I last built with deprecation warnings.
2025-01-28 11:37:11 +00:00
Mats Jun Larsen
d7c14c8f97
[IR] Replace of PointerType::getUnqual(Type) with opaque version (NFC) (#123909)
Follow up to https://github.com/llvm/llvm-project/issues/123569
2025-01-23 18:23:05 +09:00
epitavy
847acbbc52
[ExceptionDemo] Transition example from MCJIT to ORC and fix errors (#92504)
ExceptionDemo has been broken for some time. This patch fixes the
compilation errors and moves the example from MCJIT to ORC.
2025-01-23 12:40:38 +11:00
Lang Hames
81c0f3023f [ORC] Add ExecutorSymbolDef toPtr / fromPtr convenience functions.
This will simplify conversion of a number of APIs from ExecutorAddr to
ExecutorSymbolDef.
2025-01-22 09:53:42 +11:00
AidinT
6f8a363a48
[Kaleidoscope] Add mem2reg pass to function pass manager (#119707)
Kaleidoscope has switched to new pass manager before (#72324), but both
code and tutorial document have some missing parts.

This pull request fixes the following problems:
1. Adds `PromotePass` to the function pass manager. This pass was
removed during the switch from legacy pass manager to the new pass
manager.
2. Syncs the tutorial with the code.
2024-12-12 16:25:09 +01:00
Lang Hames
6410edcb67 [examples] Add missing dependence on OrcShared.
Hopefully this will fix the linker error in
https://lab.llvm.org/buildbot/#/builders/80/builds/7248.
2024-12-06 00:33:45 +00:00
Lang Hames
dc11c06015 [ORC] Move absoluteSymbols from Core.h to new AbsoluteSymbols.h header. NFC.
Continuing Core.h clean-up.

If you see any errors about a missing absoluteSymbols function you need to
include the new AbsoluteSymbols.h header.
2024-11-11 11:39:53 +11:00
Lang Hames
e575483870 [ORC] Fix LLJITWithRemoteDebugging example after db21bd4fa9b. 2024-10-22 11:31:54 -07:00
Sunho Kim
04af63b267 [ORC] Introduce IRPartitionLayer for common partition functionality. 2024-10-12 01:21:05 +09:00
Rahul Joshi
fa789dffb1
[NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclaration (#111752)
Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is also in preparation of
adding a new `Intrinsic::getDeclaration` that will have behavior similar
to `Module::getFunction` (i.e, just lookup, no creation).
2024-10-11 05:26:03 -07:00
Jeremy Morse
2f50b280dc
[DebugInfo] Enable deprecation of iterator-insertion methods (#102608)
This is an almost-final step in eliminating debug-intrinsics -- read more
about that here: https://llvm.org/docs/RemoveDIsDebugInfo.html . To
correctly update variable location information in the background when
inserting instructions, we need some information carried at runtime in
BasicBlock::iterator, hence deprecating pointer-insertion.
                                                                                                                                                                                                                 An immediate fix for any deprecation warnings is to call "getIterator"
on the insertion position pointer. If you intend on inserting at the start
of a block, use BB->begin() or similar methods to fetch the appropriate
iterator.
2024-09-20 13:56:43 +01:00
c8ef
4f4bd41f70
[NFC] Fix typos (#106817)
Fixes #106761.
2024-08-31 19:12:57 -07:00
Bjorn Pettersson
145aff6d92 Clean up pointer casts etc after opaque pointers transition. NFC (#102631) 2024-08-12 13:28:53 +02:00
Steven Wu
01b488faab
Reapply "[CMake] Fold export_executable_symbols_* into function args. (#101741)" (#102138)
Fix the builds with LLVM_TOOL_LLVM_DRIVER_BUILD enabled.

LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES is not completely
compatible with export_executable_symbols as the later will be ignored
if the previous is set to NO.

Fix the issue by passing if symbols need to be exported to
llvm_add_exectuable so the link flag can be determined directly
without calling export_executable_symbols_* later.
2024-08-07 09:12:15 -07:00
Steven Wu
f9b69a378c Revert "[CMake] Fold export_executable_symbols_* into function args. (#101741)"
This reverts commit 5c56b46a32a8856a022a54291bc9294068f7ddbd. This break
lld build when using GENERATE_DRIVER.
2024-08-06 06:08:16 -07:00
Steven Wu
5c56b46a32
[CMake] Fold export_executable_symbols_* into function args. (#101741)
`LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES` is not completely
compatible with `export_executable_symbols` as the later will be ignored
if the previous is set to NO.

 Fix the issue by passing if symbols need to be exported to
`llvm_add_exectuable` so the link flag can be determined directly
without calling `export_executable_symbols_*` later.
2024-08-05 19:08:27 -07:00
FantasqueX
2d21851fd5
[llvm] Remove useless headers in example BrainF (#93701) 2024-06-08 21:33:43 +08:00
Michael Kruse
4ecbfacf9e
[llvm] Revise IDE folder structure (#89741)
Update the folder titles for targets in the monorepository that have not
seen taken care of for some time. These are the folders that targets are
organized in Visual Studio and XCode
(`set_property(TARGET <target> PROPERTY FOLDER "<title>")`)
when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically
deduce the folder. This reduces the number of
`set_property`/`set_target_property`, but are still necessary when
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
root CMakeLists.txt.
2024-05-25 13:28:30 +02:00
Alex Voicu
10edb4991c
[Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (#88182)
At the moment, Clang is rather liberal in assuming that 0 (and by extension unqualified) is always a safe default. This does not work for targets that actually use a different value for the default / generic AS (for example, the SPIRV that obtains from HIPSPV or SYCL). This patch is a first, fairly safe step towards trying to clear things up by querying a modules' default AS from the target, rather than assuming it's 0, alongside fixing a few places where things break / we encode the 0 == DefaultAS assumption. A bunch of existing tests are extended to check for non-zero default AS usage.
2024-05-19 14:59:03 +01:00
Kamlesh Kumar
b59760d83d
Revert "[ExceptionDemo] Correct and update example ExceptionDemo" (#92257)
Reverts llvm/llvm-project#69485
2024-05-15 18:57:49 +05:30
epitavy
2ece5cc2bb
[ExceptionDemo] Correct and update example ExceptionDemo (#69485)
The ExceptionDemo example was no longer compiling (since llvm 14 at
least). The PR makes the example work with the current API and also
transition from MCJIT to ORC.
Fixes #63702
2024-05-15 08:39:11 +05:30
Nikita Popov
47682e4b4a Revert "[ORC] Implement basic reoptimization. (#67050)"
This reverts commit 0d288e5b0ccf217e41944ad4fd8772d8ae45daa1.

Breaks the build.
2024-04-26 14:47:48 +09:00
Sunho Kim
0d288e5b0c
[ORC] Implement basic reoptimization. (#67050) 2024-04-25 22:43:06 -07:00
Lang Hames
e400e908b2 [ORC] Fix SpeculativeJIT example after 7da63426ac5 (ORC dispatch unification).
Fixes the bot failure at
https://lab.llvm.org/buildbot/#/builders/272/builds/14788.

Coding my way home: 6.48551S, 128.21109W
2024-04-24 01:03:29 -08:00
Lang Hames
69703b1f94 [ORC] Fix bot failure due to 7da63426ac5 (ORC task dispatch unification).
Fixes the failure at https://lab.llvm.org/buildbot/#/builders/131/builds/62928,
and add comments about unused variable and update debugging output.

Coding my way home: 6.44615S, 128.16704W
2024-04-24 00:24:16 -08:00
Mehdi Amini
716042a63f
Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (#83702)
The base class llvm::ThreadPoolInterface will be renamed
llvm::ThreadPool in a subsequent commit.

This is a breaking change: clients who use to create a ThreadPool must
now create a DefaultThreadPool instead.
2024-03-05 18:00:46 -08:00
Jeremy Morse
df52521655 [RemoveDIs] Follow up to 6b62a9135a2, fix a ICmpInst constructor call
Seemingly I either missed this on a buildbot or otherwise didn't
cover this :(
2024-03-04 19:31:42 +00:00
Jeremy Morse
46d7876957 Follow up to 6b62a9135a2, fix llvm-examples build
This is due to the {I,F}CmpInst constructor being normalised to take a
pointer to a block rather than a reference (unlike any other Instruction).
2024-03-04 13:41:26 +00:00
Gonsolo
33aaad9427
[Kaleidoscope] LLVM is not needed for chapter two (#69823)
Since the example (llvm/examples/Kaleidoscope/Chapter2/toy.cpp) is
self-contained there is no need to use LLVM.
2024-01-12 20:48:43 -08:00
Stefan Gränitz
b7d5b0d0ee
[Orc][examples] Revisit advanced LLJIT examples and tests (#76236)
Some maintenance on implementation and tests:
* Drop manual TargetMachineBuilder setup
* Drop addDebugSupport() in favor of Orc's enableDebuggerSupport()
* Check that debug support plugins append jit_code_entry
* Update and reduce sample input
2024-01-03 09:51:18 +01:00
Stefan Gränitz
d86a93782f
[Orc][examples] Drop target triple from input for remote debugging test (#74831)
https://github.com/llvm/llvm-project/pull/74764 reported that the
`lljit-with-remote-debugging` test fails on AArch64 hosts, because the
input IR file states arch x86_64 explicitly. In order to drop the target
triple we have to remove a check in the example implementation.

Not sure it's fully portable now, but at least it's better than before.
2023-12-08 22:10:03 +01:00
Fangrui Song
114325b86a Kaleidoscope-Ch8: use Reloc::PIC_
which has better portability across different OSes.
In addition, on many ELF OSes, this output relocatable file can be
linked without -no-pie.
2023-12-05 23:44:35 -08:00
Fangrui Song
dd3184c30f [unittest,examples] Replace uses of IRBuilder::getInt8PtrTy with getPtrTy. NFC 2023-11-27 08:29:13 -08:00
Logikable
3d2527ebe3
[Kaleidoscope] Switch to the new PassManager, revisited. (#72324)
Rollforward of #69032, which was reverted in
[63d19cf](63d19cfd85).

New: implemented changes in
https://github.com/llvm/llvm-project/pull/69032#issuecomment-1809250162.
Given the PassBuilder is how we expect users to register passes, the
tutorial should reflect that.
2023-11-16 09:13:56 -08:00