Apply the 'nobuiltin' attribute to call sites when the user specifies `-fno-builtin' on the command line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175836 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 6072f60..9fd31fe 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -969,7 +969,8 @@
void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
const Decl *TargetDecl,
AttributeListType &PAL,
- unsigned &CallingConv) {
+ unsigned &CallingConv,
+ bool AttrOnCallSite) {
llvm::AttrBuilder FuncAttrs;
llvm::AttrBuilder RetAttrs;
@@ -1028,6 +1029,9 @@
FuncAttrs.addAttribute("target-features", Features.getString());
}
+ if (AttrOnCallSite && !CodeGenOpts.SimplifyLibCalls)
+ FuncAttrs.addAttribute(llvm::Attribute::NoBuiltin);
+
QualType RetTy = FI.getReturnType();
unsigned Index = 1;
const ABIArgInfo &RetAI = FI.getReturnInfo();
@@ -2238,9 +2242,10 @@
unsigned CallingConv;
CodeGen::AttributeListType AttributeList;
- CGM.ConstructAttributeList(CallInfo, TargetDecl, AttributeList, CallingConv);
+ CGM.ConstructAttributeList(CallInfo, TargetDecl, AttributeList,
+ CallingConv, true);
llvm::AttributeSet Attrs = llvm::AttributeSet::get(getLLVMContext(),
- AttributeList);
+ AttributeList);
llvm::BasicBlock *InvokeDest = 0;
if (!Attrs.hasAttribute(llvm::AttributeSet::FunctionIndex,
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 5033b56..60ec323 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -550,7 +550,7 @@
llvm::Function *F) {
unsigned CallingConv;
AttributeListType AttributeList;
- ConstructAttributeList(Info, D, AttributeList, CallingConv);
+ ConstructAttributeList(Info, D, AttributeList, CallingConv, false);
F->setAttributes(llvm::AttributeSet::get(getLLVMContext(), AttributeList));
F->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
}
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index f467ee7..bf9dc25 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -839,7 +839,8 @@
void ConstructAttributeList(const CGFunctionInfo &Info,
const Decl *TargetDecl,
AttributeListType &PAL,
- unsigned &CallingConv);
+ unsigned &CallingConv,
+ bool AttrOnCallSite);
StringRef getMangledName(GlobalDecl GD);
void getBlockMangledName(GlobalDecl GD, MangleBuffer &Buffer,