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


C++ NamedMDNode::addOperand方法代码示例

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


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

示例1: assert

DICompileUnit *DIBuilder::createCompileUnit(
    unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer,
    bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
    DebugEmissionKind Kind, uint64_t DWOId, bool EmitDebugInfo) {

  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
          (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
         "Invalid Language tag");
  assert(!Filename.empty() &&
         "Unable to create compile unit without filename");

  assert(!CUNode && "Can only make one compile unit per DIBuilder instance");
  CUNode = DICompileUnit::getDistinct(
      VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer,
      isOptimized, Flags, RunTimeVer, SplitName, Kind, nullptr,
      nullptr, nullptr, nullptr, nullptr, DWOId);

  // Create a named metadata so that it is easier to find cu in a module.
  // Note that we only generate this when the caller wants to actually
  // emit debug information. When we are only interested in tracking
  // source line locations throughout the backend, we prevent codegen from
  // emitting debug info in the final output by not generating llvm.dbg.cu.
  if (EmitDebugInfo) {
    NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
    NMD->addOperand(CUNode);
  }

  trackIfUnresolved(CUNode);
  return CUNode;
}
开发者ID:IanLee1521,项目名称:ares,代码行数:30,代码来源:DIBuilder.cpp

示例2: createLocalVariable

/// createVariable - Create a new descriptor for the specified variable.
DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
                                          StringRef Name, DIFile File,
                                          unsigned LineNo, DIType Ty,
                                          bool AlwaysPreserve, unsigned Flags,
                                          unsigned ArgNo) {
  Value *Elts[] = {
    GetTagConstant(VMContext, Tag),
    getNonCompileUnitScope(Scope),
    MDString::get(VMContext, Name),
    File,
    ConstantInt::get(Type::getInt32Ty(VMContext), (LineNo | (ArgNo << 24))),
    Ty,
    ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
    Constant::getNullValue(Type::getInt32Ty(VMContext))
  };
  MDNode *Node = MDNode::get(VMContext, Elts);
  if (AlwaysPreserve) {
    // The optimizer may remove local variable. If there is an interest
    // to preserve variable info in such situation then stash it in a
    // named mdnode.
    DISubprogram Fn(getDISubprogram(Scope));
    NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, Fn);
    FnLocals->addOperand(Node);
  }
  return DIVariable(Node);
}
开发者ID:ebraheemk,项目名称:llvm-picoblaze,代码行数:27,代码来源:DIBuilder.cpp

示例3: LLVMAddNamedMetadataOperand2

void LLVMAddNamedMetadataOperand2(LLVMModuleRef M, const char *name,
                                  LLVMMetadataRef Val) {
  NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(name);
  if (!N)
    return;
  if (!Val)
    return;
  N->addOperand(unwrap<MDNode>(Val));
}
开发者ID:Aj0Ay,项目名称:llvm,代码行数:9,代码来源:IRBindings.cpp

示例4: makeArrayRef

