Skip to content

Commit 4d4af13

Browse files
committed
Add a flag to turn off analysis of function calls in AllocBoxToStack
1 parent fba46ee commit 4d4af13

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/SILOptimizer/Transforms/AllocBoxToStack.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ static llvm::cl::opt<unsigned> MaxLocalApplyRecurDepth(
4444
"max-local-apply-recur-depth", llvm::cl::init(4),
4545
llvm::cl::desc("Max recursive depth for analyzing local functions"));
4646

47+
static llvm::cl::opt<bool> AllocBoxToStackAnalyzeApply(
48+
"allocbox-to-stack-analyze-apply", llvm::cl::init(true),
49+
llvm::cl::desc("Analyze functions into while alloc_box is passed"));
50+
4751
//===-----------------------------------------------------------------------===//
4852
// SIL Utilities for alloc_box Promotion
4953
//===----------------------------------------------------------------------===//
@@ -320,6 +324,10 @@ static bool checkLocalApplyBody(Operand *O,
320324
// AllocBoxToStack opt. We don't want to increase code size, so this is
321325
// restricted only for private local functions currently.
322326
static bool isOptimizableApplySite(ApplySite Apply) {
327+
if (!AllocBoxToStackAnalyzeApply) {
328+
// turned off explicitly
329+
return false;
330+
}
323331
auto callee = Apply.getReferencedFunctionOrNull();
324332
if (!callee) {
325333
return false;

test/SILOptimizer/allocboxtostack_localapply_ossa.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ bb0(%0 : @guaranteed ${ var Int64 }):
414414
// Order of function calls constructed in PromotedOperands: bar innercommon local1 bas innercommon local2
415415
// AppliesToSpecialize should have the order: bar bas innercommon local1 local2
416416
// Since we don't maintain any tree like data structure with more info on the call tree, this is not possible to contruct today
417-
// CHECK-LABEL: sil [noinline] @$s26allocboxtostack_localapply8testdfs2SiyF :
417+
// CHECK-LABEL: sil [noinline] [ossa] @$testdfs2 :
418418
// CHECK: alloc_box ${ var Int }, var, name "x"
419419
// CHECK: alloc_box ${ var Int }, var, name "y"
420-
// CHECK-LABEL:} // end sil function '$s26allocboxtostack_localapply8testdfs2SiyF'
420+
// CHECK-LABEL:} // end sil function '$testdfs2'
421421
sil [noinline] [ossa] @$testdfs2 : $@convention(thin) () -> Int {
422422
bb0:
423423
%0 = alloc_box ${ var Int }, var, name "x"

0 commit comments

Comments
 (0)