Skip to content

Commit 7c3b53e

Browse files
authored
Merge pull request #8219 from hjyamauchi/devin-1045-5-10
Fix an assert failure with a funclet in a swifttailcc function.
2 parents bd80ec6 + 8dde9a0 commit 7c3b53e

File tree

3 files changed

+131
-2
lines changed

3 files changed

+131
-2
lines changed

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,16 @@ static unsigned getFixedObjectSize(const MachineFunction &MF,
388388
if (!IsWin64 || IsFunclet) {
389389
return AFI->getTailCallReservedStack();
390390
} else {
391-
if (AFI->getTailCallReservedStack() != 0)
391+
if (AFI->getTailCallReservedStack() != 0 &&
392+
!MF.getFunction().getAttributes().hasAttrSomewhere(
393+
Attribute::SwiftAsync))
392394
report_fatal_error("cannot generate ABI-changing tail call for Win64");
393395
// Var args are stored here in the primary function.
394396
const unsigned VarArgsArea = AFI->getVarArgsGPRSize();
395397
// To support EH funclets we allocate an UnwindHelp object
396398
const unsigned UnwindHelpObject = (MF.hasEHFunclets() ? 8 : 0);
397-
return alignTo(VarArgsArea + UnwindHelpObject, 16);
399+
return AFI->getTailCallReservedStack() +
400+
alignTo(VarArgsArea + UnwindHelpObject, 16);
398401
}
399402
}
400403

