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
5 declare void @fakeresume1(i64* align 8)
9 %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
10 %alloc = call i8* @malloc(i64 16) #3
11 %alloc.var = alloca i8
12 call void @llvm.lifetime.start.p0i8(i64 1, i8* %alloc.var)
13 %vFrame = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %alloc)
15 %save = call token @llvm.coro.save(i8* null)
16 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
18 switch i8 %suspend, label %exit [
19 i8 0, label %await.suspend
23 %save2 = call token @llvm.coro.save(i8* null)
24 call fastcc void @fakeresume1(i64* align 8 null)
25 %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
26 switch i8 %suspend2, label %exit [
27 i8 0, label %await.ready
31 call void @consume(i8* %alloc.var)
32 call void @llvm.lifetime.end.p0i8(i64 1, i8* %alloc.var)
35 call i1 @llvm.coro.end(i8* null, i1 false)
39 ; Verify that in the resume part resume call is marked with musttail.
40 ; CHECK-LABEL: @g.resume(
41 ; CHECK: musttail call fastcc void @fakeresume1(i64* align 8 null)
42 ; CHECK-NEXT: ret void
44 declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1
45 declare i1 @llvm.coro.alloc(token) #2
46 declare i64 @llvm.coro.size.i64() #3
47 declare i8* @llvm.coro.begin(token, i8* writeonly) #2
48 declare token @llvm.coro.save(i8*) #2
49 declare i8* @llvm.coro.frame() #3
50 declare i8 @llvm.coro.suspend(token, i1) #2
51 declare i8* @llvm.coro.free(token, i8* nocapture readonly) #1
52 declare i1 @llvm.coro.end(i8*, i1) #2
53 declare i8* @llvm.coro.subfn.addr(i8* nocapture readonly, i8) #1
54 declare i8* @malloc(i64)
55 declare void @consume(i8*)
56 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
57 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
59 attributes #0 = { "coroutine.presplit"="1" }
60 attributes #1 = { argmemonly nounwind readonly }
61 attributes #2 = { nounwind }
62 attributes #3 = { nounwind readnone }