forked from OSchip/llvm-project
[NewPM] Use a separate struct for ModuleMemorySanitizerPass
Split MemorySanitizerPass into MemorySanitizerPass (as a function pass) and ModuleMemorySanitizerPass (as a module pass). Main reason is to make sure that we have a unique mapping from ClassName to PassName in the new passmanager framework, making it possible to correctly identify the passes when dealing with options such as -print-after and -print-pipeline-passes. This is a follow-up to D105006 and D105007.
This commit is contained in:
parent
05ea321f71
commit
ab41eef9ac
|
@ -1119,7 +1119,7 @@ static void addSanitizers(const Triple &TargetTriple,
|
||||||
bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
|
bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
|
||||||
|
|
||||||
MPM.addPass(
|
MPM.addPass(
|
||||||
MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
|
ModuleMemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
|
||||||
FunctionPassManager FPM;
|
FunctionPassManager FPM;
|
||||||
FPM.addPass(
|
FPM.addPass(
|
||||||
MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
|
MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
|
||||||
|
|
|
@ -40,11 +40,26 @@ struct MemorySanitizerPass : public PassInfoMixin<MemorySanitizerPass> {
|
||||||
MemorySanitizerPass(MemorySanitizerOptions Options) : Options(Options) {}
|
MemorySanitizerPass(MemorySanitizerOptions Options) : Options(Options) {}
|
||||||
|
|
||||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
|
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
|
||||||
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
|
|
||||||
void printPipeline(raw_ostream &OS,
|
void printPipeline(raw_ostream &OS,
|
||||||
function_ref<StringRef(StringRef)> MapClassName2PassName);
|
function_ref<StringRef(StringRef)> MapClassName2PassName);
|
||||||
static bool isRequired() { return true; }
|
static bool isRequired() { return true; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemorySanitizerOptions Options;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// A module pass for msan instrumentation.
|
||||||
|
///
|
||||||
|
/// Instruments functions to detect unitialized reads. This function pass
|
||||||
|
/// inserts calls to runtime library functions. If the functions aren't declared
|
||||||
|
/// yet, the pass inserts the declarations. Otherwise the existing globals are
|
||||||
|
/// used.
|
||||||
|
struct ModuleMemorySanitizerPass : public PassInfoMixin<ModuleMemorySanitizerPass> {
|
||||||
|
ModuleMemorySanitizerPass(MemorySanitizerOptions Options) : Options(Options) {}
|
||||||
|
|
||||||
|
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
|
||||||
|
static bool isRequired() { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MemorySanitizerOptions Options;
|
MemorySanitizerOptions Options;
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,7 +110,7 @@ MODULE_PASS("verify", VerifierPass())
|
||||||
MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass())
|
MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass())
|
||||||
MODULE_PASS("dfsan", DataFlowSanitizerPass())
|
MODULE_PASS("dfsan", DataFlowSanitizerPass())
|
||||||
MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, false, true, false))
|
MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, false, true, false))
|
||||||
MODULE_PASS("msan-module", MemorySanitizerPass({}))
|
MODULE_PASS("msan-module", ModuleMemorySanitizerPass({}))
|
||||||
MODULE_PASS("tsan-module", ThreadSanitizerPass())
|
MODULE_PASS("tsan-module", ThreadSanitizerPass())
|
||||||
MODULE_PASS("kasan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/true, false, true, false))
|
MODULE_PASS("kasan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/true, false, true, false))
|
||||||
MODULE_PASS("sancov-module", ModuleSanitizerCoveragePass())
|
MODULE_PASS("sancov-module", ModuleSanitizerCoveragePass())
|
||||||
|
@ -335,7 +335,6 @@ FUNCTION_PASS("verify<scalar-evolution>", ScalarEvolutionVerifierPass())
|
||||||
FUNCTION_PASS("view-cfg", CFGViewerPass())
|
FUNCTION_PASS("view-cfg", CFGViewerPass())
|
||||||
FUNCTION_PASS("view-cfg-only", CFGOnlyViewerPass())
|
FUNCTION_PASS("view-cfg-only", CFGOnlyViewerPass())
|
||||||
FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass())
|
FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass())
|
||||||
FUNCTION_PASS("msan", MemorySanitizerPass({}))
|
|
||||||
FUNCTION_PASS("tsan", ThreadSanitizerPass())
|
FUNCTION_PASS("tsan", ThreadSanitizerPass())
|
||||||
FUNCTION_PASS("memprof", MemProfilerPass())
|
FUNCTION_PASS("memprof", MemProfilerPass())
|
||||||
#undef FUNCTION_PASS
|
#undef FUNCTION_PASS
|
||||||
|
|
|
@ -673,8 +673,8 @@ PreservedAnalyses MemorySanitizerPass::run(Function &F,
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
}
|
}
|
||||||
|
|
||||||
PreservedAnalyses MemorySanitizerPass::run(Module &M,
|
PreservedAnalyses
|
||||||
ModuleAnalysisManager &AM) {
|
ModuleMemorySanitizerPass::run(Module &M, ModuleAnalysisManager &AM) {
|
||||||
if (Options.Kernel)
|
if (Options.Kernel)
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
insertModuleCtor(M);
|
insertModuleCtor(M);
|
||||||
|
|
|
@ -40,9 +40,8 @@
|
||||||
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(early-cse<>,early-cse<memssa>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-12
|
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(early-cse<>,early-cse<memssa>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-12
|
||||||
; CHECK-12: function(early-cse<>,early-cse<memssa>)
|
; CHECK-12: function(early-cse<>,early-cse<memssa>)
|
||||||
|
|
||||||
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(msan<>,msan<recover;kernel;track-origins=5>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-13
|
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='msan-module,function(msan,msan<>,msan<recover;kernel;track-origins=5>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-13
|
||||||
;;; XXX: msan-module? this is one of the places where the ClassName to pass-name mapping fails.
|
; CHECK-13: msan-module,function(msan<track-origins=0>,msan<track-origins=0>,msan<recover;kernel;track-origins=5>)
|
||||||
; CHECK-13: function(msan-module<track-origins=0>,msan-module<recover;kernel;track-origins=5>)
|
|
||||||
|
|
||||||
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan<kernel;recover>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
|
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan<kernel;recover>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
|
||||||
; CHECK-14: hwasan<>,hwasan<kernel;recover>
|
; CHECK-14: hwasan<>,hwasan<kernel;recover>
|
||||||
|
|
Loading…
Reference in New Issue