[llvm-bugs] [Bug 38777] New: [DebugInfo at O2][Dexter] static function variables not updating in loops after LICM

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 30 08:35:32 PDT 2018


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

            Bug ID: 38777
           Summary: [DebugInfo at O2][Dexter] static function variables not
                    updating in loops after LICM
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: greg.bedwell at sony.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20809
  --> https://bugs.llvm.org/attachment.cgi?id=20809&action=edit
pre-LICM DExTer trace

Testcase (simplified version of
https://github.com/SNSystems/dexter/blob/d2a419e49/tests/nostdlib/static_loop_variables/test.cpp
):

// =====================================================
int Foo(const int iterations, const int initial) {
  static int val = initial;

  for (static int i = 0; i <= iterations; ++i)
    val += (i % 2 ? 50 : 25) * i;  // <-- BREAK HERE

  return val;
}

int main(int argc, char**) {
  return Foo(4 + argc, 5 + argc);
}
// =====================================================

Using LLVM/Clang r341056.

Compiling with "-O0 -g -fno-inline", if I put a breakpoint in the loop and
inspect variable "i" at each iteration, I will see "0", "1", "2", "3", "4", "5"
as expected.  Similarly, if I inspect variable "val", I will see "6", "6",
"56", "106", "256", "356" as expected.  On the "return val" line, I see "6" for
"i" and "606" for "val".

Compiling with "-O2 -g -fno-inline", if I put a breakpoint in the loop and
inspect variable i at each iteration, I will see "0" for each iteration, and
inspecting "val" I will see "6" at each iteration.  On the "return val" line, I
still see "6" for "i" and "606" for "val".

Using DExTer's clang-opt-bisect tool:
$ dexter.py clang-opt-bisect --builder clang --debugger lldb --cflags="-O2 -g
-fno-inline" --ldflags="-g" -- tests\nostdlib\static_loop_variables
I've narrowed this change down to LICM running on the loop.

-- 
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/20180830/f873cc77/attachment-0001.html>


More information about the llvm-bugs mailing list