当前位置: 首页>>代码示例>>C++>>正文


C++ DISubprogram::getLine方法代码示例

本文整理汇总了C++中DISubprogram::getLine方法的典型用法代码示例。如果您正苦于以下问题:C++ DISubprogram::getLine方法的具体用法?C++ DISubprogram::getLine怎么用?C++ DISubprogram::getLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DISubprogram的用法示例。


在下文中一共展示了DISubprogram::getLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/// \brief Get the FunctionSamples for an instruction.
///
/// The FunctionSamples of an instruction \p Inst is the inlined instance
/// in which that instruction is coming from. We traverse the inline stack
/// of that instruction, and match it with the tree nodes in the profile.
///
/// \param Inst Instruction to query.
///
/// \returns the FunctionSamples pointer to the inlined instance.
const FunctionSamples *
SampleProfileLoader::findFunctionSamples(const Instruction &Inst) const {
  SmallVector<CallsiteLocation, 10> S;
  const DILocation *DIL = Inst.getDebugLoc();
  if (!DIL) {
    return Samples;
  }
  StringRef CalleeName;
  for (const DILocation *DIL = Inst.getDebugLoc(); DIL;
       DIL = DIL->getInlinedAt()) {
    DISubprogram *SP = DIL->getScope()->getSubprogram();
    if (!SP || DIL->getLine() < SP->getLine())
      return nullptr;
    if (!CalleeName.empty()) {
      S.push_back(CallsiteLocation(DIL->getLine() - SP->getLine(),
                                   DIL->getDiscriminator(), CalleeName));
    }
    CalleeName = SP->getLinkageName();
  }
  if (S.size() == 0)
    return Samples;
  const FunctionSamples *FS = Samples;
  for (int i = S.size() - 1; i >= 0 && FS != nullptr; i--) {
    FS = FS->findFunctionSamplesAt(S[i]);
  }
  return FS;
}
开发者ID:nightwishud,项目名称:accmut,代码行数:36,代码来源:SampleProfile.cpp

示例2: findFunctionSamples

/// \brief Get the FunctionSamples for a call instruction.
///
/// The FunctionSamples of a call instruction \p Inst is the inlined
/// instance in which that call instruction is calling to. It contains
/// all samples that resides in the inlined instance. We first find the
/// inlined instance in which the call instruction is from, then we
/// traverse its children to find the callsite with the matching
/// location and callee function name.
///
/// \param Inst Call instruction to query.
///
/// \returns The FunctionSamples pointer to the inlined instance.
const FunctionSamples *
SampleProfileLoader::findCalleeFunctionSamples(const CallInst &Inst) const {
  const DILocation *DIL = Inst.getDebugLoc();
  if (!DIL) {
    return nullptr;
  }
  DISubprogram *SP = DIL->getScope()->getSubprogram();
  if (!SP || DIL->getLine() < SP->getLine())
    return nullptr;

  Function *CalleeFunc = Inst.getCalledFunction();
  if (!CalleeFunc) {
    return nullptr;
  }

  StringRef CalleeName = CalleeFunc->getName();
  const FunctionSamples *FS = findFunctionSamples(Inst);
  if (FS == nullptr)
    return nullptr;

  return FS->findFunctionSamplesAt(CallsiteLocation(
      DIL->getLine() - SP->getLine(), DIL->getDiscriminator(), CalleeName));
}
开发者ID:nightwishud,项目名称:accmut,代码行数:35,代码来源:SampleProfile.cpp

示例3: emitFunctionAnnot

void LineNumberAnnotatedWriter::emitFunctionAnnot(
      const Function *F, formatted_raw_ostream &Out)
{
    InstrLoc = nullptr;
    DISubprogram *FuncLoc = F->getSubprogram();
    if (!FuncLoc) {
        auto SP = Subprogram.find(F);
        if (SP != Subprogram.end())
            FuncLoc = SP->second;
    }
    if (!FuncLoc)
        return;
    std::vector<DILineInfo> DIvec(1);
    DILineInfo &DI = DIvec.back();
    DI.FunctionName = FuncLoc->getName();
    DI.FileName = FuncLoc->getFilename();
    DI.Line = FuncLoc->getLine();
    LinePrinter.emit_lineinfo(Out, DIvec);
}
开发者ID:GunnarFarneback,项目名称:julia,代码行数:19,代码来源:disasm.cpp


注:本文中的DISubprogram::getLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。