llvm-project
llvm-project copied to clipboard
Clang 15 LTO assertion failure with ifunc referenced by global
Building https://github.com/ColinIanKing/stress-ng with clang and -flto
results in an assertion failure during the LTO step:
ld.gold: /home/npopov/repos/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:6597: std::pair<llvm::ValueInfo, long unsigned int> {anonymous}::ModuleSummaryIndexBitcodeReader::getValueInfoFromValueId(unsigned int): Assertion `VGI.first' failed.
The problematic input appears to be stress-cpu.o
, which results in the same assertion when run through llvm-dis
.
At a guess, this has something to do with ifuncs.
Problematic IR file (marginally reduced): https://gist.github.com/nikic/982993b057bd9362b0055a90926e5437
Tested with build/bin/opt -module-summary < $1 | build/bin/llvm-dis
.
Unfortunately none of our reduction tooling works with this, probably because something in bitcode reading or writing itself is broken.
Reduced:
@gv = constant ptr @ifunc
@ifunc = ifunc void (ptr), ptr @resolver
define ptr @resolver() {
ret ptr null
}
cc @teresajohnson, who is hopefully familiar with ModuleSummaryAnalysis.
Also cc @SchrodingerZhu who did recent work on LTO + ifuncs.
This seems to be related to the linker behavior. So ifunc will not appear in the summary; guess this is causing the issue. Maybe someone has insights of gold linker could take a look at the problem?
This https://reviews.llvm.org/D144982 solves the crash with the above reproducers.