87 lines · plain
1; Test workload based importing via -thinlto-pgo-ctx-prof2; Use external linkage symbols so we don't depend on module paths which are3; used when computing the GUIDs of internal linkage symbols.4; The functionality is shared with what workload.ll tests, so here we only care5; about testing the ctx profile is loaded and handled correctly.6;7; Set up8; RUN: rm -rf %t9; RUN: mkdir -p %t10; RUN: split-file %s %t11;12; RUN: opt -module-summary -passes=assign-guid %t/m1.ll -o %t/m1.bc13; RUN: opt -module-summary -passes=assign-guid %t/m2.ll -o %t/m2.bc14; RUN: llvm-dis %t/m1.bc -o - | FileCheck %s --check-prefix=GUIDS-115; RUN: llvm-dis %t/m2.bc -o - | FileCheck %s --check-prefix=GUIDS-216;17; GUIDS-1-LABEL: @m1_f118; GUIDS-1-SAME: !guid ![[GUID1:[0-9]+]]19; GUIDS-1: ![[GUID1]] = !{i64 6019442868614718803}20; GUIDS-1: ^0 = module:21; GUIDS-1: name: "m1_f1"22; GUIDS-1-SAME: guid = 601944286861471880323 24; note: -2853647799038631862 is 1559309627467091975425; GUIDS-2-LABEL: @m2_f126; GUIDS-2-SAME: !guid ![[GUID2:[0-9]+]]27; GUIDS-2: ![[GUID2]] = !{i64 -2853647799038631862}28; GUIDS-2: ^0 = module:29; GUIDS-2: name: "m2_f1"30; GUIDS-2-SAME: guid = 1559309627467091975431;32; RUN: rm -rf %t_baseline33; RUN: rm -rf %t_exp34; RUN: mkdir -p %t_baseline35; RUN: mkdir -p %t_exp36;37; Normal run. m1 shouldn't get m2_f1 because it's not referenced from there, and38; m1_f1 shouldn't go to m2.39;40; RUN: llvm-lto2 run %t/m1.bc %t/m2.bc \41; RUN: -o %t_baseline/result.o -save-temps \42; RUN: -r %t/m1.bc,m1_f1,plx \43; RUN: -r %t/m2.bc,m2_f1,plx44; RUN: llvm-dis %t_baseline/result.o.1.3.import.bc -o - | FileCheck %s --check-prefix=NOPROF-145; RUN: llvm-dis %t_baseline/result.o.2.3.import.bc -o - | FileCheck %s --check-prefix=NOPROF-246;47; NOPROF-1-NOT: m2_f1()48; NOPROF-2-NOT: m1_f1()49;50; The run with workload definitions - same other options. We do need to re-generate the .bc51; files, to include instrumentation.52; RUN: opt -module-summary -passes=assign-guid,ctx-instr-gen %t/m1.ll -o %t/m1-instr.bc53; RUN: opt -module-summary -passes=assign-guid,ctx-instr-gen %t/m2.ll -o %t/m2-instr.bc54;55; RUN: echo '{"Contexts": [ \56; RUN: {"Guid": 6019442868614718803, "TotalRootEntryCount": 5, "Counters": [1], "Callsites": [[{"Guid": 15593096274670919754, "Counters": [1]}]]}, \57; RUN: {"Guid": 15593096274670919754, "TotalRootEntryCount": 2, "Counters": [1], "Callsites": [[{"Guid": 6019442868614718803, "Counters": [1]}]]} \58; RUN: ]}' > %t_exp/ctxprof.yaml59; RUN: llvm-ctxprof-util fromYAML --input %t_exp/ctxprof.yaml --output %t_exp/ctxprof.bitstream60; RUN: llvm-lto2 run %t/m1-instr.bc %t/m2-instr.bc \61; RUN: -o %t_exp/result.o -save-temps \62; RUN: -use-ctx-profile=%t_exp/ctxprof.bitstream \63; RUN: -r %t/m1-instr.bc,m1_f1,plx \64; RUN: -r %t/m2-instr.bc,m2_f1,plx65; RUN: llvm-dis %t_exp/result.o.1.3.import.bc -o - | FileCheck %s --check-prefix=FIRST66; RUN: llvm-dis %t_exp/result.o.2.3.import.bc -o - | FileCheck %s --check-prefix=SECOND67;68;69; FIRST: m2_f1()70; SECOND: m1_f1()71;72;--- m1.ll73target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"74target triple = "x86_64-pc-linux-gnu"75 76define dso_local void @m1_f1() {77 ret void78}79 80;--- m2.ll81target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"82target triple = "x86_64-pc-linux-gnu"83 84define dso_local void @m2_f1() {85 ret void86}87