[llvm-commits] [poolalloc] r136714 - in /poolalloc/trunk/lib/DSA: DataStructureAA.cpp DataStructureOpt.cpp Steensgaard.cpp SteensgaardAA.cpp

John Criswell criswell at uiuc.edu
Tue Aug 2 12:34:11 PDT 2011


Author: criswell
Date: Tue Aug  2 14:34:11 2011
New Revision: 136714

URL: http://llvm.org/viewvc/llvm-project?rev=136714&view=rev
Log:
Remove the Steensgaard analysis, the DSA alias analysis, and the DSA
optimization passes.  As far as I know, no one is using them, and there's no
point in upgrading them to LLVM mainline if no one is using them.
Fear not, though, llvm-commits reader: with the power of Subversion, they can
return again in our time of greatest need.

Removed:
    poolalloc/trunk/lib/DSA/DataStructureAA.cpp
    poolalloc/trunk/lib/DSA/DataStructureOpt.cpp
    poolalloc/trunk/lib/DSA/Steensgaard.cpp
    poolalloc/trunk/lib/DSA/SteensgaardAA.cpp

Removed: poolalloc/trunk/lib/DSA/DataStructureAA.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureAA.cpp?rev=136713&view=auto
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructureAA.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructureAA.cpp (removed)
@@ -1,341 +0,0 @@
-//===- DataStructureAA.cpp - Data Structure Based Alias Analysis ----------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass uses the top-down data structure graphs to implement a simple
-// context sensitive alias analysis.
-//
-//===----------------------------------------------------------------------===//
-
-
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Module.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/Passes.h"
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
-using namespace llvm;
-
-namespace {
-  class DSAA : public ModulePass, public AliasAnalysis {
-    TDDataStructures *TD;
-    BUDataStructures *BU;
-
-    // These members are used to cache mod/ref information to make us return
-    // results faster, particularly for aa-eval.  On the first request of
-    // mod/ref information for a particular call site, we compute and store the
-    // calculated nodemap for the call site.  Any time DSA info is updated we
-    // free this information, and when we move onto a new call site, this
-    // information is also freed.
-    CallSite MapCS;
-    std::multimap<DSNode*, const DSNode*> CallerCalleeMap;
-    bool valid;
-  public:
-    static char ID;
-    DSAA() : ModulePass((intptr_t)&ID), TD(NULL), BU(NULL), valid(false) {}
-    ~DSAA() {
-      valid = false;
-      InvalidateCache();
-    }
-
-    void InvalidateCache() {
-      MapCS = CallSite();
-      CallerCalleeMap.clear();
-    }
-
-    //------------------------------------------------
-    // Implement the Pass API
-    //
-
-    // run - Build up the result graph, representing the pointer graph for the
-    // program.
-    //
-    bool runOnModule(Module &M) {
-      InitializeAliasAnalysis(this);
-      TD = &getAnalysis<TDDataStructures>();
-      BU = &getAnalysis<BUDataStructures>();
-      //FIXME: Is this not a safe assumption?
-      //assert(!valid && "DSAA executed twice without being invalidated?");
-      valid = true;
-      return false;
-    }
-
-
-    void releaseMemory() {
-      valid = false;
-      TD = NULL;
-      BU = NULL;
-      InvalidateCache();
-    }
-
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AliasAnalysis::getAnalysisUsage(AU);
-      AU.setPreservesAll();                         // Does not transform code
-      AU.addRequiredTransitive<TDDataStructures>(); // Uses TD Datastructures
-      AU.addRequiredTransitive<BUDataStructures>(); // Uses BU Datastructures
-    }
-
-    /// getAdjustedAnalysisPointer - This method is used when a pass implements
-    /// an analysis interface through multiple inheritance.  If needed, it
-    /// should override this to adjust the this pointer as needed for the
-    /// specified pass info.
-    virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-      if (PI->isPassID(&AliasAnalysis::ID))
-        return (AliasAnalysis*)this;
-      return this;
-    }
-
-    //------------------------------------------------
-    // Implement the AliasAnalysis API
-    //
-
-    AliasResult alias(const Value *V1, unsigned V1Size,
-                      const Value *V2, unsigned V2Size);
-
-    ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
-    ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
-      return AliasAnalysis::getModRefInfo(CS1,CS2);
-    }
-
-    virtual void deleteValue(Value *V) {
-      assert(valid && "DSAA invalidated but then queried?!");
-      InvalidateCache();
-      BU->deleteValue(V);
-      TD->deleteValue(V);
-      // FIXME: In the case that we chain to another ds-aa
-      // (and since we share the same TD/BU with that instance)
-      // we end up trying to delete the value twice.
-      // We *should* chain, but we also need to handle that case well.
-      //AliasAnalysis::deleteValue(V);
-    }
-
-    virtual void copyValue(Value *From, Value *To) {
-      assert(valid && "DSAA invalidated but then queried?!");
-      if (From == To) return;
-      InvalidateCache();
-      BU->copyValue(From, To);
-      TD->copyValue(From, To);
-      // FIXME: In the case that we chain to another ds-aa
-      // (and since we share the same TD/BU with that instance)
-      // we end up trying to copy the value twice.
-      // We *should* chain, but we also need to handle that case well.
-      //AliasAnalysis::copyValue(From, To);
-    }
-
-  private:
-    DSGraph *getGraphForValue(const Value *V);
-  };
-
-  // Register the pass...
-  RegisterPass<DSAA> X("ds-aa", "Data Structure Graph Based Alias Analysis");
-
-  // Register as an implementation of AliasAnalysis
-  RegisterAnalysisGroup<AliasAnalysis> Y(X);
-}
-
-char DSAA::ID;
-
-ModulePass *llvm::createDSAAPass() { return new DSAA(); }
-
-// getGraphForValue - Return the DSGraph to use for queries about the specified
-// value...
-//
-DSGraph *DSAA::getGraphForValue(const Value *V) {
-  if (const Instruction *I = dyn_cast<Instruction>(V))
-    return TD->getDSGraph(*I->getParent()->getParent());
-  else if (const Argument *A = dyn_cast<Argument>(V))
-    return TD->getDSGraph(*A->getParent());
-  else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V))
-    return TD->getDSGraph(*BB->getParent());
-  return 0;
-}
-
-AliasAnalysis::AliasResult DSAA::alias(const Value *V1, unsigned V1Size,
-                                       const Value *V2, unsigned V2Size) {
-  assert(valid && "DSAA invalidated but then queried?!");
-  if (V1 == V2) return MustAlias;
-
-  DSGraph *G1 = getGraphForValue(V1);
-  DSGraph *G2 = getGraphForValue(V2);
-  assert((!G1 || !G2 || G1 == G2) && "Alias query for 2 different functions?");
-
-  // Get the graph to use...
-  DSGraph* G = G1 ? G1 : (G2 ? G2 : TD->getGlobalsGraph());
-
-  const DSGraph::ScalarMapTy &GSM = G->getScalarMap();
-  DSGraph::ScalarMapTy::const_iterator I = GSM.find((Value*)V1);
-  if (I == GSM.end()) return NoAlias;
-
-  DSGraph::ScalarMapTy::const_iterator J = GSM.find((Value*)V2);
-  if (J == GSM.end()) return NoAlias;
-
-  DSNode  *N1 = I->second.getNode(),  *N2 = J->second.getNode();
-  unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset();
-  if (N1 == 0 || N2 == 0)
-    // Can't tell whether anything aliases null.
-    return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
-
-  // We can only make a judgment if one of the nodes is complete.
-  if (N1->isCompleteNode() || N2->isCompleteNode()) {
-    if (N1 != N2)
-      return NoAlias;   // Completely different nodes.
-
-    // See if they point to different offsets...  if so, we may be able to
-    // determine that they do not alias...
-    if (O1 != O2) {
-      if (O2 < O1) {    // Ensure that O1 <= O2
-        std::swap(V1, V2);
-        std::swap(O1, O2);
-        std::swap(V1Size, V2Size);
-      }
-
-      if (O1+V1Size <= O2)
-        return NoAlias;
-    }
-  }
-
-  // FIXME: we could improve on this by checking the globals graph for aliased
-  // global queries...
-  return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
-}
-
-/// getModRefInfo - does a callsite modify or reference a value?
-///
-AliasAnalysis::ModRefResult
-DSAA::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
-  assert(valid && "DSAA invalidated but then queried?!");
-  DSNode *N = 0;
-  // First step, check our cache.
-  if (CS.getInstruction() == MapCS.getInstruction()) {
-    {
-      const Function *Caller = CS.getInstruction()->getParent()->getParent();
-      DSGraph* CallerTDGraph = TD->getDSGraph(*Caller);
-
-      // Figure out which node in the TD graph this pointer corresponds to.
-      DSScalarMap &CallerSM = CallerTDGraph->getScalarMap();
-      DSScalarMap::iterator NI = CallerSM.find(P);
-      if (NI == CallerSM.end()) {
-        InvalidateCache();
-        return DSAA::getModRefInfo(CS, P, Size);
-      }
-      N = NI->second.getNode();
-    }
-
-  HaveMappingInfo:
-    assert(N && "Null pointer in scalar map??");
-
-    typedef std::multimap<DSNode*, const DSNode*>::iterator NodeMapIt;
-    std::pair<NodeMapIt, NodeMapIt> Range = CallerCalleeMap.equal_range(N);
-
-    // Loop over all of the nodes in the callee that correspond to "N", keeping
-    // track of aggregate mod/ref info.
-    bool NeverReads = true, NeverWrites = true;
-    for (; Range.first != Range.second; ++Range.first) {
-      if (Range.first->second->isModifiedNode())
-        NeverWrites = false;
-      if (Range.first->second->isReadNode())
-        NeverReads = false;
-      if (NeverReads == false && NeverWrites == false)
-        return AliasAnalysis::getModRefInfo(CS, P, Size);
-    }
-
-    ModRefResult Result = ModRef;
-    if (NeverWrites)      // We proved it was not modified.
-      Result = ModRefResult(Result & ~Mod);
-    if (NeverReads)       // We proved it was not read.
-      Result = ModRefResult(Result & ~Ref);
-
-    return ModRefResult(Result & AliasAnalysis::getModRefInfo(CS, P, Size));
-  }
-
-  // Any cached info we have is for the wrong function.
-  InvalidateCache();
-
-  Function *F = CS.getCalledFunction();
-
-  if (!F) return AliasAnalysis::getModRefInfo(CS, P, Size);
-
-  if (F->isDeclaration()) {
-    // If we are calling an external function, and if this global doesn't escape
-    // the portion of the program we have analyzed, we can draw conclusions
-    // based on whether the global escapes the program.
-    Function *Caller = CS.getInstruction()->getParent()->getParent();
-    DSGraph *G = TD->getDSGraph(*Caller);
-    DSScalarMap::iterator NI = G->getScalarMap().find(P);
-    if (NI == G->getScalarMap().end()) {
-      // If it wasn't in the local function graph, check the global graph.  This
-      // can occur for globals who are locally reference but hoisted out to the
-      // globals graph despite that.
-      G = G->getGlobalsGraph();
-      NI = G->getScalarMap().find(P);
-      if (NI == G->getScalarMap().end())
-        return AliasAnalysis::getModRefInfo(CS, P, Size);
-    }
-
-    // If we found a node and it's complete, it cannot be passed out to the
-    // called function.
-    if (NI->second.getNode()->isCompleteNode())
-      return NoModRef;
-    return AliasAnalysis::getModRefInfo(CS, P, Size);
-  }
-
-  // Get the graphs for the callee and caller.  Note that we want the BU graph
-  // for the callee because we don't want all caller's effects incorporated!
-  const Function *Caller = CS.getInstruction()->getParent()->getParent();
-  DSGraph* CallerTDGraph = TD->getDSGraph(*Caller);
-  DSGraph* CalleeBUGraph = BU->getDSGraph(*F);
-
-  // Figure out which node in the TD graph this pointer corresponds to.
-  DSScalarMap &CallerSM = CallerTDGraph->getScalarMap();
-  DSScalarMap::iterator NI = CallerSM.find(P);
-  if (NI == CallerSM.end()) {
-    ModRefResult Result = ModRef;
-    if (isa<ConstantPointerNull>(P) || isa<UndefValue>(P))
-      return NoModRef;                 // null is never modified :)
-    else {
-      assert(isa<GlobalVariable>(P) &&
-    cast<GlobalVariable>(P)->getType()->getElementType()->isFirstClassType() &&
-             "This isn't a global that DSA inconsiderately dropped "
-             "from the graph?");
-
-      DSGraph* GG = CallerTDGraph->getGlobalsGraph();
-      DSScalarMap::iterator NI = GG->getScalarMap().find(P);
-      if (NI != GG->getScalarMap().end() && !NI->second.isNull()) {
-        // Otherwise, if the node is only M or R, return this.  This can be
-        // useful for globals that should be marked const but are not.
-        DSNode *N = NI->second.getNode();
-        if (!N->isModifiedNode())
-          Result = (ModRefResult)(Result & ~Mod);
-        if (!N->isReadNode())
-          Result = (ModRefResult)(Result & ~Ref);
-      }
-    }
-
-    if (Result == NoModRef) return Result;
-    return ModRefResult(Result & AliasAnalysis::getModRefInfo(CS, P, Size));
-  }
-
-  // Compute the mapping from nodes in the callee graph to the nodes in the
-  // caller graph for this call site.
-  DSGraph::NodeMapTy CalleeCallerMap;
-  DSCallSite DSCS = CallerTDGraph->getDSCallSiteForCallSite(CS);
-  CallerTDGraph->computeCalleeCallerMapping(DSCS, *F, *CalleeBUGraph,
-                                            CalleeCallerMap);
-
-  // Remember the mapping and the call site for future queries.
-  MapCS = CS;
-
-  // Invert the mapping into CalleeCallerInvMap.
-  for (DSGraph::NodeMapTy::iterator I = CalleeCallerMap.begin(),
-         E = CalleeCallerMap.end(); I != E; ++I)
-    CallerCalleeMap.insert(std::make_pair(I->second.getNode(), I->first));
-
-  N = NI->second.getNode();
-  goto HaveMappingInfo;
-}

