[LLVMdev] Calling conventions for YMM registers on AVX

Jakob Stoklund Olesen jolesen at apple.com
Mon Jan 9 15:13:42 PST 2012


On Jan 9, 2012, at 10:00 AM, Jakob Stoklund Olesen wrote:

> 
> On Jan 8, 2012, at 11:18 PM, Demikhovsky, Elena wrote:
> 
>> I'll explain what we see in the code.
>> 1. The caller saves XMM registers across the call if needed (according to DEFS definition).
>> YMMs are not in the set, so caller does not take care.
> 
> This is not how the register allocator works. It saves the registers holding values, it doesn't care which alias is clobbered.
> 
> Are you saying that only the xmm part of a ymm register gets spilled before a call?
> 
>> 2. The callee preserves XMMs but works with YMMs and clobbering them.
>> 3. So after the call, the upper part of YMM is gone.
> 
> Are you on Windows? As Bruno said, all xmm and ymm registers are call-clobbered on non-Windows platforms.

This thread has lots of interesting information: http://software.intel.com/en-us/forums/showthread.php?t=59291

I wasn't able to find a formal Win64 ABI spec, but according to http://www.agner.org/optimize/calling_conventions.pdf, xmm6-xmm15 are callee-saved on win64, but the high bits in ymm6-ymm15 are not.

That's not currently correctly modelled in LLVM. To fix it, create a pseudo-register YMMHI_CLOBBER that aliases ymm6-ymm15. Then add YMMHI_CLOBBER to the registers clobbered by WINCALL64*.

/jakob




More information about the llvm-dev mailing list