We don't have VP_ANY_EXTEND or VP_SIGN_EXTEND_INREG yet so I've
deviated a little from the non-VP lowering.
My goal was to fix the crashes that occurs on these test cases without this patch.
Differential D152854
[SelectionDAG][RISCV] Add very basic PromoteIntegerResult/Op support for VP_SIGN/ZERO_EXTEND. craig.topper on Jun 13 2023, 1:34 PM. Authored by
Details We don't have VP_ANY_EXTEND or VP_SIGN_EXTEND_INREG yet so I've My goal was to fix the crashes that occurs on these test cases without this patch.
Diff Detail
Event Timeline
Comment Actions This is causing Chrome debug builds on Linux to fail (https://crbug.com/1455144) clang++: /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:780: llvm::SDValue llvm::DAGTypeLegalizer::PromoteIntRes_INT_EXTEND(llvm::SDNode *): Assertion `N->getNumOperands() == 3 && "Unexpected number of operands!"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /usr/local/google/home/ayzhao/src/llvm-project/build/bin/clang++ -MMD -MF obj/third_party/swiftshader/third_party/llvm-10.0/swiftshader_llvm_most/CodeViewDebug.o.d -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LIBCPP_ENABLE_ASSERTIONS=1 -DCOMPONENT_BUILD -DCR_LIBCXX_REVISION=055b2e17ae4f0e2c025ad0c7508b01787df17758 -DCR_SYSROOT_KEY=20230611T210420Z-1 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -I../../third_party/swiftshader/third_party/llvm-10.0/llvm/include -I../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Target/AArch64 -I../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Target/ARM -I../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Target/Mips -I../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Target/PowerPC -I../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Target/RISCV -I../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Target/X86 -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/include -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/IR -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/Target/AArch64 -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/Target/ARM -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/Target/Mips -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/Target/PowerPC -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/Target/RISCV -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/Target/X86 -I../../third_party/swiftshader/third_party/llvm-10.0/configs/common/lib/Transforms/InstCombine -I../../third_party/swiftshader/third_party/llvm-10.0/configs/linux/include -I../.. -Igen -I../../buildtools/third_party/libc++ -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -fcomplete-member-pointers -m64 -msse3 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -gdwarf-4 -g2 -gdwarf-aranges -gsplit-dwarf -ggnu-pubnames -Xclang -fuse-ctor-homing -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -Werror -Wall -Wno-unused-variable -Wno-c++11-narrowing -Wno-unused-but-set-variable -Wno-misleading-indentation -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-ignored-pragma-optimize -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-deprecated-this-capture -Wno-builtin-macro-redefined -Wno-shadow -Wno-attributes -Wno-bitwise-instead-of-logical -Wno-deprecated-declarations -Wno-enum-compare -Wno-header-hygiene -Wno-unused-function -Wno-unused-local-typedef -Wno-unused-private-field -Wno-unused-result -Wno-unused-variable -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++20 -Wno-trigraphs -gsimple-template-names -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -c ../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp -o obj/third_party/swiftshader/third_party/llvm-10.0/swiftshader_llvm_most/CodeViewDebug.o 1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module '../../third_party/swiftshader/third_party/llvm-10.0/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp'. 4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN4llvm13CodeViewDebug17createDefRangeMemEti' #0 0x0000564dc408c4fd llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:602:11 #1 0x0000564dc408c99b PrintStackTraceSignalHandler(void*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:675:1 #2 0x0000564dc408ac16 llvm::sys::RunSignalHandlers() /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Signals.cpp:104:5 #3 0x0000564dc408bd6e llvm::sys::CleanupOnSignal(unsigned long) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:368:1 #4 0x0000564dc3fc8884 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:7 #5 0x0000564dc3fc8c42 CrashRecoverySignalHandler(int) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1 #6 0x00007fe04825af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90) #7 0x00007fe0482a9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #8 0x00007fe04825aef2 raise ./signal/../sysdeps/posix/raise.c:27:6 #9 0x00007fe048245472 abort ./stdlib/abort.c:81:7 #10 0x00007fe048245395 _nl_load_domain ./intl/loadmsgcat.c:1177:9 #11 0x00007fe048253df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2) #12 0x0000564dc5bf00aa llvm::DAGTypeLegalizer::PromoteIntRes_INT_EXTEND(llvm::SDNode*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:781:5 #13 0x0000564dc5be599e llvm::DAGTypeLegalizer::PromoteIntegerResult(llvm::SDNode*, unsigned int) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:147:32 #14 0x0000564dc5b33f6f llvm::DAGTypeLegalizer::run() /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:263:17 #15 0x0000564dc5b38adb llvm::SelectionDAG::LegalizeTypes() /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:1059:34 #16 0x0000564dc5a92684 llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:807:13 #17 0x0000564dc5a91fed llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:702:1 #18 0x0000564dc5a91a24 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1705:11 #19 0x0000564dc5a8ef4a llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:482:3 #20 0x0000564dc1d07eea (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7 #21 0x0000564dc3081d75 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8 #22 0x0000564dc38f163a llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1435:23 #23 0x0000564dc38f6482 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1481:16 #24 0x0000564dc38f1ef9 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1550:23 #25 0x0000564dc38f1a6d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16 #26 0x0000564dc38f6761 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1677:3 #27 0x0000564dc443b33a (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1101:3 #28 0x0000564dc4435772 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1124:7 #29 0x0000564dc4434c37 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1283:3 #30 0x0000564dc5c34965 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:386:7 #31 0x0000564dc81faa03 clang::ParseAST(clang::Sema&, bool, bool) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Parse/ParseAST.cpp:183:12 #32 0x0000564dc5119ebc clang::ASTFrontendAction::ExecuteAction() /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1172:1 #33 0x0000564dc5c2ff84 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1171:5 #34 0x0000564dc51198bc clang::FrontendAction::Execute() /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1064:7 #35 0x0000564dc5043918 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23 #36 0x0000564dc52e3207 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8 #37 0x0000564dc1b71143 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/ayzhao/src/llvm-project/clang/tools/driver/cc1_main.cpp:249:13 #38 0x0000564dc1b5cb7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/ayzhao/src/llvm-project/clang/tools/driver/driver.cpp:366:5 #39 0x0000564dc1b5e4ed clang_main(int, char**, llvm::ToolContext const&)::$_0::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/ayzhao/src/llvm-project/clang/tools/driver/driver.cpp:506:7 #40 0x0000564dc1b5e4bd int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5 #41 0x0000564dc4ee78c9 llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5 #42 0x0000564dc4ee4028 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1::operator()() const /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Driver/Job.cpp:439:34 #43 0x0000564dc4ee3ff5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1>(long) /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5 #44 0x0000564dc2da9399 llvm::function_ref<void ()>::operator()() const /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5 #45 0x0000564dc3fc869a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:3 #46 0x0000564dc4ee3947 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Driver/Job.cpp:439:7 #47 0x0000564dc4e7e37f clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Driver/Compilation.cpp:199:15 #48 0x0000564dc4e7e587 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Driver/Compilation.cpp:253:13 #49 0x0000564dc4e98f18 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Driver/Driver.cpp:1866:7 #50 0x0000564dc1b5c638 clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/ayzhao/src/llvm-project/clang/tools/driver/driver.cpp:542:9 #51 0x0000564dc1b9493d main /usr/local/google/home/ayzhao/src/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:15:3 #52 0x00007fe04824618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #53 0x00007fe048246245 call_init ./csu/../csu/libc-start.c:128:20 #54 0x00007fe048246245 __libc_start_main ./csu/../csu/libc-start.c:368:5 #55 0x0000564dc1b5b2d1 _start (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/clang+++0x1b242d1) clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation) clang version 17.0.0 (git@github.com:llvm/llvm-project.git 6bf79fb09416b02b3f8589a4998610d70c185dae) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/google/home/ayzhao/src/llvm-project/build/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: ../../tools/clang/crashreports/CodeViewDebug-8526b2.cpp clang++: note: diagnostic msg: ../../tools/clang/crashreports/CodeViewDebug-8526b2.sh clang++: note: diagnostic msg: ******************** Comment Actions It looks like an ISD::SIGN_EXTEND is being created somewhere with an error ValueType operand that it shouldn't have. That looks like an existing bug that my patch happened to catch. |
This could maybe do with a comment - I notice the code below has Otherwise, just extend the original operand .... Does this apply here too?