Add DisableGVCompilation which forces the JIT to assert when it tries to allocate...
authorEvan Cheng <evan.cheng@apple.com>
Wed, 24 Sep 2008 16:25:55 +0000 (16:25 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 24 Sep 2008 16:25:55 +0000 (16:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56557 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ExecutionEngine/ExecutionEngine.h
lib/ExecutionEngine/ExecutionEngine.cpp
lib/ExecutionEngine/JIT/JIT.cpp

index edcddde2e390bab6335ae574193a9928305a5404..d4fd0fb19b14a53da35049ad22ac2ce202b8a6c9 100644 (file)
@@ -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.
index 52a69eaea77c40edc8a2873207443184df9f2117..8cc2244272b497a1c71166457210eac1ea60197f 100644 (file)
@@ -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?");
index 39ecc2796c77dcbc4a263d403043284dabcf6acc..383b3804758e0923ba8d9528a739a94ce7b0f924 100644 (file)
@@ -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.