[PATCH] D53241: [GlobalOpt] Never remove global values from non-discardable COMDATs
Aaron Hill via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 12 20:34:02 PDT 2018
Aaron1011 created this revision.
Aaron1011 added reviewers: pcc, tejohnson.
Herald added a subscriber: llvm-commits.
Currently, GlobalOpt will remove global values from non-discardable COMDATS (COMDATS which have at least one live object) if the value in question has local linkage.
As described in https://reviews.llvm.org/D53234, this is an invalid treatment of COMDAT members, and can lead to issues when using MD_Associated metadata.
I've modified GlobalOpt to always bail out of global value removal if the global value is in a non-discardable COMDAT.
I've also modified the associated test to check that one of its functions, which GlobalOpt currently removes due to its local linkage, is now kept.
Repository:
rL LLVM
https://reviews.llvm.org/D53241
Files:
lib/Transforms/IPO/GlobalOpt.cpp
test/Transforms/GlobalOpt/preserve-comdats.ll
Index: test/Transforms/GlobalOpt/preserve-comdats.ll
===================================================================
--- test/Transforms/GlobalOpt/preserve-comdats.ll
+++ test/Transforms/GlobalOpt/preserve-comdats.ll
@@ -24,7 +24,7 @@
store i8 42, i8* @simple_global
ret void
}
-; CHECK-NOT: @init_simple_global()
+; CHECK: define internal fastcc void @init_simple_global() unnamed_addr comdat($comdat_global)
define i8* @use_simple() {
ret i8* @simple_global
Index: lib/Transforms/IPO/GlobalOpt.cpp
===================================================================
--- lib/Transforms/IPO/GlobalOpt.cpp
+++ lib/Transforms/IPO/GlobalOpt.cpp
@@ -1743,7 +1743,7 @@
return false;
if (const Comdat *C = GV.getComdat())
- if (!GV.hasLocalLinkage() && NotDiscardableComdats.count(C))
+ if (NotDiscardableComdats.count(C))
return false;
bool Dead;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53241.169539.patch
Type: text/x-patch
Size: 887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181013/57b21698/attachment.bin>
More information about the llvm-commits
mailing list