This is an archive of the discontinued LLVM Phabricator instance.

[StackMaps] Force section serialization for functions with no records
AbandonedPublic

Authored by yrouban on Jun 8 2021, 4:15 AM.

Details

Summary

This patch allows to get function frame size from the .llvm_stackmaps section.
This section was generated for those functions that have at least one stack map record. For the other functions we could not get frame size. (The .eh_frame section does not help. Any other way?).

The StackMap class collected functions when stack map records were added. This patch introduces method StackMap::registerFunction() that is called before adding stack map records. All registered functions will have records with their frame sizes in the stack map section if the new option -stackmap-force-serialization is set to true even if there is no stack map records. With -stackmap-force-serialization set to false (the default) the old behavior is used: only those functions that have at least one record get into the stack map section and the section is generated only if there is at least one such function.

Diff Detail

Event Timeline

yrouban created this revision.Jun 8 2021, 4:15 AM
yrouban requested review of this revision.Jun 8 2021, 4:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2021, 4:15 AM
yrouban updated this revision to Diff 351052.Jun 9 2021, 8:50 PM

fixed nits reported by build bots

I don't really have an objection to this, but have you looked at the -stack-size-section support? I think you might be able to get the same information that way. If that doesn't work for some reason, just let me know and we can move forward with the review of this.

yrouban planned changes to this revision.Jun 18 2021, 3:54 AM

I don't really have an objection to this, but have you looked at the -stack-size-section support? I think you might be able to get the same information that way. If that doesn't work for some reason, just let me know and we can move forward with the review of this.

Thank you, Philip. The .stack_sizes section seems to be exactly what we need.

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
1661

must call the base PPCAsmPrinter::emitFunctionBodyStart(); to register the function in StackMaps.

llvm/test/CodeGen/AArch64/stackmap.ll
63

remove extra '_' in the name

yrouban abandoned this revision.Jul 22 2021, 10:04 PM

Thank you, Philip. The .stack_sizes section seems to be exactly what we need.

One minor issue I had to solve downstream: the .stack_sizes section does not have the ELF::SHF_ALLOC flag as the llvm_stackmaps does. So I had to set this flag in MCObjectFileInfo.cpp.