brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · 2cc655e Raw
139 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;; Update: the inlined sequence of callsite ids was manually modified to44;; include some recursion, which reproduced an error before it was fixed.45;;46;; The IR was then reduced using llvm-reduce with the expected FileCheck input.47 48; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \49; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \50; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=DUMP51 52 53target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"54target triple = "x86_64-unknown-linux-gnu"55 56define ptr @_Z3barv() #0 {57entry:58  %call = call noalias noundef nonnull dereferenceable(10) ptr @_Znam(i64 noundef 10) #7, !memprof !7, !callsite !12, !heapallocsite !1359  ret ptr null60}61 62; Function Attrs: nobuiltin63declare ptr @_Znam(i64) #164 65; Function Attrs: mustprogress66declare ptr @_Z3bazv() #267 68define i32 @main() #3 {69delete.end5:70  %call.i.i = call noundef ptr @_Z3barv(), !callsite !1471  %call.i.i8 = call noundef ptr @_Z3barv(), !callsite !1572  ret i32 073}74 75; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)76declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #477 78declare void @_ZdaPv() #579 80declare i32 @sleep() #681 82attributes #0 = { "stack-protector-buffer-size"="8" }83attributes #1 = { nobuiltin }84attributes #2 = { mustprogress }85attributes #3 = { "tune-cpu"="generic" }86attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }87attributes #5 = { "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }88attributes #6 = { "disable-tail-calls"="true" }89attributes #7 = { builtin }90 91!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}92 93!0 = !{i32 7, !"Dwarf Version", i32 5}94!1 = !{i32 2, !"Debug Info Version", i32 3}95!2 = !{i32 1, !"wchar_size", i32 4}96!3 = !{i32 8, !"PIC Level", i32 2}97!4 = !{i32 7, !"PIE Level", i32 2}98!5 = !{i32 7, !"uwtable", i32 2}99!6 = !{i32 7, !"frame-pointer", i32 2}100!7 = !{!8, !10}101!8 = !{!9, !"notcold"}102!9 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 8632435727821051414}103!10 = !{!11, !"cold"}104!11 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 -3421689549917153178}105!12 = !{i64 9086428284934609951}106!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)107!14 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 8632435727821051414}108!15 = !{i64 -5964873800580613432, i64 2732490490862098848, i64 -5964873800580613432, i64 -3421689549917153178}109 110 111; DUMP: CCG before cloning:112; DUMP: Callsite Context Graph:113; DUMP: Node [[BAR:0x[a-z0-9]+]]114; DUMP: 	  %call = call noalias noundef nonnull dereferenceable(10) ptr @_Znam(i64 noundef 10) #7, !heapallocsite !7	(clone 0)115; DUMP: 	AllocTypes: NotColdCold116; DUMP: 	ContextIds: 1 2117; DUMP: 	CalleeEdges:118; DUMP: 	CallerEdges:119; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN1:0x[a-z0-9]+]] AllocTypes: NotCold ContextIds: 1120; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN2:0x[a-z0-9]+]] AllocTypes: Cold ContextIds: 2121 122;; This is the node synthesized for the first inlined call chain of main->foo->baz123; DUMP: Node [[MAIN1]]124; DUMP: 	  %call.i.i = call noundef ptr @_Z3barv()	(clone 0)125; DUMP: 	AllocTypes: NotCold126; DUMP: 	ContextIds: 1127; DUMP: 	CalleeEdges:128; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN1]] AllocTypes: NotCold ContextIds: 1129; DUMP: 	CallerEdges:130 131;; This is the node synthesized for the second inlined call chain of main->foo->baz132; DUMP: Node [[MAIN2]]133; DUMP: 	  %call.i.i8 = call noundef ptr @_Z3barv()	(clone 0)134; DUMP: 	AllocTypes: Cold135; DUMP: 	ContextIds: 2136; DUMP: 	CalleeEdges:137; DUMP: 		Edge from Callee [[BAR]] to Caller: [[MAIN2]] AllocTypes: Cold ContextIds: 2138; DUMP: 	CallerEdges:139