Skip to content

Commit

Permalink
[MIR] Fix a bug in MIR printer.
Browse files Browse the repository at this point in the history
- Need to skip the assignment of `ID`, which is used to index that two
  object arrays.
  • Loading branch information
darkbuck committed May 6, 2020
1 parent f7060f4 commit e38018b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions llvm/lib/CodeGen/MIRPrinter.cpp
Expand Up @@ -365,7 +365,7 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
// Process fixed stack objects.
unsigned ID = 0;
for (int I = MFI.getObjectIndexBegin(); I < 0; ++I, ++ID) {
for (int I = MFI.getObjectIndexBegin(); I < 0; ++I) {
if (MFI.isDeadObjectIndex(I))
continue;

Expand All @@ -383,11 +383,13 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
YMF.FixedStackObjects.push_back(YamlObject);
StackObjectOperandMapping.insert(
std::make_pair(I, FrameIndexOperand::createFixed(ID)));
++ID;
assert(YMF.FixedStackObjects.size() == ID);
}

// Process ordinary stack objects.
ID = 0;
for (int I = 0, E = MFI.getObjectIndexEnd(); I < E; ++I, ++ID) {
for (int I = 0, E = MFI.getObjectIndexEnd(); I < E; ++I) {
if (MFI.isDeadObjectIndex(I))
continue;

Expand All @@ -409,6 +411,8 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
YMF.StackObjects.push_back(YamlObject);
StackObjectOperandMapping.insert(std::make_pair(
I, FrameIndexOperand::create(YamlObject.Name.Value, ID)));
++ID;
assert(YMF.StackObjects.size() == ID);
}

for (const auto &CSInfo : MFI.getCalleeSavedInfo()) {
Expand Down

1 comment on commit e38018b

@jayfoad
Copy link
Contributor

@jayfoad jayfoad commented on e38018b May 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing:

FAIL: LLVM :: CodeGen/PowerPC/stack-coloring-vararg.mir (1 of 1)
******************** TEST 'LLVM :: CodeGen/PowerPC/stack-coloring-vararg.mir' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/jayfoad2/llvm-debug/bin/llc -run-pass=stack-coloring /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir -o - | /home/jayfoad2/llvm-debug/bin/FileCheck /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
--
Exit Code: 1

Command Output (stderr):
--
+ : 'RUN: at line 1'
+ /home/jayfoad2/llvm-debug/bin/llc -run-pass=stack-coloring /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir -o -
+ /home/jayfoad2/llvm-debug/bin/FileCheck /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
/home/jayfoad2/git/llvm-project/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir:11:10: error: CHECK: expected string not found in input
# CHECK: - { id: 2,
         ^
<stdin>:124:13: note: scanning from here
 - { id: 0, name: buf.i.i, type: default, offset: 0, size: 1024, alignment: 8, 
            ^
<stdin>:127:2: note: possible intended match here
 - { id: 1, name: '', type: default, offset: 0, size: 96, alignment: 8, 
 ^

--

Please sign in to comment.