mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
tidy up
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112643 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f2db5b48d0
commit
b5d84d13bc
@ -278,22 +278,22 @@ static Value *getCommonReturnValue(ReturnInst *IgnoreRI, CallInst *CI) {
|
|||||||
Function *F = CI->getParent()->getParent();
|
Function *F = CI->getParent()->getParent();
|
||||||
Value *ReturnedValue = 0;
|
Value *ReturnedValue = 0;
|
||||||
|
|
||||||
for (Function::iterator BBI = F->begin(), E = F->end(); BBI != E; ++BBI)
|
for (Function::iterator BBI = F->begin(), E = F->end(); BBI != E; ++BBI) {
|
||||||
if (ReturnInst *RI = dyn_cast<ReturnInst>(BBI->getTerminator()))
|
ReturnInst *RI = dyn_cast<ReturnInst>(BBI->getTerminator());
|
||||||
if (RI != IgnoreRI) {
|
if (RI == 0 || RI == IgnoreRI) continue;
|
||||||
Value *RetOp = RI->getOperand(0);
|
|
||||||
|
|
||||||
// We can only perform this transformation if the value returned is
|
// We can only perform this transformation if the value returned is
|
||||||
// evaluatable at the start of the initial invocation of the function,
|
// evaluatable at the start of the initial invocation of the function,
|
||||||
// instead of at the end of the evaluation.
|
// instead of at the end of the evaluation.
|
||||||
//
|
//
|
||||||
if (!isDynamicConstant(RetOp, CI, RI))
|
Value *RetOp = RI->getOperand(0);
|
||||||
return 0;
|
if (!isDynamicConstant(RetOp, CI, RI))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (ReturnedValue && RetOp != ReturnedValue)
|
if (ReturnedValue && RetOp != ReturnedValue)
|
||||||
return 0; // Cannot transform if differing values are returned.
|
return 0; // Cannot transform if differing values are returned.
|
||||||
ReturnedValue = RetOp;
|
ReturnedValue = RetOp;
|
||||||
}
|
}
|
||||||
return ReturnedValue;
|
return ReturnedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ Value *TailCallElim::CanTransformAccumulatorRecursion(Instruction *I,
|
|||||||
assert(I->getNumOperands() == 2 &&
|
assert(I->getNumOperands() == 2 &&
|
||||||
"Associative/commutative operations should have 2 args!");
|
"Associative/commutative operations should have 2 args!");
|
||||||
|
|
||||||
// Exactly one operand should be the result of the call instruction...
|
// Exactly one operand should be the result of the call instruction.
|
||||||
if ((I->getOperand(0) == CI && I->getOperand(1) == CI) ||
|
if ((I->getOperand(0) == CI && I->getOperand(1) == CI) ||
|
||||||
(I->getOperand(0) != CI && I->getOperand(1) != CI))
|
(I->getOperand(0) != CI && I->getOperand(1) != CI))
|
||||||
return 0;
|
return 0;
|
||||||
@ -387,21 +387,22 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry,
|
|||||||
// tail call if all of the instructions between the call and the return are
|
// tail call if all of the instructions between the call and the return are
|
||||||
// movable to above the call itself, leaving the call next to the return.
|
// movable to above the call itself, leaving the call next to the return.
|
||||||
// Check that this is the case now.
|
// Check that this is the case now.
|
||||||
for (BBI = CI, ++BBI; &*BBI != Ret; ++BBI)
|
for (BBI = CI, ++BBI; &*BBI != Ret; ++BBI) {
|
||||||
if (!CanMoveAboveCall(BBI, CI)) {
|
if (CanMoveAboveCall(BBI, CI)) continue;
|
||||||
// If we can't move the instruction above the call, it might be because it
|
|
||||||
// is an associative and commutative operation that could be tranformed
|
// If we can't move the instruction above the call, it might be because it
|
||||||
// using accumulator recursion elimination. Check to see if this is the
|
// is an associative and commutative operation that could be tranformed
|
||||||
// case, and if so, remember the initial accumulator value for later.
|
// using accumulator recursion elimination. Check to see if this is the
|
||||||
if ((AccumulatorRecursionEliminationInitVal =
|
// case, and if so, remember the initial accumulator value for later.
|
||||||
CanTransformAccumulatorRecursion(BBI, CI))) {
|
if ((AccumulatorRecursionEliminationInitVal =
|
||||||
// Yes, this is accumulator recursion. Remember which instruction
|
CanTransformAccumulatorRecursion(BBI, CI))) {
|
||||||
// accumulates.
|
// Yes, this is accumulator recursion. Remember which instruction
|
||||||
AccumulatorRecursionInstr = BBI;
|
// accumulates.
|
||||||
} else {
|
AccumulatorRecursionInstr = BBI;
|
||||||
return false; // Otherwise, we cannot eliminate the tail recursion!
|
} else {
|
||||||
}
|
return false; // Otherwise, we cannot eliminate the tail recursion!
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We can only transform call/return pairs that either ignore the return value
|
// We can only transform call/return pairs that either ignore the return value
|
||||||
// of the call and return void, ignore the value of the call and return a
|
// of the call and return void, ignore the value of the call and return a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user