From 1235a8dac6c1c0289bc96f1af9b58aecc3caedb8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 29 Jul 2013 20:14:16 +0000 Subject: PR16715: Fix assert in verifier: only mark call to 'operator new' as 'builtin' if corresponding 'operator new' was actually emitted as a function marked 'nobuiltin'. llvm-svn: 187374 --- clang/lib/CodeGen/CGExprCXX.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index c74d88b9508..5ec135ea506 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -1009,9 +1009,10 @@ static RValue EmitNewDeleteCall(CodeGenFunction &CGF, const FunctionProtoType *CalleeType, const CallArgList &Args) { llvm::Instruction *CallOrInvoke; + llvm::Value *CalleeAddr = CGF.CGM.GetAddrOfFunction(Callee); RValue RV = CGF.EmitCall(CGF.CGM.getTypes().arrangeFreeFunctionCall(Args, CalleeType), - CGF.CGM.GetAddrOfFunction(Callee), ReturnValueSlot(), Args, + CalleeAddr, ReturnValueSlot(), Args, Callee, &CallOrInvoke); /// C++1y [expr.new]p10: @@ -1019,7 +1020,9 @@ static RValue EmitNewDeleteCall(CodeGenFunction &CGF, /// to a replaceable global allocation function. /// /// We model such elidable calls with the 'builtin' attribute. - if (Callee->isReplaceableGlobalAllocationFunction()) { + llvm::Function *Fn = dyn_cast(CalleeAddr); + if (Callee->isReplaceableGlobalAllocationFunction() && + Fn && Fn->hasFnAttribute(llvm::Attribute::NoBuiltin)) { // FIXME: Add addAttribute to CallSite. if (llvm::CallInst *CI = dyn_cast(CallOrInvoke)) CI->addAttribute(llvm::AttributeSet::FunctionIndex, -- cgit v1.2.3