100 lines · plain
1;; Test to ensure a call to a different callee but with the same debug info2;; (and therefore callsite metadata) as a preceding tail call in the alloc3;; context does not cause missing or incorrect cloning. This test is otherwise4;; the same as memprof-tailcall.ll.5 6;; -stats requires asserts7; REQUIRES: asserts8 9; RUN: opt -thinlto-bc %s >%t.o10; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \11; RUN: -supports-hot-cold-new \12; RUN: -r=%t.o,_Z3barv,plx \13; RUN: -r=%t.o,_Z3bazv,plx \14; RUN: -r=%t.o,_Z3foov,plx \15; RUN: -r=%t.o,main,plx \16; RUN: -r=%t.o,_Znam, \17; RUN: -r=%t.o,blah, \18; RUN: -stats -save-temps \19; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=STATS20 21; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR22 23; STATS: 2 memprof-context-disambiguation - Number of profiled callees found via tail calls24; STATS: 4 memprof-context-disambiguation - Aggregate depth of profiled callees found via tail calls25; STATS: 2 memprof-context-disambiguation - Maximum depth of profiled callees found via tail calls26 27source_filename = "memprof-tailcall-aliased-location1.cc"28target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"29target triple = "x86_64-unknown-linux-gnu"30 31; Function Attrs: noinline32; IR-LABEL: @_Z3barv()33define ptr @_Z3barv() local_unnamed_addr #0 {34entry:35 ; IR: call {{.*}} @_Znam(i64 10) #[[NOTCOLD:[0-9]+]]36 %call = tail call ptr @_Znam(i64 10) #2, !memprof !0, !callsite !537 ret ptr %call38}39 40; Function Attrs: nobuiltin allocsize(0)41declare ptr @_Znam(i64) #142declare void @blah()43 44; Function Attrs: noinline45; IR-LABEL: @_Z3bazv()46define ptr @_Z3bazv() #0 {47entry:48 ; IR: call ptr @_Z3barv()49 %call = tail call ptr @_Z3barv()50 ret ptr %call51}52 53; Function Attrs: noinline54; IR-LABEL: @_Z3foov()55define ptr @_Z3foov() #0 {56entry:57 ; IR: call ptr @_Z3bazv()58 %call = tail call ptr @_Z3bazv()59 ret ptr %call60}61 62; Function Attrs: noinline63; IR-LABEL: @main()64define i32 @main() #0 {65 ;; Preceding call to another callee but with the same debug location / callsite id66 call void @blah(), !callsite !667 ;; The first call to foo is part of a cold context, and should use the68 ;; original functions.69 ; IR: call ptr @_Z3foov()70 %call = tail call ptr @_Z3foov(), !callsite !671 ;; The second call to foo is part of a cold context, and should call the72 ;; cloned functions.73 ; IR: call ptr @_Z3foov.memprof.1()74 %call1 = tail call ptr @_Z3foov(), !callsite !775 ret i32 076}77 78; IR-LABEL: @_Z3barv.memprof.1()79; IR: call {{.*}} @_Znam(i64 10) #[[COLD:[0-9]+]]80; IR-LABEL: @_Z3bazv.memprof.1()81; IR: call ptr @_Z3barv.memprof.1()82; IR-LABEL: @_Z3foov.memprof.1()83; IR: call ptr @_Z3bazv.memprof.1()84 85; IR: attributes #[[NOTCOLD]] = { builtin allocsize(0) "memprof"="notcold" }86; IR: attributes #[[COLD]] = { builtin allocsize(0) "memprof"="cold" }87 88attributes #0 = { noinline }89attributes #1 = { nobuiltin allocsize(0) }90attributes #2 = { builtin allocsize(0) }91 92!0 = !{!1, !3}93!1 = !{!2, !"notcold"}94!2 = !{i64 3186456655321080972, i64 8632435727821051414}95!3 = !{!4, !"cold"}96!4 = !{i64 3186456655321080972, i64 -3421689549917153178}97!5 = !{i64 3186456655321080972}98!6 = !{i64 8632435727821051414}99!7 = !{i64 -3421689549917153178}100