HomePhabricator

[AArch64][GlobalISel] Simplify zext/sext selection, use MachineIRBuilder. NFC.

Description

[AArch64][GlobalISel] Simplify zext/sext selection, use MachineIRBuilder. NFC.

Details

Committed
aemersonThu, Jul 25, 5:01 PM
Parents
rL367074: [clang-doc] Fix failing tests on Windows
Branches
Unknown
Tags
Unknown

Event Timeline

brzycki added a subscriber: brzycki.EditedFri, Jul 26, 8:27 AM

@aemerson , this commit causes a compiler crash when compiling libcxx for aarch64. Specifically, the file filesystem/operations.cpp:

FAILED: src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.o
/work/nightly/bisect/bin/aarch64-linux-clang++  -DNDEBUG -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_COMMENT_LIB_PRAGMA -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Iinclude/c++build -I/tmp/tmp.vruMese6eR/src/libcxx/include --target=aarch64-unknown-linux-gnu --sysroot=/work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot --gcc-toolchain=/work/nightly/bisect/bin -fPIC   --target=aarch64-unknown-linux-gnu --sysroot=/work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot --gcc-toolchain=/work/nightly/bisect/bin -DLIBCXX_BUILDING_LIBCXXABI -std=c++11 -nostdinc++ -fvisibility-inlines-hidden -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wno-user-defined-literals -Wno-covered-switch-default -Wno-ignored-attributes -Wno-error -MD -MT src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.o -MF src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.o.d -o src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.o -c /tmp/tmp.vruMese6eR/src/libcxx/src/filesystem/operations.cpp
clang-10: /tmp/tmp.vruMese6eR/src/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp:2040: virtual bool (anonymous namespace)::AArch64InstructionSelector::select(llvm::MachineInstr &, llvm::CodeGenCoverage &) const: Assertion `(*RBI.getRegBank(DefReg, MRI, TRI)).getID() == AArch64::GPRRegBankID && "Unexpected ext regbank"' failed.
Stack dump:
0.      Program arguments: /work/nightly/bisect/bin/clang-10 -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name operations.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /tmp/tmp.vruMese6eR/build/libcxx-shared/src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.gcno -nostdinc++ -resource-dir /work/nightly/bisect/lib/clang/10.0.0 -dependency-file src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.o.d -sys-header-deps -MT src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.o -cxx-isystem /work/nightly/bisect/aarch64-unknown-linux-gnu/include/c++/8.3.0 -cxx-isystem /work/nightly/bisect/aarch64-unknown-linux-gnu/include/c++/8.3.0/aarch64-unknown-linux-gnu -D _GLIBCXX_INCLUDE_NEXT_C_HEADERS -D NDEBUG -D _LIBCPP_BUILDING_LIBRARY -D _LIBCPP_HAS_COMMENT_LIB_PRAGMA -D _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -I include/c++build -I /tmp/tmp.vruMese6eR/src/libcxx/include -D LIBCXX_BUILDING_LIBCXXABI -isysroot /work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot -internal-isystem /work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot/usr/local/include -internal-isystem /work/nightly/bisect/lib/clang/10.0.0/include -internal-externc-isystem /work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot/include -internal-externc-isystem /work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot/usr/include -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wno-user-defined-literals -Wno-covered-switch-default -Wno-ignored-attributes -Wno-error -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /tmp/tmp.vruMese6eR/build/libcxx-shared -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -faddrsig -o src/CMakeFiles/cxx_shared.dir/filesystem/operations.cpp.o -x c++ /tmp/tmp.vruMese6eR/src/libcxx/src/filesystem/operations.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/tmp/tmp.vruMese6eR/src/libcxx/src/filesystem/operations.cpp'.
4.      Running pass 'InstructionSelect' on function '@_ZNSt3__16chrono8durationInNS_5ratioILl1ELl1EEEEC2IlEERKT_PNS_9enable_ifIXaasr14is_convertibleIS6_nEE5valueooL_ZNS_17integral_constantIbLb0EE5valueEEntsr23treat_as_floating_pointIS6_EE5valueEvE4typeE'
 #0 0x00007f177532f954 PrintStackTraceSignalHandler(void*) (/work/nightly/bisect/lib/libLLVMSupport.so.10svn+0x180954)
 #1 0x00007f177532d63e llvm::sys::RunSignalHandlers() (/work/nightly/bisect/lib/libLLVMSupport.so.10svn+0x17e63e)
 #2 0x00007f177532fc08 SignalHandler(int) (/work/nightly/bisect/lib/libLLVMSupport.so.10svn+0x180c08)
 #3 0x00007f17796c2890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f17727ade97 raise /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f17727af801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f177279f39a __assert_fail_base /build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f177279f412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x00007f177ca9206f (anonymous namespace)::AArch64InstructionSelector::select(llvm::MachineInstr&, llvm::CodeGenCoverage&) const (/work/nightly/bisect/lib/libLLVMAArch64CodeGen.so.10svn+0x12a06f)
 #9 0x00007f17721bfe13 llvm::InstructionSelect::runOnMachineFunction(llvm::MachineFunction&) (/work/nightly/bisect/lib/libLLVMGlobalISel.so.10svn+0x4ae13)
#10 0x00007f177a49440a llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/work/nightly/bisect/lib/libLLVMCodeGen.so.10svn+0x22840a)
#11 0x00007f17769f0e43 llvm::FPPassManager::runOnFunction(llvm::Function&) (/work/nightly/bisect/lib/libLLVMCore.so.10svn+0x1e1e43)
#12 0x00007f17769f1153 llvm::FPPassManager::runOnModule(llvm::Module&) (/work/nightly/bisect/lib/libLLVMCore.so.10svn+0x1e2153)
#13 0x00007f17769f17bd llvm::legacy::PassManagerImpl::run(llvm::Module&) (/work/nightly/bisect/lib/libLLVMCore.so.10svn+0x1e27bd)
#14 0x00007f17788ac45c clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/work/nightly/bisect/lib/libclangCodeGen.so.10svn+0x9445c)
#15 0x00007f1778b63de1 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/work/nightly/bisect/lib/libclangCodeGen.so.10svn+0x34bde1)
#16 0x00007f176f72cef3 clang::ParseAST(clang::Sema&, bool, bool) (/work/nightly/bisect/lib/libclangParse.so.10svn+0x2eef3)
#17 0x00007f17781224f8 clang::FrontendAction::Execute() (/work/nightly/bisect/lib/libclangFrontend.so.10svn+0xe84f8)
#18 0x00007f17780bd988 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/work/nightly/bisect/lib/libclangFrontend.so.10svn+0x83988)
#19 0x00007f1777e3708c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/work/nightly/bisect/lib/libclangFrontendTool.so.10svn+0x408c)
#20 0x0000000000410d5c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/work/nightly/bisect/bin/clang-10+0x410d5c)
#21 0x000000000040eae4 main (/work/nightly/bisect/bin/clang-10+0x40eae4)
#22 0x00007f1772790b97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#23 0x000000000040bd9a _start (/work/nightly/bisect/bin/clang-10+0x40bd9a)
clang-10: error: unable to execute command: Aborted (core dumped)
clang-10: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 10.0.0 (/sarc-c/compiler/git/tools/llvm-project.git c07fe307b48a98a149578948b167802f7b2825cf)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/nightly/bisect/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-10: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-10: note: diagnostic msg: /tmp/operations-d52ce3.cpp
clang-10: note: diagnostic msg: /tmp/operations-d52ce3.sh
clang-10: note: diagnostic msg:

********************

I have attached the emitted diagnostic files:

The build invocation for CMake of clang/llvm is the following:

/tools/build/cmake-3.15.0/bin/cmake \
  -D CCACHE_PROGRAM=/tools/build/ccache-3.2.5/usr/bin/ccache \
  -D LLVM_CCACHE_BUILD=ON \
  -G Ninja \
  -D CMAKE_MAKE_PROGRAM=/tools/build/ninja-1.9.0/ninja \
  -D 'LLVM_TARGETS_TO_BUILD=X86;AArch64;ARM' \
  -D CMAKE_BUILD_TYPE=Release \
  -D CMAKE_INSTALL_PREFIX=/work/nightly/bisect \
  -D LLVM_PARALLEL_LINK_JOBS=1 \
  -D BUILD_SHARED_LIBS=ON \
  -D LLVM_ENABLE_ASSERTIONS=ON \
  -D LLVM_BINUTILS_INCDIR=/tools/cross/aarch64/buildroot/2019.02_sysroot/lib/gcc/aarch64-unknown-linux-gnu/8.3.0/plugin/include \
  -D LIBCXX_ENABLE_SHARED=OFF \
  -D LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
  -D LINK_POLLY_INTO_TOOLS=ON \
  -D LLVM_OPTIMIZED_TABLEGEN=ON \
  /tmp/tmp.vruMese6eR/src/llvm

And the CMake invocation for libcxx is the following:

export CC=/work/nightly/bisect/bin/aarch64-linux-clang
export CXX=/work/nightly/bisect/bin/aarch64-linux-clang++
/tools/build/cmake-3.15.0/bin/cmake \
  -D CCACHE_PROGRAM=/tools/build/ccache-3.2.5/usr/bin/ccache \
  -D LLVM_CCACHE_BUILD=ON \
  -D LIBCXX_ENABLE_SHARED=ON \
  -G Ninja \
  -D CMAKE_MAKE_PROGRAM=/tools/build/ninja-1.9.0/ninja \
  -D CMAKE_INSTALL_PREFIX=/work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot \
  -D LLVM_PATH=/tmp/tmp.vruMese6eR/src/llvm \
  -D LIBCXX_TARGET_TRIPLE=aarch64-unknown-linux-gnu \
  -D LIBCXX_CXX_ABI=libcxxabi \
  -D LIBCXX_CXX_ABI_INCLUDE_PATHS=/tmp/tmp.vruMese6eR/src/libcxxabi/include \
  -D LIBCXX_SYSROOT=/work/nightly/bisect/aarch64-unknown-linux-gnu/sysroot \
  -D LIBCXX_GCC_TOOLCHAIN=/work/nightly/bisect/bin \
  -D CMAKE_C_FLAGS= \
  -D CMAKE_CXX_FLAGS= \
  /tmp/tmp.vruMese6eR/src/libcxx

Thanks for reporting this, looks like our recent enabling of s128 types caused the assert to trigger now, but the sext is trying to extend from the wrong reg bank. I've fixed it in r367164.