xref: /llvm-project/llvm/test/LTO/X86/type-mapping-bug3.ll (revision 4e4c89a16e5696f03bd39160a099462d9c847cd5)
1; RUN: opt -module-summary -o %t0.o %S/Inputs/type-mapping-bug3.ll
2; RUN: opt -module-summary -o %t1.o %s
3; RUN: llvm-lto2 run -o %t2 %t0.o %t1.o -r %t0.o,a,px -r %t1.o,b,px -r %t1.o,c,px -r %t1.o,d,
4;
5; Test for the issue described in https://bugs.llvm.org/show_bug.cgi?id=40312
6
7target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8target triple = "x86_64-unknown-linux-gnu"
9
10; T2 is the non-opaque struct required to trigger the uniqued T2.0 and T3.0 to
11; respectively T2 and T3 in the destination module.
12%"T2" = type { ptr }
13%"T3" = type opaque
14
15; Use/refer to T2 so it gets added as an IdentifiedStructType.
16define void @c(%"T2") {
17    unreachable
18}
19
20; The global declaration that causes the assertion when its type is mapped to
21; itself incorrectly.
22declare void @d(ptr)
23
24define void @b() {
25entry:
26  %f.addr = alloca ptr load ptr, ptr %f.addr
27
28  ; The call with the getCalledOperand() vs getCalledFunction() mismatch.
29  call void @d(ptr %0)
30  unreachable
31}
32
33!llvm.dbg.cu = !{!2}
34!llvm.module.flags = !{!0, !1}
35!0 = !{i32 1, !"ThinLTO", i32 0}
36!1 = !{i32 2, !"Debug Info Version", i32 3}
37!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, retainedTypes: !4)
38!3 = !DIFile(filename: "f1", directory: "")
39!4 = !{!5}
40
41; This DICompositeType is referenced by !5 in Inputs/type-mapping-bug3.ll
42; causing the function type in !7 to be added to its module.
43!5 = !DICompositeType(tag: DW_TAG_structure_type, templateParams: !6, identifier: "SHARED")
44!6 = !{!7}
45
46; The reference to d and T3 that gets loaded into %t0.o
47!7 = !DITemplateValueParameter(value: ptr @d)
48