Skip to content

Commit

Permalink
MIR: Preserve incoming frame index numbers
Browse files Browse the repository at this point in the history
Don't skip incrementing the frame index number
if the object is dead. Instructions can still be
referencing the old frame index number, and this
doesn't attempt to remap those. The resulting
MIR then fails to load because the use instructions
use a higher frame index number than recorded
list of stack objects.

I'm not sure it's possible to craft a testcase
with the existing set of passes. It requires
selectively marking some stack objects
dead in an essentially random order.
StackSlotColoring condenses towards
the low indexes. This avoids a regression in a
future AMDGPU commit when some frame indexes
are lowered separately from PEI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354688 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
arsenm committed Feb 22, 2019
1 parent 664a45f commit 47564d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/CodeGen/MIRPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,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) {
for (int I = MFI.getObjectIndexBegin(); I < 0; ++I, ++ID) {
if (MFI.isDeadObjectIndex(I))
continue;

Expand All @@ -368,12 +368,12 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
YamlObject.IsAliased = MFI.isAliasedObjectIndex(I);
YMF.FixedStackObjects.push_back(YamlObject);
StackObjectOperandMapping.insert(
std::make_pair(I, FrameIndexOperand::createFixed(ID++)));
std::make_pair(I, FrameIndexOperand::createFixed(ID)));
}

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

Expand All @@ -394,7 +394,7 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,

YMF.StackObjects.push_back(YamlObject);
StackObjectOperandMapping.insert(std::make_pair(
I, FrameIndexOperand::create(YamlObject.Name.Value, ID++)));
I, FrameIndexOperand::create(YamlObject.Name.Value, ID)));
}

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

0 comments on commit 47564d4

Please sign in to comment.