[llvm] [ArgPromotion] Infer parameter attributes on functions (PR #110245)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 08:45:22 PDT 2024


hazzlim wrote:

> > This improves precision of alias analysis using the actual arguments of calling functions in cases where these attributes have not already been inferred.
> 
> I think this needs a PhaseOrdering test that shows why this is needed. I checked, and we run PostOrderFunctionAttrsPass before ArgumentPromotionPass. It's run in SkipNonRecursive mode, but the one thing that _does_ get inferred in that mode is actually nocapture and readonly/etc. As such, it's not super clear to me why we need to redo this inference in ArgPromotion.

Thank you for taking a look at this patch @nikic. The context for this is that we are looking into running ArgumentPromotion before IPSCCP in the LTO pipeline. This is to handle the case that is fairly common in Fortran codegen, where literal constants passed as arguments become allocas passed as pointers (because arguments are all passed by reference) and so IPSCCP fails to propagate these at present.

This change (and #110248) were intended to enable such promoted arguments to then be propagated by IPSCCP without also needing to run PostOrderFunctionAttrsPass and SROA before IPSCCP. Perhaps you have some thoughts on what might be a better approach here?

https://github.com/llvm/llvm-project/pull/110245


More information about the llvm-commits mailing list