llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.65k stars 11.84k forks source link

clang compile aarch64 neon intrinsics error #23639

Closed llvmbot closed 9 years ago

llvmbot commented 9 years ago
Bugzilla Link 23265
Resolution FIXED
Resolved on Apr 18, 2015 22:20
Version trunk
OS Linux
Attachments the command line of compiling, the source file
Reporter LLVM Bugzilla Contributor
CC @ahmedbougacha

Extended Description

Clang fails on compile arm neon intrinsic file for aarch64 target.

Here is the log:

/home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/clang -v -target aarch64-none-linux-androideabi -O2 -D__ARM_NEON -c ../../webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c clang version 3.7.0 (trunk 235161) Target: aarch64-none-linux-androideabi Thread model: posix Found candidate GCC installation: /usr/lib/gcc-cross/aarch64-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc-cross/aarch64-linux-gnu/4.8.2 Selected GCC installation: /usr/lib/gcc-cross/aarch64-linux-gnu/4.8 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/clang-3.7" -cc1 -triple aarch64-none-linux-androideabi -emit-obj -disable-free -main-file-name filterbanks_neon.c -mrelocation-model pic -pic-level 1 -mthread-model posix -mdi\ sable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -backend-option -aarch64-fix-cortex-a53-835769=1 -v -dwarf-column-info -fno-unique-section-names \ -coverage-file /home/zhongwei/project/webrtc_git/src/out/iOS_Release/filterbanks_neon.c -resource-dir /home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/../lib/clang/3.7.0 -D __ARM_NEON -internal-isystem /usr/local/include -inte\ rnal-isystem /home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/../lib/clang/3.7.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir /home/zhongwei/project/webrtc_git/s\ rc/out/iOS_Release -ferror-limit 19 -fmessage-length 118 -mstackrealign -fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o filterbanks_neon.o -x c ../../web\ rtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/include"

include "..." search starts here:

include <...> search starts here:

