Skip to content

Commit 16f27d6

Browse files
committed
[IRGen][Test] Use the new availability support.
We need to only generate references to `_swift_exceptionPersonality` if we're building for a new enough runtime. The previous code was good on Darwin, but would have resulted in build problems on Linux. rdar://120952971
1 parent faff453 commit 16f27d6

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

include/swift/AST/FeatureAvailability.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ FEATURE(SignedDescriptor, (5, 9))
5959
FEATURE(ObjCSymbolicReferences, (5, 11))
6060
FEATURE(TypedThrows, (5, 11))
6161
FEATURE(StaticReadOnlyArrays, (5, 11))
62+
FEATURE(SwiftExceptionPersonality, (5, 11))
6263

6364
FEATURE(TaskExecutor, FUTURE)
6465
FEATURE(Differentiation, FUTURE)

lib/IRGen/GenCall.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4997,11 +4997,9 @@ void IRGenFunction::emitEpilogue() {
49974997

49984998
auto deploymentAvailability =
49994999
AvailabilityContext::forDeploymentTarget(IGM.Context);
5000-
bool canUseSwiftPersonality = deploymentAvailability.isContainedIn(
5001-
IGM.Context.getSwift511Availability());
50025000
llvm::Constant *personality;
50035001

5004-
if (canUseSwiftPersonality) {
5002+
if (IGM.isSwiftExceptionPersonalityFeatureAvailable()) {
50055003
// The function should use our personality routine
50065004
auto swiftPersonality = IGM.getExceptionPersonalityFunctionPointer();
50075005
personality = swiftPersonality.getDirectPointer();

test/Interop/Cxx/exceptions/objc-trap-on-exception-irgen-itanium.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %s %t
33

4-
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
4+
// RUN: %target-swift-emit-ir -target %target-future-triple -min-runtime-version 5.11 %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
5+
// RUN: %target-swift-emit-ir -target %target-triple -min-runtime-version 5.9 %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s --check-prefix=GXX
56

67
// REQUIRES: objc_interop
78
// UNSUPPORTED: OS=windows-msvc
@@ -45,3 +46,17 @@ testObjCMethodCall()
4546
// CHECK-NEXT: call void @llvm.trap()
4647
// CHECK-NEXT: unreachable
4748
// CHECK-NEXT: }
49+
50+
// GXX: define {{.*}} @"$s4test0A14ObjCMethodCallyyF"() #[[#UWATTR:]] personality ptr @__gxx_personality_v0
51+
// GXX: invoke void {{.*}}@objc_msgSend
52+
// GXX-NEXT: to label %[[CONT1:.*]] unwind label %[[UNWIND1:.*]]
53+
// GXX-EMPTY:
54+
// GXX-NEXT: [[CONT1]]:
55+
// GXX: ret
56+
// GXX-EMPTY:
57+
// GXX-NEXT: [[UNWIND1]]:
58+
// GXX-NEXT: landingpad { ptr, i32 }
59+
// GXX-NEXT: catch ptr null
60+
// GXX-NEXT: call void @llvm.trap()
61+
// GXX-NEXT: unreachable
62+
// GXX-NEXT: }

test/Interop/Cxx/exceptions/trap-on-exception-irgen-itanium.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %s %t
33

4-
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
5-
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -g | %FileCheck --check-prefix=DEBUG %s
4+
// RUN: %target-swift-emit-ir -target %target-future-triple -min-runtime-version 5.11 %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
5+
// RUN: %target-swift-emit-ir -target %target-future-triple -min-runtime-version 5.11 %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -g | %FileCheck --check-prefix=DEBUG %s
6+
// RUN: %target-swift-emit-ir -target %target-triple -min-runtime-version 5.9 %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck --check-prefix=GXX %s
7+
// RUN: %target-swift-emit-ir -target %target-triple -min-runtime-version 5.9 %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -g | %FileCheck --check-prefix=GXX %s
68

79
// UNSUPPORTED: OS=windows-msvc
810

@@ -335,7 +337,7 @@ public func test() {
335337
// CHECK-NEXT: unreachable
336338
// CHECK-NEXT: }
337339

338-
// CHECK: i32 @_swift_exceptionPersonality(...)
340+
// CHECK: i32 @_swift_exceptionPersonality(i32, i32, i64, ptr, ptr)
339341

340342
// CHECK: define {{.*}} @"$s4test0A11MethodCallss5Int32VyF"() #[[#SWIFTUWMETA]] personality
341343
// CHECK: call swiftcc i32 @"$s4test8makeCInts5Int32VyF"()
@@ -502,3 +504,6 @@ public func test() {
502504
// DEBUG: ![[#DEBUGLOC_TRAP1]] = !DILocation(line: 0, scope: ![[#TRAPSCOPE:]], inlinedAt: ![[#DEBUGLOC_FREEFUNCTIONTHROWS1]])
503505
// DEBUG: ![[#TRAPSCOPE]] = distinct !DISubprogram(name: "Swift runtime failure: unhandled C++{{ / Objective-C | }}exception"
504506
// DEBUG: ![[#DEBUGLOC_TRAP2]] = !DILocation(line: 0, scope: ![[#TRAPSCOPE]], inlinedAt: ![[#DEBUGLOC_FREEFUNCTIONTHROWS2]])
507+
508+
// GXX: __gxx_personality_v0
509+
// GXX-NOT: _swift_exceptionPersonality

0 commit comments

Comments
 (0)