diff options
-rw-r--r-- | lld/COFF/SymbolTable.cpp | 14 | ||||
-rw-r--r-- | lld/test/COFF/lto-new-symbol.ll | 16 |
2 files changed, 26 insertions, 4 deletions
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index fc7aaf2eb80..55721f78528 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -269,12 +269,18 @@ std::error_code SymbolTable::addCombinedLTOObject() { if (!Body->isExternal()) continue; - // Find an existing Symbol. We should not see any new symbols at this point. + // Find an existing Symbol. We should not see any new undefined symbols at + // this point. StringRef Name = Body->getName(); - Symbol *Sym = Symtab[Name]; + Symbol *&Sym = Symtab[Name]; if (!Sym) { - llvm::errs() << "LTO: unexpected new symbol: " << Name << '\n'; - return make_error_code(LLDError::BrokenFile); + if (!isa<Defined>(Body)) { + llvm::errs() << "LTO: undefined symbol: " << Name << '\n'; + return make_error_code(LLDError::BrokenFile); + } + Sym = new (Alloc) Symbol(Body); + Body->setBackref(Sym); + continue; } Body->setBackref(Sym); diff --git a/lld/test/COFF/lto-new-symbol.ll b/lld/test/COFF/lto-new-symbol.ll new file mode 100644 index 00000000000..1531895e6a8 --- /dev/null +++ b/lld/test/COFF/lto-new-symbol.ll @@ -0,0 +1,16 @@ +; RUN: llvm-as -o %t.obj %s +; RUN: lld -flavor link2 /out:%t.exe /entry:foo /subsystem:console %t.obj + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc" + +define void @foo(<4 x i32>* %p, <4 x float>* %q, i1 %t) nounwind { +entry: + br label %loop +loop: + store <4 x i32><i32 1073741824, i32 1073741824, i32 1073741824, i32 1073741824>, <4 x i32>* %p + store <4 x float><float 2.0, float 2.0, float 2.0, float 2.0>, <4 x float>* %q + br i1 %t, label %loop, label %ret +ret: + ret void +} |