brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · d63076d Raw
70 lines · plain
1; Inlining in the presence of recursion presents special challenges that we2; test here.3;4; RUN: opt -passes=inline -S < %s | FileCheck %s5; RUN: opt -passes='cgscc(inline)' -S < %s | FileCheck %s6 7define i32 @large_stack_callee(i32 %param) {8; CHECK-LABEL: define i32 @large_stack_callee(9entry:10 %yyy = alloca [100000 x i8]11 call void @bar(ptr %yyy)12 ret i32 413}14 15; Test a recursive function which calls another function with a large stack. In16; addition to not inlining the recursive call, we should also not inline the17; large stack allocation into a potentially recursive frame.18define i32 @large_stack_recursive_caller(i32 %param) {19; CHECK-LABEL: define i32 @large_stack_recursive_caller(20entry:21; CHECK-NEXT: entry:22; CHECK-NOT: alloca23  %t = call i32 @foo(i32 %param)24  %cmp = icmp eq i32 %t, -125  br i1 %cmp, label %exit, label %cont26 27cont:28  %r = call i32 @large_stack_recursive_caller(i32 %t)29; CHECK: call i32 @large_stack_recursive_caller30  %f = call i32 @large_stack_callee(i32 %r)31; CHECK: call i32 @large_stack_callee32  br label %exit33 34exit:35  ret i32 436}37 38declare void @bar(ptr %in)39 40declare i32 @foo(i32 %param)41 42; Check that when inlining a non-recursive path into a function's own body that43; we get the re-mapping of instructions correct.44define i32 @test_recursive_inlining_remapping(i1 %init, ptr %addr) {45; CHECK-LABEL: define i32 @test_recursive_inlining_remapping(46bb:47  %n = alloca i3248  br i1 %init, label %store, label %load49; CHECK-NOT:     alloca50;51; CHECK:         %[[N:.*]] = alloca i3252; CHECK-NEXT:    br i1 %init,53 54store:55  store i32 0, ptr %n56  %v = call i32 @test_recursive_inlining_remapping(i1 false, ptr %n)57  ret i32 %v58; CHECK-NOT:     call59;60; CHECK:         store i32 0, ptr %[[N]]61; CHECK-NEXT:    %[[INLINED_LOAD:.*]] = load i32, ptr %[[N]]62; CHECK-NEXT:    ret i32 %[[INLINED_LOAD]]63;64; CHECK-NOT:     call65 66load:67  %n.load = load i32, ptr %addr68  ret i32 %n.load69}70