Skip to content

Commit 36c7f40

Browse files
committed
Revert "[VirtRegRewriter] Avoid clobbering registers when expanding copy bundles"
There's an msan failure: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/19549 This reverts r334750. llvm-svn: 334754
1 parent 4663ceb commit 36c7f40

File tree

3 files changed

+7
-142
lines changed

3 files changed

+7
-142
lines changed

llvm/lib/CodeGen/VirtRegMap.cpp

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -406,62 +406,23 @@ void VirtRegRewriter::expandCopyBundle(MachineInstr &MI) const {
406406
return;
407407

408408
if (MI.isBundledWithPred() && !MI.isBundledWithSucc()) {
409-
SmallVector<MachineInstr *, 2> MIs({&MI});
410-
411409
// Only do this when the complete bundle is made out of COPYs.
412410
MachineBasicBlock &MBB = *MI.getParent();
413411
for (MachineBasicBlock::reverse_instr_iterator I =
414412
std::next(MI.getReverseIterator()), E = MBB.instr_rend();
415413
I != E && I->isBundledWithSucc(); ++I) {
416414
if (!I->isCopy())
417415
return;
418-
MIs.push_back(&*I);
419-
}
420-
MachineInstr *FirstMI = MIs.back();
421-
422-
auto anyRegsAlias = [](const MachineInstr *Dst,
423-
ArrayRef<MachineInstr *> Srcs,
424-
const TargetRegisterInfo *TRI) {
425-
for (const MachineInstr *Src : Srcs)
426-
if (Src != Dst)
427-
if (TRI->regsOverlap(Dst->getOperand(0).getReg(),
428-
Src->getOperand(1).getReg()))
429-
return true;
430-
return false;
431-
};
432-
433-
// If any of the destination registers in the bundle of copies alias any of
434-
// the source registers, try to schedule the instructions to avoid any
435-
// clobbering.
436-
for (int E = MIs.size(), PrevE; E > 1; PrevE = E) {
437-
for (int I = E; I--; )
438-
if (!anyRegsAlias(MIs[I], makeArrayRef(MIs).take_front(E), TRI)) {
439-
if (I + 1 != E)
440-
std::swap(MIs[I], MIs[E - 1]);
441-
--E;
442-
}
443-
if (PrevE == E) {
444-
MF->getFunction().getContext().emitError(
445-
"register rewriting failed: cycle in copy bundle");
446-
break;
447-
}
448416
}
449417

450-
MachineInstr *BundleStart = FirstMI;
451-
for (MachineInstr *BundledMI : llvm::reverse(MIs)) {
452-
// If instruction is in the middle of the bundle, move it before the
453-
// bundle starts, otherwise, just unbundle it. When we get to the last
454-
// instruction, the bundle will have been completely undone.
455-
if (BundledMI != BundleStart) {
456-
BundledMI->removeFromBundle();
457-
MBB.insert(FirstMI, BundledMI);
458-
} else if (BundledMI->isBundledWithSucc()) {
459-
BundledMI->unbundleFromSucc();
460-
BundleStart = &*std::next(BundledMI->getIterator());
461-
}
418+
for (MachineBasicBlock::reverse_instr_iterator I = MI.getReverseIterator();
419+
I->isBundledWithPred(); ) {
420+
MachineInstr &MI = *I;
421+
++I;
462422

463-
if (Indexes && BundledMI != FirstMI)
464-
Indexes->insertMachineInstrInMaps(*BundledMI);
423+
MI.unbundleFromPred();
424+
if (Indexes)
425+
Indexes->insertMachineInstrInMaps(MI);
465426
}
466427
}
467428
}

llvm/test/CodeGen/AArch64/overlapping-copy-bundle-cycle.mir

Lines changed: 0 additions & 16 deletions
This file was deleted.

llvm/test/CodeGen/AArch64/overlapping-copy-bundle.mir

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)