-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Unoptimized IR output has different ordering of functions on different platforms and produces different bytecode #14361
Comments
|
But it's also not a code generation error in its defined sense :-). Or do the two versions behave differently as well? |
I intepreted |
@kuzdogan, this will is probably be quite problematic for source verification. One workaround for this would be to keep multiple binaries and try with each one when verification with one fails. I haven't verified that yet, but I suspect that keeping just two (emscripten and linux) might be enough to cover all bases. But I'll be able to say more when we know the exact cause of this. |
Thanks for the heads up. We don't run the emscripten compiler if it compiles successfully with the native Linux. In this case looks like we should. The pattern we should look for is this right ? "optimizer": {"enabled": false},
"viaIR": true, |
Yes. |
Ah, actually When I figure out the cause, I'll let you know what specifically triggers this and which versions are affected. |
The cause turns out be a difference in expression evaluation order between Clang and GCC (which is generally undefined in C++). macOS and Emscripten binaries are built with Clang, while Linux ones are build with GCC. In the codegen we generate functions as we go through the AST and we often do this inside function calls embedded in expressions. If the expression contains more than one such call, the evaluation order determines which which function we will be generated first. I'm actually surprised that we had only one case of this. This is something we should not be relying upon and we mostly don't, but it's very easy to do this by uintentionally. The only safeguard is the bytecode comparison, which for IR we'll be running only starting with this version. @kuzdogan So unfortunately Given that, I think it's not safe to assume this only ever happens with optimizer disabled. Any optimizer step that reorders functions could potentially be the one responsible for restoring the deterministic order and the sequence is fully customizable by the user. It's also possible that other bugs of this kind existed before 0.8.21. It's best to assume that any |
Discovered in the via IR bytecode comparison PR (#14355). The PR revealed that unoptimized via IR produces slightly different bytecode on some platforms (specifically emscripten and macOS).
I investigated
288_conditional_with_all_types_sol
and in this case the differences are caused by functions being ordered differently in the generated IR.Repro
Input
input.json
Script
Output
Versions
Bytecode diff
IR diff
Assembly diff
The text was updated successfully, but these errors were encountered: