This is an archive of the discontinued LLVM Phabricator instance.

InstSimplify: Start cleaning up simplifyFCmpInst
ClosedPublic

Authored by arsenm on Jun 1 2023, 6:49 AM.

Details

Summary

Also picks up a few improvements (Some of the fcmp.ll
test names imply they aren't quite testing what was intended.
Checking the sign bit can't be performed with a compare to a 0).

Much of the logic in here is the same as the class detection
logic of fcmpToClassTest. We could unify more with a weaker
version of fcmpToClassTest which returns implied classes rather
than exact class-like compares. Also could unify more with detection
of possible classes in non-splat vectors.

One problem here is we now only perform folds that used
to always work now require a context instruction. This is
because fcmpToClassTest requires the parent function.
Either fcmpToClassTest could tolerate a missing context
function, or we could require passing in one to simplifyFCmpInst.
Without this it's possible to hit the !isNan assert (which feels like
an unnecessary assert). In any case, these cases don't appear in
any tests.

Diff Detail

Event Timeline

arsenm created this revision.Jun 1 2023, 6:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 6:49 AM
arsenm requested review of this revision.Jun 1 2023, 6:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 6:49 AM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm added a reviewer: nikic.Jun 1 2023, 6:49 AM
jcranmer-intel added inline comments.Jul 21 2023, 2:19 PM
llvm/lib/Analysis/InstructionSimplify.cpp
4086

This should say "constants are handled below", right?

arsenm updated this revision to Diff 543164.Jul 22 2023, 4:10 AM

Rebase (new attributor test caught a bug from not passing through the defaulted arguments) and update comment

llvm/lib/Analysis/InstructionSimplify.cpp
4109

