CompCert icon indicating copy to clipboard operation
CompCert copied to clipboard

Add explicit tail calls to Clight and C#minor

Open xavierleroy opened this issue 4 years ago • 5 comments

By popular demand.

The tail call optimization pass performed later in CompCert will not turn a call into a tail call if the function has stack-allocated data, because this might change the semantics.

Having an explicit Stailcall form in Clight makes it possible to force a call in tail position to be a tail call, deallocating stack-allocated data before the call. This is the same reason why we have an Stailcall form in Cminor already.

Cc: @andrew-appel

xavierleroy avatar Nov 12 '21 15:11 xavierleroy

I would have thought that ExportClight.ml would also need to be edited, but I don't see that in the list of "files changed."

andrew-appel avatar Nov 18 '21 15:11 andrew-appel

My mistake. Will fix soon.

xavierleroy avatar Nov 18 '21 15:11 xavierleroy

Tentative fix pushed.

xavierleroy avatar Nov 18 '21 16:11 xavierleroy

Ping! Does this PR address the need?

xavierleroy avatar Jan 10 '22 17:01 xavierleroy

Yes, I'm pretty sure it does. I don't have time to test it this month. I recommend merge the P.R. Thank you.

andrew-appel avatar Jan 10 '22 17:01 andrew-appel