Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. static bool eliminateStrlen(CallInst *CI, BasicBlock::iterator &BBI,
  2.                             AliasAnalysis *AA, MemoryDependenceResults *MD,
  3.                             const DataLayout &DL, const TargetLibraryInfo *TLI,
  4.                             InstOverlapIntervalsTy &IOL,
  5.                             DenseMap<Instruction *, size_t> *InstrOrdering) {
  6.  
  7.   // Must be a strlen.
  8.   LibFunc Func;
  9.   Function *Callee = CI->getCalledFunction();
  10.   if (!TLI->getLibFunc(*Callee, Func) || !TLI->has(Func) ||
  11.       Func != LibFunc_strlen)
  12.     return false;
  13.  
  14.   Value *Dst = CI->getOperand(0);
  15.   Instruction *UnderlyingPointer = dyn_cast<Instruction>(GetUnderlyingObject(Dst, DL));
  16.   if (!UnderlyingPointer)
  17.     return false;
  18.   if (isStringFromCalloc(Dst, TLI))
  19.     return false;
  20.   errs() << "before\n";
  21.   if (memoryIsNotModifiedBetween(UnderlyingPointer, CI, AA)) {
  22.     errs() << "after\n";
  23.   }
  24.   return false;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement