143 lines · plain
1;; Similar to funcassigncloning.ll but hand modified to add another allocation2;; whose pruned cold context only includes an immediate caller node that itself3;; doesn't need cloning, but calls a cloned allocating function, and is in a4;; function that gets cloned multiple times for a different callsite. This test5;; makes sure the non-cloned callsite is correctly updated in all function6;; clones. This case was missed because, due to context pruning, we don't have7;; any caller edges for the first callsite, so the handling that kicks in to8;; "reclone" other callsites in cloned functions was being missed.9 10; RUN: opt -thinlto-bc %s >%t.o11; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \12; RUN: -supports-hot-cold-new \13; RUN: -r=%t.o,main,plx \14; RUN: -r=%t.o,_Znam, \15; RUN: -memprof-verify-ccg -memprof-verify-nodes \16; RUN: -pass-remarks=memprof-context-disambiguation -save-temps \17; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=REMARKS18 19; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR20 21 22;; Try again but with distributed ThinLTO23; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \24; RUN: -supports-hot-cold-new \25; RUN: -thinlto-distributed-indexes \26; RUN: -r=%t.o,main,plx \27; RUN: -r=%t.o,_Znam, \28; RUN: -memprof-verify-ccg -memprof-verify-nodes \29; RUN: -pass-remarks=memprof-context-disambiguation \30; RUN: -o %t2.out31 32;; Run ThinLTO backend33; RUN: opt -passes=memprof-context-disambiguation \34; RUN: -memprof-import-summary=%t.o.thinlto.bc \35; RUN: -pass-remarks=memprof-context-disambiguation \36; RUN: %t.o -S 2>&1 | FileCheck %s --check-prefix=IR \37; RUN: --check-prefix=REMARKS38 39 40source_filename = "funcassigncloning.ll"41target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"42target triple = "x86_64-unknown-linux-gnu"43 44;; Eventually this function will be cloned several times (for the calls to new45;; for the various callers). However, function blah() includes an allocation46;; whose cold context was trimmed above here. We therefore should assume that47;; every caller of this function should call the same version of blah (which48;; will be the cloned ".memprof.1" version.49; Function Attrs: noinline optnone50define internal void @_Z1EPPcS0_(ptr %buf1, ptr %buf2) #0 {51entry:52 call void @blah(), !callsite !1953 %call = call ptr @_Znam(i64 noundef 10), !memprof !0, !callsite !754 %call1 = call ptr @_Znam(i64 noundef 10), !memprof !8, !callsite !1555 ret void56}57 58; REMARKS: call in clone _Z1EPPcS0_ assigned to call function clone blah.memprof.159; REMARKS: call in clone _Z1EPPcS0_.memprof.1 assigned to call function clone blah.memprof.160; REMARKS: call in clone _Z1EPPcS0_.memprof.2 assigned to call function clone blah.memprof.161; REMARKS: call in clone _Z1EPPcS0_.memprof.3 assigned to call function clone blah.memprof.162 63; IR: define {{.*}} @_Z1EPPcS0_64; IR: call {{.*}} @blah.memprof.1()65; IR: define {{.*}} @_Z1EPPcS0_.memprof.266; IR: call {{.*}} @blah.memprof.1()67; IR: define {{.*}} @_Z1EPPcS0_.memprof.368; IR: call {{.*}} @blah.memprof.1()69 70declare ptr @_Znam(i64)71 72define internal void @_Z1BPPcS0_() {73entry:74 call void @_Z1EPPcS0_(ptr null, ptr null), !callsite !1675 ret void76}77 78define internal void @_Z1CPPcS0_() {79entry:80 call void @_Z1EPPcS0_(ptr null, ptr null), !callsite !1781 ret void82}83 84define internal void @_Z1DPPcS0_() {85entry:86 call void @_Z1EPPcS0_(ptr null, ptr null), !callsite !1887 ret void88}89 90; Function Attrs: noinline optnone91define i32 @main() #0 {92entry:93 call void @_Z1BPPcS0_()94 call void @_Z1CPPcS0_()95 call void @_Z1DPPcS0_()96 ret i32 097}98 99define internal void @blah() #0 {100entry:101 %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !memprof !22, !callsite !21102 ret void103}104 105define internal void @foo() #0 {106entry:107 call void @blah(), !callsite !20108 ret void109}110 111; uselistorder directives112uselistorder ptr @_Znam, { 1, 0, 2 }113 114attributes #0 = { noinline optnone }115 116!0 = !{!1, !3, !5}117!1 = !{!2, !"cold"}118!2 = !{i64 -3461278137325233666, i64 -7799663586031895603}119!3 = !{!4, !"notcold"}120!4 = !{i64 -3461278137325233666, i64 -3483158674395044949}121!5 = !{!6, !"notcold"}122!6 = !{i64 -3461278137325233666, i64 -2441057035866683071}123!7 = !{i64 -3461278137325233666}124!8 = !{!9, !11, !13}125!9 = !{!10, !"notcold"}126!10 = !{i64 -1415475215210681400, i64 -2441057035866683071}127!11 = !{!12, !"cold"}128!12 = !{i64 -1415475215210681400, i64 -3483158674395044949}129!13 = !{!14, !"notcold"}130!14 = !{i64 -1415475215210681400, i64 -7799663586031895603}131!15 = !{i64 -1415475215210681400}132!16 = !{i64 -2441057035866683071}133!17 = !{i64 -3483158674395044949}134!18 = !{i64 -7799663586031895603}135!19 = !{i64 123}136!20 = !{i64 234}137!21 = !{i64 345}138!22 = !{!23, !25}139!23 = !{!24, !"cold"}140!24 = !{i64 345, i64 123}141!25 = !{!26, !"notcold"}142!26 = !{i64 345, i64 234}143