-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[CodeGenPrepare] Fix signed overflow #141487
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
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.
is it possible to add a test?
I have a small test locally that triggers the issue with sanitizers enabled (the sanitizer will complain about the addition). But without it enabled I'm not sure how I could test for it. |
Does the overflow affect codegen? Like, when it overflows Also, please refrain from force-push unless it's necessary. |
Ok, then I will not force-push. Let's say I manage to cause a difference with and without the patch using a test. Then it's not certain the same difference (or any difference at all) can be reproduced on another compiler due to the undefined behavior. Does it really make sense to add such a test? |
True, on some platforms or compilers the codegen result might be the same regardless of your fix. But I still think it's a good idea to check in a test showing what we expect for future references. |
I could add an |
Thinking about this more I don't like the idea of adding a test that tests the debug print for something like this either. The only thing we gain is the coverage and nothing else. I still consider adding a test not worth it. |
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.
LGTM
Thinking about this more I don't like the idea of adding a test that tests the debug print for something like this either. The only thing we gain is the coverage and nothing else. I still consider adding a test not worth it.
After revisiting this, I agree that we can probably leave it without a test for this particular case.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/6554 Here is the relevant piece of the build log for the reference
|
The signed addition could overflow which is undefined behavior, now the code checks for it.
The signed addition could overflow which is undefined behavior, now the code checks for it.