Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android NDK r22b clang-compiler failed to compile code for AArch32 #1555

Closed
pavel-zhigulin opened this issue Aug 3, 2021 · 5 comments
Closed
Assignees
Projects

Comments

@pavel-zhigulin
Copy link

Code below causes compiler crash during compilation for AArch32 architecture (for AArch64 it works fine). Detailed instruction how to reproduce the issue could be found in this repo.

#include <arm_neon.h>
#include <arm_acle.h>
#include <stdint.h>
#include <stddef.h>

static inline void
prepareInterleavedKeys(
     uint8_t* roundKeys
) {
     enum {
          roundKeySize = 16
     };
     uint8_t* output = roundKeys;
     uint8x16x4_t  keys_0_3;
     uint8x16x4_t  keys_4_7;
     uint8x16x3_t  keys_8_10;
     uint8x16x4_t  buff;

     keys_0_3  = vld1q_u8_x4(roundKeys);
     keys_4_7  = vld1q_u8_x4(roundKeys + roundKeySize * 4);
     keys_8_10 = vld1q_u8_x3(roundKeys + roundKeySize * 8);

     for(size_t i = 0; i < 4u; ++i) {
          buff.val[0] = keys_0_3.val[i];
          buff.val[1] = keys_0_3.val[i];
          buff.val[2] = keys_0_3.val[i];
          buff.val[3] = keys_0_3.val[i];

          vst1q_u8_x4(output, buff);
          output += roundKeySize * 4;
     }

     for(size_t i = 0; i < 4u; ++i) {
          buff.val[0] = keys_4_7.val[i];
          buff.val[1] = keys_4_7.val[i];
          buff.val[2] = keys_4_7.val[i];
          buff.val[3] = keys_4_7.val[i];

          vst1q_u8_x4(output, buff);
          output += roundKeySize * 4;
     }

     for(size_t i = 0; i < 3u; ++i) {
          buff.val[0] = keys_8_10.val[i];
          buff.val[1] = keys_8_10.val[i];
          buff.val[2] = keys_8_10.val[i];
          buff.val[3] = keys_8_10.val[i];

          vst1q_u8_x4(output, buff);
          output += roundKeySize * 4;
     }
}

int main(void) {
     uint8_t keys[704] = {0};
     prepareInterleavedKeys(keys);
}

OS: Ubuntu 20.04.2 LTS

Clang version:

$: /opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -v
Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: /opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x
Found candidate GCC installation: /opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

Compilation ERROR

"/opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" --target=armv7a-linux-androideabi23 -c -fPIC -std=c99 -Wall -Wextra -Wno-unused-label -fPIC -fvisibility=hidden -O3 -Werror -g -DNDEBUG -mfpu=neon -mfloat-abi=hard ./test.c -o ./test.o
PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7a-linux-androideabi23 -c -fPIC -std=c99 -Wall -Wextra -Wno-unused-label -fPIC -fvisibility=hidden -O3 -Werror -g -DNDEBUG -mfpu=neon -mfloat-abi=hard ./test.c -o ./test.o 
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module './test.c'.
4.      Running pass 'ARM Instruction Selection' on function '@main'
#0 0x0000000003456ac5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x3456ac5)
#1 0x0000000003456960 llvm::sys::RunSignalHandlers() (/opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x3456960)
#2 0x0000000003425250 (/opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x3425250)
#3 0x000000000342540c (/opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x342540c)
#4 0x00007f92757c13c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#5 0x0000000002ae0fe4 (/opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x2ae0fe4)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
Target: armv7a-unknown-linux-android23
Thread model: posix
InstalledDir: /opt/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin
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/test-dd13a1.c
clang: note: diagnostic msg: /tmp/test-dd13a1.sh
clang: note: diagnostic msg: 

********************
make: *** [Makefile:2: all] Error 254
@pirama-arumuga-nainar
Copy link
Collaborator

This also crashes with clang-r416183 which is in r23. It doesn't crash in LLVM ToT though. Running a bisection now.

@DanAlbert DanAlbert added this to Triaged in r23 via automation Aug 3, 2021
@DanAlbert DanAlbert added this to Awaiting triage in LLVM via automation Aug 3, 2021
@DanAlbert DanAlbert moved this from Awaiting triage to Needs upstream bug in LLVM Aug 3, 2021
@DanAlbert DanAlbert moved this from Needs upstream bug to Awaiting fix in LLVM Aug 3, 2021
@DanAlbert DanAlbert moved this from Awaiting fix to Awaiting update in LLVM Aug 3, 2021
@DanAlbert
Copy link
Member

r23 has already been sent to QA do it's too late for a respin. This will be looked at for r23b.

@pirama-arumuga-nainar
Copy link
Collaborator

@DanAlbert DanAlbert removed this from Triaged in r23 Aug 13, 2021
@DanAlbert DanAlbert added this to Triaged in r23b via automation Aug 13, 2021
@DanAlbert DanAlbert moved this from Awaiting update to Awaiting prebuilt drop in LLVM Aug 31, 2021
@DanAlbert DanAlbert moved this from Triaged to Needs prebuilt update in r23b Sep 14, 2021
@DanAlbert DanAlbert moved this from Needs prebuilt update to Needs cherry-pick in r23b Sep 16, 2021
@DanAlbert
Copy link
Member

https://ci.android.com/builds/branches/aosp-master-ndk/grid?head=7732824&tail=7732824 has the fix for this. I was able to verify that locally.

chenguoyin-alibaba pushed a commit to riscv-android-src/platform-ndk that referenced this issue Oct 21, 2021
Test: ./checkbuild.py && ./run_tests.py
Bug: android/ndk#1540
Bug: android/ndk#1551
Bug: android/ndk#1555
Change-Id: I2d345546457d8c461b603be4ea9e725230f11af9
(cherry picked from commit 2af6bc5)
chenguoyin-alibaba pushed a commit to riscv-android-src/toolchain-llvm_android that referenced this issue Oct 21, 2021
Bug: android/ndk#1555

76786037c68 [ARM] Fix postinc of vst1xN

Test: N/A
Change-Id: I9d0042b9b479ff20e19a47ef6dc3944d16b9dc9b
@rprichard
Copy link
Collaborator

Fixed in r23b.

r23b automation moved this from Needs cherry-pick to Merged Oct 29, 2021
@DanAlbert DanAlbert moved this from Awaiting prebuilt drop to Prebuilts submitted in LLVM Dec 14, 2021
nekoana pushed a commit to nekoana/superproject that referenced this issue Apr 13, 2022
Bug: android/ndk#1555

76786037c68 [ARM] Fix postinc of vst1xN

Test: N/A
Change-Id: I9d0042b9b479ff20e19a47ef6dc3944d16b9dc9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
LLVM
  
Prebuilts submitted
r23b
  
Merged
Development

No branches or pull requests

4 participants