This patch would cause clang to mark the __cxa_guard_* functions
'nounwind'. I believe this is the correct reading of the Itanium ABI;
the functions are completely specified, and each function which may
throw an exception specifically says what exception it will throw and
under what conditions. Most of the functions say nothing about throwing
exceptions, so I assume that they aren't allowed to throw.
I'm not an expert on this though, so please review.
This would fix the intersting problem of invokes to __cxa_guard_*
functions. Even though clang never generates an invoke to these, one
still manages to show up in
SingleSource/Benchmarks/Misc-C++-EH/Output/spirit.llvm.bc. How? When the
inliner inlines an invoke, all calls inside the callee turn into invokes
with their unwind-destination pointing at the inline-callsite's
unwind-destination.
Naturally, marking the __cxa_guard_* methods nounwind would fix that.
Nick
Index: lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- lib/CodeGen/ItaniumCXXABI.cpp (revision 150327)
+++ lib/CodeGen/ItaniumCXXABI.cpp (working copy)
@@ -979,7 +979,8 @@
llvm::FunctionType::get(CGM.getTypes().ConvertType(CGM.getContext().IntTy),
GuardPtrTy, /*isVarArg=*/false);
- return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire");
+ return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire",
+ llvm::Attribute::NoUnwind);
}
static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
@@ -988,7 +989,8 @@
llvm::FunctionType *FTy =
llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
- return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release");
+ return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release",
+ llvm::Attribute::NoUnwind);
}
static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
@@ -997,7 +999,8 @@
llvm::FunctionType *FTy =
llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
- return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort");
+ return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort",
+ llvm::Attribute::NoUnwind);
}
namespace {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits