[llvm-bugs] [Bug 24563] New: LiveDebugVariables propagates constant values without joining at bb boundaries

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 24 16:18:49 PDT 2015


            Bug ID: 24563
           Summary: LiveDebugVariables propagates constant values without
                    joining at bb boundaries
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: aprantl at apple.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Found while reviewing http://reviews.llvm.org/D11933

Compiling the following testcase at -O1

void g(int *);
int f() {
  int x = 23;
  if (x == 42)
  return x;

will cause the constant value 23 to be propagated into the last basic block:

BB#2: derived from LLVM BB %if.end
    Predecessors according to CFG: BB#0 BB#1
  DBG_VALUE 23, 0, !"x", <!14>; line no:3
  %EAX<def> = MOV32rm %RSP, 1, %noreg, 4, %noreg; mem:LD4[%x](tbaa=!17)
  %RDX<def> = POP64r %RSP<imp-def>, %RSP<imp-use>; dbg:r.c:7:3
  RETQ %EAX; dbg:r.c:7:3

Looking into this I found that LiveDebugVariables is the culprit here:

  void UserValue::extendDef(SlotIndex Idx, unsigned LocNo,
                            LiveRange *LR, const VNInfo *VNI,
                            SmallVectorImpl<SlotIndex> *Kills,
                            LiveIntervals &LIS, MachineDominatorTree &MDT,
                            UserValueScopes &UVS) {
      for (unsigned i = 0, e = Children.size(); i != e; ++i) {
        MachineBasicBlock *MBB = Children[i]->getBlock();
        if (UVS.dominates(MBB))

It look like it just unconditionally propagates all DBG_VALUEs down the
dominator tree, which happens to work fine if there already is another
DBG_VALUE but is wrong if the DBG_VALUE is coming from only one of the
predecessors like in this example here.

The DBG_VALUES should only end up in a subsequent basic block if they appear at
the end of all predecessors.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150824/1f23b70c/attachment.html>

More information about the llvm-bugs mailing list