The catch object parameter to llvm.eh.begincatch is optional, and can be
null. We can save some ourselves the stack space, copy ctor, and dtor
calls if we pass null.
llvm-svn: 234264
llvm::Function *BeginCatch =
CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_begincatch);
- if (!CatchParam) {
+ // If this is a catch-all or the catch parameter is unnamed, we don't need to
+ // emit an alloca to the object.
+ if (!CatchParam || !CatchParam->getDeclName()) {
llvm::Value *Args[2] = {Exn, llvm::Constant::getNullValue(CGF.Int8PtrTy)};
CGF.EmitNounwindRuntimeCall(BeginCatch, Args);
CGF.EHStack.pushCleanup<CallEndCatchMSVC>(NormalAndEHCleanup);
// WIN64: call void @handle_exception(i8* %[[e_i8]])
// WIN64: call void @llvm.eh.endcatch()
+extern "C" void catch_int_unnamed() {
+ try {
+ might_throw();
+ } catch (int) {
+ }
+}
+
+// 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()
+
struct A {
A();
A(const A &o);
external(); // TRY: invoke void @"\01?external@@YAXXZ"
} catch (int) {
rv = 1;
- // TRY: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* %{{.*}})
+ // TRY: call void @llvm.eh.begincatch(i8* %{{.*}}, i8* null)
// TRY: call void @llvm.eh.endcatch()
}
#endif