本文整理汇总了C++中GlobalAlias::getBaseObject方法的典型用法代码示例。如果您正苦于以下问题:C++ GlobalAlias::getBaseObject方法的具体用法?C++ GlobalAlias::getBaseObject怎么用?C++ GlobalAlias::getBaseObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalAlias
的用法示例。
在下文中一共展示了GlobalAlias::getBaseObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Flags
static void
computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
DenseSet<GlobalValue::GUID> &CantBePromoted) {
bool NonRenamableLocal = isNonRenamableLocal(A);
GlobalValueSummary::GVFlags Flags(A.getLinkage(), NonRenamableLocal,
/* LiveRoot = */ false);
auto AS = llvm::make_unique<AliasSummary>(Flags, ArrayRef<ValueInfo>{});
auto *Aliasee = A.getBaseObject();
auto *AliaseeSummary = Index.getGlobalValueSummary(*Aliasee);
assert(AliaseeSummary && "Alias expects aliasee summary to be parsed");
AS->setAliasee(AliaseeSummary);
if (NonRenamableLocal)
CantBePromoted.insert(A.getGUID());
Index.addGlobalValueSummary(A.getName(), std::move(AS));
}
示例2: resolveFunction
static Function*
resolveFunction(Module& M, StringRef name)
{
Function* f = M.getFunction(name);
if (f != NULL)
return f;
GlobalAlias* ga = M.getNamedAlias(name);
if (ga != NULL) {
const GlobalValue* v = ga->getBaseObject();
f = dyn_cast<Function>(const_cast<GlobalValue*>(v));
if (f != NULL) {
errs() << "Resolved alias " << name << " to " << f->getName() << "\n";
return f;
}
}
return NULL;
}
示例3: convertAliasToDeclaration
static void convertAliasToDeclaration(GlobalAlias &GA, Module &M) {
GlobalValue *GVal = GA.getBaseObject();
GlobalValue *NewGV;
if (auto *GVar = dyn_cast<GlobalVariable>(GVal)) {
GlobalVariable *NewGVar = new GlobalVariable(
M, GVar->getType()->getElementType(), GVar->isConstant(),
GVar->getLinkage(), /*init*/ nullptr, GA.getName(), GVar,
GVar->getThreadLocalMode(), GVar->getType()->getAddressSpace());
NewGV = NewGVar;
NewGV->copyAttributesFrom(GVar);
} else {
auto *F = dyn_cast<Function>(GVal);
assert(F);
Function *NewF = Function::Create(F->getFunctionType(), F->getLinkage(),
GA.getName(), &M);
NewGV = NewF;
NewGV->copyAttributesFrom(F);
}
GA.replaceAllUsesWith(ConstantExpr::getBitCast(NewGV, GA.getType()));
GA.eraseFromParent();
}