Detect and skip non load and store instructions, up to a limit,
when finding available loads for a pointer. The scan limit is only 6
instructions which is fairly small, so for example type test and assume
intrinsics inserted for whole program devirtualization would prevent
analysis, sometimes causing profile matching issues. On the other hand,
debug and pseudo instructions were skipped indefinitely.
We now skip all of the unrelated instruction types when scanning for an
available load or intervening memory write, up to a default limit of 32
instructions. This supercedes the unlimited skipping of debug and pseudo
instructions that previously existed.
This exposed an issue where a caller from jump threading could end up
infinitely looping due to an unreachable loop with a single predecessor
(the backedge). It was not exposed before because the branch instruction
was counted towards the scan limit of 6 instructions, so iteration would
terminate. Fix this and added a test case.
nit: This comment (which is very useful) is a big duplication in code.
What do you think of wrapping this chunk of code to a function, so that either logic, or the comment will not get out of sync?
Something like: