bool BPFCov::runOnModule()

in lib/BPFCov.cpp [660:694]


bool BPFCov::runOnModule(Module &M)
{
    errs() << "module: " << M.getName() << "\n"; // LLVM_DEBUG(dbgs() << "");

    bool instrumented = false;

    // Bail out when missing debug info
    if (M.debug_compile_units().empty())
    {
        errs() << "Missing debug info\n";
        return instrumented;
    }

    // This sequence is not random at all
    instrumented |= deleteGVarByName(M, "llvm.global_ctors");
    instrumented |= deleteFuncByName(M, "__llvm_profile_init");
    instrumented |= deleteFuncByName(M, "__llvm_profile_register_function");
    instrumented |= deleteFuncByName(M, "__llvm_profile_register_names_function");
    instrumented |= deleteFuncByName(M, "__llvm_profile_runtime_user");
    instrumented |= deleteGVarByName(M, "__llvm_profile_runtime");
    instrumented |= fixupUsedGlobals(M);
    // Stop here to avoid rewriting the profiling and coverage structs
    if (StripInitializersOnly)
    {
        return instrumented;
    }
    instrumented |= swapSectionWithPrefix(M, "__llvm_prf_cnts", ".data.profc");
    instrumented |= swapSectionWithPrefix(M, "__llvm_prf_names", ".rodata.profn");
    instrumented |= convertStructs(M);
    instrumented |= annotateCounters(M);
    instrumented |= swapSectionWithPrefix(M, "__llvm_prf_data", ".rodata.profd");
    instrumented |= swapSectionWithPrefix(M, "__llvm_covmap", ".rodata.covmap");

    return instrumented;
}