[llvm] DAG: Preserve range metadata when load is narrowed (PR #128144)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 11:20:19 PST 2025


thurstond wrote:

The ASan builds have been failing, and I think it may be related to this DAGCombiner change (first seen in https://lab.llvm.org/buildbot/#/builders/52/builds/6343). Could you please take a look?

```
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include -nostdinc++ -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1 -fsanitize=address -Wl,--rpath=/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -L/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -w -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o -MF tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o.d -o tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o -c /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang++: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/IR/ConstantRange.cpp:875: ConstantRange llvm::ConstantRange::truncate(uint32_t) const: Assertion `getBitWidth() > DstTySize && "Not a value truncation"' 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: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang++ -fsanitize=address -L/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -w -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -fdiagnostics-color -Wl,--rpath=/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include -nostdinc++ -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1 -stdlib=libc++ -DNDEBUG -UNDEBUG -c -MD -MT tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o -MF tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o.d -fcolor-diagnostics -o tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN12_GLOBAL__N_121SymbolicRangeInferrer19VisitBinaryOperatorEN5clang4ento8RangeSetENS1_18BinaryOperatorKindES3_NS1_8QualTypeE'
 #0 0x000060a5218b70b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x84dc0b8)
 #1 0x000060a5218b4b6e llvm::sys::RunSignalHandlers() (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x84d9b6e)
 #2 0x000060a52181e336 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000745fbde45250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
 #4 0x0000745fbdea3f1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0xa3f1c)
 #5 0x0000745fbde4519e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4519e)
 #6 0x0000745fbde28902 abort (/lib/x86_64-linux-gnu/libc.so.6+0x28902)
 #7 0x0000745fbde2881e (/lib/x86_64-linux-gnu/libc.so.6+0x2881e)
 #8 0x0000745fbde3b7c7 (/lib/x86_64-linux-gnu/libc.so.6+0x3b7c7)
 #9 0x000060a52116eb71 llvm::ConstantRange::truncate(unsigned int) const (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x7d93b71)
#10 0x000060a522abaec4 (anonymous namespace)::DAGCombiner::reduceLoadWidth(llvm::SDNode*) DAGCombiner.cpp:0:0
#11 0x000060a522a6f7d0 (anonymous namespace)::DAGCombiner::visitTRUNCATE(llvm::SDNode*) DAGCombiner.cpp:0:0
#12 0x000060a522a47516 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#13 0x000060a522a452f6 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel) (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x966a2f6)
#14 0x000060a522c0b349 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x9830349)
```

The ASan builds were red prior to this change but due to other patches (with different failure reports).


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


More information about the llvm-commits mailing list