summaryrefslogtreecommitdiff
path: root/include/llvm/ExecutionEngine/ExecutionEngine.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ExecutionEngine/ExecutionEngine.h')
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index 821c0181ce83..a7302602dcd8 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -104,7 +104,12 @@ class ExecutionEngine {
ExecutionEngineState EEState;
/// The target data for the platform for which execution is being performed.
- const DataLayout *DL;
+ ///
+ /// Note: the DataLayout is LLVMContext specific because it has an
+ /// internal cache based on type pointers. It makes unsafe to reuse the
+ /// ExecutionEngine across context, we don't enforce this rule but undefined
+ /// behavior can occurs if the user tries to do it.
+ const DataLayout DL;
/// Whether lazy JIT compilation is enabled.
bool CompilingLazily;
@@ -126,8 +131,6 @@ protected:
/// optimize for the case where there is only one module.
SmallVector<std::unique_ptr<Module>, 1> Modules;
- void setDataLayout(const DataLayout *Val) { DL = Val; }
-
/// getMemoryforGV - Allocate memory for a global variable.
virtual char *getMemoryForGV(const GlobalVariable *GV);
@@ -194,7 +197,7 @@ public:
//===--------------------------------------------------------------------===//
- const DataLayout *getDataLayout() const { return DL; }
+ const DataLayout &getDataLayout() const { return DL; }
/// removeModule - Remove a Module from the list of modules. Returns true if
/// M is found.
@@ -478,7 +481,8 @@ public:
}
protected:
- ExecutionEngine() {}
+ ExecutionEngine(const DataLayout DL) : DL(std::move(DL)){}
+ explicit ExecutionEngine(DataLayout DL, std::unique_ptr<Module> M);
explicit ExecutionEngine(std::unique_ptr<Module> M);
void emitGlobals();
@@ -488,6 +492,9 @@ protected:
GenericValue getConstantValue(const Constant *C);
void LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr,
Type *Ty);
+
+private:
+ void Init(std::unique_ptr<Module> M);
};
namespace EngineKind {