diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-02 04:32:35 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-02 04:32:35 +0000 |
commit | d14151d5f52fa9048d41d7539299243e05755ec4 (patch) | |
tree | 988f42a281acbd84f25ce513dea1e9dcef1e3597 /lib/CodeGen/CGCall.cpp | |
parent | 31937a5f7cb689377ff39397f4d0a8cff22d7359 (diff) |
Cleanup handling of function attributes in calls.
- No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65805 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 38f6e96c14..28152f2de1 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -22,6 +22,7 @@ #include "clang/AST/RecordLayout.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Attributes.h" +#include "llvm/Support/CallSite.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" @@ -1771,46 +1772,37 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, llvm::AttrListPtr Attrs = llvm::AttrListPtr::get(AttributeList.begin(), AttributeList.end()); - llvm::Instruction *CI; - if (!InvokeDest || Attrs.getFnAttributes() & (llvm::Attribute::NoUnwind || - llvm::Attribute::NoReturn)) { - llvm::CallInst *CallInstr = - Builder.CreateCall(Callee, &Args[0], &Args[0]+Args.size()); - CI = CallInstr; - - CallInstr->setAttributes(Attrs); - if (const llvm::Function *F = dyn_cast<llvm::Function>(Callee)) - CallInstr->setCallingConv(F->getCallingConv()); - - // If the call doesn't return, finish the basic block and clear the - // insertion point; this allows the rest of IRgen to discard - // unreachable code. - if (CallInstr->doesNotReturn()) { - Builder.CreateUnreachable(); - Builder.ClearInsertionPoint(); - - // FIXME: For now, emit a dummy basic block because expr - // emitters in generally are not ready to handle emitting - // expressions at unreachable points. - EnsureInsertPoint(); - - // Return a reasonable RValue. - return GetUndefRValue(RetTy); - } + llvm::CallSite CS; + if (!InvokeDest || (Attrs.getFnAttributes() & llvm::Attribute::NoUnwind)) { + CS = Builder.CreateCall(Callee, &Args[0], &Args[0]+Args.size()); } else { llvm::BasicBlock *Cont = createBasicBlock("invoke.cont"); - llvm::InvokeInst *InvokeInstr = - Builder.CreateInvoke(Callee, Cont, InvokeDest, - &Args[0], &Args[0]+Args.size()); - CI = InvokeInstr; - - InvokeInstr->setAttributes(Attrs); - if (const llvm::Function *F = dyn_cast<llvm::Function>(Callee)) - InvokeInstr->setCallingConv(F->getCallingConv()); - + CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, + &Args[0], &Args[0]+Args.size()); EmitBlock(Cont); } + CS.setAttributes(Attrs); + if (const llvm::Function *F = dyn_cast<llvm::Function>(Callee)) + CS.setCallingConv(F->getCallingConv()); + + // If the call doesn't return, finish the basic block and clear the + // insertion point; this allows the rest of IRgen to discard + // unreachable code. + if (CS.doesNotReturn()) { + Builder.CreateUnreachable(); + Builder.ClearInsertionPoint(); + + // FIXME: For now, emit a dummy basic block because expr + // emitters in generally are not ready to handle emitting + // expressions at unreachable points. + EnsureInsertPoint(); + + // Return a reasonable RValue. + return GetUndefRValue(RetTy); + } + + llvm::Instruction *CI = CS.getInstruction(); if (CI->getType() != llvm::Type::VoidTy) CI->setName("call"); |