[PATCH] D30324: [ARM] Thumb2: favor R4-R7 over R12/LR in allocation order when opt for minsize

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 12:47:46 PST 2017


qcolombet added inline comments.


================
Comment at: lib/CodeGen/RegisterClassInfo.cpp:129
 
+  if (TRI->costPerUseOverridesCSR(*MF)) {
+    // If cost per use outweights CSR in deciding allocation order, we reorder
----------------
weimingz wrote:
> rengolin wrote:
> > I'm not very knowledgeable in this part of the code, but it seems you're destroying everything the above code was trying to do with the RCI order. It looks to me as though you should try to add the logic into the loop above, rather than splitting and discarding.
> The code will maintain the original order if two registers have the same priority by using stable_sort: one register has lower CostPerUse, it has higher priority. Otherwise,  the caller saved register have higher priority. Everything equal, the original order is kept.
Renato is right, you're doing more that changing the order of the CSRs.
Although this is probably not used in-tree, there is nothing that prevents to set a different cost for each register. Thus a stable sort on the cost per use may give a very different order than the raw order.

For instance, the raw order could well be in terms of cost per use {10, 8, 3, 12, etc.}.

Instead, what I would suggest is:
- Define an alternative order for MF
- Add a callback just to disable the special case for CSR, i.e., the callback you have works, just use it inside the loop not to populate the CSRAlias


Repository:
  rL LLVM

https://reviews.llvm.org/D30324





More information about the llvm-commits mailing list