r247843 - [WinEH] Pass the catch adjectives to catchpad directly
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 16 13:15:56 PDT 2015
Author: rnk
Date: Wed Sep 16 15:15:55 2015
New Revision: 247843
URL: http://llvm.org/viewvc/llvm-project?rev=247843&view=rev
Log:
[WinEH] Pass the catch adjectives to catchpad directly
This avoids building a fake LLVM IR global variable just to ferry an i32
down into LLVM codegen. It also puts a nail in the coffin of using MS
ABI C++ EH with landingpads, since now we'll assert in the lpad code
when flags are present.
Modified:
cfe/trunk/lib/CodeGen/CGCXXABI.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGCleanup.h
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-try-throw.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.cpp?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.cpp Wed Sep 16 15:15:55 2015
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "CGCXXABI.h"
+#include "CGCleanup.h"
using namespace clang;
using namespace CodeGen;
@@ -321,3 +322,7 @@ CGCXXABI::emitTerminateForUnexpectedExce
// Just call std::terminate and ignore the violating exception.
return CGF.EmitNounwindRuntimeCall(CGF.CGM.getTerminateFn());
}
+
+CatchTypeInfo CGCXXABI::getCatchAllTypeInfo() {
+ return CatchTypeInfo{nullptr, 0};
+}
Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Wed Sep 16 15:15:55 2015
@@ -37,6 +37,7 @@ class MangleContext;
namespace CodeGen {
class CodeGenFunction;
class CodeGenModule;
+struct CatchTypeInfo;
/// \brief Implements C++ ABI-specific code generation functions.
class CGCXXABI {
@@ -236,8 +237,9 @@ public:
llvm::Value *Exn);
virtual llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) = 0;
- virtual llvm::Constant *
+ virtual CatchTypeInfo
getAddrOfCXXCatchHandlerType(QualType Ty, QualType CatchHandlerType) = 0;
+ virtual CatchTypeInfo getCatchAllTypeInfo();
virtual bool shouldTypeidBeNullChecked(bool IsDeref,
QualType SrcRecordTy) = 0;
Modified: cfe/trunk/lib/CodeGen/CGCleanup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.h?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCleanup.h (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.h Wed Sep 16 15:15:55 2015
@@ -33,6 +33,13 @@ namespace CodeGen {
class CodeGenModule;
class CodeGenFunction;
+/// The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the
+/// type of a catch handler, so we use this wrapper.
+struct CatchTypeInfo {
+ llvm::Constant *RTTI;
+ unsigned Flags;
+};
+
/// A protected scope for zero-cost EH handling.
class EHScope {
llvm::BasicBlock *CachedLandingPad;
@@ -153,12 +160,12 @@ public:
struct Handler {
/// A type info value, or null (C++ null, not an LLVM null pointer)
/// for a catch-all.
- llvm::Constant *Type;
+ CatchTypeInfo Type;
/// The catch handler for this type.
llvm::BasicBlock *Block;
- bool isCatchAll() const { return Type == nullptr; }
+ bool isCatchAll() const { return Type.RTTI == nullptr; }
};
private:
@@ -188,11 +195,17 @@ public:
}
void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block) {
- setHandler(I, /*catchall*/ nullptr, Block);
+ setHandler(I, CatchTypeInfo{nullptr, 0}, Block);
}
void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block) {
assert(I < getNumHandlers());
+ getHandlers()[I].Type = CatchTypeInfo{Type, 0};
+ getHandlers()[I].Block = Block;
+ }
+
+ void setHandler(unsigned I, CatchTypeInfo Type, llvm::BasicBlock *Block) {
+ assert(I < getNumHandlers());
getHandlers()[I].Type = Type;
getHandlers()[I].Block = Block;
}
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Wed Sep 16 15:15:55 2015
@@ -554,16 +554,16 @@ void CodeGenFunction::EnterCXXTryStmt(co
QualType CaughtType = CGM.getContext().getUnqualifiedArrayType(
C->getCaughtType().getNonReferenceType(), CaughtTypeQuals);
- llvm::Constant *TypeInfo = nullptr;
+ CatchTypeInfo TypeInfo{nullptr, 0};
if (CaughtType->isObjCObjectPointerType())
- TypeInfo = CGM.getObjCRuntime().GetEHType(CaughtType);
+ TypeInfo.RTTI = CGM.getObjCRuntime().GetEHType(CaughtType);
else
- TypeInfo =
- CGM.getAddrOfCXXCatchHandlerType(CaughtType, C->getCaughtType());
+ TypeInfo = CGM.getCXXABI().getAddrOfCXXCatchHandlerType(
+ CaughtType, C->getCaughtType());
CatchScope->setHandler(I, TypeInfo, Handler);
} else {
// No exception decl indicates '...', a catch-all.
- CatchScope->setCatchAllHandler(I, Handler);
+ CatchScope->setHandler(I, CGM.getCXXABI().getCatchAllTypeInfo(), Handler);
}
}
}
@@ -807,18 +807,20 @@ llvm::BasicBlock *CodeGenFunction::EmitL
EHCatchScope &catchScope = cast<EHCatchScope>(*I);
for (unsigned hi = 0, he = catchScope.getNumHandlers(); hi != he; ++hi) {
EHCatchScope::Handler handler = catchScope.getHandler(hi);
+ assert(handler.Type.Flags == 0 &&
+ "landingpads do not support catch handler flags");
// If this is a catch-all, register that and abort.
- if (!handler.Type) {
+ if (!handler.Type.RTTI) {
assert(!hasCatchAll);
hasCatchAll = true;
goto done;
}
// Check whether we already have a handler for this type.
- if (catchTypes.insert(handler.Type).second)
+ if (catchTypes.insert(handler.Type.RTTI).second)
// If not, add it directly to the landingpad.
- LPadInst->addClause(handler.Type);
+ LPadInst->addClause(handler.Type.RTTI);
}
}
@@ -881,10 +883,9 @@ static llvm::BasicBlock *emitMSVCCatchDi
for (unsigned I = 0, E = CatchScope.getNumHandlers(); I < E; ++I) {
const EHCatchScope::Handler &Handler = CatchScope.getHandler(I);
- llvm::Value *TypeValue = Handler.Type;
- assert(TypeValue != nullptr || Handler.isCatchAll());
- if (!TypeValue)
- TypeValue = llvm::Constant::getNullValue(CGF.VoidPtrTy);
+ CatchTypeInfo TypeInfo = Handler.Type;
+ if (!TypeInfo.RTTI)
+ TypeInfo.RTTI = llvm::Constant::getNullValue(CGF.VoidPtrTy);
// If this is the last handler, we're at the end, and the next
// block is the block for the enclosing EH scope.
@@ -897,11 +898,12 @@ static llvm::BasicBlock *emitMSVCCatchDi
}
if (EHPersonality::get(CGF).isMSVCXXPersonality()) {
- CGF.Builder.CreateCatchPad(
- Handler.Block, NextBlock,
- {TypeValue, llvm::Constant::getNullValue(CGF.VoidPtrTy)});
+ CGF.Builder.CreateCatchPad(Handler.Block, NextBlock,
+ {TypeInfo.RTTI,
+ CGF.Builder.getInt32(TypeInfo.Flags),
+ llvm::Constant::getNullValue(CGF.VoidPtrTy)});
} else {
- CGF.Builder.CreateCatchPad(Handler.Block, NextBlock, {TypeValue});
+ CGF.Builder.CreateCatchPad(Handler.Block, NextBlock, {TypeInfo.RTTI});
}
// Otherwise we need to emit and continue at that block.
@@ -948,7 +950,9 @@ static llvm::BasicBlock *emitCatchDispat
assert(i < e && "ran off end of handlers!");
const EHCatchScope::Handler &handler = catchScope.getHandler(i);
- llvm::Value *typeValue = handler.Type;
+ llvm::Value *typeValue = handler.Type.RTTI;
+ assert(handler.Type.Flags == 0 &&
+ "landingpads do not support catch handler flags");
assert(typeValue && "fell into catch-all case!");
typeValue = CGF.Builder.CreateBitCast(typeValue, CGF.Int8PtrTy);
@@ -1841,7 +1845,8 @@ void CodeGenFunction::EnterSEHTryStmt(co
HelperCGF.GenerateSEHFilterFunction(*this, *Except);
llvm::Constant *OpaqueFunc =
llvm::ConstantExpr::getBitCast(FilterFunc, Int8PtrTy);
- CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except.ret"));
+ CatchScope->setHandler(0, CatchTypeInfo{OpaqueFunc},
+ createBasicBlock("__except.ret"));
}
void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Sep 16 15:15:55 2015
@@ -3808,12 +3808,6 @@ llvm::Constant *CodeGenModule::EmitUuido
return llvm::ConstantStruct::getAnon(Fields);
}
-llvm::Constant *
-CodeGenModule::getAddrOfCXXCatchHandlerType(QualType Ty,
- QualType CatchHandlerType) {
- return getCXXABI().getAddrOfCXXCatchHandlerType(Ty, CatchHandlerType);
-}
-
llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty,
bool ForEH) {
// Return a bogus pointer if RTTI is disabled, unless it's for EH.
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Sep 16 15:15:55 2015
@@ -723,9 +723,6 @@ public:
/// Get the address of the RTTI descriptor for the given type.
llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
- llvm::Constant *getAddrOfCXXCatchHandlerType(QualType Ty,
- QualType CatchHandlerType);
-
/// Get the address of a uuid descriptor .
ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr* E);
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Sep 16 15:15:55 2015
@@ -179,10 +179,10 @@ public:
void EmitFundamentalRTTIDescriptor(QualType Type);
void EmitFundamentalRTTIDescriptors();
llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) override;
- llvm::Constant *
+ CatchTypeInfo
getAddrOfCXXCatchHandlerType(QualType Ty,
QualType CatchHandlerType) override {
- return getAddrOfRTTIDescriptor(Ty);
+ return CatchTypeInfo{getAddrOfRTTIDescriptor(Ty), 0};
}
bool shouldTypeidBeNullChecked(bool IsDeref, QualType SrcRecordTy) override;
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Sep 16 15:15:55 2015
@@ -15,6 +15,7 @@
//===----------------------------------------------------------------------===//
#include "CGCXXABI.h"
+#include "CGCleanup.h"
#include "CGVTables.h"
#include "CodeGenModule.h"
#include "CodeGenTypes.h"
@@ -105,9 +106,14 @@ public:
const VPtrInfo *Info);
llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) override;
- llvm::Constant *
+ CatchTypeInfo
getAddrOfCXXCatchHandlerType(QualType Ty, QualType CatchHandlerType) override;
+ /// MSVC needs an extra flag to indicate a catchall.
+ CatchTypeInfo getCatchAllTypeInfo() override {
+ return CatchTypeInfo{nullptr, 0x40};
+ }
+
bool shouldTypeidBeNullChecked(bool IsDeref, QualType SrcRecordTy) override;
void EmitBadTypeidCall(CodeGenFunction &CGF) override;
llvm::Value *EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy,
@@ -926,7 +932,7 @@ void MicrosoftCXXABI::emitBeginCatch(Cod
llvm::Value *Args[2] = {Exn, ParamAddr.getPointer()};
CGF.EmitNounwindRuntimeCall(BeginCatch, Args);
} else {
- CPI->setArgOperand(1, var.getObjectAddress(CGF).getPointer());
+ CPI->setArgOperand(2, var.getObjectAddress(CGF).getPointer());
}
CGF.EHStack.pushCleanup<CallEndCatchMSVC>(NormalCleanup, CPI);
CGF.EmitAutoVarCleanups(var);
@@ -3687,7 +3693,7 @@ static QualType decomposeTypeForEH(ASTCo
return T;
}
-llvm::Constant *
+CatchTypeInfo
MicrosoftCXXABI::getAddrOfCXXCatchHandlerType(QualType Type,
QualType CatchHandlerType) {
// TypeDescriptors for exceptions never have qualified pointer types,
@@ -3706,28 +3712,8 @@ MicrosoftCXXABI::getAddrOfCXXCatchHandle
if (IsReference)
Flags |= 8;
- SmallString<256> MangledName;
- {
- llvm::raw_svector_ostream Out(MangledName);
- getMangleContext().mangleCXXCatchHandlerType(Type, Flags, Out);
- }
-
- if (llvm::GlobalVariable *GV = CGM.getModule().getNamedGlobal(MangledName))
- return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
-
- llvm::Constant *Fields[] = {
- llvm::ConstantInt::get(CGM.IntTy, Flags), // Flags
- getAddrOfRTTIDescriptor(Type), // TypeDescriptor
- };
- llvm::StructType *CatchHandlerTypeType = getCatchHandlerTypeType();
- auto *Var = new llvm::GlobalVariable(
- CGM.getModule(), CatchHandlerTypeType, /*Constant=*/true,
- llvm::GlobalValue::PrivateLinkage,
- llvm::ConstantStruct::get(CatchHandlerTypeType, Fields),
- StringRef(MangledName));
- Var->setUnnamedAddr(true);
- Var->setSection("llvm.metadata");
- return Var;
+ return CatchTypeInfo{getAddrOfRTTIDescriptor(Type)->stripPointerCasts(),
+ Flags};
}
/// \brief Gets a TypeDescriptor. Returns a llvm::Constant * rather than a
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=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp Wed Sep 16 15:15:55 2015
@@ -17,7 +17,7 @@ void test_catch() {
// CHECK: to label %[[NORMAL:.*]] unwind label %[[CATCH_INT:.*]]
// CHECK: [[CATCH_INT]]
-// CHECK: %[[CATCHPAD_INT:.*]] = catchpad [{{.*}} @llvm.eh.handlertype.H.0, i8* null]
+// CHECK: %[[CATCHPAD_INT:.*]] = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H at 8", i32 0, i8* null]
// CHECK: to label %[[CATCH_INT_HANDLER:.*]] unwind label %[[CATCH_DOUBLE:.*]]
// CHECK: [[CATCH_INT_HANDLER]]
@@ -34,7 +34,7 @@ void test_catch() {
// CHECK: ret void
// CHECK: [[CATCH_DOUBLE]]
-// CHECK: %[[CATCHPAD_DOUBLE:.*]] = catchpad [{{.*}} @llvm.eh.handlertype.N.0, i8* null]
+// CHECK: %[[CATCHPAD_DOUBLE:.*]] = catchpad [%rtti.TypeDescriptor2* @"\01??_R0N at 8", i32 0, i8* null]
// CHECK: to label %[[CATCH_DOUBLE_HANDLER:.*]] unwind label %[[CATCHENDPAD]]
// CHECK: [[CATCH_DOUBLE_HANDLER]]
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp Wed Sep 16 15:15:55 2015
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc -mconstructor-aliases -fexceptions -fcxx-exceptions | FileCheck -check-prefix WIN64 %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc \
+// RUN: -mconstructor-aliases -fexceptions -fcxx-exceptions -fnew-ms-eh \
+// RUN: | FileCheck -check-prefix WIN64 %s
extern "C" void might_throw();
@@ -18,19 +20,22 @@ extern "C" void catch_all() {
// WIN64: invoke void @might_throw()
// WIN64-NEXT: to label %[[cont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
//
-// WIN64: [[cont]]
-// WIN64: br label %[[ret:[^ ]*]]
-//
// WIN64: [[lpad]]
-// WIN64: landingpad { i8*, i32 }
-// WIN64-NEXT: catch i8* null
-// WIN64: call void @llvm.eh.begincatch(i8* %{{[^,]*}}, i8* null)
+// WIN64: catchpad [i8* null, i32 64, i8* null]
+// WIN64: to label %[[catchit:[^ ]*]] unwind label %{{.*}}
+//
+// WIN64: [[catchit]]
// WIN64: call void @recover()
-// WIN64: call void @llvm.eh.endcatch()
-// WIN64: br label %[[ret]]
+// WIN64: catchret %{{.*}} to label %[[catchret:[^ ]*]]
+//
+// WIN64: [[catchret]]
+// WIN64-NEXT: br label %[[ret:[^ ]*]]
//
// WIN64: [[ret]]
// WIN64: ret void
+//
+// WIN64: [[cont]]
+// WIN64: br label %[[ret]]
extern "C" void catch_int() {
try {
@@ -41,12 +46,10 @@ extern "C" void catch_int() {
}
// WIN64-LABEL: define void @catch_int()
-// WIN64: landingpad { i8*, i32 }
-// WIN64: %[[e_i8:[^ ]*]] = bitcast i32* %[[e_addr:[^ ]*]] to i8*
-// WIN64: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* %[[e_i8]])
+// WIN64: catchpad [%rtti.TypeDescriptor2* @"\01??_R0H at 8", i32 0, i32* %[[e_addr:[^\]]*]]]
// WIN64: %[[e_i8:[^ ]*]] = bitcast i32* %[[e_addr]] to i8*
// WIN64: call void @handle_exception(i8* %[[e_i8]])
-// WIN64: call void @llvm.eh.endcatch()
+// WIN64: catchret
extern "C" void catch_int_unnamed() {
try {
@@ -56,9 +59,8 @@ extern "C" void catch_int_unnamed() {
}
// WIN64-LABEL: define void @catch_int_unnamed()
-// WIN64: landingpad { i8*, i32 }
-// WIN64: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* null)
-// WIN64: call void @llvm.eh.endcatch()
+// WIN64: catchpad [%rtti.TypeDescriptor2* @"\01??_R0H at 8", i32 0, i8* null]
+// WIN64: catchret
struct A {
A();
@@ -84,12 +86,10 @@ extern "C" void catch_a_byval() {
// WIN64-LABEL: define void @catch_a_byval()
// WIN64: %[[e_addr:[^ ]*]] = alloca %struct.A
-// WIN64: landingpad { i8*, i32 }
-// WIN64: %[[e_i8:[^ ]*]] = bitcast %struct.A* %[[e_addr]] to i8*
-// WIN64: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* %[[e_i8]])
+// WIN64: catchpad [%rtti.TypeDescriptor7* @"\01??_R0?AUA@@@8", i32 0, %struct.A* %[[e_addr]]]
// WIN64: %[[e_i8:[^ ]*]] = bitcast %struct.A* %[[e_addr]] to i8*
// WIN64: call void @handle_exception(i8* %[[e_i8]])
-// WIN64: call void @llvm.eh.endcatch()
+// WIN64: catchret
extern "C" void catch_a_ref() {
try {
@@ -101,13 +101,11 @@ extern "C" void catch_a_ref() {
// WIN64-LABEL: define void @catch_a_ref()
// WIN64: %[[e_addr:[^ ]*]] = alloca %struct.A*
-// WIN64: landingpad { i8*, i32 }
-// WIN64: %[[e_i8:[^ ]*]] = bitcast %struct.A** %[[e_addr]] to i8*
-// WIN64: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* %[[e_i8]])
+// WIN64: catchpad [%rtti.TypeDescriptor7* @"\01??_R0?AUA@@@8", i32 8, %struct.A** %[[e_addr]]]
// WIN64: %[[eptr:[^ ]*]] = load %struct.A*, %struct.A** %[[e_addr]]
// WIN64: %[[eptr_i8:[^ ]*]] = bitcast %struct.A* %[[eptr]] to i8*
// WIN64: call void @handle_exception(i8* %[[eptr_i8]])
-// WIN64: call void @llvm.eh.endcatch()
+// WIN64: catchret
extern "C" void fn_with_exc_spec() throw(int) {
might_throw();
@@ -131,24 +129,32 @@ extern "C" void catch_nested() {
// WIN64-LABEL: define void @catch_nested()
// WIN64: invoke void @might_throw()
-// WIN64-NEXT: to label %[[cont1:[^ ]*]] unwind label %[[lp1:[^ ]*]]
-// WIN64: [[cont1]]
+// WIN64-NEXT: to label %{{.*}} unwind label %[[lp1:[^ ]*]]
//
// WIN64: [[lp1]]
-// WIN64: landingpad { i8*, i32 }
-// WIN64: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* null)
+// WIN64: catchpad [%rtti.TypeDescriptor2* @"\01??_R0H at 8", i32 0, i8* null]
+// WIN64: to label %[[catchit:[^ ]*]] unwind label %{{.*}}
+//
+// WIN64: [[catchit]]
// WIN64: invoke void @might_throw()
// WIN64-NEXT: to label %[[cont2:[^ ]*]] unwind label %[[lp2:[^ ]*]]
//
-// WIN64: [[cont2]]
-// WIN64-NEXT: br label %[[trycont:[^ ]*]]
-//
// WIN64: [[lp2]]
-// WIN64: landingpad { i8*, i32 }
-// WIN64: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* null)
-// WIN64-NEXT: call void @might_throw()
-// WIN64-NEXT: call void @llvm.eh.endcatch()
-// WIN64-NEXT: br label %[[trycont]]
+// WIN64: catchpad [%rtti.TypeDescriptor2* @"\01??_R0H at 8", i32 0, i8* null]
+// WIN64: to label %[[catchit2:[^ ]*]] unwind label %[[endcatch2:[^ ]*]]
+//
+// WIN64: [[catchit2]]
+// WIN64-NEXT: invoke void @might_throw()
+// WIN64-NEXT: to label %[[catchret1:[^ ]*]] unwind label %[[endcatch2]]
+//
+// WIN64: [[catchret1]]
+// WIN64: catchret {{.*}} to label %[[catchret2:[^ ]*]]
+//
+// WIN64: [[catchret2]]
+// WIN64: catchret {{.*}} to label %[[mainret:[^ ]*]]
+//
+// WIN64: [[mainret]]
+// WIN64: ret void
//
-// WIN64: [[trycont]]
-// WIN64: call void @llvm.eh.endcatch()
+// WIN64: [[endcatch2]]
+// WIN64: catchendpad unwind label %{{.*}}
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-try-throw.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-try-throw.cpp?rev=247843&r1=247842&r2=247843&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-try-throw.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-try-throw.cpp Wed Sep 16 15:15:55 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTRY | FileCheck %s -check-prefix=TRY
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTRY -fnew-ms-eh | FileCheck %s -check-prefix=TRY
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTHROW | FileCheck %s -check-prefix=THROW
// THROW-DAG: @"\01??_R0H at 8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
@@ -6,8 +6,6 @@
// THROW-DAG: @_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0H at 84"] }, section ".xdata", comdat
// THROW-DAG: @_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1H to i8*) }, section ".xdata", comdat
-// TRY-DAG: @llvm.eh.handlertype.PAH.1 = private unnamed_addr constant %eh.CatchHandlerType { i32 1, i8* bitcast (%rtti.TypeDescriptor4* @"\01??_R0PAH at 8" to i8*) }, section "llvm.metadata"
-
void external();
inline void not_emitted() {
@@ -21,8 +19,8 @@ int main() {
external(); // TRY: invoke void @"\01?external@@YAXXZ"
} catch (int) {
rv = 1;
- // TRY: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* null)
- // TRY: call void @llvm.eh.endcatch()
+ // TRY: catchpad [%rtti.TypeDescriptor2* @"\01??_R0H at 8", i32 0, i8* null]
+ // TRY: catchret
}
#endif
#ifdef THROW
@@ -41,7 +39,7 @@ void qual_catch() {
external();
} catch (const int *) {
}
- // TRY: catch %eh.CatchHandlerType* @llvm.eh.handlertype.PAH.1
- // TRY: call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.PAH.1 to i8*))
+ // TRY: catchpad [%rtti.TypeDescriptor4* @"\01??_R0PAH at 8", i32 1, i8* null]
+ // TRY: catchret
}
#endif
More information about the cfe-commits
mailing list