brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 2f1aded Raw
73 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=tailcallelim -verify-dom-info -S | FileCheck %s3 4; IR for that test was generated from the following C++ source:5;6;int count;7;__attribute__((noinline)) void globalIncrement(const int* param) { count += *param; }8;9;void test(int recurseCount)10;{11;    if (recurseCount == 0) return;12;    int temp = 10;13;    globalIncrement(&temp);14;    test(recurseCount - 1);15;}16;17 18@count = dso_local local_unnamed_addr global i32 0, align 419 20; Function Attrs: nofree noinline norecurse nounwind uwtable21declare void @_Z15globalIncrementPKi(ptr nocapture readonly %param) #022 23; Test that TRE could be done for recursive tail routine containing24; call to function receiving a pointer to local stack.25 26; Function Attrs: nounwind uwtable27define dso_local void @_Z4testi(i32 %recurseCount) local_unnamed_addr #1 {28; CHECK-LABEL: @_Z4testi(29; CHECK-NEXT:  entry:30; CHECK-NEXT:    [[TEMP:%.*]] = alloca i32, align 431; CHECK-NEXT:    br label [[TAILRECURSE:%.*]]32; CHECK:       tailrecurse:33; CHECK-NEXT:    [[RECURSECOUNT_TR:%.*]] = phi i32 [ [[RECURSECOUNT:%.*]], [[ENTRY:%.*]] ], [ [[SUB:%.*]], [[IF_END:%.*]] ]34; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[RECURSECOUNT_TR]], 035; CHECK-NEXT:    br i1 [[CMP]], label [[RETURN:%.*]], label [[IF_END]]36; CHECK:       if.end:37; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr nonnull [[TEMP]])38; CHECK-NEXT:    store i32 10, ptr [[TEMP]], align 439; CHECK-NEXT:    call void @_Z15globalIncrementPKi(ptr nonnull [[TEMP]])40; CHECK-NEXT:    [[SUB]] = add nsw i32 [[RECURSECOUNT_TR]], -141; CHECK-NEXT:    call void @llvm.lifetime.end.p0(ptr nonnull [[TEMP]])42; CHECK-NEXT:    br label [[TAILRECURSE]]43; CHECK:       return:44; CHECK-NEXT:    ret void45;46entry:47  %temp = alloca i32, align 448  %cmp = icmp eq i32 %recurseCount, 049  br i1 %cmp, label %return, label %if.end50 51if.end:                                           ; preds = %entry52  call void @llvm.lifetime.start.p0(ptr nonnull %temp) #653  store i32 10, ptr %temp, align 454  call void @_Z15globalIncrementPKi(ptr nonnull %temp)55  %sub = add nsw i32 %recurseCount, -156  call void @_Z4testi(i32 %sub)57  call void @llvm.lifetime.end.p0(ptr nonnull %temp) #658  br label %return59 60return:                                           ; preds = %entry, %if.end61  ret void62}63 64; Function Attrs: argmemonly nounwind willreturn65declare void @llvm.lifetime.start.p0(ptr nocapture) #266 67; Function Attrs: argmemonly nounwind willreturn68declare void @llvm.lifetime.end.p0(ptr nocapture) #269 70attributes #0 = { nofree noinline norecurse nounwind uwtable }71attributes #1 = { nounwind uwtable }72attributes #2 = { argmemonly nounwind willreturn }73