File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
test/Transforms/GlobalOpt Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2865,7 +2865,12 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
2865
2865
continue ;
2866
2866
2867
2867
Constant *Aliasee = J->getAliasee ();
2868
- GlobalValue *Target = cast<GlobalValue>(Aliasee->stripPointerCasts ());
2868
+ GlobalValue *Target = dyn_cast<GlobalValue>(Aliasee->stripPointerCasts ());
2869
+ // We can't trivially replace the alias with the aliasee if the aliasee is
2870
+ // non-trivial in some way.
2871
+ // TODO: Try to handle non-zero GEPs of local aliasees.
2872
+ if (!Target)
2873
+ continue ;
2869
2874
Target->removeDeadConstantUsers ();
2870
2875
2871
2876
// Make all users of the alias use the aliasee instead.
Original file line number Diff line number Diff line change 12
12
@weak1 = alias weak void ()* @bar2
13
13
; CHECK: @weak1 = alias weak void ()* @bar2
14
14
15
+ @bar4 = private unnamed_addr constant [2 x i8* ] zeroinitializer
16
+ @foo4 = unnamed_addr alias linkonce_odr getelementptr inbounds ([2 x i8* ]* @bar4 , i32 0 , i32 1 )
17
+ ; CHECK: @foo4 = unnamed_addr alias linkonce_odr getelementptr inbounds ([2 x i8*]* @bar4, i32 0, i32 1)
18
+
15
19
define void @bar2 () {
16
20
ret void
17
21
}
You can’t perform that action at this time.
0 commit comments