aeubanks created this revision. aeubanks added reviewers: nemanjai, vitalybuka, leonardchan. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Properly forward TrackOrigins and Recover user options to the MSan pass under the new pass manager. This makes the number of check-msan failures when ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER is TRUE go from 52 to 2. Based on https://reviews.llvm.org/D77249. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D79445 Files: clang/lib/CodeGen/BackendUtil.cpp Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -1016,8 +1016,11 @@ } if (LangOpts.Sanitize.has(SanitizerKind::Memory)) { - MPM.addPass(MemorySanitizerPass({})); - MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({}))); + int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins; + bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory); + MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false})); + MPM.addPass(createModuleToFunctionPassAdaptor( + MemorySanitizerPass({TrackOrigins, Recover, false}))); } if (LangOpts.Sanitize.has(SanitizerKind::KernelMemory)) { @@ -1236,12 +1239,16 @@ FPM.addPass(BoundsCheckingPass()); }); if (LangOpts.Sanitize.has(SanitizerKind::Memory)) { - PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) { - MPM.addPass(MemorySanitizerPass({})); - }); + int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins; + bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory); + PB.registerPipelineStartEPCallback( + [TrackOrigins, Recover](ModulePassManager &MPM) { + MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false})); + }); PB.registerOptimizerLastEPCallback( - [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) { - FPM.addPass(MemorySanitizerPass({})); + [TrackOrigins, Recover](FunctionPassManager &FPM, + PassBuilder::OptimizationLevel Level) { + FPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false})); }); } if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -1016,8 +1016,11 @@ } if (LangOpts.Sanitize.has(SanitizerKind::Memory)) { - MPM.addPass(MemorySanitizerPass({})); - MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({}))); + int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins; + bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory); + MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false})); + MPM.addPass(createModuleToFunctionPassAdaptor( + MemorySanitizerPass({TrackOrigins, Recover, false}))); } if (LangOpts.Sanitize.has(SanitizerKind::KernelMemory)) { @@ -1236,12 +1239,16 @@ FPM.addPass(BoundsCheckingPass()); }); if (LangOpts.Sanitize.has(SanitizerKind::Memory)) { - PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) { - MPM.addPass(MemorySanitizerPass({})); - }); + int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins; + bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory); + PB.registerPipelineStartEPCallback( + [TrackOrigins, Recover](ModulePassManager &MPM) { + MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false})); + }); PB.registerOptimizerLastEPCallback( - [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) { - FPM.addPass(MemorySanitizerPass({})); + [TrackOrigins, Recover](FunctionPassManager &FPM, + PassBuilder::OptimizationLevel Level) { + FPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false})); }); } if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits