[PATCH] D40593: ThinLTOBitcodeWriter: Try harder to discard unused references to the merged module.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 15:06:25 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319494: ThinLTOBitcodeWriter: Try harder to discard unused references to the merged… (authored by pcc).
Changed prior to commit:
https://reviews.llvm.org/D40593?vs=124678&id=125038#toc
Repository:
rL LLVM
https://reviews.llvm.org/D40593
Files:
llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
Index: llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -40,9 +40,17 @@
continue;
auto Name = ExportGV.getName();
- GlobalValue *ImportGV = ImportM.getNamedValue(Name);
- if ((!ImportGV || ImportGV->use_empty()) && !PromoteExtra.count(&ExportGV))
- continue;
+ GlobalValue *ImportGV = nullptr;
+ if (!PromoteExtra.count(&ExportGV)) {
+ ImportGV = ImportM.getNamedValue(Name);
+ if (!ImportGV)
+ continue;
+ ImportGV->removeDeadConstantUsers();
+ if (ImportGV->use_empty()) {
+ ImportGV->eraseFromParent();
+ continue;
+ }
+ }
std::string NewName = (Name + ModuleId).str();
Index: llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
===================================================================
--- llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
+++ llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
@@ -1,7 +1,9 @@
; RUN: opt -thinlto-bc -o %t %s
; RUN: llvm-modextract -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=CHECK0 %s
; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=CHECK1 %s
+; CHECK0-NOT: @{{.*}}anon{{.*}}=
; CHECK0: @al = external global i8*
+; CHECK0-NOT: @{{.*}}anon{{.*}}=
; CHECK1: @al = unnamed_addr alias i8*,
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40593.125038.patch
Type: text/x-patch
Size: 1560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/6cc4aeda/attachment.bin>
More information about the llvm-commits
mailing list