mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +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) {
|
||||
// Code coverage instrumentation.
|
||||
if (options->sancov) {
|
||||
module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage)));
|
||||
}
|
||||
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()));
|
||||
// Thread sanitizer
|
||||
if (options->tsan) {
|
||||
module_pm.addPass(ModuleThreadSanitizerPass());
|
||||
module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the output
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user