From 8445cbd1ca964ff490268e0854ecafaf97718639 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 21 Mar 2017 21:58:08 +0000 Subject: SplitKit: Fix subreg copy related problems Fix two problems related to r298025: - SplitKit would create duplicate VNIs in some cases leading to crashs when hoisting copies. - VirtRegMap could fail expanding copies at the beginning of a basic block. This fixes http://llvm.org/PR32353 llvm-svn: 298448 --- llvm/lib/CodeGen/VirtRegMap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/VirtRegMap.cpp') diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp index 06a97fd6d4d..c8946010e9d 100644 --- a/llvm/lib/CodeGen/VirtRegMap.cpp +++ b/llvm/lib/CodeGen/VirtRegMap.cpp @@ -383,8 +383,10 @@ void VirtRegRewriter::expandCopyBundle(MachineInstr &MI) const { if (MI.isBundledWithPred() && !MI.isBundledWithSucc()) { // Only do this when the complete bundle is made out of COPYs. + MachineBasicBlock &MBB = *MI.getParent(); for (MachineBasicBlock::reverse_instr_iterator I = - std::next(MI.getReverseIterator()); I->isBundledWithSucc(); ++I) { + std::next(MI.getReverseIterator()), E = MBB.instr_rend(); + I != E && I->isBundledWithSucc(); ++I) { if (!I->isCopy()) return; } -- cgit v1.2.3