1; REQUIRES: x86_64-linux 2; 3; RUN: rm -rf %t 4; RUN: split-file %s %t 5; 6; Test that the GUID metadata survives through thinlink. 7; Also test that the flattener works correctly. f2 is called in 2 places, with 8; different counter values, and we expect resulting flat profile to be the sum 9; (of values at the same index). 10; 11; RUN: llvm-ctxprof-util fromYAML --input=%t/profile.yaml --output=%t/profile.ctxprofdata 12; 13; RUN: opt -module-summary -passes='thinlto-pre-link<O2>' -use-ctx-profile=%t/profile.ctxprofdata -o %t/m1.bc %t/m1.ll 14; RUN: opt -module-summary -passes='thinlto-pre-link<O2>' -use-ctx-profile=%t/profile.ctxprofdata -o %t/m2.bc %t/m2.ll 15; 16; RUN: rm -rf %t/postlink 17; RUN: mkdir %t/postlink 18; 19; 20; RUN: llvm-lto2 run %t/m1.bc %t/m2.bc -o %t/ -thinlto-distributed-indexes \ 21; RUN: -use-ctx-profile=%t/profile.ctxprofdata \ 22; RUN: -r %t/m1.bc,f1,plx \ 23; RUN: -r %t/m1.bc,f3,plx \ 24; RUN: -r %t/m2.bc,f1 \ 25; RUN: -r %t/m2.bc,f3 \ 26; RUN: -r %t/m2.bc,entrypoint,plx 27; RUN: opt --passes='function-import,require<ctx-prof-analysis>,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything \ 28; RUN: -summary-file=%t/m2.bc.thinlto.bc -use-ctx-profile=%t/profile.ctxprofdata %t/m2.bc \ 29; RUN: -S -o %t/m2.post.ll 2> %t/profile.txt 30; RUN: diff %t/expected.txt %t/profile.txt 31;--- m1.ll 32target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 33target triple = "x86_64-pc-linux-gnu" 34 35source_filename = "random_path/m1.cc" 36 37define private void @f2() #0 !guid !0 { 38 ret void 39} 40 41define void @f1() #0 { 42 call void @f2() 43 ret void 44} 45 46define void @f3() #0 { 47 call void @f2() 48 ret void 49} 50 51attributes #0 = { noinline } 52!0 = !{ i64 3087265239403591524 } 53 54;--- m2.ll 55target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 56target triple = "x86_64-pc-linux-gnu" 57 58source_filename = "random_path/m2.cc" 59 60declare void @f1() 61declare void @f3() 62 63define void @entrypoint() { 64 call void @f1() 65 call void @f3() 66 ret void 67} 68;--- profile.yaml 69- Guid: 10507721908651011566 70 Counters: [1] 71 Callsites: - 72 - Guid: 2072045998141807037 73 Counters: [7] 74 Callsites: - 75 - Guid: 3087265239403591524 76 Counters: [10, 7] 77 - 78 - Guid: 4197650231481825559 79 Counters: [2] 80 Callsites: - 81 - Guid: 3087265239403591524 82 Counters: [1, 2] 83;--- expected.txt 84Function Info: 852072045998141807037 : f1. MaxCounterID: 1. MaxCallsiteID: 1 863087265239403591524 : f2.llvm.0. MaxCounterID: 1. MaxCallsiteID: 0 874197650231481825559 : f3. MaxCounterID: 1. MaxCallsiteID: 1 8810507721908651011566 : entrypoint. MaxCounterID: 1. MaxCallsiteID: 2 89 90Current Profile: 91 92- Guid: 10507721908651011566 93 Counters: [ 1 ] 94 Callsites: 95 - - Guid: 2072045998141807037 96 Counters: [ 7 ] 97 Callsites: 98 - - Guid: 3087265239403591524 99 Counters: [ 10, 7 ] 100 - - Guid: 4197650231481825559 101 Counters: [ 2 ] 102 Callsites: 103 - - Guid: 3087265239403591524 104 Counters: [ 1, 2 ] 105 106Flat Profile: 1072072045998141807037 : 7 1083087265239403591524 : 11 9 1094197650231481825559 : 2 11010507721908651011566 : 1 111