Skip to content

Commit d9fc3d8

Browse files
committed
[NewPM] Replace 'kasan-module' by 'asan-module<kernel>'
Change the asan-module pass into a MODULE_PASS_WITH_PARAMS in the pass registry, and add a single parameter called 'kernel' that can be set instead of having a special pass name 'kasan-module' to trigger that special pass config. 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.
1 parent 8f86166 commit d9fc3d8

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class ModuleAddressSanitizerPass
136136
bool UseOdrIndicator = false,
137137
AsanDtorKind DestructorKind = AsanDtorKind::Global);
138138
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
139+
void printPipeline(raw_ostream &OS,
140+
function_ref<StringRef(StringRef)> MapClassName2PassName);
139141
static bool isRequired() { return true; }
140142

141143
private:

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ Expected<bool> parseLowerMatrixIntrinsicsPassOptions(StringRef Params) {
574574
return parseSinglePassOption(Params, "minimal", "LowerMatrixIntrinsics");
575575
}
576576

577+
Expected<bool> parseModuleAddressSanitizerPassOptions(StringRef Params) {
578+
return parseSinglePassOption(Params, "kernel", "ModuleAddressSanitizer");
579+
}
580+
577581
Expected<AddressSanitizerOptions> parseASanPassOptions(StringRef Params) {
578582
AddressSanitizerOptions Result;
579583
while (!Params.empty()) {

llvm/lib/Passes/PassRegistry.def

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ MODULE_PASS("synthetic-counts-propagation", SyntheticCountsPropagation())
109109
MODULE_PASS("verify", VerifierPass())
110110
MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass())
111111
MODULE_PASS("dfsan", DataFlowSanitizerPass())
112-
MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, false, true, false))
113112
MODULE_PASS("msan-module", ModuleMemorySanitizerPass({}))
114113
MODULE_PASS("tsan-module", ModuleThreadSanitizerPass())
115-
MODULE_PASS("kasan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/true, false, true, false))
116114
MODULE_PASS("sancov-module", ModuleSanitizerCoveragePass())
117115
MODULE_PASS("memprof-module", ModuleMemProfilerPass())
118116
MODULE_PASS("poison-checking", PoisonCheckingPass())
@@ -138,6 +136,15 @@ MODULE_PASS_WITH_PARAMS("hwasan",
138136
},
139137
parseHWASanPassOptions,
140138
"kernel;recover")
139+
MODULE_PASS_WITH_PARAMS("asan-module",
140+
"ModuleAddressSanitizerPass",
141+
[](bool CompileKernel) {
142+
return ModuleAddressSanitizerPass(CompileKernel,
143+
false, true,
144+
false);
145+
},
146+
parseModuleAddressSanitizerPassOptions,
147+
"kernel")
141148
#undef MODULE_PASS_WITH_PARAMS
142149

143150
#ifndef CGSCC_ANALYSIS

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,16 @@ void AddressSanitizerPass::printPipeline(
12831283
OS << ">";
12841284
}
12851285

1286+
void ModuleAddressSanitizerPass::printPipeline(
1287+
raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
1288+
static_cast<PassInfoMixin<ModuleAddressSanitizerPass> *>(this)->printPipeline(
1289+
OS, MapClassName2PassName);
1290+
OS << "<";
1291+
if (CompileKernel)
1292+
OS << "kernel";
1293+
OS << ">";
1294+
}
1295+
12861296
ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
12871297
bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
12881298
AsanDtorKind DestructorKind)

0 commit comments

Comments
 (0)