static void
ModuleMetaSet(Module *module, StringRef MetaName, StringRef ValueStr) {
  NamedMDNode *node = module->getNamedMetadata(MetaName);
  if (node)
    module->eraseNamedMetadata(node);
  node = module->getOrInsertNamedMetadata(MetaName);
  MDString *value = MDString::get(module->getContext(), ValueStr);
  node->addOperand(MDNode::get(module->getContext(),
                   makeArrayRef(static_cast<Value*>(value))));
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:10,代码来源:Module.cpp

示例5: linkNamedMDNodes

/// Insert all of the named MDNodes in Src into the Dest module.
void IRLinker::linkNamedMDNodes() {
  const NamedMDNode *SrcModFlags = SrcM->getModuleFlagsMetadata();
  for (const NamedMDNode &NMD : SrcM->named_metadata()) {
    // Don't link module flags here. Do them separately.
    if (&NMD == SrcModFlags)
      continue;
    NamedMDNode *DestNMD = DstM.getOrInsertNamedMetadata(NMD.getName());
    // Add Src elements into Dest node.
    for (const MDNode *Op : NMD.operands())
      DestNMD->addOperand(Mapper.mapMDNode(*Op));
  }
}
开发者ID:yxsamliu,项目名称:llvm,代码行数:13,代码来源:IRMover.cpp

示例6: linkNamedMDNodes

/// linkNamedMDNodes - Insert all of the named mdnodes in Src into the Dest
/// module.
void ModuleLinker::linkNamedMDNodes() {
  const NamedMDNode *SrcModFlags = SrcM->getModuleFlagsMetadata();
  for (Module::const_named_metadata_iterator I = SrcM->named_metadata_begin(),
       E = SrcM->named_metadata_end(); I != E; ++I) {
    // Don't link module flags here. Do them separately.
    if (&*I == SrcModFlags) continue;
    NamedMDNode *DestNMD = DstM->getOrInsertNamedMetadata(I->getName());
    // Add Src elements into Dest node.
    for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
      DestNMD->addOperand(MapValue(I->getOperand(i), ValueMap,
                                   RF_None, &TypeMap));
  }
}
开发者ID:groue,项目名称:llvm,代码行数:15,代码来源:LinkModules.cpp

示例7: createCompileUnit

DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
                                           StringRef Directory,
                                           StringRef Producer, bool isOptimized,
                                           StringRef Flags, unsigned RunTimeVer,
                                           StringRef SplitName,
                                           DebugEmissionKind Kind,
                                           bool EmitDebugInfo) {

  assert(((Lang <= dwarf::DW_LANG_OCaml && Lang >= dwarf::DW_LANG_C89) ||
          (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
         "Invalid Language tag");
  assert(!Filename.empty() &&
         "Unable to create compile unit without filename");
  Value *TElts[] = {HeaderBuilder::get(DW_TAG_base_type).get(VMContext)};
  TempEnumTypes = MDNode::getTemporary(VMContext, TElts);

  TempRetainTypes = MDNode::getTemporary(VMContext, TElts);

  TempSubprograms = MDNode::getTemporary(VMContext, TElts);

  TempGVs = MDNode::getTemporary(VMContext, TElts);

  TempImportedModules = MDNode::getTemporary(VMContext, TElts);

  Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_compile_unit)
                       .concat(Lang)
                       .concat(Producer)
                       .concat(isOptimized)
                       .concat(Flags)
                       .concat(RunTimeVer)
                       .concat(SplitName)
                       .concat(Kind)
                       .get(VMContext),
                   createFilePathPair(VMContext, Filename, Directory),
                   TempEnumTypes, TempRetainTypes, TempSubprograms, TempGVs,
                   TempImportedModules};

  MDNode *CUNode = MDNode::get(VMContext, Elts);

  // Create a named metadata so that it is easier to find cu in a module.
  // Note that we only generate this when the caller wants to actually
  // emit debug information. When we are only interested in tracking
  // source line locations throughout the backend, we prevent codegen from
  // emitting debug info in the final output by not generating llvm.dbg.cu.
  if (EmitDebugInfo) {
    NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
    NMD->addOperand(CUNode);
  }

  return DICompileUnit(CUNode);
}
开发者ID:MessiahAndrw,项目名称:Perception,代码行数:51,代码来源:DIBuilder.cpp

示例8: linkNamedMDNodes

/// Insert all of the named MDNodes in Src into the Dest module.
void IRLinker::linkNamedMDNodes() {
  const NamedMDNode *SrcModFlags = SrcM.getModuleFlagsMetadata();
  for (const NamedMDNode &NMD : SrcM.named_metadata()) {
    // Don't link module flags here. Do them separately.
    if (&NMD == SrcModFlags)
      continue;
    NamedMDNode *DestNMD = DstM.getOrInsertNamedMetadata(NMD.getName());
    // Add Src elements into Dest node.
    for (const MDNode *op : NMD.operands())
      DestNMD->addOperand(MapMetadata(
          op, ValueMap, RF_MoveDistinctMDs | RF_NullMapMissingGlobalValues,
          &TypeMap, &GValMaterializer));
  }
}
开发者ID:jhayworth,项目名称:llvm,代码行数:15,代码来源:IRMover.cpp

示例9: createCompileUnit

