PR12357: The pointer was used before it was checked.

llvm-svn: 153465
This commit is contained in:
Nadav Rotem 2012-03-26 20:39:18 +00:00
parent 6da64f39d4
commit e63e59cc44
1 changed files with 3 additions and 1 deletions

View File

@ -915,11 +915,13 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// Handle gep(bitcast x) and gep(gep x, 0, 0, 0).
Value *StrippedPtr = PtrOp->stripPointerCasts();
PointerType *StrippedPtrTy = dyn_cast<PointerType>(StrippedPtr->getType());
// We do not handle pointer-vector geps here
if (!StrippedPtr)
return 0;
PointerType *StrippedPtrTy = dyn_cast<PointerType>(StrippedPtr->getType());
if (StrippedPtr != PtrOp &&
StrippedPtrTy->getAddressSpace() == GEP.getPointerAddressSpace()) {