/usr/local/include /home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/../lib/clang/3.7.0/include /usr/include End of search list. clang-3.7: /home/zhongwei/projects/read_learn/llvm-toolchain/llvm/include/llvm/CodeGen/ValueTypes.h:226: unsigned int llvm::EVT::getVectorNumElements() const: Assertion `isVector() && "Invalid vector type!"' failed. 0 clang-3.7 0x00000000025e7e3a llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 44 1 clang-3.7 0x00000000025e814f 2 clang-3.7 0x00000000025e6c4f 3 libpthread.so.0 0x00002b5d50e4d340 4 libc.so.6 0x00002b5d51acacc9 gsignal + 57 5 libc.so.6 0x00002b5d51ace0d8 abort + 328 6 libc.so.6 0x00002b5d51ac3b86 7 libc.so.6 0x00002b5d51ac3c32 8 clang-3.7 0x0000000001342170 9 clang-3.7 0x000000000134da6e 10 clang-3.7 0x000000000134e4ea 11 clang-3.7 0x000000000135d477 12 clang-3.7 0x0000000002aa7058 llvm::SelectionDAGISel::DoInstructionSelection() + 528 13 clang-3.7 0x0000000002aa69ec llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 3544 14 clang-3.7 0x0000000002aa5845 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator, llvm::ilist_iterator, bool&) + 235 15 clang-3.7 0x0000000002aa8b61 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 2841 16 clang-3.7 0x0000000002aa49d9 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1013 17 clang-3.7 0x00000000013442a2 18 clang-3.7 0x0000000001e91dcb llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95 19 clang-3.7 0x00000000021d8cec llvm::FPPassManager::runOnFunction(llvm::Function&) + 290 19 clang-3.7 0x00000000021d8cec llvm::FPPassManager::runOnFunction(llvm::Function&) + 290 20 clang-3.7 0x00000000021d8e5c llvm::FPPassManager::runOnModule(llvm::Module&) + 84 21 clang-3.7 0x00000000021d917a 22 clang-3.7 0x00000000021d9820 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 244 23 clang-3.7 0x00000000021d9a3f llvm::legacy::PassManager::run(llvm::Module&) + 39 24 clang-3.7 0x0000000002b7083d 25 clang-3.7 0x0000000002b708ed clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module, clang::BackendAction, llvm::r\ aw_pwrite_stream) + 127 26 clang-3.7 0x0000000002b52282 27 clang-3.7 0x00000000035d13c0 clang::ParseAST(clang::Sema&, bool, bool) + 784 28 clang-3.7 0x00000000027e97c6 clang::ASTFrontendAction::ExecuteAction() + 322 29 clang-3.7 0x0000000002b54798 clang::CodeGenAction::ExecuteAction() + 1486 30 clang-3.7 0x00000000027e92a1 clang::FrontendAction::Execute() + 139 31 clang-3.7 0x00000000027b0ed4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 772 32 clang-3.7 0x00000000028fe389 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 993 33 clang-3.7 0x00000000012d4a22 cc1_main(llvm::ArrayRef<char const>, char const, void) + 770 34 clang-3.7 0x00000000012cd28e 35 clang-3.7 0x00000000012cd875 main + 1074 36 libc.so.6 0x00002b5d51ab5ec5 __libc_start_main + 245 37 clang-3.7 0x00000000012ca239 Stack dump:

  1. Program arguments: /home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/clang-3.7 -cc1 -triple aarch64-none-linux-androideabi -emit-obj -disable-free -main-file-name filterbanks_neon.c -mrelocation-model pic -pic-level 1 -\ mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -backend-option -aarch64-fix-cortex-a53-835769=1 -v -dwarf-column-info -f\ no-unique-section-names -coverage-file /home/zhongwei/project/webrtc_git/src/out/iOS_Release/filterbanks_neon.c -resource-dir /home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/../lib/clang/3.7.0 -D __ARM_NEON -internal-isystem \ /usr/local/include -internal-isystem /home/zhongwei/projects/read_learn/llvm-toolchain/build/bin/../lib/clang/3.7.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir /home/zhong\ wei/project/webrtc_git/src/out/iOS_Release -ferror-limit 19 -fmessage-length 118 -mstackrealign -fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o filterban\ ks_neon.o -x c ../../webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c
  2. parser at end of file
  3. Code generation
  4. Running pass 'Function Pass Manager' on module '../../webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c'.
  5. Running pass 'AArch64 Instruction Selection' on function '@WebRtcIsacfix_AllpassFilter2FixDec16Neon' clang-3.7: error: unable to execute command: Aborted (core dumped) clang-3.7: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.7.0 (trunk 235161) Target: aarch64-none-linux-androideabi Thread model: posix clang-3.7: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script. clang-3.7: note: diagnostic msg:

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


make: *** [trunk-clang] Error 254

llvmbot commented 9 years ago

Thanks for your quick fix!

ahmedbougacha commented 9 years ago

Should be fixed with r235243.

ahmedbougacha commented 9 years ago

And here's a from-scratch testcase, with a ctpop to force vector ops legalization to run:

define <4 x i16> @​foo(i16* %bar, i16 %ptr, i64 %inc, <4 x i16> %A, <2 x i32> %d1, <2 x i32> %d2) { %tmp1 = load i16, i16 %bar %tmp2 = insertelement <4 x i16> %A, i16 %tmp1, i32 1 %tmp3 = getelementptr i16, i16 %bar, i64 %inc store i16 %tmp3, i16 %ptr %d3 = call <2 x i32> @​llvm.ctpop.v2i32(<2 x i32> %d1) store <2 x i32> %d3, <2 x i32>* %d2 ret <4 x i16> %tmp2 }

ahmedbougacha commented 9 years ago

Note that this doesn't reproduce on the simple testcases of arm64-indexed-vector-ldst.ll, because there, the v4i16 insert_vector_elt is lowered to extract_subreg of v8i16, and the LD1LANEpost combine doesn't run BeforeLegalizeOps.

isBeforeLegalizeOps is defined as: Level < AfterLegalizeVectorOps

So, the only situation where the combine could run on v4i16 is if there's a vector legalization phase, whereas it should really be able to run after type legalization if there isn't a vector legalization phase.

ahmedbougacha commented 9 years ago

The faulty code is in AArch64DAGToDAGISel::SelectPostLoadLane:

ReplaceUses(SDValue(N, 0),
            Narrow ? NarrowVector(SuperReg, *CurDAG) : SuperReg);

Here SuperReg is an Untyped vector list (whereas NarrowVector expects a 128-bit vector type), and should probably be wrapped in an EXTRACT_SUBREG.

llvmbot commented 9 years ago

Hi Yao:

Maybe you want to compress filterbanks_neon-c2acf1.c before uploading it (with bzip2 or xz, for example).

Done, thanks!

llvmbot commented 9 years ago

the source file proprecessed (compressed in xz file format)

llvmbot commented 9 years ago

Hi Yao:

Maybe you want to compress filterbanks_neon-c2acf1.c before uploading it (with bzip2 or xz, for example).

llvmbot commented 9 years ago

By the way, it is OK when compile with option "-O0".

llvmbot commented 9 years ago

My /tmp/filterbanks_neon-c2acf1.c (3.1MB) file can't be upload due to the size limitation of attachment (1MB).