This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Always use APFloat for FP dumping
ClosedPublic

Authored by labath on Jul 14 2022, 4:12 AM.

Details

Summary

The DumpDataExtractor function had two branches for printing floating
point values. One branch (APFloat) was used if we had a Target object
around and could query it for the appropriate semantics. If we didn't
have a Target, we used host operations to read and format the value.

This patch changes second path to use APFloat as well. To make it work,
I pick reasonable defaults for different byte size. Notably, I did not
include x87 long double in that list (as it is ambibuous and
architecture-specific). This exposed a bug where we were printing
register values using the target-less branch, even though the registers
definitely belong to a target, and we had it available. Fixing this
prompted the update of several tests for register values due to slightly
different floating point outputs.

The most dubious aspect of this patch is the change in
TypeSystemClang::GetFloatTypeSemantics to recognize 10 as a valid size
for x87 long double. This was necessary because because sizeof(long
double) on x86_64 is 16 even though it only holds 10 bytes of useful
data. This generalizes the hackaround present in the target-free branch
of the dumping function.

Diff Detail

Event Timeline

labath created this revision.Jul 14 2022, 4:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 4:12 AM
Herald added subscribers: jsji, pengfei. · View Herald Transcript
labath requested review of this revision.Jul 14 2022, 4:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 4:12 AM
Emmmer added a comment.EditedJul 14 2022, 5:48 AM

Confirmed LLDBCoreTests passed after applying this patch on the riscv64 platform.
Superseding D129736

DavidSpickett accepted this revision.Jul 14 2022, 6:39 AM

I'm no float expert but seems fine. Also checked on AArch64 and no failures there.

This revision is now accepted and ready to land.Jul 14 2022, 6:39 AM

@labath Did you forget about this?

This revision was automatically updated to reflect the committed changes.

@labath Did you forget about this?

Yeah, pretty much that. Committed now.