Skip to content

[BUG] clang++ optimizer crash (segmentation fault) with neon intrinsics #1303

@SimonSuckut

Description

@SimonSuckut

Description

I encountered a bug in the optimizer of clang++ which leads to a segmentation fault when working with neon intrinsic. This only happens when I run a release build in android studio. I played a bit with the clang++ command and found out that this happens due to the optimization level (-Oz) of the release build.

I provided a small test case that shows the issue:
https://github.com/SimonSuckut/ndk_clang-_bug

with build_debug.sh (contains the clang++ command of the debug build) the compilation works perfectly fine, with build.sh (contains the clang++ command of the release build) the compile process ends with an segmentation fault:

1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module '/home/simon/AndroidStudioProjects/llvm_bug/llvm_bug.cpp'. 4. Running pass 'ARM Instruction Selection' on function '@_GLOBAL__sub_I_llvm_bug.cpp' #0 0x0000000002e6e2b5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/simon/Dokumente/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2e6e2b5) #1 0x0000000002e6e63e llvm::sys::RunSignalHandlers() (/home/simon/Dokumente/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2e6e63e) #2 0x0000000002e6e4e8 (/home/simon/Dokumente/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2e6e4e8) #3 0x00007f5b9b5453c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0) #4 0x000000000266a480 llvm::TargetLowering::DAGCombinerInfo::CombineTo(llvm::SDNode*, llvm::ArrayRef<llvm::SDValue>, bool) (/home/simon/Dokumente/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x266a480) #5 0x0000000004bc6968 clang++: error: unable to execute command: Segmentation fault (core dumped) clang++: error: clang frontend command failed due to signal (use -v to see invocation) Android (5900059 based on r365631c) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 207d7abc1a2abf3ef8d4301736d6a7ebc224a290) (based on LLVM 9.0.8svn) Target: armv7-none-linux-android19 Thread model: posix

Environment Details

  • NDK Version: 21.3.6528147
  • Build system: clang++
  • Host OS: Ubuntu 20.04
  • ABI: armeabi-v7a
  • NDK API level: 19

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions