PR12357: The pointer was used before it was checked.
authorNadav Rotem <nadav.rotem@intel.com>
Mon, 26 Mar 2012 20:39:18 +0000 (20:39 +0000)
committerNadav Rotem <nadav.rotem@intel.com>
Mon, 26 Mar 2012 20:39:18 +0000 (20:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153465 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstructionCombining.cpp

index 349ba83961c470da3839501b5e0022d84bc14508..8802ba448e777d778c4f01d4086a5d9845822ae4 100644 (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()) {