101 lines · plain
1;; Test to make sure that missing tail call frames in memprof profiles are2;; identified and cloned as needed for regular LTO.3 4;; -stats requires asserts5; REQUIRES: asserts6 7; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \8; RUN: -stats %s -S 2>&1 | FileCheck %s --check-prefix=STATS --check-prefix=IR9 10;; Check that a smaller search depth limit blocks the tail call discovery11; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \12; RUN: -memprof-tail-call-search-depth=1 -stats %s -S 2>&1 | FileCheck %s \13; RUN: --implicit-check-not=_Z3foov.memprof --implicit-check-not="found via tail calls"14 15source_filename = "memprof-tailcall.cc"16target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"17target triple = "x86_64-unknown-linux-gnu"18 19@a = dso_local global [2 x ptr] [ptr @_Z2a1v, ptr @_Z2a2v], align 1620 21declare void @_Z2a1v() #022 23declare void @_Z2a2v() #024 25; Function Attrs: noinline26; IR-LABEL: @_Z3barv()27define ptr @_Z3barv() local_unnamed_addr #0 {28entry:29 ; IR: call ptr @_Znam(i64 10) #[[NOTCOLD:[0-9]+]]30 %call = tail call ptr @_Znam(i64 10) #2, !memprof !0, !callsite !531 ret ptr %call32}33 34; Function Attrs: nobuiltin allocsize(0)35declare ptr @_Znam(i64) #136 37; Function Attrs: noinline38; IR-LABEL: @_Z3bazv()39define ptr @_Z3bazv() #0 {40entry:41 ; IR: call ptr @_Z3barv()42 %call = tail call ptr @_Z3barv()43 ret ptr %call44}45 46; Function Attrs: noinline47; IR-LABEL: @_Z3foov()48define ptr @_Z3foov() #0 {49entry:50 ; IR: call ptr @_Z3bazv()51 %call = tail call ptr @_Z3bazv()52 ret ptr %call53}54 55; Function Attrs: noinline56; IR-LABEL: @main()57define i32 @main() #0 {58 ;; The first call to foo is part of a cold context, and should use the59 ;; original functions.60 ;; allocation. The latter should call the cloned functions.61 ; IR: call ptr @_Z3foov()62 %call = tail call ptr @_Z3foov(), !callsite !663 ;; The second call to foo is part of a cold context, and should call the64 ;; cloned functions.65 ; IR: call ptr @_Z3foov.memprof.1()66 %call1 = tail call ptr @_Z3foov(), !callsite !767 %2 = load ptr, ptr @a, align 1668 call void %2(), !callsite !1069 ret i32 070}71 72; IR-LABEL: @_Z3barv.memprof.1()73; IR: call ptr @_Znam(i64 10) #[[COLD:[0-9]+]]74; IR-LABEL: @_Z3bazv.memprof.1()75; IR: call ptr @_Z3barv.memprof.1()76; IR-LABEL: @_Z3foov.memprof.1()77; IR: call ptr @_Z3bazv.memprof.1()78 79; IR: attributes #[[NOTCOLD]] = { builtin allocsize(0) "memprof"="notcold" }80; IR: attributes #[[COLD]] = { builtin allocsize(0) "memprof"="cold" }81 82; STATS: 2 memprof-context-disambiguation - Number of profiled callees found via tail calls83; STATS: 4 memprof-context-disambiguation - Aggregate depth of profiled callees found via tail calls84; STATS: 2 memprof-context-disambiguation - Maximum depth of profiled callees found via tail calls85 86attributes #0 = { noinline }87attributes #1 = { nobuiltin allocsize(0) }88attributes #2 = { builtin allocsize(0) }89 90!0 = !{!1, !3, !8}91!1 = !{!2, !"notcold"}92!2 = !{i64 3186456655321080972, i64 8632435727821051414}93!3 = !{!4, !"cold"}94!4 = !{i64 3186456655321080972, i64 -3421689549917153178}95!5 = !{i64 3186456655321080972}96!6 = !{i64 8632435727821051414}97!7 = !{i64 -3421689549917153178}98!8 = !{!9, !"notcold"}99!9 = !{i64 3186456655321080972, i64 1}100!10 = !{i64 1}101