Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/TypeSwitch.h"

using namespace mlir;
Expand Down Expand Up @@ -58,7 +59,9 @@ void LLVMStructType::print(AsmPrinter &printer) const {
if (isIdentified()) {
cyclicPrint = printer.tryStartCyclicPrint(*this);

printer << '"' << getName() << '"';
printer << '"';
llvm::printEscapedString(getName(), printer.getStream());
printer << '"';
// If we are printing a reference to one of the enclosing structs, just
// print the name and stop to avoid infinitely long output.
if (failed(cyclicPrint)) {
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Dialect/LLVMIR/roundtrip.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1045,3 +1045,11 @@ llvm.func @llvm.aarch64.neon.st3.v8i8.p0(vector<8xi8>, vector<8xi8>, vector<8xi8

llvm.mlir.global internal thread_local unnamed_addr @myglobal(-1 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dso_local} : i32
// CHECK: llvm.mlir.global internal thread_local unnamed_addr @myglobal(-1 : i32) {addr_space = 0 : i32, alignment = 4 : i64, dso_local} : i32

// CHECK-LABEL: llvm.func @escapedtypename
llvm.func @escapedtypename() {
%0 = llvm.mlir.constant(1 : i32) : i32
// CHECK: llvm.alloca %0 x !llvm.struct<"bucket<string, double, '\\b'>::Iterator", (ptr, i64, i64)>
%1 = llvm.alloca %0 x !llvm.struct<"bucket<string, double, '\\b'>::Iterator", (ptr, i64, i64)> {alignment = 8 : i64} : (i32) -> !llvm.ptr
llvm.return
}
11 changes: 11 additions & 0 deletions mlir/test/Target/LLVMIR/Import/struct.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

; RUN: mlir-translate -import-llvm -split-input-file %s | FileCheck %s

%"bucket<string, double, '\\b'>::Iterator" = type { ptr, i64, i64 }

; CHECK-LABEL: llvm.func @g
define void @g() {
%item.i = alloca %"bucket<string, double, '\\b'>::Iterator", align 8
; CHECK: llvm.alloca %0 x !llvm.struct<"bucket<string, double, '\\b'>::Iterator", (ptr, i64, i64)> {alignment = 8 : i64} : (i32) -> !llvm.ptr
ret void
}