llvm/lib/Target/AArch64/AArch64Subtarget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
312312
case CallingConv::C:
313313
case CallingConv::Fast:
314314
case CallingConv::Swift:
315+
case CallingConv::SwiftTail:
315316
return isTargetWindows();
316317
case CallingConv::Win64:
317318
return true;
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
; RUN: llc < %s -o - | FileCheck %s
2+
3+
; Check that no assert failure occurs when there's a funclet in a swifttailcc function.
4+
; CHECK-LABEL: foo:
5+
6+
target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
7+
target triple = "aarch64-unknown-windows-msvc19.38.33134"
8+
9+
declare ptr @F2()
10+
11+
declare void @F3(ptr)
12+
13+
declare i32 @__CxxFrameHandler3(...)
14+
15+
define swifttailcc void @foo(ptr swiftasync %0, ptr %v3, ptr %v4) personality ptr @__CxxFrameHandler3 !dbg !88 {
16+
v21:
17+
call void @F3(ptr %0)
18+
%v28 = invoke ptr @F2(ptr %v3, ptr %v4)
19+
to label %v29 unwind label %v39
20+
21+
v29: ; preds = %v21
22+
ret void
23+
24+
v39: ; preds = %v21
25+
%v40 = cleanuppad within none []
26+
%v43 = load i1, ptr null, align 1
27+
cleanupret from %v40 unwind to caller
28+
}
29+
30+
; This test is sensitive to the debug info
31+
32+
!llvm.dbg.cu = !{!0, !11}
33+
!llvm.module.flags = !{!87}
34+
35+
!0 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !1, producer: "Swift version 5.11-dev", isOptimized: true, flags: "-private-discriminator _0FA2C3DB08FF346F3CA00B2EC660E1DF -enable-experimental-cxx-interop", runtimeVersion: 5, emissionKind: FullDebug, globals: !2, imports: !10, sysroot: "S:\\Windows.sdk", sdk: "Windows.sdk")
36+
!1 = !DIFile(filename: "foo.swift", directory: "C:\\foo")
37+
!2 = !{!3}
38+
!3 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression())
39+
!4 = distinct !DIGlobalVariable(name: "mutationQueue", linkageName: "$sSo8fire", scope: !5, file: !1, line: 18, type: !6, isLocal: false, isDefinition: true)
40+
!5 = !DIModule(scope: null, name: "FF", includePath: "C:\\foo")
41+
!6 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !7)
42+
!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DispatchQueue", scope: !9, file: !8, size: 64, elements: !10, runtimeLang: DW_LANG_Swift, identifier: "$s8Dispatch0A5QueueCD")
43+
!8 = !DIFile(filename: "S:\\aarch64-unknown-windows-msvc.swiftmodule", directory: "")
44+
!9 = !DIModule(scope: null, name: "Dispatch", configMacros: "\22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "S:\\aarch64-unknown-windows-msvc.swiftmodule")
45+
!10 = !{}
46+
!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !12, producer: "clang version 17.0.6", isOptimized: true, flags: "-private-discriminator _0FA2C3DB08FF346F3CA00B2EC660E1DF -enable-experimental-cxx-interop", runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !10, globals: !13, splitDebugInlining: false, nameTableKind: None)
47+
!12 = !DIFile(filename: "<swift-imported-modules>", directory: "C:\\foo")
48+
!13 = !{!14, !20, !29, !36, !40, !43, !53, !55, !59, !62, !77}
49+
!14 = !DIGlobalVariableExpression(var: !15, expr: !DIExpression())
50+
!15 = distinct !DIGlobalVariable(scope: null, file: !16, line: 2314, type: !17, isLocal: true, isDefinition: true)
51+
!16 = !DIFile(filename: "C:\\xstring", directory: "")
52+
!17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 128, elements: !10)
53+
!18 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !19)
54+
!19 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
55+
!20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression())
56+
!21 = distinct !DIGlobalVariable(name: "_Fake_alloc", linkageName: "?_Fake_alloc@std@@3U_Fake_allocator@1@B", scope: !22, file: !26, line: 1491, type: !27, isLocal: true, isDefinition: true)
57+
!22 = !DINamespace(name: "std", scope: !23)
58+
!23 = !DIModule(scope: !24, name: "xmemory", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
59+
!24 = !DIModule(scope: !25, name: "_Private", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
60+
!25 = !DIModule(scope: null, name: "std", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
61+
!26 = !DIFile(filename: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\xmemory", directory: "")
62+
!27 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !28)
63+
!28 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_Fake_allocator", scope: !22, file: !26, line: 1169, size: 8, flags: DIFlagFwdDecl, identifier: ".?AU_Fake_allocator@std@@")
64+
!29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression(DW_OP_constu, 8, DW_OP_stack_value))
65+
!30 = distinct !DIGlobalVariable(name: "_Small_object_num_ptrs", scope: !31, file: !33, line: 28, type: !34, isLocal: true, isDefinition: true)
66+
!31 = !DINamespace(name: "std", scope: !32)
67+
!32 = !DIModule(scope: !25, name: "typeinfo", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
68+
!33 = !DIFile(filename: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\typeinfo", directory: "")
69+
!34 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !35)
70+
!35 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
71+
!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression())
72+
!37 = distinct !DIGlobalVariable(scope: null, file: !38, line: 140, type: !39, isLocal: true, isDefinition: true)
73+
!38 = !DIFile(filename: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\vcruntime_exception.h", directory: "")
74+
!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 168, elements: !10)
75+
!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression())
76+
!41 = distinct !DIGlobalVariable(scope: null, file: !38, line: 95, type: !42, isLocal: true, isDefinition: true)
77+
!42 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 144, elements: !10)
78+
!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression(DW_OP_constu, 14695981039346656037, DW_OP_stack_value))
79+
!44 = distinct !DIGlobalVariable(name: "_FNV_offset_basis", scope: !45, file: !47, line: 2312, type: !48, isLocal: true, isDefinition: true)
80+
!45 = !DINamespace(name: "std", scope: !46)
81+
!46 = !DIModule(scope: !25, name: "type_traits", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
82+
!47 = !DIFile(filename: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\type_traits", directory: "")
83+
!48 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !49)
84+
!49 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", scope: !51, file: !50, line: 193, baseType: !52)
85+
!50 = !DIFile(filename: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\vcruntime.h", directory: "")
86+
!51 = !DIModule(scope: null, name: "vcruntime", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
87+
!52 = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned)
88+
!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression(DW_OP_constu, 1099511628211, DW_OP_stack_value))
89+
!54 = distinct !DIGlobalVariable(name: "_FNV_prime", scope: !45, file: !47, line: 2313, type: !48, isLocal: true, isDefinition: true)
90+
!55 = !DIGlobalVariableExpression(var: !56, expr: !DIExpression())
91+
!56 = distinct !DIGlobalVariable(scope: null, file: !57, line: 1645, type: !58, isLocal: true, isDefinition: true)
92+
!57 = !DIFile(filename: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\xhash", directory: "")
93+
!58 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 216, elements: !10)
94+
!59 = !DIGlobalVariableExpression(var: !60, expr: !DIExpression())
95+
!60 = distinct !DIGlobalVariable(scope: null, file: !57, line: 1715, type: !61, isLocal: true, isDefinition: true)
96+
!61 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 208, elements: !10)
97+
!62 = !DIGlobalVariableExpression(var: !63, expr: !DIExpression())
98+
!63 = distinct !DIGlobalVariable(name: "_Min_buckets", linkageName: "_Min_buckets", scope: !64, file: !57, line: 365, type: !65, isLocal: false, isDefinition: true, declaration: !76)
99+
!64 = !DIModule(scope: !24, name: "xhash", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
100+
!65 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !66)
101+
!66 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_type", scope: !67, file: !57, line: 347, baseType: !69, flags: DIFlagPublic)
102+
!67 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "_Hash", scope: !68, file: !57, line: 330, size: 512, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !10, templateParams: !10, identifier: ".?AV?")
103+
!68 = !DINamespace(name: "std", scope: !64)
104+
!69 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_type", scope: !71, file: !70, line: 783, baseType: !74, flags: DIFlagPublic)
105+
!70 = !DIFile(filename: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include\\list", directory: "")
106+
!71 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "list", scope: !72, file: !70, line: 755, size: 128, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !10, templateParams: !10, identifier: ".?AV?")
107+
!72 = !DINamespace(name: "std", scope: !73)
108+
!73 = !DIModule(scope: !25, name: "list", configMacros: "\22-D__swift__=51100\22 \22-D_ARM64_\22 \22-DINTERNAL_EXPERIMENTAL\22 \22-DSR69711\22", includePath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\include")
109+
!74 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_type", scope: !75, file: !26, line: 656, baseType: !49)
110+
!75 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_Default", scope: !22, file: !26, line: 647, size: 8, flags: DIFlagTypePassByValue, elements: !10, templateParams: !10, identifier: ".?AU?")
111+
!76 = !DIDerivedType(tag: DW_TAG_member, name: "_Min_buckets", scope: !67, file: !57, line: 365, baseType: !65, flags: DIFlagPublic | DIFlagStaticMember, extraData: i64 8)
112+
!77 = !DIGlobalVariableExpression(var: !78, expr: !DIExpression())
113+
!78 = distinct !DIGlobalVariable(name: "_Min_buckets", linkageName: "_Min_buckets", scope: !64, file: !57, line: 365, type: !79, isLocal: false, isDefinition: true, declaration: !86)
114+
!79 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !80)
115+
!80 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_type", scope: !81, file: !57, line: 347, baseType: !82, flags: DIFlagPublic)
116+
!81 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "_Hash", scope: !68, file: !57, line: 330, size: 512, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !10, templateParams: !10, identifier: ".?AV?")
117+
!82 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_type", scope: !83, file: !70, line: 783, baseType: !84, flags: DIFlagPublic)
118+
!83 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "list", scope: !72, file: !70, line: 755, size: 128, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !10, templateParams: !10, identifier: ".?AV?")
119+
!84 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_type", scope: !85, file: !26, line: 656, baseType: !49)
120+
!85 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_Default_allocator_traits", scope: !22, file: !26, line: 647, size: 8, flags: DIFlagTypePassByValue, elements: !10, templateParams: !10, identifier: ".?AU?")
121+
!86 = !DIDerivedType(tag: DW_TAG_member, name: "_Min_buckets", scope: !81, file: !57, line: 365, baseType: !79, flags: DIFlagPublic | DIFlagStaticMember, extraData: i64 8)
122+
!87 = !{i32 2, !"Debug Info Version", i32 3}
123+
!88 = distinct !DISubprogram(name: "get", linkageName: "foo", scope: !5, file: !1, line: 32, type: !89, scopeLine: 32, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !90, retainedNodes: !10, thrownTypes: !10)
124+
!89 = !DISubroutineType(types: !10)
125+
!90 = !DISubprogram(name: "get", linkageName: "foo", scope: !5, file: !1, line: 32, type: !89, scopeLine: 32, spFlags: DISPFlagOptimized, thrownTypes: !10)

0 commit comments

Comments
 (0)