From aae0298921d946a64385052ce6e678d36f936fb3 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 1 May 2013 13:07:03 +0000 Subject: [PATCH] Now that the underlying issue is fixed, revert r180750 and r180722. The cause of the windows failures was fixed by r180791. Revert to the state after Sabre's original revert. Original message: revert r179735, it has no testcases, and doesn't really make sense. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180844 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Attributes.h | 3 +-- lib/IR/AsmWriter.cpp | 20 +++++++++++++++++--- lib/IR/AttributeImpl.h | 2 +- lib/IR/Attributes.cpp | 15 ++++++--------- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 1cd879361cf..2c7da6485dc 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -307,8 +307,7 @@ public: unsigned getStackAlignment(unsigned Index) const; /// \brief Return the attributes at the index as a string. - std::string getAsString(unsigned Index, bool TargetIndependent = true, - bool InAttrGrp = false) const; + std::string getAsString(unsigned Index, bool InAttrGrp = false) const; typedef ArrayRef::iterator iterator; diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index dd0abba0e4f..7761127d557 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -1608,7 +1608,22 @@ void AssemblyWriter::printFunction(const Function *F) { const AttributeSet &Attrs = F->getAttributes(); if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) { AttributeSet AS = Attrs.getFnAttributes(); - std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, false); + std::string AttrStr; + + unsigned Idx = 0; + for (unsigned E = AS.getNumSlots(); Idx != E; ++Idx) + if (AS.getSlotIndex(Idx) == AttributeSet::FunctionIndex) + break; + + for (AttributeSet::iterator I = AS.begin(Idx), E = AS.end(Idx); + I != E; ++I) { + Attribute Attr = *I; + if (!Attr.isStringAttribute()) { + if (!AttrStr.empty()) AttrStr += ' '; + AttrStr += Attr.getAsString(); + } + } + if (!AttrStr.empty()) Out << "; Function Attrs: " << AttrStr << '\n'; } @@ -2142,8 +2157,7 @@ void AssemblyWriter::writeAllAttributeGroups() { for (std::vector >::iterator I = asVec.begin(), E = asVec.end(); I != E; ++I) Out << "attributes #" << I->second << " = { " - << I->first.getAsString(AttributeSet::FunctionIndex, true, true) - << " }\n"; + << I->first.getAsString(AttributeSet::FunctionIndex, true) << " }\n"; } //===----------------------------------------------------------------------===// diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h index 2f7b4491b23..0b6228b331e 100644 --- a/lib/IR/AttributeImpl.h +++ b/lib/IR/AttributeImpl.h @@ -178,7 +178,7 @@ public: unsigned getAlignment() const; unsigned getStackAlignment() const; - std::string getAsString(bool TargetIndependent, bool InAttrGrp) const; + std::string getAsString(bool InAttrGrp) const; typedef SmallVectorImpl::iterator iterator; typedef SmallVectorImpl::const_iterator const_iterator; diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 2443b3401d4..4fe6f9ddc59 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -483,16 +483,13 @@ unsigned AttributeSetNode::getStackAlignment() const { return 0; } -std::string AttributeSetNode::getAsString(bool TargetIndependent, - bool InAttrGrp) const { +std::string AttributeSetNode::getAsString(bool InAttrGrp) const { std::string Str; for (SmallVectorImpl::const_iterator I = AttrList.begin(), E = AttrList.end(); I != E; ++I) { - if (TargetIndependent || !I->isStringAttribute()) { - if (I != AttrList.begin()) - Str += ' '; - Str += I->getAsString(InAttrGrp); - } + if (I != AttrList.begin()) + Str += ' '; + Str += I->getAsString(InAttrGrp); } return Str; } @@ -848,10 +845,10 @@ unsigned AttributeSet::getStackAlignment(unsigned Index) const { return ASN ? ASN->getStackAlignment() : 0; } -std::string AttributeSet::getAsString(unsigned Index, bool TargetIndependent, +std::string AttributeSet::getAsString(unsigned Index, bool InAttrGrp) const { AttributeSetNode *ASN = getAttributes(Index); - return ASN ? ASN->getAsString(TargetIndependent, InAttrGrp) : std::string(""); + return ASN ? ASN->getAsString(InAttrGrp) : std::string(""); } /// \brief The attributes for the specified index are returned.