This is an archive of the discontinued LLVM Phabricator instance.

[X86] add dwarf information for loop stack probe
AbandonedPublic

Authored by YangKeao on Mar 30 2021, 6:02 AM.

Details

Summary

This patch only contains the implementation for 64-bit
architecture. Because r11d cannot be used in 32-bit
architecture and I don't know why (and in which step)
the r11d register is rewritten to work on 32-bit 😢, but it
doesn't cover dwarf annotation.

As discussed in D98789, we cannot find a register unconditionally
safe in 32-bit, so I left this problem for further discussion.
nagisa's D98999 is an attemption to solve this problem.

Signed-off-by: YangKeao <keao.yang@yahoo.com>

Diff Detail

Event Timeline

YangKeao created this revision.Mar 30 2021, 6:02 AM
YangKeao requested review of this revision.Mar 30 2021, 6:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2021, 6:02 AM

@nagisa This is another part of D98789, and is only implemented for 64-bit platform.

Better to rebase it since many changes had committed with D99579.

YangKeao updated this revision to Diff 339320.Apr 21 2021, 10:57 AM

rebase origin/main

Better to rebase it since many changes had committed with D99579.

Done. A fast rebase without changing anything 🍻

Please correct me if I'm wrong. I realize that generating a DWARF message based on r11d doesn't help the unwinder to get a correct backtrace.

In most case, the unwinder got an RIP register, parse the .eh_frames table and use it to find the address of "return address". The pointer to the "return address" (called ax1) is usually "CFA - 8" and by dereferencing it, we can get a parent IP address (usually is 5 bytes more than the call instruction location). Then it uses the parent IP as the new RIP address and find the representation of the new pointer to the return address, which could also be "CFA - 8". The problem is that if "CFA" is calculated through r11, the unwinder will have no chance to know what r11 is at that RIP. But the unwinder could know the rsp at that RIP, because the RSP is ax1 - 8.

Oops. Sorry, it doesn't matter. The stack probing part will never be a parent frame of anything, so it would still be nice as it's the first frame to unwind. This patch is still good 🍻 .

YangKeao added a comment.EditedApr 26 2021, 7:49 AM

Does anyone know why the unit test failed?

Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 5:51 AM
Herald added a subscriber: StephenFan. · View Herald Transcript