diff options
author | Eric Christopher <echristo@gmail.com> | 2015-09-02 20:40:12 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-09-02 20:40:12 +0000 |
commit | 86fdc85181ae75e0280b00175b1b1af86b5b0c7d (patch) | |
tree | 38c2bf81a87de157132b83655c8593c4e45e260b /clang/lib/CodeGen | |
parent | d97846ed05ac0e191634d535ede124347bdebaf9 (diff) | |
download | bcm5719-llvm-86fdc85181ae75e0280b00175b1b1af86b5b0c7d.tar.gz bcm5719-llvm-86fdc85181ae75e0280b00175b1b1af86b5b0c7d.zip |
Migrate the target attribute parsing code to returning an instance
every time it's called rather than attempting to cache the result.
It's unlikely to be called frequently and the overhead of using
it in the first place is already factored out.
llvm-svn: 246706
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index ed7bf60c024..2dc68622e77 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1499,24 +1499,24 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl); if (FD && FD->hasAttr<TargetAttr>()) { llvm::StringMap<bool> FeatureMap; - auto *TD = FD->getAttr<TargetAttr>(); + const auto *TD = FD->getAttr<TargetAttr>(); + TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse(); - // Make a copy of the features as passed on the command line. - std::vector<std::string> FnFeatures = - getTarget().getTargetOpts().FeaturesAsWritten; + // Make a copy of the features as passed on the command line into the + // beginning of the additional features from the function to override. + ParsedAttr.first.insert( + ParsedAttr.first.begin(), + getTarget().getTargetOpts().FeaturesAsWritten.begin(), + getTarget().getTargetOpts().FeaturesAsWritten.end()); - std::vector<std::string> &AttrFeatures = TD->getFeatures(); - std::copy(AttrFeatures.begin(), AttrFeatures.end(), - std::back_inserter(FnFeatures)); - - if (TD->getCPU() != "") - TargetCPU = TD->getCPU(); + if (ParsedAttr.second != "") + TargetCPU = ParsedAttr.second; // Now populate the feature map, first with the TargetCPU which is either // the default or a new one from the target attribute string. Then we'll // use the passed in features (FeaturesAsWritten) along with the new ones // from the attribute. - getTarget().initFeatureMap(FeatureMap, Diags, TargetCPU, FnFeatures); + getTarget().initFeatureMap(FeatureMap, Diags, TargetCPU, ParsedAttr.first); // Produce the canonical string for this set of features. std::vector<std::string> Features; |