diff options
author | Dale Johannesen <dalej@apple.com> | 2010-03-08 05:38:13 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2010-03-08 05:38:13 +0000 |
commit | 84839daa595968286acd25644820c644867f0c52 (patch) | |
tree | 83af7c21f67dc9fde590e45be9d6978af69a2417 /lib/CodeGen | |
parent | 9a1ac4c107489b65d92c541acf182000818a900a (diff) | |
download | external_llvm-84839daa595968286acd25644820c644867f0c52.zip external_llvm-84839daa595968286acd25644820c644867f0c52.tar.gz external_llvm-84839daa595968286acd25644820c644867f0c52.tar.bz2 |
Fix dbg value handling in tail merging.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/BranchFolding.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index d94729a..a937e8f 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -310,12 +310,23 @@ static unsigned HashEndOfMBB(const MachineBasicBlock *MBB, return 0; // Empty MBB. --I; + // Skip debug info so it will not affect codegen. + while (I->isDebugValue()) { + if (I==MBB->begin()) + return 0; // MBB empty except for debug info. + --I; + } unsigned Hash = HashMachineInstr(I); if (I == MBB->begin() || minCommonTailLength == 1) return Hash; // Single instr MBB. --I; + while (I->isDebugValue()) { + if (I==MBB->begin()) + return Hash; // MBB with single non-debug instr. + --I; + } // Hash in the second-to-last instruction. Hash ^= HashMachineInstr(I) << 2; return Hash; @@ -334,9 +345,18 @@ static unsigned ComputeCommonTailLength(MachineBasicBlock *MBB1, unsigned TailLen = 0; while (I1 != MBB1->begin() && I2 != MBB2->begin()) { --I1; --I2; - // Don't merge debugging pseudos. - if (I1->isDebugValue() || I2->isDebugValue() || - !I1->isIdenticalTo(I2) || + // Skip debugging pseudos; necessary to avoid changing the code. + while (I1->isDebugValue()) { + if (I1==MBB1->begin()) + return TailLen; + --I1; + } + while (I2->isDebugValue()) { + if (I2==MBB2->begin()) + return TailLen; + --I2; + } + if (!I1->isIdenticalTo(I2) || // FIXME: This check is dubious. It's used to get around a problem where // people incorrectly expect inline asm directives to remain in the same // relative order. This is untenable because normal compiler @@ -643,6 +663,8 @@ unsigned BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB, SameTails[commonTailIndex].getTailStartPos(); MachineBasicBlock *MBB = SameTails[commonTailIndex].getBlock(); + // If the common tail includes any debug info we will take it pretty + // randomly from one of the inputs. Might be better to remove it? DEBUG(dbgs() << "\nSplitting BB#" << MBB->getNumber() << ", size " << maxCommonTailLength); |