diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-25 23:25:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-25 23:25:17 +0000 |
commit | 356deb5ecde78fdef706e325325c23c828666b9f (patch) | |
tree | 21aa8a0fb4fed7044dc5449561035d3d8e26a825 /lib/ExecutionEngine/JIT | |
parent | 7e2bf3c6f908cc79dd48c69f86920a3826141e72 (diff) | |
download | llvm-356deb5ecde78fdef706e325325c23c828666b9f.tar.gz llvm-356deb5ecde78fdef706e325325c23c828666b9f.tar.bz2 llvm-356deb5ecde78fdef706e325325c23c828666b9f.tar.xz |
Use DataLayout from the module when easily available.
Eventually DataLayoutPass should go away, but for now that is the only easy
way to get a DataLayout in some APIs. This patch only changes the ones that
have easy access to a Module.
One interesting issue with sometimes using DataLayoutPass and sometimes
fetching it from the Module is that we have to make sure they are equivalent.
We can get most of the way there by always constructing the pass with a Module.
In fact, the pass could be changed to point to an external DataLayout instead
of owning one to make this stricter.
Unfortunately, the C api passes a DataLayout, so it has to be up to the caller
to make sure the pass and the module are in sync.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202204 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT')
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 2836218d4a..b271618a5f 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -26,6 +26,7 @@ #include "llvm/IR/Function.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Instructions.h" +#include "llvm/IR/Module.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/ErrorHandling.h" @@ -151,7 +152,8 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji, // Add target data MutexGuard locked(lock); FunctionPassManager &PM = jitstate->getPM(locked); - PM.add(new DataLayoutPass(*TM.getDataLayout())); + M->setDataLayout(TM.getDataLayout()); + PM.add(new DataLayoutPass(M)); // Turn the machine code intermediate representation into bytes in memory that // may be executed. @@ -183,7 +185,8 @@ void JIT::addModule(Module *M) { jitstate = new JITState(M); FunctionPassManager &PM = jitstate->getPM(locked); - PM.add(new DataLayoutPass(*TM.getDataLayout())); + M->setDataLayout(TM.getDataLayout()); + PM.add(new DataLayoutPass(M)); // Turn the machine code intermediate representation into bytes in memory // that may be executed. @@ -214,7 +217,8 @@ bool JIT::removeModule(Module *M) { jitstate = new JITState(Modules[0]); FunctionPassManager &PM = jitstate->getPM(locked); - PM.add(new DataLayoutPass(*TM.getDataLayout())); + M->setDataLayout(TM.getDataLayout()); + PM.add(new DataLayoutPass(M)); // Turn the machine code intermediate representation into bytes in memory // that may be executed. |