-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stubs] Implement unsigned/signed div/mod ti3 for Win64 #13295
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
Conversation
and use unsigned int directly instead of Compiler-RT's equivalent su_int.
#define SWIFT_MODE_TI __attribute__((__mode__(TI))) | ||
#else | ||
#define SWIFT_MODE_DI | ||
#define SWIFT_MODE_TI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this a hard error. Without this, the types are completely the wrong size and you do not get any type of warning/error that things went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with a hard error is that I moved this out of the #if
blocks, since the definitions are used by multiple disjoint if
blocks. If we hard error, then that applies to every platform, even ones that will never need to use the types.
The alternatives would be to either warn or to duplicate these definitions and move them back into each #if
block. The problem that then arises is that the definitions become conditional on what #if
blocks we'd already encountered, unless we #define
d and #undef
d the types within each block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've addressed this by adding a 3-line check for __mode__
support within each #if
block.
stdlib/public/stubs/Stubs.cpp
Outdated
|
||
#if defined(_WIN64) | ||
|
||
#define CHAR_BIT 8 // number of bits in a char |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not use the standard headers for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry. I was blindly following Compiler-RT here, but it's already defined from <limits.h>
.
du_int low; | ||
du_int high; | ||
}s; | ||
} utwords; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This technically is a GNU extension (union fields may only be access through initialized fields) and breaks aliasing. At that point, you should assume that the __mode__
extension is available
@gparker42 When you get a chance, could you take a look at this in comparison to #13234 and see which approach you prefer? |
Currently, |
Okay, great. I’ll close these two PRs. |
On Windows 64-bit, the
dividingFullWidth
method onUInt64
andInt64
causes LLVM to emit references toudivti3
,umodti3
,divti3
, andmodti3
, which are undefined on Windows. Provide an implementation here based on Compiler-RT.This is an alternative fix to #13234.
cc @gparker42