mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +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:
parent
07abe17bd2
commit
ff5dfdff56
@ -26,6 +26,7 @@
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/Analysis/ProfileInfo.h"
|
||||
#include "llvm/CodeGen/MachineDominators.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
@ -44,6 +45,10 @@ namespace {
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
UnreachableBlockElim() : FunctionPass(&ID) {}
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addPreserved<ProfileInfo>();
|
||||
}
|
||||
};
|
||||
}
|
||||
char UnreachableBlockElim::ID = 0;
|
||||
@ -79,8 +84,11 @@ bool UnreachableBlockElim::runOnFunction(Function &F) {
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
return DeadBlocks.size();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||
#include "llvm/Analysis/Dominators.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/Analysis/ProfileInfo.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Type.h"
|
||||
@ -44,6 +45,7 @@ namespace {
|
||||
AU.addPreserved<DominatorTree>();
|
||||
AU.addPreserved<DominanceFrontier>();
|
||||
AU.addPreserved<LoopInfo>();
|
||||
AU.addPreserved<ProfileInfo>();
|
||||
|
||||
// No loop canonicalization guarantees are broken by this pass.
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user