This is an archive of the discontinued LLVM Phabricator instance.

Improve stack-clash implementation on x86
ClosedPublic

Authored by serge-sans-paille on May 6 2020, 4:49 AM.

Details

Summary
  • test both 32 and 64 bit version
  • probe the tail in dynamic-alloca
  • generate more concise code

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2020, 4:49 AM
jonpa added a comment.May 6 2020, 5:02 AM

This LGTM, but I would prefer if someone else working on X86 also gave an approval.

Rework and improve the patch:

  • more documentation
  • more assert
  • slight update of the way static alloca are probed, leads to slightly smaller code
  • completely rework the way dynamic alloca are probed, which leads to smaller and cleaner assembly. As a side effect it also probes the tail.
craig.topper added inline comments.May 15 2020, 9:12 AM
llvm/lib/Target/X86/X86FrameLowering.cpp
715

This can't be MOV64rr for 32-bit. Can we use TargetOpcode::COPY?

llvm/lib/Target/X86/X86ISelLowering.cpp
31580

use Register instead of unsigned.

31587

This shouldn't be MOV64rr if the stack pointer is 32 bits. Can we just use TargetOpcode::COPY here?

Take remarks into account

serge-sans-paille marked 3 inline comments as done.May 15 2020, 1:12 PM

Can we have tests for 32-bit mode too? Which I hope would have caught those previous issues.

llvm/lib/Target/X86/X86FrameLowering.cpp
663

Register

serge-sans-paille retitled this revision from Fix stack clash probing on the tail of dynamic allocation to Improve stack-clash implementation on x86.
serge-sans-paille edited the summary of this revision. (Show Details)
serge-sans-paille marked an inline comment as done.

@craig.topper test cases for 32bit target added!

This revision is now accepted and ready to land.May 25 2020, 1:12 AM
lkail added a subscriber: lkail.May 25 2020, 5:47 AM
lkail removed a subscriber: lkail.
This revision was automatically updated to reflect the committed changes.