68 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; Only run with new pass manager since old pass manager's alias analysis isn't3; powerful enough to tell that the tailcall's arguments don't alias the frame.4;5; RUN: opt < %s -passes='coro-elide' -S | FileCheck %s6; RUN: opt < %s -aa-pipeline= -passes='coro-elide' -S | FileCheck %s -check-prefix=NOAA7 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]14 15declare dso_local void @"bar"() align 216declare dso_local fastcc void @"bar.resume"(ptr align 8 dereferenceable(24)) align 217 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.21define internal fastcc void @foo.resume_musttail(ptr %FramePtr) {22; CHECK-LABEL: @foo.resume_musttail(23; CHECK-NEXT: entry:24; CHECK-NEXT: [[TMP0:%.*]] = alloca [24 x i8], align 825; CHECK-NEXT: [[VFRAME:%.*]] = bitcast ptr [[TMP0]] to ptr26; 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 void30;31; NOAA-LABEL: @foo.resume_musttail(32; NOAA-NEXT: entry:33; NOAA-NEXT: [[TMP0:%.*]] = alloca [24 x i8], align 834; NOAA-NEXT: [[VFRAME:%.*]] = bitcast ptr [[TMP0]] to ptr35; 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]])38; NOAA-NEXT: ret void39;40entry: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)47 ret void48}49 50; Function Attrs: argmemonly nofree nosync nounwind willreturn51declare void @llvm.lifetime.start.p0(ptr nocapture) #052 53; Function Attrs: argmemonly nounwind readonly54declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #155 56; Function Attrs: nounwind57declare i1 @llvm.coro.alloc(token) #258 59; Function Attrs: nounwind60declare ptr @llvm.coro.begin(token, ptr writeonly) #261 62; Function Attrs: argmemonly nounwind readonly63declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #164 65attributes #0 = { argmemonly nofree nosync nounwind willreturn }66attributes #1 = { argmemonly nounwind readonly }67attributes #2 = { nounwind }68