[llvm] [AsmPrinter] Reduce AsmPrinterHandlers virt. fn calls (PR #96785)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 23:32:19 PDT 2024


https://github.com/MaskRay commented:

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

LGTM. cleanup after https://reviews.llvm.org/D91878

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

LGTM. This part of this patch yields the largest win.

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

LGTM.

> Remove NamedRegionTimer from instruction loop. Checking a global variable for every instruction (and doing an out-of-line function call) is too expensive for a profiling functionality.

LGTM. Agreed that the overhead overweighs the potential use.
To address @aeubanks's comment, this could be split to a separate PR.


https://github.com/llvm/llvm-project/pull/96785


More information about the llvm-commits mailing list