Skip to content

Commit

Permalink
[NFC][asan] Rename ModuleAddressSanitizerPass
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka committed Sep 6, 2022
1 parent e7bac3b commit 93600eb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ static void addSanitizers(const Triple &TargetTriple,
Opts.Recover = CodeGenOpts.SanitizeRecover.has(Mask);
Opts.UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
Opts.UseAfterReturn = CodeGenOpts.getSanitizeAddressUseAfterReturn();
MPM.addPass(ModuleAddressSanitizerPass(
Opts, UseGlobalGC, UseOdrIndicator, DestructorKind));
MPM.addPass(AddressSanitizerPass(Opts, UseGlobalGC, UseOdrIndicator,
DestructorKind));
}
};
ASanPass(SanitizerKind::Address, false);
Expand Down
10 changes: 4 additions & 6 deletions llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ struct AddressSanitizerOptions {
///
/// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also
/// run intependently of the function address sanitizer.
class ModuleAddressSanitizerPass
: public PassInfoMixin<ModuleAddressSanitizerPass> {
class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> {
public:
ModuleAddressSanitizerPass(
const AddressSanitizerOptions &Options, bool UseGlobalGC = true,
bool UseOdrIndicator = false,
AsanDtorKind DestructorKind = AsanDtorKind::Global);
AddressSanitizerPass(const AddressSanitizerOptions &Options,
bool UseGlobalGC = true, bool UseOdrIndicator = false,
AsanDtorKind DestructorKind = AsanDtorKind::Global);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName);
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Passes/PassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ MODULE_PASS_WITH_PARAMS("hwasan",
},
parseHWASanPassOptions,
"kernel;recover")
MODULE_PASS_WITH_PARAMS("asan-module",
"ModuleAddressSanitizerPass",
MODULE_PASS_WITH_PARAMS("asan",
"AddressSanitizerPass",
[](AddressSanitizerOptions Opts) {
return ModuleAddressSanitizerPass(Opts);
return AddressSanitizerPass(Opts);
},
parseASanPassOptions,
"kernel")
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,24 +1110,24 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {

} // end anonymous namespace

void ModuleAddressSanitizerPass::printPipeline(
void AddressSanitizerPass::printPipeline(
raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
static_cast<PassInfoMixin<ModuleAddressSanitizerPass> *>(this)->printPipeline(
static_cast<PassInfoMixin<AddressSanitizerPass> *>(this)->printPipeline(
OS, MapClassName2PassName);
OS << "<";
if (Options.CompileKernel)
OS << "kernel";
OS << ">";
}

ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
AddressSanitizerPass::AddressSanitizerPass(
const AddressSanitizerOptions &Options, bool UseGlobalGC,
bool UseOdrIndicator, AsanDtorKind DestructorKind)
: Options(Options), UseGlobalGC(UseGlobalGC),
UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}

PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
ModuleAnalysisManager &MAM) {
PreservedAnalyses AddressSanitizerPass::run(Module &M,
ModuleAnalysisManager &MAM) {
ModuleAddressSanitizer ModuleSanitizer(M, Options.CompileKernel,
Options.Recover, UseGlobalGC,
UseOdrIndicator, DestructorKind);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; 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,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 triple = "x86_64-unknown-linux-gnu"
$Foo = comdat any
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/opt/NewPMDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
ArrayRef<PassBuilder::PipelineElement>) {
AddressSanitizerOptions Opts;
if (Name == "asan-pipeline") {
MPM.addPass(ModuleAddressSanitizerPass(Opts));
MPM.addPass(AddressSanitizerPass(Opts));
return true;
}
return false;
Expand Down

0 comments on commit 93600eb

Please sign in to comment.