Skip to content

Conversation

beetrees
Copy link
Contributor

To render f16s in debuggers on MSVC targets, this PR changes the compiler to output f16s as struct f16 { bits: u16 }, and includes a Natvis visualiser that manually converts the f16's bits to a float which is can then be displayed by debuggers. gdb, lldb and cdb tests are also included for f16 .

f16/f128 MSVC debug info issue: #121837
Tracking issue: #116909

@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2024

r? @estebank

rustbot has assigned @estebank.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 26, 2024
@beetrees beetrees marked this pull request as ready for review June 26, 2024 19:47
@beetrees
Copy link
Contributor Author

@rustbot label +F-f16_and_f128

@rustbot rustbot added the F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` label Jun 26, 2024
@tgross35
Copy link
Contributor

Cc @MaulingMonkey since you suggested what I copied to #121837

@tgross35
Copy link
Contributor

tgross35 commented Jun 27, 2024

@ChrisDenton do you handle the natvis stuff? I seem to remember there not being too many people who were able to review it (though this seems pretty understandable, the math part in intrinsic.natvis looks correct to me)

@ChrisDenton
Copy link
Member

No, sorry. While I have a little familiarity with the format, I wouldn't trust myself to review. Try @michaelwoerister maybe?

@michaelwoerister
Copy link
Member

r? @michaelwoerister
I'll take a look next week.

@rustbot rustbot assigned michaelwoerister and unassigned estebank Jun 27, 2024
@michaelwoerister
Copy link
Member

C# seems to have something like f16, so maybe we are lucky:
https://devblogs.microsoft.com/dotnet/introducing-the-half-type/

Copy link
Member

@michaelwoerister michaelwoerister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks @beetrees!
I have only some minor comments.

@@ -0,0 +1,56 @@
//@ compile-flags: -g
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add //@ only-windows so that we ignore the test on other platforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added //@ only-msvc as cpp_like_debuginfo is only used on MSVC targets.

ty::FloatTy::F32 => "float",
ty::FloatTy::F64 => "double",
ty::FloatTy::F128 => "fp128",
}
}
}

fn build_cpp_f16_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) -> DINodeCreationResult<'ll> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why we do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@michaelwoerister
Copy link
Member

Thanks for the updates, @beetrees!

Excluding from rollups since debuginfo tests often fail on the first try in CI.
@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Jul 5, 2024

📌 Commit b701222 has been approved by michaelwoerister

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 5, 2024
@bors
Copy link
Collaborator

bors commented Jul 5, 2024

⌛ Testing commit b701222 with merge 66fe6dd...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 5, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 5, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 5, 2024
// gdbg-command:print 'basic_types_mut_globals'::F64
// gdbr-command:print F64
// gdb-check:$28 = 9.25
// gdb-check:$30 = 9.25

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a #![feature(f16)].

If you're up for it you can try to remove the //@ ignore-gdb directive at the top, since the very similar basic-types-globals.rs test seems to work just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the missing #![feature(f16)]s, and removed the //@ ignore-gdb (the test passes locally).

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 8, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 8, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 8, 2024
@compiler-errors
Copy link
Member

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2024
@bors
Copy link
Collaborator

bors commented Jul 9, 2024

⌛ Testing commit 4252842 with merge 585ffed...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 9, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 9, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 9, 2024
@beetrees
Copy link
Contributor Author

beetrees commented Jul 9, 2024

I've fixed the typos in the test that caused the failure.

@michaelwoerister
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 9, 2024

📌 Commit b058de9 has been approved by michaelwoerister

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 9, 2024
@bors
Copy link
Collaborator

bors commented Jul 9, 2024

⌛ Testing commit b058de9 with merge 8672b2b...

@bors
Copy link
Collaborator

bors commented Jul 9, 2024

☀️ Test successful - checks-actions
Approved by: michaelwoerister
Pushing 8672b2b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 9, 2024
@bors bors merged commit 8672b2b into rust-lang:master Jul 9, 2024
@rustbot rustbot added this to the 1.81.0 milestone Jul 9, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8672b2b): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary -4.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-4.7%, -4.7%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary -3.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.5% [-3.5%, -3.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.5% [-3.5%, -3.5%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 702.485s -> 703.117s (0.09%)
Artifact size: 328.89 MiB -> 328.74 MiB (-0.05%)

@beetrees beetrees deleted the f16-debuginfo branch July 9, 2024 14:45
Dajamante added a commit to ferrocene/ferrocene that referenced this pull request Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants