IR: Properly return nullptr when getAggregateElement is out-of-bounds
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 Feb 2015 04:02:09 +0000 (04:02 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 Feb 2015 04:02:09 +0000 (04:02 +0000)
commit6de0a12927845ca49cd5cb1da9206fe503b565ec
tree5d82d88fa7ddc91847a665e5f33804e846170431
parent36fcfaf54eeee8b8fd63eea33c443d3b22a015ed
IR: Properly return nullptr when getAggregateElement is out-of-bounds

We didn't properly handle the out-of-bounds case for
ConstantAggregateZero and UndefValue.  This would manifest as a crash
when the constant folder was asked to fold a load of a constant global
whose struct type has no operands.

This fixes PR22595.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229352 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Constants.h
lib/IR/Constants.cpp
test/Transforms/InstSimplify/load.ll [new file with mode: 0644]