[llvm-bugs] [Bug 39900] New: DebugInfo: SCCP loses debug info for constant globals

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 5 15:49:34 PST 2018


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: unassignedbugs at nondot.org
          Reporter: dblaikie at gmail.com
                CC: aprantl at apple.com, jdevlieghere at apple.com,
                    keith.walker at arm.com, llvm-bugs at lists.llvm.org,
                    paul_robinson at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181205/0345d188/attachment.html>


More information about the llvm-bugs mailing list