[llvm-bugs] [Bug 34751] New: Error in backend: Cannot encode high byte register in REX-prefixed instruction

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 27 12:36:35 PDT 2017


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

            Bug ID: 34751
           Summary: Error in backend: Cannot encode high byte register in
                    REX-prefixed instruction
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: douglas_yung at playstation.sony.com
                CC: llvm-bugs at lists.llvm.org

We hit this crash in the compiler which was introduced in r314151, fixed in
r314199 (a revert of r314151), and then reintroduced in r314249 which was a
recommit of r314151.

Here is the repro that we came up with:

/* test.c */
struct S {
  unsigned char *buf;
  unsigned int p;
  unsigned int w;
  unsigned long a;
};
extern unsigned long foo();
int bar(struct S * s) {
  s->a = foo();
  unsigned int h = (s->w) << 8;
  if (s)
    h |= 0x20;
  h += 31 - (h % 31);
  s->buf[s->p++] = h >> 8;
  s->buf[0] = h;
  return s->p != 0;
}

If you compile this on linux with "-O2 -march=btver2", you get the following
crash:

clang version 6.0.0 (trunk 314249)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dyung/src/upstream/314249-linux/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/home/dyung/src/upstream/314249-linux/bin/clang-6.0" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name test.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu btver2
-dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -v
-coverage-notes-file /home/dyung/sandbox/184159/test.gcno -resource-dir
/home/dyung/src/upstream/314249-linux/lib/clang/6.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/dyung/src/upstream/314249-linux/lib/clang/6.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdebug-compilation-dir /home/dyung/sandbox/184159 -ferror-limit 19
-fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option
-vectorize-loops -vectorize-slp -o test.o -x c test.c
clang -cc1 version 6.0.0 based upon LLVM 6.0.0 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /home/dyung/src/upstream/314249-linux/lib/clang/6.0.0/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
fatal error: error in backend: Cannot encode high byte register in REX-prefixed
instruction
clang-6.0: error: clang frontend command failed with exit code 70 (use -v to
see invocation)
clang version 6.0.0 (trunk 314249)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dyung/src/upstream/314249-linux/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-6.0: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /tmp/test-c4d6b5.c
clang-6.0: note: diagnostic msg: /tmp/test-c4d6b5.sh
clang-6.0: note: diagnostic msg: 

********************

-- 
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/20170927/b93559fb/attachment.html>


More information about the llvm-bugs mailing list