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
[SR-13106] "isvolatile argument of memory intrinsics must be a constant int" when compiling UnsafeRawPointer #55552
Comments
Comment by Carl Peto (JIRA) Feedback assistant issue raised with ID FB7814621. All required files and instructions to reproduce the issue attached to that. |
carlos4242 (JIRA User) What's going wrong here is that the Bool initializer is not inlined (though it's defined as "transparent"). |
Comment by Carl Peto (JIRA) That sounds like sense. I can try it with -wmo. A bit of retooling needed but not too bad. A couple of dumb questions: 1) wmo looks like it does optimisation, for example SIL transforms, across swift files. Is this the same as link-time-optimisation or are they unrelated? 2) Is it possible to compile stdlib in whole module optimisation mode and still emit the result to IR? I depend on that workflow because I'm using a separate llc compiler to make object code from llvm IR. Thanks Carl |
Comment by Carl Peto (JIRA) update: i think i'll end up answering my own questions... it looks like it is not the same as LTO, and it looks like it's possible to emit the files as IR still. The documentation you pointed to explicitly points out that each unit is compiled to LLVM IR in memory at least, even when taken as a whole they're optimised together. basically your fixed seems to have worked in this case of Bool code... the accessor wasn't getting inlined properly until I turned on "-whole-module-optimisation", now it's compiling. On to the next issue! Thanks 🙂 |
Marking the issue as resolved since it looks like the problem was due to a misconfiguration, which has been fixed. Please mark it as closed if that's correct. 🙂 |
Comment by Carl Peto (JIRA) Looks good |
👍 |
Environment
macOS 10.15.5, compiler is
Apple clang version 11.0.3 (clang-1103.0.32.62) installed as part of Xcode 11.5
swift built from https://github.com/carlos4242/swift/tree/SR-13095-test using ninja
Additional Detail from JIRA
md5: 89fcaeb3e5abce0c94d16277e9b8ed76
Issue Description:
More work on my custom standard library. I'm compiling using this command...
And the method being compiled is...
Bool is defined as usual in my stdlib...
The error I'm getting is...
It looks like compilation is fine through parse, AST, Sema, SIL generation and optimisation (probably), then during IRGen, the function being written is passed through custom LLVM passes, including verification. At that point, internal checks in LLVM detect that the emitted code is invalid and trap.
Putting in breakpoints and examining the IR shows the problem with the LLVM IR that swift is generating...
The call site for the intrinsic memcpy is wrong...
This should have been optimised away to...
What I would have expected was sSb22_builtinBooleanLiteralSbBi1__tcfC and the subsequent _value access should have been inlined, then by constant propagation, the code eliminated and false passed as the final parameter to the memcpy intrinsic.
If it's useful, later this afternoon (UK time) I'll raise a feeback assistant ticket with the full code as I did with my previous ticket.
In the meantime, if anyone can immediately see what's wrong, I'd welcome the feedback!
The text was updated successfully, but these errors were encountered: