mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 03:03:09 +00:00
ZigLLVMTargetMachineEmitToFile: schedule sancov pass depending on mode
In debug mode, schedule it early. In release modes, schedule it late.
This commit is contained in:
parent
4162f401cb
commit
31c1320818
@ -311,19 +311,35 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) {
|
const bool early_san = options->is_debug;
|
||||||
//});
|
|
||||||
|
pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) {
|
||||||
|
if (early_san) {
|
||||||
|
// Code coverage instrumentation.
|
||||||
|
if (options->sancov) {
|
||||||
|
module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Thread sanitizer
|
||||||
|
if (options->tsan) {
|
||||||
|
module_pm.addPass(ModuleThreadSanitizerPass());
|
||||||
|
module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) {
|
pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) {
|
||||||
// Code coverage instrumentation.
|
if (!early_san) {
|
||||||
if (options->sancov) {
|
// Code coverage instrumentation.
|
||||||
module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage)));
|
if (options->sancov) {
|
||||||
}
|
module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage)));
|
||||||
|
}
|
||||||
|
|
||||||
// Thread sanitizer
|
// Thread sanitizer
|
||||||
if (options->tsan) {
|
if (options->tsan) {
|
||||||
module_pm.addPass(ModuleThreadSanitizerPass());
|
module_pm.addPass(ModuleThreadSanitizerPass());
|
||||||
module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
|
module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the output
|
// Verify the output
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user