mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 03:32:10 +00:00
Do not register and de-register PassRegistrationListeners during
construction and destruction. PassRegistrationListener is intended for use as a generic listener. In some cases, PassRegistrationListener-derived classes were being created, and automatically registered and de-registered in static constructors and destructors. Since ManagedStatics are destroyed prior to program shutdown, this leads to errors where an attempt is made to access a ManagedStatic that has already been destroyed. Reviewed by: rnk, dblaikie Differential Revision: http://reviews.llvm.org/D4106 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210724 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
87fcb536ab
commit
a4dc93e6b6
@ -43,7 +43,7 @@ class PassNameParser : public PassRegistrationListener,
|
|||||||
public cl::parser<const PassInfo*> {
|
public cl::parser<const PassInfo*> {
|
||||||
cl::Option *Opt;
|
cl::Option *Opt;
|
||||||
public:
|
public:
|
||||||
PassNameParser() : Opt(nullptr) {}
|
PassNameParser();
|
||||||
virtual ~PassNameParser();
|
virtual ~PassNameParser();
|
||||||
|
|
||||||
void initialize(cl::Option &O) {
|
void initialize(cl::Option &O) {
|
||||||
|
@ -337,19 +337,12 @@ struct RegisterAnalysisGroup : public RegisterAGBase {
|
|||||||
/// clients that are interested in which passes get registered and unregistered
|
/// clients that are interested in which passes get registered and unregistered
|
||||||
/// at runtime (which can be because of the RegisterPass constructors being run
|
/// at runtime (which can be because of the RegisterPass constructors being run
|
||||||
/// as the program starts up, or may be because a shared object just got
|
/// as the program starts up, or may be because a shared object just got
|
||||||
/// loaded). Deriving from the PassRegistrationListener class automatically
|
/// loaded).
|
||||||
/// registers your object to receive callbacks indicating when passes are loaded
|
|
||||||
/// and removed.
|
|
||||||
///
|
///
|
||||||
struct PassRegistrationListener {
|
struct PassRegistrationListener {
|
||||||
|
|
||||||
/// PassRegistrationListener ctor - Add the current object to the list of
|
PassRegistrationListener() {}
|
||||||
/// PassRegistrationListeners...
|
virtual ~PassRegistrationListener() {}
|
||||||
PassRegistrationListener();
|
|
||||||
|
|
||||||
/// dtor - Remove object from list of listeners...
|
|
||||||
///
|
|
||||||
virtual ~PassRegistrationListener();
|
|
||||||
|
|
||||||
/// Callback functions - These functions are invoked whenever a pass is loaded
|
/// Callback functions - These functions are invoked whenever a pass is loaded
|
||||||
/// or removed from the current executable.
|
/// or removed from the current executable.
|
||||||
|
@ -224,17 +224,6 @@ RegisterAGBase::RegisterAGBase(const char *Name, const void *InterfaceID,
|
|||||||
// PassRegistrationListener implementation
|
// PassRegistrationListener implementation
|
||||||
//
|
//
|
||||||
|
|
||||||
// PassRegistrationListener ctor - Add the current object to the list of
|
|
||||||
// PassRegistrationListeners...
|
|
||||||
PassRegistrationListener::PassRegistrationListener() {
|
|
||||||
PassRegistry::getPassRegistry()->addRegistrationListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// dtor - Remove object from list of listeners...
|
|
||||||
PassRegistrationListener::~PassRegistrationListener() {
|
|
||||||
PassRegistry::getPassRegistry()->removeRegistrationListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// enumeratePasses - Iterate over the registered passes, calling the
|
// enumeratePasses - Iterate over the registered passes, calling the
|
||||||
// passEnumerate callback on each PassInfo object.
|
// passEnumerate callback on each PassInfo object.
|
||||||
//
|
//
|
||||||
@ -242,7 +231,16 @@ void PassRegistrationListener::enumeratePasses() {
|
|||||||
PassRegistry::getPassRegistry()->enumerateWith(this);
|
PassRegistry::getPassRegistry()->enumerateWith(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PassNameParser::~PassNameParser() {}
|
PassNameParser::PassNameParser()
|
||||||
|
: Opt(nullptr) {
|
||||||
|
PassRegistry::getPassRegistry()->addRegistrationListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
PassNameParser::~PassNameParser() {
|
||||||
|
// This only gets called during static destruction, in which case the
|
||||||
|
// PassRegistry will have already been destroyed by llvm_shutdown(). So
|
||||||
|
// attempting to remove the registration listener is an error.
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// AnalysisUsage Class Implementation
|
// AnalysisUsage Class Implementation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user