This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [builtins] Implement __chkstk for arm64 windows
ClosedPublic

Authored by mstorsjo on Dec 12 2017, 2:26 PM.

Diff Detail

Event Timeline

mstorsjo created this revision.Dec 12 2017, 2:26 PM
compnerd added inline comments.Dec 13 2017, 10:50 AM
lib/builtins/aarch64/chkstk.S
14

Im not sure what the point of this check is. This is an AArch64 source so would only be compiled for that target.

mgorny added inline comments.Dec 13 2017, 10:53 AM
lib/builtins/aarch64/chkstk.S
14

We do this in all (most?) of the files for consistency. There were historically cases when tools compiled all files found in the directory — it mostly applies to tests in pre-lit times.

compnerd added inline comments.Dec 14 2017, 5:44 PM
lib/builtins/aarch64/chkstk.S
18

I'm not sure I understand the reasoning for this entirely. Why the lsl x16, x15, #4 and then subs x16, x16, #1000? Wouldn't it be equal to just doing subs x15, x15, #100 each time and entirely avoid the shift?

24

Can we not use PAGE_SIZE here?

mstorsjo added inline comments.Dec 14 2017, 10:13 PM
lib/builtins/aarch64/chkstk.S
18

Yes - except we need to preserve x15 on return as well. So since we need to clobber another register, it doesn't matter which range we use for the subtractions.

24

Afaik there's no global PAGE_SIZE define, but we could make one within this file and use that for better readability.

mstorsjo updated this revision to Diff 127070.Dec 14 2017, 11:37 PM

Added some more comments about what registers are clobbered, using a define for the page size. Removed the assumption that we don't need to touch the final page, to be on the safe side (in case a caller would do two of these calls consecutively without touching the stack inbetween).

compnerd accepted this revision.Dec 19 2017, 2:03 PM

Bah, I forgot that __chkstk is special and the normal preserved/clobbered register set is not the same.

This revision is now accepted and ready to land.Dec 19 2017, 2:03 PM
This revision was automatically updated to reflect the committed changes.
Herald added a subscriber: Restricted Project. · View Herald TranscriptDec 19 2017, 10:53 PM