Removed: poolalloc/trunk/lib/DSA/DataStructureOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureOpt.cpp?rev=136713&view=auto
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructureOpt.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructureOpt.cpp (removed)
@@ -1,107 +0,0 @@
-//===- DataStructureOpt.cpp - Data Structure Analysis Based Optimizations -===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass uses DSA to a series of simple optimizations, like marking
-// unwritten global variables 'constant'.
-//
-//===----------------------------------------------------------------------===//
-
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
-#include "llvm/Analysis/Passes.h"
-#include "llvm/Module.h"
-#include "llvm/Constant.h"
-#include "llvm/Constants.h"
-#include "llvm/Type.h"
-#include "llvm/ADT/Statistic.h"
-#include "llvm/Support/Debug.h"
-using namespace llvm;
-
-namespace {
-  STATISTIC (NumGlobalsConstanted, "Number of globals marked constant");
-  STATISTIC (NumGlobalsIsolated, "Number of globals with references dropped");
-
-  class DSOpt : public ModulePass {
-    TDDataStructures *TD;
-  public:
-    static char ID;
-    DSOpt() : ModulePass((intptr_t)&ID) {};
-
-    bool runOnModule(Module &M) {
-      TD = &getAnalysis<TDDataStructures>();
-      bool Changed = OptimizeGlobals(M);
-      return Changed;
-    }
-
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.addRequired<TDDataStructures>();      // Uses TD Datastructures
-      AU.addPreserved<LocalDataStructures>();  // Preserves local...
-      AU.addPreserved<TDDataStructures>();     // Preserves bu...
-      AU.addPreserved<BUDataStructures>();     // Preserves td...
-    }
-
-  private:
-    bool OptimizeGlobals(Module &M);
-  };
-
-  RegisterPass<DSOpt> X("ds-opt", "DSA-based simple optimizations");
-}
-
-char DSOpt::ID;
-
-ModulePass *llvm::createDSOptPass() { return new DSOpt(); }
-
-/// OptimizeGlobals - This method uses information taken from DSA to optimize
-/// global variables.
-///
-bool DSOpt::OptimizeGlobals(Module &M) {
-  DSGraph* GG = TD->getGlobalsGraph();
-  const DSGraph::ScalarMapTy &SM = GG->getScalarMap();
-  bool Changed = false;
-
-  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
-    if (!I->isDeclaration()) { // Loop over all of the non-external globals...
-      // Look up the node corresponding to this global, if it exists.
-      DSNode *GNode = 0;
-      DSGraph::ScalarMapTy::const_iterator SMI = SM.find(I);
-      if (SMI != SM.end()) GNode = SMI->second.getNode();
-
-      if (GNode == 0 && I->hasInternalLinkage()) {
-        // If there is no entry in the scalar map for this global, it was never
-        // referenced in the program.  If it has internal linkage, that means we
-        // can delete it.  We don't ACTUALLY want to delete the global, just
-        // remove anything that references the global: later passes will take
-        // care of nuking it.
-        if (!I->use_empty()) {
-          I->replaceAllUsesWith(ConstantPointerNull::get(I->getType()));
-          ++NumGlobalsIsolated;
-        }
-      } else if (GNode && GNode->isCompleteNode()) {
-
-        // If the node has not been read or written, and it is not externally
-        // visible, kill any references to it so it can be DCE'd.
-        if (!GNode->isModifiedNode() && !GNode->isReadNode() &&I->hasInternalLinkage()){
-          if (!I->use_empty()) {
-            I->replaceAllUsesWith(ConstantPointerNull::get(I->getType()));
-            ++NumGlobalsIsolated;
-          }
-        }
-
-        // We expect that there will almost always be a node for this global.
-        // If there is, and the node doesn't have the M bit set, we can set the
-        // 'constant' bit on the global.
-        if (!GNode->isModifiedNode() && !I->isConstant()) {
-          I->setConstant(true);
-          ++NumGlobalsConstanted;
-          Changed = true;
-        }
-      }
-    }
-  return Changed;
-}

