brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.4 KiB · 3e026fa Raw
266 lines · plain
1;; Test callsite context graph exporting to dot with various options.2;;3;; The code is similar to that of basic.ll, but with a second allocation.4 5;; Check expected error if alloc scope requested without an alloc id.6; RUN: not --crash opt -passes=memprof-context-disambiguation -supports-hot-cold-new \7; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \8; RUN:	-memprof-dot-scope=alloc \9; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=ERRMISSINGALLOCID10; ERRMISSINGALLOCID: -memprof-dot-scope=alloc requires -memprof-dot-alloc-id11 12;; Check expected error if context scope requested without a context id.13; RUN: not --crash opt -passes=memprof-context-disambiguation -supports-hot-cold-new \14; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \15; RUN:	-memprof-dot-scope=context \16; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=ERRMISSINGCONTEXTID17; ERRMISSINGCONTEXTID: -memprof-dot-scope=context requires -memprof-dot-context-id18 19;; Check expected error if both alloc and context ids are specified when we are20;; exporting the full graph to dot. It is unclear which scope to highlight.21; RUN: not --crash opt -passes=memprof-context-disambiguation -supports-hot-cold-new \22; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \23; RUN:	-memprof-dot-alloc-id=0 -memprof-dot-context-id=2 \24; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=ERRBOTH25; ERRBOTH: -memprof-dot-scope=all can't have both -memprof-dot-alloc-id and -memprof-dot-context-id26 27;; Export full graph (default), without any highlight.28; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \29; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \30; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR31; RUN:	cat %t.ccg.postbuild.dot | FileCheck %s -check-prefix=DOTCOMMON --check-prefix=DOTALLANDALLOC0 --check-prefix=DOTALL --check-prefix=DOTALLNONE32 33;; Export full graph (default), with highlight of alloc 0.34; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \35; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \36; RUN:	-memprof-dot-alloc-id=0 \37; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR38; RUN:	cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTCOMMON --check-prefix=DOTALLANDALLOC0 --check-prefix=DOTALL --check-prefix=DOTALLALLOC039 40;; Export full graph (default), with highlight of context 1.41; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \42; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \43; RUN:	-memprof-dot-context-id=1 \44; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR45; RUN:	cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTCOMMON --check-prefix=DOTALLANDALLOC0 --check-prefix=DOTALL --check-prefix=DOTALLCONTEXT146 47;; Export alloc 0 only, without any highlight.48; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \49; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \50; RUN:	-memprof-dot-scope=alloc -memprof-dot-alloc-id=0 \51; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR52; RUN:	cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTCOMMON --check-prefix=DOTALLANDALLOC0 --check-prefix=DOTALLOC0NONE53 54;; Export alloc 0 only, with highlight of context 1.55; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \56; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \57; RUN:	-memprof-dot-scope=alloc -memprof-dot-alloc-id=0 \58; RUN:	-memprof-dot-context-id=1 \59; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR60; RUN:	cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTCOMMON --check-prefix=DOTALLANDALLOC0 --check-prefix=DOTALLOC0CONTEXT161 62;; Export context 1 only (which means no highlighting).63; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \64; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \65; RUN:	-memprof-dot-scope=context -memprof-dot-context-id=1 \66; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR67; RUN:	cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTCOMMON --check-prefix=DOTCONTEXT168 69target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"70target triple = "x86_64-unknown-linux-gnu"71 72define i32 @main() #0 {73entry:74  %call = call noundef ptr @_Z3foov(), !callsite !075  %call1 = call noundef ptr @_Z3foov(), !callsite !176  ret i32 077}78 79; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)80declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #181 82; Function Attrs: nobuiltin83declare void @_ZdaPv() #284 85define internal ptr @_Z3barv() #3 {86entry:87  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !memprof !2, !callsite !788  %call2 = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !memprof !13, !callsite !1889  ret ptr null90}91 92declare ptr @_Znam(i64)93 94define internal ptr @_Z3bazv() #4 {95entry:96  %call = call noundef ptr @_Z3barv(), !callsite !897  ret ptr null98}99 100; Function Attrs: noinline101define internal ptr @_Z3foov() #5 {102entry:103  %call = call noundef ptr @_Z3bazv(), !callsite !9104  ret ptr null105}106 107; uselistorder directives108uselistorder ptr @_Z3foov, { 1, 0 }109 110attributes #0 = { "tune-cpu"="generic" }111attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }112attributes #2 = { nobuiltin }113attributes #3 = { "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }114attributes #4 = { "stack-protector-buffer-size"="8" }115attributes #5 = { noinline }116attributes #6 = { builtin }117 118!0 = !{i64 8632435727821051414}119!1 = !{i64 -3421689549917153178}120!2 = !{!3, !5}121!3 = !{!4, !"notcold", !10}122!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}123!5 = !{!6, !"cold", !11, !12}124!6 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}125!7 = !{i64 9086428284934609951}126!8 = !{i64 -5964873800580613432}127!9 = !{i64 2732490490862098848}128!10 = !{i64 123, i64 100}129!11 = !{i64 456, i64 200}130!12 = !{i64 789, i64 300}131!13 = !{!14, !16}132!14 = !{!15, !"notcold", !10}133!15 = !{i64 123, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}134!16 = !{!17, !"cold", !11, !12}135!17 = !{i64 123, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}136!18 = !{i64 123}137 138; IR: define {{.*}} @main139;; The first call to foo does not allocate cold memory. It should call the140;; original functions, which ultimately call the original allocations decorated141;; with a "notcold" attribute.142; IR:   call {{.*}} @_Z3foov()143;; The second call to foo allocates cold memory. It should call cloned functions144;; which ultimately call acloned allocations decorated with a "cold" attribute.145; IR:   call {{.*}} @_Z3foov.memprof.1()146; IR: define internal {{.*}} @_Z3barv()147; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[NOTCOLD:[0-9]+]]148; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[NOTCOLD]]149; IR: define internal {{.*}} @_Z3bazv()150; IR:   call {{.*}} @_Z3barv()151; IR: define internal {{.*}} @_Z3foov()152; IR:   call {{.*}} @_Z3bazv()153; IR: define internal {{.*}} @_Z3barv.memprof.1()154; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[COLD:[0-9]+]]155; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[COLD]]156; IR: define internal {{.*}} @_Z3bazv.memprof.1()157; IR:   call {{.*}} @_Z3barv.memprof.1()158; IR: define internal {{.*}} @_Z3foov.memprof.1()159; IR:   call {{.*}} @_Z3bazv.memprof.1()160; IR: attributes #[[NOTCOLD]] = { builtin "memprof"="notcold" }161; IR: attributes #[[COLD]] = { builtin "memprof"="cold" }162 163 164;; Check highlighting. Alloc 0 includes context ids 1 and 2.165 166; DOTCOMMON:  Node[[BAR:0x[a-z0-9]+]] [shape=record,tooltip="N[[BAR]] ContextIds: 1 2",167;; This node is highlighted when dumping the whole graph and specifying168;; alloc 0 or context 1, or if dumping alloc 0 and specifying context 1.169; DOTALLNONE-SAME: fillcolor="mediumorchid1",170; DOTALLALLOC0-SAME: fontsize="30",fillcolor="magenta",171; DOTALLCONTEXT1-SAME: fontsize="30",fillcolor="magenta",172; DOTALLOC0NONE-SAME: fillcolor="mediumorchid1",173; DOTALLOC0CONTEXT1-SAME: fontsize="30",fillcolor="magenta",174; DOTCONTEXT1-SAME: fillcolor="mediumorchid1",175; DOTCOMMON-SAME: style="filled",label="{OrigId: Alloc0{{.*}}\n_Z3barv -\> _Znam}"];176 177; DOTCOMMON:  Node[[BAZ:0x[a-z0-9]+]] [shape=record,tooltip="N[[BAZ]] ContextIds: 1 2 3 4",178;; This node is highlighted when dumping the whole graph and specifying179;; alloc 0 or context 1, or if dumping alloc 0 and specifying context 1.180; DOTALLNONE-SAME: fillcolor="mediumorchid1",181; DOTALLALLOC0-SAME: fontsize="30",fillcolor="magenta",182; DOTALLCONTEXT1-SAME: fontsize="30",fillcolor="magenta",183; DOTALLOC0NONE-SAME: fillcolor="mediumorchid1",184; DOTALLOC0CONTEXT1-SAME: fontsize="30",fillcolor="magenta",185; DOTCONTEXT1-SAME: fillcolor="mediumorchid1",186; DOTCOMMON-SAME: style="filled",label="{OrigId: 12481870273128938184{{.*}}\n_Z3bazv -\> _Z3barv}"];187 188; DOTCOMMON:  Node[[BAZ]] -> Node[[BAR]][tooltip="ContextIds: 1 2",189;; This edge is highlighted when dumping the whole graph and specifying190;; alloc 0 or context 1, or if dumping alloc 0 and specifying context 1.191; DOTALLNONE-SAME: fillcolor="mediumorchid1",color="mediumorchid1"];192; DOTALLALLOC0-SAME: fillcolor="magenta",color="magenta",penwidth="2.0",weight="2"];193; DOTALLCONTEXT1-SAME: fillcolor="magenta",color="magenta",penwidth="2.0",weight="2"];194; DOTALLOC0NONE-SAME: fillcolor="mediumorchid1",color="mediumorchid1"];195; DOTALLOC0CONTEXT1-SAME: fillcolor="magenta",color="magenta",penwidth="2.0",weight="2"];196; DOTCONTEXT1-SAME: fillcolor="mediumorchid1",color="mediumorchid1"];197 198;; This edge is not in alloc 0 or context 0, so only included when exporting199;; the whole graph (and never highlighted).200; DOTALL:  Node[[BAZ]] -> Node[[BAR2:0x[a-z0-9]+]][tooltip="ContextIds: 3 4",fillcolor="mediumorchid1",color="mediumorchid1"];201 202; DOTCOMMON:  Node[[FOO:0x[a-z0-9]+]] [shape=record,tooltip="N[[FOO]] ContextIds: 1 2 3 4",203;; This node is highlighted when dumping the whole graph and specifying204;; alloc 0 or context 1, or if dumping alloc 0 and specifying context 1.205; DOTALLNONE-SAME: fillcolor="mediumorchid1",206; DOTALLALLOC0-SAME: fontsize="30",fillcolor="magenta",207; DOTALLCONTEXT1-SAME: fontsize="30",fillcolor="magenta",208; DOTALLOC0NONE-SAME: fillcolor="mediumorchid1",209; DOTALLOC0CONTEXT1-SAME: fontsize="30",fillcolor="magenta",210; DOTCONTEXT1-SAME: fillcolor="mediumorchid1",211; DOTCOMMON-SAME: style="filled",label="{OrigId: 2732490490862098848{{.*}}\n_Z3foov -\> _Z3bazv}"];212 213; DOTCOMMON:  Node[[FOO]] -> Node[[BAZ]][tooltip="ContextIds: 1 2 3 4",214;; This edge is highlighted when dumping the whole graph and specifying215;; alloc 0 or context 1, or if dumping alloc 0 and specifying context 1.216; DOTALLNONE-SAME: fillcolor="mediumorchid1",color="mediumorchid1"];217; DOTALLALLOC0-SAME: fillcolor="magenta",color="magenta",penwidth="2.0",weight="2"];218; DOTALLCONTEXT1-SAME: fillcolor="magenta",color="magenta",penwidth="2.0",weight="2"];219; DOTALLOC0NONE-SAME: fillcolor="mediumorchid1",color="mediumorchid1"];220; DOTALLOC0CONTEXT1-SAME: fillcolor="magenta",color="magenta",penwidth="2.0",weight="2"];221; DOTCONTEXT1-SAME: fillcolor="mediumorchid1",color="mediumorchid1"];222 223; DOTCOMMON:  Node[[MAIN1:0x[a-z0-9]+]] [shape=record,tooltip="N[[MAIN1]] ContextIds: 1 3",224;; This node is highlighted when dumping the whole graph and specifying225;; alloc 0 or context 1, or if dumping alloc 0 and specifying context 1.226;; Note that the highlight color is the same as when there is no highlighting.227; DOTALLALLOC0-SAME: fontsize="30",228; DOTALLCONTEXT1-SAME: fontsize="30",229; DOTALLOC0CONTEXT1-SAME: fontsize="30",230; DOTCOMMON-SAME: fillcolor="brown1",style="filled",label="{OrigId: 8632435727821051414{{.*}}\nmain -\> _Z3foov}"];231 232; DOTCOMMON:  Node[[MAIN1]] -> Node[[FOO]][tooltip="ContextIds: 1 3",fillcolor="brown1",color="brown1"233;; This edge is highlighted when dumping the whole graph and specifying234;; alloc 0 or context 1, or if dumping alloc 0 and specifying context 1.235; DOTALLNONE-SAME: ];236; DOTALLALLOC0-SAME: penwidth="2.0",weight="2"];237; DOTALLCONTEXT1-SAME: penwidth="2.0",weight="2"];238; DOTALLOC0NONE-SAME: ];239; DOTALLOC0CONTEXT1-SAME: penwidth="2.0",weight="2"];240; DOTCONTEXT1-SAME: ];241 242; DOTALLANDALLOC0:  Node[[MAIN2:0x[a-z0-9]+]] [shape=record,tooltip="N[[MAIN2]] ContextIds: 2 4",243;; This node is highlighted when dumping the whole graph and specifying244;; alloc 0. Note that the unhighlighted color is different when there is any245;; highlighting (lightskyblue) vs no highlighting (cyan).246; DOTALLNONE-SAME: fillcolor="cyan",247; DOTALLALLOC0-SAME: fontsize="30",fillcolor="cyan",248; DOTALLCONTEXT1-SAME: fillcolor="lightskyblue",249; DOTALLOC0NONE-SAME: fillcolor="cyan",250; DOTALLOC0CONTEXT1-SAME: fillcolor="lightskyblue",251; DOTALLANDALLOC0-SAME: style="filled",label="{OrigId: 15025054523792398438{{.*}}\nmain -\> _Z3foov}"];252 253; DOTALLANDALLOC0:  Node[[MAIN2]] -> Node[[FOO]][tooltip="ContextIds: 2 4",254;; This edge is highlighted when dumping the whole graph and specifying255;; alloc 0. Note that the unhighlighted color is different when there is any256;; highlighting (lightskyblue) vs no highlighting (cyan).257; DOTALLNONE-SAME: fillcolor="cyan",color="cyan"];258; DOTALLALLOC0-SAME: fillcolor="cyan",color="cyan",penwidth="2.0",weight="2"];259; DOTALLCONTEXT1-SAME: fillcolor="lightskyblue",color="lightskyblue"];260; DOTALLOC0NONE-SAME: fillcolor="cyan",color="cyan"];261; DOTALLOC0CONTEXT1-SAME: fillcolor="lightskyblue",color="lightskyblue"];262 263;; This edge is not in alloc 0 or context 0, so only included when exporting264;; the whole graph (and never highlighted).265; DOTALL:  Node[[BAR2]] [shape=record,tooltip="N[[BAR2]] ContextIds: 3 4",fillcolor="mediumorchid1",style="filled",label="{OrigId: Alloc2{{.*}}\n_Z3barv -\> _Znam}"];266