[llvm-bugs] [Bug 38372] New: ThinLTO IR verification error (Called function is not the same type as the call!)
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 30 10:49:35 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38372
Bug ID: 38372
Summary: ThinLTO IR verification error (Called function is not
the same type as the call!)
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Linker
Assignee: unassignedbugs at nondot.org
Reporter: trent.xin.tong at gmail.com
CC: llvm-bugs at lists.llvm.org
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).
~/llvm/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.
Commands to reproduce with ToT LLVM:
===============================
~/llvm/build-debug/bin/opt -module-summary -o a.o a.ll
~/llvm/build-debug/bin/opt -module-summary -o b.o b.ll
~/llvm/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
[~/thinltobug]$ cat a.ll
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.TA = type {}
@gv = dso_local global %struct.TA * zeroinitializer
define i32 @c() !dbg !6 {
bitcast %struct.TA ** @gv to i8*
unreachable
}
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 1, !"ThinLTO", i32 0}
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3,
retainedTypes: !4)
!3 = !DIFile(filename: "f2", directory: "")
!4 = !{!5}
!5 = !DICompositeType(tag: DW_TAG_class_type, file: !3, flags:
DIFlagFwdDecl, identifier: "SHARED")
!6 = distinct !DISubprogram(unit: !2)
[~/thinltobug]$ cat b.ll
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.TA = type opaque
@gv = external dso_local global %struct.TA *
define i1 @b(%struct.TA*) {
unreachable
}
define i1 @a(%struct.TA* %a) {
call i1 @b(%struct.TA* %a)
unreachable
}
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 1, !"ThinLTO", i32 0}
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3,
retainedTypes: !4)
!3 = !DIFile(filename: "f1", directory: "")
!4 = !{!5, !9}
!5 = !DICompositeType(tag: DW_TAG_class_type, file: !3,
templateParams: !6, scope: !8)
!6 = !{!7}
; The reference to @b and struct.TA.0 (renamed) that will be loaded in %a.o
!7 = !DITemplateValueParameter(value: i1 (%struct.TA*)* @b)
!8 = distinct !DISubprogram(unit: !2)
!9 = !DICompositeType(tag: DW_TAG_class_type, file: !3, identifier:
"SHARED", scope: !8)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180730/39ef6a38/attachment.html>
More information about the llvm-bugs
mailing list