Page MenuHomePhabricator

[X86] add dwarf information for loop stack probe
Needs ReviewPublic

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



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 <>

Diff Detail

Unit TestsFailed

3,180 msx64 debian > libFuzzer.libFuzzer::entropic-scale-per-exec-time.test
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/mnt/disks/ssd0/agent/llvm-project/compiler-rt/lib/fuzzer -m64 /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/fuzzer/EntropicScalePerExecTimeTest.cpp -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/fuzzer/X86_64DefaultLinuxConfig/Output/entropic-scale-per-exec-time.test.tmp-EntropicScalePerExecTimeTest
10 msx64 debian > libomptarget.mapping::declare_mapper_nested_default_mappers_array.cpp
Script: -- : 'RUN: at line 1'; echo ignored-command

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.Wed, Apr 21, 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.EditedMon, Apr 26, 7:49 AM

Does anyone know why the unit test failed?