[Mlir-commits] [mlir] 524eafa - [MLIR] Avoid double space print on llvm global op

Uday Bondhugula llvmlistbot at llvm.org
Thu Sep 9 07:23:28 PDT 2021


Author: Uday Bondhugula
Date: 2021-09-09T19:52:38+05:30
New Revision: 524eafa5b20285ea26351113a46ce4a5299e4ff8

URL: https://github.com/llvm/llvm-project/commit/524eafa5b20285ea26351113a46ce4a5299e4ff8
DIFF: https://github.com/llvm/llvm-project/commit/524eafa5b20285ea26351113a46ce4a5299e4ff8.diff

LOG: [MLIR] Avoid double space print on llvm global op

Fix extra space print for llvm global op when the 'unamed_addr'
attribute was empty. This led to two spaces being printed in the custom
form between non-whitespace chars. A round trip would add an extra space
to a typical spaced form. NFC.

Differential Revision: https://reviews.llvm.org/D109502

Added: 
    

Modified: 
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 28cebbd5772ed..18eec0e195ecd 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1410,8 +1410,11 @@ void GlobalOp::build(OpBuilder &builder, OperationState &result, Type type,
 
 static void printGlobalOp(OpAsmPrinter &p, GlobalOp op) {
   p << ' ' << stringifyLinkage(op.linkage()) << ' ';
-  if (op.unnamed_addr())
-    p << stringifyUnnamedAddr(*op.unnamed_addr()) << ' ';
+  if (auto unnamedAddr = op.unnamed_addr()) {
+    StringRef str = stringifyUnnamedAddr(*unnamedAddr);
+    if (!str.empty())
+      p << str << ' ';
+  }
   if (op.constant())
     p << "constant ";
   p.printSymbolName(op.sym_name());


        


More information about the Mlir-commits mailing list