diff gen/irstate.h @ 1300:329e45865d84

Add 'nounwind' attribute to the relevant runtime functions, and use it when deciding whether or not to generate an invoke instead of a call.
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 04 May 2009 20:26:45 +0200
parents 6bd5ce91b136
children 3f5ea912149d
line wrap: on
line diff
--- a/gen/irstate.h	Mon May 04 13:32:16 2009 +0200
+++ b/gen/irstate.h	Mon May 04 20:26:45 2009 +0200
@@ -178,13 +178,12 @@
     llvm::BasicBlock* pad;
     if(pad = func()->landingPad.get())
     {
-        // intrinsics don't support invoking
+        // intrinsics don't support invoking and 'nounwind' functions don't need it.
         LLFunction* funcval = llvm::dyn_cast<LLFunction>(Callee);
-        if (funcval && funcval->isIntrinsic())
+        if (funcval && (funcval->isIntrinsic() || funcval->doesNotThrow()))
         {
             llvm::CallInst* call = ir->CreateCall(Callee, ArgBegin, ArgEnd, Name);
-            if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee))
-                call->setAttributes(fn->getAttributes());
+            call->setAttributes(funcval->getAttributes());
             return call;
         }