diff options
| author | Reid Kleckner <rnk@google.com> | 2017-04-10 20:34:19 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2017-04-10 20:34:19 +0000 |
| commit | 211b1f324fec79eddecccc4cb43a284bd3324cd5 (patch) | |
| tree | 79b6b6a51d322e61e42c702acf10511de901cee7 /llvm/lib/Transforms/Utils | |
| parent | d972949b10ef0b10fd73d5b153084217c535bb15 (diff) | |
| download | bcm5719-llvm-211b1f324fec79eddecccc4cb43a284bd3324cd5.tar.gz bcm5719-llvm-211b1f324fec79eddecccc4cb43a284bd3324cd5.zip | |
Revert "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"
This reverts r299875. A Linux bot came back with a test failure:
http://bb.pgr.jp/builders/test-clang-i686-linux-RA/builds/741/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__2006-05-19-SingleEltReturn.c
llvm-svn: 299878
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 22 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 3 |
2 files changed, 11 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index f4803028f3c..60b988e880b 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -103,25 +103,21 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges, TypeMapper, Materializer)); - SmallVector<std::pair<unsigned, AttributeSetNode*>, 4> AttrVec; AttributeList OldAttrs = OldFunc->getAttributes(); - - // Copy the return attributes. - if (auto *RetAttrs = OldAttrs.getRetAttributes()) - AttrVec.emplace_back(AttributeList::ReturnIndex, RetAttrs); - // Clone any argument attributes that are present in the VMap. for (const Argument &OldArg : OldFunc->args()) if (Argument *NewArg = dyn_cast<Argument>(VMap[&OldArg])) { - if (auto *ParmAttrs = OldAttrs.getParamAttributes(OldArg.getArgNo() + 1)) - AttrVec.emplace_back(NewArg->getArgNo() + 1, ParmAttrs); + AttributeList attrs = OldAttrs.getParamAttributes(OldArg.getArgNo() + 1); + if (attrs.getNumSlots() > 0) + NewArg->addAttr(attrs); } - // Copy any function attributes. - if (auto *FnAttrs = OldAttrs.getFnAttributes()) - AttrVec.emplace_back(AttributeList::FunctionIndex, FnAttrs); - - NewFunc->setAttributes(AttributeList::get(NewFunc->getContext(), AttrVec)); + NewFunc->setAttributes( + NewFunc->getAttributes() + .addAttributes(NewFunc->getContext(), AttributeList::ReturnIndex, + OldAttrs.getRetAttributes()) + .addAttributes(NewFunc->getContext(), AttributeList::FunctionIndex, + OldAttrs.getFnAttributes())); SmallVector<std::pair<unsigned, MDNode *>, 1> MDs; OldFunc->getAllMetadata(MDs); diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 3bc33d0c666..755427cace2 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -362,7 +362,8 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs, // "target-features" attribute allowing it to be lowered. // FIXME: This should be changed to check to see if a specific // attribute can not be inherited. - AttrBuilder AB(oldFunction->getAttributes().getFnAttributes()); + AttributeList OldFnAttrs = oldFunction->getAttributes().getFnAttributes(); + AttrBuilder AB(OldFnAttrs, AttributeList::FunctionIndex); for (const auto &Attr : AB.td_attrs()) newFunction->addFnAttr(Attr.first, Attr.second); |

