<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - __builtin_readcyclecounter leads to ICE on ARMv6"
   href="http://llvm.org/bugs/show_bug.cgi?id=17057">17057</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__builtin_readcyclecounter leads to ICE on ARMv6
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>schnetter@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I am using clang 3.3:

clang version 3.3 (branches/release_33 188901) (llvm/branches/release_33
188900)
Target: armv6-unknown-linux-gnueabihf
Thread model: posix

I am building this program:

pi@water ~/src/c $ cat builtin_cyclecounter.c 
unsigned long long f(void)
{
#if __has_builtin(__builtin_readcyclecounter)
  return __builtin_readcyclecounter();
#else
#  error "__builtin_readcyclecounter not available"
#endif
}

I am running on a Raspberry Pi:

pi@water ~/src/c $ uname -a
Linux water 3.6.11+ #474 PREEMPT Thu Jun 13 17:14:42 BST 2013 armv6l GNU/Linux

I receive this error:

pi@water ~/src/c $ clang -S builtin_cyclecounter.c 
ExpandIntegerResult #0: 0x36cd948: i64,ch = ReadCycleCounter 0x36c05e4 [ORD=1]
[ID=0]

Do not know how to expand the result of this operator!
UNREACHABLE executed at
/home/pi/src/llvm-3.3/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:1083!
Stack dump:
0.    Program arguments: /home/pi/llvm-3.3/bin/clang -cc1 -triple
armv6-unknown-linux-gnueabihf -S -disable-free -main-file-name
builtin_cyclecounter.c -mrelocation-model static -mdisable-fp-elim -fmath-errno
-mconstructor-aliases -fuse-init-array -target-abi aapcs-linux -target-cpu
arm1136jf-s -mfloat-abi hard -target-linker-version 2.22 -coverage-file
/home/pi/src/c/builtin_cyclecounter.s -resource-dir
/home/pi/llvm-3.3/bin/../lib/clang/3.3 -internal-isystem /usr/local/include
-internal-isystem /home/pi/llvm-3.3/bin/../lib/clang/3.3/include
-internal-externc-isystem /usr/include/arm-linux-gnueabihf
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fno-dwarf-directory-asm -fdebug-compilation-dir /home/pi/src/c -ferror-limit
19 -fmessage-length 80 -mstackrealign -fno-signed-char -fobjc-runtime=gcc
-fobjc-default-synthesize-properties -fdiagnostics-show-option
-fcolor-diagnostics -backend-option -vectorize-loops -o builtin_cyclecounter.s
-x c builtin_cyclecounter.c 
1.    <eof> parser at end of file
2.    Code generation
3.    Running pass 'Function Pass Manager' on module 'builtin_cyclecounter.c'.
4.    Running pass 'ARM Instruction Selection' on function '@f'
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.3 (branches/release_33 188901) (llvm/branches/release_33
188900)
Target: armv6-unknown-linux-gnueabihf
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

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

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

The requested files to attach are:

pi@water ~/src/c $ cat /tmp/builtin_cyclecounter-0fN6h0.c
# 1 "builtin_cyclecounter.c" 1
unsigned long long f(void)
{
#if __has_builtin(__builtin_readcyclecounter)
  return __builtin_readcyclecounter();
#else
#  error "__builtin_readcyclecounter not available"
#endif
}

pi@water ~/src/c $ cat /tmp/builtin_cyclecounter-0fN6h0.sh
/home/pi/llvm-3.3/bin/clang -cc1 -triple armv6-unknown-linux-gnueabihf -S
-disable-free -main-file-name builtin_cyclecounter.c -mrelocation-model static
-mdisable-fp-elim -fmath-errno -mconstructor-aliases -fuse-init-array
-target-abi aapcs-linux -target-cpu arm1136jf-s -mfloat-abi hard
-target-linker-version 2.22 -fno-dwarf-directory-asm -ferror-limit 19
-fmessage-length 80 -mstackrealign -fno-signed-char -fobjc-runtime=gcc
-fobjc-default-synthesize-properties -fdiagnostics-show-option
-fcolor-diagnostics -backend-option -vectorize-loops -x c
builtin_cyclecounter-0fN6h0.c</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>