本文整理汇总了C++中AttrBuilder::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ AttrBuilder::clear方法的具体用法?C++ AttrBuilder::clear怎么用?C++ AttrBuilder::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttrBuilder
的用法示例。
在下文中一共展示了AttrBuilder::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddReadAttrs
//.........这里部分代码省略.........
if (AliasAnalysis::onlyAccessesArgPointees(MRB)) {
// If the call does access argument pointees, check each argument.
if (AliasAnalysis::doesAccessArgPointees(MRB))
// Check whether all pointer arguments point to local memory, and
// ignore calls that only access local memory.
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
CI != CE; ++CI) {
Value *Arg = *CI;
if (Arg->getType()->isPointerTy()) {
AliasAnalysis::Location Loc(Arg,
AliasAnalysis::UnknownSize,
I->getMetadata(LLVMContext::MD_tbaa));
if (!AA->pointsToConstantMemory(Loc, /*OrLocal=*/true)) {
if (MRB & AliasAnalysis::Mod)
// Writes non-local memory. Give up.
return false;
if (MRB & AliasAnalysis::Ref)
// Ok, it reads non-local memory.
ReadsMemory = true;
}
}
}
continue;
}
// The call could access any memory. If that includes writes, give up.
if (MRB & AliasAnalysis::Mod)
return false;
// If it reads, note it.
if (MRB & AliasAnalysis::Ref)
ReadsMemory = true;
continue;
} else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
// Ignore non-volatile loads from local memory. (Atomic is okay here.)
if (!LI->isVolatile()) {
AliasAnalysis::Location Loc = AA->getLocation(LI);
if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
continue;
}
} else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
// Ignore non-volatile stores to local memory. (Atomic is okay here.)
if (!SI->isVolatile()) {
AliasAnalysis::Location Loc = AA->getLocation(SI);
if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
continue;
}
} else if (VAArgInst *VI = dyn_cast<VAArgInst>(I)) {
// Ignore vaargs on local memory.
AliasAnalysis::Location Loc = AA->getLocation(VI);
if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
continue;
}
// Any remaining instructions need to be taken seriously! Check if they
// read or write memory.
if (I->mayWriteToMemory())
// Writes memory. Just give up.
return false;
// If this instruction may read memory, remember that.
ReadsMemory |= I->mayReadFromMemory();
}
}
// Success! Functions in this SCC do not access memory, or only read memory.
// Give them the appropriate attribute.
bool MadeChange = false;
for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
Function *F = (*I)->getFunction();
if (F->doesNotAccessMemory())
// Already perfect!
continue;
if (F->onlyReadsMemory() && ReadsMemory)
// No change.
continue;
MadeChange = true;
// Clear out any existing attributes.
AttrBuilder B;
B.addAttribute(Attribute::ReadOnly)
.addAttribute(Attribute::ReadNone);
F->removeAttribute(AttributeSet::FunctionIndex,
Attribute::get(F->getContext(), B));
// Add in the new attribute.
B.clear();
B.addAttribute(ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone);
F->addAttribute(AttributeSet::FunctionIndex,
Attribute::get(F->getContext(), B));
if (ReadsMemory)
++NumReadOnly;
else
++NumReadNone;
}
return MadeChange;
}