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


C++ DISubprogram类代码示例

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


在下文中一共展示了DISubprogram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
      return nullptr;
    if (!CalleeName.empty()) {
      S.push_back(CallsiteLocation(getOffset(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:adityavs,项目名称:llvm,代码行数:36,代码来源:SampleProfile.cpp

示例2: ReplaceFunctionVariables

int
ReplaceFunctionVariables(
    ClientData clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[])
{
    if (objc < 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "function variable...");
	return TCL_ERROR;
    }

    DISubprogram *function;
    if (GetMetadataFromObj(interp, objv[1], "function", function) != TCL_OK)
	return TCL_ERROR;
    std::vector<Metadata*> variables;
    for (int i=2 ; i<objc ; i++) {
	DILocalVariable *var;
	if (GetMetadataFromObj(interp, objv[i], "variable", var) != TCL_OK)
	    return TCL_ERROR;
	variables.push_back(var);
    }

    auto vars = function->getVariables();
    if (!vars->isTemporary()) {
	Tcl_SetObjResult(interp, Tcl_NewStringObj(
		"can only replace variable list when temporary", -1));
	return TCL_ERROR;
    }

    vars->replaceAllUsesWith(MDNode::get(vars->getContext(), variables));
    function->resolveCycles();
    return TCL_OK;
}
开发者ID:jdc8,项目名称:llvmtcl,代码行数:34,代码来源:debuginfo.cpp

示例3: processSubprogram

/// processSubprogram - Process DISubprogram.
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
  if (!addSubprogram(SP))
    return;
  if (SP.getVersion() <= LLVMDebugVersion10)
    addCompileUnit(SP.getCompileUnit());
  processType(SP.getType());
}
开发者ID:PhongNgo,项目名称:llvm,代码行数:8,代码来源:DebugInfo.cpp

示例4: getScopeNode

DebugLoc DebugLoc::getFnDebugLoc(const LLVMContext &Ctx) const {
  const MDNode *Scope = getScopeNode(Ctx);
  DISubprogram SP = getDISubprogram(Scope);
  if (SP.isSubprogram())
    return DebugLoc::get(SP.getScopeLineNumber(), 0, SP);

  return DebugLoc();
}
开发者ID:Drup,项目名称:llvm,代码行数:8,代码来源:DebugLoc.cpp

示例5: processSubprogram

/// processSubprogram - Process DISubprogram.
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
  if (SP.isNull())
    return;
  if (!addSubprogram(SP))
    return;
  addCompileUnit(SP.getCompileUnit());
  processType(SP.getType());
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例6: getInlinedAtScope

DebugLoc DebugLoc::getFnDebugLoc() const {
  // FIXME: Add a method on \a MDLocation that does this work.
  const MDNode *Scope = getInlinedAtScope();
  DISubprogram SP = getDISubprogram(Scope);
  if (SP.isSubprogram())
    return DebugLoc::get(SP.getScopeLineNumber(), 0, SP);

  return DebugLoc();
}
开发者ID:chapuni,项目名称:llvm,代码行数:9,代码来源:DebugLoc.cpp

示例7: assert

bool DIVariable::isInlinedFnArgument(const Function *CurFn) {
  assert(CurFn && "Invalid function");
  DISubprogram SP = dyn_cast<MDSubprogram>(getContext());
  if (!SP)
    return false;
  // This variable is not inlined function argument if its scope
  // does not describe current function.
  return !SP.describes(CurFn);
}
开发者ID:kunhuahuang,项目名称:llvm,代码行数:9,代码来源:DebugInfo.cpp

示例8: addSubprogram

// addSubprogram - Add subprgoram into SPs.
bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
  if (SP.isNull())
    return false;

  if (!NodesSeen.insert(SP.getNode()))
    return false;

  SPs.push_back(SP.getNode());
  return true;
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例9: assert

void DebugDatabase::addFunction(MDNode *subprogram, GenerateRTL *hw) {
    string name;
    DISubprogram s;

    assert(subprogram || hw);

    if (subprogram) {
        s = DISubprogram(subprogram);
        name = s.getName().str();
    }

    if (hw) {
        //        dbgs() << "Adding function " <<
        //        hw->getFunction()->getName().str() << "\n";
        if (hwToFunctionIds.find(hw) != hwToFunctionIds.end()) {
            // This function has already been added
            // This can happen since we add functions with metadata first, then
            // add all functions with hardware next.  Those with metadata will
            // have
            // already been added
            //            dbgs() << "exiting\n";
            return;
        } else {
            //            dbgs() << "not exiting\n";
        }

        if (subprogram) {
            assert(name == hw->getFunction()->getName().str());
        } else {
            name = hw->getFunction()->getName().str();
        }
    }

    std::string query = "INSERT INTO Function (designId, name, inlined, "
                        "hasMetadata, startLineNumber) ";
    query += "VALUES (" + std::to_string(designId);
    query += "," + addQuotesToStr(name);
    query += "," + std::to_string(hw ? false : true);
    query += "," + std::to_string(subprogram ? true : false);
    query += "," + (subprogram ? std::to_string(s.getLineNumber()) : "NULL");
    query += ");";
    runQuery(query);

    int functionId = mysql_insert_id(connection);

    if (subprogram) {
        subprogramsToFunctionIds[subprogram] = functionId;
    }

    if (hw) {
        hwToFunctionIds[hw] = functionId;
    }
}
开发者ID:eddiehung,项目名称:dox-legup,代码行数:53,代码来源:DebugDatabase.cpp

示例10: getScopeNode

DebugLoc DebugLoc::getFnDebugLoc(const LLVMContext &Ctx) {
  const MDNode *Scope = getScopeNode(Ctx);
  DISubprogram SP = getDISubprogram(Scope);
  if (SP.isSubprogram()) {
    // Check for number of operands since the compatibility is
    // cheap here.  FIXME: Name the magic constant.
    if (SP->getNumOperands() > 19)
      return DebugLoc::get(SP.getScopeLineNumber(), 0, SP);
    else
      return DebugLoc::get(SP.getLineNumber(), 0, SP);
  }

  return DebugLoc();
}
开发者ID:ADonut,项目名称:LLVM-GPGPU,代码行数:14,代码来源:DebugLoc.cpp

示例11: getFunctionInfo

void getFunctionInfo(const char **name, int *line, const char **filename, size_t pointer)
{
    std::map<size_t, FuncInfo> info = jl_jit_events->getMap();
    *name = NULL;
    *line = -1;
    *filename = "no file";
    for (std::map<size_t, FuncInfo>::iterator it= info.begin(); it!= info.end(); it++) {
        if ((*it).first <= pointer) {
            if ((size_t)(*it).first + (*it).second.lengthAdr >= pointer) {
#if LLVM_VERSION_MAJOR == 3
#if LLVM_VERSION_MINOR == 0
                *name = &(*(*it).second.func).getNameStr()[0];
#elif LLVM_VERSION_MINOR >= 1
                *name = (((*(*it).second.func).getName()).data());
#endif
#endif
                if ((*it).second.lines.size() == 0) {
                    continue;
                }
                
                std::vector<JITEvent_EmittedFunctionDetails::LineStart>::iterator vit = (*it).second.lines.begin();
                JITEvent_EmittedFunctionDetails::LineStart prev = *vit;

                DISubprogram debugscope =
                    DISubprogram(prev.Loc.getScope((*it).second.func->getContext()));
                *filename = debugscope.getFilename().data();
                // the DISubprogram has the un-mangled name, so use that if
                // available.
                *name = debugscope.getName().data();
                
                vit++;
                
                while (vit != (*it).second.lines.end()) {
                    if (pointer <= (*vit).Address) {
                        *line = prev.Loc.getLine();
                        break;
                    }
                    prev = *vit;
                    vit++;
                }
                if (*line == -1) {
                    *line = prev.Loc.getLine();
                }
                
                break;
            }
        }
    }
}
开发者ID:ajpkane,项目名称:julia,代码行数:49,代码来源:debuginfo.cpp

示例12: processSubprogram

void DebugInfoFinder::processSubprogram(DISubprogram SP) {
  if (!addSubprogram(SP))
    return;
  processScope(SP.getContext().resolve(TypeIdentifierMap));
  processType(SP.getType());
  for (auto *Element : SP.getTemplateParams()) {
    if (DITemplateTypeParameter TType =
            dyn_cast<MDTemplateTypeParameter>(Element)) {
      processType(TType.getType().resolve(TypeIdentifierMap));
    } else if (DITemplateValueParameter TVal =
                   dyn_cast<MDTemplateValueParameter>(Element)) {
      processType(TVal.getType().resolve(TypeIdentifierMap));
    }
  }
}
开发者ID:kunhuahuang,项目名称:llvm,代码行数:15,代码来源:DebugInfo.cpp

示例13: getDISubprogram

DISubprogram llvm::getDISubprogram(const Function *F) {
  // We look for the first instr that has a debug annotation leading back to F.
  for (auto &BB : *F) {
    auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) {
      return !Inst.getDebugLoc().isUnknown();
    });
    if (Inst == BB.end())
      continue;
    DebugLoc DLoc = Inst->getDebugLoc();
    const MDNode *Scope = DLoc.getScopeNode();
    DISubprogram Subprogram = getDISubprogram(Scope);
    return Subprogram.describes(F) ? Subprogram : DISubprogram();
  }

  return DISubprogram();
}
开发者ID:cschreiner,项目名称:llvm,代码行数:16,代码来源:DebugInfo.cpp

示例14: processSubprogram

void DebugInfoFinder::processSubprogram(DISubprogram SP) {
  if (!addSubprogram(SP))
    return;
  processScope(SP.getContext().resolve(TypeIdentifierMap));
  processType(SP.getType());
  DIArray TParams = SP.getTemplateParams();
  for (unsigned I = 0, E = TParams.getNumElements(); I != E; ++I) {
    DIDescriptor Element = TParams.getElement(I);
    if (Element.isTemplateTypeParameter()) {
      DITemplateTypeParameter TType(Element);
      processType(TType.getType().resolve(TypeIdentifierMap));
    } else if (Element.isTemplateValueParameter()) {
      DITemplateValueParameter TVal(Element);
      processType(TVal.getType().resolve(TypeIdentifierMap));
    }
  }
}
开发者ID:RichardsonAlex,项目名称:llvm,代码行数:17,代码来源:DebugInfo.cpp

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