mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
Preserve ProfileInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81360 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -26,6 +26,7 @@
|
|||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
|
#include "llvm/Analysis/ProfileInfo.h"
|
||||||
#include "llvm/CodeGen/MachineDominators.h"
|
#include "llvm/CodeGen/MachineDominators.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
@ -44,6 +45,10 @@ namespace {
|
|||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
UnreachableBlockElim() : FunctionPass(&ID) {}
|
UnreachableBlockElim() : FunctionPass(&ID) {}
|
||||||
|
|
||||||
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
|
AU.addPreserved<ProfileInfo>();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
char UnreachableBlockElim::ID = 0;
|
char UnreachableBlockElim::ID = 0;
|
||||||
@ -79,8 +84,11 @@ bool UnreachableBlockElim::runOnFunction(Function &F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actually remove the blocks now.
|
// Actually remove the blocks now.
|
||||||
for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i)
|
ProfileInfo *PI = getAnalysisIfAvailable<ProfileInfo>();
|
||||||
|
for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) {
|
||||||
|
if (PI) PI->removeBlock(DeadBlocks[i]);
|
||||||
DeadBlocks[i]->eraseFromParent();
|
DeadBlocks[i]->eraseFromParent();
|
||||||
|
}
|
||||||
|
|
||||||
return DeadBlocks.size();
|
return DeadBlocks.size();
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
|
#include "llvm/Analysis/ProfileInfo.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
@ -44,6 +45,7 @@ namespace {
|
|||||||
AU.addPreserved<DominatorTree>();
|
AU.addPreserved<DominatorTree>();
|
||||||
AU.addPreserved<DominanceFrontier>();
|
AU.addPreserved<DominanceFrontier>();
|
||||||
AU.addPreserved<LoopInfo>();
|
AU.addPreserved<LoopInfo>();
|
||||||
|
AU.addPreserved<ProfileInfo>();
|
||||||
|
|
||||||
// No loop canonicalization guarantees are broken by this pass.
|
// No loop canonicalization guarantees are broken by this pass.
|
||||||
AU.addPreservedID(LoopSimplifyID);
|
AU.addPreservedID(LoopSimplifyID);
|
||||||
@ -338,5 +340,10 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update ProfileInfo if it is around.
|
||||||
|
if (ProfileInfo *PI = P->getAnalysisIfAvailable<ProfileInfo>()) {
|
||||||
|
PI->splitEdge(TIBB,DestBB,NewBB,MergeIdenticalEdges);
|
||||||
|
}
|
||||||
|
|
||||||
return NewBB;
|
return NewBB;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user