diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -3337,10 +3337,14 @@ std::string AttrStr; for (const Attribute &Attr : AS) { - if (!Attr.isStringAttribute()) { - if (!AttrStr.empty()) AttrStr += ' '; - AttrStr += Attr.getAsString(); - } + bool IsStringAttr = Attr.isStringAttribute(); + auto AttrKeyStr = Attr.getAsString(); + // Filter string attributes based on the size of key + value. This is a heuristic. + if (IsStringAttr && (AttrKeyStr.size() > 15 + /* quotes */ 4 + /* equal sign */ 1)) + continue; + if (!AttrStr.empty()) + AttrStr += ' '; + AttrStr += AttrKeyStr; } if (!AttrStr.empty()) diff --git a/llvm/test/Bitcode/attributes.ll b/llvm/test/Bitcode/attributes.ll --- a/llvm/test/Bitcode/attributes.ll +++ b/llvm/test/Bitcode/attributes.ll @@ -204,7 +204,7 @@ ; CHECK: define void @f34() { call void @nobuiltin() nobuiltin -; CHECK: call void @nobuiltin() #36 +; CHECK: call void @nobuiltin() #37 ret void; } @@ -351,6 +351,14 @@ ret void } +; CHECK: Function Attrs: "short"="option" +; CHECK-NOT: long +; CHECK-NEXT: define void @f60() #36 +define void @f60() #0 +{ + ret void +} + ; CHECK: attributes #0 = { noreturn } ; CHECK: attributes #1 = { nounwind } ; CHECK: attributes #2 = { readnone } @@ -387,4 +395,7 @@ ; CHECK: attributes #33 = { speculatable } ; CHECK: attributes #34 = { sanitize_hwaddress } ; CHECK: attributes #35 = { shadowcallstack } -; CHECK: attributes #36 = { nobuiltin } +; CHECK: attributes #36 = { "long"="options_are_excluded" "short"="option" } +; CHECK: attributes #37 = { nobuiltin } + +attributes #0 = { "long"="options_are_excluded" "short"="option" }