1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00

[NFCI] Change RewriteStatepointsForGC to a ModulePass.

Summary:
A later change that has RewriteStatepointsForGC change function
attributes throughout the module depends on this.

Reviewers: reames, pgavlin

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10104

llvm-svn: 238882
This commit is contained in:
Sanjoy Das 2015-06-02 22:33:34 +00:00
parent ac84e180d5
commit b0be5949a7
2 changed files with 17 additions and 14 deletions

View File

@ -456,7 +456,7 @@ FunctionPass *createPlaceSafepointsPass();
// RewriteStatepointsForGC - Rewrite any gc.statepoints which do not yet have // RewriteStatepointsForGC - Rewrite any gc.statepoints which do not yet have
// explicit relocations to include explicit relocations. // explicit relocations to include explicit relocations.
// //
FunctionPass *createRewriteStatepointsForGCPass(); ModulePass *createRewriteStatepointsForGCPass();
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //

View File

@ -74,13 +74,19 @@ static cl::opt<bool, true> ClobberNonLiveOverride("rs4gc-clobber-non-live",
cl::Hidden); cl::Hidden);
namespace { namespace {
struct RewriteStatepointsForGC : public FunctionPass { struct RewriteStatepointsForGC : public ModulePass {
static char ID; // Pass identification, replacement for typeid static char ID; // Pass identification, replacement for typeid
RewriteStatepointsForGC() : FunctionPass(ID) { RewriteStatepointsForGC() : ModulePass(ID) {
initializeRewriteStatepointsForGCPass(*PassRegistry::getPassRegistry()); initializeRewriteStatepointsForGCPass(*PassRegistry::getPassRegistry());
} }
bool runOnFunction(Function &F) override; bool runOnFunction(Function &F);
bool runOnModule(Module &M) override {
bool Changed = false;
for (Function &F : M)
Changed |= runOnFunction(F);
return Changed;
}
void getAnalysisUsage(AnalysisUsage &AU) const override { void getAnalysisUsage(AnalysisUsage &AU) const override {
// We add and rewrite a bunch of instructions, but don't really do much // We add and rewrite a bunch of instructions, but don't really do much
@ -93,7 +99,7 @@ struct RewriteStatepointsForGC : public FunctionPass {
char RewriteStatepointsForGC::ID = 0; char RewriteStatepointsForGC::ID = 0;
FunctionPass *llvm::createRewriteStatepointsForGCPass() { ModulePass *llvm::createRewriteStatepointsForGCPass() {
return new RewriteStatepointsForGC(); return new RewriteStatepointsForGC();
} }
@ -1031,14 +1037,11 @@ static void recomputeLiveInValues(
// goes through the statepoint. We might need to split an edge to make this // goes through the statepoint. We might need to split an edge to make this
// possible. // possible.
static BasicBlock * static BasicBlock *
normalizeForInvokeSafepoint(BasicBlock *BB, BasicBlock *InvokeParent, Pass *P) { normalizeForInvokeSafepoint(BasicBlock *BB, BasicBlock *InvokeParent,
DominatorTree *DT = nullptr; DominatorTree &DT) {
if (auto *DTP = P->getAnalysisIfAvailable<DominatorTreeWrapperPass>())
DT = &DTP->getDomTree();
BasicBlock *Ret = BB; BasicBlock *Ret = BB;
if (!BB->getUniquePredecessor()) { if (!BB->getUniquePredecessor()) {
Ret = SplitBlockPredecessors(BB, InvokeParent, "", nullptr, DT); Ret = SplitBlockPredecessors(BB, InvokeParent, "", nullptr, &DT);
} }
// Now that 'ret' has unique predecessor we can safely remove all phi nodes // Now that 'ret' has unique predecessor we can safely remove all phi nodes
@ -2016,9 +2019,9 @@ static bool insertParsePoints(Function &F, DominatorTree &DT, Pass *P,
continue; continue;
InvokeInst *invoke = cast<InvokeInst>(CS.getInstruction()); InvokeInst *invoke = cast<InvokeInst>(CS.getInstruction());
normalizeForInvokeSafepoint(invoke->getNormalDest(), invoke->getParent(), normalizeForInvokeSafepoint(invoke->getNormalDest(), invoke->getParent(),
P); DT);
normalizeForInvokeSafepoint(invoke->getUnwindDest(), invoke->getParent(), normalizeForInvokeSafepoint(invoke->getUnwindDest(), invoke->getParent(),
P); DT);
} }
// A list of dummy calls added to the IR to keep various values obviously // A list of dummy calls added to the IR to keep various values obviously
@ -2221,7 +2224,7 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F) {
if (!shouldRewriteStatepointsIn(F)) if (!shouldRewriteStatepointsIn(F))
return false; return false;
DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
// Gather all the statepoints which need rewritten. Be careful to only // Gather all the statepoints which need rewritten. Be careful to only
// consider those in reachable code since we need to ask dominance queries // consider those in reachable code since we need to ask dominance queries