54 lines · plain
1; RUN: llc -mtriple=aarch64-windows %s -o - | FileCheck %s2 3; This test verifies that functions requiring Windows CFI that have minimal4; or no prologue instructions still emit proper SEH directives, specifically5; ensuring .seh_endprologue is emitted before .seh_startepilogue.6;7; This reproduces the issue where Swift async functions with swifttailcc8; calling convention would fail with:9; "error: starting epilogue (.seh_startepilogue) before prologue has ended (.seh_endprologue)"10 11; Test 1: Swift-style tail call function with minimal prologue12define swifttailcc void @test_swifttailcc_minimal(ptr %async_ctx, ptr %arg1, ptr %arg2) {13; CHECK-LABEL: test_swifttailcc_minimal:14; CHECK-NOT: .seh_proc test_swifttailcc_minimal15; CHECK-NOT: .seh_endprologue16; CHECK-NOT: .seh_startepilogue17; CHECK-NOT: .seh_endepilogue18; CHECK-NOT: .seh_endproc19entry:20 %ptr1 = getelementptr inbounds i8, ptr %async_ctx, i64 1621 %ptr2 = getelementptr inbounds i8, ptr %async_ctx, i64 2422 store ptr %arg1, ptr %ptr1, align 823 store ptr %arg2, ptr %ptr2, align 824 musttail call swifttailcc void @external_swift_function(ptr %async_ctx, ptr %arg1)25 ret void26}27 28; Test 2: Function similar to the original failing case29define linkonce_odr hidden swifttailcc void @test_linkonce_swifttailcc(ptr swiftasync %async_ctx, ptr %arg1, ptr noalias dereferenceable(40) %arg2, ptr %arg3, i64 %value, ptr %arg4, ptr %arg5, ptr %arg6, i1 %flag, ptr %arg7, ptr noalias dereferenceable(40) %arg8) {30; CHECK-LABEL: test_linkonce_swifttailcc:31; CHECK-NEXT: .seh_proc32; CHECK: .seh_endprologue33; CHECK: .seh_startepilogue34; CHECK: .seh_endepilogue35; CHECK: .seh_endproc36entry:37 %frame_ptr = getelementptr inbounds nuw i8, ptr %async_ctx, i64 1638 %ctx1 = getelementptr inbounds nuw i8, ptr %async_ctx, i64 40039 %ctx2 = getelementptr inbounds nuw i8, ptr %async_ctx, i64 116840 %spill1 = getelementptr inbounds nuw i8, ptr %async_ctx, i64 239241 store ptr %arg8, ptr %spill1, align 842 %spill2 = getelementptr inbounds nuw i8, ptr %async_ctx, i64 238443 store ptr %arg7, ptr %spill2, align 844 %spill3 = getelementptr inbounds nuw i8, ptr %async_ctx, i64 222545 store i1 %flag, ptr %spill3, align 146 %spill4 = getelementptr inbounds nuw i8, ptr %async_ctx, i64 237647 store ptr %arg6, ptr %spill4, align 848 musttail call swifttailcc void @external_swift_continuation(ptr swiftasync %async_ctx, i64 0, i64 0)49 ret void50}51 52declare swifttailcc void @external_swift_function(ptr, ptr)53declare swifttailcc void @external_swift_continuation(ptr swiftasync, i64, i64)54