Skip to content

Commit 8f86166

Browse files
committed
[NewPM] Use a separate struct for ModuleThreadSanitizerPass
Split ThreadSanitizerPass into ThreadSanitizerPass (as a function pass) and ModuleThreadSanitizerPass (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.
1 parent ab41eef commit 8f86166

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ static void addSanitizers(const Triple &TargetTriple,
11421142
MSanPass(SanitizerKind::KernelMemory, true);
11431143

11441144
if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
1145-
MPM.addPass(ThreadSanitizerPass());
1145+
MPM.addPass(ModuleThreadSanitizerPass());
11461146
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
11471147
}
11481148

llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ FunctionPass *createThreadSanitizerLegacyPassPass();
2727
/// yet, the pass inserts the declarations. Otherwise the existing globals are
2828
struct ThreadSanitizerPass : public PassInfoMixin<ThreadSanitizerPass> {
2929
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
30+
static bool isRequired() { return true; }
31+
};
32+
33+
/// A module pass for tsan instrumentation.
34+
///
35+
/// Create ctor and init functions.
36+
struct ModuleThreadSanitizerPass
37+
: public PassInfoMixin<ModuleThreadSanitizerPass> {
3038
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
3139
static bool isRequired() { return true; }
3240
};

llvm/lib/Passes/PassRegistry.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass())
111111
MODULE_PASS("dfsan", DataFlowSanitizerPass())
112112
MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, false, true, false))
113113
MODULE_PASS("msan-module", ModuleMemorySanitizerPass({}))
114-
MODULE_PASS("tsan-module", ThreadSanitizerPass())
114+
MODULE_PASS("tsan-module", ModuleThreadSanitizerPass())
115115
MODULE_PASS("kasan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/true, false, true, false))
116116
MODULE_PASS("sancov-module", ModuleSanitizerCoveragePass())
117117
MODULE_PASS("memprof-module", ModuleMemProfilerPass())

llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ PreservedAnalyses ThreadSanitizerPass::run(Function &F,
206206
return PreservedAnalyses::all();
207207
}
208208

209-
PreservedAnalyses ThreadSanitizerPass::run(Module &M,
210-
ModuleAnalysisManager &MAM) {
209+
PreservedAnalyses ModuleThreadSanitizerPass::run(Module &M,
210+
ModuleAnalysisManager &MAM) {
211211
insertModuleCtor(M);
212212
return PreservedAnalyses::none();
213213
}

0 commit comments

Comments
 (0)