[PATCH] D151901: [BOLT] Instrumentation: Add support for MacOS counters

Elvina Yakubova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 09:35:43 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG70405a0bf70f: [BOLT][Instrumentation] Add support for MacOS counters (authored by Elvina).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151901/new/

https://reviews.llvm.org/D151901

Files:
  bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp


Index: bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
===================================================================
--- bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
+++ bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
@@ -1352,6 +1352,34 @@
     return createInstrumentedIndCallHandlerExitBB();
   }
 
+  InstructionListType createGetter(MCContext *Ctx, const char *name) const {
+    InstructionListType Insts(4);
+    MCSymbol *Locs = Ctx->getOrCreateSymbol(name);
+    InstructionListType Addr = materializeAddress(Locs, Ctx, AArch64::X0);
+    std::copy(Addr.begin(), Addr.end(), Insts.begin());
+    assert(Addr.size() == 2 && "Invalid Addr size");
+    loadReg(Insts[2], AArch64::X0, AArch64::X0);
+    createReturn(Insts[3]);
+    return Insts;
+  }
+
+  InstructionListType createNumCountersGetter(MCContext *Ctx) const override {
+    return createGetter(Ctx, "__bolt_num_counters");
+  }
+
+  InstructionListType
+  createInstrLocationsGetter(MCContext *Ctx) const override {
+    return createGetter(Ctx, "__bolt_instr_locations");
+  }
+
+  InstructionListType createInstrTablesGetter(MCContext *Ctx) const override {
+    return createGetter(Ctx, "__bolt_instr_tables");
+  }
+
+  InstructionListType createInstrNumFuncsGetter(MCContext *Ctx) const override {
+    return createGetter(Ctx, "__bolt_instr_num_funcs");
+  }
+
   void convertIndirectCallToLoad(MCInst &Inst, MCPhysReg Reg) override {
     bool IsTailCall = isTailCall(Inst);
     if (IsTailCall)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151901.553167.patch
Type: text/x-patch
Size: 1485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230824/16604e30/attachment.bin>


More information about the llvm-commits mailing list