74 lines · plain
1; Test behavior when inlining policy grows size out of control.2; In all cases, the end result is the same: mandatory inlinings must happen.3; Also in all cases, we don't record the mandatory inlining (there's nothing to4; learn from it).5; However, when we discover we 'trip' over the artificially-low size increase 6; factor, we penalize the 'bad' decision.7; REQUIRES: have_tflite8;9; Generate mock model10; RUN: rm -rf %t11; RUN: rm -rf %t_savedmodel12; RUN: %python %S/../../../../lib/Analysis/models/gen-inline-oz-test-model.py %t_savedmodel13; RUN: %python %S/../../../../lib/Analysis/models/saved-model-to-tflite.py %t_savedmodel %t14;15; When the bounds are very wide ("no bounds"), all inlinings happen.16; RUN: opt -passes=scc-oz-module-inliner -ml-inliner-model-under-training=%t -training-log=%t1 -enable-ml-inliner=development -ml-advisor-size-increase-threshold=10.0 -S < %s | FileCheck %s --check-prefixes=NOBOUNDS-OUT,CHECK17; RUN: %python %S/../../../../lib/Analysis/models/log_reader.py %t1 | FileCheck %s --check-prefix=NOBOUNDS18;19; When the bounds are very restrictive, the first inlining happens but it's20; considered as "bad" (since it trips over the bounds) and its reward is a21; penalty. However, the mandatory inlining, which is considered next, happens.22; No other inlinings happend.23; RUN: opt -passes=scc-oz-module-inliner -ml-inliner-model-under-training=%t -training-log=%t2 -enable-ml-inliner=development -ml-advisor-size-increase-threshold=1.0 -S < %s | FileCheck %s --check-prefixes=BOUNDS-OUT,CHECK24; RUN: %python %S/../../../../lib/Analysis/models/log_reader.py %t2 | FileCheck %s --check-prefix=BOUNDS25;26; With more restrictive bounds, the first inlining happens and is OK. The27; mandatory inlining happens next, and it trips over the bounds, which then28; forces no further inlinings.29; RUN: opt -passes=scc-oz-module-inliner -ml-inliner-model-under-training=%t -training-log=%t3 -enable-ml-inliner=development -ml-advisor-size-increase-threshold=1.2 -S < %s | FileCheck %s --check-prefixes=RELAXED-BOUNDS-OUT,CHECK30; RUN: %python %S/../../../../lib/Analysis/models/log_reader.py %t3 | FileCheck %s --check-prefix=RELAXED-BOUNDS31 32target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"33target triple = "x86_64-grtev4-linux-gnu"34declare i64 @f1()35define i64 @may_not_be_inlined() {36 %r = call i64 @f1()37 %r2 = add i64 13, %r38 ret i64 %r239}40define i64 @must_be_inlined() #0 {41 %r = call i64 @may_not_be_inlined()42 %r2 = add i64 13, %r43 ret i64 %r244}45define i64 @top() {46 %r = call i64 @must_be_inlined()47 %r2 = call i64 @may_not_be_inlined()48 %r3 = call i64 @may_not_be_inlined()49 %r4 = add i64 %r, %r250 %r5 = add i64 %r3, %r451 ret i64 %r552}53attributes #0 = { alwaysinline }54; NOBOUNDS: observation: 055; NOBOUNDS: inlining_decision: 156; RELAXED-BOUNDS: inlining_decision: 157; BOUNDS: inlining_decision: 158; NOBOUNDS: observation: 159; BOUNDS-NOT: observation: 160; RELAXED-BOUNDS: observation: 161; NOBOUNDS: inlining_decision: 162; NOBOUNDS: observation: 263; NOBOUNDS: inlining_decision64; RELAXED-BOUNDS-NOT: observation: 265 66; CHECK-LABEL: @top67; must_be_inlined must always be inlined, so we won't find a call to it in @top()68; CHECK-NOT: call i64 @must_be_inlined69; @some-function isn't mandatory, and when we set the increase threshold too low,70; it won't be inlined.71; NOBOUNDS-OUT-NOT: @may_not_be_inlined72; RELAXED-BOUNDS-OUT: call i64 @may_not_be_inlined73; BOUNDS-OUT: call i64 @may_not_be_inlined74