aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-09-24 16:25:55 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-09-24 16:25:55 +0000
commit446531e7bb4355117b070493ca8e81e4b123ef18 (patch)
tree76a5172fb16d6058cc8a26df2d7c569cd3f92591
parentf3cbca279db891403659208a99f8e1cceb8c9ea6 (diff)
Add DisableGVCompilation which forces the JIT to assert when it tries to allocate space for a GlobalVariable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56557 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h11
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp1
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp4
3 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index edcddde2e3..d4fd0fb19b 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -65,6 +65,7 @@ class ExecutionEngine {
const TargetData *TD;
ExecutionEngineState state;
bool LazyCompilationDisabled;
+ bool GVCompilationDisabled;
bool SymbolSearchingDisabled;
protected:
@@ -254,6 +255,16 @@ public:
bool isLazyCompilationDisabled() const {
return LazyCompilationDisabled;
}
+
+ /// DisableGVCompilation - If called, the JIT will abort if it's asked to allocate
+ /// space and populate a GlobalVariable.
+ void DisableGVCompilation(bool Disabled = true) {
+ GVCompilationDisabled = Disabled;
+ }
+ bool isGVCompilationDisabled() const {
+ return GVCompilationDisabled;
+ }
+
/// DisableSymbolSearching - If called, the JIT will not try to lookup unknown
/// symbols with dlsym. A client can still use InstallLazyFunctionCreator to
/// resolve symbols in a custom way.
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 52a69eaea7..8cc2244272 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -40,6 +40,7 @@ ExecutionEngine::EERegisterFn ExecutionEngine::ExceptionTableRegister = 0;
ExecutionEngine::ExecutionEngine(ModuleProvider *P) : LazyFunctionCreator(0) {
LazyCompilationDisabled = false;
+ GVCompilationDisabled = false;
SymbolSearchingDisabled = false;
Modules.push_back(P);
assert(P && "ModuleProvider is null?");
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 39ecc2796c..383b380475 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -552,6 +552,10 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) {
addGlobalMapping(GV, Ptr);
}
} else {
+ if (isGVCompilationDisabled()) {
+ cerr << "Compilation of GlobalVariable is disabled!\n";
+ abort();
+ }
// If the global hasn't been emitted to memory yet, allocate space and
// emit it into memory. It goes in the same array as the generated
// code, jump tables, etc.