[llvm] [SLP]Improve minbitwidth analysis. (PR #84536)

Zequan Wu via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 16:15:40 PDT 2024


ZequanWu wrote:

The reland https://github.com/llvm/llvm-project/commit/31eaf86a1e8f1870e6ee4c42088a5213bde294b8 causes clang crash:
```
clang-cl: ../../llvm/lib/IR/Instructions.cpp:737: void llvm::CallInst::init(FunctionType *, Value *, ArrayRef<Value *>, ArrayRef<OperandBundleDef>, const Twine &): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' 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: clang-cl -cc1 -triple x86_64-pc-windows-msvc19.34.0 -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name performance_metrics_overlay.cc -mrelocation-model pic -pic-level 2 -fmerge-all-constants -fno-delete-null-pointer-checks -mframe-pointer=none -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -fms-volatile -funwind-tables=2 -target-cpu x86-64 -target-feature +sse3 -mllvm -x86-asm-syntax=intel -tune-cpu generic -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames --show-includes -fno-rtti-data -stack-protector 2 -fdiagnostics-format msvc -cfguard-no-checks -gcodeview -gcodeview-ghash -gno-codeview-command-line -debug-info-kind=line-tables-only -fdebug-compilation-dir=. -object-file-name=obj\\media\\cast\\sender\\performance_metrics_overlay.obj -mllvm -crash-diagnostics-dir=../../tools/clang/crashreports -ffunction-sections -fcoverage-compilation-dir=. -D USE_AURA=1 -D MEMORY_TOOL_REPLACES_ALLOCATOR -D ADDRESS_SANITIZER -D _HAS_NODISCARD -D _CRT_NONSTDC_NO_WARNINGS -D _WINSOCK_DEPRECATED_NO_WARNINGS -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D CR_CLANG_REVISION=\"llvmorg-19-init-6054-g9fb85b09-1\" -D _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D CR_LIBCXX_REVISION=80307e66e74bae927fb8709a549859e777e3bf0b -D TEMP_REBUILD_HACK -D __STD_C -D _CRT_RAND_S -D _CRT_SECURE_NO_DEPRECATE -D _SCL_SECURE_NO_DEPRECATE -D _ATL_NO_OPENGL -D _WINDOWS -D CERT_CHAIN_PARA_HAS_EXTRA_FIELDS -D PSAPI_VERSION=2 -D WIN32 -D _SECURE_ATL -D WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D WIN32_LEAN_AND_MEAN -D NOMINMAX -D _UNICODE -D UNICODE -D NTDDI_VERSION=NTDDI_WIN10_NI -D _WIN32_WINNT=0x0A00 -D WINVER=0x0A00 -D NDEBUG -D NVALGRIND -D DYNAMIC_ANNOTATIONS_ENABLED=0 -D BASE_USE_PERFETTO_CLIENT_LIBRARY=1 -D ENABLE_IPC_FUZZER -D LIBYUV_DISABLE_NEON -D LIBYUV_DISABLE_LSX -D LIBYUV_DISABLE_LASX -D SK_ENABLE_SKSL -D SK_UNTIL_CRBUG_1187654_IS_FIXED -D SK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\" -D SK_WIN_FONTMGR_NO_SIMULATIONS -D SK_DISABLE_LEGACY_INIT_DECODERS -D SK_SLUG_DISABLE_LEGACY_DESERIALIZE -D SK_DISABLE_LEGACY_VULKAN_BACKENDSEMAPHORE -D SK_DISABLE_LEGACY_CREATE_CHARACTERIZATION -D SK_DISABLE_LEGACY_VULKAN_MUTABLE_TEXTURE_STATE -D SK_CODEC_DECODES_JPEG -D SK_ENCODE_JPEG -D SK_ENCODE_PNG -D SK_ENCODE_WEBP -D GR_GL_FUNCTION_TYPE=__stdcall -D SK_GANESH -D SK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -D SK_GL -D SK_VULKAN=1 -D SK_GRAPHITE -D SK_DAWN -D VK_USE_PLATFORM_WIN32_KHR -D USE_EGL -D GOOGLE_PROTOBUF_NO_RTTI -D GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -D GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE=0 -D U_USING_ICU_NAMESPACE=0 -D U_ENABLE_DYLOAD=0 -D USE_CHROMIUM_ICU=1 -D U_ENABLE_TRACING=1 -D U_ENABLE_RESOURCE_TRACING=0 -D U_STATIC_IMPLEMENTATION -D ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -D WEBRTC_ENABLE_AVX2 -D RTC_ENABLE_WIN_WGC -D WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -D WEBRTC_CHROMIUM_BUILD -D WEBRTC_WIN -D ABSL_ALLOCATOR_NOTHROW=1 -D LOGGING_INSIDE_WEBRTC -D ENABLE_TRACE_LOGGING -D CRASHPAD_ZLIB_SOURCE_EXTERNAL -D LEVELDB_PLATFORM_CHROMIUM=1 -D __WRL_ENABLE_FUNCTION_STATICS__ -D __DATE__= -D __TIME__= -D __TIMESTAMP__= -D PROTOBUF_ALLOW_DEPRECATED=1 -ffile-reproducible -O2 -WCL4 -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-nonportable-include-path -Wno-cast-function-type -Wno-ignored-pragma-optimize -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-deprecated-this-capture -Wno-invalid-offsetof -Wno-vla-extension -Wno-thread-safety-reference-return -Wshadow -Wno-builtin-macro-redefined -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-redundant-parens -Wno-redundant-parens -Wenum-compare-conditional -Wno-c++11-narrowing-const-reference -Wno-trigraphs -fdeprecated-macro -ferror-limit 19 -fsanitize=address -fno-sanitize-memory-param-retval -fsanitize-address-use-after-scope -fsanitize-address-globals-dead-stripping -fno-sanitize-address-use-odr-indicator -fno-assume-sane-operator-new -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.34 -std=c++20 -fno-implicit-modules -fskip-odr-check-in-gmf -Qn -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -x c++ performance_metrics_overlay-b41337.cpp
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x00005576b9397188 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x3af5188)
 #1 0x00005576b9394ebe llvm::sys::RunSignalHandlers() (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x3af2ebe)
 #2 0x00005576b939781d SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f85a0f7b510 (/lib/x86_64-linux-gnu/libc.so.6+0x3c510)
 #4 0x00007f85a0fc916c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f85a0f7b472 raise ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007f85a0f654b2 abort ./stdlib/abort.c:81:7
 #7 0x00007f85a0f653d5 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #8 0x00007f85a0f743a2 (/lib/x86_64-linux-gnu/libc.so.6+0x353a2)
 #9 0x00005576b912c0ae llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*>>, llvm::Twine const&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x388a0ae)
#10 0x00005576b7eee0ed llvm::CallInst::Create(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*>>, llvm::Twine const&, llvm::Instruction*) CodeGenModule.cpp:0:0
#11 0x00005576b7f36890 llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*>>, llvm::Twine const&, llvm::MDNode*) CGCall.cpp:0:0
#12 0x00005576bb7f4c16 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f52c16)
#13 0x00005576bb7f2327 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f50327)
#14 0x00005576bb7f3709 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f51709)
#15 0x00005576bb7f2327 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f50327)
#16 0x00005576bb7f3f4b llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f51f4b)
#17 0x00005576bb7f2327 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f50327)
#18 0x00005576bb7f385b llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f5185b)
#19 0x00005576bb7f2327 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f50327)
#20 0x00005576bb7f477a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f5277a)
#21 0x00005576bb7f81e1 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f561e1)
#22 0x00005576bb7f7ff2 llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f55ff2)
#23 0x00005576bb8084de llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f664de)
#24 0x00005576bb809b64 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&)::$_0::operator()(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&) const SLPVectorizer.cpp:0:0
#25 0x00005576bb808ffb llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f66ffb)
#26 0x00005576bb805b3b llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f63b3b)
#27 0x00005576bb804e9b llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f62e9b)
#28 0x00005576bb80479f llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x5f6279f)
#29 0x00005576bb35ea1d llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#30 0x00005576b919d7c0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x38fb7c0)
#31 0x00005576b845857d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) BackendUtil.cpp:0:0
#32 0x00005576b919c472 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x38fa472)
#33 0x00005576b8454d2d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) BackendUtil.cpp:0:0
#34 0x00005576b919ca52 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x38faa52)
#35 0x00005576b844b03c (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(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>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#36 0x00005576b8443acc 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>>, clang::BackendConsumer*) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x2ba1acc)
#37 0x00005576b845d4f5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x2bbb4f5)
#38 0x00005576ba357a09 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x4ab5a09)
#39 0x00005576b86f2d5f clang::FrontendAction::Execute() (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x2e50d5f)
#40 0x00005576b866a28d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x2dc828d)
#41 0x00005576b87ce307 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x2f2c307)
#42 0x00005576b7e1e015 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x257c015)
#43 0x00005576b7e2c669 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#44 0x00005576b7e2b663 clang_main(int, char**, llvm::ToolContext const&) (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x2589663)
#45 0x00005576b7e2d447 main (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x258b447)
#46 0x00007f85a0f666ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#47 0x00007f85a0f66785 call_init ./csu/../csu/libc-start.c:128:20
#48 0x00007f85a0f66785 __libc_start_main ./csu/../csu/libc-start.c:347:5
#49 0x00005576b7e1cd11 _start (/usr/local/google/home/zequanwu/workspace/llvm/out/gn/bin/clang+0x257ad11)
```

https://github.com/llvm/llvm-project/pull/84536


More information about the llvm-commits mailing list