diff options
author | Eric Christopher <echristo@gmail.com> | 2015-11-20 00:34:54 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-11-20 00:34:54 +0000 |
commit | eb027124afc07b00c85a141b1f03b29a5681f840 (patch) | |
tree | ec63e2c149446887dca8e5947b5170034e70130c /llvm/lib | |
parent | 586d24bbf23ff9b29545952300f2fc70331f1f3d (diff) | |
download | bcm5719-llvm-eb027124afc07b00c85a141b1f03b29a5681f840.tar.gz bcm5719-llvm-eb027124afc07b00c85a141b1f03b29a5681f840.zip |
Split the argument unscheduling loop in the WebAssembly register
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
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp index 7f27e7cede6..bf21024a731 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp @@ -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) { |