Skip to content

Revert "[Runtime][IRGen] Trap C++ exceptions on *throw*, not catch." #71679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/swift/AST/FeatureAvailability.def
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ FEATURE(SignedDescriptor, (5, 9))
FEATURE(ObjCSymbolicReferences, (5, 11))
FEATURE(TypedThrows, (5, 11))
FEATURE(StaticReadOnlyArrays, (5, 11))
FEATURE(SwiftExceptionPersonality, (5, 11))

FEATURE(TaskExecutor, FUTURE)
FEATURE(Differentiation, FUTURE)
Expand Down
42 changes: 0 additions & 42 deletions include/swift/Runtime/Exception.h

This file was deleted.

18 changes: 0 additions & 18 deletions include/swift/Runtime/RuntimeFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -2807,24 +2807,6 @@ FUNCTION(InitRawStructMetadata,
EFFECT(MetaData),
UNKNOWN_MEMEFFECTS)

// _Unwind_Reason_Code _swift_exceptionPersonality(int version,
// _Unwind_Action actions,
// uint64 exceptionClass,
// struct _Unwind_Exception *exceptionObject,
// struct _Unwind_Context *context);
FUNCTION(ExceptionPersonality,
_swift_exceptionPersonality,
C_CC, AlwaysAvailable,
RETURNS(Int32Ty),
ARGS(Int32Ty,
Int32Ty,
Int64Ty,
Int8PtrTy,
Int8PtrTy),
ATTRS(NoUnwind),
EFFECT(NoEffect),
UNKNOWN_MEMEFFECTS)

