예제 #1
0
void SideEffectAnalysis::analyzeFunction(FunctionInfo *FInfo,
                                         FunctionOrder &BottomUpOrder,
                                         int RecursionDepth) {
  FInfo->NeedUpdateCallers = true;

  if (BottomUpOrder.prepareForVisiting(FInfo))
    return;

  // Handle @effects attributes
  if (getDefinedEffects(FInfo->FE, FInfo->F)) {
    DEBUG(llvm::dbgs() << "  -- has defined effects " <<
          FInfo->F->getName() << '\n');
    return;
  }
  
  if (!FInfo->F->isDefinition()) {
    // We can't assume anything about external functions.
    DEBUG(llvm::dbgs() << "  -- is external " << FInfo->F->getName() << '\n');
    FInfo->FE.setWorstEffects();
    return;
  }
  
  DEBUG(llvm::dbgs() << "  >> analyze " << FInfo->F->getName() << '\n');

  // Check all instructions of the function
  for (auto &BB : *FInfo->F) {
    for (auto &I : BB) {
      analyzeInstruction(FInfo, &I, BottomUpOrder, RecursionDepth);
    }
  }
  DEBUG(llvm::dbgs() << "  << finished " << FInfo->F->getName() << '\n');
}
예제 #2
0
void GenericFunctionEffectAnalysis<FunctionEffects>::analyzeFunction(
    FunctionInfo *functionInfo, FunctionOrder &bottomUpOrder,
    int recursionDepth) {
  functionInfo->needUpdateCallers = true;

  if (bottomUpOrder.prepareForVisiting(functionInfo))
    return;

  auto *F = functionInfo->F;
  if (functionInfo->functionEffects.summarizeFunction(F))
    return;

  DEBUG(llvm::dbgs() << "  >> analyze " << F->getName() << '\n');

  // Check all instructions of the function
  for (auto &BB : *F) {
    for (auto &I : BB) {
      if (auto fullApply = FullApplySite::isa(&I))
        analyzeCall(functionInfo, fullApply, bottomUpOrder, recursionDepth);
      else
        functionInfo->functionEffects.analyzeInstruction(&I);
    }
  }
  DEBUG(llvm::dbgs() << "  << finished " << F->getName() << '\n');
}
예제 #3
0
void AccessSummaryAnalysis::processFunction(FunctionInfo *info,
                                            FunctionOrder &order) {
  // Does the summary need to be recomputed?
  if (order.prepareForVisiting(info))
    return;

  // Compute function summary on a per-argument basis.
  unsigned index = 0;
  for (SILArgument *arg : info->getFunction()->getArguments()) {
    FunctionSummary &functionSummary = info->getSummary();
    ArgumentSummary &argSummary =
        functionSummary.getAccessForArgument(index);
    index++;

    auto *functionArg = cast<SILFunctionArgument>(arg);
    // Only summarize @inout_aliasable arguments.
    SILArgumentConvention convention =
        functionArg->getArgumentConvention().Value;
    if (convention != SILArgumentConvention::Indirect_InoutAliasable)
      continue;

    processArgument(info, functionArg, argSummary, order);
  }
}