diff options
| author | Owen Anderson <resistor@mac.com> | 2008-02-12 21:15:18 +0000 | 
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2008-02-12 21:15:18 +0000 | 
| commit | 00dba4f734d1fd64803a3ef16bc153ba63b6a283 (patch) | |
| tree | 599fbdc881124c9ac5f1ac2d6f7143b3bfdb4ea0 /llvm/lib/Analysis | |
| parent | f213e82bc597dfa3d452c3ed3e2e16b77fc4d2ff (diff) | |
| download | bcm5719-llvm-00dba4f734d1fd64803a3ef16bc153ba63b6a283.tar.gz bcm5719-llvm-00dba4f734d1fd64803a3ef16bc153ba63b6a283.zip | |
Re-apply the patch to improve the optimizations of memcpy's, with several
bugs fixed.  This now passes PPC bootstrap.
llvm-svn: 47026
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 42 | 
1 files changed, 41 insertions, 1 deletions
| diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 36c18f0c0b5..22c454fae15 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -457,6 +457,46 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,    return NonLocal;  } +/// dropInstruction - Remove an instruction from the analysis, making  +/// absolutely conservative assumptions when updating the cache.  This is +/// useful, for example when an instruction is changed rather than removed. +void MemoryDependenceAnalysis::dropInstruction(Instruction* drop) { +  depMapType::iterator depGraphEntry = depGraphLocal.find(drop); +  if (depGraphEntry != depGraphLocal.end()) +    reverseDep[depGraphEntry->second.first].erase(drop); +   +  // Drop dependency information for things that depended on this instr +  SmallPtrSet<Instruction*, 4>& set = reverseDep[drop]; +  for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end(); +       I != E; ++I) +    depGraphLocal.erase(*I); +   +  depGraphLocal.erase(drop); +  reverseDep.erase(drop); +   +  for (DenseMap<BasicBlock*, Value*>::iterator DI = +       depGraphNonLocal[drop].begin(), DE = depGraphNonLocal[drop].end(); +       DI != DE; ++DI) +    if (DI->second != None) +      reverseDepNonLocal[DI->second].erase(drop); +   +  if (reverseDepNonLocal.count(drop)) { +    SmallPtrSet<Instruction*, 4>& set = reverseDepNonLocal[drop]; +    for (SmallPtrSet<Instruction*, 4>::iterator I = set.begin(), E = set.end(); +         I != E; ++I) +      for (DenseMap<BasicBlock*, Value*>::iterator DI = +           depGraphNonLocal[*I].begin(), DE = depGraphNonLocal[*I].end(); +           DI != DE; ++DI) +        if (DI->second == drop) +          DI->second = Dirty; +  } +   +  reverseDepNonLocal.erase(drop); +  nonLocalDepMapType::iterator I = depGraphNonLocal.find(drop); +  if (I != depGraphNonLocal.end()) +    depGraphNonLocal.erase(I); +} +  /// removeInstruction - Remove an instruction from the dependence analysis,  /// updating the dependence of instructions that previously depended on it.  /// This method attempts to keep the cache coherent using the reverse map. @@ -473,7 +513,7 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction* rem) {    depMapType::iterator depGraphEntry = depGraphLocal.find(rem);    if (depGraphEntry != depGraphLocal.end()) { -    reverseDep[depGraphLocal[rem].first].erase(rem); +    reverseDep[depGraphEntry->second.first].erase(rem);      if (depGraphEntry->second.first != NonLocal &&          depGraphEntry->second.first != None && | 

