[LLVMbugs] [Bug 23437] New: Possible miscompile with arm64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 6 11:36:42 PDT 2015


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

            Bug ID: 23437
           Summary: Possible miscompile with arm64
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This assert fails when building with trunk clang when targeting arm64:

$ cat test.cc
#include <assert.h>

int main(int argc, char **argv) {
  const struct {
    const char* to_escape;
    const char* escaped;
  } cases[] = {
    {"\xe5\xc4\x4f\x05\xb6\xfd\0", "\\u00E5\\u00C4O\\u0005\\u00B6\\u00FD"},
  };

  assert((unsigned char)cases[0].to_escape[0] == 0xe5);
  return 0;
}
$ Release+Asserts/bin/clang++ -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk
-O0 -gdwarf-2 -fvisibility=hidden -miphoneos-version-min=7.0 -arch arm64
-std=c++11 -stdlib=libc++ -fno-rtti -fno-exceptions -fvisibility-inlines-hidden
-fno-threadsafe-statics  -fcolor-diagnostics -fstack-protector-all  -c test.cc
-o test.o
$ Release+Asserts/bin/clang++ -Wl,-search_paths_first -Wl,-ObjC
-miphoneos-version-min=7.0 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk
-arch arm64 -L. -stdlib=libc++ -o foo test.o



Here's the disassembly of the relevant bits of main:

0000000100007e60         stp        x29, x30, [sp, #0xfffffff0]!               
; XREF=0x1000000d0
0000000100007e64         mov        x29, sp
0000000100007e68         sub        sp, sp, #0x20
0000000100007e6c         adrp       x8, #0x100008000                           
; imp___got____stack_chk_guard
0000000100007e70         add        x8, x8, #0x28                              
; __ZZ4mainE5cases

0000000100007e74         adrp       x10, #0x100008000                          
 ; imp___got____stack_chk_guard
0000000100007e78         ldr        x10, [x10]
0000000100007e7c         ldr        x10, [x10]
0000000100007e80         mov        x2, x10
0000000100007e84         stur       x10, [x29, #0xfffffff8]
0000000100007e88         stur       wzr, [x29, #0xfffffff4]
0000000100007e8c         str        w0, [sp, #0x10]
0000000100007e90         str        x1, [sp, #0x8]
0000000100007e94         ldr        x8, [x8]
0000000100007e98         ldrb       w0, [x8]

0000000100007e9c         cmp        w0, #0xe5
0000000100007ea0         cset       w0, eq


0000000100007ea4         eor        w0, w0, #0x1


0000000100007ea8         cmp        w0, #0x0
0000000100007eac         str        x2, [sp]
0000000100007eb0         b.eq       0x100007ed4

0000000100007eb4         adrp       x8, #0x100007000                           
; 0x100007000 (__mh_execute_header + 0x7000)
0000000100007eb8         add        x0, x8, #0xf78                             
; "main"
0000000100007ebc         adrp       x8, #0x100007000                           
; 0x100007000 (__mh_execute_header + 0x7000)
0000000100007ec0         add        x1, x8, #0xf7d                             
; "test.cc"
0000000100007ec4         orr        w2, wzr, #0x10
0000000100007ec8         adrp       x8, #0x100007000                           
; 0x100007000 (__mh_execute_header + 0x7000), argument #1 for method
imp___stubs____assert_rtn
0000000100007ecc         add        x3, x8, #0xf85                             
; "(unsigned char)cases[0].to_escape[0] == 0xe5"
0000000100007ed0         bl         imp___stubs____assert_rtn


I can't read arm64 well enough to say if that makes sense.


The assert doesn't fire with xcode's clang, so maybe it's a somewhat recent
regression?

-- 
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/20150506/4231d8e9/attachment.html>


More information about the llvm-bugs mailing list