brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · d25d335 Raw
67 lines · plain
1; Check that we can handle spills of the result of the invoke instruction2; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s3 4define ptr @f(i64 %this) presplitcoroutine personality i32 0 {5entry:6  %this.addr = alloca i647  store i64 %this, ptr %this.addr8  %this1 = load i64, ptr %this.addr9  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)10  %size = call i32 @llvm.coro.size.i32()11  %alloc = call ptr @malloc(i32 %size)12  %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)13  %r = invoke double @print(double 0.0) to label %cont unwind label %pad14 15cont:16  %0 = call i8 @llvm.coro.suspend(token none, i1 false)17  switch i8 %0, label %suspend [i8 0, label %resume18                                i8 1, label %cleanup]19resume:20  call double @print(double %r)21  call void @print2(i64 %this1)22  br label %cleanup23 24cleanup:25  %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)26  call void @free(ptr %mem)27  br label %suspend28suspend:29  call void @llvm.coro.end(ptr %hdl, i1 0, token none)30  ret ptr %hdl31pad:32  %tok = cleanuppad within none []33  cleanupret from %tok unwind to caller34}35 36; See if the float was added to the frame37; CHECK-LABEL: %f.Frame = type { ptr, ptr, double, i64, i1 }38 39; See if the float was spilled into the frame40; CHECK-LABEL: @f(41; CHECK: %r = call double @print(42; CHECK: %r.spill.addr = getelementptr inbounds %f.Frame, ptr %hdl, i32 0, i32 243; CHECK: store double %r, ptr %r.spill.addr44; CHECK: ret ptr %hdl45 46; See if the float was loaded from the frame47; CHECK-LABEL: @f.resume(ptr noundef nonnull align 848; CHECK: %r.reload = load double, ptr %r.reload.addr49; CHECK: call double @print(double %r.reload)50; CHECK: ret void51 52declare ptr @llvm.coro.free(token, ptr)53declare i32 @llvm.coro.size.i32()54declare i8  @llvm.coro.suspend(token, i1)55declare void @llvm.coro.resume(ptr)56declare void @llvm.coro.destroy(ptr)57 58declare token @llvm.coro.id(i32, ptr, ptr, ptr)59declare i1 @llvm.coro.alloc(token)60declare ptr @llvm.coro.begin(token, ptr)61declare void @llvm.coro.end(ptr, i1, token)62 63declare noalias ptr @malloc(i32)64declare double @print(double)65declare void @print2(i64)66declare void @free(ptr)67