@@ -1070,6 +1070,16 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
1070
1070
ASanPass (SanitizerKind::KernelAddress, /* CompileKernel=*/ true );
1071
1071
}
1072
1072
1073
+ if (LangOpts.Sanitize .has (SanitizerKind::HWAddress)) {
1074
+ bool Recover = CodeGenOpts.SanitizeRecover .has (SanitizerKind::HWAddress);
1075
+ MPM.addPass (HWAddressSanitizerPass (
1076
+ /* CompileKernel=*/ false , Recover));
1077
+ }
1078
+ if (LangOpts.Sanitize .has (SanitizerKind::KernelHWAddress)) {
1079
+ MPM.addPass (HWAddressSanitizerPass (
1080
+ /* CompileKernel=*/ true , /* Recover=*/ true ));
1081
+ }
1082
+
1073
1083
if (LangOpts.Sanitize .has (SanitizerKind::Memory)) {
1074
1084
bool Recover = CodeGenOpts.SanitizeRecover .has (SanitizerKind::Memory);
1075
1085
int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins ;
@@ -1348,6 +1358,28 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
1348
1358
/* CompileKernel=*/ false , Recover, UseAfterScope)));
1349
1359
});
1350
1360
}
1361
+
1362
+ if (LangOpts.Sanitize .has (SanitizerKind::HWAddress)) {
1363
+ bool Recover =
1364
+ CodeGenOpts.SanitizeRecover .has (SanitizerKind::HWAddress);
1365
+ PB.registerOptimizerLastEPCallback (
1366
+ [Recover](ModulePassManager &MPM,
1367
+ PassBuilder::OptimizationLevel Level) {
1368
+ MPM.addPass (HWAddressSanitizerPass (
1369
+ /* CompileKernel=*/ false , Recover));
1370
+ });
1371
+ }
1372
+ if (LangOpts.Sanitize .has (SanitizerKind::KernelHWAddress)) {
1373
+ bool Recover =
1374
+ CodeGenOpts.SanitizeRecover .has (SanitizerKind::KernelHWAddress);
1375
+ PB.registerOptimizerLastEPCallback (
1376
+ [Recover](ModulePassManager &MPM,
1377
+ PassBuilder::OptimizationLevel Level) {
1378
+ MPM.addPass (HWAddressSanitizerPass (
1379
+ /* CompileKernel=*/ true , Recover));
1380
+ });
1381
+ }
1382
+
1351
1383
if (Optional<GCOVOptions> Options = getGCOVOptions (CodeGenOpts, LangOpts))
1352
1384
PB.registerPipelineStartEPCallback ([Options](ModulePassManager &MPM) {
1353
1385
MPM.addPass (GCOVProfilerPass (*Options));
@@ -1384,16 +1416,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
1384
1416
MPM.addPass (ModuleMemProfilerPass ());
1385
1417
}
1386
1418
1387
- if (LangOpts.Sanitize .has (SanitizerKind::HWAddress)) {
1388
- bool Recover = CodeGenOpts.SanitizeRecover .has (SanitizerKind::HWAddress);
1389
- MPM.addPass (HWAddressSanitizerPass (
1390
- /* CompileKernel=*/ false , Recover));
1391
- }
1392
- if (LangOpts.Sanitize .has (SanitizerKind::KernelHWAddress)) {
1393
- MPM.addPass (HWAddressSanitizerPass (
1394
- /* CompileKernel=*/ true , /* Recover=*/ true ));
1395
- }
1396
-
1397
1419
if (CodeGenOpts.OptimizationLevel == 0 ) {
1398
1420
// FIXME: the backends do not handle matrix intrinsics currently. Make
1399
1421
// sure they are also lowered in O0. A lightweight version of the pass
0 commit comments