brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.7 KiB · 068e1f1 Raw
275 lines · plain
1;; Test to ensure a call to a different callee but with the same debug info2;; (and therefore callsite metadata) as a subsequent call in the alloc context3;; does not cause missing or incorrect cloning. This test is otherwise the same4;; as basic.ll.5 6;; -stats requires asserts7; REQUIRES: asserts8 9; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \10; RUN:	-memprof-verify-ccg -memprof-verify-nodes \11; RUN:	-stats -pass-remarks=memprof-context-disambiguation \12; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR \13; RUN:	--check-prefix=STATS --check-prefix=REMARKS14 15target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"16target triple = "x86_64-unknown-linux-gnu"17 18define i32 @main() #0 {19entry:20  %call = call noundef ptr @_Z3foov(), !callsite !021  %call1 = call noundef ptr @_Z3foov(), !callsite !122  ret i32 023}24 25; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)26declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #127 28; Function Attrs: nobuiltin29declare void @_ZdaPv() #230 31define internal ptr @_Z3barv() #3 {32entry:33  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !memprof !2, !callsite !734  ret ptr null35}36 37declare ptr @_Znam(i64)38declare void @blah()39 40define internal ptr @_Z3bazv() #4 {41entry:42  %call = call noundef ptr @_Z3barv(), !callsite !843  ;; Subsequent call to another callee but with the same debug location / callsite id44  call void @blah(), !callsite !845  ret ptr null46}47 48; Function Attrs: noinline49define internal ptr @_Z3foov() #5 {50entry:51  %call = call noundef ptr @_Z3bazv(), !callsite !952  ret ptr null53}54 55; uselistorder directives56uselistorder ptr @_Z3foov, { 1, 0 }57 58attributes #0 = { "tune-cpu"="generic" }59attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }60attributes #2 = { nobuiltin }61attributes #3 = { "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }62attributes #4 = { "stack-protector-buffer-size"="8" }63attributes #5 = { noinline }64attributes #6 = { builtin }65 66!0 = !{i64 8632435727821051414}67!1 = !{i64 -3421689549917153178}68!2 = !{!3, !5}69!3 = !{!4, !"notcold"}70!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}71!5 = !{!6, !"cold"}72!6 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}73!7 = !{i64 9086428284934609951}74!8 = !{i64 -5964873800580613432}75!9 = !{i64 2732490490862098848}76 77 78; DUMP: CCG before cloning:79; DUMP: Callsite Context Graph:80; DUMP: Node [[BAR:0x[a-z0-9]+]]81; DUMP: 	  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6	(clone 0)82; DUMP: 	AllocTypes: NotColdCold83; DUMP: 	ContextIds: 1 284; DUMP: 	CalleeEdges:85; DUMP: 	CallerEdges:86; DUMP: 		Edge from Callee [[BAR]] to Caller: [[BAZ:0x[a-z0-9]+]] AllocTypes: NotColdCold ContextIds: 1 287 88; DUMP: Node [[BAZ]]89; DUMP: 	  %call = call noundef ptr @_Z3barv()	(clone 0)90; DUMP: 	AllocTypes: NotColdCold91; DUMP: 	ContextIds: 1 292; DUMP: 	CalleeEdges:93; DUMP: 		Edge from Callee [[BAR]] to Caller: [[BAZ]] AllocTypes: NotColdCold ContextIds: 1 294; DUMP: 	CallerEdges:95; DUMP: 		Edge from Callee [[BAZ]] to Caller: [[FOO:0x[a-z0-9]+]] AllocTypes: NotColdCold ContextIds: 1 296 97; DUMP: Node [[FOO]]98; DUMP: 	  %call = call noundef ptr @_Z3bazv()	(clone 0)99; DUMP: 	AllocTypes: NotColdCold100; DUMP: 	ContextIds: 1 2101; DUMP: 	CalleeEdges:102; DUMP: 		Edge from Callee [[BAZ]] to Caller: [[FOO]] AllocTypes: NotColdCold ContextIds: 1 2103; DUMP: 	CallerEdges:104; DUMP: 		Edge from Callee [[FOO]] to Caller: [[MAIN1:0x[a-z0-9]+]] AllocTypes: NotCold ContextIds: 1105; DUMP: 		Edge from Callee [[FOO]] to Caller: [[MAIN2:0x[a-z0-9]+]] AllocTypes: Cold ContextIds: 2106 107; DUMP: Node [[MAIN1]]108; DUMP: 	  %call = call noundef ptr @_Z3foov()	(clone 0)109; DUMP: 	AllocTypes: NotCold110; DUMP: 	ContextIds: 1111; DUMP: 	CalleeEdges:112; DUMP: 		Edge from Callee [[FOO]] to Caller: [[MAIN1]] AllocTypes: NotCold ContextIds: 1113; DUMP: 	CallerEdges:114 115; DUMP: Node [[MAIN2]]116; DUMP: 	  %call1 = call noundef ptr @_Z3foov()	(clone 0)117; DUMP: 	AllocTypes: Cold118; DUMP: 	ContextIds: 2119; DUMP: 	CalleeEdges:120; DUMP: 		Edge from Callee [[FOO]] to Caller: [[MAIN2]] AllocTypes: Cold ContextIds: 2121; DUMP: 	CallerEdges:122 123; DUMP: CCG after cloning:124; DUMP: Callsite Context Graph:125; DUMP: Node [[BAR:0x[a-z0-9]+]]126; DUMP: 	  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6	(clone 0)127; DUMP: 	AllocTypes: NotCold128; DUMP: 	ContextIds: 1129; DUMP: 	CalleeEdges:130; DUMP: 	CallerEdges:131; DUMP: 		Edge from Callee [[BAR]] to Caller: [[BAZ:0x[a-z0-9]+]] AllocTypes: NotCold ContextIds: 1132; DUMP:		Clones: [[BAR2:0x[a-z0-9]+]]133 134; DUMP: Node [[BAZ]]135; DUMP: 	  %call = call noundef ptr @_Z3barv()	(clone 0)136; DUMP: 	AllocTypes: NotCold137; DUMP: 	ContextIds: 1138; DUMP: 	CalleeEdges:139; DUMP: 		Edge from Callee [[BAR]] to Caller: [[BAZ]] AllocTypes: NotCold ContextIds: 1140; DUMP: 	CallerEdges:141; DUMP: 		Edge from Callee [[BAZ]] to Caller: [[FOO:0x[a-z0-9]+]] AllocTypes: NotCold ContextIds: 1142; DUMP:		Clones: [[BAZ2:0x[a-z0-9]+]]143 144; DUMP: Node [[FOO]]145; DUMP: 	  %call = call noundef ptr @_Z3bazv()	(clone 0)146; DUMP: 	AllocTypes: NotCold147; DUMP: 	ContextIds: 1148; DUMP: 	CalleeEdges:149; DUMP: 		Edge from Callee [[BAZ]] to Caller: [[FOO]] AllocTypes: NotCold ContextIds: 1150; DUMP: 	CallerEdges:151; DUMP: 		Edge from Callee [[FOO]] to Caller: [[MAIN1:0x[a-z0-9]+]] AllocTypes: NotCold ContextIds: 1152; DUMP:		Clones: [[FOO2:0x[a-z0-9]+]]153 154; DUMP: Node [[MAIN1]]155; DUMP: 	  %call = call noundef ptr @_Z3foov()	(clone 0)156; DUMP: 	AllocTypes: NotCold157; DUMP: 	ContextIds: 1158; DUMP: 	CalleeEdges:159; DUMP: 		Edge from Callee [[FOO]] to Caller: [[MAIN1]] AllocTypes: NotCold ContextIds: 1160; DUMP: 	CallerEdges:161 162; DUMP: Node [[MAIN2]]163; DUMP: 	  %call1 = call noundef ptr @_Z3foov()	(clone 0)164; DUMP: 	AllocTypes: Cold165; DUMP: 	ContextIds: 2166; DUMP: 	CalleeEdges:167; DUMP: 		Edge from Callee [[FOO2]] to Caller: [[MAIN2]] AllocTypes: Cold ContextIds: 2168; DUMP: 	CallerEdges:169 170; DUMP: Node [[FOO2]]171; DUMP: 	  %call = call noundef ptr @_Z3bazv()	(clone 0)172; DUMP: 	AllocTypes: Cold173; DUMP: 	ContextIds: 2174; DUMP: 	CalleeEdges:175; DUMP: 		Edge from Callee [[BAZ2]] to Caller: [[FOO2]] AllocTypes: Cold ContextIds: 2176; DUMP: 	CallerEdges:177; DUMP: 		Edge from Callee [[FOO2]] to Caller: [[MAIN2:0x[a-z0-9]+]] AllocTypes: Cold ContextIds: 2178; DUMP:		Clone of [[FOO]]179 180; DUMP: Node [[BAZ2]]181; DUMP: 	  %call = call noundef ptr @_Z3barv()	(clone 0)182; DUMP: 	AllocTypes: Cold183; DUMP: 	ContextIds: 2184; DUMP: 	CalleeEdges:185; DUMP: 		Edge from Callee [[BAR2]] to Caller: [[BAZ2]] AllocTypes: Cold ContextIds: 2186; DUMP: 	CallerEdges:187; DUMP: 		Edge from Callee [[BAZ2]] to Caller: [[FOO2]] AllocTypes: Cold ContextIds: 2188; DUMP:		Clone of [[BAZ]]189 190; DUMP: Node [[BAR2]]191; DUMP: 	  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6	(clone 0)192; DUMP: 	AllocTypes: Cold193; DUMP: 	ContextIds: 2194; DUMP: 	CalleeEdges:195; DUMP: 	CallerEdges:196; DUMP: 		Edge from Callee [[BAR2]] to Caller: [[BAZ2]] AllocTypes: Cold ContextIds: 2197; DUMP:		Clone of [[BAR]]198 199 200; REMARKS: created clone _Z3barv.memprof.1201; REMARKS: created clone _Z3bazv.memprof.1202; REMARKS: created clone _Z3foov.memprof.1203; REMARKS: call in clone main assigned to call function clone _Z3foov.memprof.1204; REMARKS: call in clone _Z3foov.memprof.1 assigned to call function clone _Z3bazv.memprof.1205; REMARKS: call in clone _Z3bazv.memprof.1 assigned to call function clone _Z3barv.memprof.1206; REMARKS: call in clone _Z3barv.memprof.1 marked with memprof allocation attribute cold207; REMARKS: call in clone main assigned to call function clone _Z3foov208; REMARKS: call in clone _Z3foov assigned to call function clone _Z3bazv209; REMARKS: call in clone _Z3bazv assigned to call function clone _Z3barv210; REMARKS: call in clone _Z3barv marked with memprof allocation attribute notcold211 212; SIZES: NotCold context 1 with total size 100 is NotCold after cloning213; SIZES: Cold context 2 with total size 400 is Cold after cloning214 215; IR: define {{.*}} @main216;; The first call to foo does not allocate cold memory. It should call the217;; original functions, which ultimately call the original allocation decorated218;; with a "notcold" attribute.219; IR:   call {{.*}} @_Z3foov()220;; The second call to foo allocates cold memory. It should call cloned functions221;; which ultimately call a cloned allocation decorated with a "cold" attribute.222; IR:   call {{.*}} @_Z3foov.memprof.1()223; IR: define internal {{.*}} @_Z3barv()224; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[NOTCOLD:[0-9]+]]225; IR: define internal {{.*}} @_Z3bazv()226; IR:   call {{.*}} @_Z3barv()227; IR: define internal {{.*}} @_Z3foov()228; IR:   call {{.*}} @_Z3bazv()229; IR: define internal {{.*}} @_Z3barv.memprof.1()230; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[COLD:[0-9]+]]231; IR: define internal {{.*}} @_Z3bazv.memprof.1()232; IR:   call {{.*}} @_Z3barv.memprof.1()233; IR: define internal {{.*}} @_Z3foov.memprof.1()234; IR:   call {{.*}} @_Z3bazv.memprof.1()235; IR: attributes #[[NOTCOLD]] = { builtin "memprof"="notcold" }236; IR: attributes #[[COLD]] = { builtin "memprof"="cold" }237 238 239; STATS: 1 memprof-context-disambiguation - Number of cold static allocations (possibly cloned)240; STATS: 1 memprof-context-disambiguation - Number of not cold static allocations (possibly cloned)241; STATS: 3 memprof-context-disambiguation - Number of function clones created during whole program analysis242 243 244; DOT: digraph "postbuild" {245; DOT: 	label="postbuild";246; DOT: 	Node[[BAR:0x[a-z0-9]+]] [shape=record,tooltip="N[[BAR]] ContextIds: 1 2",fillcolor="mediumorchid1",style="filled",style="filled",label="{OrigId: Alloc0\n_Z3barv -\> _Znam}"];247; DOT: 	Node[[BAZ:0x[a-z0-9]+]] [shape=record,tooltip="N[[BAZ]] ContextIds: 1 2",fillcolor="mediumorchid1",style="filled",style="filled",label="{OrigId: 12481870273128938184\n_Z3bazv -\> _Z3barv}"];248; DOT: 	Node[[BAZ]] -> Node[[BAR]][tooltip="ContextIds: 1 2",fillcolor="mediumorchid1"];249; DOT: 	Node[[FOO:0x[a-z0-9]+]] [shape=record,tooltip="N[[FOO]] ContextIds: 1 2",fillcolor="mediumorchid1",style="filled",style="filled",label="{OrigId: 2732490490862098848\n_Z3foov -\> _Z3bazv}"];250; DOT: 	Node[[FOO]] -> Node[[BAZ]][tooltip="ContextIds: 1 2",fillcolor="mediumorchid1"];251; DOT: 	Node[[MAIN1:0x[a-z0-9]+]] [shape=record,tooltip="N[[MAIN1]] ContextIds: 1",fillcolor="brown1",style="filled",style="filled",label="{OrigId: 8632435727821051414\nmain -\> _Z3foov}"];252; DOT: 	Node[[MAIN1]] -> Node[[FOO]][tooltip="ContextIds: 1",fillcolor="brown1"];253; DOT: 	Node[[MAIN2:0x[a-z0-9]+]] [shape=record,tooltip="N[[MAIN2]] ContextIds: 2",fillcolor="cyan",style="filled",style="filled",label="{OrigId: 15025054523792398438\nmain -\> _Z3foov}"];254; DOT: 	Node[[MAIN2]] -> Node[[FOO]][tooltip="ContextIds: 2",fillcolor="cyan"];255; DOT: }256 257 258; DOTCLONED: digraph "cloned" {259; DOTCLONED: 	label="cloned";260; DOTCLONED: 	Node[[BAR:0x[a-z0-9]+]] [shape=record,tooltip="N[[BAR]] ContextIds: 1",fillcolor="brown1",style="filled",style="filled",label="{OrigId: Alloc0\n_Z3barv -\> _Znam}"];261; DOTCLONED: 	Node[[BAZ:0x[a-z0-9]+]] [shape=record,tooltip="N[[BAZ]] ContextIds: 1",fillcolor="brown1",style="filled",style="filled",label="{OrigId: 12481870273128938184\n_Z3bazv -\> _Z3barv}"];262; DOTCLONED: 	Node[[BAZ]] -> Node[[BAR]][tooltip="ContextIds: 1",fillcolor="brown1"];263; DOTCLONED: 	Node[[FOO:0x[a-z0-9]+]] [shape=record,tooltip="N[[FOO]] ContextIds: 1",fillcolor="brown1",style="filled",style="filled",label="{OrigId: 2732490490862098848\n_Z3foov -\> _Z3bazv}"];264; DOTCLONED: 	Node[[FOO]] -> Node[[BAZ]][tooltip="ContextIds: 1",fillcolor="brown1"];265; DOTCLONED: 	Node[[MAIN1:0x[a-z0-9]+]] [shape=record,tooltip="N[[MAIN1]] ContextIds: 1",fillcolor="brown1",style="filled",style="filled",label="{OrigId: 8632435727821051414\nmain -\> _Z3foov}"];266; DOTCLONED: 	Node[[MAIN1]] -> Node[[FOO]][tooltip="ContextIds: 1",fillcolor="brown1"];267; DOTCLONED: 	Node[[MAIN2:0x[a-z0-9]+]] [shape=record,tooltip="N[[MAIN2]] ContextIds: 2",fillcolor="cyan",style="filled",style="filled",label="{OrigId: 15025054523792398438\nmain -\> _Z3foov}"];268; DOTCLONED: 	Node[[MAIN2]] -> Node[[FOO2:0x[a-z0-9]+]][tooltip="ContextIds: 2",fillcolor="cyan"];269; DOTCLONED: 	Node[[FOO2]] [shape=record,tooltip="N[[FOO2]] ContextIds: 2",fillcolor="cyan",style="filled",color="blue",style="filled,bold,dashed",label="{OrigId: 0\n_Z3foov -\> _Z3bazv}"];270; DOTCLONED: 	Node[[FOO2]] -> Node[[BAZ2:0x[a-z0-9]+]][tooltip="ContextIds: 2",fillcolor="cyan"];271; DOTCLONED: 	Node[[BAZ2]] [shape=record,tooltip="N[[BAZ2]] ContextIds: 2",fillcolor="cyan",style="filled",color="blue",style="filled,bold,dashed",label="{OrigId: 0\n_Z3bazv -\> _Z3barv}"];272; DOTCLONED: 	Node[[BAZ2]] -> Node[[BAR2:0x[a-z0-9]+]][tooltip="ContextIds: 2",fillcolor="cyan"];273; DOTCLONED: 	Node[[BAR2]] [shape=record,tooltip="N[[BAR2]] ContextIds: 2",fillcolor="cyan",style="filled",color="blue",style="filled,bold,dashed",label="{OrigId: Alloc0\n_Z3barv -\> _Znam}"];274; DOTCLONED: }275