[llvm-bugs] [Bug 35530] New: [DI] LLVM loses track of induction variables at -O1 and beyond

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 5 07:15:25 PST 2017


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

            Bug ID: 35530
           Summary: [DI] LLVM loses track of induction variables at -O1
                    and beyond
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: aprantl at apple.com, friss at apple.com,
                    jdevlieghere at apple.com, jingham at apple.com,
                    jmolenda at apple.com, llvm-bugs at lists.llvm.org,
                    vsk at apple.com

Testcase:

$ cat missing.cpp
#include <atomic>
#include <limits.h>
#include <stdint.h>

int
main(void)
{
        std::atomic<uint64_t> limit(0);
        std::atomic<uint64_t> vr_ac(0);
        uint64_t vr_index;

        limit.store(UINT64_MAX, std::memory_order_seq_cst);
        for (vr_index = 0; vr_index < limit; vr_index++)
                vr_ac.store(vr_index, std::memory_order_seq_cst);
        return vr_ac;
}


The quality of DI generates varies a bit depending on the optimization level.

-O0 -g:
(lldb) p vr_ac
(std::__1::atomic<unsigned long long>) $0 = 519251459
(lldb) p vr_index
(uint64_t) $1 = 519251460
(lldb) p limit
(std::__1::atomic<unsigned long long>) $2 = 18446744073709551615

-O1 -g:
(lldb) p vr_index
(uint64_t) $1 = 12232201402
(lldb) p vr_ac
error: Couldn't materialize: couldn't get the value of variable vr_ac: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p limit
error: Couldn't materialize: couldn't get the value of variable limit: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

-O2 -g (also -O3 -g):
(lldb) p vr_index
(uint64_t) $0 = 0
(lldb) p limit
error: Couldn't materialize: couldn't get the value of variable limit: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p vr_ac
error: Couldn't materialize: couldn't get the value of variable vr_ac: no
location, value may have been optimized out

At -O1, it's not able to retrieve the values for vr_ac and limit (although
they're atomic and therefore not optimized out). At -O2, it's slightly worse as
the value of vr_index is wrong (always zero, no matter when I break).

I'm actually not on top-of-tree so the situation might have improved a bit, but
writing this down so I won't forget (and I'll test with a new compiler as soon
as I can).

-- 
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/20171205/305ff30f/attachment.html>


More information about the llvm-bugs mailing list