Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool eliminateStrlen(CallInst *CI, BasicBlock::iterator &BBI,
- AliasAnalysis *AA, MemoryDependenceResults *MD,
- const DataLayout &DL, const TargetLibraryInfo *TLI,
- InstOverlapIntervalsTy &IOL,
- DenseMap<Instruction *, size_t> *InstrOrdering) {
- // Must be a strlen.
- LibFunc Func;
- Function *Callee = CI->getCalledFunction();
- if (!TLI->getLibFunc(*Callee, Func) || !TLI->has(Func) ||
- Func != LibFunc_strlen)
- return false;
- Value *Dst = CI->getOperand(0);
- Instruction *UnderlyingPointer = dyn_cast<Instruction>(GetUnderlyingObject(Dst, DL));
- if (!UnderlyingPointer)
- return false;
- if (isStringFromCalloc(Dst, TLI))
- return false;
- errs() << "before\n";
- if (memoryIsNotModifiedBetween(UnderlyingPointer, CI, AA)) {
- errs() << "after\n";
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement