Skip to content

[stdlib] Disable 128-bit div/mod on 64-bit Windows #13234

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

Closed
wants to merge 1 commit into from

Conversation

troughton
Copy link
Contributor

64-bit Windows doesn't support the 128-bit operations udivti3, umodti3, divti3, or modti3, which LLVM emits upon encountering this function. Disable dividingFullWidth on Win64 as a temporary fix.

Longer term, Compiler-RT should be amended to support 128-bit operations on Windows (since it's currently gated on being LP64 while Windows uses LLP64). We can then link against the Compiler-RT runtime support library.

@gparker42
Copy link
Contributor

Is there a bug report against compiler-rt for this? We should have a FIXME comment referring to that bug.

The other fix would be to implement those functions ourselves locally. IIRC the arm64 build did something similar for a while.

@troughton
Copy link
Contributor Author

troughton commented Dec 4, 2017

I'm not aware of any bug report currently – the reason I've not submitted one is I'm not actually sure there is a bug. LLVM emits these instructions, but Windows technically doesn't support them; they wouldn't be found in the MSVC runtime, for instance, and 128-bit integers are only supported as a SSE2 SIMD type (as I understand it).

As for implementing the functions locally: I looked at the Compiler-RT source and found that we'd need to copy across a 250+ line function (https://github.com/apple/swift-compiler-rt/blob/70a977cee7fa82acfd99f2e40b2070cb469d99ed/lib/builtins/udivmodti4.c) and need to define a few custom types to match. That's certainly doable, but seemed a more extreme addition than this PR.

In other words, I'm open to hear the best approach; this is just a stopgap solution to fix the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants