Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1299:847b767b2d0b | 1300:329e45865d84 |
---|---|
176 llvm::CallSite IRState::CreateCallOrInvoke(LLValue* Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char* Name) | 176 llvm::CallSite IRState::CreateCallOrInvoke(LLValue* Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char* Name) |
177 { | 177 { |
178 llvm::BasicBlock* pad; | 178 llvm::BasicBlock* pad; |
179 if(pad = func()->landingPad.get()) | 179 if(pad = func()->landingPad.get()) |
180 { | 180 { |
181 // intrinsics don't support invoking | 181 // intrinsics don't support invoking and 'nounwind' functions don't need it. |
182 LLFunction* funcval = llvm::dyn_cast<LLFunction>(Callee); | 182 LLFunction* funcval = llvm::dyn_cast<LLFunction>(Callee); |
183 if (funcval && funcval->isIntrinsic()) | 183 if (funcval && (funcval->isIntrinsic() || funcval->doesNotThrow())) |
184 { | 184 { |
185 llvm::CallInst* call = ir->CreateCall(Callee, ArgBegin, ArgEnd, Name); | 185 llvm::CallInst* call = ir->CreateCall(Callee, ArgBegin, ArgEnd, Name); |
186 if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee)) | 186 call->setAttributes(funcval->getAttributes()); |
187 call->setAttributes(fn->getAttributes()); | |
188 return call; | 187 return call; |
189 } | 188 } |
190 | 189 |
191 llvm::BasicBlock* postinvoke = llvm::BasicBlock::Create("postinvoke", topfunc(), scopeend()); | 190 llvm::BasicBlock* postinvoke = llvm::BasicBlock::Create("postinvoke", topfunc(), scopeend()); |
192 llvm::InvokeInst* invoke = ir->CreateInvoke(Callee, postinvoke, pad, ArgBegin, ArgEnd, Name); | 191 llvm::InvokeInst* invoke = ir->CreateInvoke(Callee, postinvoke, pad, ArgBegin, ArgEnd, Name); |