58 lines · plain
1; Check that we can handle the case when both alloc function and2; the user body consume the same argument.3; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s4 5; using this directly (as it would happen under -O2)6define ptr @f_direct(i64 %this) presplitcoroutine {7entry:8 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)9 %size = call i32 @llvm.coro.size.i32()10 %alloc = call ptr @myAlloc(i64 %this, i32 %size)11 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)12 %0 = call i8 @llvm.coro.suspend(token none, i1 false)13 switch i8 %0, label %suspend [i8 0, label %resume14 i8 1, label %cleanup]15resume:16 call void @print2(i64 %this)17 br label %cleanup18 19cleanup:20 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)21 call void @free(ptr %mem)22 br label %suspend23suspend:24 call void @llvm.coro.end(ptr %hdl, i1 0, token none)25 ret ptr %hdl26}27 28; See if %this was added to the frame29; CHECK: %f_direct.Frame = type { ptr, ptr, i64, i1 }30 31; See that %this is spilled into the frame32; CHECK-LABEL: define ptr @f_direct(i64 %this)33; CHECK: %this.spill.addr = getelementptr inbounds %f_direct.Frame, ptr %hdl, i32 0, i32 234; CHECK: store i64 %this, ptr %this.spill.addr35; CHECK: ret ptr %hdl36 37; See that %this was loaded from the frame38; CHECK-LABEL: @f_direct.resume(39; CHECK: %this.reload = load i64, ptr %this.reload.addr40; CHECK: call void @print2(i64 %this.reload)41; CHECK: ret void42 43declare ptr @llvm.coro.free(token, ptr)44declare i32 @llvm.coro.size.i32()45declare i8 @llvm.coro.suspend(token, i1)46declare void @llvm.coro.resume(ptr)47declare void @llvm.coro.destroy(ptr)48 49declare token @llvm.coro.id(i32, ptr, ptr, ptr)50declare i1 @llvm.coro.alloc(token)51declare ptr @llvm.coro.begin(token, ptr)52declare void @llvm.coro.end(ptr, i1, token)53 54declare noalias ptr @myAlloc(i64, i32)55declare double @print(double)56declare void @print2(i64)57declare void @free(ptr)58