#undef RETURNS
#undef ARGS
#undef ATTRS
Expand Down
13 changes: 1 addition & 12 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4994,18 +4994,7 @@ void IRGenFunction::emitEpilogue() {
// The function should have an unwind table when catching exceptions.
CurFn->addFnAttr(llvm::Attribute::getWithUWTableKind(
*IGM.LLVMContext, llvm::UWTableKind::Default));

llvm::Constant *personality;

if (IGM.isSwiftExceptionPersonalityFeatureAvailable()) {
// The function should use our personality routine
auto swiftPersonality = IGM.getExceptionPersonalityFunctionPointer();
personality = swiftPersonality.getDirectPointer();
} else {
personality = IGM.getForeignExceptionHandlingPersonalityFunc();
}

CurFn->setPersonalityFn(personality);
CurFn->setPersonalityFn(IGM.getForeignExceptionHandlingPersonalityFunc());
}
for (auto *bb : ExceptionUnwindBlocks)
CurFn->insert(CurFn->end(), bb);
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ set(swift_runtime_sources
ErrorObjectNative.cpp
Errors.cpp
ErrorDefaultImpls.cpp
Exception.cpp
Exclusivity.cpp
ExistentialContainer.cpp
Float16Support.cpp
Expand Down
51 changes: 0 additions & 51 deletions stdlib/public/runtime/Exception.cpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// 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
// 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
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s

// REQUIRES: objc_interop
// UNSUPPORTED: OS=windows-msvc
Expand Down Expand Up @@ -33,7 +32,7 @@ func testObjCMethodCall() {

testObjCMethodCall()

// CHECK: define {{.*}} @"$s4test0A14ObjCMethodCallyyF"() #[[#UWATTR:]] personality ptr @_swift_exceptionPersonality
// CHECK: define {{.*}} @"$s4test0A14ObjCMethodCallyyF"() #[[#UWATTR:]] personality
// CHECK: invoke void {{.*}}@objc_msgSend
// CHECK-NEXT: to label %[[CONT1:.*]] unwind label %[[UNWIND1:.*]]
// CHECK-EMPTY:
Expand All @@ -46,17 +45,3 @@ testObjCMethodCall()
// CHECK-NEXT: call void @llvm.trap()
// CHECK-NEXT: unreachable
// CHECK-NEXT: }

// GXX: define {{.*}} @"$s4test0A14ObjCMethodCallyyF"() #[[#UWATTR:]] personality ptr @__gxx_personality_v0
// GXX: invoke void {{.*}}@objc_msgSend
// GXX-NEXT: to label %[[CONT1:.*]] unwind label %[[UNWIND1:.*]]
// GXX-EMPTY:
// GXX-NEXT: [[CONT1]]:
// GXX: ret
// GXX-EMPTY:
// GXX-NEXT: [[UNWIND1]]:
// GXX-NEXT: landingpad { ptr, i32 }
// GXX-NEXT: catch ptr null
// GXX-NEXT: call void @llvm.trap()
// GXX-NEXT: unreachable
// GXX-NEXT: }
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// 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
// 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
// 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
// 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
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -g | %FileCheck --check-prefix=DEBUG %s

// UNSUPPORTED: OS=windows-msvc

Expand Down Expand Up @@ -311,7 +309,7 @@ public func test() {
// CHECK-NEXT: ret i32
// CHECK-NEXT: }

// CHECK: define {{.*}} @"$s4test0A17FreeFunctionCallss5Int32VyF"() #[[#SWIFTUWMETA:]] personality ptr @_swift_exceptionPersonality
// CHECK: define {{.*}} @"$s4test0A17FreeFunctionCallss5Int32VyF"() #[[#SWIFTUWMETA:]] personality ptr @__gxx_personality_v0
// CHECK: invoke i32 @_Z18freeFunctionThrowsi(i32 0)
// CHECK-NEXT: to label %[[CONT1:.*]] unwind label %[[UNWIND1:.*]]
// CHECK-EMPTY:
Expand All @@ -337,7 +335,7 @@ public func test() {
// CHECK-NEXT: unreachable
// CHECK-NEXT: }

// CHECK: i32 @_swift_exceptionPersonality(i32, i32, i64, ptr, ptr)
// CHECK: i32 @__gxx_personality_v0(...)

// CHECK: define {{.*}} @"$s4test0A11MethodCallss5Int32VyF"() #[[#SWIFTUWMETA]] personality
// CHECK: call swiftcc i32 @"$s4test8makeCInts5Int32VyF"()
Expand Down Expand Up @@ -504,6 +502,3 @@ public func test() {
// DEBUG: ![[#DEBUGLOC_TRAP1]] = !DILocation(line: 0, scope: ![[#TRAPSCOPE:]], inlinedAt: ![[#DEBUGLOC_FREEFUNCTIONTHROWS1]])
// DEBUG: ![[#TRAPSCOPE]] = distinct !DISubprogram(name: "Swift runtime failure: unhandled C++{{ / Objective-C | }}exception"
// DEBUG: ![[#DEBUGLOC_TRAP2]] = !DILocation(line: 0, scope: ![[#TRAPSCOPE]], inlinedAt: ![[#DEBUGLOC_FREEFUNCTIONTHROWS2]])

// GXX: __gxx_personality_v0
// GXX-NOT: _swift_exceptionPersonality
1 change: 0 additions & 1 deletion test/abi/macOS/arm64/stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,5 @@ Added: __swift_pod_destroy
Added: __swift_pod_direct_initializeBufferWithCopyOfBuffer
Added: __swift_pod_indirect_initializeBufferWithCopyOfBuffer
Added: __swift_validatePrespecializedMetadata
Added: __swift_exceptionPersonality
Added: _swift_willThrowTypedImpl
Added: __swift_enableSwizzlingOfAllocationAndRefCountingFunctions_forInstrumentsOnly
1 change: 0 additions & 1 deletion test/abi/macOS/x86_64/stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,5 @@ Added: __swift_pod_destroy
Added: __swift_pod_direct_initializeBufferWithCopyOfBuffer
Added: __swift_pod_indirect_initializeBufferWithCopyOfBuffer
Added: __swift_validatePrespecializedMetadata
Added: __swift_exceptionPersonality
Added: _swift_willThrowTypedImpl
Added: __swift_enableSwizzlingOfAllocationAndRefCountingFunctions_forInstrumentsOnly