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
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 @@
   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 @@
   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.