]> granicus.if.org Git - llvm/commit
Fix a bug w/inbounds invalidation in LFTR
authorPhilip Reames <listmail@philipreames.com>
Thu, 13 Jun 2019 18:23:13 +0000 (18:23 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 13 Jun 2019 18:23:13 +0000 (18:23 +0000)
commitb8ff4408f17d86fd56c3a70f85ddb63b95752801
treebac9d716a65a28e7ed34224bcbc29f8a2caeb39c
parent303105c8eeeef7f07b960713653fdb7fcccfa51e
Fix a bug w/inbounds invalidation in LFTR

This contains fixes for two cases where we might invalidate inbounds and leave it stale in the IR (a miscompile). Case 1 is when switching to an IV with no dynamically live uses, and case 2 is when doing pre-to-post conversion on the same pointer type IV.

The basic scheme used is to prove that using the given IV (pre or post increment forms) would have to already trigger UB on the path to the test we're modifying.  As such, our potential UB triggering use does not change the semantics of the original program.

As was pointed out in the review thread by Nikita, this is defending against a separate issue from the hasConcreteDef case. This is about poison, that's about undef. Unfortunately, the two are different, see Nikita's comment for a fuller explanation, he explains it well.

(Note: I'm going to address Nikita's last style comment in a separate commit just to minimize chance of subtle bugs being introduced due to typos.)

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363289 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/IndVarSimplify.cpp
test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll
test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll
test/Transforms/IndVarSimplify/lftr-dead-ivs.ll
test/Transforms/IndVarSimplify/lftr.ll