[llvm] Migrate PAEval to new pass manager

This commit is contained in:
Arthur Eubanks 2022-10-01 16:40:58 -07:00
parent 5bbc5eb55f
commit 5df4ab55f9
9 changed files with 12 additions and 41 deletions

View File

@ -26,8 +26,6 @@ namespace llvm {
//
ImmutablePass *createObjCARCAAWrapperPass();
FunctionPass *createPAEvalPass();
//===--------------------------------------------------------------------===//
//
/// createLazyValueInfoPass - This creates an instance of the LazyValueInfo

View File

@ -324,7 +324,6 @@ void initializeObjCARCExpandPass(PassRegistry&);
void initializeObjCARCOptLegacyPassPass(PassRegistry &);
void initializeOptimizationRemarkEmitterWrapperPassPass(PassRegistry&);
void initializeOptimizePHIsPass(PassRegistry&);
void initializePAEvalPass(PassRegistry&);
void initializePEIPass(PassRegistry&);
void initializePHIEliminationPass(PassRegistry&);
void initializePartialInlinerLegacyPassPass(PassRegistry&);

View File

@ -143,7 +143,6 @@ namespace {
(void) llvm::createObjCARCExpandPass();
(void) llvm::createObjCARCContractPass();
(void) llvm::createObjCARCOptPass();
(void) llvm::createPAEvalPass();
(void) llvm::createPromoteMemoryToRegisterPass();
(void) llvm::createDemoteRegisterToMemoryPass();
(void)llvm::createPostDomOnlyPrinterWrapperPassPass();

View File

@ -60,6 +60,10 @@ struct ObjCARCExpandPass : public PassInfoMixin<ObjCARCExpandPass> {
PreservedAnalyses run(Function &M, FunctionAnalysisManager &AM);
};
struct PAEvalPass : public PassInfoMixin<PAEvalPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};
} // End llvm namespace
#endif

View File

@ -330,6 +330,7 @@ FUNCTION_PASS("loop-versioning", LoopVersioningPass())
FUNCTION_PASS("objc-arc", ObjCARCOptPass())
FUNCTION_PASS("objc-arc-contract", ObjCARCContractPass())
FUNCTION_PASS("objc-arc-expand", ObjCARCExpandPass())
FUNCTION_PASS("pa-eval", PAEvalPass())
FUNCTION_PASS("pgo-memop-opt", PGOMemOPSizeOpt())
FUNCTION_PASS("print", PrintFunctionPass(dbgs()))
FUNCTION_PASS("print<assumptions>", AssumptionPrinterPass(dbgs()))

View File

@ -35,7 +35,6 @@ void llvm::initializeObjCARCOpts(PassRegistry &Registry) {
initializeObjCARCExpandPass(Registry);
initializeObjCARCContractLegacyPassPass(Registry);
initializeObjCARCOptLegacyPassPass(Registry);
initializePAEvalPass(Registry);
}
void LLVMInitializeObjCARCOpts(LLVMPassRegistryRef R) {

View File

@ -26,6 +26,7 @@
#define LLVM_LIB_TRANSFORMS_OBJCARC_PROVENANCEANALYSIS_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ValueHandle.h"
#include <utility>

View File

@ -7,38 +7,16 @@
//===----------------------------------------------------------------------===//
#include "ProvenanceAnalysis.h"
#include "llvm/Transforms/ObjCARC.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using namespace llvm::objcarc;
namespace {
class PAEval : public FunctionPass {
public:
static char ID;
PAEval();
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool runOnFunction(Function &F) override;
};
}
char PAEval::ID = 0;
PAEval::PAEval() : FunctionPass(ID) {}
void PAEval::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<AAResultsWrapperPass>();
}
static StringRef getName(Value *V) {
StringRef Name = V->getName();
if (Name.startswith("\1"))
@ -52,7 +30,7 @@ static void insertIfNamed(SetVector<Value *> &Values, Value *V) {
Values.insert(V);
}
bool PAEval::runOnFunction(Function &F) {
PreservedAnalyses PAEvalPass::run(Function &F, FunctionAnalysisManager &AM) {
SetVector<Value *> Values;
for (auto &Arg : F.args())
@ -66,7 +44,7 @@ bool PAEval::runOnFunction(Function &F) {
}
ProvenanceAnalysis PA;
PA.setAA(&getAnalysis<AAResultsWrapperPass>().getAAResults());
PA.setAA(&AM.getResult<AAManager>(F));
for (Value *V1 : Values) {
StringRef NameV1 = getName(V1);
@ -82,13 +60,5 @@ bool PAEval::runOnFunction(Function &F) {
}
}
return false;
}
FunctionPass *llvm::createPAEvalPass() { return new PAEval(); }
INITIALIZE_PASS_BEGIN(PAEval, "pa-eval",
"Evaluate ProvenanceAnalysis on all pairs", false, true)
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
INITIALIZE_PASS_END(PAEval, "pa-eval",
"Evaluate ProvenanceAnalysis on all pairs", false, true)
return PreservedAnalyses::all();
}

View File

@ -1,4 +1,4 @@
; RUN: opt -disable-output -disable-basic-aa -pa-eval %s -enable-new-pm=0 2>&1 | FileCheck %s
; RUN: opt -disable-output -aa-pipeline= -passes=pa-eval %s 2>&1 | FileCheck %s
@"\01l_objc_msgSend_fixup_" = global i8 0
@g1 = global i8 0, section "__OBJC,__message_refs,literal_pointers,no_dead_strip"