[PATCH] D99629: [GlobalOpt] Don't replace alias with aliasee if aliasee is interposable
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 30 17:33:23 PDT 2021
aeubanks updated this revision to Diff 334312.
aeubanks added a comment.
update
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99629/new/
https://reviews.llvm.org/D99629
Files:
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/GlobalOpt/alias-resolve.ll
Index: llvm/test/Transforms/GlobalOpt/alias-resolve.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/alias-resolve.ll
+++ llvm/test/Transforms/GlobalOpt/alias-resolve.ll
@@ -33,7 +33,10 @@
; CHECK: call void @bar2()
call void @weak1()
-; CHECK: call void @weak1()
+; CHECK: call void @bar2()
+
+ call void @bar6()
+; CHECK: call void @bar6()
ret void
}
@@ -44,3 +47,9 @@
ret void
}
;CHECK: define void @foo3
+
+define weak void @bar5() {
+ ret void
+}
+
+ at bar6 = alias void(), void ()* @bar5
Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2932,16 +2932,14 @@
continue;
}
- // If the alias can change at link time, nothing can be done - bail out.
- if (J->isInterposable())
- continue;
-
Constant *Aliasee = J->getAliasee();
GlobalValue *Target = dyn_cast<GlobalValue>(Aliasee->stripPointerCasts());
// We can't trivially replace the alias with the aliasee if the aliasee is
- // non-trivial in some way.
+ // non-trivial in some way. We also can't replace the alias with the aliasee
+ // if the aliasee is interposable because aliases point to the local
+ // definition.
// TODO: Try to handle non-zero GEPs of local aliasees.
- if (!Target)
+ if (!Target || Target->isInterposable())
continue;
Target->removeDeadConstantUsers();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99629.334312.patch
Type: text/x-patch
Size: 1558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210331/604fa184/attachment.bin>
More information about the llvm-commits
mailing list