[PATCH] D79445: [MSan] Pass MSan command line options under new pass manager
Arthur Eubanks via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 5 16:12:47 PDT 2020
aeubanks updated this revision to Diff 262248.
aeubanks added a comment.
Address review comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79445/new/
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
@@ -1015,14 +1015,20 @@
ASanPass(SanitizerKind::KernelAddress, /*CompileKernel=*/true);
}
+ auto MSanPass = [&](SanitizerMask Mask, bool Kernel) {
+ bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+ int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
+ MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, Kernel}));
+ MPM.addPass(createModuleToFunctionPassAdaptor(
+ MemorySanitizerPass({TrackOrigins, Recover, Kernel})));
+ };
+
if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
- MPM.addPass(MemorySanitizerPass({}));
- MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
+ MSanPass(SanitizerKind::Memory, /*Kernel=*/false);
}
if (LangOpts.Sanitize.has(SanitizerKind::KernelMemory)) {
- MPM.addPass(createModuleToFunctionPassAdaptor(
- MemorySanitizerPass({0, false, /*Kernel=*/true})));
+ MSanPass(SanitizerKind::KernelMemory, /*Kernel=*/true);
}
if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
@@ -1236,12 +1242,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)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79445.262248.patch
Type: text/x-patch
Size: 2324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200505/9078c6e6/attachment-0001.bin>
More information about the cfe-commits
mailing list