[llvm] r256276 - Delete dead GlobalAliases.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 22 11:50:23 PST 2015
Author: rafael
Date: Tue Dec 22 13:50:22 2015
New Revision: 256276
URL: http://llvm.org/viewvc/llvm-project?rev=256276&view=rev
Log:
Delete dead GlobalAliases.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/test/Transforms/GlobalOpt/alias-resolve.ll
llvm/trunk/test/Transforms/GlobalOpt/deadglobal.ll
llvm/trunk/test/Transforms/GlobalOpt/localize-constexpr.ll
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=256276&r1=256275&r2=256276&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Dec 22 13:50:22 2015
@@ -2993,10 +2993,17 @@ bool GlobalOpt::OptimizeGlobalAliases(Mo
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
I != E;) {
- Module::alias_iterator J = I++;
+ GlobalAlias *J = &*I++;
+
// Aliases without names cannot be referenced outside this module.
if (!J->hasName() && !J->isDeclaration() && !J->hasLocalLinkage())
J->setLinkage(GlobalValue::InternalLinkage);
+
+ if (deleteIfDead(*J)) {
+ Changed = true;
+ continue;
+ }
+
// If the aliasee may change at link time, nothing can be done - bail out.
if (J->mayBeOverridden())
continue;
Modified: llvm/trunk/test/Transforms/GlobalOpt/alias-resolve.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/alias-resolve.ll?rev=256276&r1=256275&r2=256276&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/alias-resolve.ll (original)
+++ llvm/trunk/test/Transforms/GlobalOpt/alias-resolve.ll Tue Dec 22 13:50:22 2015
@@ -13,8 +13,8 @@
; CHECK: @weak1 = weak alias void (), void ()* @bar2
@bar4 = private unnamed_addr constant [2 x i8*] zeroinitializer
- at foo4 = linkonce_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
-; CHECK: @foo4 = linkonce_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
+ at foo4 = weak_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
+; CHECK: @foo4 = weak_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
define void @bar2() {
ret void
Modified: llvm/trunk/test/Transforms/GlobalOpt/deadglobal.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/deadglobal.ll?rev=256276&r1=256275&r2=256276&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/deadglobal.ll (original)
+++ llvm/trunk/test/Transforms/GlobalOpt/deadglobal.ll Tue Dec 22 13:50:22 2015
@@ -1,11 +1,14 @@
; RUN: opt < %s -globalopt -S | FileCheck %s
@G1 = internal global i32 123 ; <i32*> [#uses=1]
+ at A1 = internal alias i32, i32* @G1
; CHECK-NOT: @G1
; CHECK: @G2
; CHECK-NOT: @G3
+; CHECK-NOT: @A1
+
define void @foo1() {
; CHECK: define void @foo
; CHECK-NEXT: ret
Modified: llvm/trunk/test/Transforms/GlobalOpt/localize-constexpr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/localize-constexpr.ll?rev=256276&r1=256275&r2=256276&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/localize-constexpr.ll (original)
+++ llvm/trunk/test/Transforms/GlobalOpt/localize-constexpr.ll Tue Dec 22 13:50:22 2015
@@ -13,7 +13,7 @@ define i8 @f() norecurse {
}
@H = internal global i32 42
- at Halias = internal alias i32, i32* @H
+ at Halias = alias i32, i32* @H
; @H can't be localized because @Halias uses it, and @Halias can't be converted to an instruction.
define i8 @g() norecurse {
More information about the llvm-commits
mailing list