Allow computing size of interposable or externally initializable global variables.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Transforms/InstSimplify/gv-externally-initializable.ll | ||
---|---|---|
10–11 ↗ | (On Diff #528378) | I'd assume this could return false even for interposable globals |
LGTM, but please write a patch description and precommit tests.
This is legal because externally_initialized does not affect the size of the global.
If you want to handle interposable globals, you need to handle the NullIsUnknownSize flag (because they may be null), as well as EvalMode, because they may be larger than declared according to LangRef.
We should also have a test for some case where EvalMode is not Min -- maybe just grep the codebase to find something appropriate.
llvm/lib/Analysis/MemoryBuiltins.cpp | ||
---|---|---|
837 | We might as well handle the !hasInitializer() case as well, which has the same minimum size requirement as interposable symbols. Also, I just realized that NullIsUnknownSize is only relevant for extern_weak linkage, not for other interposable linkage. So I think the right conditions would be something like this: if ((!hasInitializer || isInterposable) && EvalMode != Min) return unknown; if (hasExternalWeakLinkage && NullIsUnkownSize) return unknown; |
It doesn't make the ObjectSizeOffsetVisitor visit a global variable. I tried the following:
@gv_objectsize = weak global i64 zeroinitializer, align 16 ... call i32 @llvm.objectsize.i32.p5(ptr @gv_objectsize, i1, i1, i1)
llvm.objectsize lowering depends a lot on the parameters and the used pass. Which did you use?
I'd expect that llvm.objectsize with min=true, dynamic=false in InstCombine will not fold on an interposable global due to the Min restriction, but the same call in LowerConstantIntrinsics will fold. With min=false neither should fold.
llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll | ||
---|---|---|
156 | Can you please add another test with min=true? And another that uses an extern_weak global with nullunknown=true/false? |
llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll | ||
---|---|---|
174 | For this test and the one below, can you please set min=true? Then one should return 8 the other -1, I believe. |
Modified tests
llvm/test/Transforms/LowerConstantIntrinsics/objectsize_basic.ll | ||
---|---|---|
174 | The last test returns -1 with min=false and nullunknown=true. |
llvm/lib/Analysis/MemoryBuiltins.cpp | ||
---|---|---|
837 | Sorry for the back and forth here, but after further consideration, I think we always need to return unknown() for GV.hasExternalWeakLinkage(), independent of NullIsUnknownSize. The reason is that in NullIsUnknownSize=false mode, we would have to treat null as size 0. However, we only get here in Min mode, so we would have 0 as the overall result, which is the same as unknown. So we should just always return unknown for this case. |
Return unknown() for GV.hasExternalWeakLinkage(). Eliminate last two tests in objectsize_basic.ll
LGTM
Could you please restore those two tests? They are still useful as negative tests, to make sure both are 0.
This is causing Chrome builds to crash on an assertion failure (https://crbug.com/1454861):
[1/1] CXX obj/components/feed/core/v2/core_unit_tests/feed_store_unittest.o FAILED: obj/components/feed/core/v2/core_unit_tests/feed_store_unittest.o /usr/local/google/home/ayzhao/src/llvm-project/build/bin/clang++ -MMD -MF obj/components/feed/core/v2/core_unit_tests/feed_store_unittest.o.d -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -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 -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 -DLIBYUV_DISABLE_NEON -DWEBP_EXTERN=extern -DUSE_EGL -DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_WAYLAND_KHR -DABSL_CONSUME_DLL -DBORINGSSL_SHARED_LIBRARY -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DGOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE=0 -DHAVE_PTHREAD -DPROTOBUF_USE_DLLS -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DGTEST_API_= -DGTEST_HAS_POSIX_RE=0 -DGTEST_LANG_CXX11=1 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_ABSL=1 -DUNIT_TEST -DWEBRTC_ENABLE_SYMBOL_EXPORT -DWEBRTC_ENABLE_AVX2 -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -DWEBRTC_USE_X11 -DWEBRTC_USE_PIPEWIRE -DWEBRTC_USE_GIO -DLOGGING_INSIDE_WEBRTC -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_CODEC_DECODES_JPEG -DSK_CODEC_DECODES_PNG -DSK_CODEC_DECODES_WEBP -DSK_ENCODE_JPEG -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSK_HAS_WUFFS_LIBRARY -DSKIA_DLL -DSKCMS_API=__attribute__\(\(visibility\(\"default\"\)\)\) -DSK_GANESH -DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -DSK_GL -DSK_VULKAN=1 -DSK_GRAPHITE -DLEVELDB_PLATFORM_CHROMIUM=1 -DLEVELDB_SHARED_LIBRARY -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/libyuv/include -I../../third_party/jsoncpp/source/include -I../../third_party/libwebp/src/src -I../../third_party/vulkan-deps/vulkan-headers/src/include -I../../third_party/wayland/src/src -I../../third_party/wayland/include/src -Igen/third_party/dawn/include -I../../third_party/dawn/include -I../../third_party/khronos -I../../gpu -Igen/third_party/private_membership/src -Igen/third_party/shell-encryption/src -Igen/components/policy/proto -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/ced/src -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/googletest/custom -I../../third_party/googletest/src/googlemock/include -I../../third_party/googletest/src/googletest/include -I../../third_party/ipcz/include -I../../net/third_party/quiche/overrides -I../../net/third_party/quiche/src/quiche/common/platform/default -I../../net/third_party/quiche/src -Igen/net/third_party/quiche/src -I../../third_party/webrtc_overrides -I../../third_party/webrtc -Igen/third_party/webrtc -I../../third_party/skia -I../../third_party/wuffs/src/release/c -I../../third_party/vulkan/include -I../../third_party/leveldatabase -I../../third_party/leveldatabase/src -I../../third_party/leveldatabase/src/include -Igen/third_party/metrics_proto -I../../third_party/zlib -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 -Wno-builtin-macro-redefined -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 -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-omit-frame-pointer -g0 -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 -Wno-inconsistent-missing-override -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/include/nss -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/include/nspr -Wno-redundant-parens -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 ../../components/feed/core/v2/feed_store_unittest.cc -o obj/components/feed/core/v2/core_unit_tests/feed_store_unittest.o clang++: /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/DataLayout.h:669: llvm::TypeSize llvm::DataLayout::getTypeSizeInBits(llvm::Type *) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' 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/components/feed/core/v2/core_unit_tests/feed_store_unittest.o.d -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -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 -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 -DLIBYUV_DISABLE_NEON -DWEBP_EXTERN=extern -DUSE_EGL -DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_WAYLAND_KHR -DABSL_CONSUME_DLL -DBORINGSSL_SHARED_LIBRARY -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DGOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE=0 -DHAVE_PTHREAD -DPROTOBUF_USE_DLLS -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DGTEST_API_= -DGTEST_HAS_POSIX_RE=0 -DGTEST_LANG_CXX11=1 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_ABSL=1 -DUNIT_TEST -DWEBRTC_ENABLE_SYMBOL_EXPORT -DWEBRTC_ENABLE_AVX2 -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -DWEBRTC_USE_X11 -DWEBRTC_USE_PIPEWIRE -DWEBRTC_USE_GIO -DLOGGING_INSIDE_WEBRTC -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_CODEC_DECODES_JPEG -DSK_CODEC_DECODES_PNG -DSK_CODEC_DECODES_WEBP -DSK_ENCODE_JPEG -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSK_HAS_WUFFS_LIBRARY -DSKIA_DLL -DSKCMS_API=__attribute__((visibility(\"default\"))) -DSK_GANESH -DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -DSK_GL -DSK_VULKAN=1 -DSK_GRAPHITE -DLEVELDB_PLATFORM_CHROMIUM=1 -DLEVELDB_SHARED_LIBRARY -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/libyuv/include -I../../third_party/jsoncpp/source/include -I../../third_party/libwebp/src/src -I../../third_party/vulkan-deps/vulkan-headers/src/include -I../../third_party/wayland/src/src -I../../third_party/wayland/include/src -Igen/third_party/dawn/include -I../../third_party/dawn/include -I../../third_party/khronos -I../../gpu -Igen/third_party/private_membership/src -Igen/third_party/shell-encryption/src -Igen/components/policy/proto -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/ced/src -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/googletest/custom -I../../third_party/googletest/src/googlemock/include -I../../third_party/googletest/src/googletest/include -I../../third_party/ipcz/include -I../../net/third_party/quiche/overrides -I../../net/third_party/quiche/src/quiche/common/platform/default -I../../net/third_party/quiche/src -Igen/net/third_party/quiche/src -I../../third_party/webrtc_overrides -I../../third_party/webrtc -Igen/third_party/webrtc -I../../third_party/skia -I../../third_party/wuffs/src/release/c -I../../third_party/vulkan/include -I../../third_party/leveldatabase -I../../third_party/leveldatabase/src -I../../third_party/leveldatabase/src/include -Igen/third_party/metrics_proto -I../../third_party/zlib -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 -Wno-builtin-macro-redefined -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 -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-omit-frame-pointer -g0 -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 -Wno-inconsistent-missing-override -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/include/nss -isystem../../build/linux/debian_bullseye_amd64-sysroot/usr/include/nspr -Wno-redundant-parens -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 ../../components/feed/core/v2/feed_store_unittest.cc -o obj/components/feed/core/v2/core_unit_tests/feed_store_unittest.o 1. <eof> parser at end of file 2. Optimizer #0 0x000055f531943d9d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:602:11 #1 0x000055f53194423b PrintStackTraceSignalHandler(void*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:675:1 #2 0x000055f5319424b6 llvm::sys::RunSignalHandlers() /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Signals.cpp:104:5 #3 0x000055f53194360e llvm::sys::CleanupOnSignal(unsigned long) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:368:1 #4 0x000055f531880124 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:7 #5 0x000055f5318804e2 CrashRecoverySignalHandler(int) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1 #6 0x00007fe86d45af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90) #7 0x00007fe86d4a9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #8 0x00007fe86d45aef2 raise ./signal/../sysdeps/posix/raise.c:27:6 #9 0x00007fe86d445472 abort ./stdlib/abort.c:81:7 #10 0x00007fe86d445395 _nl_load_domain ./intl/loadmsgcat.c:1177:9 #11 0x00007fe86d453df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2) #12 0x000055f52f49280b llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/DataLayout.h:670:11 #13 0x000055f52f49268d llvm::DataLayout::getTypeStoreSize(llvm::Type*) const /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/DataLayout.h:469:25 #14 0x000055f52f490a11 llvm::DataLayout::getTypeAllocSize(llvm::Type*) const /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/DataLayout.h:502:20 #15 0x000055f53049a643 llvm::ObjectSizeOffsetVisitor::visitGlobalVariable(llvm::GlobalVariable&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/MemoryBuiltins.cpp:834:28 #16 0x000055f53049a2b9 llvm::ObjectSizeOffsetVisitor::computeImpl(llvm::Value*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/MemoryBuiltins.cpp:744:5 #17 0x000055f5304993cb llvm::ObjectSizeOffsetVisitor::compute(llvm::Value*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/MemoryBuiltins.cpp:711:12 #18 0x000055f5304991fa llvm::getObjectSize(llvm::Value const*, unsigned long&, llvm::DataLayout const&, llvm::TargetLibraryInfo const*, llvm::ObjectSizeOpts) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/MemoryBuiltins.cpp:590:8 #19 0x000055f5303e19e2 computePointerICmp(llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:2797:54 #20 0x000055f5303ce267 simplifyICmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:3959:15 #21 0x000055f5303d7358 simplifyInstructionWithOperands(llvm::Instruction*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&, unsigned int) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:6815:5 #22 0x000055f5303d793d llvm::simplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:6880:10 #23 0x000055f5319b0fc8 (anonymous namespace)::PruningFunctionCloner::CloneBlock(llvm::BasicBlock const*, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, std::vector<llvm::BasicBlock const*, std::allocator<llvm::BasicBlock const*>>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Transforms/Utils/CloneFunction.cpp:519:18 #24 0x000055f5319af697 llvm::CloneAndPruneIntoFromInst(llvm::Function*, llvm::Function const*, llvm::Instruction const*, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&, bool, llvm::SmallVectorImpl<llvm::ReturnInst*>&, char const*, llvm::ClonedCodeInfo*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Transforms/Utils/CloneFunction.cpp:667:25 #25 0x000055f5319b1abd llvm::CloneAndPruneFunctionInto(llvm::Function*, llvm::Function const*, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&, bool, llvm::SmallVectorImpl<llvm::ReturnInst*>&, char const*, llvm::ClonedCodeInfo*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Transforms/Utils/CloneFunction.cpp:936:1 #26 0x000055f531a0efd9 llvm::InlineFunction(llvm::CallBase&, llvm::InlineFunctionInfo&, bool, llvm::AAResults*, bool, llvm::Function*) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Transforms/Utils/InlineFunction.cpp:2149:19 #27 0x000055f5338bff3a llvm::InlinerPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Transforms/IPO/Inliner.cpp:381:11 #28 0x000055f53360e2e7 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::InlinerPass, 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/ayzhao/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:17 #29 0x000055f53812d4b6 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/ayzhao/src/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:90:9 #30 0x000055f5335f7e67 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/ayzhao/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:17 #31 0x000055f53812e359 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:405:38 #32 0x000055f53362ebf7 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/ayzhao/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:17 #33 0x000055f53812de8d llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:278:15 #34 0x000055f5335f8507 llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:17 #35 0x000055f53122176a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/PassManager.h:521:7 #36 0x000055f5338c128c llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Transforms/IPO/Inliner.cpp:633:3 #37 0x000055f533604857 llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:17 #38 0x000055f53122176a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/IR/PassManager.h:521:7 #39 0x000055f531cf26fe (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>>&) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1064:5 #40 0x000055f531cecde5 (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:1121:3 #41 0x000055f531cec2c7 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 #42 0x000055f53347dcb5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:386:7 #43 0x000055f535a412e3 clang::ParseAST(clang::Sema&, bool, bool) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Parse/ParseAST.cpp:183:12 #44 0x000055f532967b8c clang::ASTFrontendAction::ExecuteAction() /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1172:1 #45 0x000055f5334792d4 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1171:5 #46 0x000055f53296758c clang::FrontendAction::Execute() /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1064:7 #47 0x000055f5328915e8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23 #48 0x000055f532b31077 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/ayzhao/src/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8 #49 0x000055f52f42e143 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 #50 0x000055f52f419b7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/ayzhao/src/llvm-project/clang/tools/driver/driver.cpp:366:5 #51 0x000055f52f41b4ed 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 #52 0x000055f52f41b4bd 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 #53 0x000055f53273ec79 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 #54 0x000055f53273b3d8 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 #55 0x000055f53273b3a5 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 #56 0x000055f530661469 llvm::function_ref<void ()>::operator()() const /usr/local/google/home/ayzhao/src/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5 #57 0x000055f53187ff3a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:3 #58 0x000055f53273acf7 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 #59 0x000055f5326d5bbf 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 #60 0x000055f5326d5dc7 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 #61 0x000055f5326f04c8 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 #62 0x000055f52f419638 clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/ayzhao/src/llvm-project/clang/tools/driver/driver.cpp:542:9 #63 0x000055f52f45193d main /usr/local/google/home/ayzhao/src/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:15:3 #64 0x00007fe86d44618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #65 0x00007fe86d446245 call_init ./csu/../csu/libc-start.c:128:20 #66 0x00007fe86d446245 __libc_start_main ./csu/../csu/libc-start.c:368:5 #67 0x000055f52f4182d1 _start (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/clang+++0x1ae32d1) 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 17b7df3daee85c1a4d1d955e558d42b34ce17549) 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/feed_store_unittest-74fbf5.cpp clang++: note: diagnostic msg: ../../tools/clang/crashreports/feed_store_unittest-74fbf5.sh clang++: note: diagnostic msg: ******************** ninja: build stopped: subcommand failed.
llvm/lib/Analysis/MemoryBuiltins.cpp | ||
---|---|---|
838 | Fix for the assertion failure should be pretty simple: We also need to bail out if the type is !isSized(). Previously this was guaranteed by having an initializer. |
We might as well handle the !hasInitializer() case as well, which has the same minimum size requirement as interposable symbols.
Also, I just realized that NullIsUnknownSize is only relevant for extern_weak linkage, not for other interposable linkage. So I think the right conditions would be something like this: