[PATCH] D69606: [MachineBasicBlock] Skip over debug instructions in computeRegisterLiveness before checking for begin/end.

Chris Ye via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 18:39:47 PDT 2019


yechunliang added a comment.

Look at the debugging printf information, I found the begin() is the first instruction of the BasicBlock, but the end() is not the last instruction, it's something unknown or none flag. 
If what I found is correct, and would say end() could not be debug instruction,  and  maybe we needn't consider about debug instruction impact for end() part.



================
Comment at: llvm/lib/CodeGen/MachineBasicBlock.cpp:1410-1411
+  // Skip over debug instructions.
+  if (I != end() && I->isDebugInstr())
+    ++I;
+
----------------
efriedma wrote:
> craig.topper wrote:
> > yechunliang wrote:
> > > Does this code duplicated with the line: 1392-1394?
> > > 
> > > ```
> > >  for (; I != end() && N > 0; ++I) {
> > >     if (I->isDebugInstr())
> > >       continue;
> > > ```
> > > 
> > But that code stops when N is 0. So we can exit the loop without being at end() and have debug instructions after right?
> Yes, but it's probably better to refactor the loop to use an an early exit, or something like that.
Before N--, the above code " if (I->isDebugInstr()) continue" will skip the DebugInstr. So the variable  "I" could not be DebugInstr when N=0.
So when case N=0, the variable "I" should be real instruction. And Line 1409-1411 will be duplicate. 




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69606/new/

https://reviews.llvm.org/D69606





More information about the llvm-commits mailing list