1 ; RUN: opt -module-summary -o %t0.o %S/Inputs/type-mapping-bug4_0.ll
2 ; RUN: opt -module-summary -o %t1.o %S/Inputs/type-mapping-bug4_1.ll
3 ; RUN: opt -module-summary -o %t2.o %s
4 ; RUN: llvm-lto2 run -save-temps -o %t3 %t0.o %t1.o %t2.o -r %t1.o,a,px -r %t2.o,d,px -r %t1.o,h,x -r %t2.o,h,x -r %t1.o,j,px
5 ; RUN: llvm-dis < %t3.0.0.preopt.bc | FileCheck %s
9 ; stage2: during linking t1.o, mapping @d
10 ; stage3: linking t2.o
12 ; Stage0 is not described because it is not interesting for the purpose of this test.
13 ; Stage1 and stage2 are described in type-mapping-bug4_1.ll.
14 ; Stage3 is described in this file.
16 ; CHECK: %class.CCSM = type opaque
17 ; CHECK: %class.CB = type { %"class.std::unique_ptr_base.1" }
18 ; CHECK: %"class.std::unique_ptr_base.1" = type { %class.CCSM* }
20 ; CHECK: define void @j() {
21 ; CHECK: call void @h(%class.CCSM* undef)
25 ; CHECK: declare void @h(%class.CCSM*)
27 ; CHECK: define void @a() {
28 ; CHECK: call void @llvm.dbg.value(metadata %class.CB* undef, metadata !10, metadata !DIExpression())
32 ; CHECK: declare void @llvm.dbg.value(metadata, metadata, metadata) #0
34 ; CHECK: define void @d(%class.CB* %0) {
35 ; CHECK: %2 = getelementptr inbounds %class.CB, %class.CB* undef, i64 0, i32 0, i32 0
39 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
40 target triple = "x86_64-unknown-linux-gnu"
42 ; (stage3) Remapping this type returns itself due to D47898 and stage1.3
43 %class.CB = type { %"class.std::unique_ptr_base.2" }
45 ; (stage3) Remapping this type returns itself due to D47898 and stage2
46 %"class.std::unique_ptr_base.2" = type { %class.CCSM* }
48 %class.CCSM = type opaque
50 ; (stage3) computeTypeMapping add the mapping %class.CCSM -> %class.CWBD due to stage1.2
51 declare void @h(%class.CCSM*)
53 define void @d(%class.CB*) {
54 ; Without the fix in D87001 to delay materialization of @d until its module is linked
56 ; * SourceElementType of getelementptr is remapped to itself.
57 ; * ResultElementType of getelementptr is incorrectly remapped to %class.CWBD*.
58 ; Its type should be %class.CCSM*.
59 %2 = getelementptr inbounds %class.CB, %class.CB* undef, i64 0, i32 0, i32 0
64 !llvm.module.flags = !{!0, !1}
65 !0 = !{i32 1, !"ThinLTO", i32 0}
66 !1 = !{i32 2, !"Debug Info Version", i32 3}
67 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, retainedTypes: !4)
68 !3 = !DIFile(filename: "f1", directory: "")
71 ; This DICompositeType is referenced by !5 in Inputs/type-mapping-bug4_1.ll
72 ; causing the function type in !7 to be added to its module.
73 !5 = !DICompositeType(tag: DW_TAG_structure_type, templateParams: !6, identifier: "SHARED")
76 ; The reference to d and %class.CB that gets loaded into %t1.o
77 !7 = !DITemplateValueParameter(value: void (%class.CB*)* @d)