summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/test/tools/gold/Inputs/comdat.ll5
-rw-r--r--llvm/tools/gold/gold-plugin.cpp6
2 files changed, 10 insertions, 1 deletions
diff --git a/llvm/test/tools/gold/Inputs/comdat.ll b/llvm/test/tools/gold/Inputs/comdat.ll
index 8b699d439c5..464aefa49dc 100644
--- a/llvm/test/tools/gold/Inputs/comdat.ll
+++ b/llvm/test/tools/gold/Inputs/comdat.ll
@@ -1,4 +1,9 @@
$c2 = comdat any
+$c1 = comdat any
+
+; This is only present in this file. The linker will keep $c1 from the first
+; file and this will be undefined.
+@will_be_undefined = global i32 1, comdat($c1)
@v1 = weak_odr global i32 41, comdat($c2)
define weak_odr protected i32 @f1(i8* %this) comdat($c2) {
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index 1ba08cc53dc..bcc91e9d061 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -629,10 +629,14 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile,
case LDPR_RESOLVED_IR:
case LDPR_RESOLVED_EXEC:
case LDPR_RESOLVED_DYN:
- case LDPR_UNDEF:
assert(GV->isDeclarationForLinker());
break;
+ case LDPR_UNDEF:
+ assert(GV->hasComdat());
+ Drop.insert(GV);
+ break;
+
case LDPR_PREVAILING_DEF_IRONLY: {
keepGlobalValue(*GV, KeptAliases);
if (!Used.count(GV)) {
OpenPOWER on IntegriCloud