[llvm-commits] [WinABI patch] Make sure to call __chkstk when appropriate
asl at math.spbu.ru
Wed Aug 18 03:56:13 PDT 2010
> I put it in the same area as the mingw case, for __alloca, so I thought it
> was in the right place.
Hrm... Doesn't seem so. Stuff really should be done inside emitPrologue(),
not within some helper routine.
> You're right it will clobber eax in the 32-bit case, so there'd have to be
> some code added to save/restore it.
emitPrologue() already handles this case for __alloca, no need to code
you'll just have to tune the name there.
> I'll have to take your word that __chkstk is the same as __alloca, but
> reading the documentation on Microsoft's website, it doesn't come across
> that way:
> Allocates memory on the stack. This function is deprecated because a more
> secure version is available; see _malloca.
MS __alloca != mingw32 __alloca
> The __chkstk helper will not modify any registers other than R10, R11, and
> the condition codes. In particular, it will return RAX unchanged and leave
> all nonvolatile registers and argument-passing registers unmodified.
> So, the only registers which are munged, in the 64-bit case, are the
> volatile ones. I assumed that the 32-bit case would be similar.
There is one point
> The reason I didn't add this code to the mingw case is because that path
> never calls emitSPUpdate(): it relys on __alloca to do all the stack
> manipulation. This didn't appear to me that it would be valid, according
> to the Windows ABI.
It definitely does all the stack manipulations, see above. I'm not quite sure
about 64 bit case. I vague recall some discussion on gcc ML, that on 64 bit
__chkstk != __alloca
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
More information about the llvm-commits