aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/IR/GlobalVariable.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/IR/GlobalVariable.h')
-rw-r--r--include/llvm/IR/GlobalVariable.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h
index 342bdc01bfbd..ebeb635468d0 100644
--- a/include/llvm/IR/GlobalVariable.h
+++ b/include/llvm/IR/GlobalVariable.h
@@ -65,6 +65,8 @@ public:
bool isExternallyInitialized = false);
~GlobalVariable() override {
+ dropAllReferences();
+
// FIXME: needed by operator delete
setGlobalVariableNumOperands(1);
}
@@ -94,9 +96,9 @@ public:
/// unique.
inline bool hasDefinitiveInitializer() const {
return hasInitializer() &&
- // The initializer of a global variable with weak linkage may change at
- // link time.
- !mayBeOverridden() &&
+ // The initializer of a global variable may change to something arbitrary
+ // at link time.
+ !isInterposable() &&
// The initializer of a global variable with the externally_initialized
// marker may change at runtime before C++ initializers are evaluated.
!isExternallyInitialized();
@@ -159,6 +161,10 @@ public:
///
void eraseFromParent() override;
+ /// Drop all references in preparation to destroy the GlobalVariable. This
+ /// drops not only the reference to the initializer but also to any metadata.
+ void dropAllReferences();
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Value *V) {
return V->getValueID() == Value::GlobalVariableVal;