[llvm-bugs] [Bug 30748] New: Silent miscompile of integer to string conversion in stage 2 build

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 20 09:39:12 PDT 2016


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

            Bug ID: 30748
           Summary: Silent miscompile of integer to string conversion in
                    stage 2 build
           Product: clang
           Version: unspecified
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: t.p.northover at gmail.com
          Reporter: zturner at google.com
                CC: llvm-bugs at lists.llvm.org, renato.golin at linaro.org
    Classification: Unclassified

I submitted r284425 which adds some functions for formatting numbers.  This
broke the AArch64 build
[http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3344] with
one failing unit tests which tries to print -10 and instead prints "-0".  This
was reverted in r284462.

We suspect a latent clang bug, as there is no apparent UB in my patch, as well
as the fact that it only happens with optimizations on.

One particular quirk.  It only happens on a stage 2 build, and only when BOTH
stage 1 and stage 2 are compiled without O0.  If either stage 1 or stage 2 is
built at -O0, the problem does not happen.

Attached are 3 patches which might help to diagnose the issue.  Short
description as follows:

moretest - Adds unit tests for all numbers from -1000 to 1000.  Is there a
pattern that causes it to fail?  Certainly -10 can't be the only value.

rewrite - Simplifies the code a little.  If this is an optimizer bug, maybe we
can just remove whatever is tickling the optimizer so I can submit this and
unblock myself.

logging - Adds some print statements which might help identify where the bad CG
is.  Here is the output when it works:

calling write_signed() with N == -10, sizeof(N) == 4
Unsigned value = 10
Using 32-bit codepath
write_unsigned_impl.  N = 10, IsNegative = 1
Prec = 1
format_to_buffer(10), BufferSize = 128
Wrote character 0
Wrote character 1
formatted value to buffer, Len = 2
LeadingZeros = 0
Writing negative sign
Writing 2 characters "10"
finished


All 3 patches are independent of each other and should be applied directly on
top of the bad commit.

-- 
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/20161020/664d34b8/attachment-0001.html>


More information about the llvm-bugs mailing list