[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)
Yingwei Zheng via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 14 07:40:35 PDT 2024
dtcxzyw wrote:
`APInt::getAllOnes` will assert if `BitWidth == 0`.
```
[----------] 6 tests from APFloatTest
[ RUN ] APFloatTest.MinimumNumber
[ OK ] APFloatTest.MinimumNumber (0 ms)
[ RUN ] APFloatTest.Float8E8M0FNUValues
ADTTests: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/include/llvm/ADT/APInt.h:116: llvm::APInt::APInt(unsigned int, uint64_t, bool, bool): Assertion `val == 0 && "Value must be zero for 0-bit APInt"' failed.
#0 0x00007ffff7e15c32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libLLVMSupport.so.20.0git+0x215c32)
#1 0x00007ffff7e12aff llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libLLVMSupport.so.20.0git+0x212aff)
#2 0x00007ffff7e12c45 SignalHandler(int) Signals.cpp:0:0
#3 0x00007ffff7442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007ffff74969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007ffff74969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007ffff74969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007ffff7442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007ffff74287f3 abort ./stdlib/abort.c:81:7
#9 0x00007ffff742871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007ffff7439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007ffff7c97cb6 (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libLLVMSupport.so.20.0git+0x97cb6)
#12 0x00007ffff7c98b83 llvm::detail::IEEEFloat::makeNaN(bool, bool, llvm::APInt const*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libLLVMSupport.so.20.0git+0x98b83)
#13 0x00007ffff7c9e019 llvm::detail::IEEEFloat::convertFromStringSpecials(llvm::StringRef) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libLLVMSupport.so.20.0git+0x9e019)
#14 0x00007ffff7caef9d llvm::detail::IEEEFloat::convertFromString(llvm::StringRef, llvm::RoundingMode) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libLLVMSupport.so.20.0git+0xaef9d)
#15 0x00007ffff7caf4f6 llvm::APFloat::APFloat(llvm::fltSemantics const&, llvm::StringRef) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libLLVMSupport.so.20.0git+0xaf4f6)
#16 0x000055555585e240 (anonymous namespace)::APFloatTest_Float8E8M0FNUValues_Test::TestBody() APFloatTest.cpp:0:0
#17 0x00007ffff7f6e9d1 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libllvm_gtest.so.20.0git+0x569d1)
#18 0x00007ffff7f6ef2a testing::Test::Run() (.part.0) gtest-all.cc:0:0
#19 0x00007ffff7f6fc02 testing::TestInfo::Run() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libllvm_gtest.so.20.0git+0x57c02)
#20 0x00007ffff7f721e9 testing::TestSuite::Run() (.part.0) gtest-all.cc:0:0
#21 0x00007ffff7f7c18b testing::internal::UnitTestImpl::RunAllTests() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libllvm_gtest.so.20.0git+0x6418b)
#22 0x00007ffff7f6e441 testing::UnitTest::Run() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libllvm_gtest.so.20.0git+0x56441)
#23 0x00007ffff7fb71cc main (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/lib/libllvm_gtest_main.so.20.0git+0x11cc)
#24 0x00007ffff7429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#25 0x00007ffff7429e40 call_init ./csu/../csu/libc-start.c:128:20
#26 0x00007ffff7429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#27 0x00005555557b7075 _start (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/unittests/ADT/./ADTTests+0x263075)
```
Would be better to handle this corner case in `IEEEFloat::makeNaN`:
https://github.com/llvm/llvm-project/blob/81fee740d073640c79c0d45a8e8e804c1c5fea40/llvm/lib/Support/APFloat.cpp#L966
https://github.com/llvm/llvm-project/pull/80309
More information about the lldb-commits
mailing list