Skip to content

Commit

Permalink
Handle a symbol being undefined.
Browse files Browse the repository at this point in the history
This can happen if:
* It is present in a comdat in one file.
* It is not present in the comdat of the file that is kept.
* Is is not used.

This should fix the LTO boostrap.

Thanks to Takumi NAKAMURA for setting up the bot!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225983 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Jan 14, 2015
1 parent 81e68c9 commit 5f92811
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test/tools/gold/Inputs/comdat.ll
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion tools/gold/gold-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 5f92811

Please sign in to comment.