Lines Matching refs:BC

174 Instrumentation::createInstrumentationSnippet(BinaryContext &BC, bool IsLeaf) {  in createInstrumentationSnippet()  argument
175 auto L = BC.scopeLock(); in createInstrumentationSnippet()
177 Label = BC.Ctx->createNamedTempSymbol("InstrEntry"); in createInstrumentationSnippet()
180 BC.MIB->createInstrIncMemory(CounterInstrs, Label, &*BC.Ctx, IsLeaf); in createInstrumentationSnippet()
217 BinaryContext &BC = FromFunction.getBinaryContext(); in instrumentIndirectTarget() local
218 bool IsTailCall = BC.MIB->isTailCall(*Iter); in instrumentIndirectTarget()
219 InstructionListType CounterInstrs = BC.MIB->createInstrumentedIndirectCall( in instrumentIndirectTarget()
223 IndCallSiteID, &*BC.Ctx); in instrumentIndirectTarget()
253 BinaryContext &BC = FromFunction.getBinaryContext(); in instrumentOneTarget() local
255 if (BC.MIB->isCall(Inst)) { in instrumentOneTarget()
292 BinaryContext &BC = Function.getBinaryContext(); in instrumentFunction() local
293 if (BC.isMachO() && Function.hasName("___GLOBAL_init_65535/1")) in instrumentFunction()
364 if (BC.MIB->isCall(*I)) { in instrumentFunction()
365 if (BC.MIB->isInvoke(*I)) in instrumentFunction()
380 if (!BC.MIB->getOffset(Inst)) in instrumentFunction()
386 else if (BC.MIB->isUnconditionalBranch(Inst)) in instrumentFunction()
388 else if ((!BC.MIB->isCall(Inst) && !BC.MIB->isConditionalBranch(Inst)) || in instrumentFunction()
389 BC.MIB->isUnsupportedBranch(Inst.getOpcode())) in instrumentFunction()
392 const uint32_t FromOffset = *BC.MIB->getOffset(Inst); in instrumentFunction()
393 const MCSymbol *Target = BC.MIB->getTargetSymbol(Inst); in instrumentFunction()
397 TargetBB ? &Function : BC.getFunctionForSymbol(Target); in instrumentFunction()
398 if (TargetFunc && BC.MIB->isCall(Inst)) { in instrumentFunction()
414 auto L = BC.scopeLock(); in instrumentFunction()
431 auto L = BC.scopeLock(); in instrumentFunction()
448 if (opts::InstrumentCalls && BC.MIB->isIndirectCall(*I)) in instrumentFunction()
461 while (LastInstr != I && BC.MIB->isPseudo(*LastInstr)) in instrumentFunction()
468 if (!BC.MIB->getOffset(*LastInstr)) in instrumentFunction()
470 FromOffset = *BC.MIB->getOffset(*LastInstr); in instrumentFunction()
474 auto L = BC.scopeLock(); in instrumentFunction()
511 void Instrumentation::runOnFunctions(BinaryContext &BC) { in runOnFunctions() argument
512 if (!BC.isX86()) in runOnFunctions()
518 BC.registerOrUpdateSection(".bolt.instr.counters", ELF::SHT_PROGBITS, Flags, in runOnFunctions()
521 BC.registerOrUpdateNoteSection(".bolt.instr.tables", nullptr, 0, in runOnFunctions()
526 BC.Ctx->getOrCreateSymbol("__bolt_ind_call_counter_func_pointer"); in runOnFunctions()
528 BC.Ctx->getOrCreateSymbol("__bolt_ind_tailcall_counter_func_pointer"); in runOnFunctions()
530 createAuxiliaryFunctions(BC); in runOnFunctions()
543 BC, ParallelUtilities::SchedulingPolicy::SP_INST_QUADRATIC, WorkFun, in runOnFunctions()
546 if (BC.isMachO()) { in runOnFunctions()
547 if (BC.StartFunctionAddress) { in runOnFunctions()
549 BC.getBinaryFunctionAtAddress(*BC.StartFunctionAddress); in runOnFunctions()
554 BC.getUniqueSectionByName("I__setup"); in runOnFunctions()
559 MCSymbol *Target = BC.registerNameAtAddress( in runOnFunctions()
562 BC.MIB->createCall(NewInst, Target, BC.Ctx.get()); in runOnFunctions()
568 if (BinaryData *BD = BC.getBinaryDataByName("___GLOBAL_init_65535/1")) { in runOnFunctions()
569 BinaryFunction *Ctor = BC.getBinaryFunctionAtAddress(BD->getAddress()); in runOnFunctions()
573 BC.getUniqueSectionByName("I__fini"); in runOnFunctions()
578 MCSymbol *Target = BC.registerNameAtAddress( in runOnFunctions()
580 auto IsLEA = [&BC](const MCInst &Inst) { return BC.MIB->isLEA64r(Inst); }; in runOnFunctions()
584 MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *BC.Ctx)); in runOnFunctions()
590 setupRuntimeLibrary(BC); in runOnFunctions()
593 void Instrumentation::createAuxiliaryFunctions(BinaryContext &BC) { in createAuxiliaryFunctions() argument
596 BinaryFunction *Func = BC.createInjectedBinaryFunction(std::string(Title)); in createAuxiliaryFunctions()
618 BC.MIB->createInstrumentedIndCallHandlerExitBB()); in createAuxiliaryFunctions()
622 BC.MIB->createInstrumentedIndCallHandlerEntryBB( in createAuxiliaryFunctions()
624 IndCallHandlerExitBB->getSymbol(), &*BC.Ctx)); in createAuxiliaryFunctions()
628 BC.MIB->createInstrumentedIndTailCallHandlerExitBB()); in createAuxiliaryFunctions()
632 BC.MIB->createInstrumentedIndCallHandlerEntryBB( in createAuxiliaryFunctions()
634 IndTailCallHandlerExitBB->getSymbol(), &*BC.Ctx)); in createAuxiliaryFunctions()
637 BC.MIB->createNumCountersGetter(BC.Ctx.get())); in createAuxiliaryFunctions()
639 BC.MIB->createInstrLocationsGetter(BC.Ctx.get())); in createAuxiliaryFunctions()
641 BC.MIB->createInstrTablesGetter(BC.Ctx.get())); in createAuxiliaryFunctions()
643 BC.MIB->createInstrNumFuncsGetter(BC.Ctx.get())); in createAuxiliaryFunctions()
645 if (BC.isELF()) { in createAuxiliaryFunctions()
646 if (BC.StartFunctionAddress) { in createAuxiliaryFunctions()
648 BC.getBinaryFunctionAtAddress(*BC.StartFunctionAddress); in createAuxiliaryFunctions()
653 BC.MIB->createSymbolTrampoline(StartSym, BC.Ctx.get())); in createAuxiliaryFunctions()
655 if (BC.FiniFunctionAddress) { in createAuxiliaryFunctions()
657 BC.getBinaryFunctionAtAddress(*BC.FiniFunctionAddress); in createAuxiliaryFunctions()
662 BC.MIB->createSymbolTrampoline(FiniSym, BC.Ctx.get())); in createAuxiliaryFunctions()
668 BC.MIB->createDummyReturnFunction(BC.Ctx.get())); in createAuxiliaryFunctions()
673 void Instrumentation::setupRuntimeLibrary(BinaryContext &BC) { in setupRuntimeLibrary() argument
704 static_cast<InstrumentationRuntimeLibrary *>(BC.getRuntimeLibrary()); in setupRuntimeLibrary()