ZigLLVMTargetMachineEmitToFile: put sanitizers in registerOptimizerLastEPCallback

matching the default of clang's behavior. I originally put them in
registerOptimizerEarlyEPCallback because I thought clang was doing that,
but I see now it is behind the flag `--sanitizer-early-opt-ep` which is
disabled by default.
This commit is contained in:
Andrew Kelley 2024-08-10 17:29:14 -07:00
parent b5398180d6
commit e8e49efe21

View File

@ -311,7 +311,10 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi
}
});
pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) {
//pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) {
//});
pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) {
// Code coverage instrumentation.
if (options.sancov) {
module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options.coverage)));
@ -322,9 +325,7 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi
module_pm.addPass(ModuleThreadSanitizerPass());
module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
}
});
pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) {
// Verify the output
if (assertions_on) {
module_pm.addPass(VerifierPass());