[clang] [llvm] [clang/LLVM] Add flatten_deep attribute for depth-limited inlining (1/2) (PR #165777)

Aiden Grossman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 31 13:03:57 PDT 2025


boomanaiden154 wrote:

> Can you please elaborate what do you mean by it "changes the semantics of alwaysinline"? I am introducing a new attribute flatten_deep both on clang side and LLVM side. alwaysinline should still mean the same thing.

You said patch 2 will update the alwaysinliner pass. `alwaysinline` has previously always inlined a function unless it was illegal to do so. You're now maybe not inlining depending on the `flatten_deep` attribute, which seems like a cost heuristic encoded in the IR to me.

> To clarify, our primary use case at Meta is to completely flatten functions by inlining the entire call tree. The max depth parameter is not intended as a core part of the user workflow, but rather as a safeguard to prevent issues if the call tree happens to be extremely deep.

So you want to completely flatten functions but not completely flatten functions? What exactly is the use case of flattening these functions?

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


More information about the cfe-commits mailing list