[NFC][asan] Rename ModuleAddressSanitizerPass

This commit is contained in:
Vitaly Buka 2022-09-05 22:37:45 -07:00
parent e7bac3b9fa
commit 93600eb50c
6 changed files with 16 additions and 18 deletions

View File

@ -673,8 +673,8 @@ static void addSanitizers(const Triple &TargetTriple,
Opts.Recover = CodeGenOpts.SanitizeRecover.has(Mask); Opts.Recover = CodeGenOpts.SanitizeRecover.has(Mask);
Opts.UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope; Opts.UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
Opts.UseAfterReturn = CodeGenOpts.getSanitizeAddressUseAfterReturn(); Opts.UseAfterReturn = CodeGenOpts.getSanitizeAddressUseAfterReturn();
MPM.addPass(ModuleAddressSanitizerPass( MPM.addPass(AddressSanitizerPass(Opts, UseGlobalGC, UseOdrIndicator,
Opts, UseGlobalGC, UseOdrIndicator, DestructorKind)); DestructorKind));
} }
}; };
ASanPass(SanitizerKind::Address, false); ASanPass(SanitizerKind::Address, false);

View File

@ -33,12 +33,10 @@ struct AddressSanitizerOptions {
/// ///
/// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also /// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also
/// run intependently of the function address sanitizer. /// run intependently of the function address sanitizer.
class ModuleAddressSanitizerPass class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> {
: public PassInfoMixin<ModuleAddressSanitizerPass> {
public: public:
ModuleAddressSanitizerPass( AddressSanitizerPass(const AddressSanitizerOptions &Options,
const AddressSanitizerOptions &Options, bool UseGlobalGC = true, bool UseGlobalGC = true, bool UseOdrIndicator = false,
bool UseOdrIndicator = false,
AsanDtorKind DestructorKind = AsanDtorKind::Global); AsanDtorKind DestructorKind = AsanDtorKind::Global);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
void printPipeline(raw_ostream &OS, void printPipeline(raw_ostream &OS,

View File

@ -146,10 +146,10 @@ MODULE_PASS_WITH_PARAMS("hwasan",
}, },
parseHWASanPassOptions, parseHWASanPassOptions,
"kernel;recover") "kernel;recover")
MODULE_PASS_WITH_PARAMS("asan-module", MODULE_PASS_WITH_PARAMS("asan",
"ModuleAddressSanitizerPass", "AddressSanitizerPass",
[](AddressSanitizerOptions Opts) { [](AddressSanitizerOptions Opts) {
return ModuleAddressSanitizerPass(Opts); return AddressSanitizerPass(Opts);
}, },
parseASanPassOptions, parseASanPassOptions,
"kernel") "kernel")

View File

@ -1110,9 +1110,9 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
} // end anonymous namespace } // end anonymous namespace
void ModuleAddressSanitizerPass::printPipeline( void AddressSanitizerPass::printPipeline(
raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) { raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
static_cast<PassInfoMixin<ModuleAddressSanitizerPass> *>(this)->printPipeline( static_cast<PassInfoMixin<AddressSanitizerPass> *>(this)->printPipeline(
OS, MapClassName2PassName); OS, MapClassName2PassName);
OS << "<"; OS << "<";
if (Options.CompileKernel) if (Options.CompileKernel)
@ -1120,13 +1120,13 @@ void ModuleAddressSanitizerPass::printPipeline(
OS << ">"; OS << ">";
} }
ModuleAddressSanitizerPass::ModuleAddressSanitizerPass( AddressSanitizerPass::AddressSanitizerPass(
const AddressSanitizerOptions &Options, bool UseGlobalGC, const AddressSanitizerOptions &Options, bool UseGlobalGC,
bool UseOdrIndicator, AsanDtorKind DestructorKind) bool UseOdrIndicator, AsanDtorKind DestructorKind)
: Options(Options), UseGlobalGC(UseGlobalGC), : Options(Options), UseGlobalGC(UseGlobalGC),
UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {} UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M, PreservedAnalyses AddressSanitizerPass::run(Module &M,
ModuleAnalysisManager &MAM) { ModuleAnalysisManager &MAM) {
ModuleAddressSanitizer ModuleSanitizer(M, Options.CompileKernel, ModuleAddressSanitizer ModuleSanitizer(M, Options.CompileKernel,
Options.Recover, UseGlobalGC, Options.Recover, UseGlobalGC,

View File

@ -2,7 +2,7 @@
; Make sure asan does not instrument __sancov_gen_ ; Make sure asan does not instrument __sancov_gen_
; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s
; RUN: opt < %s -passes='module(sancov-module,asan-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s ; RUN: opt < %s -passes='module(sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu" target triple = "x86_64-unknown-linux-gnu"
$Foo = comdat any $Foo = comdat any

View File

@ -381,7 +381,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
ArrayRef<PassBuilder::PipelineElement>) { ArrayRef<PassBuilder::PipelineElement>) {
AddressSanitizerOptions Opts; AddressSanitizerOptions Opts;
if (Name == "asan-pipeline") { if (Name == "asan-pipeline") {
MPM.addPass(ModuleAddressSanitizerPass(Opts)); MPM.addPass(AddressSanitizerPass(Opts));
return true; return true;
} }
return false; return false;