https://bugs.llvm.org/show_bug.cgi?id=39900

            Bug ID: 39900
           Summary: DebugInfo: SCCP loses debug info for constant globals
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedb...@nondot.org
          Reporter: dblai...@gmail.com
                CC: apra...@apple.com, jdevliegh...@apple.com,
                    keith.wal...@arm.com, llvm-bugs@lists.llvm.org,
                    paul_robin...@playstation.sony.com

Given this code:

  static int x = 3;
  int z() { return x; }

Unoptimized, the resulting DWARF describes the location of 'x'.

Once optimized by SCCP, the LLVM IR is not updated with a description of the
constant value of 'x', the value is lost entirely.

Looks like down in the final loop (line ~2140) in SCCP.cpp, that's deleting
globals - it could check if there's debug info attached to the GlobalVariable,
and rewrite it to a constant description using I->second.getConstant(), if the
constant is of a type (int or float? I think are the ones currently supported)
that can be encoded as a constant in the debug info metadata at the moment.

This may be incorrect in cases where this optimization fires & due to previous
passes eliminating dead stores to the variable (in which case the dead stores
wouldn't be reflected - though I suppose at that point describing the location
of the variable as being in the global is just as erroneous), but it looks
like, at least if you complicate the case by adding "x = 7;" to z() before the
return, it's not SCCP that optimizes away the GlobalVariable, but GlobalOpt. So
maybe fixing SCCP isn't an issue in this way.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to