Prevent Constant Folding From Optimizing inrange GEP
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 11 Sep 2018 01:53:36 +0000 (01:53 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 11 Sep 2018 01:53:36 +0000 (01:53 +0000)
commitc7d281905b75686f09c22b466d05a715d825d8c1
tree700bbaad05fe4d20076554baff174dc39a3336ea
parentdd01efc56d7ef3a335aad3d9cfe1b53d0f8524f8
Prevent Constant Folding From Optimizing inrange GEP

This patch does the following things:

1. update SymbolicallyEvaluateGEP so that it bails out if it cannot preserve inrange arribute;
2. update llvm/test/Analysis/ConstantFolding/gep.ll to remove UB in it;
3. remove inaccurate comment above ConstantFoldInstOperandsImpl in llvm/lib/Analysis/ConstantFolding.cpp;
4. add a new regression test that makes sure that no optimizations change an inrange GEP in an unexpected way.

Patch by Zhaomo Yang!

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

llvm-svn: 341888
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Analysis/ConstantFolding/gep.ll
llvm/test/Other/optimize-inrange-gep.ll [new file with mode: 0644]