Use mayBeOverridden here, in anticipation of the
[oota-llvm.git] / lib / VMCore / Globals.cpp
index 7340f1532f536c4278df179316f968437b123188..de1b247150ea3e6db8002e071cf6f5b1cb81df36 100644 (file)
@@ -248,13 +248,21 @@ const GlobalValue *GlobalAlias::getAliasedGlobal() const {
   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 && mayBeOverridden())
+    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->mayBeOverridden())
+      break;
+
     GV = GA->getAliasedGlobal();
 
     if (!Visited.insert(GV))