brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · a008485 Raw
94 lines · plain
1; https://github.com/llvm/llvm-project/pull/1100642; This test case checks if thinLTO correctly links metadata values in a specific3; situation. Assume we are linking module B into module A, where an extern4; function used in A is defined in B, but the function body has a5; DITemplateValueParameter referring to another function back in A. The6; compiler must check this other function is actually coming from A, thus7; already materialized and does not require remapping. The IR here is modified8; from the following source code.9;10; // A.h11; template <void (*Func)()>12; struct S {13;   void Impl() {14;     Func();15;   }16; };17;18; void func1();19;20; // A.cpp21; #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.cpp31; #include "A.h"32; void thinlto1() {33;   S<func1> s;34; }35;36; RUN: opt -module-summary -o %t1.bc %s37; RUN: opt -module-summary -o %t2.bc %S/Inputs/ditemplatevalueparameter-remap.ll38; 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,px44; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s45 46target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"47target triple = "x86_64-unknown-linux-gnu"48 49$_Z5func1v = comdat any50 51define linkonce_odr void @_Z5func1v() unnamed_addr !dbg !10 {52  ret void53}54 55; Dummy function to use _Z5func1v so that it is not treated as dead symbol.56define void @_Z3bazv() {57  tail call void @_Z5func1v()58  ret void59}60 61declare void @_Z8thinlto1v() unnamed_addr62 63; Check _Z8thinlto1v is inlined after thinLTO.64; CHECK: void @_Z3barv()65; CHECK-NOT: @_Z8thinlto1v()66; CHECK-NEXT: ret void67define void @_Z3barv() unnamed_addr !dbg !14 {68  tail call void @_Z8thinlto1v(), !dbg !2569  ret void70}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)94