[llvm] Jump table annotations for Linux (PR #112606)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 09:43:07 PDT 2024


================
@@ -453,6 +453,10 @@ class AsmPrinter : public MachineFunctionPass {
   /// function to the current output stream.
   virtual void emitJumpTableInfo();
 
+  /// Emit jump table annotations correlating each table with its associated
+  /// indirect branch instruction.
+  virtual void emitJumpTableAnnotation(const MachineFunction &MF, const MachineInstr &MI);
----------------
nickdesaulniers wrote:

Yes (sorry, I could have phrased it differently).

As an example, if you look at the below method declaration for `emitGlobalVariable`, you'll find a definition for it in the base class AsmPrinter, but overrides are provided in various derived classes (`AMDGPUAsmPrinter`, `ARMAsmPrinter`, `NVPTXAsmPrinter`, `PPCAsmPrinter`, and `WebAssemblyAsmPrinter`).

Since you're not changing the functionality for any of the derived classes (i.e. no `override`s) and only providing a definition for the base class, then you should not declare this method as `virtual`.  That should avoid needing to traverse the vtable to call this method.

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


More information about the llvm-commits mailing list