[llvm-bugs] [Bug 28633] New: clang aarch64 compiler crash on inline constraints

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 20 16:01:08 PDT 2016


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

            Bug ID: 28633
           Summary: clang aarch64 compiler crash on inline constraints
           Product: new-bugs
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: fbarchard at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

This inline aarch64 function causes a segfault in clang

// This function known to cause compiler fault on clang 64 bit.
int saturate_32bit_to_16bit(int a) {
    int ret;
    asm volatile ("sqxtn h0, %s[a]\n"
                  "sxtl  v0.4s, v0.4h\n"
                  "fmov %w[ret], s0\n"
                  : [ret] "=&r" (ret)
                  : [a] "w" (a)
                  : "v0" );
    return ret;
}

Expected Results:
same as gcc - generate valid code.

Actual Results:
./clang saturate_test.c -O2 -target aarch64-none-linux-android -c

.../saturate_test.c:5:19: error: couldn't allocate input reg for constraint 'w'
    asm volatile ("sqxtn h0, %s[a]\n"
                  ^
clang-3.8: error: unable to execute command: Segmentation fault (core dumped)
clang-3.8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.1 
Target: aarch64-none-linux-android
Thread model: posix


This also fails:
static inline int saturate_32bit_to_16bit(int a) {
    int ret;
    asm volatile ("sqxtn %h[ret], %s[a]\n"
                  "sxtl %[ret].4s, %[ret].4h\n"
                  : [ret] "=w" (ret)
                  : [a] "w" (a)
                  :);
    return ret;
}

This works
static inline int saturate_32bit_to_16bit(int a) {
    int ret;
    asm volatile ("fmov s0, %w[a]\n"
                  "sqxtn h0, s0\n"
                  "sxtl v0.4s, v0.4h\n"
                  "fmov %w[ret], s0\n"
                  : [ret] "=&r" (ret)
                  : [a] "r" (a)
                  : "v0" );
    return ret;
}

This similar function works
static inline int saturate_float_to_16bit(float a) {
    int ret;
    asm volatile ("fcvtas %s[ret], %s[a]\n"
                  "sqxtn %h[ret], %s[ret]\n"
                  "sxtl %[ret].4s, %[ret].4h\n"
                  : [ret] "=w" (ret)
                  : [a] "w" (a)
                  :);
    return ret;
}


Additional Information: 
all variations work ok in gcc 4.9
Tested/fails on OSX and Linux.

-- 
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/20160720/8faff393/attachment.html>


More information about the llvm-bugs mailing list