diff options
author | Lang Hames <lhames@gmail.com> | 2018-10-01 00:59:26 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-10-01 00:59:26 +0000 |
commit | d89c273a2ee4349704dc2e21b7037f01f6bde60a (patch) | |
tree | ada1f1bfed97bc934c8c3f6abc22030724b7f797 | |
parent | 1d1dca6a6f9a2815eeb4676df16f4478965d4610 (diff) | |
download | bcm5719-llvm-d89c273a2ee4349704dc2e21b7037f01f6bde60a.tar.gz bcm5719-llvm-d89c273a2ee4349704dc2e21b7037f01f6bde60a.zip |
[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).
llvm-svn: 343429
-rw-r--r-- | llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h | 12 | ||||
-rw-r--r-- | llvm/tools/lli/lli.cpp | 7 |
2 files changed, 13 insertions, 6 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h index 327941d52fe..eb9b6bf2dea 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h @@ -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); diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index 9b3c7478b41..b23733eac99 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -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) |