[LegacyPM] Remove ThreadSanitizerLegacyPass

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 ThreadSanitizerLegacyPass.

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D124209
This commit is contained in:
Fangrui Song 2022-04-27 16:25:41 -07:00
parent 761366e6ae
commit c74a706893
7 changed files with 0 additions and 60 deletions

View File

@ -16,15 +16,9 @@
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
using namespace llvm; using namespace llvm;
void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createThreadSanitizerLegacyPassPass());
}
void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM, void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,
int ABIListFilesNum, int ABIListFilesNum,
const char **ABIListFiles) { const char **ABIListFiles) {

View File

@ -23,7 +23,6 @@ extern "C" {
// a (somewhat) less stable collection of C APIs for use in creating bindings of // a (somewhat) less stable collection of C APIs for use in creating bindings of
// LLVM in other languages. // LLVM in other languages.
void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM);
void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM, int ABIListFilesNum, void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM, int ABIListFilesNum,
const char **ABIListFiles); const char **ABIListFiles);

View File

@ -19,10 +19,6 @@ package llvm
import "C" import "C"
import "unsafe" import "unsafe"
func (pm PassManager) AddThreadSanitizerPass() {
C.LLVMAddThreadSanitizerPass(pm.C)
}
func (pm PassManager) AddDataFlowSanitizerPass(abilist []string) { func (pm PassManager) AddDataFlowSanitizerPass(abilist []string) {
abiliststrs := make([]*C.char, len(abilist)) abiliststrs := make([]*C.char, len(abilist))
for i, arg := range abilist { for i, arg := range abilist {

View File

@ -432,7 +432,6 @@ void initializeTailDuplicatePass(PassRegistry&);
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry&); void initializeTargetLibraryInfoWrapperPassPass(PassRegistry&);
void initializeTargetPassConfigPass(PassRegistry&); void initializeTargetPassConfigPass(PassRegistry&);
void initializeTargetTransformInfoWrapperPassPass(PassRegistry&); void initializeTargetTransformInfoWrapperPassPass(PassRegistry&);
void initializeThreadSanitizerLegacyPassPass(PassRegistry&);
void initializeTLSVariableHoistLegacyPassPass(PassRegistry &); void initializeTLSVariableHoistLegacyPassPass(PassRegistry &);
void initializeTwoAddressInstructionPassPass(PassRegistry&); void initializeTwoAddressInstructionPassPass(PassRegistry&);
void initializeTypeBasedAAWrapperPassPass(PassRegistry&); void initializeTypeBasedAAWrapperPassPass(PassRegistry&);

View File

@ -19,8 +19,6 @@ namespace llvm {
class Function; class Function;
class FunctionPass; class FunctionPass;
class Module; class Module;
// Insert ThreadSanitizer (race detection) instrumentation
FunctionPass *createThreadSanitizerLegacyPassPass();
/// A function pass for tsan instrumentation. /// A function pass for tsan instrumentation.
/// ///

View File

@ -98,7 +98,6 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) {
initializeCGProfileLegacyPassPass(Registry); initializeCGProfileLegacyPassPass(Registry);
initializeInstrOrderFileLegacyPassPass(Registry); initializeInstrOrderFileLegacyPassPass(Registry);
initializeInstrProfilingLegacyPassPass(Registry); initializeInstrProfilingLegacyPassPass(Registry);
initializeThreadSanitizerLegacyPassPass(Registry);
initializeModuleSanitizerCoverageLegacyPassPass(Registry); initializeModuleSanitizerCoverageLegacyPassPass(Registry);
initializeDataFlowSanitizerLegacyPassPass(Registry); initializeDataFlowSanitizerLegacyPassPass(Registry);
} }

View File

@ -173,19 +173,6 @@ private:
FunctionCallee MemmoveFn, MemcpyFn, MemsetFn; FunctionCallee MemmoveFn, MemcpyFn, MemsetFn;
}; };
struct ThreadSanitizerLegacyPass : FunctionPass {
ThreadSanitizerLegacyPass() : FunctionPass(ID) {
initializeThreadSanitizerLegacyPassPass(*PassRegistry::getPassRegistry());
}
StringRef getPassName() const override;
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool runOnFunction(Function &F) override;
bool doInitialization(Module &M) override;
static char ID; // Pass identification, replacement for typeid.
private:
Optional<ThreadSanitizer> TSan;
};
void insertModuleCtor(Module &M) { void insertModuleCtor(Module &M) {
getOrCreateSanitizerCtorAndInitFunctions( getOrCreateSanitizerCtorAndInitFunctions(
M, kTsanModuleCtorName, kTsanInitName, /*InitArgTypes=*/{}, M, kTsanModuleCtorName, kTsanInitName, /*InitArgTypes=*/{},
@ -210,38 +197,6 @@ PreservedAnalyses ModuleThreadSanitizerPass::run(Module &M,
insertModuleCtor(M); insertModuleCtor(M);
return PreservedAnalyses::none(); return PreservedAnalyses::none();
} }
char ThreadSanitizerLegacyPass::ID = 0;
INITIALIZE_PASS_BEGIN(ThreadSanitizerLegacyPass, "tsan",
"ThreadSanitizer: detects data races.", false, false)
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
INITIALIZE_PASS_END(ThreadSanitizerLegacyPass, "tsan",
"ThreadSanitizer: detects data races.", false, false)
StringRef ThreadSanitizerLegacyPass::getPassName() const {
return "ThreadSanitizerLegacyPass";
}
void ThreadSanitizerLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetLibraryInfoWrapperPass>();
}
bool ThreadSanitizerLegacyPass::doInitialization(Module &M) {
insertModuleCtor(M);
TSan.emplace();
return true;
}
bool ThreadSanitizerLegacyPass::runOnFunction(Function &F) {
auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
TSan->sanitizeFunction(F, TLI);
return true;
}
FunctionPass *llvm::createThreadSanitizerLegacyPassPass() {
return new ThreadSanitizerLegacyPass();
}
void ThreadSanitizer::initialize(Module &M) { void ThreadSanitizer::initialize(Module &M) {
const DataLayout &DL = M.getDataLayout(); const DataLayout &DL = M.getDataLayout();
IntptrTy = DL.getIntPtrType(M.getContext()); IntptrTy = DL.getIntPtrType(M.getContext());