[PATCH] D45308: [IPRA] Do not collect register usage information on functions that can be derefined

Vivek Pandya via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 3 22:16:02 PDT 2018


vivekvpandya added a comment.

In https://reviews.llvm.org/D45308#1145575, @kbarton wrote:

> @vivekvpandya You're right - the change will allow noCSROpt to run on functions with external linkage, which is not correct.
>  I think what we really want here is the isSafeForNoCSROpt to check for the existing conditions (i.e., prior to this patch, when it looks for local linkage) and also whether IPRA was successful for this function. I added the isDefinitionExact() call, to try and replicate the necessary conditions for IPRA, but now I'm wondering if it would be better to query the PRUI and make sure it contains a valid RegMask for the given function. Does this seem reasonable to you?


It should work but I think we can discuss properly if you update this patch as per your expectation. 
I assume that you will return early in RegUsageInfoCollector::runOnMachineFunction() if definition is not exact. So we don't have regmask in PRUI for given function.
Now while inserting prologue/epilogue along with isSafeForNoCSROpt() you would like to check if due to above mention condition no regmask is present in PRUI for given function?

Also I realised a potential optimization problem with return early in RegUsageInfoCollector::runOnMachineFunction() for any function without inserting a regmask (even default given as per calling convention for function). 
For example there is call sequence like A->B 
now as per calling convention for B  https://reviews.llvm.org/diffusion/L/, https://reviews.llvm.org/source/clang-tools-extra/, https://reviews.llvm.org/source/clang/ are not callee saved, but RegUsageInfoCollector detects that it only uses https://reviews.llvm.org/diffusion/L/, https://reviews.llvm.org/source/clang-tools-extra/ so on TOT version every function will have regmask in PRUI so that RegUsageInforPropogate() can use this data in caller function. In this case A can use the fact that https://reviews.llvm.org/source/clang/ is free to be used. Now with early return due to any condition will make A use default calling convention for B i.e https://reviews.llvm.org/source/clang/ should not be used without spill/restore around call site of B.


https://reviews.llvm.org/D45308





More information about the llvm-commits mailing list