| ... | @@ -311,19 +311,35 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi | ... | @@ -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) { | 314 | const bool early_san = options->is_debug; |
| 315 | //}); | 315 | |
| 316 | | 316 | pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 317 | pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) { | 317 | if (early_san) { |
| 318 | // Code coverage instrumentation. | 318 | // Code coverage instrumentation. |
| 319 | if (options->sancov) { | 319 | if (options->sancov) { |
| 320 | module_pm.addPass(SanitizerCoveragePass(getSanCovOptions(options->coverage))); | 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 | 331 | pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) { |
| 324 | if (options->tsan) { | 332 | if (!early_san) { |
| 325 | module_pm.addPass(ModuleThreadSanitizerPass()); | 333 | // Code coverage instrumentation. |
| 326 | module_pm.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); | 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 | // Verify the output | 345 | // Verify the output |