brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · d293b2a Raw
134 lines · plain
1;; Test to make sure that missing tail call frames in memprof profiles are2;; identified but not cloned when there are multiple non-unique possible3;; tail call chains between the profiled frames.4 5;; -stats requires asserts6; REQUIRES: asserts7 8; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \9; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \10; RUN:  -stats -debug %s -S 2>&1 | FileCheck %s --check-prefix=STATS \11; RUN:  --check-prefix=IR --check-prefix=DEBUG12 13; DEBUG: Not found through unique tail call chain: _Z3barv from main that actually called xyz (found multiple possible chains)14 15;; Graph fixup should have nulled the call in the node that could not be16;; resolved via tail call fixup. That happens in between the initial17;; stack update and the end of graph building.18; RUN:  cat %t.ccg.poststackupdate.dot | FileCheck %s --check-prefix=DOTPOSTSTACKUPDATE19; DOTPOSTSTACKUPDATE: {OrigId: 15025054523792398438{{.*}}\nmain -\> xyz}20; RUN:  cat %t.ccg.postbuild.dot | FileCheck %s --check-prefix=DOTPOSTBUILD21; DOTPOSTBUILD: {OrigId: 15025054523792398438{{.*}}\nnull call (external)}22 23;; Check that all calls in the IR are to the original functions, leading to a24;; non-cold operator new call.25 26source_filename = "tailcall-nonunique.cc"27target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"28target triple = "x86_64-unknown-linux-gnu"29 30; Function Attrs: noinline31; IR-LABEL: @_Z3barv()32define dso_local ptr @_Z3barv() local_unnamed_addr #0 {33entry:34  ; IR: call ptr @_Znam(i64 10) #[[NOTCOLD:[0-9]+]]35  %call = tail call ptr @_Znam(i64 10) #2, !memprof !0, !callsite !936  ret ptr %call37}38 39; Function Attrs: nobuiltin allocsize(0)40declare ptr @_Znam(i64) #141 42; Function Attrs: noinline43; IR-LABEL: @_Z5blah1v()44define dso_local ptr @_Z5blah1v() local_unnamed_addr #0 {45entry:46  ; IR: call ptr @_Z3barv()47  %call = tail call ptr @_Z3barv()48  ret ptr %call49}50 51; Function Attrs: noinline52; IR-LABEL: @_Z5blah2v()53define dso_local ptr @_Z5blah2v() local_unnamed_addr #0 {54entry:55  ; IR: call ptr @_Z3barv()56  %call = tail call ptr @_Z3barv()57  ret ptr %call58}59 60; Function Attrs: noinline61; IR-LABEL: @_Z4baz1v()62define dso_local ptr @_Z4baz1v() local_unnamed_addr #0 {63entry:64  ; IR: call ptr @_Z5blah1v()65  %call = tail call ptr @_Z5blah1v()66  ret ptr %call67}68 69; Function Attrs: noinline70; IR-LABEL: @_Z4baz2v()71define dso_local ptr @_Z4baz2v() local_unnamed_addr #0 {72entry:73  ; IR: call ptr @_Z5blah2v()74  %call = tail call ptr @_Z5blah2v()75  ret ptr %call76}77 78; Function Attrs: noinline79; IR-LABEL: @_Z3foob(i1 %b)80define dso_local ptr @_Z3foob(i1 %b) local_unnamed_addr #0 {81entry:82  br i1 %b, label %if.then, label %if.else83 84if.then:                                          ; preds = %entry85  ; IR: call ptr @_Z4baz1v()86  %call = tail call ptr @_Z4baz1v()87  br label %return88 89if.else:                                          ; preds = %entry90  ; IR: call ptr @_Z4baz2v()91  %call1 = tail call ptr @_Z4baz2v()92  br label %return93 94return:                                           ; preds = %if.else, %if.then95  %retval.0 = phi ptr [ %call, %if.then ], [ %call1, %if.else ]96  ret ptr %retval.097}98 99; Function Attrs: noinline100; IR-LABEL: @xyz()101define dso_local i32 @xyz() local_unnamed_addr #0 {102  ; IR: call ptr @_Z3foob(i1 true)103  %call = tail call ptr @_Z3foob(i1 true)104  ; IR: call ptr @_Z3foob(i1 true)105  %call1 = tail call ptr @_Z3foob(i1 true)106  ; IR: call ptr @_Z3foob(i1 false)107  %call2 = tail call ptr @_Z3foob(i1 false)108  ; IR: call ptr @_Z3foob(i1 false)109  %call3 = tail call ptr @_Z3foob(i1 false)110  ret i32 0111}112 113define dso_local i32 @main() local_unnamed_addr #0 {114  ; IR: call i32 @xyz()115  %call1 = tail call i32 @xyz(), !callsite !11116  ret i32 0117}118 119; IR: attributes #[[NOTCOLD]] = { builtin allocsize(0) "memprof"="notcold" }120 121; STATS: 1 memprof-context-disambiguation - Number of profiled callees found via multiple tail call chains122 123attributes #0 = { noinline }124attributes #1 = { nobuiltin allocsize(0) }125attributes #2 = { builtin allocsize(0) }126 127!0 = !{!5, !7}128!5 = !{!6, !"notcold"}129!6 = !{i64 3186456655321080972, i64 8632435727821051414}130!7 = !{!8, !"cold"}131!8 = !{i64 3186456655321080972, i64 -3421689549917153178}132!9 = !{i64 3186456655321080972}133!11 = !{i64 -3421689549917153178}134