[llvm-dev] Less aggressive on the first allocation of CSR if detecting an early exit
Jun Lim via llvm-dev
llvm-dev at lists.llvm.org
Fri Oct 27 13:32:46 PDT 2017
When compiling C code below for AArach64, I saw that shrink-wrapping didn't
happen due to the very early uses of CSRs in the entry block. So CSR
spills/reloads are executed even when the early exit block is taken.
int getI(int i);
int foo(int *P, int i) {
if (i>0)
return P[i];
i = getI(i);
return P[i];
}
It's not that hard to find such cases where RegAllocGreedy aggressively
allocates a CSRs when a live range expands across a call-site. That's
because of the conservatively initialized CSRCost, causing RegAllocGreedy to
strongly favour allocating a CSR over splitting a region. Since allocation
of CSRs requires the cost of spilling CSRs, allocating CSRs is not always
beneficial. Like the case above, if a function has an early exit code, we
may want to be less aggressive on the first allocation of CSR in the entry
block by increasing the CSRCost.
Previously, I proposed https://reviews.llvm.org/D34608 in this matter, but
the way I detect the profitable cases and the way I increase the CRSCost was
somewhat unclear. Now, I'm thinking to less aggressive on the first
allocation of CSR in the entry block in case where the function has an early
exit so that encourage more shrink-wrapping and avoid executing CSR
spill/recover when the early exit is taken. By sending this out, I just want
to get any high level feedback early. Please let me know if anyone has any
opinion about this.
Thanks,
Jun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171027/63368b72/attachment-0001.html>
More information about the llvm-dev
mailing list