r255521 - [MS ABI] Don't rely on terminatepad
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 14 10:34:19 PST 2015
Author: majnemer
Date: Mon Dec 14 12:34:18 2015
New Revision: 255521
URL: http://llvm.org/viewvc/llvm-project?rev=255521&view=rev
Log:
[MS ABI] Don't rely on terminatepad
We'd like to remove support for terminatepad from LLVM. To do this, we
need to move Clang off of it first. The intent behind terminatepad was
to carefully model exception specifications for the MSVC personality.
However, we don't support exception specifications for the MSVC
personality and neither does MSVC. Instead, MSVC supports
all-or-nothing exception specifications. We can model this limited
usage using cleanuppads which call std::terminate.
Differential Revision: http://reviews.llvm.org/D15478
Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=255521&r1=255520&r2=255521&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Mon Dec 14 12:34:18 2015
@@ -1325,21 +1325,20 @@ llvm::BasicBlock *CodeGenFunction::getTe
// end of the function by FinishFunction.
TerminateHandler = createBasicBlock("terminate.handler");
Builder.SetInsertPoint(TerminateHandler);
+ llvm::Value *Exn = nullptr;
if (EHPersonality::get(*this).usesFuncletPads()) {
llvm::Value *ParentPad = CurrentFuncletPad;
if (!ParentPad)
ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
- Builder.CreateTerminatePad(ParentPad, /*UnwindBB=*/nullptr,
- {CGM.getTerminateFn()});
+ Builder.CreateCleanupPad(ParentPad);
} else {
- llvm::Value *Exn = nullptr;
if (getLangOpts().CPlusPlus)
Exn = getExceptionFromSlot();
- llvm::CallInst *terminateCall =
- CGM.getCXXABI().emitTerminateForUnexpectedException(*this, Exn);
- terminateCall->setDoesNotReturn();
- Builder.CreateUnreachable();
}
+ llvm::CallInst *terminateCall =
+ CGM.getCXXABI().emitTerminateForUnexpectedException(*this, Exn);
+ terminateCall->setDoesNotReturn();
+ Builder.CreateUnreachable();
// Restore the saved insertion state.
Builder.restoreIP(SavedIP);
Modified: cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp?rev=255521&r1=255520&r2=255521&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp Mon Dec 14 12:34:18 2015
@@ -72,5 +72,6 @@ void test_cleanup() {
// CHECK: ret void
// CHECK: [[TERMINATE]]
-// CHECK: terminatepad within none [void ()* @"\01?terminate@@YAXXZ"] unwind to caller
+// CHECK: cleanuppad within none []
+// CHECK-NEXT: call void @"\01?terminate@@YAXXZ"()
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp?rev=255521&r1=255520&r2=255521&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp Mon Dec 14 12:34:18 2015
@@ -9,6 +9,7 @@ void never_throws() noexcept(true) {
// CHECK-LABEL: define void @"\01?never_throws@@YAXXZ"()
// CHECK-SAME: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
// CHECK: invoke void @"\01?may_throw@@YAXXZ"()
-// MSVC2013: terminatepad within none [void ()* @"\01?terminate@@YAXXZ"]
-// MSVC2015: terminatepad within none [void ()* @__std_terminate]
+// CHECK: cleanuppad within none []
+// MSVC2013: call void @"\01?terminate@@YAXXZ"()
+// MSVC2015: call void @__std_terminate()
// CHECK-NEXT: unreachable
More information about the cfe-commits
mailing list