<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [Aarch64] Wshadow and vcopy intrinsic"
   href="https://bugs.llvm.org/show_bug.cgi?id=44391">44391</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Aarch64] Wshadow and vcopy intrinsic
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>C
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>aleyzour@magicleap.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Here the code:
/// vcopy.c 
#include <arm_neon.h>

float32x4_t insert00(float32x4_t v1, float32x4_t v2) {
   return vcopyq_laneq_f32(v1, 0, v2, 0);
}
////

$ clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


$ clang --target=aarch64-linux-gnu vcopy.c -c -I
/usr/aarch64-linux-gnu/include/ -E

# 2 "vcopy.c" 2

float32x4_t insert00(float32x4_t v1, float32x4_t v2) {
   return __extension__ ({ float32x4_t __s0_70 = v1; float32x4_t __s2_70 = v2;
float32x4_t __ret_70; __ret_70 = __extension__ ({ float32_t __s0 =
__extension__ ({ float32x4_t __s0 = __s2_70; float32_t __ret; __ret =
(float32_t) __builtin_neon_vgetq_lane_f32((int8x16_t)__s0, 0); __ret; });
float32x4_t __s1 = __s0_70; float32x4_t __ret; __ret = (float32x4_t)
__builtin_neon_vsetq_lane_f32(__s0, (int8x16_t)__s1, 0); __ret; }); __ret_70;
});


Notice that code:
{ float32_t __s0 = __extension__ ({ float32x4_t __s0 = __s2_70; .....

Should report a shadowing issue, but does fails to do so:

$ clang --target=aarch64-linux-gnu vcopy.c -c -I
/usr/aarch64-linux-gnu/include/ -Werror -Wshadow

does not report any issue at all.
But this code here (as the result of the clang -E > t1.c and reedited for
clarity)

//// t1.c
#include <arm_neon.h>

float32x4_t insert00(float32x4_t v1, float32x4_t v2) {
   return __extension__ ({ float32x4_t __s0_70 = v1; float32x4_t __s2_70 = v2;
float32x4_t __ret_70; __ret_70 = __extension__ ({ float32_t __s0 =
__extension__ ({ float32x4_t __s0 = __s2_70; float32_t __ret; __ret =
(float32_t) __builtin_neon_vgetq_lane_f32((int8x16_t)__s0, 0); __ret; });
float32x4_t __s1 = __s0_70; float32x4_t __ret; __ret = (float32x4_t)
__builtin_neon_vsetq_lane_f32(__s0, (int8x16_t)__s1, 0); __ret; }); __ret_70;
});
}
////

$ clang --target=aarch64-linux-gnu t1.c -c -I /usr/aarch64-linux-gnu/include/
-Werror -Wshadow 
t1.c:4:176: error: declaration shadows a local variable [-Werror,-Wshadow]
  ...({ float32_t __s0 = __extension__ ({ float32x4_t __s0 = __s2_70;
float32...
                                                      ^
t1.c:4:140: note: previous declaration is here
  ...float32x4_t __ret_70; __ret_70 = __extension__ ({ float32_t __s0 =
__ext...
                                                                 ^
1 error generated.

[Note: though I use clang 6.0, this can be reproduced with trunk clang]

Now. multiple questions obviously come to mind:
1- By what magic does clang remove the error in the first compilation (the one
of vcopy.c), but fails in the second case. Are those shadow errors inconsistent
or just deliberately trapped for some pattern and silently ignored?

2- Why so many neon intrinsics not functions? Does the compiler fails at
inlining them?


The reason for filing this bug is that I believe ccache (heavily used in the
context of building chromium) reuses the preprocessed C/C++ code and reinjects
them into the compilation process. And it fails when vcopy is used in the code.

There is an obvious workaround though (but only for clang), so make it a low
priority.</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>