Skip to content

Commit

Permalink
[LegacyPM] Remove HWAsanSanitizerLegacyPass
Browse files Browse the repository at this point in the history
Using the legacy PM for the optimization pipeline was deprecated in 13.0.0.
Following recent changes to remove non-core features of the legacy
PM/optimization pipeline, remove AddressSanitizerLegacyPass...

...,
ModuleAddressSanitizerLegacyPass, and ASanGlobalsMetadataWrapperPass.

MemorySanitizerLegacyPass was removed in D123894.
AddressSanitizerLegacyPass was removed in D124216.

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D124337
  • Loading branch information
MaskRay committed Apr 25, 2022
1 parent 4051cac commit 39e23bb
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 92 deletions.
1 change: 0 additions & 1 deletion llvm/include/llvm/InitializePasses.h
Expand Up @@ -182,7 +182,6 @@ void initializeHardwareLoopsPass(PassRegistry&);
void initializeMIRProfileLoaderPassPass(PassRegistry &);
void initializeMemProfilerLegacyPassPass(PassRegistry &);
void initializeHotColdSplittingLegacyPassPass(PassRegistry&);
void initializeHWAddressSanitizerLegacyPassPass(PassRegistry &);
void initializeIPSCCPLegacyPassPass(PassRegistry&);
void initializeIRCELegacyPassPass(PassRegistry&);
void initializeIROutlinerLegacyPassPass(PassRegistry&);
Expand Down
Expand Up @@ -50,11 +50,6 @@ class HWAddressSanitizerPass : public PassInfoMixin<HWAddressSanitizerPass> {
HWAddressSanitizerOptions Options;
};

FunctionPass *
createHWAddressSanitizerLegacyPassPass(bool CompileKernel = false,
bool Recover = false,
bool DisableOptimization = false);

namespace HWASanAccessInfo {

// Bit field positions for the accessinfo parameter to
Expand Down
85 changes: 0 additions & 85 deletions llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Expand Up @@ -389,93 +389,8 @@ class HWAddressSanitizer {
GlobalValue *ThreadPtrGlobal = nullptr;
};

class HWAddressSanitizerLegacyPass : public FunctionPass {
public:
// Pass identification, replacement for typeid.
static char ID;

explicit HWAddressSanitizerLegacyPass(bool CompileKernel = false,
bool Recover = false,
bool DisableOptimization = false)
: FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover),
DisableOptimization(DisableOptimization) {
initializeHWAddressSanitizerLegacyPassPass(
*PassRegistry::getPassRegistry());
}

StringRef getPassName() const override { return "HWAddressSanitizer"; }

bool doInitialization(Module &M) override {
HWASan = std::make_unique<HWAddressSanitizer>(M, CompileKernel, Recover,
/*SSI=*/nullptr);
return true;
}

bool runOnFunction(Function &F) override {
auto TargetTriple = Triple(F.getParent()->getTargetTriple());
if (shouldUseStackSafetyAnalysis(TargetTriple, DisableOptimization)) {
// We cannot call getAnalysis in doInitialization, that would cause a
// crash as the required analyses are not initialized yet.
HWASan->setSSI(
&getAnalysis<StackSafetyGlobalInfoWrapperPass>().getResult());
}
return HWASan->sanitizeFunction(
F,
[&]() -> const DominatorTree & {
return getAnalysis<DominatorTreeWrapperPass>().getDomTree();
},
[&]() -> const PostDominatorTree & {
return getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();
});
}

bool doFinalization(Module &M) override {
HWASan.reset();
return false;
}

void getAnalysisUsage(AnalysisUsage &AU) const override {
// This is an over-estimation of, in case we are building for an
// architecture that doesn't allow stack tagging we will still load the
// analysis.
// This is so we don't need to plumb TargetTriple all the way to here.
if (mightUseStackSafetyAnalysis(DisableOptimization))
AU.addRequired<StackSafetyGlobalInfoWrapperPass>();
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<PostDominatorTreeWrapperPass>();
}

private:
std::unique_ptr<HWAddressSanitizer> HWASan;
bool CompileKernel;
bool Recover;
bool DisableOptimization;
};

} // end anonymous namespace

char HWAddressSanitizerLegacyPass::ID = 0;

INITIALIZE_PASS_BEGIN(
HWAddressSanitizerLegacyPass, "hwasan",
"HWAddressSanitizer: detect memory bugs using tagged addressing.", false,
false)
INITIALIZE_PASS_DEPENDENCY(StackSafetyGlobalInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)
INITIALIZE_PASS_END(
HWAddressSanitizerLegacyPass, "hwasan",
"HWAddressSanitizer: detect memory bugs using tagged addressing.", false,
false)

FunctionPass *
llvm::createHWAddressSanitizerLegacyPassPass(bool CompileKernel, bool Recover,
bool DisableOptimization) {
assert(!CompileKernel || Recover);
return new HWAddressSanitizerLegacyPass(CompileKernel, Recover,
DisableOptimization);
}

PreservedAnalyses HWAddressSanitizerPass::run(Module &M,
ModuleAnalysisManager &MAM) {
const StackSafetyGlobalInfo *SSI = nullptr;
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
Expand Up @@ -98,7 +98,6 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) {
initializeCGProfileLegacyPassPass(Registry);
initializeInstrOrderFileLegacyPassPass(Registry);
initializeInstrProfilingLegacyPassPass(Registry);
initializeHWAddressSanitizerLegacyPassPass(Registry);
initializeThreadSanitizerLegacyPassPass(Registry);
initializeModuleSanitizerCoverageLegacyPassPass(Registry);
initializeDataFlowSanitizerLegacyPassPass(Registry);
Expand Down

0 comments on commit 39e23bb

Please sign in to comment.