On 7/16/24 12:05 PM, Iain Sandoe wrote:
Hi Jason,

On 15 Jul 2024, at 23:29, Jason Merrill <ja...@redhat.com> wrote:
On 7/12/24 1:03 PM, Iain Sandoe wrote:

-   More helpful for optimization might be to make the contracts a wrapper
-   function (for non-variadic functions), that could be inlined into a
-   caller while preserving the call to the actual function?  Either that or
-   mirror a never-continue post contract with an assume in the caller.  */

Much the old documentation about outlining conditions still seems relevant.  In 
particular I'd keep something like

"FIXME outlining contract checks into separate functions was motivated partly 
by wanting to call the postcondition function at each return statement, which we no 
longer do; at this point outlining doesn't seem to have any advantage over emitting 
the contracts directly in the function body.

More helpful for optimization might be to make the contracts a wrapper function that 
could be inlined into the caller, the callee, or both."

Nina is about to start looking into the implementation of caller-side contracts 
(at least in so far as it relates to the current virtual functions proposal) .. 
so I will work with her to implement this.

My expectation is that the callee side can be updated to do the work inline, we 
can then drop the special handling for cdtors.

Caller-side seems likely to need a wrapper thunk that then calls the original 
fn.

(but we did not get into the details yet, those are just initial thoughts).

I had been thinking that for non-virtual functions it could be two of the same wrapper, but as discussed on the list that would involve ABI complexities, so indeed probably simpler for callee to handle them directly.

Jason

Reply via email to