1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; Only run with new pass manager since old pass manager's alias analysis isn't
3 ; powerful enough to tell that the tailcall's arguments don't alias the frame.
5 ; RUN: opt < %s -passes='coro-elide' -S | FileCheck %s
6 ; RUN: opt < %s -aa-pipeline= -passes='coro-elide' -S | FileCheck %s -check-prefix=NOAA
8 %"bar.Frame" = type { ptr, ptr, %"struct.coroutine<false, int>::promise_type", i1 }
9 %"struct.coroutine<false, int>::promise_type" = type { i32 }
10 %"foo.Frame" = type { ptr, ptr, %"struct.coroutine<true, int>::promise_type", i1, %"struct.coroutine<true, int>::promise_type::final_awaitable" }
11 %"struct.coroutine<true, int>::promise_type" = type { i32 }
12 %"struct.coroutine<true, int>::promise_type::final_awaitable" = type { i8 }
13 @"bar.resumers" = private constant [3 x ptr] [ptr @"bar.resume", ptr undef, ptr undef]
15 declare dso_local void @"bar"() align 2
16 declare dso_local fastcc void @"bar.resume"(ptr align 8 dereferenceable(24)) align 2
18 ; There is a musttail call.
19 ; With alias analysis, we can tell that the frame does not interfere with CALL34, and hence we can keep the tailcalls.
20 ; Without alias analysis, we have to keep the tailcalls.
21 define internal fastcc void @foo.resume_musttail(ptr %FramePtr) {
22 ; CHECK-LABEL: @foo.resume_musttail(
24 ; CHECK-NEXT: [[TMP0:%.*]] = alloca [24 x i8], align 8
25 ; CHECK-NEXT: [[VFRAME:%.*]] = bitcast ptr [[TMP0]] to ptr
26 ; CHECK-NEXT: [[TMP1:%.*]] = tail call token @llvm.coro.id(i32 16, ptr null, ptr @bar, ptr @bar.resumers)
27 ; CHECK-NEXT: [[CALL34:%.*]] = call ptr undef()
28 ; CHECK-NEXT: musttail call fastcc void undef(ptr [[CALL34]])
29 ; CHECK-NEXT: ret void
31 ; NOAA-LABEL: @foo.resume_musttail(
33 ; NOAA-NEXT: [[TMP0:%.*]] = alloca [24 x i8], align 8
34 ; NOAA-NEXT: [[VFRAME:%.*]] = bitcast ptr [[TMP0]] to ptr
35 ; NOAA-NEXT: [[TMP1:%.*]] = call token @llvm.coro.id(i32 16, ptr null, ptr @bar, ptr @bar.resumers)
36 ; NOAA-NEXT: [[CALL34:%.*]] = call ptr undef()
37 ; NOAA-NEXT: musttail call fastcc void undef(ptr [[CALL34]])
41 %0 = tail call token @llvm.coro.id(i32 16, ptr null, ptr @"bar", ptr @"bar.resumers")
42 %1 = tail call i1 @llvm.coro.alloc(token %0)
43 %2 = tail call ptr @llvm.coro.begin(token %0, ptr null)
44 call ptr @llvm.coro.subfn.addr(ptr %2, i8 1)
45 %call34 = call ptr undef()
46 musttail call fastcc void undef(ptr %call34)
50 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
51 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0
53 ; Function Attrs: argmemonly nounwind readonly
54 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1
56 ; Function Attrs: nounwind
57 declare i1 @llvm.coro.alloc(token) #2
59 ; Function Attrs: nounwind
60 declare ptr @llvm.coro.begin(token, ptr writeonly) #2
62 ; Function Attrs: argmemonly nounwind readonly
63 declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #1
65 attributes #0 = { argmemonly nofree nosync nounwind willreturn }
66 attributes #1 = { argmemonly nounwind readonly }
67 attributes #2 = { nounwind }