This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Skip a float16 NaN test for RISC-V
AbandonedPublic

Authored by Emmmer on Jul 14 2022, 12:47 AM.

Details

Summary

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, so I would like to turn it off temporarily on the riscv platform, until more investigations are taken.

Diff Detail

Event Timeline

Emmmer created this revision.Jul 14 2022, 12:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 12:47 AM
Emmmer requested review of this revision.Jul 14 2022, 12:47 AM

Seems fine to me. Do you have a tracking issue for this? You could just open one for "lldb riscv test failures" and add comments as you find more failures. So people can see the current state of the test suite.

lldb/unittests/Core/DumpDataExtractorTest.cpp
202

Add a brief comment with the reason, "riscv does not support...." just a one liner.

labath added a subscriber: labath.Jul 14 2022, 4:15 AM

That code is horrible. Lemme see if I can remove it (=> D129750). If that doesn't work, then we can try skipping this...

Emmmer abandoned this revision.Jul 14 2022, 5:48 AM

Superseded by D129750, which introduced a platform independent way of checking floating point test cases.