[PATCH] D71164: [InstCombine] Fix infinite loop due to bitcast <-> phi transforms

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 14:22:20 PST 2020


nikic added a comment.

Okay, I think I got it. I don't have a standalone reproducer for this, but what seems to be happening is that we're iterating over `OldPN->users()` in https://github.com/llvm/llvm-project/blob/a506f7f9105eec4baac296d21c922457d6f4b52a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L2347, but https://github.com/llvm/llvm-project/blob/a506f7f9105eec4baac296d21c922457d6f4b52a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L2353 is going to modify the users. That makes us skip over a user (specifically, the original bitcast), which then refers to the old phi node.

That's already rather bad in itself (because it defeats the purpose of the transform and smells of memory unsafety), but with this change the undef replacement makes uses of the old phi actively incorrect.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71164/new/

https://reviews.llvm.org/D71164





More information about the llvm-commits mailing list