Hi
I have encountered a module verification failure when running 2 files
with thin-lto (I hit this bug in the link step in LTO on a really
large program and I reduced to this test case).
~/llvmfb/build-debug/bin/llvm-lto2 run -o c a.o b.o -r a.o,c,px -r
b.o,a,px -r b.o,b,px -r a.o,gv -r b.o,gv
Called function is not the same type as the call!
%2 = call i1 bitcast (i1 (%struct.TA*)* @b to i1 (%0*)*)(%struct.TA* %0)
in function a
LLVM ERROR: Broken function found, compilation aborted!
My understanding why this is happening is roughly as follow. I would
like to check with people whether this is a real bug. And also would
like to help fixing it with other people’s help if it’s a real bug. I
am quite new to this part of LLVM.
1. DICompositeType “SHARED” in a.ll is ODRed with the one in b.ll at load time.
2. %struct.TA.0 (renamed from %struct.TA at load time) = type opaque
and i1 (%struct.TA.0*)* @b in b.ll gets pulled into the destination
module when we are merging in a.ll.
3. We only found out that %struct.TA.0 maps to %struct.TA when we link
in b.ll because of the @gv global variable.
4. Then we have a problem, because declare i1 @b(%struct.TA.0*) in
a.ll should have been remapped due to what we found in #3, but was
not. This eventually leads to the IR verifier failure.
Thanks
-Xin
Commands to reproduce with ToT LLVM: