| ... | ... | @@ -189,6 +189,27 @@ struct TimeTracerRAII { |
| 189 | 189 | }; |
| 190 | 190 | } // end anonymous namespace |
| 191 | 191 | |
| 192 | static SanitizerCoverageOptions getSanCovOptions(void) { |
| 193 | SanitizerCoverageOptions o; |
| 194 | o.CoverageType = SanitizerCoverageOptions::SCK_Edge; |
| 195 | o.IndirectCalls = true; |
| 196 | o.TraceBB = false; |
| 197 | o.TraceCmp = true; |
| 198 | o.TraceDiv = false; |
| 199 | o.TraceGep = false; |
| 200 | o.Use8bitCounters = false; |
| 201 | o.TracePC = false; |
| 202 | o.TracePCGuard = false; |
| 203 | o.Inline8bitCounters = true; |
| 204 | o.InlineBoolFlag = false; |
| 205 | o.PCTable = true; |
| 206 | o.NoPrune = false; |
| 207 | o.StackDepth = true; |
| 208 | o.TraceLoads = false; |
| 209 | o.TraceStores = false; |
| 210 | o.CollectControlFlow = false; |
| 211 | return o; |
| 212 | } |
| 192 | 213 | |
| 193 | 214 | bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, |
| 194 | 215 | char **error_message, bool is_debug, |
| ... | ... | @@ -279,36 +300,23 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM |
| 279 | 300 | pass_builder.registerCGSCCAnalyses(cgscc_am); |
| 280 | 301 | pass_builder.registerFunctionAnalyses(function_am); |
| 281 | 302 | pass_builder.registerLoopAnalyses(loop_am); |
| 282 | | pass_builder.crossRegisterProxies(loop_am, function_am, |
| 283 | | cgscc_am, module_am); |
| 284 | | |
| 285 | | // IR verification |
| 286 | | if (assertions_on) { |
| 287 | | // Verify the input |
| 288 | | pass_builder.registerPipelineStartEPCallback( |
| 289 | | [](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 290 | | module_pm.addPass(VerifierPass()); |
| 291 | | }); |
| 292 | | // Verify the output |
| 293 | | pass_builder.registerOptimizerLastEPCallback( |
| 294 | | [](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 295 | | module_pm.addPass(VerifierPass()); |
| 296 | | }); |
| 297 | | } |
| 303 | pass_builder.crossRegisterProxies(loop_am, function_am, cgscc_am, module_am); |
| 298 | 304 | |
| 299 | | // Passes specific for release build |
| 300 | | if (!is_debug) { |
| 301 | | pass_builder.registerPipelineStartEPCallback( |
| 302 | | [](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 303 | | module_pm.addPass( |
| 304 | | createModuleToFunctionPassAdaptor(AddDiscriminatorsPass())); |
| 305 | | }); |
| 306 | | } |
| 305 | pass_builder.registerPipelineStartEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 306 | // Verify the input |
| 307 | if (assertions_on) { |
| 308 | module_pm.addPass(VerifierPass()); |
| 309 | } |
| 307 | 310 | |
| 308 | | pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) { |
| 311 | if (!is_debug) { |
| 312 | module_pm.addPass(createModuleToFunctionPassAdaptor(AddDiscriminatorsPass())); |
| 313 | } |
| 314 | }); |
| 315 | |
| 316 | pass_builder.registerOptimizerEarlyEPCallback([&](ModulePassManager &module_pm, OptimizationLevel OL) { |
| 309 | 317 | // Code coverage instrumentation. |
| 310 | 318 | if (sancov) { |
| 311 | | module_pm.addPass(SanitizerCoveragePass()); |
| 319 | module_pm.addPass(SanitizerCoveragePass(getSanCovOptions())); |
| 312 | 320 | } |
| 313 | 321 | |
| 314 | 322 | // Thread sanitizer |
| ... | ... | @@ -318,6 +326,13 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM |
| 318 | 326 | } |
| 319 | 327 | }); |
| 320 | 328 | |
| 329 | pass_builder.registerOptimizerLastEPCallback([&](ModulePassManager &module_pm, OptimizationLevel level) { |
| 330 | // Verify the output |
| 331 | if (assertions_on) { |
| 332 | module_pm.addPass(VerifierPass()); |
| 333 | } |
| 334 | }); |
| 335 | |
| 321 | 336 | ModulePassManager module_pm; |
| 322 | 337 | OptimizationLevel opt_level; |
| 323 | 338 | // Setting up the optimization level |