This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Mark condition flags as clobbered when calling __chkstk
ClosedPublic

Authored by mstorsjo on Oct 30 2018, 11:08 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Oct 30 2018, 11:08 AM

Missing implicit-def of r16/r17?

On a sort-of-related note, I'm confused about the difference between small/large code model; doesn't the AArch64 linker support range-extension thunks? (This is related because range-extension thunks can clobber r16/r17.)

Missing implicit-def of r16/r17?

For both cases, or just the first one? (The other one has got .addReg(AArch64::X16, RegState::Kill) already. Would that be .addReg(AArch64::X16, RegState::Implicit | RegState::Define) for both X16 and X17 there? I can't say I really understand what all these flags mean.

On a sort-of-related note, I'm confused about the difference between small/large code model; doesn't the AArch64 linker support range-extension thunks? (This is related because range-extension thunks can clobber r16/r17.)

I guess AArch64 COFF linkers in general could support range extension thunks, although I don't know if link.exe does - lld doesn't at least. The __chkstk function itself also clobbers both X16 and X17, so they definitely should be considered clobbered here. (Not that I know what really would assume these registers to have any sensible value here, as this is emitted in the prologue of a function.)

For both cases; the "blr x16" both uses and clobbers x16, so it needs two operands to represent that. .addReg(AArch64::X16, RegState::Implicit | RegState::Define | RegState::Dead) is correct (just like you used for NZCV).

"RegState::Define" means it's a definition, rather than a use. RegState::Implicit means that it's not one of the explicit inputs or outputs listed in the instruction description. RegState::Dead and RegState::Kill are optimization hints; a dead definition is never used, and a "kill" use is the last use of a definition.

(Not that I know what really would assume these registers to have any sensible value here, as this is emitted in the prologue of a function.)

In theory, if unwind tables are disabled, some code after the prologue could get rescheduled into the prologue.

I guess AArch64 COFF linkers in general could support range extension thunks, although I don't know if link.exe does - lld doesn't at least.

I would be surprised if link.exe doesn't support it, given it supports the equivalent for 32-bit ARM.

For both cases; the "blr x16" both uses and clobbers x16, so it needs two operands to represent that. .addReg(AArch64::X16, RegState::Implicit | RegState::Define | RegState::Dead) is correct (just like you used for NZCV).

"RegState::Define" means it's a definition, rather than a use. RegState::Implicit means that it's not one of the explicit inputs or outputs listed in the instruction description. RegState::Dead and RegState::Kill are optimization hints; a dead definition is never used, and a "kill" use is the last use of a definition.

Ok, thanks!

(Not that I know what really would assume these registers to have any sensible value here, as this is emitted in the prologue of a function.)

In theory, if unwind tables are disabled, some code after the prologue could get rescheduled into the prologue.

Oh, ok.

mstorsjo updated this revision to Diff 171783.Oct 30 2018, 1:48 PM
mstorsjo edited the summary of this revision. (Show Details)

Marking x16/x17 as clobbered as well, extended the test to both variants.

This revision is now accepted and ready to land.Oct 30 2018, 2:54 PM
This revision was automatically updated to reflect the committed changes.