/// createCompileUnit - A CompileUnit provides an anchor for all debugging
/// information generated during this instance of compilation.
void DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
                                  StringRef Directory, StringRef Producer,
                                  bool isOptimized, StringRef Flags,
                                  unsigned RunTimeVer) {
  assert(((Lang <= dwarf::DW_LANG_Python && Lang >= dwarf::DW_LANG_C89) ||
          (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
         "Invalid Language tag");
  assert(!Filename.empty() &&
         "Unable to create compile unit without filename");
  Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
  TempEnumTypes = MDNode::getTemporary(VMContext, TElts);
  Value *THElts[] = { TempEnumTypes };
  MDNode *EnumHolder = MDNode::get(VMContext, THElts);

  TempRetainTypes = MDNode::getTemporary(VMContext, TElts);
  Value *TRElts[] = { TempRetainTypes };
  MDNode *RetainHolder = MDNode::get(VMContext, TRElts);

  TempSubprograms = MDNode::getTemporary(VMContext, TElts);
  Value *TSElts[] = { TempSubprograms };
  MDNode *SPHolder = MDNode::get(VMContext, TSElts);

  TempGVs = MDNode::getTemporary(VMContext, TElts);
  Value *TVElts[] = { TempGVs };
  MDNode *GVHolder = MDNode::get(VMContext, TVElts);

  Value *Elts[] = {
    GetTagConstant(VMContext, dwarf::DW_TAG_compile_unit),
    Constant::getNullValue(Type::getInt32Ty(VMContext)),
    ConstantInt::get(Type::getInt32Ty(VMContext), Lang),
    MDString::get(VMContext, Filename),
    MDString::get(VMContext, Directory),
    MDString::get(VMContext, Producer),
    // Deprecate isMain field.
    ConstantInt::get(Type::getInt1Ty(VMContext), true), // isMain
    ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
    MDString::get(VMContext, Flags),
    ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer),
    EnumHolder,
    RetainHolder,
    SPHolder,
    GVHolder
  };
  TheCU = DICompileUnit(MDNode::get(VMContext, Elts));

  // Create a named metadata so that it is easier to find cu in a module.
  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
  NMD->addOperand(TheCU);
}
开发者ID:ebraheemk,项目名称:llvm-picoblaze,代码行数:51,代码来源:DIBuilder.cpp

示例10: CU

    CopyConnectedComponent(Module * dest_, Module * src_, llvmutil_Property copyGlobal_, void * data_, ValueToValueMapTy & VMap_)
    : dest(dest_), src(src_), copyGlobal(copyGlobal_), data(data_), VMap(VMap_), DI(NULL) {
        if(NamedMDNode * NMD = src->getNamedMetadata("llvm.module.flags")) {
            NamedMDNode * New = dest->getOrInsertNamedMetadata(NMD->getName());
            for (unsigned i = 0; i < NMD->getNumOperands(); i++) {
                New->addOperand(MapValue(NMD->getOperand(i), VMap));
            }
        }

        if(NamedMDNode * CUN = src->getNamedMetadata("llvm.dbg.cu")) {
            DI = new DIBuilder(*dest);
            DICompileUnit CU(CUN->getOperand(0));
            NCU = DI->createCompileUnit(CU.getLanguage(), CU.getFilename(), CU.getDirectory(), CU.getProducer(), CU.isOptimized(), CU.getFlags(), CU.getRunTimeVersion());
        }
    }
开发者ID:0----0,项目名称:terra,代码行数:15,代码来源:tllvmutil.cpp

示例11: convertLibraryListToMetadata

void Module::convertLibraryListToMetadata() const {
  if (LibraryList.size() == 0)
    return;
  // Get the DepLib node
  NamedMDNode *Node = getNamedMetadata("DepLibs");
  assert(Node && "DepLibs metadata node missing");
  // Erase all existing operands
  Node->dropAllReferences();
  // Add all libraries from the library list
  for (Module::lib_iterator I = lib_begin(), E = lib_end(); I != E; ++I) {
    MDString *value = MDString::get(getContext(), *I);
    Node->addOperand(MDNode::get(getContext(),
                                 makeArrayRef(static_cast<Value*>(value))));
  }
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:15,代码来源:Module.cpp

示例12: TestNamedMDOps

bool ReduceCrashingNamedMDOps::TestNamedMDOps(
    std::vector<const MDNode *> &NamedMDOps) {
  // Convert list to set for fast lookup...
  SmallPtrSet<const MDNode *, 32> OldMDNodeOps;
  for (unsigned i = 0, e = NamedMDOps.size(); i != e; ++i) {
    OldMDNodeOps.insert(NamedMDOps[i]);
  }

  outs() << "Checking for crash with only " << OldMDNodeOps.size();
  if (OldMDNodeOps.size() == 1)
    outs() << " named metadata operand: ";
  else
    outs() << " named metadata operands: ";

  ValueToValueMapTy VMap;
  Module *M = CloneModule(BD.getProgram(), VMap).release();

  // This is a little wasteful. In the future it might be good if we could have
  // these dropped during cloning.
  for (auto &NamedMD : BD.getProgram()->named_metadata()) {
    // Drop the old one and create a new one
    M->eraseNamedMetadata(M->getNamedMetadata(NamedMD.getName()));
    NamedMDNode *NewNamedMDNode =
        M->getOrInsertNamedMetadata(NamedMD.getName());
    for (MDNode *op : NamedMD.operands())
      if (OldMDNodeOps.count(op))
        NewNamedMDNode->addOperand(cast<MDNode>(MapMetadata(op, VMap)));
  }

  // Verify that this is still valid.
  legacy::PassManager Passes;
  Passes.add(createVerifierPass(/*FatalErrors=*/false));
  Passes.run(*M);

  // Try running on the hacked up program...
  if (TestFn(BD, M)) {
    // Make sure to use instruction pointers that point into the now-current
    // module, and that they don't include any deleted blocks.
    NamedMDOps.clear();
    for (const MDNode *Node : OldMDNodeOps)
      NamedMDOps.push_back(cast<MDNode>(*VMap.getMappedMD(Node)));

    BD.setNewProgram(M); // It crashed, keep the trimmed version...
    return true;
  }
  delete M; // It didn't crash, try something else.
  return false;
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:48,代码来源:CrashDebugger.cpp

示例13: assert

  bool
  SpecializationTable::addSpecialization(Function* parent,
      ConstSpecScheme scheme, Function* specialization, bool record)
  {
    assert(parent != NULL);
    assert(specialization != NULL);

    SpecTable::iterator cursor = this->specialized.find(specialization);
    //Specialization* spec = this->specialized.lookup(specialization->getName());
    if (cursor != this->specialized.end()) {
      return false;
    }

    Specialization* parentSpec = this->getSpecialization(parent);

    Specialization* spec = new Specialization();
    spec->handle = specialization;
    spec->parent = parentSpec;
    spec->args = scheme;
    this->specialized[specialization] = spec;

    //.GetOrCreateValue(specialization->getName(), spec);
    parentSpec->children.push_back(spec);

#if RECORD_IN_METADATA
    // Add the meta-data
    if (record) {
      NamedMDNode* md = this->module->getOrInsertNamedMetadata(
          "previrt::specializations");

      const unsigned int arg_count = parent->getArgumentList().size();
      Value** vals = new Value*[2 + arg_count];
      vals[0] = MDString::get(parent->getContext(), parent->getName());
      vals[1] = MDString::get(parent->getContext(), specialization->getName());
      for (unsigned int i = 0; i < parent->getArgumentList().size(); ++i) {
        vals[i+2] = scheme[i];
      }

      ArrayRef<Value*> ar_vals(vals, vals+2+arg_count);
      MDNode* nde = MDNode::get(this->module->getContext(), ar_vals);

      md->addOperand(nde);
    }
#endif /* RECORD_IN_METADATA */

    return true;
  }
开发者ID:ishaq,项目名称:OCCAM,代码行数:47,代码来源:SpecializationTable.cpp

示例14: addNeededRecord

void Module::addNeededRecord(StringRef DynFile, GlobalValue *GV) {
  if (DynFile.empty()) {
    // We never resolved this symbol, even after linking.
    // This should only happen in a shared object.
    // It is safe to ignore this symbol, and let the dynamic loader
    // figure out where it comes from.
    return;
  }
  std::string Key = NeededPrefix;
  Key += DynFile;
  // Get the node for this file.
  NamedMDNode *Node = getOrInsertNamedMetadata(Key);
  // Add this global value's name to the list.
  MDString *value = MDString::get(getContext(), GV->getName());
  Node->addOperand(MDNode::get(getContext(),
                   makeArrayRef(static_cast<Value*>(value))));
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:17,代码来源:Module.cpp

示例15: createCompileUnit

/// createCompileUnit - A CompileUnit provides an anchor for all debugging
/// information generated during this instance of compilation.
DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
                                           StringRef Directory,
                                           StringRef Producer, bool isOptimized,
                                           StringRef Flags, unsigned RunTimeVer,
                                           StringRef SplitName) {
  assert(((Lang <= dwarf::DW_LANG_Python && Lang >= dwarf::DW_LANG_C89) ||
          (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
         "Invalid Language tag");
  assert(!Filename.empty() &&
         "Unable to create compile unit without filename");
  Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
  TempEnumTypes = MDNode::getTemporary(VMContext, TElts);

  TempRetainTypes = MDNode::getTemporary(VMContext, TElts);

  TempSubprograms = MDNode::getTemporary(VMContext, TElts);

  TempGVs = MDNode::getTemporary(VMContext, TElts);

  TempImportedModules = MDNode::getTemporary(VMContext, TElts);

  Value *Elts[] = {
    GetTagConstant(VMContext, dwarf::DW_TAG_compile_unit),
    createFilePathPair(VMContext, Filename, Directory),
    ConstantInt::get(Type::getInt32Ty(VMContext), Lang),
    MDString::get(VMContext, Producer),
    ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
    MDString::get(VMContext, Flags),
    ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer),
    TempEnumTypes,
    TempRetainTypes,
    TempSubprograms,
    TempGVs,
    TempImportedModules,
    MDString::get(VMContext, SplitName)
  };

  MDNode *CUNode = MDNode::get(VMContext, Elts);

  // Create a named metadata so that it is easier to find cu in a module.
  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
  NMD->addOperand(CUNode);

  return DICompileUnit(CUNode);
}
开发者ID:Dr15Jones,项目名称:root,代码行数:47,代码来源:DIBuilder.cpp


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