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


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

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


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

示例1: 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

示例2: convertMetadataToLibraryList

// @LOCALMOD-BEGIN
void Module::convertMetadataToLibraryList() {
  LibraryList.clear();
  // Get the DepLib node
  NamedMDNode *Node = getNamedMetadata("DepLibs");
  if (!Node)
    return;
  for (unsigned i = 0; i < Node->getNumOperands(); i++) {
    MDString* Mds = dyn_cast_or_null<MDString>(
        Node->getOperand(i)->getOperand(0));
    assert(Mds && "Bad NamedMetadata operand");
    LibraryList.push_back(Mds->getString());
  }
  // Clear the metadata so the linker won't try to merge it
  Node->dropAllReferences();
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:16,代码来源:Module.cpp

示例3: linkModuleFlagsMetadata

/// linkModuleFlagsMetadata - Merge the linker flags in Src into the Dest
/// module.
bool ModuleLinker::linkModuleFlagsMetadata() {
  const NamedMDNode *SrcModFlags = SrcM->getModuleFlagsMetadata();
  if (!SrcModFlags) return false;

  NamedMDNode *DstModFlags = DstM->getOrInsertModuleFlagsMetadata();

  // If the destination module doesn't have module flags yet, then just copy
  // over the source module's flags.
  if (DstModFlags->getNumOperands() == 0) {
    for (unsigned I = 0, E = SrcModFlags->getNumOperands(); I != E; ++I)
      DstModFlags->addOperand(SrcModFlags->getOperand(I));

    return false;
  }

  bool HasErr = false;

  // Otherwise, we have to merge them based on their behaviors. First,
  // categorize all of the nodes in the modules' module flags. If an error or
  // warning occurs, then emit the appropriate message(s).
  DenseMap<MDString*, MDNode*> ErrorNode;
  DenseMap<MDString*, MDNode*> WarningNode;
  DenseMap<MDString*, MDNode*> OverrideNode;
  DenseMap<MDString*, SmallSetVector<MDNode*, 8> > RequireNodes;
  SmallSetVector<MDString*, 16> SeenIDs;

  HasErr |= categorizeModuleFlagNodes(SrcModFlags, ErrorNode, WarningNode,
                                      OverrideNode, RequireNodes, SeenIDs);
  HasErr |= categorizeModuleFlagNodes(DstModFlags, ErrorNode, WarningNode,
                                      OverrideNode, RequireNodes, SeenIDs);

  // Check that there isn't both an error and warning node for a flag.
  for (SmallSetVector<MDString*, 16>::iterator
         I = SeenIDs.begin(), E = SeenIDs.end(); I != E; ++I) {
    MDString *ID = *I;
    if (ErrorNode[ID] && WarningNode[ID])
      HasErr = emitError("linking module flags '" + ID->getString() +
                         "': IDs have conflicting behaviors");
  }

  // Early exit if we had an error.
  if (HasErr) return true;

  // Get the destination's module flags ready for new operands.
  DstModFlags->dropAllReferences();

  // Add all of the module flags to the destination module.
  DenseMap<MDString*, SmallVector<MDNode*, 4> > AddedNodes;
  for (SmallSetVector<MDString*, 16>::iterator
         I = SeenIDs.begin(), E = SeenIDs.end(); I != E; ++I) {
    MDString *ID = *I;
    if (OverrideNode[ID]) {
      DstModFlags->addOperand(OverrideNode[ID]);
      AddedNodes[ID].push_back(OverrideNode[ID]);
    } else if (ErrorNode[ID]) {
      DstModFlags->addOperand(ErrorNode[ID]);
      AddedNodes[ID].push_back(ErrorNode[ID]);
    } else if (WarningNode[ID]) {
      DstModFlags->addOperand(WarningNode[ID]);
      AddedNodes[ID].push_back(WarningNode[ID]);
    }

    for (SmallSetVector<MDNode*, 8>::iterator
           II = RequireNodes[ID].begin(), IE = RequireNodes[ID].end();
         II != IE; ++II)
      DstModFlags->addOperand(*II);
  }

  // Now check that all of the requirements have been satisfied.
  for (SmallSetVector<MDString*, 16>::iterator
         I = SeenIDs.begin(), E = SeenIDs.end(); I != E; ++I) {
    MDString *ID = *I;
    SmallSetVector<MDNode*, 8> &Set = RequireNodes[ID];

    for (SmallSetVector<MDNode*, 8>::iterator
           II = Set.begin(), IE = Set.end(); II != IE; ++II) {
      MDNode *Node = *II;
      assert(isa<MDNode>(Node->getOperand(2)) &&
             "Module flag's third operand must be an MDNode!");
      MDNode *Val = cast<MDNode>(Node->getOperand(2));

      MDString *ReqID = cast<MDString>(Val->getOperand(0));
      Value *ReqVal = Val->getOperand(1);

      bool HasValue = false;
      for (SmallVectorImpl<MDNode*>::iterator
             RI = AddedNodes[ReqID].begin(), RE = AddedNodes[ReqID].end();
           RI != RE; ++RI) {
        MDNode *ReqNode = *RI;
        if (ReqNode->getOperand(2) == ReqVal) {
          HasValue = true;
          break;
        }
      }

      if (!HasValue)
        HasErr = emitError("linking module flags '" + ReqID->getString() +
                           "': does not have the required value");
//.........这里部分代码省略.........
开发者ID:groue,项目名称:llvm,代码行数:101,代码来源:LinkModules.cpp


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