[llvm] r343429 - [ORC] Add a method to JITTargetMachineBuilder to get the default data layout
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 30 17:59:26 PDT 2018
Author: lhames
Date: Sun Sep 30 17:59:26 2018
New Revision: 343429
URL: http://llvm.org/viewvc/llvm-project?rev=343429&view=rev
Log:
[ORC] Add a method to JITTargetMachineBuilder to get the default data layout
for the target machine.
This simplifies usage during setup of concurrent JIT stacks where the client
needs a DataLayout, but not a TargetMachine (TargetMachines are created on
the fly by the compile threads later).
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
llvm/trunk/tools/lli/lli.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h?rev=343429&r1=343428&r2=343429&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h Sun Sep 30 17:59:26 2018
@@ -56,6 +56,18 @@ public:
/// also be registered.
Expected<std::unique_ptr<TargetMachine>> createTargetMachine();
+ /// Get the default DataLayout for the target.
+ ///
+ /// Note: This is reasonably expensive, as it creates a temporary
+ /// TargetMachine instance under the hood. It is only suitable for use during
+ /// JIT setup.
+ Expected<DataLayout> getDefaultDataLayoutForTarget() {
+ auto TM = createTargetMachine();
+ if (!TM)
+ return TM.takeError();
+ return (*TM)->createDataLayout();
+ }
+
/// Set the CPU string.
JITTargetMachineBuilder &setCPU(std::string CPU) {
this->CPU = std::move(CPU);
Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=343429&r1=343428&r2=343429&view=diff
==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Sun Sep 30 17:59:26 2018
@@ -786,12 +786,7 @@ int runOrcLazyJIT(const char *ProgName)
? Optional<CodeModel::Model>(CMModel)
: None);
- DataLayout DL("");
- {
- // Create a throwaway TargetMachine to get the data layout.
- auto TM = ExitOnErr(JTMB.createTargetMachine());
- DL = TM->createDataLayout();
- }
+ DataLayout DL = ExitOnErr(JTMB.getDefaultDataLayoutForTarget());
auto J = ExitOnErr(orc::LLLazyJIT::Create(std::move(JTMB), DL, LazyJITCompileThreads));
if (PerModuleLazy)
More information about the llvm-commits
mailing list