Removed: poolalloc/trunk/lib/DSA/Steensgaard.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Steensgaard.cpp?rev=136713&view=auto
==============================================================================
--- poolalloc/trunk/lib/DSA/Steensgaard.cpp (original)
+++ poolalloc/trunk/lib/DSA/Steensgaard.cpp (removed)
@@ -1,182 +0,0 @@
-//===- Steensgaard.cpp - Context Insensitive Data Structure Analysis ------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass computes a context-insensitive data analysis graph.  It does this
-// by computing the local analysis graphs for all of the functions, then merging
-// them together into a single big graph without cloning.
-//
-//===----------------------------------------------------------------------===//
-
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/Passes.h"
-#include "llvm/Module.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/FormattedStream.h"
-#include <ostream>
-
-using namespace llvm;
-
-SteensgaardDataStructures::~SteensgaardDataStructures() { }
-
-void
-SteensgaardDataStructures::releaseMemory() {
-  delete ResultGraph; 
-  ResultGraph = 0;
-  DataStructures::releaseMemory();
-}
-
-// print - Implement the Pass::print method...
-void
-SteensgaardDataStructures::print(llvm::raw_ostream &O, const Module *M) const {
-  assert(ResultGraph && "Result graph has not yet been computed!");
-  ResultGraph->writeGraphToFile(O, "steensgaards");
-}
-
-/// run - Build up the result graph, representing the pointer graph for the
-/// program.
-///
-bool
-SteensgaardDataStructures::runOnModule(Module &M) {
-  DS = &getAnalysis<StdLibDataStructures>();
-  init(&getAnalysis<TargetData>());
-  return runOnModuleInternal(M);
-}
-
-bool
-SteensgaardDataStructures::runOnModuleInternal(Module &M) {
-  assert(ResultGraph == 0 && "Result graph already allocated!");
-  
-  // Get a copy for the globals graph.
-  DSGraph * GG = DS->getGlobalsGraph();
-  GlobalsGraph = new DSGraph(GG, GG->getGlobalECs(), *TypeSS);
-
-  // Create a new, empty, graph...
-  ResultGraph = new DSGraph(GG->getGlobalECs(), getTargetData(), *TypeSS);
-  ResultGraph->setGlobalsGraph(GlobalsGraph);
-  // ResultGraph->spliceFrom(DS->getGlobalsGraph());
-
-  
-  // Loop over the rest of the module, merging graphs for non-external functions
-  // into this graph.
-  //
-  for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
-    if (!I->isDeclaration()) {
-      ResultGraph->spliceFrom(DS->getDSGraph(*I));
-    }
-  }
-
-  ResultGraph->removeTriviallyDeadNodes();
-  ResultGraph->maskIncompleteMarkers();
-  ResultGraph->markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals);
-
-  // Now that we have all of the graphs inlined, we can go about eliminating
-  // call nodes...
-  //
-
-  // Start with a copy of the original call sites.
-  std::list<DSCallSite> & Calls = ResultGraph->getFunctionCalls();
-
-  for (std::list<DSCallSite>::iterator CI = Calls.begin(), E = Calls.end();
-       CI != E;) {
-    DSCallSite &CurCall = *CI++;
-
-    // Loop over the called functions, eliminating as many as possible...
-    std::vector<const Function*> CallTargets;
-    if (CurCall.isDirectCall())
-      CallTargets.push_back(CurCall.getCalleeFunc());
-    else
-      CurCall.getCalleeNode()->addFullFunctionList(CallTargets);
-
-    for (unsigned c = 0; c != CallTargets.size(); ) {
-      // If we can eliminate this function call, do so!
-      const Function *F = CallTargets[c];
-      if (!F->isDeclaration()) {
-        ResolveFunctionCall(F, CurCall, ResultGraph->getReturnNodes()[F]);
-        CallTargets[c] = CallTargets.back();
-        CallTargets.pop_back();
-      } else
-        ++c;  // Cannot eliminate this call, skip over it...
-    }
-
-    if (CallTargets.empty()) {        // Eliminated all calls?
-      std::list<DSCallSite>::iterator I = CI;
-      Calls.erase(--I);               // Remove entry
-    }
-  }
-
-  // Remove our knowledge of what the return values of the functions are, except
-  // for functions that are externally visible from this module (e.g. main).  We
-  // keep these functions so that their arguments are marked incomplete.
-  for (DSGraph::ReturnNodesTy::iterator I =
-         ResultGraph->getReturnNodes().begin(),
-         E = ResultGraph->getReturnNodes().end(); I != E; )
-    if (I->first->hasInternalLinkage())
-      ResultGraph->getReturnNodes().erase(I++);
-    else
-      ++I;
-
-  // Update the "incomplete" markers on the nodes, ignoring unknownness due to
-  // incoming arguments...
-  ResultGraph->maskIncompleteMarkers();
-  ResultGraph->markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals);
-
-  // Remove any nodes that are dead after all of the merging we have done...
-
-  ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
-
-  GlobalsGraph->removeTriviallyDeadNodes();
-  GlobalsGraph->maskIncompleteMarkers();
-
-  // Mark external globals incomplete.
-  GlobalsGraph->markIncompleteNodes(DSGraph::IgnoreGlobals);
-
-  formGlobalECs();
-
-  // Clone the global nodes into this graph.
-  cloneGlobalsInto(ResultGraph, DSGraph::DontCloneCallNodes |
-                              DSGraph::DontCloneAuxCallNodes);
-
-  DEBUG(print(errs(), &M));
-  return false;
-}
-
-/// ResolveFunctionCall - Resolve the actual arguments of a call to function F
-/// with the specified call site descriptor.  This function links the arguments
-/// and the return value for the call site context-insensitively.
-///
-void
-SteensgaardDataStructures::ResolveFunctionCall(const Function *F, 
-                                                const DSCallSite &Call,
-                                                DSNodeHandle &RetVal) {
-
-  assert(ResultGraph != 0 && "Result graph not allocated!");
-  DSGraph::ScalarMapTy &ValMap = ResultGraph->getScalarMap();
-
-  // Handle the return value of the function...
-  if (Call.getRetVal().getNode() && RetVal.getNode())
-    RetVal.mergeWith(Call.getRetVal());
-
-  // Loop over all pointer arguments, resolving them to their provided pointers
-  unsigned PtrArgIdx = 0;
-  for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
-       AI != AE && PtrArgIdx < Call.getNumPtrArgs(); ++AI) {
-    DSGraph::ScalarMapTy::iterator I = ValMap.find(AI);
-    if (I != ValMap.end())    // If its a pointer argument...
-      I->second.mergeWith(Call.getPtrArg(PtrArgIdx++));
-  }
-}
-
-char SteensgaardDataStructures::ID = 0;
-
-// Register the pass...
-static RegisterPass<SteensgaardDataStructures> X
-("dsa-steens",
- "Context-insensitive Data Structure Analysis");

