Skip to content

Commit

Permalink
Split the argument unscheduling loop in the WebAssembly register
Browse files Browse the repository at this point in the history
coloring pass. Turn the logic into "look for an insert point and
then move things past the insert point".

No functional change intended.

llvm-svn: 253626
  • Loading branch information
echristo committed Nov 20, 2015
1 parent 586d24b commit eb02712
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,30 @@ bool WebAssemblyRegColoring::runOnMachineFunction(MachineFunction &MF) {

// FIXME: If scheduling has moved an ARGUMENT virtual register, move it back,
// and recompute liveness. This is a temporary hack.
bool SawNonArg = false;
bool MovedArg = false;
MachineBasicBlock &EntryMBB = MF.front();
for (auto MII = EntryMBB.begin(); MII != EntryMBB.end(); ) {
MachineInstr *MI = &*MII++;
MachineBasicBlock::iterator InsertPt = EntryMBB.end();
// Look for the first NonArg instruction.
for (auto MII = EntryMBB.begin(), MIE = EntryMBB.end(); MII != MIE; ++MII) {
MachineInstr *MI = MII;
if (MI->getOpcode() != WebAssembly::ARGUMENT_I32 &&
MI->getOpcode() != WebAssembly::ARGUMENT_I64 &&
MI->getOpcode() != WebAssembly::ARGUMENT_F32 &&
MI->getOpcode() != WebAssembly::ARGUMENT_F64) {
InsertPt = MII;
break;
}
}
// Now move any argument instructions later in the block
// to before our first NonArg instruction.
for (auto I = InsertPt, E = EntryMBB.end(); I != E; ++I) {
MachineInstr *MI = I;
if (MI->getOpcode() == WebAssembly::ARGUMENT_I32 ||
MI->getOpcode() == WebAssembly::ARGUMENT_I64 ||
MI->getOpcode() == WebAssembly::ARGUMENT_F32 ||
MI->getOpcode() == WebAssembly::ARGUMENT_F64) {
EntryMBB.insert(EntryMBB.begin(), MI->removeFromParent());
if (SawNonArg)
MovedArg = true;
} else {
SawNonArg = true;
EntryMBB.insert(InsertPt, MI->removeFromParent());
MovedArg = true;
}
}
if (MovedArg) {
Expand Down

0 comments on commit eb02712

Please sign in to comment.