<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - ThinLTO IR verification error (Called function is not the same type as the call!)"
href="https://bugs.llvm.org/show_bug.cgi?id=38372">38372</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ThinLTO IR verification error (Called function is not the same type as the call!)
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Linker
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>trent.xin.tong@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>