From 2f81db66afd54612937ac36a24d271e4b1b849ef Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 22 Feb 2013 20:53:29 +0000 Subject: [PATCH] Make sure we apply attributes to correct places. Some attributes make sense only on the function or on the call site, but not both. Make this distinction here. llvm-svn: 175918 --- clang/lib/CodeGen/CGCall.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index f2c2d0a..fe0088d 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1021,21 +1021,25 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, if (CodeGenOpts.NoImplicitFloat) FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat); - if (!TargetOpts.CPU.empty()) - FuncAttrs.addAttribute("target-cpu", TargetOpts.CPU); - - if (TargetOpts.Features.size()) { - llvm::SubtargetFeatures Features; - for (std::vector::const_iterator - it = TargetOpts.Features.begin(), - ie = TargetOpts.Features.end(); it != ie; ++it) - Features.AddFeature(*it); - FuncAttrs.addAttribute("target-features", Features.getString()); + if (AttrOnCallSite) { + // Attributes that should go on the call site only. + if (!CodeGenOpts.SimplifyLibCalls) + FuncAttrs.addAttribute(llvm::Attribute::NoBuiltin); + } else { + // Attributes that should go on the function, but not the call site. + if (!TargetOpts.CPU.empty()) + FuncAttrs.addAttribute("target-cpu", TargetOpts.CPU); + + if (TargetOpts.Features.size()) { + llvm::SubtargetFeatures Features; + for (std::vector::const_iterator + it = TargetOpts.Features.begin(), + ie = TargetOpts.Features.end(); it != ie; ++it) + Features.AddFeature(*it); + 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(); -- 2.7.4