Skip to content

Remove 4146 from libunwind #66427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 14, 2022

Conversation

AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Mar 10, 2022

Contributes to #66154

This converts the invalid arithmetic negation on an unsigned value to use the identity of bitwise negation plus one.

Upstream PR: libunwind/libunwind#333

/cc @GrabYourPitchforks @jkotas @janvorli @am11

This converts the invalid arithmetic negation on an unsigned value
  to use the identity of bitwise negation plus one.
@ghost
Copy link

ghost commented Mar 10, 2022

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Issue Details

Contributes to #66154

This converts the invalid arithmetic negation on an unsigned value to use the identity of bitwise negation plus one.

Upstream PR: libunwind/libunwind#333

/cc @GrabYourPitchforks @jkotas @janvorli @am11

Author: AaronRobinsonMSFT
Assignees: -
Labels:

area-Infrastructure

Milestone: 7.0.0

@GrabYourPitchforks
Copy link
Member

Just out of curiosity, do you prefer ~a + 1 or (size_t)(-(ssize_t)a)? The former is more compact, but I wonder if the latter is easier to understand. But if you have an existing preferred pattern then carry on. :)

@AaronRobinsonMSFT
Copy link
Member Author

Just out of curiosity, do you prefer ~a + 1 or (size_t)(-(ssize_t)a)?

@GrabYourPitchforks That is a fair point. I try to avoid casting when possible as it feels like an escape hatch for doing something I shouldn't be doing. If you think the latter would be preferable, I am fine changing it to that.

@jkotas
Copy link
Member

jkotas commented Mar 10, 2022

~a + 1

Nit: This may be less efficient than the original code (depends on whether the compiler knows how to optimize back to -a).

I believe that the most common pattern for these situations is x & ~(sizeof(Y) - 1). We use it e.g. here:

return (value+alignment-1)&~(alignment-1);

It really depends on what the libunwind maintainer prefers...

@AaronRobinsonMSFT
Copy link
Member Author

@jkotas @GrabYourPitchforks One of the maintainers of libunwind responded and indicated they don't have a strong preference. This would seem to imply we can do what we think is best. See the reply and options at libunwind/libunwind#333 (comment).

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit c3d3932 into dotnet:main Mar 14, 2022
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the remove_4146_coreclr branch March 14, 2022 21:00
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Mar 30, 2022
* Remove 4146 from libunwind

Use existing libunwind align macro and use casting
  when the operation's target should reflect a signed value.
@ghost ghost locked as resolved and limited conversation to collaborators Apr 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants