tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] manually inlining functions


From: Michael Matz
Subject: Re: [Tinycc-devel] manually inlining functions
Date: Fri, 7 May 2021 17:15:14 +0200 (CEST)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,

On Tue, 4 May 2021, uso ewin wrote:

Tinycc handle inline function like if they were macro, so using inline
in tcc always inline functions.

That's not accurate. Inline functions in TCC are emitted like normal functions but only when there's reason to emit them (which are involved and depend on if they are called (or address-taken) or if they are c99 inline or gnu inline semantics, and static or global). But they are _not_ emitted like macros at every use, rather a normal argument setup and call is done, and the body is emitted only once as a normal function.

Either way, the discussion about speed of inline functions in TCC is fairly academic, code performance is low for many other, more important, reasons. There is no optimizer, there is no intermediate representation that could be optimized, there is nothing that could benefit from inlining except the call instruction and the prologue/epilogue itself would be removed.

Not even the argument setup would be saved very often: TCCs compilation model would require evaluating the arguments to local temporaries which are often spilled to stack right soon, in the end needing exactly the same work as the argument setup for a call.

I somewhen wrote a simple function inliner for tcc handling most normal cases (those when the inline doesn't contain a local static variable, and when no variadic args are used), but the result was somewhat so-and-so, there simply wasn't much point to having it before having a better single-pass optimizer / register allocator.


Ciao,
Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]