This is an archive of the discontinued LLVM Phabricator instance.

Test and document stackmap corner case: when the frame size isn't statically known
ClosedPublic

Authored by vext01 on Jun 24 2022, 6:48 AM.

Details

Summary

When a function does a dynamic stack allocation, is it impossible to know the size of the stack statically. If such a function uses stackmaps, then the stack size field is populated with UINT64_MAX to indicate this, however this is not tested or documented.

This change tests and documents this case.

Brought to my attention by @ptersilie , thanks.

Diff Detail

Event Timeline

vext01 created this revision.Jun 24 2022, 6:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 6:48 AM
Herald added subscribers: jsji, pengfei. · View Herald Transcript
vext01 requested review of this revision.Jun 24 2022, 6:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 6:48 AM
vext01 retitled this revision from Test and document stackmap corner case: when the fram size isn't statically known to Test and document stackmap corner case: when the frame size isn't statically known.Jun 24 2022, 6:49 AM
arsenm added inline comments.Jun 24 2022, 6:52 AM
llvm/test/CodeGen/AArch64/stackmap-dynamic-alloca.ll
26

I'm surprised this isn't eliminated as dead

vext01 updated this revision to Diff 439735.Jun 24 2022, 7:09 AM

I think the reason the alloca isn't optimised out is that:

stackmap and patchpoint intrinsics are considered to potentially read and write all memory

https://llvm.org/docs/StackMaps.html#id12

But to be doubly sure it can't be optimised out, in this revised diff I've made use of the value returned by alloca.

Looks good?

arsenm added inline comments.Jun 24 2022, 8:31 AM
llvm/test/CodeGen/SystemZ/stackmap-dynamic-alloca.ll
28

This is undefined behavior. The argument use is good enough

vext01 updated this revision to Diff 439786.Jun 24 2022, 8:49 AM

Removed UB.

arsenm accepted this revision.Jun 24 2022, 9:10 AM
This revision is now accepted and ready to land.Jun 24 2022, 9:10 AM
This revision was landed with ongoing or failed builds.Jun 27 2022, 3:58 AM
This revision was automatically updated to reflect the committed changes.