In the TD pass, don't iterate over the scalar map to find the globals, iterate over
[oota-llvm.git] / lib / Analysis / DataStructure / Parallelize.cpp
index e78386740290ca97e5e9e025f0fc20609be9b071..e22c86cb7fe47bedfe6d22b6ff291529d8fed247 100644 (file)
@@ -1,4 +1,11 @@
 //===- Parallelize.cpp - Auto parallelization using DS Graphs -------------===//
+// 
+//                     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 file implements a pass that automatically parallelizes a program,
 // using the Cilk multi-threaded runtime system to execute parallel code.
 
 #include "llvm/Transforms/Utils/DemoteRegToStack.h"
 #include "llvm/Analysis/PgmDependenceGraph.h"
-#include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/DataStructure.h"
 #include "llvm/Analysis/DSGraph.h"
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
-#include "llvm/iTerminators.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Support/InstVisitor.h"
 #include "Support/Statistic.h"
 #include "Support/hash_map"
 #include <functional>
 #include <algorithm>
-
-
-
-#if 0
-void AddToDomSet(vector<BasicBlock*>& domSet, BasicBlock* bb,
-                 const DominatorTree& domTree)
-{
-  DominatorTreeBase::Node* bbNode = domTree.getNode(bb);
-  const std::vector<Node*>& domKids = bbNode.getChildren();
-  domSet.insert(domSet.end(), domKids.begin(), domKids.end());
-  for (unsigned i = 0; i < domKids.size(); ++i)
-    AddToDomSet(domSet, domKids[i]->getNode(), domTree);
-}
-
-bool CheckDominance(Function& func,
-                    const CallInst& callInst1,
-                    const CallInst& callInst2)
-{
-  if (callInst1 == callInst2)           // makes sense if this is in a loop but
-    return false;                       // we're not handling loops yet
-
-  // Check first if one call dominates the other
-  DominatorSet& domSet = getAnalysis<DominatorSet>(func);
-  if (domSet.dominates(callInst2, callInst1))
-    { // swap callInst1 and callInst2
-      const CallInst& tmp = callInst2; callInst2 = callInst1; callInst1 = tmp;
-    }
-  else if (! domSet.dominates(callInst1, callInst2))
-    return false;                       // neither dominates the other: 
-
-  // 
-  if (! AreIndependent(func, callInst1, callInst2))
-    return false;
-}
-
-#endif
-
+using namespace llvm;
 
 //---------------------------------------------------------------------------- 
 // Global constants used in marking Cilk functions and function calls.
@@ -120,7 +89,7 @@ static bool isSync(const CallInst& CI) {
 // class Cilkifier
 //
 // Code generation pass that transforms code to identify where Cilk keywords
-// should be inserted.  This relies on dis -c to print out the keywords.
+// should be inserted.  This relies on `llvm-dis -c' to print out the keywords.
 //---------------------------------------------------------------------------- 
 
 
@@ -206,7 +175,7 @@ void Cilkifier::DFSVisitInstr(Instruction* I,
       else
         syncI = new CallInst(DummySyncFunc, std::vector<Value*>(), "", I);
 
-      // Remember the sync for each spawn to eliminate rendundant ones later
+      // Remember the sync for each spawn to eliminate redundant ones later
       spawnToSyncsMap[cast<CallInst>(root)].insert(syncI);
 
       return;
@@ -533,7 +502,7 @@ bool Parallelize::run(Module& M)
 
 #undef CAN_USE_BIND1ST_ON_REFERENCE_TYPE_ARGS
 #ifdef CAN_USE_BIND1ST_ON_REFERENCE_TYPE_ARGS
-  // Use this undecipherable STLese because erase invalidates iterators.
+  // Use this indecipherable STLese because erase invalidates iterators.
   // Otherwise we have to copy sets as above.
   hash_set<Function*>::iterator extrasBegin = 
     std::remove_if(parallelFunctions.begin(), parallelFunctions.end(),
@@ -567,3 +536,4 @@ bool Parallelize::run(Module& M)
 
   return true;
 }
+