diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2019-10-29 11:38:20 +0000 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2019-10-29 11:45:38 +0000 |
commit | ec32dff0b075055b30140c543e9f2bef608adc14 (patch) | |
tree | f3a953d6c5dc7bd52bf05e2ba5c1812f94ff01d8 /llvm/lib/CodeGen | |
parent | dc63d6175aa5692db1670dc9ee7a1f304e752d87 (diff) | |
download | llvm-ec32dff0b075055b30140c543e9f2bef608adc14.zip llvm-ec32dff0b075055b30140c543e9f2bef608adc14.tar.gz llvm-ec32dff0b075055b30140c543e9f2bef608adc14.tar.bz2 |
[BranchFolding] skip debug instr to avoid code change
Use the existing helper function in BranchFolding, "countsAsInstruction",
to skip over non-instructions. Otherwise debug instructions can be
identified as the last real instruction in a block, leading to different
codegen decisions when debug is enabled as demonstrated by the test case.
Patch by: yechunliang (Chris Ye)!
Differential Revision: https://reviews.llvm.org/D66467
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 455916e..b6e7c9f4 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -402,11 +402,12 @@ SkipTopCFIAndReturn: // the CFI instruction. Later on, this leads to BB2 being 'hacked off' at the // wrong place (in ReplaceTailWithBranchTo()) which results in losing this CFI // instruction. - while (I1 != MBB1->end() && I1->isCFIInstruction()) { + // Skip CFI_INSTRUCTION and debugging instruction; necessary to avoid changing the code. + while (I1 != MBB1->end() && !countsAsInstruction(*I1)) { ++I1; } - while (I2 != MBB2->end() && I2->isCFIInstruction()) { + while (I2 != MBB2->end() && !countsAsInstruction(*I2)) { ++I2; } |