Nit: this if statement needs a comment explaining which cases its intended to case (compares that can be written as class tests.

4127–4128

This TODO is effectively done with m_APFloatAllowUndef, right?

4136

The clearing of fcNaN is already done by the above helper for computeKnownFPClass, so you shouldn't need the select here (and later).

4140

Nit: extra space.

arsenm updated this revision to Diff 550460.Aug 15 2023, 1:52 PM
arsenm marked 3 inline comments as done.
arsenm added inline comments.Aug 15 2023, 1:52 PM
llvm/lib/Analysis/InstructionSimplify.cpp
4127–4128

Kind of, it doesn't handle cases like mixed negative-but-not-splat vectors

jcranmer-intel accepted this revision.Aug 30 2023, 8:14 AM
This revision is now accepted and ready to land.Aug 30 2023, 8:14 AM

Heads up this causing assertion failure when compiling chromium code:

clang++: /usr/local/google/home/zequanwu/workspace/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:4136: llvm::Value *simplifyFCmpInst(unsigned int, llvm::Value *, llvm::Value *, llvm::FastMathFlags, const llvm::SimplifyQuery &, unsigned int): Assertion `!C->isNaN() && "Unexpected NaN constant!"' 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/zequanwu/workspace/llvm-project/build/cmake/bin/clang++ -MMD -MF obj/ui/gfx/color_space/color_space.o.d -DCOLOR_SPACE_IMPLEMENTATION -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -DOFFICIAL_BUILD -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D_GNU_SOURCE -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -DCR_LIBCXX_REVISION=84fb809dd6dae36d556dc0bb702c6cc2ce9d4b80 -DCR_SYSROOT_KEY=20230611T210420Z-2 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_56 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 -DBASE_USE_PERFETTO_CLIENT_LIBRARY=1 -DSK_ENABLE_SKSL -DSK_UNTIL_CRBUG_1187654_IS_FIXED -DSK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\" -DSK_WIN_FONTMGR_NO_SIMULATIONS -DSK_DISABLE_LEGACY_SKSURFACE_METHODS -DSK_DISABLE_LEGACY_GRAPHITE_IMAGE_FACTORIES -DSK_DISABLE_LEGACY_GRAPHITE_IMAGE_METHODS -DSK_DISABLE_LEGACY_SKSURFACE_FACTORIES -DSK_DISABLE_LEGACY_SKSURFACE_FLUSH -DSK_DISABLE_LEGACY_SKSURFACE_AS_IMAGE -DSK_DISABLE_LEGACY_SKSURFACE_DISPLAYLIST -DSK_DISABLE_LEGACY_IMAGE_SUBSET_METHODS -DSK_DISABLE_LEGACY_IMAGE_COLORSPACE_METHODS -DSK_DISABLE_LEGACY_IMAGE_RELEASE_PROCS -DSK_DISABLE_LEGACY_GL_BACKEND_SURFACE -DSK_DISABLE_LEGACY_INIT_DECODERS -DSK_CODEC_DECODES_JPEG -DSK_ENCODE_JPEG -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSK_GANESH -DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -DSK_GL -DSK_VULKAN=1 -DSK_GRAPHITE -DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_WAYLAND_KHR -DWEBP_EXTERN=extern -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -I../../third_party/skia -Igen/third_party/skia -I../../third_party/wuffs/src/release/c -I../../third_party/vulkan/include -I../../third_party/vulkan-deps/vulkan-headers/src/include -I../../third_party/wayland/src/src -I../../third_party/wayland/include/src -I../../third_party/libwebp/src/src -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -Wall -Werror -Wextra -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -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 -Wshadow -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers -m64 -msse3 -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-omit-frame-pointer -g0 -fprofile-generate -fsanitize=cfi-vcall -fsanitize-ignorelist=../../tools/cfi/ignores.txt -fsanitize=cfi-icall -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/include/glib-2.0 -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wno-redundant-parens -DPROTOBUF_ALLOW_DEPRECATED=1 -std=c++20 -Wno-trigraphs -gsimple-template-names -fno-exceptions -fno-rtti -nostdinc++ -isystem../../third_party/libc++/src/include -isystem../../third_party/libc++abi/src/include --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -c ../../ui/gfx/color_space.cc -o obj/ui/gfx/color_space/color_space.o
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x0000564f48406a07 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x355da07)
 #1 0x0000564f484046ee llvm::sys::RunSignalHandlers() (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x355b6ee)
 #2 0x0000564f483788a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fbf98c5a540 (/lib/x86_64-linux-gnu/libc.so.6+0x3c540)
 #4 0x00007fbf98ca812c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fbf98c5a4a2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007fbf98c444b2 abort ./stdlib/abort.c:81:7
 #7 0x00007fbf98c443d5 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #8 0x00007fbf98c533a2 (/lib/x86_64-linux-gnu/libc.so.6+0x353a2)
 #9 0x0000564f475c0b93 simplifyFCmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::FastMathFlags, llvm::SimplifyQuery const&, unsigned int) InstructionSimplify.cpp:0:0
#10 0x0000564f4b848df0 llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(llvm::Value*, llvm::BasicBlock*, llvm::SmallVectorImpl<std::pair<llvm::Constant*, llvm::BasicBlock*>>&, llvm::jumpthreading::ConstantPreference, llvm::DenseSet<llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>>&, llvm::Instruction*) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x699fdf0)
#11 0x0000564f4b84ab44 llvm::JumpThreadingPass::processThreadableEdges(llvm::Value*, llvm::BasicBlock*, llvm::jumpthreading::ConstantPreference, llvm::Instruction*) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x69a1b44)
#12 0x0000564f4b8476db llvm::JumpThreadingPass::processBlock(llvm::BasicBlock*) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x699e6db)
#13 0x0000564f4b846713 llvm::JumpThreadingPass::runImpl(llvm::Function&, llvm::AnalysisManager<llvm::Function>*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::LazyValueInfo*, llvm::AAResults*, std::unique_ptr<llvm::DomTreeUpdater, std::default_delete<llvm::DomTreeUpdater>>, std::optional<llvm::BlockFrequencyInfo*>, std::optional<llvm::BranchProbabilityInfo*>) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x699d713)
#14 0x0000564f4b845dd4 llvm::JumpThreadingPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x699cdd4)
#15 0x0000564f4861135d llvm::detail::PassModel<llvm::Function, llvm::JumpThreadingPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x376835d)
#16 0x0000564f47e86ee4 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x2fddee4)
#17 0x0000564f4626edbd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x13c5dbd)
#18 0x0000564f47539b96 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x2690b96)
#19 0x0000564f46270e0d llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x13c7e0d)
#20 0x0000564f47534423 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x268b423)
#21 0x0000564f495286dd llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x467f6dd)
#22 0x0000564f47537d58 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x268ed58)
#23 0x0000564f495428fd llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x46998fd)
#24 0x0000564f47536418 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x268d418)
#25 0x0000564f495289ad llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x467f9ad)
#26 0x0000564f47e860f4 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x2fdd0f4)
#27 0x0000564f496672cc llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x47be2cc)
#28 0x0000564f4952eeed llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x4685eed)
#29 0x0000564f47e860f4 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x2fdd0f4)
#30 0x0000564f4860b22c (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>>&) BackendUtil.cpp:0:0
#31 0x0000564f48601770 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/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3758770)
#32 0x0000564f4947117a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x45c817a)
#33 0x0000564f4a4f0534 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x5647534)
#34 0x0000564f48dca780 clang::FrontendAction::Execute() (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3f21780)
#35 0x0000564f48d3b1af clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3e921af)
#36 0x0000564f48ea459c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3ffb59c)
#37 0x0000564f45f5b4ae cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x10b24ae)
#38 0x0000564f45f582d1 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#39 0x0000564f48b9d479 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) Job.cpp:0:0
#40 0x0000564f483785eb llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x34cf5eb)
#41 0x0000564f48b9ca10 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/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3cf3a10)
#42 0x0000564f48b5c52e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3cb352e)
#43 0x0000564f48b5c7e7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3cb37e7)
#44 0x0000564f48b7cce7 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x3cd3ce7)
#45 0x0000564f45f5791e clang_main(int, char**, llvm::ToolContext const&) (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x10ae91e)
#46 0x0000564f45f67861 main (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x10be861)
#47 0x00007fbf98c456ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#48 0x00007fbf98c45785 call_init ./csu/../csu/libc-start.c:128:20
#49 0x00007fbf98c45785 __libc_start_main ./csu/../csu/libc-start.c:347:5
#50 0x0000564f45f54711 _start (/usr/local/google/home/zequanwu/workspace/llvm-project/build/cmake/bin/clang+++0x10ab711)

Trying to reduce the crash.

Attach reduced IR:

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: null_pointer_is_valid
define i1 @_ZNK3gfx10ColorSpace25IsTransferFunctionEqualToERK22skcms_TransferFunction(ptr %this, float %0) #0 {
entry:
  store float 0xFFFFFFFFE0000000, ptr %this, align 4
  %call = call i1 @_ZNK3gfx10ColorSpace19GetTransferFunctionEP22skcms_TransferFunctionN4absl8optionalIfEE()
  %1 = load float, ptr %this, align 4
  %cmp = fcmp oeq float %1, %0
  br i1 %cmp, label %land.lhs.true, label %land.end

land.lhs.true:                                    ; preds = %entry
  %2 = load float, ptr null, align 4294967296
  %tobool = fcmp une float %2, 0.000000e+00
  br i1 %tobool, label %land.rhs, label %land.end

land.rhs:                                         ; preds = %land.lhs.true
  br label %land.end

land.end:                                         ; preds = %land.rhs, %land.lhs.true, %entry
  %3 = phi i1 [ false, %land.lhs.true ], [ false, %entry ], [ true, %land.rhs ]
  ret i1 %3
}

; Function Attrs: null_pointer_is_valid
define i1 @_ZNK3gfx10ColorSpace19GetTransferFunctionEP22skcms_TransferFunctionN4absl8optionalIfEE() #0 {
entry:
  %0 = load i8, ptr null, align 4294967296
  switch i8 %0, label %sw.default [
    i8 0, label %common.ret
    i8 1, label %common.ret
  ]

common.ret:                                       ; preds = %sw.default, %entry, %entry
  ret i1 false

sw.default:                                       ; preds = %entry
  %call6 = call i1 null(i8 0, ptr null)
  br label %common.ret
}

attributes #0 = { null_pointer_is_valid }

This command triggers the error even with the fix (0637b00041c7d6a191d51d9966c4f5f41fb97ab5):

opt '-passes=default<O2>' reduce.ll
arsenm added a comment.Sep 2 2023, 7:22 AM

Attach reduced IR:

This command triggers the error even with the fix (0637b00041c7d6a191d51d9966c4f5f41fb97ab5):

opt '-passes=default<O2>' reduce.ll

Fixed by 6f2e943de67aed26c356ebbc03c5afb9925557bd