summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-04-20 06:05:54 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-04-20 06:05:54 +0000
commit428d4903326faec482ecbf64200ed62f47a53f48 (patch)
treebc8098c20a1694ddf30df14f3fa89d47783f99ef /llvm/lib/Transforms
parent5ed5e9a6126537258f56bddfb8722346ae8615fb (diff)
downloadbcm5719-llvm-428d4903326faec482ecbf64200ed62f47a53f48.tar.gz
bcm5719-llvm-428d4903326faec482ecbf64200ed62f47a53f48.zip
Before trying to introduce/eliminate cast/ext/trunc to make indices type as
pointer type, make sure that the pointer size is a valid sequential index type. llvm-svn: 69574
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index a2658b3e3f1..0d32eacbb17 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -10695,7 +10695,12 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
gep_type_iterator GTI = gep_type_begin(GEP);
for (User::op_iterator i = GEP.op_begin() + 1, e = GEP.op_end();
i != e; ++i, ++GTI) {
- if (isa<SequentialType>(*GTI)) {
+ // Before trying to eliminate/introduce cast/ext/trunc to make
+ // indices as pointer types, make sure that the pointer size
+ // makes a valid sequential index.
+ const SequentialType *ST = dyn_cast<SequentialType>(*GTI);
+ Value *PtrTypeVal = Constant::getNullValue(TD->getIntPtrType());
+ if (ST && ST->indexValid(PtrTypeVal)) {
if (CastInst *CI = dyn_cast<CastInst>(*i)) {
if (CI->getOpcode() == Instruction::ZExt ||
CI->getOpcode() == Instruction::SExt) {
OpenPOWER on IntegriCloud