[PATCH] D132708: [MC] Emit Stackmaps before debug info

Markus Böck via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 15:29:08 PDT 2022


zero9178 created this revision.
zero9178 added reviewers: lhames, aprantl, dblaikie, echristo.
Herald added subscribers: StephenFan, pengfei, hiraditya.
Herald added a project: All.
zero9178 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is essentially an alternative to https://reviews.llvm.org/D75836 and was mentioned by @lhames in a comment.

The gist of the issue is that Mach-O has restrictions on which kind of sections are allowed after debug info has been emitted, which is also properly asserted within LLVM. Problem is that stack maps are currently emitted as one of the last sections in each target-specific AsmPrinter so far, which would cause the assertion to trigger. The current approach of special casing for the `__LLVM_STACKMAPS` section is not viable either, as downstream users can overwrite the stackmap format using plugins, which may want to use different sections.

This patch fixes the issue by emitting the stack map earlier, right before debug info is emitted. The way this is implemented is by taking the choice when to emit the StackMap away from the target AsmPrinter and doing so in the base class. The only disadvantage of this approach is that the `StackMaps` member is now part of the base class, even for targets that do not support them. This is functionaly not a problem however, as emitting an empty `StackMaps` is a no-op.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132708

Files:
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/test/CodeGen/X86/stackmap-macho.ll
  llvm/test/CodeGen/X86/statepoint-stackmap-size.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132708.455735.patch
Type: text/x-patch
Size: 7825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220825/93bb1d2b/attachment.bin>


More information about the llvm-commits mailing list