]> granicus.if.org Git - llvm/commit
[ConstantFold] Fix defect in constant folding computation for GEP
authorJaved Absar <javed.absar@arm.com>
Wed, 8 Mar 2017 23:01:50 +0000 (23:01 +0000)
committerJaved Absar <javed.absar@arm.com>
Wed, 8 Mar 2017 23:01:50 +0000 (23:01 +0000)
commit9dd9f4f8b4cc334831976baf7ff7b01c161e7ccd
tree4e7c8ac91f425deacb37eb70dacb07d80aaef5f7
parentc036eebbeb6ab205707c42b78276d18aac96e535
[ConstantFold] Fix defect in constant folding computation for GEP

When the array indexes are all determined by GVN to be constants,
a call is made to constant-folding to optimize/simplify the address
computation.

The constant-folding, however, makes a mistake in that it sometimes reads
back stale Idxs instead of NewIdxs, that it re-computed in previous iteration.
This leads to incorrect addresses coming out of constant-folding to GEP.
A test case is included. The error is only triggered when indexes have particular
patterns that the stale/new index updates interplay matters.

Reviewers: Daniel Berlin
Differential Revision: https://reviews.llvm.org/D30642

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297317 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/ConstantFold.cpp
test/Analysis/ConstantFolding/gep-constanfolding-error.ll [new file with mode: 0644]