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


C++ GlobalObject::copyAttributesFrom方法代码示例

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


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

示例1: GlobalVariable

Value *LocalValueMaterializer::materializeValueFor(Value *V) {
  auto *GO = dyn_cast<GlobalObject>(V);
  if (!GO)
    return nullptr;

  auto I = LocalVersions.find(GO);
  if (I != LocalVersions.end())
    return I->second;

  if (!Dropped.count(GO))
    return nullptr;

  Module &M = *GO->getParent();
  GlobalValue::LinkageTypes L = GO->getLinkage();
  GlobalObject *Declaration;
  if (auto *F = dyn_cast<Function>(GO)) {
    Declaration = Function::Create(F->getFunctionType(), L, "", &M);
  } else {
    auto *Var = cast<GlobalVariable>(GO);
    Declaration = new GlobalVariable(M, Var->getType()->getElementType(),
                                     Var->isConstant(), L,
                                     /*Initializer*/ nullptr);
  }
  Declaration->takeName(GO);
  Declaration->copyAttributesFrom(GO);

  GO->setLinkage(GlobalValue::InternalLinkage);
  GO->setName(Declaration->getName());
  Dropped.erase(GO);
  GO->replaceAllUsesWith(Declaration);

  LocalVersions[Declaration] = GO;

  return GO;
}
开发者ID:nightwishud,项目名称:accmut,代码行数:35,代码来源:gold-plugin.cpp

示例2: message

static GlobalObject *makeInternalReplacement(GlobalObject *GO) {
  Module *M = GO->getParent();
  GlobalObject *Ret;
  if (auto *F = dyn_cast<Function>(GO)) {
    if (F->isMaterializable()) {
      if (F->materialize())
        message(LDPL_FATAL, "LLVM gold plugin has failed to read a function");

    }

    auto *NewF = Function::Create(F->getFunctionType(), F->getLinkage(),
                                  F->getName(), M);

    ValueToValueMapTy VM;
    Function::arg_iterator NewI = NewF->arg_begin();
    for (auto &Arg : F->args()) {
      NewI->setName(Arg.getName());
      VM[&Arg] = NewI;
      ++NewI;
    }

    NewF->getBasicBlockList().splice(NewF->end(), F->getBasicBlockList());
    for (auto &BB : *NewF) {
      for (auto &Inst : BB)
        RemapInstruction(&Inst, VM, RF_IgnoreMissingEntries);
    }

    Ret = NewF;
    F->deleteBody();
  } else {
    auto *Var = cast<GlobalVariable>(GO);
    Ret = new GlobalVariable(
        *M, Var->getType()->getElementType(), Var->isConstant(),
        Var->getLinkage(), Var->getInitializer(), Var->getName(),
        nullptr, Var->getThreadLocalMode(), Var->getType()->getAddressSpace(),
        Var->isExternallyInitialized());
    Var->setInitializer(nullptr);
  }
  Ret->copyAttributesFrom(GO);
  Ret->setLinkage(GlobalValue::InternalLinkage);
  Ret->setComdat(GO->getComdat());

  return Ret;
}
开发者ID:Drup,项目名称:llvm,代码行数:44,代码来源:gold-plugin.cpp

示例3: GlobalVariable

static GlobalObject *makeInternalReplacement(GlobalObject *GO) {
  Module *M = GO->getParent();
  GlobalObject *Ret;
  if (auto *F = dyn_cast<Function>(GO)) {
    auto *NewF = Function::Create(
        F->getFunctionType(), GlobalValue::InternalLinkage, F->getName(), M);
    NewF->getBasicBlockList().splice(NewF->end(), F->getBasicBlockList());
    Ret = NewF;
    F->deleteBody();
  } else {
    auto *Var = cast<GlobalVariable>(GO);
    Ret = new GlobalVariable(
        *M, Var->getType()->getElementType(), Var->isConstant(),
        GlobalValue::InternalLinkage, Var->getInitializer(), Var->getName(),
        nullptr, Var->getThreadLocalMode(), Var->getType()->getAddressSpace(),
        Var->isExternallyInitialized());
    Var->setInitializer(nullptr);
  }
  Ret->copyAttributesFrom(GO);
  Ret->setComdat(GO->getComdat());

  return Ret;
}
开发者ID:caio-s-o,项目名称:llvm,代码行数:23,代码来源:gold-plugin.cpp


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