brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · ccdefdc Raw
78 lines · plain
1; REQUIRES: have_tflite2; RUN: rm -rf %t.runfiles %t.tflite %t.model_out3; RUN: mkdir %t.runfiles4; RUN: cp %S/../../../../lib/Analysis/models/gen-inline-oz-test-model.py %t.runfiles5; RUN: cp %S/../../../../lib/Analysis/models/saved-model-to-tflite.py %t.runfiles6; RUN: %python %t.runfiles/gen-inline-oz-test-model.py %t.model_out never7; RUN: %python %t.runfiles/saved-model-to-tflite.py %t.model_out %t.tflite8 9; When running O2, we expect both callers to inline callee.10; RUN: opt < %s -passes='default<O2>' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s --check-prefixes=O2-HOT,O2-COLD11 12; The ML model we use always blocks inlining (by construction)13; RUN: opt < %s -passes='default<O2>' -inline-threshold=0 -hot-callsite-threshold=100 \14; RUN:  -enable-ml-inliner=development -ml-inliner-model-under-training=%t.tflite \15; RUN:  -S | FileCheck %s --check-prefixes=ML-HOT,ML-COLD16 17; When bypassing ML for non-cold callers, the hot caller will have its callee inlined, but the cold one won't18; RUN: opt < %s -passes='default<O2>' -inline-threshold=0 -hot-callsite-threshold=100 \19; RUN:  -enable-ml-inliner=development -ml-inliner-model-under-training=%t.tflite \20; RUN: -ml-inliner-skip-policy=if-caller-not-cold -S | FileCheck %s --check-prefixes=O2-HOT,ML-COLD21 22declare void @extern()23 24define i32 @callee(i32 %x) {25  %x1 = add i32 %x, 126  %x2 = add i32 %x1, 127  %x3 = add i32 %x2, 128  call void @extern()29  call void @extern()30  ret i32 %x331}32 33define i32 @hot_caller(i32 %y1) !prof !15 {34  %y = call i32 @callee(i32 %y1), !prof !1635  ret i32 %y36}37 38define i32 @cold_caller(i32 %y1) !prof !17 {39  %y = call i32 @callee(i32 %y1), !prof !1640  ret i32 %y41}42 43 44!llvm.module.flags = !{!1}45!15 = !{!"function_entry_count", i64 300}46!16 = !{!"branch_weights", i64 300}47!17 = !{!"function_entry_count", i64 1}48 49!1 = !{i32 1, !"ProfileSummary", !2}50!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}51!3 = !{!"ProfileFormat", !"SampleProfile"}52!4 = !{!"TotalCount", i64 10000}53!5 = !{!"MaxCount", i64 1000}54!6 = !{!"MaxInternalCount", i64 1}55!7 = !{!"MaxFunctionCount", i64 1000}56!8 = !{!"NumCounts", i64 3}57!9 = !{!"NumFunctions", i64 3}58!10 = !{!"DetailedSummary", !11}59!11 = !{!12, !13, !14}60!12 = !{i32 10000, i64 100, i32 1}61!13 = !{i32 999000, i64 100, i32 1}62!14 = !{i32 999999, i64 1, i32 2}63 64; O2-HOT-LABEL: @hot_caller65; O2-HOT-NOT: call i32 @callee66; O2-HOT: call void @extern67; O2-HOT-NEXT: call void @extern68; O2-HOT-NEXT: ret69; O2-COLD-LABEL: @cold_caller70; O2-COLD-NOT: call i32 @callee71; O2-COLD: call void @extern72; O2-COLD-NEXT: call void @extern73; O2-COLD-NEXT: ret74 75; ML-HOT-LABEL: @hot_caller76; ML-HOT-NEXT: call i32 @callee77; ML-COLD-LABEL: @cold_caller78; ML-COLD-NEXT: call i32 @callee