brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 9f67849 Raw
126 lines · plain
1;; Test callsite context graph generation for call graph with two memprof2;; contexts and multiple levels of inlining, requiring generation of new3;; fused nodes to represent the inlined sequence while matching callsite4;; nodes onto the graph. In particular this tests the case where a function5;; has inlined a callee containing an inlined callee.6;;7;; Original code looks like:8;;9;; char *bar() __attribute__((noinline)) {10;;   return new char[10];11;; }12;;13;; char *baz() {14;;   return bar();15;; }16;;17;; char *foo() {18;;   return baz();19;; }20;;21;; int main(int argc, char **argv) {22;;   char *x = foo();23;;   char *y = foo();24;;   memset(x, 0, 10);25;;   memset(y, 0, 10);26;;   delete[] x;27;;   sleep(10);28;;   delete[] y;29;;   return 0;30;; }31;;32;; Code compiled with -mllvm -memprof-ave-lifetime-cold-threshold=5 so that the33;; memory freed after sleep(10) results in cold lifetimes.34;;35;; Both foo and baz are inlined into main, at both foo callsites.36;; We should update the graph for new fused nodes for both of those inlined37;; callsites to bar.38;;39;; Note that baz and bar are both dead due to the inlining, but have been left40;; in the input IR to ensure that the MIB call chain is matched to the longer41;; inline sequences from main.42;;43;; The IR was then reduced using llvm-reduce with the expected FileCheck input.44 45; RUN: opt -thinlto-bc %s >%t.o46; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \47; RUN:  -supports-hot-cold-new \48; RUN:  -r=%t.o,main,plx \49; RUN:  -r=%t.o,_Z3barv,plx \50; RUN:  -r=%t.o,_Z3bazv,plx \51; RUN:  -r=%t.o,_Z3foov,plx \52; RUN:  -r=%t.o,_ZdaPv, \53; RUN:  -r=%t.o,sleep, \54; RUN:  -r=%t.o,_Znam, \55; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \56; RUN:  -o %t.out 2>&1 | FileCheck %s --check-prefix=DUMP57 58 59target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"60target triple = "x86_64-unknown-linux-gnu"61 62define ptr @_Z3barv() {63entry:64  %call = call ptr @_Znam(i64 0), !memprof !0, !callsite !565  ret ptr null66}67 68declare ptr @_Znam(i64)69 70declare ptr @_Z3bazv()71 72declare ptr @_Z3foov()73 74define i32 @main() {75delete.end5:76  %call.i.i = call ptr @_Z3barv(), !callsite !677  %call.i.i8 = call ptr @_Z3barv(), !callsite !778  ret i32 079}80 81declare void @_ZdaPv()82 83declare i32 @sleep()84 85!0 = !{!1, !3}86!1 = !{!2, !"notcold"}87!2 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}88!3 = !{!4, !"cold"}89!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}90!5 = !{i64 9086428284934609951}91!6 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}92!7 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}93 94 95; DUMP: CCG before cloning:96; DUMP: Callsite Context Graph:97; DUMP: Node [[BAR:0x[a-z0-9]+]]98; DUMP: 	Versions: 1 MIB:99; DUMP: 		AllocType 1 StackIds: 0, 1, 2100; DUMP: 		AllocType 2 StackIds: 0, 1, 3101; DUMP: 	(clone 0)102; DUMP: 	AllocTypes: NotColdCold103; DUMP: 	ContextIds: 1 2104; DUMP: 	CalleeEdges:105; DUMP: 	CallerEdges:106; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN1:0x[a-z0-9]+]] AllocTypes: NotCold ContextIds: 1107; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN2:0x[a-z0-9]+]] AllocTypes: Cold ContextIds: 2108 109;; This is the node synthesized for the first inlined call chain of main->foo->baz110; DUMP: Node [[MAIN1]]111; DUMP: 	Callee: 17377440600225628772 (_Z3barv) Clones: 0 StackIds: 0, 1, 2	(clone 0)112; DUMP: 	AllocTypes: NotCold113; DUMP: 	ContextIds: 1114; DUMP: 	CalleeEdges:115; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN1]] AllocTypes: NotCold ContextIds: 1116; DUMP: 	CallerEdges:117 118;; This is the node synthesized for the second inlined call chain of main->foo->baz119; DUMP: Node [[MAIN2]]120; DUMP: 	Callee: 17377440600225628772 (_Z3barv) Clones: 0 StackIds: 0, 1, 3	(clone 0)121; DUMP: 	AllocTypes: Cold122; DUMP: 	ContextIds: 2123; DUMP: 	CalleeEdges:124; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN2]] AllocTypes: Cold ContextIds: 2125; DUMP: 	CallerEdges:126