|
| 1 | +; RUN: opt < %s -passes=coro-split -S | FileCheck %s |
| 2 | +%promise_type = type { i8 } |
| 3 | +%struct.A = type <{ i64, i64, i32, [4 x i8] }> |
| 4 | + |
| 5 | +; Function Attrs: noinline ssp uwtable mustprogress |
| 6 | +define %promise_type* @foo(%struct.A* nocapture readonly byval(%struct.A) align 8 %a1) #0 { |
| 7 | +entry: |
| 8 | + %__promise = alloca %promise_type, align 1 |
| 9 | + %a2 = alloca %struct.A, align 8 |
| 10 | + %0 = getelementptr inbounds %promise_type, %promise_type* %__promise, i64 0, i32 0 |
| 11 | + %1 = call token @llvm.coro.id(i32 16, i8* nonnull %0, i8* bitcast (%promise_type* (%struct.A*)* @foo to i8*), i8* null) |
| 12 | + %2 = call i1 @llvm.coro.alloc(token %1) |
| 13 | + br i1 %2, label %coro.alloc, label %coro.init |
| 14 | + |
| 15 | +coro.alloc: ; preds = %entry |
| 16 | + %3 = call i64 @llvm.coro.size.i64() |
| 17 | + %call = call noalias nonnull i8* @_Znwm(i64 %3) #9 |
| 18 | + br label %coro.init |
| 19 | + |
| 20 | +coro.init: ; preds = %coro.alloc, %entry |
| 21 | + %4 = phi i8* [ null, %entry ], [ %call, %coro.alloc ] |
| 22 | + %5 = call i8* @llvm.coro.begin(token %1, i8* %4) #10 |
| 23 | + %6 = bitcast %struct.A* %a1 to i8* |
| 24 | + call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %0) #2 |
| 25 | + %call2 = call %promise_type* @_ZN4task12promise_type17get_return_objectEv(%promise_type* nonnull dereferenceable(1) %__promise) |
| 26 | + call void @initial_suspend(%promise_type* nonnull dereferenceable(1) %__promise) |
| 27 | + %7 = call token @llvm.coro.save(i8* null) |
| 28 | + call fastcc void @_ZNSt12experimental13coroutines_v116coroutine_handleIN4task12promise_typeEE12from_addressEPv(i8* %5) #2 |
| 29 | + %8 = call i8 @llvm.coro.suspend(token %7, i1 false) |
| 30 | + switch i8 %8, label %coro.ret [ |
| 31 | + i8 0, label %init.ready |
| 32 | + i8 1, label %cleanup33 |
| 33 | + ] |
| 34 | + |
| 35 | +init.ready: ; preds = %coro.init |
| 36 | + %9 = bitcast %struct.A* %a2 to i8* |
| 37 | + call void @llvm.lifetime.start.p0i8(i64 24, i8* nonnull %9) #2 |
| 38 | + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %9, i8* align 8 %6, i64 24, i1 false) |
| 39 | + call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %9) #2 |
| 40 | + call void @_ZN4task12promise_type13final_suspendEv(%promise_type* nonnull dereferenceable(1) %__promise) #2 |
| 41 | + %10 = call token @llvm.coro.save(i8* null) |
| 42 | + call fastcc void @_ZNSt12experimental13coroutines_v116coroutine_handleIN4task12promise_typeEE12from_addressEPv(i8* %5) #2 |
| 43 | + %11 = call i8 @llvm.coro.suspend(token %10, i1 true) #10 |
| 44 | + %switch = icmp ult i8 %11, 2 |
| 45 | + br i1 %switch, label %cleanup33, label %coro.ret |
| 46 | + |
| 47 | +cleanup33: ; preds = %init.ready, %coro.init |
| 48 | + call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %0) #2 |
| 49 | + %12 = call i8* @llvm.coro.free(token %1, i8* %5) |
| 50 | + %.not = icmp eq i8* %12, null |
| 51 | + br i1 %.not, label %coro.ret, label %coro.free |
| 52 | + |
| 53 | +coro.free: ; preds = %cleanup33 |
| 54 | + call void @_ZdlPv(i8* nonnull %12) #2 |
| 55 | + br label %coro.ret |
| 56 | + |
| 57 | +coro.ret: ; preds = %coro.free, %cleanup33, %init.ready, %coro.init |
| 58 | + %13 = call i1 @llvm.coro.end(i8* null, i1 false) #10 |
| 59 | + ret %promise_type* %call2 |
| 60 | +} |
| 61 | + |
| 62 | +; check that the frame contains the entire struct, instead of just the struct pointer |
| 63 | +; CHECK: %foo.Frame = type { void (%foo.Frame*)*, void (%foo.Frame*)*, %promise_type, %struct.A, i1 } |
| 64 | + |
| 65 | +; Function Attrs: argmemonly nounwind readonly |
| 66 | +declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1 |
| 67 | + |
| 68 | +; Function Attrs: nounwind |
| 69 | +declare i1 @llvm.coro.alloc(token) #2 |
| 70 | + |
| 71 | +; Function Attrs: nobuiltin nofree allocsize(0) |
| 72 | +declare nonnull i8* @_Znwm(i64) local_unnamed_addr #3 |
| 73 | + |
| 74 | +; Function Attrs: nounwind readnone |
| 75 | +declare i64 @llvm.coro.size.i64() #4 |
| 76 | + |
| 77 | +; Function Attrs: nounwind |
| 78 | +declare i8* @llvm.coro.begin(token, i8* writeonly) #2 |
| 79 | + |
| 80 | +; Function Attrs: argmemonly nofree nosync nounwind willreturn |
| 81 | +declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #5 |
| 82 | + |
| 83 | +; Function Attrs: argmemonly nofree nounwind willreturn |
| 84 | +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #6 |
| 85 | + |
| 86 | +; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress |
| 87 | +declare %promise_type* @_ZN4task12promise_type17get_return_objectEv(%promise_type* nonnull dereferenceable(1)) local_unnamed_addr #7 align 2 |
| 88 | + |
| 89 | +; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress |
| 90 | +declare void @initial_suspend(%promise_type* nonnull dereferenceable(1)) local_unnamed_addr #7 align 2 |
| 91 | + |
| 92 | +; Function Attrs: nounwind |
| 93 | +declare token @llvm.coro.save(i8*) #2 |
| 94 | + |
| 95 | +; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress |
| 96 | +declare hidden fastcc void @_ZNSt12experimental13coroutines_v116coroutine_handleIN4task12promise_typeEE12from_addressEPv(i8*) unnamed_addr #7 align 2 |
| 97 | + |
| 98 | +; Function Attrs: argmemonly nofree nosync nounwind willreturn |
| 99 | +declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #5 |
| 100 | + |
| 101 | +; Function Attrs: nounwind |
| 102 | +declare i8 @llvm.coro.suspend(token, i1) #2 |
| 103 | + |
| 104 | +; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress |
| 105 | +declare void @_ZN4task12promise_type13final_suspendEv(%promise_type* nonnull dereferenceable(1)) local_unnamed_addr #7 align 2 |
| 106 | + |
| 107 | +; Function Attrs: nounwind |
| 108 | +declare i1 @llvm.coro.end(i8*, i1) #2 |
| 109 | + |
| 110 | +; Function Attrs: nobuiltin nounwind |
| 111 | +declare void @_ZdlPv(i8*) local_unnamed_addr #8 |
| 112 | + |
| 113 | +; Function Attrs: argmemonly nounwind readonly |
| 114 | +declare i8* @llvm.coro.free(token, i8* nocapture readonly) #1 |
| 115 | + |
| 116 | +attributes #0 = { noinline ssp uwtable mustprogress "coroutine.presplit"="1" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" } |
| 117 | +attributes #1 = { argmemonly nounwind readonly } |
| 118 | +attributes #2 = { nounwind } |
| 119 | +attributes #3 = { nobuiltin nofree allocsize(0) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" } |
| 120 | +attributes #4 = { nounwind readnone } |
| 121 | +attributes #5 = { argmemonly nofree nosync nounwind willreturn } |
| 122 | +attributes #6 = { argmemonly nofree nounwind willreturn } |
| 123 | +attributes #7 = { noinline nounwind ssp uwtable willreturn mustprogress "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" } |
| 124 | +attributes #8 = { nobuiltin nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" } |
| 125 | +attributes #9 = { allocsize(0) } |
| 126 | +attributes #10 = { noduplicate } |
| 127 | + |
0 commit comments