IR: Don't constant fold GEP bitcasts between different address spaces
authorMeador Inge <meadori@codesourcery.com>
Wed, 27 Feb 2013 02:26:42 +0000 (02:26 +0000)
committerMeador Inge <meadori@codesourcery.com>
Wed, 27 Feb 2013 02:26:42 +0000 (02:26 +0000)
commit8df7c39976890d94198d835e032848a374fec158
tree720c2f50e52f22799557139f939fdf79d84ce37f
parent5e5974f51ad079a3ed890ca8be1d3f50150320ad
IR: Don't constant fold GEP bitcasts between different address spaces

PR15262 reported a bug where the following instruction:

  i8 getelementptr inbounds i8* bitcast ([4 x i8] addrspace(12)* @buf to i8*),
                                i32 2

was getting folded into:

  addrspace(12)* getelementptr inbounds ([4 x i8] addrspace(12)* @buf, i32 0,
                                        i32 2)

This caused instcombine to crash because the original instruction and
the folded instruction have different types.  The issue was fixed by
disallowing bitcasts between different address spaces to be folded away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176156 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/ConstantFold.cpp
test/Other/constant-fold-gep.ll