aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-20 18:06:48 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-20 18:06:48 +0000
commitc0ef9f59937c3971c48b6fed37cf5bd8985c024b (patch)
tree5cc83e25acc874fda399923131dd15ef30e2a0f8 /lib/CodeGen
parent67956052ea5fb0cd7f443de96a11f9a0176dc681 (diff)
Set call attribute for direct calls (i.e. noreturn).
- Remove an unused variant of EmitCallExpr overload. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGCall.cpp6
-rw-r--r--lib/CodeGen/CGExpr.cpp33
-rw-r--r--lib/CodeGen/CodeGenFunction.h13
3 files changed, 26 insertions, 26 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 42f671a7e6..d0122fa4f9 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -1676,7 +1676,8 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
llvm::Value *Callee,
- const CallArgList &CallArgs) {
+ const CallArgList &CallArgs,
+ const Decl *TargetDecl) {
// FIXME: We no longer need the types from CallArgs; lift up and
// simplify.
llvm::SmallVector<llvm::Value*, 16> Args;
@@ -1752,9 +1753,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
llvm::CallInst *CI = Builder.CreateCall(Callee,&Args[0],&Args[0]+Args.size());
- // FIXME: Provide TargetDecl so nounwind, noreturn, etc, etc get set.
CodeGen::AttributeListType AttributeList;
- CGM.ConstructAttributeList(CallInfo, 0, AttributeList);
+ CGM.ConstructAttributeList(CallInfo, TargetDecl, AttributeList);
CI->setAttributes(llvm::AttrListPtr::get(AttributeList.begin(),
AttributeList.size()));
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 5da0de9cbb..22a6a2d02e 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -966,29 +966,25 @@ LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr* E)
RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) {
+ // Builtins never have block type.
+ if (E->getCallee()->getType()->isBlockPointerType())
+ return EmitBlockCallExpr(E);
+
+ const Decl *TargetDecl = 0;
if (const ImplicitCastExpr *IcExpr =
- dyn_cast<const ImplicitCastExpr>(E->getCallee()))
+ dyn_cast<ImplicitCastExpr>(E->getCallee())) {
if (const DeclRefExpr *DRExpr =
- dyn_cast<const DeclRefExpr>(IcExpr->getSubExpr()))
- if (const FunctionDecl *FDecl =
- dyn_cast<const FunctionDecl>(DRExpr->getDecl()))
+ dyn_cast<DeclRefExpr>(IcExpr->getSubExpr())) {
+ TargetDecl = DRExpr->getDecl();
+ if (const FunctionDecl *FDecl = dyn_cast<FunctionDecl>(TargetDecl))
if (unsigned builtinID = FDecl->getBuiltinID(getContext()))
return EmitBuiltinExpr(FDecl, builtinID, E);
-
- if (E->getCallee()->getType()->isBlockPointerType())
- return EmitBlockCallExpr(E);
+ }
+ }
llvm::Value *Callee = EmitScalarExpr(E->getCallee());
return EmitCallExpr(Callee, E->getCallee()->getType(),
- E->arg_begin(), E->arg_end());
-}
-
-RValue CodeGenFunction::EmitCallExpr(Expr *FnExpr,
- CallExpr::const_arg_iterator ArgBeg,
- CallExpr::const_arg_iterator ArgEnd) {
-
- llvm::Value *Callee = EmitScalarExpr(FnExpr);
- return EmitCallExpr(Callee, FnExpr->getType(), ArgBeg, ArgEnd);
+ E->arg_begin(), E->arg_end(), TargetDecl);
}
LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
@@ -1108,7 +1104,8 @@ CodeGenFunction::EmitObjCSuperExpr(const ObjCSuperExpr *E) {
RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType CalleeType,
CallExpr::const_arg_iterator ArgBeg,
- CallExpr::const_arg_iterator ArgEnd) {
+ CallExpr::const_arg_iterator ArgEnd,
+ const Decl *TargetDecl) {
// Get the actual function type. The callee type will always be a
// pointer to function type or a block pointer type.
QualType ResultType;
@@ -1127,5 +1124,5 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType CalleeType,
I->getType()));
return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args),
- Callee, Args);
+ Callee, Args, TargetDecl);
}
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index bc602f3720..7072be8f60 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -618,18 +618,21 @@ public:
/// EmitCall - Generate a call of the given function, expecting the given
/// result type, and using the given argument list which specifies both the
/// LLVM arguments and the types they were derived from.
+ ///
+ /// \param TargetDecl - If given, the decl of the function in a
+ /// direct call; used to set attributes on the call (noreturn,
+ /// etc.).
RValue EmitCall(const CGFunctionInfo &FnInfo,
llvm::Value *Callee,
- const CallArgList &Args);
+ const CallArgList &Args,
+ const Decl *TargetDecl = 0);
RValue EmitCallExpr(const CallExpr *E);
- RValue EmitCallExpr(Expr *FnExpr, CallExpr::const_arg_iterator ArgBeg,
- CallExpr::const_arg_iterator ArgEnd);
-
RValue EmitCallExpr(llvm::Value *Callee, QualType FnType,
CallExpr::const_arg_iterator ArgBeg,
- CallExpr::const_arg_iterator ArgEnd);
+ CallExpr::const_arg_iterator ArgEnd,
+ const Decl *TargetDecl = 0);
RValue EmitBuiltinExpr(const FunctionDecl *FD,
unsigned BuiltinID, const CallExpr *E);