[Lldb-commits] [PATCH] D129736: [lldb] Skip a float16 NaN test for RISC-V
Emmmer S via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 14 00:47:03 PDT 2022
Emmmer created this revision.
Emmmer added reviewers: MaskRay, liaolucy, craig.topper, DavidSpickett.
Emmmer added projects: LLDB, LLDB test suite on simulator.
Herald added subscribers: jsji, sunshaoce, VincentWu, luke957, StephenFan, vkmr, luismarques, sameer.abuasal, JDevlieghere, pengfei, s.egerton, Jim, PkmX, rogfer01, shiva0217, kito-cheng, simoncook, arichardson.
Herald added a project: All.
Emmmer requested review of this revision.
Herald added subscribers: lldb-commits, pcwang-thead.
When I try to run some unit tests, I met this problem
[ RUN ] DumpDataExtractorTest.Formats
/home/emmmer/git/llvm-project/lldb/unittests/Core/DumpDataExtractorTest.cpp:90: Failure
Expected equality of these values:
expected
Which is: "{-nan -nan nan nan}"
result.GetString()
Which is: "{nan nan nan nan}"
[ FAILED ] DumpDataExtractorTest.Formats (25 ms)
So I extracted a minimal repro from `lldb/source/Core/DumpDataExtractor.cpp:53 half2float(uint16_t half)` .
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <string.h>
int main() {
float f = 0;
*(uint32_t *) &f = 0xffffe000;
float w = f * ldexpf(1, -112);
printf("%f(%x)\n", w, *(uint32_t *) &w);
return 0;
}
On x86_64 it runs correctly.
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This GDB was configured as "x86_64-linux-gnu".
Reading symbols from nan...
(gdb) b main
Breakpoint 1 at 0x113d: file nan.c, line 7.
(gdb) r
Starting program: /home/emmmer/nan
Breakpoint 1, main () at nan.c:7
7 float f = 0;
(gdb) n
8 *(uint32_t *) &f = 0xffffe000;
(gdb) n
9 float w = f * ldexpf(1, -112);
(gdb) n
10 printf("%f(%x)\n", w, *(uint32_t *) &w);
(gdb) p w
$1 = -nan(0x7fe000) \\ -nan expected
(gdb) p f
$2 = -nan(0x7fe000)
But on riscv64, it seems to meet some problem.
c
GNU gdb (GDB) openEuler 11.1-2.oe2203
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Reading symbols from nan...
(gdb) b main
Breakpoint 1 at 0x105e8: file nan.c, line 7.
(gdb) r
Starting program: /root/nan
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib64/libthread_db.so.1".
Breakpoint 1, main () at nan.c:7
7 float f = 0;
(gdb) n
n8 *(uint32_t *) &f = 0xffffe000;
(gdb) n
9 float w = f * ldexpf(1, -112);
(gdb) n
10 printf("%f(%x)\n", w, *(uint32_t *) &w);
(gdb) p w
$1 = nan(0x400000) \\ -nan expected
(gdb) p f
$2 = -nan(0x7fe000)
The problem occurs after line 9, the nan payload got lost after the float multiplication.
The problem only happens when running float16 tests, due to riscv standard does not enforce NaN payload propagation <https://github.com/riscv/riscv-isa-manual/blob/f518c259c008f926eba4aba67804f62531b6e94b/src/f.tex#L282>, so I would like to turn it off temporarily on the riscv platform, until more investigations are taken.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129736
Files:
lldb/unittests/Core/DumpDataExtractorTest.cpp
Index: lldb/unittests/Core/DumpDataExtractorTest.cpp
===================================================================
--- lldb/unittests/Core/DumpDataExtractorTest.cpp
+++ lldb/unittests/Core/DumpDataExtractorTest.cpp
@@ -199,9 +199,11 @@
TestDump(std::vector<uint16_t>{0xabcd, 0x1234},
lldb::Format::eFormatVectorOfFloat16, "{-0.0609436 0.000757217}");
+#if !defined(__riscv)
// quiet/signaling NaNs.
TestDump(std::vector<uint16_t>{0xffff, 0xffc0, 0x7fff, 0x7fc0},
lldb::Format::eFormatVectorOfFloat16, "{-nan -nan nan nan}");
+#endif
// +/-Inf.
TestDump(std::vector<uint16_t>{0xfc00, 0x7c00},
lldb::Format::eFormatVectorOfFloat16, "{-inf inf}");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129736.444523.patch
Type: text/x-patch
Size: 704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220714/ca3556c6/attachment-0001.bin>
More information about the lldb-commits
mailing list