79 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes="default<O2>" -aa-pipeline=default -S | FileCheck %s3 4define ptr @f(ptr %buffer, i32 %n) {5; CHECK-LABEL: @f(6; CHECK-NEXT: coro.return:7; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 12)8; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER:%.*]], align 89; CHECK-NEXT: store i32 [[N:%.*]], ptr [[TMP0]], align 410; CHECK-NEXT: ret ptr @f.resume.011;12entry:13 %id = call token @llvm.coro.id.retcon(i32 8, i32 4, ptr %buffer, ptr @prototype, ptr @allocate, ptr @deallocate)14 %hdl = call ptr @llvm.coro.begin(token %id, ptr null)15 br label %loop16 17loop:18 %n.val = phi i32 [ %n, %entry ], [ %sum, %resume ]19 %values = call { i32, i1 } (...) @llvm.coro.suspend.retcon.sl_i32i1s()20 %finished = extractvalue { i32, i1 } %values, 121 br i1 %finished, label %cleanup, label %resume22 23resume:24 %input = extractvalue { i32, i1 } %values, 025 %sum = add i32 %n.val, %input26 br label %loop27 28cleanup:29 call void @print(i32 %n.val)30 call void @llvm.coro.end(ptr %hdl, i1 0, token none)31 unreachable32}33 34 35 36define i32 @main() {37; CHECK-LABEL: @main(38; CHECK-NEXT: entry:39; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 12)40; CHECK-NEXT: store i32 1, ptr [[TMP0]], align 441; CHECK-NEXT: [[N_VAL3_SPILL_ADDR_I:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 442; CHECK-NEXT: store i32 1, ptr [[N_VAL3_SPILL_ADDR_I]], align 4, !noalias [[META0:![0-9]+]]43; CHECK-NEXT: [[INPUT_SPILL_ADDR_I:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 844; CHECK-NEXT: store i32 2, ptr [[INPUT_SPILL_ADDR_I]], align 4, !noalias [[META0]]45; CHECK-NEXT: [[INPUT_RELOAD_ADDR13_I:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 846; CHECK-NEXT: [[N_VAL3_RELOAD_ADDR11_I:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 447; CHECK-NEXT: store i32 3, ptr [[N_VAL3_RELOAD_ADDR11_I]], align 4, !noalias [[META3:![0-9]+]]48; CHECK-NEXT: store i32 4, ptr [[INPUT_RELOAD_ADDR13_I]], align 4, !noalias [[META3]]49; CHECK-NEXT: tail call void @print(i32 7), !noalias [[META6:![0-9]+]]50; CHECK-NEXT: tail call void @deallocate(ptr nonnull [[TMP0]]), !noalias [[META6]]51; CHECK-NEXT: ret i32 052;53entry:54 %0 = alloca [8 x i8], align 455 %prepare = call ptr @llvm.coro.prepare.retcon(ptr @f)56 %cont0 = call ptr %prepare(ptr %0, i32 1)57 %cont1 = call ptr %cont0(ptr %0, i32 2, i1 zeroext false)58 %cont2 = call ptr %cont1(ptr %0, i32 4, i1 zeroext false)59 call ptr %cont2(ptr %0, i32 100, i1 zeroext true)60 ret i32 061}62 63; Unfortunately, we don't seem to fully optimize this right now due64; to some sort of phase-ordering thing.65 66declare token @llvm.coro.id.retcon(i32, i32, ptr, ptr, ptr, ptr)67declare ptr @llvm.coro.begin(token, ptr)68declare { i32, i1 } @llvm.coro.suspend.retcon.sl_i32i1s(...)69declare void @llvm.coro.end(ptr, i1, token)70declare ptr @llvm.coro.prepare.retcon(ptr)71 72declare ptr @prototype(ptr, i32, i1 zeroext)73 74declare noalias ptr @allocate(i32 %size)75declare void @deallocate(ptr %ptr)76 77declare void @print(i32)78 79