mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Reimplement the internal abstraction used by MemDep in terms
of a pointer/int pair instead of a manually bitmangled pointer. This forces clients to think a little more about checking the appropriate pieces and will be useful for internal implementation improvements later. I'm not particularly happy with this. After going through this I don't think that the clients of memdep should be exposed to the internal type at all. I'll fix this in a subsequent commit. This has no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60230 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -46,9 +46,11 @@ namespace {
|
||||
Changed |= runOnBasicBlock(*I);
|
||||
return Changed;
|
||||
}
|
||||
|
||||
typedef MemoryDependenceAnalysis::DepResultTy DepResultTy;
|
||||
|
||||
bool runOnBasicBlock(BasicBlock &BB);
|
||||
bool handleFreeWithNonTrivialDependency(FreeInst *F, Instruction *Dep);
|
||||
bool handleFreeWithNonTrivialDependency(FreeInst *F, DepResultTy Dep);
|
||||
bool handleEndBlock(BasicBlock &BB);
|
||||
bool RemoveUndeadPointers(Value* pointer, uint64_t killPointerSize,
|
||||
BasicBlock::iterator& BBI,
|
||||
@@ -108,17 +110,16 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||
|
||||
// ... to a pointer that has been stored to before...
|
||||
if (last) {
|
||||
Instruction* dep = MD.getDependency(Inst);
|
||||
DepResultTy dep = MD.getDependency(Inst);
|
||||
bool deletedStore = false;
|
||||
|
||||
// ... and no other memory dependencies are between them....
|
||||
while (dep != MemoryDependenceAnalysis::None &&
|
||||
dep != MemoryDependenceAnalysis::NonLocal &&
|
||||
isa<StoreInst>(dep)) {
|
||||
if (dep != last ||
|
||||
while (dep.getInt() == MemoryDependenceAnalysis::Normal &&
|
||||
isa<StoreInst>(dep.getPointer())) {
|
||||
if (dep.getPointer() != last ||
|
||||
TD.getTypeStoreSize(last->getOperand(0)->getType()) >
|
||||
TD.getTypeStoreSize(Inst->getOperand(0)->getType())) {
|
||||
dep = MD.getDependency(Inst, dep);
|
||||
dep = MD.getDependency(Inst, dep.getPointer());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -151,14 +152,14 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||
// loaded from, then the store can be removed;
|
||||
if (LoadInst* L = dyn_cast<LoadInst>(S->getOperand(0))) {
|
||||
// FIXME: Don't do dep query if Parents don't match and other stuff!
|
||||
Instruction* dep = MD.getDependency(S);
|
||||
DepResultTy dep = MD.getDependency(S);
|
||||
DominatorTree& DT = getAnalysis<DominatorTree>();
|
||||
|
||||
if (!S->isVolatile() && S->getParent() == L->getParent() &&
|
||||
S->getPointerOperand() == L->getPointerOperand() &&
|
||||
(dep == MemoryDependenceAnalysis::None ||
|
||||
dep == MemoryDependenceAnalysis::NonLocal ||
|
||||
DT.dominates(dep, L))) {
|
||||
(dep.getInt() == MemoryDependenceAnalysis::None ||
|
||||
dep.getInt() == MemoryDependenceAnalysis::NonLocal ||
|
||||
DT.dominates(dep.getPointer(), L))) {
|
||||
|
||||
DeleteDeadInstruction(S);
|
||||
if (!isa<TerminatorInst>(BB.begin()))
|
||||
@@ -184,15 +185,15 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
|
||||
|
||||
/// handleFreeWithNonTrivialDependency - Handle frees of entire structures whose
|
||||
/// dependency is a store to a field of that structure.
|
||||
bool DSE::handleFreeWithNonTrivialDependency(FreeInst* F, Instruction* dep) {
|
||||
bool DSE::handleFreeWithNonTrivialDependency(FreeInst* F, DepResultTy dep) {
|
||||
TargetData &TD = getAnalysis<TargetData>();
|
||||
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
||||
|
||||
if (dep == MemoryDependenceAnalysis::None ||
|
||||
dep == MemoryDependenceAnalysis::NonLocal)
|
||||
if (dep.getInt() == MemoryDependenceAnalysis::None ||
|
||||
dep.getInt() == MemoryDependenceAnalysis::NonLocal)
|
||||
return false;
|
||||
|
||||
StoreInst* dependency = dyn_cast<StoreInst>(dep);
|
||||
StoreInst* dependency = dyn_cast<StoreInst>(dep.getPointer());
|
||||
if (!dependency)
|
||||
return false;
|
||||
else if (dependency->isVolatile())
|
||||
|
Reference in New Issue
Block a user