[all-commits] [llvm/llvm-project] 117b53: [AsmPrinter] Reduce AsmPrinterHandlers virt. fn ca...

Alexis Engelke via All-commits all-commits at lists.llvm.org
Mon Jul 1 04:56:19 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 117b53ae38428ca66eaa886fb432e6f09db88fe4
      https://github.com/llvm/llvm-project/commit/117b53ae38428ca66eaa886fb432e6f09db88fe4
  Author: Alexis Engelke <engelke at in.tum.de>
  Date:   2024-07-01 (Mon, 01 Jul 2024)

  Changed paths:
    M llvm/include/llvm/CodeGen/AsmPrinter.h
    M llvm/include/llvm/CodeGen/AsmPrinterHandler.h
    M llvm/include/llvm/CodeGen/DebugHandlerBase.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
    M llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
    M llvm/lib/CodeGen/AsmPrinter/EHStreamer.h
    M llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
    M llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.h
    M llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h
    M llvm/lib/Target/BPF/BPFAsmPrinter.cpp
    M llvm/lib/Target/BPF/BTFDebug.h
    M llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp

  Log Message:
  -----------
  [AsmPrinter] Reduce AsmPrinterHandlers virt. fn calls (#96785)

Currently, an AsmPrinterHandler has several methods that allow to
dynamically hook in unwind or debug info emission, e.g. at begin/end of
every function or instruction. The class hierarchy and the actually
overridden functions are as follows:

    (SymSz=setSymbolSize, mFE=markFunctionEnd, BBS=BasicBlockSection,
     FL=Funclet; b=beginX, e=endX)
                          SymSz   Mod Fn  mFE BBS FL  Inst
    AsmPrinterHandler     -       -   -   -   -   -   -
    ` PseudoProbeHandler  -       -   -   -   -   -   -
    ` WinCFGuard          -       e   e   -   -   -   -
    ` EHStreamer          -       -   -   -   -   -   -
      ` DwarfCFIException -       e   be  -   be  -   -
      ` ARMException      -       -   be  e   -   -   -
      ` AIXException      -       -   e   -   -   -   -
      ` WinException      -       e   be  e   -   be  -
      ` WasmException     -       e   be  -   -   -   -
    ` DebugHandlerBase    -       b   be  -   be  -   be
      ` BTFDebug          -       e   -   -   -   -   b
      ` CodeViewDebug     -       be  -   -   -   -   b
      ` DWARFDebug        yes     be  -   -   -   -   b

Doing virtual function calls per instruction is costly and useless when
the called function does nothing.

This commit performs the following clean-up/improvements:

- PseudoProbeHandler is no longer an AsmPrinterHandler -- it used
nothing of its functionality to hook in at the possible points. This
avoids virtual function calls when a pseudo probe printer is present.

- DebugHandlerBase is no longer an AsmPrinterHandler, but a separate
base class. DebugHandlerBase is the only remaining "hook" for begin/end
instruction and setSymbolSize (only used by DWARFDebug). begin/end for
function and basic block sections are never overriden and therefore are
no longer virtual. (Originally I intended there to be only one debug
handler, but BPF as the only target supports two at the same time: DWARF
and BTF.)

- AsmPrinterHandler no longer has begin/end instruction and
setSymbolSize hooks -- these were only used by DebugHandlerBase. This
avoid iterating over handlers in every instruction.

    AsmPrinterHandler     Mod Fn  mFE BBS FL
    ` WinCFGuard          e   e   -   -   -
    ` EHStreamer          -   -   -   -   -
      ` DwarfCFIException e   be  -   be  -
      ` ARMException      -   be  e   -   -
      ` AIXException      -   e   -   -   -
      ` WinException      e   be  e   -   be
      ` WasmException     e   be  -   -   -

                          SymSz   Mod Fn  BBS Inst
    DebugHandlerBase      -       b   be  be  be
    ` BTFDebug            -       e           b
    ` CodeViewDebug       -       be          b
    ` DWARFDebug          yes     be          b

    PseudoProbeHandler (no shared methods)

To continue allowing external users (e.g., Julia) to hook in at every
instruction, a new method addDebugHandler is exposed.

This results in a performance improvement, especially in the -O0 -g0
case with unwind information (e.g., JIT baseline).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list