1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[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
This commit is contained in:
Gabriel Hjort Åkerlund 2020-12-28 17:41:25 +01:00 committed by Mikael Holmen
parent bb2bb5b29c
commit 1c8a391cbc
3 changed files with 28 additions and 5 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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,