Always remove an alias when we rename the target.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 12 Jun 2013 16:45:47 +0000 (16:45 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 12 Jun 2013 16:45:47 +0000 (16:45 +0000)
Should fix the dragonegg build bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183845 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp
test/Transforms/GlobalOpt/alias-resolve.ll

index 72ba250f470fb7dee1c51e5c0cf75c13c1b2a718..a4de71b3ae66ea7ed4b48b8a5062ba9e98d6c6fc 100644 (file)
@@ -3238,9 +3238,7 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
 
       if (Used.compilerUsedErase(J))
         Used.compilerUsedInsert(Target);
-    }
-
-    if (mayHaveOtherReferences(*J, Used))
+    } else if (mayHaveOtherReferences(*J, Used))
       continue;
 
     // Delete the alias.
index a42dd280da8678cb5248608d6d2b551fb91f78aa..32f4bf8ebe255e87071a66a593c596552d3cbe35 100644 (file)
@@ -1,4 +1,7 @@
-; RUN: opt < %s -globalopt -S | FileCheck %s
+; We use a temporary file so that the test fails when opt crashes.
+
+; RUN: opt < %s -globalopt -S > %t
+; RUN: FileCheck %s < %t
 
 @foo1 = alias void ()* @foo2
 ; CHECK: @foo1 = alias void ()* @foo2
@@ -25,3 +28,11 @@ entry:
 
          ret void
 }
+
+@foo3 = alias void ()* @bar3
+; CHECK-NOT: bar3
+
+define internal void @bar3() {
+  ret void
+}
+;CHECK: define void @foo3