| ... | ... | @@ -311,19 +311,35 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi |
| 311 | 311 | } |
| 312 | 312 | }); |
| 313 | 313 | |
| 314 | | //pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 315 | | //}); |
| 316 | | |
| 317 | | pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) { |
| 318 | | // Code coverage instrumentation. |
| 319 | | if (options->sancov) { |
| 320 | | module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage))); |
| 314 | const bool early_san = options->is_debug; |
| 315 | |
| 316 | pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 317 | if (early_san) { |
| 318 | // Code coverage instrumentation. |
| 319 | if (options->sancov) { |
| 320 | module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage))); |
| 321 | } |
| 322 | |
| 323 | // Thread sanitizer |
| 324 | if (options->tsan) { |
| 325 | module_pm.addPass(ModuleThreadSanitizerPass()); |
| 326 | module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); |
| 327 | } |
| 321 | 328 | } |
| 329 | }); |
| 322 | 330 | |
| 323 | | // Thread sanitizer |
| 324 | | if (options->tsan) { |
| 325 | | module_pm.addPass(ModuleThreadSanitizerPass()); |
| 326 | | module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); |
| 331 | pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) { |
| 332 | if (!early_san) { |
| 333 | // Code coverage instrumentation. |
| 334 | if (options->sancov) { |
| 335 | module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage))); |
| 336 | } |
| 337 | |
| 338 | // Thread sanitizer |
| 339 | if (options->tsan) { |
| 340 | module_pm.addPass(ModuleThreadSanitizerPass()); |
| 341 | module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); |
| 342 | } |
| 327 | 343 | } |
| 328 | 344 | |
| 329 | 345 | // Verify the output |