[PATCH] D73065: Fix printer for llvm.addressof symbol name that need escaping
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 13:13:48 PST 2020
mehdi_amini created this revision.
mehdi_amini added a reviewer: rriddle.
Herald added subscribers: llvm-commits, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar.
Herald added a reviewer: nicolasvasilache.
Herald added a project: LLVM.
rriddle accepted this revision.
This revision is now accepted and ready to land.
Using `printSymbolName()` helper for printing symbol name will handle symbols
that require escaping/quoting.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73065
Files:
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/test/Dialect/LLVMIR/global.mlir
Index: mlir/test/Dialect/LLVMIR/global.mlir
===================================================================
--- mlir/test/Dialect/LLVMIR/global.mlir
+++ mlir/test/Dialect/LLVMIR/global.mlir
@@ -6,8 +6,8 @@
// CHECK: llvm.mlir.global internal constant @constant(3.700000e+01 : f64) : !llvm.float
llvm.mlir.global internal constant @constant(37.0) : !llvm.float
-// CHECK: llvm.mlir.global internal constant @string("foobar")
-llvm.mlir.global internal constant @string("foobar") : !llvm<"[6 x i8]">
+// CHECK: llvm.mlir.global internal constant @".string"("foobar")
+llvm.mlir.global internal constant @".string"("foobar") : !llvm<"[6 x i8]">
// CHECK: llvm.mlir.global internal @string_notype("1234567")
llvm.mlir.global internal @string_notype("1234567")
@@ -51,8 +51,8 @@
// CHECK: llvm.mlir.addressof @global : !llvm<"i64*">
%0 = llvm.mlir.addressof @global : !llvm<"i64*">
- // CHECK: llvm.mlir.addressof @string : !llvm<"[6 x i8]*">
- %1 = llvm.mlir.addressof @string : !llvm<"[6 x i8]*">
+ // CHECK: llvm.mlir.addressof @".string" : !llvm<"[6 x i8]*">
+ %1 = llvm.mlir.addressof @".string" : !llvm<"[6 x i8]*">
llvm.return
}
Index: mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
===================================================================
--- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -767,7 +767,8 @@
}
static void printAddressOfOp(OpAsmPrinter &p, AddressOfOp op) {
- p << op.getOperationName() << " @" << op.global_name();
+ p << op.getOperationName() << " ";
+ p.printSymbolName(op.global_name());
p.printOptionalAttrDict(op.getAttrs(), {"global_name"});
p << " : " << op.getResult().getType();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73065.239194.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200120/79c73d4f/attachment.bin>
More information about the llvm-commits
mailing list