summaryrefslogtreecommitdiff
path: root/include/llvm/IR/GlobalVariable.h
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-02-05 06:53:26 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-02-05 06:53:26 +0000
commite1b6b5290373073c95f6865ceaf76fa7848ecf44 (patch)
tree7db83ccc7524db4ca00d5b65b6037a5a10fd929a /include/llvm/IR/GlobalVariable.h
parent429f7ef0c116c0504052b9a6655ef4d973177e9d (diff)
downloadllvm-e1b6b5290373073c95f6865ceaf76fa7848ecf44.tar.gz
llvm-e1b6b5290373073c95f6865ceaf76fa7848ecf44.tar.bz2
llvm-e1b6b5290373073c95f6865ceaf76fa7848ecf44.tar.xz
Add code to GlobalVariable.h so that global variables marked as
externally_initialized return false for hasDefiniteInitializer and hasUniqueInitializer. rdar://12580965. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IR/GlobalVariable.h')
-rw-r--r--include/llvm/IR/GlobalVariable.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h
index bf1e89181e..112a8468e3 100644
--- a/include/llvm/IR/GlobalVariable.h
+++ b/include/llvm/IR/GlobalVariable.h
@@ -110,7 +110,10 @@ public:
return hasInitializer() &&
// The initializer of a global variable with weak linkage may change at
// link time.
- !mayBeOverridden();
+ !mayBeOverridden() &&
+ // The initializer of a global variable with the externally_initialized
+ // marker may change at runtime before cxx initializers are evaluated.
+ !isExternallyInitialized();
}
/// hasUniqueInitializer - Whether the global variable has an initializer, and
@@ -123,7 +126,11 @@ public:
// instead. It is wrong to modify the initializer of a global variable
// with *_odr linkage because then different instances of the global may
// have different initializers, breaking the One Definition Rule.
- !isWeakForLinker();
+ !isWeakForLinker() &&
+ // It is not safe to modify initializers of global variables with the
+ // external_initializer marker since the value may be changed at runtime
+ // before cxx initializers are evaluated.
+ !isExternallyInitialized();
}
/// getInitializer - Return the initializer for this global variable. It is