brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 851f8a7 Raw
63 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 copy of this (as it would happen under -O0)6define ptr @f_copy(i64 %this_arg) presplitcoroutine {7entry:8  %this.addr = alloca i649  store i64 %this_arg, ptr %this.addr10  %this = load i64, ptr %this.addr11  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)12  %size = call i32 @llvm.coro.size.i32()13  %alloc = call ptr @myAlloc(i64 %this, i32 %size)14  %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)15  %0 = call i8 @llvm.coro.suspend(token none, i1 false)16  switch i8 %0, label %suspend [i8 0, label %resume17                                i8 1, label %cleanup]18resume:19  call void @print2(i64 %this)20  br label %cleanup21 22cleanup:23  %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)24  call void @free(ptr %mem)25  br label %suspend26suspend:27  call void @llvm.coro.end(ptr %hdl, i1 0, token none)28  ret ptr %hdl29}30 31; See if %this was added to the frame32; CHECK: %f_copy.Frame = type { ptr, ptr, i64, i1 }33 34; See that %this is spilled into the frame35; CHECK-LABEL: define ptr @f_copy(i64 %this_arg)36; CHECK:  %this.addr = alloca i64, align 837; CHECK:  store i64 %this_arg, ptr %this.addr, align 438; CHECK:  %this.spill.addr = getelementptr inbounds %f_copy.Frame, ptr %hdl, i32 0, i32 239; CHECK:  store i64 %this_arg, ptr %this.spill.addr40; CHECK:  ret ptr %hdl41 42; See that %this was loaded from the frame43; CHECK-LABEL: @f_copy.resume(44; CHECK:  %this.reload = load i64, ptr %this.reload.addr45; CHECK:  call void @print2(i64 %this.reload)46; CHECK:  ret void47 48declare ptr @llvm.coro.free(token, ptr)49declare i32 @llvm.coro.size.i32()50declare i8  @llvm.coro.suspend(token, i1)51declare void @llvm.coro.resume(ptr)52declare void @llvm.coro.destroy(ptr)53 54declare token @llvm.coro.id(i32, ptr, ptr, ptr)55declare i1 @llvm.coro.alloc(token)56declare ptr @llvm.coro.begin(token, ptr)57declare void @llvm.coro.end(ptr, i1, token)58 59declare noalias ptr @myAlloc(i64, i32)60declare double @print(double)61declare void @print2(i64)62declare void @free(ptr)63