[clang] [llvm] [clang/LLVM] Add function level flatten_depth attribute for depth-limited inlining (PR #165777)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 11:27:59 PST 2025


mtrofin wrote:

> alwaysinline can't always meet the needs -- it causes a particular function to be inlined into all callers, which is not selective based on calling context. What this does is make inlining happen under a particular call tree, and fully flatten a call tree.
> 
> + at mtrofin hope you can see the merit of the extension -- we have real use case for it in our internal codebase where we don't want any calls for some paths and this is a simple, natural extension for existing flatten attribute.

Sorry, I only saw this now. I second @efriedma-quic 's feedback that a RFC seems appropriate. An aspect that I hope the RFC could cover is whether this could be initially implemented LLVM-side only (e.g. via some manifest file saying which functions should be treated this way) - effectively a gradual introduction.

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


More information about the llvm-commits mailing list