[llvm] f42bc84 - [AsmWriter] Simplify type attribute printing (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 7 13:54:24 PDT 2021
Author: Nikita Popov
Date: 2021-07-07T22:47:33+02:00
New Revision: f42bc8424e775e96bcf35925e80df26179418faa
URL: https://github.com/llvm/llvm-project/commit/f42bc8424e775e96bcf35925e80df26179418faa
DIFF: https://github.com/llvm/llvm-project/commit/f42bc8424e775e96bcf35925e80df26179418faa.diff
LOG: [AsmWriter] Simplify type attribute printing (NFC)
Avoid enumerating all supported type attributes, instead fetch
their name from the attribute kind.
Added:
Modified:
llvm/lib/IR/AsmWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 66c93b6e6af2..ea860338e253 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4416,20 +4416,7 @@ void AssemblyWriter::writeAttribute(const Attribute &Attr, bool InAttrGroup) {
return;
}
- if (Attr.hasAttribute(Attribute::ByVal)) {
- Out << "byval";
- } else if (Attr.hasAttribute(Attribute::StructRet)) {
- Out << "sret";
- } else if (Attr.hasAttribute(Attribute::ByRef)) {
- Out << "byref";
- } else if (Attr.hasAttribute(Attribute::Preallocated)) {
- Out << "preallocated";
- } else if (Attr.hasAttribute(Attribute::InAlloca)) {
- Out << "inalloca";
- } else {
- llvm_unreachable("unexpected type attr");
- }
-
+ Out << Attribute::getNameFromAttrKind(Attr.getKindAsEnum());
if (Type *Ty = Attr.getValueAsType()) {
Out << '(';
TypePrinter.print(Ty, Out);
More information about the llvm-commits
mailing list