Check that the operand of the GEP is not the GEP itself. This occurred during an...
[oota-llvm.git] / lib / VMCore / Verifier.cpp
index fd629b485aaa5a6cb58a32ed587743b23353d933..88ad5b11cbe5775ea8fbdb2c002eb1a3c3fb0fd3 100644 (file)
@@ -1371,9 +1371,11 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) {
   Type *TargetTy = GEP.getPointerOperandType()->getScalarType();
 
   Assert1(isa<PointerType>(TargetTy),
-    "GEP base pointer is not a vector or a vector of pointers", &GEP);
+          "GEP base pointer is not a vector or a vector of pointers", &GEP);
   Assert1(cast<PointerType>(TargetTy)->getElementType()->isSized(),
           "GEP into unsized type!", &GEP);
+  Assert1(GEP.getPointerOperand() != &GEP,
+          "GEP is using the result as the pointer operand!", &GEP);
 
   SmallVector<Value*, 16> Idxs(GEP.idx_begin(), GEP.idx_end());
   Type *ElTy =