-
-
Notifications
You must be signed in to change notification settings - Fork 271
Fix evaluation order issues #1620
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
|
Let's see what the CI testers say... meanwhile, I am going to try and compile Weka's codebase with it. Edit: so there was a bug due to copy-paste error (casts that are needed for bitwise ops should not be there for the other ops), fixed now. |
|
There is some funny business happening in the code that is wholly unnecessary I think. Let's see what the CI testers think... First I'll commit the (I hope) fully fixed version, then a second commit with the funny business cut out. Edit: OK, without it, things break, so I'll keep it for now. |
|
Cancelled all CI tests, amend+pushforce to start all of them again. |
|
|
||
| // FIXME: I don't know why this is there. Is it needed? | ||
| bool useFindLval = | ||
| (binOp == llvm::Instruction::Shl) || (binOp == llvm::Instruction::LShr); |
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.
Yes I think it's needed. Test:
int x = 6;
int inc() { ++x; return 4; }
(x++) <<= inc();
assert(x == 8 << 4);[Note that I haven't actually tested this code. ;)]
Using the lhs_val for the lhs makes sure we use the lvalue subexpression x which should be 8 by the time we load the lhs for the binop. lhs_fullEvaluation, i.e., (x++), would be 6.
But I now think that this should probably be the case for all other binassign expressions, not just for shifts...
Hmm? The pre-evaluation of the lvalue subexpression or what do you mean?
No rush mate ;) - let's refactor this a bit, 170 additional lines shouldn't be necessary. That doesn't have to be you, I could do that as well, but that might take some time. |
|
Indeed I thought pre-evaluation of
(keep pasting testcase ideas too!) |
Yep, this isn't a very elegant solution at the moment. The thing is that we need the address to store the result of the binop to, and that the full lhs expression
Edit: Oh I forgot that the lvalue should probably be the actual lhs for the binop, for all binassign expressions and not just shifts. This means that we only need to fully evaluate |
|
Hmm this may all be a tedious fight with a symptom. Firstly, the lhs I'll have a go at some refactoring and will then try to get rid of the pre-evaluation. |
|
Continued here: #1623 |
|
@kinke shall I close this one? |
Fix evaluation order issues (continuation of #1620)
Resolves #1617 .
There is a lot of refactoring potential here (duplication of code), but it is additional work and we first need to get this right.