return 0;
}
-const GlobalValue *GlobalAlias::resolveAliasedGlobal() const {
+const GlobalValue *GlobalAlias::resolveAliasedGlobal(bool stopOnWeak) const {
SmallPtrSet<const GlobalValue*, 3> Visited;
+ // Check if we need to stop early.
+ if (stopOnWeak && 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 (stopOnWeak && GA->hasWeakLinkage())
+ break;
+
GV = GA->getAliasedGlobal();
if (!Visited.insert(GV))