diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -182,7 +182,6 @@ void initializeMIRProfileLoaderPassPass(PassRegistry &); void initializeMemProfilerLegacyPassPass(PassRegistry &); void initializeHotColdSplittingLegacyPassPass(PassRegistry&); -void initializeHWAddressSanitizerLegacyPassPass(PassRegistry &); void initializeIPSCCPLegacyPassPass(PassRegistry&); void initializeIRCELegacyPassPass(PassRegistry&); void initializeIROutlinerLegacyPassPass(PassRegistry&); diff --git a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h --- a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h +++ b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h @@ -50,11 +50,6 @@ HWAddressSanitizerOptions Options; }; -FunctionPass * -createHWAddressSanitizerLegacyPassPass(bool CompileKernel = false, - bool Recover = false, - bool DisableOptimization = false); - namespace HWASanAccessInfo { // Bit field positions for the accessinfo parameter to diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -389,93 +389,8 @@ 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(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().getResult()); - } - return HWASan->sanitizeFunction( - F, - [&]() -> const DominatorTree & { - return getAnalysis().getDomTree(); - }, - [&]() -> const PostDominatorTree & { - return getAnalysis().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(); - AU.addRequired(); - AU.addRequired(); - } - -private: - std::unique_ptr 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; diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp --- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -98,7 +98,6 @@ initializeCGProfileLegacyPassPass(Registry); initializeInstrOrderFileLegacyPassPass(Registry); initializeInstrProfilingLegacyPassPass(Registry); - initializeHWAddressSanitizerLegacyPassPass(Registry); initializeThreadSanitizerLegacyPassPass(Registry); initializeModuleSanitizerCoverageLegacyPassPass(Registry); initializeDataFlowSanitizerLegacyPassPass(Registry);