diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h --- a/bolt/include/bolt/Core/MCPlusBuilder.h +++ b/bolt/include/bolt/Core/MCPlusBuilder.h @@ -1977,6 +1977,12 @@ return InstructionListType(); } + virtual InstructionListType createGetter(MCContext *Ctx, + const char *name) const { + llvm_unreachable("not implemented"); + return {}; + } + virtual InstructionListType createNumCountersGetter(MCContext *Ctx) const { llvm_unreachable("not implemented"); return {}; diff --git a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp --- a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp +++ b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp @@ -1327,6 +1327,35 @@ return createInstrumentedIndCallHandlerExitBB(); } + InstructionListType createGetter(MCContext *Ctx, + const char *name) const override { + const MCPhysReg TempReg = getIntArgRegister(0); + InstructionListType Insts(4); + MCSymbol *Locs = Ctx->getOrCreateSymbol(name); + InstructionListType Addr = materializeAddress(Locs, Ctx, TempReg); + std::copy(Addr.begin(), Addr.end(), Insts.begin()); + loadReg(Insts[2], TempReg, false); + 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 { if (Inst.getOpcode() == AArch64::BL || Inst.getOpcode() == AArch64::BLR || Inst.getOpcode() == AArch64::BR || Inst.getOpcode() == AArch64::B) {