This is an archive of the discontinued LLVM Phabricator instance.

[X86] add dwarf information for loop stack probe
ClosedPublic

Authored by erikdesjardins on Jan 4 2022, 2:26 PM.

Details

Summary

This patch is based on https://reviews.llvm.org/D99585.

While inside the stack probing loop, temporarily change the CFA
to be based on r11/eax, which are already used to hold the loop bound.
The stack pointer cannot be used for CFI here as it changes during the loop,
so it does not have a constant offset to the CFA.

Co-authored-by: YangKeao <keao.yang@yahoo.com>

Diff Detail

Event Timeline

erikdesjardins created this revision.Jan 4 2022, 2:26 PM
erikdesjardins requested review of this revision.Jan 4 2022, 2:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 4 2022, 2:26 PM
erikdesjardins edited the summary of this revision. (Show Details)

improve description

pengfei added inline comments.Jan 5 2022, 1:23 AM
llvm/lib/Target/X86/X86FrameLowering.cpp
698–699

alignDown(Offset, StackProbeSize)

use alignDown

LGTM, but I'm not expert on dwarf directives. I'd like others to sign off.

nagisa added a comment.Jan 6 2022, 3:37 AM

LGTM after the code change is applied.

llvm/lib/Target/X86/X86FrameLowering.cpp
715–720
llvm/test/CodeGen/X86/stack-clash-large.ll
20–21

In theory this could also be .cfi_def_cfa %rsp, 71888 but seems like it may be non-trivial to make it happen.

add test demonstrating adjust

llvm/lib/Target/X86/X86FrameLowering.cpp
715–720

It's necessary to use adjust instead of def in case there are any CFA offset changes earlier in the prologue, i.e. due to push. Added a test demonstrating this.

It would surely be possible to pass down the current CFA offset through TargetFrameLowering::inlineStackProbe, allowing us to use def here, but I think it's likely nontrivial for the same reason your other comment is nontrivial.

llvm/test/CodeGen/X86/stack-clash-large.ll
20–21

Yep, I had the same thought and came to the same conclusion.

nagisa accepted this revision.Jan 6 2022, 5:16 PM
This revision is now accepted and ready to land.Jan 6 2022, 5:16 PM

Please commit this on my behalf: Erik Desjardins <erikdesjardinspublic@gmail.com>

This revision was landed with ongoing or failed builds.Jan 6 2022, 11:43 PM
This revision was automatically updated to reflect the committed changes.