bool CallAnalyzer::visitIntToPtr(IntToPtrInst &I) { // Propagate constants through ptrtoint. Constant *COp = dyn_cast<Constant>(I.getOperand(0)); if (!COp) COp = SimplifiedValues.lookup(I.getOperand(0)); if (COp) if (Constant *C = ConstantExpr::getIntToPtr(COp, I.getType())) { SimplifiedValues[&I] = C; return true; } // Track base/offset pairs when round-tripped through a pointer without // modifications provided the integer is not too large. Value *Op = I.getOperand(0); unsigned IntegerSize = Op->getType()->getScalarSizeInBits(); if (TD && IntegerSize <= TD->getPointerSizeInBits()) { std::pair<Value *, APInt> BaseAndOffset = ConstantOffsetPtrs.lookup(Op); if (BaseAndOffset.first) ConstantOffsetPtrs[&I] = BaseAndOffset; } // "Propagate" SROA here in the same manner as we do for ptrtoint above. Value *SROAArg; DenseMap<Value *, int>::iterator CostIt; if (lookupSROAArgAndCost(Op, SROAArg, CostIt)) SROAArgValues[&I] = SROAArg; return isInstructionFree(&I, TD); }
bool CallAnalyzer::visitIntToPtr(IntToPtrInst &I) { // Propagate constants through ptrtoint. if (Constant *COp = dyn_cast<Constant>(I.getOperand(0))) if (Constant *C = ConstantExpr::getIntToPtr(COp, I.getType())) { SimplifiedValues[&I] = C; return true; } // Track base/offset pairs when round-tripped through a pointer without // modifications provided the integer is not too large. Value *Op = I.getOperand(0); unsigned IntegerSize = Op->getType()->getScalarSizeInBits(); if (TD && IntegerSize <= TD->getPointerSizeInBits()) { std::pair<Value *, APInt> BaseAndOffset = ConstantOffsetPtrs.lookup(Op); if (BaseAndOffset.first) ConstantOffsetPtrs[&I] = BaseAndOffset; } // "Propagate" SROA here in the same manner as we do for ptrtoint above. Value *SROAArg; DenseMap<Value *, int>::iterator CostIt; if (lookupSROAArgAndCost(Op, SROAArg, CostIt)) SROAArgValues[&I] = SROAArg; // An inttoptr cast is free so long as the input is a legal integer type // which doesn't contain values outside the range of a pointer. return TD && TD->isLegalInteger(IntegerSize) && IntegerSize <= TD->getPointerSizeInBits(); }
void GraphBuilder::visitIntToPtrInst(IntToPtrInst &I) { DSNode *N = createNode(); if(I.hasOneUse()) { if(isa<ICmpInst>(*(I.use_begin()))) { NumBoringIntToPtr++; return; } } else { N->setIntToPtrMarker(); N->setUnknownMarker(); } setDestTo(I, N); }
/* These next two are caught by the regular verifier on LLVM 5.0+, but we may want to run this on earlier LLVM versions. */ void GCInvariantVerifier::visitIntToPtrInst(IntToPtrInst &IPI) { Check(!isSpecialAS(IPI.getAddressSpace()), "Illegal inttoptr", &IPI); }
void visitIntToPtrInst(IntToPtrInst& I) { if (isa<FunctionType>(I.getDestTy())) anyUnknown = true; }