-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Crash with asm volatile #1689
Comments
Did a bit more testing:
Callstack if that's of any help:
So I guess the modifications I listed in my previous comment are irrelevant, they just help avoiding CE's cache and trigger a new compilation, that may or may not crash. |
Thanks for doing that research. Looks like we may need to report this upstream. Are you using an assertion-enabled LLVM? |
I only have the release build you supplied right now but I plan to do a debug one eventually. |
That's one reason I want to run the test with assertions on - it is likely to catch a problem caused by Zig using the API incorrectly. |
Update (I'm learning as I go, so please correct me if needed): In the example I linked from google/benchmark, the comma in the constraints is used to denote alternative constraints, ie. the compiler is free to chose So if I understand correclty, replacing commas in constraints by However, in this very case, I don't understand why the source of google/benchmark uses |
Found #215 (and TODOs) while investigating other crashes related to |
I think we should definitely prioritize fixing the crashes. These are typically easy, small fixes that make a big difference in user experience. Worst case scenario they can emit compile errors that say "TODO" and link to the relevant issue. I'll have to take a look at those docs you linked. At this point you're probably more knowledgeable about this topic than me; it's been a while since I visited the inline assembly code in Zig. I know that it's one of the first things I implemented because I needed it for syscalls and it badly needs revisiting. |
OK, hopefully I will have time to fix some in the next few days then. |
I was toying with inline assembly syntax to try to reproduce the
DoNotOptimize
function from google/benchmark https://github.com/google/benchmark/blob/master/include/benchmark/benchmark.h#L309-L326.I wrote this https://godbolt.org/z/eExl8y by trial and error since there's no inline asm documentation yet.
Ouput operands cannot be empty do I added a dummy variable to satisfy the language.
Now even insignificant modifications to this code can cause a compiler crash:
asm volatile
xxx
identifiernum
to be a value instead of a pointera
directly inside the asm instead of its addressThese only happen in release modes.
I'm not sure what belongs to bugs and to invalid input, but I guess the compiler should at least not crash.
The text was updated successfully, but these errors were encountered: