summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Globals.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/VMCore/Globals.cpp')
-rw-r--r--llvm/lib/VMCore/Globals.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp
index 7340f1532f5..e55cb5a5ac5 100644
--- a/llvm/lib/VMCore/Globals.cpp
+++ b/llvm/lib/VMCore/Globals.cpp
@@ -248,13 +248,21 @@ const GlobalValue *GlobalAlias::getAliasedGlobal() const {
return 0;
}
-const GlobalValue *GlobalAlias::resolveAliasedGlobal() const {
+const GlobalValue *GlobalAlias::resolveAliasedGlobal(bool traverseWeak) const {
SmallPtrSet<const GlobalValue*, 3> Visited;
+ // Check if we need to stop early.
+ if (!traverseWeak && hasWeakLinkage())
+ return this;
+
const GlobalValue *GV = getAliasedGlobal();
Visited.insert(GV);
+ // Iterate over aliasing chain, stopping on weak alias if necessary.
while (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV)) {
+ if (traverseWeak && GA->hasWeakLinkage())
+ break;
+
GV = GA->getAliasedGlobal();
if (!Visited.insert(GV))
OpenPOWER on IntegriCloud