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 | b960b7b7c7d7a79124f83fc720b9b7981d5d07dd (patch) | |
tree | cdfde49238324a72048aa4377cbcaa2813d18c06 /clang/lib | |
parent | f170d2e6c8a45bc2707e035942349621ed67540a (diff) | |
download | bcm5719-llvm-b960b7b7c7d7a79124f83fc720b9b7981d5d07dd.tar.gz bcm5719-llvm-b960b7b7c7d7a79124f83fc720b9b7981d5d07dd.zip |
Cleanup handling of function attributes in calls.
- No intended functionality change.
llvm-svn: 65805
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 38f6e96c140..28152f2de16 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/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"); |