1 ; Tests that sinked lifetime markers wouldn't provent optimization
2 ; to convert a resuming call to a musttail call.
3 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 ; RUN: opt < %s -passes='pgo-instr-gen,cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
6 declare void @fakeresume1(ptr align 8)
10 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
11 %alloc = call ptr @malloc(i64 16) #3
12 %alloc.var = alloca i8
13 call void @llvm.lifetime.start.p0(i64 1, ptr %alloc.var)
14 %vFrame = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %alloc)
16 %save = call token @llvm.coro.save(ptr null)
17 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
19 switch i8 %suspend, label %exit [
20 i8 0, label %await.suspend
24 %save2 = call token @llvm.coro.save(ptr null)
25 call fastcc void @fakeresume1(ptr align 8 null)
26 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
27 switch i8 %suspend2, label %exit [
28 i8 0, label %await.ready
32 call void @consume(ptr %alloc.var)
33 call void @llvm.lifetime.end.p0(i64 1, ptr %alloc.var)
36 call i1 @llvm.coro.end(ptr null, i1 false, token none)
40 ; Verify that in the resume part resume call is marked with musttail.
41 ; CHECK-LABEL: @g.resume(
42 ; CHECK: musttail call fastcc void @fakeresume1(ptr align 8 null)
43 ; CHECK-NEXT: ret void
45 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
46 declare i1 @llvm.coro.alloc(token) #2
47 declare i64 @llvm.coro.size.i64() #3
48 declare ptr @llvm.coro.begin(token, ptr writeonly) #2
49 declare token @llvm.coro.save(ptr) #2
50 declare ptr @llvm.coro.frame() #3
51 declare i8 @llvm.coro.suspend(token, i1) #2
52 declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1
53 declare i1 @llvm.coro.end(ptr, i1, token) #2
54 declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1
55 declare ptr @malloc(i64)
56 declare void @consume(ptr)
57 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
58 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
60 attributes #0 = { presplitcoroutine }
61 attributes #1 = { argmemonly nounwind readonly }
62 attributes #2 = { nounwind }
63 attributes #3 = { nounwind readnone }