127 lines · plain
1; RUN: opt < %s -passes='asan,coro-early' -S2;3; Regression test to see if ASan breaks the @llvm.coro.id intrinsic4; (see commit bee2654300a8f524e05dd4cad41411d597246ac0)5;6; Forked from llvm/test/Transforms/Coroutines/coro-byval-param.ll7 8%promise_type = type { i8 }9%struct.A = type <{ i64, i64, i32, [4 x i8] }>10 11; Function Attrs: noinline ssp uwtable mustprogress12define ptr @foo(ptr nocapture readonly byval(%struct.A) align 8 %a1) #0 {13entry:14 %__promise = alloca %promise_type, align 115 %a2 = alloca %struct.A, align 816 %0 = call token @llvm.coro.id(i32 16, ptr nonnull %__promise, ptr @foo, ptr null)17 %1 = call i1 @llvm.coro.alloc(token %0)18 br i1 %1, label %coro.alloc, label %coro.init19 20coro.alloc: ; preds = %entry21 %2 = call i64 @llvm.coro.size.i64()22 %call = call noalias nonnull ptr @_Znwm(i64 %2) #923 br label %coro.init24 25coro.init: ; preds = %coro.alloc, %entry26 %3 = phi ptr [ null, %entry ], [ %call, %coro.alloc ]27 %4 = call ptr @llvm.coro.begin(token %0, ptr %3) #1028 call void @llvm.lifetime.start.p0(ptr nonnull %__promise) #229 %call2 = call ptr @_ZN4task12promise_type17get_return_objectEv(ptr nonnull dereferenceable(1) %__promise)30 call void @initial_suspend(ptr nonnull dereferenceable(1) %__promise)31 %5 = call token @llvm.coro.save(ptr null)32 call fastcc void @_ZNSt12experimental13coroutines_v116coroutine_handleIN4task12promise_typeEE12from_addressEPv(ptr %4) #233 %6 = call i8 @llvm.coro.suspend(token %5, i1 false)34 switch i8 %6, label %coro.ret [35 i8 0, label %init.ready36 i8 1, label %cleanup3337 ]38 39init.ready: ; preds = %coro.init40 call void @llvm.lifetime.start.p0(ptr nonnull %a2) #241 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %a2, ptr align 8 %a1, i64 24, i1 false)42 call void @llvm.lifetime.end.p0(ptr nonnull %a2) #243 call void @_ZN4task12promise_type13final_suspendEv(ptr nonnull dereferenceable(1) %__promise) #244 %7 = call token @llvm.coro.save(ptr null)45 call fastcc void @_ZNSt12experimental13coroutines_v116coroutine_handleIN4task12promise_typeEE12from_addressEPv(ptr %4) #246 %8 = call i8 @llvm.coro.suspend(token %7, i1 true) #1047 %switch = icmp ult i8 %8, 248 br i1 %switch, label %cleanup33, label %coro.ret49 50cleanup33: ; preds = %init.ready, %coro.init51 call void @llvm.lifetime.end.p0(ptr nonnull %__promise) #252 %9 = call ptr @llvm.coro.free(token %0, ptr %4)53 %.not = icmp eq ptr %9, null54 br i1 %.not, label %coro.ret, label %coro.free55 56coro.free: ; preds = %cleanup3357 call void @_ZdlPv(ptr nonnull %9) #258 br label %coro.ret59 60coro.ret: ; preds = %coro.free, %cleanup33, %init.ready, %coro.init61 call void @llvm.coro.end(ptr null, i1 false, token none) #1062 ret ptr %call263}64 65; Function Attrs: argmemonly nounwind readonly66declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #167 68; Function Attrs: nounwind69declare i1 @llvm.coro.alloc(token) #270 71; Function Attrs: nobuiltin nofree allocsize(0)72declare nonnull ptr @_Znwm(i64) local_unnamed_addr #373 74; Function Attrs: nounwind readnone75declare i64 @llvm.coro.size.i64() #476 77; Function Attrs: nounwind78declare ptr @llvm.coro.begin(token, ptr writeonly) #279 80; Function Attrs: argmemonly nofree nosync nounwind willreturn81declare void @llvm.lifetime.start.p0(ptr nocapture) #582 83; Function Attrs: argmemonly nofree nounwind willreturn84declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #685 86; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress87declare ptr @_ZN4task12promise_type17get_return_objectEv(ptr nonnull dereferenceable(1)) local_unnamed_addr #7 align 288 89; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress90declare void @initial_suspend(ptr nonnull dereferenceable(1)) local_unnamed_addr #7 align 291 92; Function Attrs: nounwind93declare token @llvm.coro.save(ptr) #294 95; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress96declare hidden fastcc void @_ZNSt12experimental13coroutines_v116coroutine_handleIN4task12promise_typeEE12from_addressEPv(ptr) unnamed_addr #7 align 297 98; Function Attrs: argmemonly nofree nosync nounwind willreturn99declare void @llvm.lifetime.end.p0(ptr nocapture) #5100 101; Function Attrs: nounwind102declare i8 @llvm.coro.suspend(token, i1) #2103 104; Function Attrs: noinline nounwind ssp uwtable willreturn mustprogress105declare void @_ZN4task12promise_type13final_suspendEv(ptr nonnull dereferenceable(1)) local_unnamed_addr #7 align 2106 107; Function Attrs: nounwind108declare void @llvm.coro.end(ptr, i1, token) #2109 110; Function Attrs: nobuiltin nounwind111declare void @_ZdlPv(ptr) local_unnamed_addr #8112 113; Function Attrs: argmemonly nounwind readonly114declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1115 116attributes #0 = { noinline ssp uwtable mustprogress presplitcoroutine sanitize_address "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" }117attributes #1 = { argmemonly nounwind readonly }118attributes #2 = { nounwind }119attributes #3 = { nobuiltin nofree allocsize(0) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" }120attributes #4 = { nounwind readnone }121attributes #5 = { argmemonly nofree nosync nounwind willreturn }122attributes #6 = { argmemonly nofree nounwind willreturn }123attributes #7 = { noinline nounwind ssp uwtable willreturn mustprogress "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" }124attributes #8 = { nobuiltin nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" }125attributes #9 = { allocsize(0) }126attributes #10 = { noduplicate }127