[PATCH] D66467: [Codegen] skip debug instr to avoid code change

Chris Ye via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 04:02:32 PDT 2019


yechunliang created this revision.
yechunliang added reviewers: jmorse, gbedwell.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Skip debugging instruction and CFI_INSTRUCTION to avoid different codegen with/without -g. Most of ComputeCommonTailLength uses the "countsAsInstruction" helper to skip over debug instructions, but the last two loops don't.

the bug is reported in
https://bugs.llvm.org/show_bug.cgi?id=42138


Repository:
  rL LLVM

https://reviews.llvm.org/D66467

Files:
  llvm/lib/CodeGen/BranchFolding.cpp


Index: llvm/lib/CodeGen/BranchFolding.cpp
===================================================================
--- llvm/lib/CodeGen/BranchFolding.cpp
+++ llvm/lib/CodeGen/BranchFolding.cpp
@@ -396,11 +396,12 @@
   // 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;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66467.216094.patch
Type: text/x-patch
Size: 754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190820/5e411102/attachment.bin>


More information about the llvm-commits mailing list