Overall this leads to simpler code even though a few cases are slightly longer.
NFC.
Details
Diff Detail
Event Timeline
skipDebugInstructionsForward/Backward take the iterator by value and return the advanced iterator again, because it seemed more in line with C++'s iterator functions (like next and prev), @MatzeB suggested that in https://reviews.llvm.org/D27782#623009 .
In my opinion, it's obvious what the current implementation does by just looking at the call and having the end/beginning checks are in the caller's code, whereas the version proposed in this review is a little bit less obvious and the savings in code size seem quite small.
Note that the standard also has ::advance(it, n) which works via side-effect, so the std can't decide one way or the other.
In my opinion, it's obvious what the current implementation does by just looking at the call and having the end/beginning checks are in the caller's code, whereas the version proposed in this review is a little bit less obvious and the savings in code size seem quite small.
Even without returning empty, I prefer the side effect version. It makes nearly all the call sites simpler.
lib/CodeGen/BranchFolding.cpp | ||
---|---|---|
1814 | Seems like this ought to become if (skipDebugInstructionsForward(TIB, TIE) || skipDebugInstructionsForward(FIB, FIE)) break; | |
lib/CodeGen/IfConversion.cpp | ||
624 | These two 'if's can be combined. Or if you prefer to leave them as they are, that's fine too. But put a space between 'if' and paren. | |
666 | As above these could be combined if you like. |
Oh yes of course! I guess it comes down to personal preference and that's not a call for me to make.
I'm not in favor of this. Reference parameters (that actually change a variable) are non obvious and should mostly be avoided in C++.
At least to me it is also not obvious what that return value is when seeing the name skipDebugInstructionsForward.
Seems like this ought to become