Tuning CSRCost for shrink-wrapping

Hi,

I often observed missing shrink-wrapping opportunities. For example, when compiling below C code with -O3 for AArach64, I saw that Clang placed the spills of CSRs in the entry block, while GCC shrink-wrapped the spills of CSRs from the entry block.

int getI(int i);

int foo(int *P, int i) {
   if (i>0)
     return P[i];

   i = getI(i);
   return P[i];
}

I believe this is because the current CSRCost fixed in RegAllocGreedy is too conservative. In most cases we allocate a CSR rather than splitting ranges when the live range is across a call. In https://reviews.llvm.org/D34608, I tried to increase the CSRCost to defer the allocation of CSR with the hope of more shrink-wrapping. However, I'm not convinced it's really right approach to handle the problem. If you have any thoughts on this issue, I would love to hear your feedback.

Thanks,
Jun