[REGRESSION] Compiler aborts in LTO
| Bugzilla Link | 30509 |
| Resolution | FIXED |
| Resolved on | Nov 07, 2018 00:17 |
| Version | trunk |
| OS | Linux |
| Depends On | llvm/llvm-project#29716 |
| Reporter | LLVM Bugzilla Contributor |
| CC | @arpilipe,@pcc |
Extended Description
Compiler aborts while building one of our internal benchmarks with following build error:
trunk/llvm/lib/LTO/LTO.cpp:335: llvm::Error llvm::lto::LTO::addRegularLTO(std::unique_ptrllvm::lto::InputFile, llvm::ArrayRefllvm::lto::SymbolResolution): Assertion `ResI != Res.end()' failed. clang-4.0: error: unable to execute command: Aborted (core dumped)
I shall try to come up with a test case.
The regression is introduced in r281853.
Verified! Thanks to all.
283117
I didn't manage to reproduce it locally with ToT and the last example. Here is the output in my case: ld.lld -o t2 1.bc 2.bc entry symbol _start not found, assuming 0 But it produces the output file successfully.
Rafael, I'm willing to review the patch.
Thanks. It is at https://reviews.llvm.org/D25184
I didn't manage to reproduce it locally with ToT and the last example. Here is the output in my case: ld.lld -o t2 1.bc 2.bc entry symbol _start not found, assuming 0 But it produces the output file successfully.
Rafael, I'm willing to review the patch.
I think I have a patch that at least avoids the LTO issue.
This reduces to just
file1.llvm.ll: target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" %foo = type { } declare <4 x %foo*> @llvm.masked.load.v4p0foo.p0v4p0foo(<4 x %foo*>, i32, <4 x i1>, <4 x %foo>)
and
file2.llvm.ll target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" %foo = type { } declare void @foo( %foo* )
which crashes with
ld.lld -o t2 file2.llvm.bc file1.llvm.bc
I'll take a look.
I'm removing my name from this bug, since my commit only triggered an existing bug in address space casting of "masked.load" intrinsic. Artur should, probably, take it.
The problem is that the second input's symbol table differs depending on whether we load it into a context on its own or into a context with the first input already loaded. In the latter case "%struct.sv" in the second input is renamed to "%struct.sv.1" because of a conflict with the "%struct.sv" in the first input. That causes us to take the branch at http://llvm-cs.pcc.me.uk/lib/IR/AutoUpgrade.cpp#179 and we rename the intrinsic to "masked.load.v4p0struct.sv.p0v4p0struct.sv.old", which causes the symbol table to change since that is not the name of an intrinsic function.
Most likely what needs to happen is that the "masked.load.v4p0struct.sv.p0v4p0struct.sv.old" function needs to be removed rather than being left in the module.
I am copying Artur Pilipenko, the author of the autoupgrade code for this intrinsic (https://reviews.llvm.org/D17270).
Reproduced. Adding Peter who owns/developed the new LTO API where this is failing and is most familiar with it.
I added LTO people to CC. Can anybody say me what's wrong with the input ll files? I'm trying to build llvmgold.so meanwhile.. Thank you.
Yes, please provide a test case. It may be an unrelated bug in LTO, since I did not touch LTO in this patch at all.
assigned to @arpilipe