1; Check that we can handle the case when both alloc function and 2; the user body consume the same argument. 3; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s 4 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 %resume 14 i8 1, label %cleanup] 15resume: 16 call void @print2(i64 %this) 17 br label %cleanup 18 19cleanup: 20 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl) 21 call void @free(ptr %mem) 22 br label %suspend 23suspend: 24 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none) 25 ret ptr %hdl 26} 27 28; See if %this was added to the frame 29; CHECK: %f_direct.Frame = type { ptr, ptr, i64, i1 } 30 31; See that %this is spilled into the frame 32; CHECK-LABEL: define ptr @f_direct(i64 %this) 33; CHECK: %this.spill.addr = getelementptr inbounds %f_direct.Frame, ptr %hdl, i32 0, i32 2 34; CHECK: store i64 %this, ptr %this.spill.addr 35; CHECK: ret ptr %hdl 36 37; See that %this was loaded from the frame 38; CHECK-LABEL: @f_direct.resume( 39; CHECK: %this.reload = load i64, ptr %this.reload.addr 40; CHECK: call void @print2(i64 %this.reload) 41; CHECK: ret void 42 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 i1 @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