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 { void (%"bar.Frame"*)*, void (%"bar.Frame"*)*, %"struct.coroutine<false, int>::promise_type", i1 }
9 %"struct.coroutine<false, int>::promise_type" = type { i32 }
10 %"foo.Frame" = type { void (%"foo.Frame"*)*, void (%"foo.Frame"*)*, %"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 void (%"bar.Frame"*)*] [void (%"bar.Frame"*)* @"bar.resume", void (%"bar.Frame"*)* undef, void (%"bar.Frame"*)* undef]
15 declare dso_local void @"bar"() align 2
16 declare dso_local fastcc void @"bar.resume"(%"bar.Frame"*) 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(%"foo.Frame"* %FramePtr) {
22 ; CHECK-LABEL: @foo.resume_musttail(
24 ; CHECK-NEXT: [[TMP0:%.*]] = alloca [24 x i8], align 8
25 ; CHECK-NEXT: [[VFRAME:%.*]] = bitcast [24 x i8]* [[TMP0]] to i8*
26 ; CHECK-NEXT: [[TMP1:%.*]] = tail call token @llvm.coro.id(i32 16, i8* null, i8* bitcast (void ()* @bar to i8*), i8* bitcast ([3 x void (%bar.Frame*)*]* @bar.resumers to i8*))
27 ; CHECK-NEXT: [[CALL34:%.*]] = call i8* undef()
28 ; CHECK-NEXT: musttail call fastcc void undef(i8* [[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 [24 x i8]* [[TMP0]] to i8*
35 ; NOAA-NEXT: [[TMP1:%.*]] = call token @llvm.coro.id(i32 16, i8* null, i8* bitcast (void ()* @bar to i8*), i8* bitcast ([3 x void (%bar.Frame*)*]* @bar.resumers to i8*))
36 ; NOAA-NEXT: [[CALL34:%.*]] = call i8* undef()
37 ; NOAA-NEXT: musttail call fastcc void undef(i8* [[CALL34]])
41 %0 = tail call token @llvm.coro.id(i32 16, i8* null, i8* bitcast (void ()* @"bar" to i8*), i8* bitcast ([3 x void (%"bar.Frame"*)*]* @"bar.resumers" to i8*))
42 %1 = tail call i1 @llvm.coro.alloc(token %0)
43 %2 = tail call i8* @llvm.coro.begin(token %0, i8* null)
44 call i8* @llvm.coro.subfn.addr(i8* %2, i8 1)
45 %call34 = call i8* undef()
46 musttail call fastcc void undef(i8* %call34)
50 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
51 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #0
53 ; Function Attrs: argmemonly nounwind readonly
54 declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1
56 ; Function Attrs: nounwind
57 declare i1 @llvm.coro.alloc(token) #2
59 ; Function Attrs: nounwind
60 declare i8* @llvm.coro.begin(token, i8* writeonly) #2
62 ; Function Attrs: argmemonly nounwind readonly
63 declare i8* @llvm.coro.subfn.addr(i8* nocapture readonly, i8) #1
65 attributes #0 = { argmemonly nofree nosync nounwind willreturn }
66 attributes #1 = { argmemonly nounwind readonly }
67 attributes #2 = { nounwind }