diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-04-29 18:23:53 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-04-29 18:23:53 +0000 |
commit | f2e83499fcc41484cb5dac073c4fe87525926d2b (patch) | |
tree | 2d205544b2ec8660278d784271682551ed4848ea /lib/IR | |
parent | d2755af8bda2e0fd80efb46556485c4cdbe8704a (diff) | |
download | external_llvm-f2e83499fcc41484cb5dac073c4fe87525926d2b.zip external_llvm-f2e83499fcc41484cb5dac073c4fe87525926d2b.tar.gz external_llvm-f2e83499fcc41484cb5dac073c4fe87525926d2b.tar.bz2 |
Revert "revert r179735, it has no testcases, and doesn't really make sense."
This un-reverts r179735 and reverts commit r180574.
This fixes assertion failures for me locally and should fix the failures
on Windows reported widely on llvm-dev. We should check if the bots
caught this and if so why not.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/AsmWriter.cpp | 42 | ||||
-rw-r--r-- | lib/IR/AttributeImpl.h | 2 | ||||
-rw-r--r-- | lib/IR/Attributes.cpp | 16 |
3 files changed, 32 insertions, 28 deletions
diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 7761127..5e9c520 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -33,6 +33,7 @@ #include "llvm/IR/TypeFinder.h" #include "llvm/IR/ValueSymbolTable.h" #include "llvm/Support/CFG.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" @@ -42,6 +43,12 @@ #include <cctype> using namespace llvm; +static cl::opt<bool> +OldStyleAttrSyntax("enable-old-style-attr-syntax", + cl::desc("Output attributes on functions rather than in attribute groups"), + cl::Hidden, + cl::init(false)); + // Make virtual table appear in this compilation unit. AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {} @@ -1378,7 +1385,7 @@ void AssemblyWriter::printModule(const Module *M) { printFunction(I); // Output all attribute groups. - if (!Machine.as_empty()) { + if (!OldStyleAttrSyntax && !Machine.as_empty()) { Out << '\n'; writeAllAttributeGroups(); } @@ -1606,24 +1613,9 @@ void AssemblyWriter::printFunction(const Function *F) { Out << "; Materializable\n"; const AttributeSet &Attrs = F->getAttributes(); - if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) { + if (!OldStyleAttrSyntax && Attrs.hasAttributes(AttributeSet::FunctionIndex)) { AttributeSet AS = Attrs.getFnAttributes(); - 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(); - } - } - + std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, false); if (!AttrStr.empty()) Out << "; Function Attrs: " << AttrStr << '\n'; } @@ -1685,8 +1677,15 @@ void AssemblyWriter::printFunction(const Function *F) { Out << ')'; if (F->hasUnnamedAddr()) Out << " unnamed_addr"; - if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) - Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes()); + if (!OldStyleAttrSyntax) { + if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) + Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes()); + } else { + AttributeSet AS = Attrs.getFnAttributes(); + std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, false); + if (!AttrStr.empty()) + Out << ' ' << AttrStr; + } if (F->hasSection()) { Out << " section \""; PrintEscapedString(F->getSection(), Out); @@ -2157,7 +2156,8 @@ void AssemblyWriter::writeAllAttributeGroups() { for (std::vector<std::pair<AttributeSet, unsigned> >::iterator I = asVec.begin(), E = asVec.end(); I != E; ++I) Out << "attributes #" << I->second << " = { " - << I->first.getAsString(AttributeSet::FunctionIndex, true) << " }\n"; + << I->first.getAsString(AttributeSet::FunctionIndex, true, true) + << " }\n"; } //===----------------------------------------------------------------------===// diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h index 8e9c30d..b17aa43 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 InAttrGrp) const; + std::string getAsString(bool TargetIndependent, bool InAttrGrp) const; typedef SmallVectorImpl<Attribute>::iterator iterator; typedef SmallVectorImpl<Attribute>::const_iterator const_iterator; diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 8347844..80968db 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -483,13 +483,16 @@ unsigned AttributeSetNode::getStackAlignment() const { return 0; } -std::string AttributeSetNode::getAsString(bool InAttrGrp) const { +std::string AttributeSetNode::getAsString(bool TargetIndependent, + bool InAttrGrp) const { std::string Str; for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(), E = AttrList.end(); I != E; ++I) { - if (I != AttrList.begin()) - Str += ' '; - Str += I->getAsString(InAttrGrp); + if (TargetIndependent || !I->isStringAttribute()) { + if (I != AttrList.begin()) + Str += ' '; + Str += I->getAsString(InAttrGrp); + } } return Str; } @@ -845,10 +848,11 @@ unsigned AttributeSet::getStackAlignment(unsigned Index) const { return ASN ? ASN->getStackAlignment() : 0; } -std::string AttributeSet::getAsString(unsigned Index, +std::string AttributeSet::getAsString(unsigned Index, bool TargetIndependent, bool InAttrGrp) const { AttributeSetNode *ASN = getAttributes(Index); - return ASN ? ASN->getAsString(InAttrGrp) : std::string(""); + return ASN ? ASN->getAsString(TargetIndependent, InAttrGrp) : + std::string(""); } /// \brief The attributes for the specified index are returned. |