[PATCH] D93685: [MIRPrinter] Fix incorrect output of unnamed stack names

Gabriel Hjort Ã…kerlund via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 22 03:29:11 PST 2020


ehjogab created this revision.
Herald added subscribers: bjope, hiraditya.
ehjogab requested review of this revision.
Herald added a project: LLVM.

The MIRParser expects unnamed stack entries to have empty names ('').
In case of unnamed alloca instructions, the MIRPrinter would output
'<unnamed alloca>', which caused the MIRParser to reject the generated
code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93685

Files:
  llvm/lib/CodeGen/MIRPrinter.cpp
  llvm/test/CodeGen/MIR/Generic/unnamed-stack.ll


Index: llvm/test/CodeGen/MIR/Generic/unnamed-stack.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/MIR/Generic/unnamed-stack.ll
@@ -0,0 +1,19 @@
+; RUN: llc -O0 -march aarch64 -global-isel -stop-after=irtranslator -o %t.mir %s && llc -march aarch64 -run-pass=none -o - %t.mir | FileCheck %s
+
+define i16 @unnamed_stack() {
+entry:
+  ; CHECK-NAME: unnamed_stack
+  ; CHECK:      %0:_(p0) = G_FRAME_INDEX %stack.0
+  %0 = alloca i16
+  %1 = load i16, i16* %0
+  ret i16 %1
+}
+
+define i16 @named_stack() {
+entry:
+  ; CHECK-NAME: named_stack
+  ; CHECK:      %0:_(p0) = G_FRAME_INDEX %stack.0.ptr
+  %ptr = alloca i16
+  %0 = load i16, i16* %ptr
+  ret i16 %0
+}
Index: llvm/lib/CodeGen/MIRPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/MIRPrinter.cpp
+++ llvm/lib/CodeGen/MIRPrinter.cpp
@@ -415,7 +415,7 @@
     YamlObject.ID = ID;
     if (const auto *Alloca = MFI.getObjectAllocation(I))
       YamlObject.Name.Value = std::string(
-          Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>");
+          Alloca->hasName() ? Alloca->getName() : "");
     YamlObject.Type = MFI.isSpillSlotObjectIndex(I)
                           ? yaml::MachineStackObject::SpillSlot
                           : MFI.isVariableSizedObjectIndex(I)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93685.313282.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201222/ebafda98/attachment.bin>


More information about the llvm-commits mailing list