+
+ if (ElTy) break; // Found a number of zeros we can strip off!
+
+ // Otherwise, we can convert a GEP from one form to the other iff the
+ // current gep is of the form 'getelementptr sbyte*, long N
+ // and we could convert this to an appropriate GEP for the new type.
+ //
+ if (GEP->getNumOperands() == 2 &&
+ GEP->getType() == PointerType::get(Type::SByteTy)) {
+
+ // Do not Check to see if our incoming pointer can be converted
+ // to be a ptr to an array of the right type... because in more cases than
+ // not, it is simply not analyzable because of pointer/array
+ // discrepancies. To fix this, we will insert a cast before the GEP.
+ //
+
+ // Check to see if 'N' is an expression that can be converted to
+ // the appropriate size... if so, allow it.
+ //
+ std::vector<Value*> Indices;
+ const Type *ElTy = ConvertibleToGEP(PTy, I->getOperand(1), Indices, TD);
+ if (ElTy == PVTy) {
+ if (!ExpressionConvertibleToType(I->getOperand(0),
+ PointerType::get(ElTy), CTMap, TD))
+ return false; // Can't continue, ExConToTy might have polluted set!
+ break;
+ }
+ }
+
+ // Otherwise, it could be that we have something like this:
+ // getelementptr [[sbyte] *] * %reg115, long %reg138 ; [sbyte]**
+ // and want to convert it into something like this:
+ // getelemenptr [[int] *] * %reg115, long %reg138 ; [int]**
+ //
+ if (GEP->getNumOperands() == 2 &&
+ PTy->getElementType()->isSized() &&
+ TD.getTypeSize(PTy->getElementType()) ==
+ TD.getTypeSize(GEP->getType()->getElementType())) {
+ const PointerType *NewSrcTy = PointerType::get(PVTy);
+ if (!ExpressionConvertibleToType(I->getOperand(0), NewSrcTy, CTMap, TD))
+ return false;
+ break;
+ }
+
+ return false; // No match, maybe next time.
+ }
+
+ case Instruction::Call: {
+ if (isa<Function>(I->getOperand(0)))
+ return false; // Don't even try to change direct calls.
+
+ // If this is a function pointer, we can convert the return type if we can
+ // convert the source function pointer.
+ //
+ const PointerType *PT = cast<PointerType>(I->getOperand(0)->getType());
+ const FunctionType *FT = cast<FunctionType>(PT->getElementType());
+ std::vector<const Type *> ArgTys(FT->param_begin(), FT->param_end());
+ const FunctionType *NewTy =
+ FunctionType::get(Ty, ArgTys, FT->isVarArg());
+ if (!ExpressionConvertibleToType(I->getOperand(0),
+ PointerType::get(NewTy), CTMap, TD))
+ return false;
+ break;