diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1016,8 +1016,11 @@ } if (LangOpts.Sanitize.has(SanitizerKind::Memory)) { - MPM.addPass(MemorySanitizerPass({})); - MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({}))); + bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory); + int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins; + 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)) {