brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · bf419ea Raw
103 lines · plain
1;; This test ensures that the logic which assigns calls to stack nodes2;; correctly handles a case where multiple nodes have stack ids that3;; overlap with each other but have different last nodes (can happen with4;; inlining into various levels of a call chain). Specifically, when we5;; have one that is duplicated (e.g. unrolling), we need to correctly6;; handle the case where the context id has already been assigned to7;; a different call with a different last node.8 9;; -stats requires asserts10; REQUIRES: asserts11 12; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \13; RUN:	-memprof-verify-ccg -memprof-verify-nodes \14; RUN:  -stats -pass-remarks=memprof-context-disambiguation \15; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=IR \16; RUN:  --check-prefix=STATS --check-prefix=REMARKS17 18; REMARKS: created clone _Z1Ab.memprof.119; REMARKS: created clone _Z3XZNv.memprof.120; REMARKS: call in clone main assigned to call function clone _Z3XZNv.memprof.121;; Make sure the inlined context in _Z3XZNv, which partially overlaps the stack22;; ids in the shorter inlined context of Z2XZv, correctly calls a cloned23;; version of Z1Ab, which will call the cold annotated allocation.24; REMARKS: call in clone _Z3XZNv.memprof.1 assigned to call function clone _Z1Ab.memprof.125; REMARKS: call in clone _Z1Ab.memprof.1 marked with memprof allocation attribute cold26; REMARKS: call in clone main assigned to call function clone _Z3XZNv27; REMARKS: call in clone _Z3XZNv assigned to call function clone _Z1Ab28; REMARKS: call in clone _Z1Ab marked with memprof allocation attribute notcold29 30 31target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"32target triple = "x86_64-unknown-linux-gnu"33 34define dso_local void @_Z1Ab() {35entry:36  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #1, !memprof !0, !callsite !537  ret void38}39 40; Function Attrs: nobuiltin41declare ptr @_Znam(i64) #042 43;; Inlining of stack id 2 into 3. Assume this is called from somewhere else.44define dso_local void @_Z2XZv() local_unnamed_addr #0 {45entry:46  ;; Simulate duplication of the callsite (e.g. unrolling).47  call void @_Z1Ab(), !callsite !648  call void @_Z1Ab(), !callsite !649  ret void50}51 52;; Inlining of stack id 2 into 3 into 4. Called by main below.53define dso_local void @_Z3XZNv() local_unnamed_addr {54entry:55  call void @_Z1Ab(), !callsite !756  ret void57}58 59define dso_local noundef i32 @main() local_unnamed_addr {60entry:61  call void @_Z3XZNv(), !callsite !8 ;; Not cold context62  call void @_Z3XZNv(), !callsite !9 ;; Cold context63  ret i32 064}65 66attributes #0 = { nobuiltin }67attributes #7 = { builtin }68 69!0 = !{!1, !3}70;; Not cold context via first call to _Z3XZNv in main71!1 = !{!2, !"notcold"}72!2 = !{i64 1, i64 2, i64 3, i64 4, i64 5}73;; Cold context via second call to _Z3XZNv in main74!3 = !{!4, !"cold"}75!4 = !{i64 1, i64 2, i64 3, i64 4, i64 6}76!5 = !{i64 1}77!6 = !{i64 2, i64 3}78!7 = !{i64 2, i64 3, i64 4}79!8 = !{i64 5}80!9 = !{i64 6}81 82; IR: define {{.*}} @_Z1Ab()83; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[NOTCOLD:[0-9]+]]84; IR: define {{.*}} @_Z2XZv()85; IR:   call {{.*}} @_Z1Ab()86; IR:   call {{.*}} @_Z1Ab()87; IR: define {{.*}} @_Z3XZNv()88; IR:   call {{.*}} @_Z1Ab()89; IR: define {{.*}} @main()90; IR:   call {{.*}} @_Z3XZNv()91; IR:   call {{.*}} @_Z3XZNv.memprof.1()92; IR: define {{.*}} @_Z1Ab.memprof.1()93; IR:   call {{.*}} @_Znam(i64 noundef 10) #[[COLD:[0-9]+]]94; IR: define {{.*}} @_Z3XZNv.memprof.1()95; IR:   call {{.*}} @_Z1Ab.memprof.1()96 97; IR: attributes #[[NOTCOLD]] = { "memprof"="notcold" }98; IR: attributes #[[COLD]] = { "memprof"="cold" }99 100; STATS: 1 memprof-context-disambiguation - Number of cold static allocations (possibly cloned)101; STATS: 1 memprof-context-disambiguation - Number of not cold static allocations (possibly cloned)102; STATS: 2 memprof-context-disambiguation - Number of function clones created during whole program analysis103