Is there any way to manipulate the IR tree after f...
# compiler
j
Is there any way to manipulate the IR tree after function inlining has happened?
i
Hi! Not really (or at least I don't know any). Can you please describe what you want to achieve? A little bit of additional info. We actually have 2 kind of inliners in Kotlin. The first one for JVM and it works by inlining bytecode. The second one for Klib backends (JS, WASM, Native) and here we indeed inline IR. Right now, inside Klibs, we are storing non-inlined call sites of inline functions. But it will be changed soon and the compiler will do the inlining process before serialisation. See this ticket for details.
j
The Compose runtime's
remember { }
function is
inline
, and its body contains unnecessary function calls that are used solely for debugging. I would like to remove them in our release builds. I was already told there is no way to manipulate the entire IR tree of my transitive dependency graph during linking (https://kotlinlang.slack.com/archives/C7L3JB43G/p1739217898811039), so I'm looking at alternatives. I was hoping a compiler plugin that I apply to every module would get me 99% of the way there, but since I don't see the inlined IR, I cannot actually remove them from anywhere.
m
Maybe you can replace remember calls with the body yourself in IR. Or provide your own runtime remember function with your Logic and change each call to the remember function of your runtime?