Removed: poolalloc/trunk/lib/DSA/SteensgaardAA.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/SteensgaardAA.cpp?rev=136713&view=auto
==============================================================================
--- poolalloc/trunk/lib/DSA/SteensgaardAA.cpp (original)
+++ poolalloc/trunk/lib/DSA/SteensgaardAA.cpp (removed)
@@ -1,162 +0,0 @@
-//===- Steensgaard.cpp - Context Insensitive Alias Analysis ---------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass uses the data structure graphs to implement a simple context
-// insensitive alias analysis.  It does this by computing the local analysis
-// graphs for all of the functions, then merging them together into a single big
-// graph without cloning.
-//
-//===----------------------------------------------------------------------===//
-
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/Passes.h"
-#include "llvm/Module.h"
-#include "llvm/Support/Debug.h"
-#include <ostream>
-using namespace llvm;
-
-namespace {
-  class Steens : public ModulePass, public AliasAnalysis {
-    DSGraph * ResultGraph;
-  public:
-    static char ID;
-    Steens() : ModulePass((intptr_t)&ID), ResultGraph(NULL) {}
-    ~Steens() {    }
-
-    //------------------------------------------------
-    // Implement the Pass API
-    //
-
-    // run - Build up the result graph, representing the pointer graph for the
-    // program.
-    //
-    bool runOnModule(Module &M);
-
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AliasAnalysis::getAnalysisUsage(AU);
-      AU.setPreservesAll();                    // Does not transform code...
-      AU.addRequired<SteensgaardDataStructures>();   // Uses steensgaard dsgraph
-    }
-
-    //------------------------------------------------
-    // Implement the AliasAnalysis API
-    //
-
-    AliasResult alias(const Value *V1, unsigned V1Size,
-                      const Value *V2, unsigned V2Size);
-
-    virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
-    virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2);
-
-  };
-
-  // Register the pass...
-  RegisterPass<Steens> X("steens-aa",
-                         "Steensgaard's alias analysis (DSGraph based)");
-
-  // Register as an implementation of AliasAnalysis
-  RegisterAnalysisGroup<AliasAnalysis> Y(X);
-}
-
-char Steens::ID;
-
-ModulePass *llvm::createSteensgaardPass() { return new Steens(); }
-
-/// run - Build up the result graph, representing the pointer graph for the
-/// program.
-///
-bool Steens::runOnModule(Module &M) {
-  InitializeAliasAnalysis(this);
-  ResultGraph = getAnalysis<SteensgaardDataStructures>().getResultGraph();
-  return false;
-}
-
-AliasAnalysis::AliasResult Steens::alias(const Value *V1, unsigned V1Size,
-                                         const Value *V2, unsigned V2Size) {
-  assert(ResultGraph && "Result graph has not been computed yet!");
-
-  DSGraph::ScalarMapTy &GSM = ResultGraph->getScalarMap();
-
-  DSGraph::ScalarMapTy::iterator I = GSM.find(const_cast<Value*>(V1));
-  DSGraph::ScalarMapTy::iterator J = GSM.find(const_cast<Value*>(V2));
-  if (I != GSM.end() && !I->second.isNull() &&
-      J != GSM.end() && !J->second.isNull()) {
-    DSNodeHandle &V1H = I->second;
-    DSNodeHandle &V2H = J->second;
-
-    // If at least one of the nodes is complete, we can say something about
-    // this.  If one is complete and the other isn't, then they are obviously
-    // different nodes.  If they are both complete, we can't say anything
-    // useful.
-    if (I->second.getNode()->isCompleteNode() ||
-        J->second.getNode()->isCompleteNode()) {
-      // If the two pointers point to different data structure graph nodes, they
-      // cannot alias!
-      if (V1H.getNode() != V2H.getNode())
-        return NoAlias;
-
-      // See if they point to different offsets...  if so, we may be able to
-      // determine that they do not alias...
-      unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset();
-      if (O1 != O2) {
-        if (O2 < O1) {    // Ensure that O1 <= O2
-          std::swap(V1, V2);
-          std::swap(O1, O2);
-          std::swap(V1Size, V2Size);
-        }
-
-        if (O1+V1Size <= O2)
-          return NoAlias;
-      }
-    }
-  }
-
-  // If we cannot determine alias properties based on our graph, fall back on
-  // some other AA implementation.
-  //
-  return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
-}
-
-AliasAnalysis::ModRefResult
-Steens::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
-  AliasAnalysis::ModRefResult Result = ModRef;
-
-  // Find the node in question.
-  DSGraph::ScalarMapTy &GSM = ResultGraph->getScalarMap();
-  DSGraph::ScalarMapTy::iterator I = GSM.find(P);
-
-  if (I != GSM.end() && !I->second.isNull()) {
-    DSNode *N = I->second.getNode();
-    if (N->isCompleteNode()) {
-      // If this is a direct call to an external function, and if the pointer
-      // points to a complete node, the external function cannot modify or read
-      // the value (we know it's not passed out of the program!).
-      if (Function *F = CS.getCalledFunction())
-        if (F->isDeclaration())
-          return NoModRef;
-
-      // Otherwise, if the node is complete, but it is only M or R, return this.
-      // This can be useful for globals that should be marked const but are not.
-      if (!N->isModifiedNode())
-        Result = (ModRefResult)(Result & ~Mod);
-      if (!N->isReadNode())
-        Result = (ModRefResult)(Result & ~Ref);
-    }
-  }
-
-  return (ModRefResult)(Result & AliasAnalysis::getModRefInfo(CS, P, Size));
-}
-
-AliasAnalysis::ModRefResult 
-Steens::getModRefInfo(CallSite CS1, CallSite CS2)
-{
-  return AliasAnalysis::getModRefInfo(CS1,CS2);
-}





More information about the llvm-commits mailing list