[LLVMdev] Improving support for the "Cold" Calling Convention

Will Dietz willdtz at gmail.com
Fri Dec 28 18:03:02 PST 2012

Hi all,

I'm interested in fixing PR14481 (http://llvm.org/PR14481), regarding
teaching LLVM that coldcc functions do not clobber any registers.

As a brief motivation why: this can have a significant performance
benefits and is very useful for instrumenting code with many calls
that are executed only very rarely.  Ubsan's runtime calls are a good
example of this.

Attached is my attempt at fixing this from the caller's perspective
for X86/X86-64.

The patch works for me (review welcome), but there are still some
large pieces missing that I'd appreciate your thoughts and guidance

* How to best implement the other half: generating function
definitions that actually preserve all registers.  Ideally this would
be done in a way that only preserves *clobbered* registers, but
naively saving/restoring all registers regardless would be a good
starting point.

* Changing the behavior of a calling convention will likely break
codes that use it expecting the existing behavior, which presently
seems to be an analysis hint.  Is this something to be concerned
about?  Does anyone know of code that uses coldcc in this manner, or
at all?

* A convention that "preserves all" seems like it could be neatly done
in a target-agnostic manner.  I'm not sure if there is sufficient
interest to justify such a solution, and am unfortunately not
sufficiently familiar with the CodeGen architecture to propose a
solution, but thought I'd mention it.  Might even be easier to tackle
it this way than with the approach taken in the patch :).

Thank you for your time,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-support-for-ColdCC-on-X86-X86-64.patch
Type: application/octet-stream
Size: 3637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121228/771b0f29/attachment.obj>

More information about the llvm-dev mailing list