mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 19:42:54 +02:00
use CallSite to access calls vs. invokes uniformly
and remove assumptions about operand order llvm-svn: 100544
This commit is contained in:
parent
81177fa767
commit
a1fcda6242
@ -682,16 +682,17 @@ static bool OptimizeAwayTrappingUsesOfValue(Value *V, Constant *NewV) {
|
|||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
} else if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
|
} else if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
|
||||||
if (I->getOperand(0) == V) {
|
CallSite CS(I);
|
||||||
|
if (CS.getCalledValue() == V) {
|
||||||
// Calling through the pointer! Turn into a direct call, but be careful
|
// Calling through the pointer! Turn into a direct call, but be careful
|
||||||
// that the pointer is not also being passed as an argument.
|
// that the pointer is not also being passed as an argument.
|
||||||
I->setOperand(0, NewV);
|
CS.setCalledFunction(NewV);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
bool PassedAsArg = false;
|
bool PassedAsArg = false;
|
||||||
for (unsigned i = 1, e = I->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = CS.arg_size(); i != e; ++i)
|
||||||
if (I->getOperand(i) == V) {
|
if (CS.getArgument(i) == V) {
|
||||||
PassedAsArg = true;
|
PassedAsArg = true;
|
||||||
I->setOperand(i, NewV);
|
CS.setArgument(i, NewV);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PassedAsArg) {
|
if (PassedAsArg) {
|
||||||
|
Loading…
Reference in New Issue
Block a user