|
| 1 | +; https://github.com/llvm/llvm-project/pull/110064 |
| 2 | +; This test case checks if thinLTO correctly links metadata values in a specific |
| 3 | +; situation. Assume we are linking module B into module A, where an extern |
| 4 | +; function used in A is defined in B, but the function body has a |
| 5 | +; DITemplateValueParameter referring to another function back in A. The |
| 6 | +; compiler must check this other function is actually coming from A, thus |
| 7 | +; already materialized and does not require remapping. The IR here is modified |
| 8 | +; from the following source code. |
| 9 | +; |
| 10 | +; // A.h |
| 11 | +; template <void (*Func)()> |
| 12 | +; struct S { |
| 13 | +; void Impl() { |
| 14 | +; Func(); |
| 15 | +; } |
| 16 | +; }; |
| 17 | +; |
| 18 | +; void func1(); |
| 19 | +; |
| 20 | +; // A.cpp |
| 21 | +; #include "A.h" |
| 22 | +; __attribute__((weak)) void func1() {} |
| 23 | +; extern void thinlto1(); |
| 24 | +; void bar() { |
| 25 | +; S<func1> s; // Force instantiation of S<func1> in this compilation unit. |
| 26 | +; s.Impl(); |
| 27 | +; thinlto1(); |
| 28 | +; } |
| 29 | +; |
| 30 | +; // B.cpp |
| 31 | +; #include "A.h" |
| 32 | +; void thinlto1() { |
| 33 | +; S<func1> s; |
| 34 | +; } |
| 35 | +; |
| 36 | +; RUN: opt -module-summary -o %t1.bc %s |
| 37 | +; RUN: opt -module-summary -o %t2.bc %S/Inputs/ditemplatevalueparameter-remap.ll |
| 38 | +; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t3 -save-temps \ |
| 39 | +; RUN: -r=%t1.bc,_Z5func1v,p \ |
| 40 | +; RUN: -r=%t1.bc,_Z3bazv,px \ |
| 41 | +; RUN: -r=%t1.bc,_Z8thinlto1v,x \ |
| 42 | +; RUN: -r=%t1.bc,_Z3barv,px \ |
| 43 | +; RUN: -r=%t2.bc,_Z8thinlto1v,px |
| 44 | +; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s |
| 45 | + |
| 46 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
| 47 | +target triple = "x86_64-unknown-linux-gnu" |
| 48 | + |
| 49 | +$_Z5func1v = comdat any |
| 50 | + |
| 51 | +define linkonce_odr void @_Z5func1v() unnamed_addr !dbg !10 { |
| 52 | + ret void |
| 53 | +} |
| 54 | + |
| 55 | +; Dummy function to use _Z5func1v so that it is not treated as dead symbol. |
| 56 | +define void @_Z3bazv() { |
| 57 | + tail call void @_Z5func1v() |
| 58 | + ret void |
| 59 | +} |
| 60 | + |
| 61 | +declare void @_Z8thinlto1v() unnamed_addr |
| 62 | + |
| 63 | +; Check _Z8thinlto1v is inlined after thinLTO. |
| 64 | +; CHECK: void @_Z3barv() |
| 65 | +; CHECK-NOT: @_Z8thinlto1v() |
| 66 | +; CHECK-NEXT: ret void |
| 67 | +define void @_Z3barv() unnamed_addr !dbg !14 { |
| 68 | + tail call void @_Z8thinlto1v(), !dbg !25 |
| 69 | + ret void |
| 70 | +} |
| 71 | + |
| 72 | +!llvm.dbg.cu = !{!0} |
| 73 | +!llvm.module.flags = !{!2, !3, !4, !5} |
| 74 | + |
| 75 | +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) |
| 76 | +!1 = !DIFile(filename: "A.cpp", directory: ".") |
| 77 | +!2 = !{i32 7, !"Dwarf Version", i32 4} |
| 78 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 79 | +!4 = !{i32 1, !"wchar_size", i32 4} |
| 80 | +!5 = !{i32 8, !"PIC Level", i32 2} |
| 81 | +!10 = distinct !DISubprogram(name: "func1", linkageName: "_Z5func1v", scope: !11, file: !11, line: 6, type: !12, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 82 | +!11 = !DIFile(filename: "a.h", directory: ".") |
| 83 | +!12 = !DISubroutineType(types: !13) |
| 84 | +!13 = !{null} |
| 85 | +!14 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !11, file: !11, line: 15, type: !12, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16) |
| 86 | +!16 = !{!17} |
| 87 | +!17 = !DILocalVariable(name: "s", scope: !14, file: !11, line: 10, type: !18) |
| 88 | +!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S<&func1>", file: !11, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !19, templateParams: !20, identifier: "_ZTS1SIXadL_Z5func1vEEE") |
| 89 | +!19 = !{} |
| 90 | +!20 = !{!21} |
| 91 | +!21 = !DITemplateValueParameter(name: "Func", type: !22, value: ptr @_Z5func1v) |
| 92 | +!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) |
| 93 | +!25 = !DILocation(line: 16, column: 5, scope: !14) |
0 commit comments