[IndVars] Fix a miscompile in off-by-default loop predication implementation

Authored by reames on Oct 16 2019, 12:58 PM.


[IndVars] Fix a miscompile in off-by-default loop predication implementation

The problem is that we can have two loop exits, 'a' and 'b', where 'a' and 'b' would exit at the same iteration, 'a' precedes 'b' along some path, and 'b' is predicated while 'a' is not. In this case (see the previously submitted test case), we causing the loop to exit through 'b' whereas it should have exited through 'a'.

This only applies to loop exits where the exit counts are not provably inequal, but that isn't as much of a restriction as it appears. If we could order the exit counts, we'd have already removed one of the two exits. In theory, we might be able to prove inequality w/o ordering, but I didn't really explore that piece. Instead, I went for the obvious restriction and ensured we didn't predicate exits following non-predicateable exits.

Credit goes to Evgeny Brevnov for figuring out the problematic case. Fuzzing probably also found it (failures seen), but due to some silly infrastructure problems I hadn't gotten to the results before Evgeny hand reduced it from a benchmark (he manually enabled the transform). Once this is fixed, I'll try to filter through the fuzzer failures to see if there's anything additional lurking.

Differential Revision https://reviews.llvm.org/D68956

llvm-svn: 375038


reamesOct 16 2019, 12:58 PM
rG13993a6f8681: [LLDB] Use the llvm microsoft demangler instead of the windows dbghelp api.

Event Timeline

xbolva00 added inline comments.

Drop fixme

reames marked 2 inline comments as done.Oct 16 2019, 1:25 PM
reames added inline comments.

Good catch, thanks. Done in 375040.