diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1410,8 +1410,11 @@ 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());