1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[StackSafety,NFC] Fix use of CallBase API

Code does not need iterate arguments and can get ArgNo from
CallBase::getArgOperandNo.
This commit is contained in:
Vitaly Buka 2020-06-11 13:47:50 -07:00
parent fd252374a0
commit 22a79315a8

View File

@ -327,8 +327,6 @@ bool StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
case Instruction::Call:
case Instruction::Invoke: {
const auto &CB = cast<CallBase>(*I);
if (I->isLifetimeStartOrEnd())
break;
@ -337,6 +335,12 @@ bool StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
break;
}
const auto &CB = cast<CallBase>(*I);
if (!CB.isArgOperand(&UI)) {
US.updateRange(UnknownRange);
return false;
}
// FIXME: consult devirt?
// Do not follow aliases, otherwise we could inadvertently follow
// dso_preemptable aliases or aliases with interposable linkage.
@ -348,19 +352,8 @@ bool StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr,
}
assert(isa<Function>(Callee) || isa<GlobalAlias>(Callee));
int Found = 0;
for (size_t ArgNo = 0; ArgNo < CB.getNumArgOperands(); ++ArgNo) {
if (CB.getArgOperand(ArgNo) == V) {
++Found;
US.Calls.emplace_back(Callee, ArgNo, offsetFrom(UI, Ptr));
}
}
if (!Found) {
US.updateRange(UnknownRange);
return false;
}
US.Calls.emplace_back(Callee, CB.getArgOperandNo(&UI),
offsetFrom(UI, Ptr));
break;
}