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

[BUG] NDK r24 compile codes with function <svcntb> error #1732

Closed
niinorz opened this issue Jul 11, 2022 · 2 comments
Closed

[BUG] NDK r24 compile codes with function <svcntb> error #1732

niinorz opened this issue Jul 11, 2022 · 2 comments
Labels

Comments

@niinorz
Copy link

niinorz commented Jul 11, 2022

Description

I am using NDK r24, and I want to test SVE2 performance, I write codes as below:

#include <stdio.h>
// #ifdef __ARM_FEATURE_SVE
#include <arm_sve.h>
// #endif

int main()
{
int n = 0;
// #ifdef __ARM_FEATURE_SVE
n = svcntb() * 8;
// #endif
if (n) {
printf("SVE is available. The length is %d bits\n", n);
} else {
printf("SVE is unavailable.\n");
}
return 0;
}

And in CMakeLists.txt I add

target_compile_options( ${PROJECT_NAME} PRIVATE "-D__ARM_FEATURE_SVE")

But when compile, I get error:
fatal error: error in backend: Cannot select: 0x7524fd8: i64 = vscale Constant:i64<1>
0x7524f70: i64 = Constant<1>
In function: main
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: /mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android28 --sysroot=/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DBUILD_REE -DBUILD_SAMPLE -DCUSTOM_XIAOMI -DVERSIONSTR="ver1.3.04_rx_build-20220711.16.54.51" -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -O3 -DNDEBUG -fPIE -D__ARM_FEATURE_SVE -MD -MT code/ta/modules/algo/samplecode/CMakeFiles/sample_test.dir/samples.cpp.o -MF CMakeFiles/sample_test.dir/samples.cpp.o.d -o CMakeFiles/sample_test.dir/samples.cpp.o -c /mnt/rd_home/yzp/workspace/tenacity/code/ta/modules/algo/samplecode/samples.cpp

  1.  <eof> parser at end of file
    
  2.  Code generation
    
  3.  Running pass 'Function Pass Manager' on module '/mnt/rd_home/yzp/workspace/tenacity/code/ta/modules/algo/samplecode/samples.cpp'.
    
  4.  Running pass 'AArch64 Instruction Selection' on function '@main'
    

#0 0x000000000456d858 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x456d858)
#1 0x000000000456d6e0 llvm::sys::RunSignalHandlers() (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x456d6e0)
#2 0x000000000453d363 (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x453d363)
#3 0x000000000453d31b (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x453d31b)
#4 0x0000000003e8d7d7 llvm::sys::Process::Exit(int, bool) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3e8d7d7)
#5 0x0000000003e8d780 (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3e8d780)
#6 0x0000000002c24552 llvm::report_fatal_error(llvm::Twine const&, bool) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2c24552)
#7 0x0000000003adfd78 (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3adfd78)
#8 0x00000000029da932 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x29da932)
#9 0x00000000029c9ac4 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x29c9ac4)
#10 0x0000000003cbf52e (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3cbf52e)
#11 0x00000000031002b4 llvm::SelectionDAGISel::DoInstructionSelection() (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x31002b4)
#12 0x00000000030fdbb8 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x30fdbb8)
#13 0x00000000030f6648 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x30f6648)
#14 0x00000000030f1a17 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x30f1a17)
#15 0x00000000036d2070 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x36d2070)
#16 0x0000000002c87fc3 llvm::FPPassManager::runOnFunction(llvm::Function&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2c87fc3)
#17 0x0000000002c87d0f llvm::FPPassManager::runOnModule(llvm::Module&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2c87d0f)
#18 0x0000000003b91da5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3b91da5)
#19 0x0000000003b43d94 (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3b43d94)
#20 0x0000000003b42361 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_deletellvm::raw_pwrite_stream >) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3b42361)
#21 0x0000000003b41b40 (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3b41b40)
#22 0x000000000389e066 clang::ParseAST(clang::Sema&, bool, bool) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x389e066)
#23 0x00000000039383d1 clang::FrontendAction::Execute() (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x39383d1)
#24 0x0000000003937fcb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3937fcb)
#25 0x0000000003937bc1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3937bc1)
#26 0x0000000003936bff cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3936bff)
#27 0x0000000003e8b9b7 (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3e8b9b7)
#28 0x0000000005912b02 clang::driver::CC1Command::setEnvironment(llvm::ArrayRef<char const*>) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x5912b02)
#29 0x0000000003c35e67 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3c35e67)
#30 0x0000000003c35c4d clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, bool) const (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3c35c4d)
#31 0x0000000003acc724 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3acc724)
#32 0x000000000383e033 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x383e033)
#33 0x000000000383a5b7 main (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x383a5b7)
#34 0x00007fd2852c1c87 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c87)
#35 0x000000000582fa99 _start (/mnt/rd_home/tools/android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x582fa99)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Android (8075178, based on r437112b) clang version 14.0.1 (https://android.googlesource.com/toolchain/llvm-project 8671348b81b95fc603505dfc881b45103bee1731)
Target: aarch64-none-linux-android28
Thread model: posix
InstalledDir: /mnt/rd_home/tools/android-ndk-r24/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/samples-a1ccdf.cpp
clang++: note: diagnostic msg: /tmp/samples-a1ccdf.sh
clang++: note: diagnostic msg:


code/ta/modules/algo/samplecode/CMakeFiles/sample_test.dir/build.make:75: recipe for target 'code/ta/modules/algo/samplecode/CMakeFiles/sample_test.dir/samples.cpp.o' failed
make[2]: *** [code/ta/modules/algo/samplecode/CMakeFiles/sample_test.dir/samples.cpp.o] Error 70
CMakeFiles/Makefile2:141: recipe for target 'code/ta/modules/algo/samplecode/CMakeFiles/sample_test.dir/all' failed
make[1]: *** [code/ta/modules/algo/samplecode/CMakeFiles/sample_test.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error
samples-a1ccdf.cpp.txt
samples-a1ccdf.sh.txt
2

Affected versions

r24, r25

Canary version

No response

Host OS

Linux

Host OS version

ubuntu 18.04

Affected ABIs

arm64-v8a

Build system

CMake

Other build system

No response

minSdkVersion

android-28

Device API level

No response

@niinorz niinorz added the bug label Jul 11, 2022
@pirama-arumuga-nainar
Copy link
Collaborator

You'd need -march=armv8-a+sve (-march=armv8-a+sve2 for sve2) for LLVM to be able to generate code for svcntb (... and then test on a new-enough phone that has SVE/SVE2). That flag should implicitly define the macro as well.

@enh-google
Copy link
Collaborator

You'd need -march=armv8-a+sve (-march=armv8-a+sve2 for sve2) for LLVM to be able to generate code for svcntb (... and then test on a new-enough phone that has SVE/SVE2). That flag should implicitly define the macro as well.

(note that if you do go this route, you'll probably want to build that separately and then use ifuncs to select the SVE or non-SVE code at runtime.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants