本文整理汇总了C++中Argument::uses方法的典型用法代码示例。如果您正苦于以下问题:C++ Argument::uses方法的具体用法?C++ Argument::uses怎么用?C++ Argument::uses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Argument
的用法示例。
在下文中一共展示了Argument::uses方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool CallingConvention_x86_64_systemv::analyzeFunction(ParameterRegistry ®istry, CallInformation &callInfo, Function &function)
{
// TODO: Look at called functions to find hidden parameters/return values
if (md::isPrototype(function))
{
return false;
}
TargetInfo& targetInfo = registry.getTargetInfo();
// We always need rip and rsp.
callInfo.addParameter(ValueInformation::IntegerRegister, targetInfo.registerNamed("rip"));
callInfo.addParameter(ValueInformation::IntegerRegister, targetInfo.registerNamed("rsp"));
// Identify register GEPs.
// (assume x86 regs as first parameter)
assert(function.arg_size() == 1);
Argument* regs = function.arg_begin();
auto pointerType = dyn_cast<PointerType>(regs->getType());
assert(pointerType != nullptr && pointerType->getTypeAtIndex(int(0))->getStructName() == "struct.x86_regs");
unordered_multimap<const TargetRegisterInfo*, GetElementPtrInst*> geps;
for (auto& use : regs->uses())
{
if (GetElementPtrInst* gep = dyn_cast<GetElementPtrInst>(use.getUser()))
if (const TargetRegisterInfo* regName = targetInfo.registerInfo(*gep))
{
geps.insert({regName, gep});
}
}
// Look at temporary registers that are read before they are written
MemorySSA& mssa = *registry.getMemorySSA(function);
for (const char* name : parameterRegisters)
{
const TargetRegisterInfo* smallReg = targetInfo.registerNamed(name);
const TargetRegisterInfo* regInfo = targetInfo.largestOverlappingRegister(*smallReg);
auto range = geps.equal_range(regInfo);
vector<Instruction*> addresses;
for (auto iter = range.first; iter != range.second; ++iter)
{
addresses.push_back(iter->second);
}
for (size_t i = 0; i < addresses.size(); ++i)
{
Instruction* addressInst = addresses[i];
for (auto& use : addressInst->uses())
{
if (auto load = dyn_cast<LoadInst>(use.getUser()))
{
MemoryAccess* parent = mssa.getMemoryAccess(load)->getDefiningAccess();
if (mssa.isLiveOnEntryDef(parent))
{
// register argument!
callInfo.addParameter(ValueInformation::IntegerRegister, regInfo);
}
}
else if (auto cast = dyn_cast<CastInst>(use.getUser()))
{
if (cast->getType()->isPointerTy())
{
addresses.push_back(cast);
}
}
}
}
}
// Does the function refer to values at an offset above the initial rsp value?
// Assume that rsp is known to be preserved.
auto spRange = geps.equal_range(targetInfo.getStackPointer());
for (auto iter = spRange.first; iter != spRange.second; ++iter)
{
auto* gep = iter->second;
// Find all uses of reference to sp register
for (auto& use : gep->uses())
{
if (auto load = dyn_cast<LoadInst>(use.getUser()))
{
// Find uses above +8 (since +0 is the return address)
for (auto& use : load->uses())
{
ConstantInt* offset = nullptr;
if (match(use.get(), m_Add(m_Value(), m_ConstantInt(offset))))
{
make_signed<decltype(offset->getLimitedValue())>::type intOffset = offset->getLimitedValue();
if (intOffset > 8)
{
// memory argument!
callInfo.addParameter(ValueInformation::Stack, intOffset);
}
}
}
}
}
}
//.........这里部分代码省略.........