mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
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
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user