[llvm-branch-commits] [llvm] b9a7c89 - [MIRPrinter] Fix incorrect output of unnamed stack names
Mikael Holmen via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 28 09:06:45 PST 2020
Author: Gabriel Hjort Ã…kerlund
Date: 2020-12-28T18:01:40+01:00
New Revision: b9a7c89d4322b261b65eb96d678a9d38b776cb60
URL: https://github.com/llvm/llvm-project/commit/b9a7c89d4322b261b65eb96d678a9d38b776cb60
DIFF: https://github.com/llvm/llvm-project/commit/b9a7c89d4322b261b65eb96d678a9d38b776cb60.diff
LOG: [MIRPrinter] Fix incorrect output of unnamed stack names
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.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D93685
Added:
llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll
Modified:
llvm/lib/CodeGen/MIRPrinter.cpp
llvm/test/CodeGen/PowerPC/alloca-crspill.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 25f785342d04..eae174019b56 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -415,7 +415,7 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
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)
diff --git a/llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll b/llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll
new file mode 100644
index 000000000000..c7e87e3f62a6
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll
@@ -0,0 +1,23 @@
+; RUN: llc -O0 -march aarch64 -global-isel -stop-after=irtranslator -o - %s | llc -x mir -march aarch64 -run-pass=none -o - | FileCheck %s
+
+define i16 @unnamed_stack() {
+entry:
+ ; CHECK-NAME: unnamed_stack
+ ; CHECK: stack:
+ ; CHECK-NEXT: - { id: 0, name: '',
+ ; 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: stack:
+ ; CHECK-NEXT: - { id: 0, name: ptr,
+ ; CHECK: %0:_(p0) = G_FRAME_INDEX %stack.0.ptr
+ %ptr = alloca i16
+ %0 = load i16, i16* %ptr
+ ret i16 %0
+}
diff --git a/llvm/test/CodeGen/PowerPC/alloca-crspill.ll b/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
index f52e305fb05c..b71a9ff6d49b 100644
--- a/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
+++ b/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
@@ -49,8 +49,8 @@ declare signext i32 @do_something(double*)
; CHECK64-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
; CHECK64-NEXT: stack:
-; CHECK64-NEXT: - { id: 0, name: '<unnamed alloca>', type: variable-sized, offset: -8,
-; CHECK64-NEXT: alignment: 1, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
+; CHECK64-NEXT: - { id: 0, name: '', type: variable-sized, offset: -8, alignment: 1,
+; CHECK64-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true,
; CHECK64-NEXT: local-offset: 0, debug-info-variable: '', debug-info-expression: '',
; CHECK64-NEXT: debug-info-location: '' }
; CHECK64-NEXT: - { id: 1, name: '', type: default, offset: -16, size: 8, alignment: 8,
@@ -68,8 +68,8 @@ declare signext i32 @do_something(double*)
; CHECK32-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
; CHECK32-NEXT: stack:
-; CHECK32-NEXT: - { id: 0, name: '<unnamed alloca>', type: variable-sized, offset: -4,
-; CHECK32-NEXT: alignment: 1, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
+; CHECK32-NEXT: - { id: 0, name: '', type: variable-sized, offset: -4, alignment: 1,
+; CHECK32-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true,
; CHECK32-NEXT: local-offset: 0, debug-info-variable: '', debug-info-expression: '',
; CHECK32-NEXT: debug-info-location: '' }
; CHECK32-NEXT: - { id: 1, name: '', type: default, offset: -8, size: 4, alignment: 4,
More information about the llvm-branch-commits
mailing list