forked from OSchip/llvm-project
[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:
parent
27f8bd94cb
commit
a10fc165f5
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue