diff options
author | dim <dim@FreeBSD.org> | 2015-07-05 14:23:59 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-07-05 14:23:59 +0000 |
commit | e7bcad327814a78ecb8d5f5545d2e3df84c67a5c (patch) | |
tree | ac719b5984165053bf83d71142e4d96b609b9784 /lib/CodeGen/CGCall.cpp | |
parent | 9dd834653b811ad20382e98a87dff824980c9916 (diff) | |
download | FreeBSD-src-e7bcad327814a78ecb8d5f5545d2e3df84c67a5c.zip FreeBSD-src-e7bcad327814a78ecb8d5f5545d2e3df84c67a5c.tar.gz |
Vendor import of clang trunk r241361:
https://llvm.org/svn/llvm-project/cfe/trunk@241361
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 58ef171..0535c05 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -32,7 +32,6 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/Transforms/Utils/Local.h" -#include <sstream> using namespace clang; using namespace CodeGen; @@ -1453,6 +1452,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, // Attributes that should go on the call site only. if (!CodeGenOpts.SimplifyLibCalls) FuncAttrs.addAttribute(llvm::Attribute::NoBuiltin); + if (!CodeGenOpts.TrapFuncName.empty()) + FuncAttrs.addAttribute("trap-func-name", CodeGenOpts.TrapFuncName); } else { // Attributes that should go on the function, but not the call site. if (!CodeGenOpts.DisableFPElim) { @@ -1493,12 +1494,16 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, // avoid putting features in the target-features set if we know it'll be // one of the default features in the backend, e.g. corei7-avx and +avx or // figure out non-explicit dependencies. - std::vector<std::string> Features(getTarget().getTargetOpts().Features); + // Canonicalize the existing features in a new feature map. + // TODO: Migrate the existing backends to keep the map around rather than + // the vector. + llvm::StringMap<bool> FeatureMap; + for (auto F : getTarget().getTargetOpts().Features) { + const char *Name = F.c_str(); + bool Enabled = Name[0] == '+'; + getTarget().setFeatureEnabled(FeatureMap, Name + 1, Enabled); + } - // TODO: The target attribute complicates this further by allowing multiple - // additional features to be tacked on to the feature string for a - // particular function. For now we simply append to the set of features and - // let backend resolution fix them up. const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl); if (FD) { if (const TargetAttr *TD = FD->getAttr<TargetAttr>()) { @@ -1507,7 +1512,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, FeaturesStr.split(AttrFeatures, ","); // Grab the various features and prepend a "+" to turn on the feature to - // the backend and add them to our existing set of Features. + // the backend and add them to our existing set of features. for (auto &Feature : AttrFeatures) { // While we're here iterating check for a different target cpu. if (Feature.startswith("arch=")) @@ -1521,24 +1526,28 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, // attributes on the function. ; else if (Feature.startswith("mno-")) - Features.push_back("-" + Feature.split("-").second.str()); + getTarget().setFeatureEnabled(FeatureMap, Feature.split("-").second, + false); else - Features.push_back("+" + Feature.str()); - } + getTarget().setFeatureEnabled(FeatureMap, Feature, true); + } } } + // Produce the canonical string for this set of features. + std::vector<std::string> Features; + for (llvm::StringMap<bool>::const_iterator it = FeatureMap.begin(), + ie = FeatureMap.end(); + it != ie; ++it) + Features.push_back((it->second ? "+" : "-") + it->first().str()); + // Now add the target-cpu and target-features to the function. if (TargetCPU != "") FuncAttrs.addAttribute("target-cpu", TargetCPU); if (!Features.empty()) { - std::stringstream TargetFeatures; - std::copy(Features.begin(), Features.end(), - std::ostream_iterator<std::string>(TargetFeatures, ",")); - - // The drop_back gets rid of the trailing space. + std::sort(Features.begin(), Features.end()); FuncAttrs.addAttribute("target-features", - StringRef(TargetFeatures.str()).drop_back(1)); + llvm::join(Features.begin(), Features.end(), ",")); } } |