Skip to content
MemCpyOptimizer.cpp 39 KiB
Newer Older
        RepeatInstruction = processMemMove(M);
      else if (CallSite CS = (Value*)I) {
        for (unsigned i = 0, e = CS.arg_size(); i != e; ++i)
            MadeChange |= processByValArgument(CS, i);
      }

      // Reprocess the instruction if desired.
      if (RepeatInstruction) {
Nadav Rotem's avatar
Nadav Rotem committed

  return MadeChange;

// MemCpyOpt::runOnFunction - This is the main transformation entry point for a
// function.
//
bool MemCpyOpt::runOnFunction(Function &F) {
  bool MadeChange = false;
  MD = &getAnalysis<MemoryDependenceAnalysis>();
  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
  DL = DLP ? &DLP->getDataLayout() : 0;
  TLI = &getAnalysis<TargetLibraryInfo>();
Nadav Rotem's avatar
Nadav Rotem committed

  // If we don't have at least memset and memcpy, there is little point of doing
  // anything here.  These are required by a freestanding implementation, so if
  // even they are disabled, there is no point in trying hard.
  if (!TLI->has(LibFunc::memset) || !TLI->has(LibFunc::memcpy))
    return false;
Nadav Rotem's avatar
Nadav Rotem committed

  while (1) {
    if (!iterateOnFunction(F))
      break;
    MadeChange = true;
  }
Nadav Rotem's avatar
Nadav Rotem committed