本文整理汇总了C++中llvm::Function::arg_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Function::arg_begin方法的具体用法?C++ Function::arg_begin怎么用?C++ Function::arg_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::Function
的用法示例。
在下文中一共展示了Function::arg_begin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeFunction
bool CallingConvention_AnyArch_AnyCC::analyzeFunction(ParameterRegistry ®istry, CallInformation &fillOut, llvm::Function &func)
{
if (!isFullDisassembly() || md::isPrototype(func))
{
return false;
}
auto regs = &*func.arg_begin();
unordered_map<const TargetRegisterInfo*, ModRefInfo> resultMap;
// Find all GEPs
const auto& target = registry.getTargetInfo();
unordered_multimap<const TargetRegisterInfo*, User*> registerUsers;
for (User* user : regs->users())
{
if (const TargetRegisterInfo* maybeRegister = target.registerInfo(*user))
{
const TargetRegisterInfo& registerInfo = target.largestOverlappingRegister(*maybeRegister);
registerUsers.insert({®isterInfo, user});
}
}
// Find all users of these GEPs
DominatorsPerRegister gepUsers;
for (auto iter = registerUsers.begin(); iter != registerUsers.end(); iter++)
{
addAllUsers(*iter->second, iter->first, gepUsers);
}
DominatorTree& preDom = registry.getAnalysis<DominatorTreeWrapperPass>(func).getDomTree();
PostDominatorTree& postDom = registry.getAnalysis<PostDominatorTreeWrapperPass>(func).getPostDomTree();
// Add calls
SmallVector<CallInst*, 8> calls;
CallGraph& cg = registry.getAnalysis<CallGraphWrapperPass>().getCallGraph();
CallGraphNode* thisFunc = cg[&func];
for (const auto& pair : *thisFunc)
{
Function* callee = pair.second->getFunction();
if (const CallInformation* callInfo = registry.getCallInfo(*callee))
if (callInfo->getStage() == CallInformation::Completed)
{
// pair.first is a weak value handle and has a cast operator to get the pointee
CallInst* caller = cast<CallInst>((Value*)pair.first);
calls.push_back(caller);
for (const auto& vi : *callInfo)
{
if (vi.type == ValueInformation::IntegerRegister)
{
gepUsers[vi.registerInfo].insert(caller);
}
}
}
}
// Start out resultMap based on call dominance. Weed out calls until dominant call set has been established.
// This map will be refined by results from mod/ref instruction analysis. The purpose is mainly to define
// mod/ref behavior for registers that are used in callees of this function, but not in this function
// directly.
while (calls.size() > 0)
{
unordered_map<const TargetRegisterInfo*, unsigned> callResult;
auto dominant = findDominantValues(preDom, calls);
for (CallInst* call : dominant)
{
Function* callee = call->getCalledFunction();
for (const auto& pair : translateToModRef(*registry.getCallInfo(*callee)))
{
callResult[pair.first] |= pair.second;
}
calls.erase(find(calls.begin(), calls.end(), call));
}
for (const auto& pair : callResult)
{
resultMap[pair.first] = static_cast<ModRefInfo>(pair.second);
}
}
// Find the dominant use(s)
auto preDominatingUses = gepUsers;
for (auto& pair : preDominatingUses)
{
pair.second = findDominantValues(preDom, pair.second);
}
// Fill out ModRef use dictionary
// (Ref info is incomplete)
for (auto& pair : preDominatingUses)
{
ModRefInfo& r = resultMap[pair.first];
r = IncompleteRef;
for (auto inst : pair.second)
{
if (isa<StoreInst>(inst))
{
// If we see a dominant store, then the register is modified.
r = MRI_Mod;
//.........这里部分代码省略.........