summaryrefslogtreecommitdiff
path: root/include/llvm/ExecutionEngine
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-10-23 22:37:43 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-10-23 22:37:43 +0000
commit23e5fcfec4640955fec41dc8348f467adf1a3e56 (patch)
treeff1de1e3e7b059ed882c0e5c6a3e1c7a8632ddde /include/llvm/ExecutionEngine
parent7b929dad59785f62a66f7c58615082f98441e95e (diff)
downloadllvm-23e5fcfec4640955fec41dc8348f467adf1a3e56.tar.gz
llvm-23e5fcfec4640955fec41dc8348f467adf1a3e56.tar.bz2
llvm-23e5fcfec4640955fec41dc8348f467adf1a3e56.tar.xz
Fix http://llvm.org/PR4822: allow module deletion after a function has been
compiled. When functions are compiled, they accumulate references in the JITResolver's stub maps. This patch removes those references when the functions are destroyed. It's illegal to destroy a Function when any thread may still try to call its machine code. This patch also updates r83987 to use ValueMap instead of explicit CallbackVHs and fixes a couple "do stuff inside assert()" bugs from r84522. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84975 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ExecutionEngine')
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h39
1 files changed, 13 insertions, 26 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index b9da0fcfce..92f552de0e 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -19,6 +19,7 @@
#include <map>
#include <string>
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/ValueMap.h"
#include "llvm/Support/ValueHandle.h"
#include "llvm/System/Mutex.h"
#include "llvm/Target/TargetMachine.h"
@@ -42,26 +43,23 @@ class Type;
class ExecutionEngineState {
public:
- class MapUpdatingCVH : public CallbackVH {
- ExecutionEngineState &EES;
-
- public:
- MapUpdatingCVH(ExecutionEngineState &EES, const GlobalValue *GV);
-
- operator const GlobalValue*() const {
- return cast<GlobalValue>(getValPtr());
- }
-
- virtual void deleted();
- virtual void allUsesReplacedWith(Value *new_value);
+ struct AddressMapConfig : public ValueMapConfig<const GlobalValue*> {
+ typedef ExecutionEngineState *ExtraData;
+ static sys::Mutex *getMutex(ExecutionEngineState *EES);
+ static void onDelete(ExecutionEngineState *EES, const GlobalValue *Old);
+ static void onRAUW(ExecutionEngineState *, const GlobalValue *,
+ const GlobalValue *);
};
+ typedef ValueMap<const GlobalValue *, void *, AddressMapConfig>
+ GlobalAddressMapTy;
+
private:
ExecutionEngine &EE;
/// GlobalAddressMap - A mapping between LLVM global values and their
/// actualized version...
- std::map<MapUpdatingCVH, void *> GlobalAddressMap;
+ GlobalAddressMapTy GlobalAddressMap;
/// GlobalAddressReverseMap - This is the reverse mapping of GlobalAddressMap,
/// used to convert raw addresses into the LLVM global value that is emitted
@@ -70,13 +68,9 @@ private:
std::map<void *, AssertingVH<const GlobalValue> > GlobalAddressReverseMap;
public:
- ExecutionEngineState(ExecutionEngine &EE) : EE(EE) {}
+ ExecutionEngineState(ExecutionEngine &EE);
- MapUpdatingCVH getVH(const GlobalValue *GV) {
- return MapUpdatingCVH(*this, GV);
- }
-
- std::map<MapUpdatingCVH, void *> &
+ GlobalAddressMapTy &
getGlobalAddressMap(const MutexGuard &) {
return GlobalAddressMap;
}
@@ -485,15 +479,8 @@ class EngineBuilder {
}
ExecutionEngine *create();
-
};
-inline bool operator<(const ExecutionEngineState::MapUpdatingCVH& lhs,
- const ExecutionEngineState::MapUpdatingCVH& rhs) {
- return static_cast<const GlobalValue*>(lhs) <
- static_cast<const GlobalValue*>(rhs);
-}
-
} // End llvm namespace
#endif