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


C++ GlobalVariable::print方法代码示例

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


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

示例1: assert

bool AArch64PromoteConstant::insertDefinitions(
    Constant *Cst, InsertionPointsPerFunc &InsPtsPerFunc) {
  // We will create one global variable per Module.
  DenseMap<Module *, GlobalVariable *> ModuleToMergedGV;
  bool HasChanged = false;

  // Traverse all insertion points in all the function.
  for (InsertionPointsPerFunc::iterator FctToInstPtsIt = InsPtsPerFunc.begin(),
                                        EndIt = InsPtsPerFunc.end();
       FctToInstPtsIt != EndIt; ++FctToInstPtsIt) {
    InsertionPoints &InsertPts = FctToInstPtsIt->second;
// Do more checking for debug purposes.
#ifndef NDEBUG
    DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(
        *FctToInstPtsIt->first).getDomTree();
#endif
    GlobalVariable *PromotedGV;
    assert(!InsertPts.empty() && "Empty uses does not need a definition");

    Module *M = FctToInstPtsIt->first->getParent();
    DenseMap<Module *, GlobalVariable *>::iterator MapIt =
        ModuleToMergedGV.find(M);
    if (MapIt == ModuleToMergedGV.end()) {
      PromotedGV = new GlobalVariable(
          *M, Cst->getType(), true, GlobalValue::InternalLinkage, nullptr,
          "_PromotedConst", nullptr, GlobalVariable::NotThreadLocal);
      PromotedGV->setInitializer(Cst);
      ModuleToMergedGV[M] = PromotedGV;
      DEBUG(dbgs() << "Global replacement: ");
      DEBUG(PromotedGV->print(dbgs()));
      DEBUG(dbgs() << '\n');
      ++NumPromoted;
      HasChanged = true;
    } else {
      PromotedGV = MapIt->second;
    }

    for (InsertionPoints::iterator IPI = InsertPts.begin(),
                                   EndIPI = InsertPts.end();
         IPI != EndIPI; ++IPI) {
      // Create the load of the global variable.
      IRBuilder<> Builder(IPI->first->getParent(), IPI->first);
      LoadInst *LoadedCst = Builder.CreateLoad(PromotedGV);
      DEBUG(dbgs() << "**********\n");
      DEBUG(dbgs() << "New def: ");
      DEBUG(LoadedCst->print(dbgs()));
      DEBUG(dbgs() << '\n');

      // Update the dominated uses.
      Users &DominatedUsers = IPI->second;
      for (Value::user_iterator Use : DominatedUsers) {
#ifndef NDEBUG
        assert((DT.dominates(LoadedCst, cast<Instruction>(*Use)) ||
                (isa<PHINode>(*Use) &&
                 DT.dominates(LoadedCst, findInsertionPoint(Use)))) &&
               "Inserted definition does not dominate all its uses!");
#endif
        DEBUG(dbgs() << "Use to update " << Use.getOperandNo() << ":");
        DEBUG(Use->print(dbgs()));
        DEBUG(dbgs() << '\n');
        Use->setOperand(Use.getOperandNo(), LoadedCst);
        ++NumPromotedUses;
      }
    }
  }
  return HasChanged;
}
开发者ID:AntiMoron,项目名称:llvm,代码行数:67,代码来源:AArch64PromoteConstant.cpp


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