summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp14
-rw-r--r--llvm/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll2
2 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 7d6d538bc11..4138606bf0f 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -40,9 +40,17 @@ void promoteInternals(Module &ExportM, Module &ImportM, StringRef ModuleId,
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();
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
index 48f2900da36..eb0cbe78a73 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
+++ b/llvm/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"
OpenPOWER on IntegriCloud