[LLVMbugs] [Bug 15364] New: LTO miscompiles some code?

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 26 10:10:29 PST 2013


            Bug ID: 15364
           Summary: LTO miscompiles some code?
           Product: new-bugs
           Version: 3.2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: bruce.mitchener at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10081
  --> http://llvm.org/bugs/attachment.cgi?id=10081&action=edit
Demonstration of error

I'm working on emscripten and am updating the version of libcxx that is used in
emscripten to the current version.  I thought it would be a good idea to run
the libcxx test cases against emscripten and found what appears to be a bug in

I've attached a fairly minimal test case for the bug and it goes into an
infinite loop when compiled with emscripten.

According to Alon Zakai (lead on emscripten):

    Looks like LLVM LTO is breaking this. It works with -O1 --llvm-lto 0 and
    fails with -O1 --llvm-lto 1.

    Diffing those, it does look like LTO messes stuff up. With


    applies to the LTO's one, it works ok. Basically, LTO copies the first
    into local vars - but never uses them. It also doesn't make a stack copy
    of the last vars. Manually changing those in the diff make it work

The 'first' and 'last' variables that he is referring to are from the
definition of std::includes:

    template <class _Compare, class _InputIterator1, class _InputIterator2>
    __includes(_InputIterator1 __first1, _InputIterator1 __last1,
               _InputIterator2 __first2, _InputIterator2 __last2,
               _Compare __comp)
        for (; __first2 != __last2; ++__first1)
            if (__first1 == __last1 || __comp(*__first2, *__first1))
                return false;
            if (!__comp(*__first1, *__first2))
        return true;

The bug against emscripten can be seen at

I am using clang / llvm 3.2.

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/20130226/662f7e91/attachment.html>

More information about the llvm-bugs mailing list