[llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp

2007-06-07 Thread Zhou Sheng


Changes in directory llvm/lib/VMCore:

Verifier.cpp updated: 1.212 - 1.213
---
Log message:

Add assert to check if the attributes ZExt/SExt, NoAlias are apply to the
correct type of parameters.


---
Diffs of the changes:  (+15 -0)

 Verifier.cpp |   15 +++
 1 files changed, 15 insertions(+)


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.212 llvm/lib/VMCore/Verifier.cpp:1.213
--- llvm/lib/VMCore/Verifier.cpp:1.212  Wed May  2 20:11:54 2007
+++ llvm/lib/VMCore/Verifier.cppThu Jun  7 01:12:03 2007
@@ -46,6 +46,7 @@
 #include llvm/Pass.h
 #include llvm/Module.h
 #include llvm/ModuleProvider.h
+#include llvm/ParameterAttributes.h
 #include llvm/DerivedTypes.h
 #include llvm/InlineAsm.h
 #include llvm/Instructions.h
@@ -358,6 +359,20 @@
FT-getNumParams()  0  isaPointerType(FT-getParamType(0))),
   Invalid struct-return function!, F);
 
+  if (const ParamAttrsList *Attrs = FT-getParamAttrs()) {
+unsigned Idx = 1;
+for (FunctionType::param_iterator I = FT-param_begin(), 
+ E = FT-param_end(); I != E; ++I, ++Idx) {
+  if (Attrs-paramHasAttr(Idx, ParamAttr::ZExt) ||
+  Attrs-paramHasAttr(Idx, ParamAttr::SExt))
+Assert1(FT-getParamType(Idx-1)-isInteger(),
+Attribute ZExt should only apply to Integer type!, F);
+  if (Attrs-paramHasAttr(Idx, ParamAttr::NoAlias))
+Assert1(isaPointerType(FT-getParamType(Idx-1)),
+Attribute NoAlias should only apply to Pointer type!, F);
+}
+  }
+
   // Check that this function meets the restrictions on this calling 
convention.
   switch (F.getCallingConv()) {
   default:



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/Transforms/IPO/InlineSimple.cpp

2007-06-07 Thread Duncan Sands
Missing spaces after if:

 +  if(GV == 0)

 +  if(InitList == 0)

 +if(const Function *f = dyn_castFunction(Elt))

Also, in this last if you call the function f but I guess
F would be more consistent.

Ciao,

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/IfConversion.cpp

2007-06-07 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

IfConversion.cpp updated: 1.35 - 1.36
---
Log message:

ifcvt a triangle: don't merge ifcvt block with rejoin block if it can fall 
through to it. If merged, the resulting block is not a candidate for iterative 
ifcvting since it contains both predicated and non-predicated code.

---
Diffs of the changes:  (+29 -17)

 IfConversion.cpp |   46 +-
 1 files changed, 29 insertions(+), 17 deletions(-)


Index: llvm/lib/CodeGen/IfConversion.cpp
diff -u llvm/lib/CodeGen/IfConversion.cpp:1.35 
llvm/lib/CodeGen/IfConversion.cpp:1.36
--- llvm/lib/CodeGen/IfConversion.cpp:1.35  Wed Jun  6 21:12:15 2007
+++ llvm/lib/CodeGen/IfConversion.cpp   Thu Jun  7 03:13:00 2007
@@ -615,29 +615,41 @@
   BBInfo FalseBBI = BBAnalysis[BBI.FalseBB-getNumber()];
   bool FalseBBDead = false;
   bool IterIfcvt = true;
-  if (!HasEarlyExit  FalseBBI.BB-pred_size() == 2) {
-MergeBlocks(TrueBBI, FalseBBI);
-FalseBBDead = true;
-  } else if (!isNextBlock(TrueBBI.BB, FalseBBI.BB)) {
-InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII);
-TrueBBI.hasFallThrough = false;
-if (BBI.ModifyPredicate || TrueBBI.ModifyPredicate)
-  // Now ifcvt'd block will look like this:
-  // BB:
-  // ...
-  // t, f = cmp
-  // if t op
-  // b BBf
-  //
-  // We cannot further ifcvt this block because the unconditional branch 
will
-  // have to be predicated on the new condition, that will not be available
-  // if cmp executes.
+  bool isFallThrough = isNextBlock(TrueBBI.BB, FalseBBI.BB);
+  if (!isFallThrough) {
+// Only merge them if the true block does not fallthrough to the false
+// block. By not merging them, we make it possible to iteratively
+// ifcvt the blocks.
+if (!HasEarlyExit  FalseBBI.BB-pred_size() == 2) {
+  MergeBlocks(TrueBBI, FalseBBI);
+  FalseBBDead = true;
+  // Mixed predicated and unpredicated code. This cannot be iteratively
+  // predicated.
   IterIfcvt = false;
+} else {
+  InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII);
+  TrueBBI.hasFallThrough = false;
+  if (BBI.ModifyPredicate || TrueBBI.ModifyPredicate)
+// Now ifcvt'd block will look like this:
+// BB:
+// ...
+// t, f = cmp
+// if t op
+// b BBf
+//
+// We cannot further ifcvt this block because the unconditional branch 
will
+// have to be predicated on the new condition, that will not be 
available
+// if cmp executes.
+IterIfcvt = false;
+}
   }
 
   // Now merge the entry of the triangle with the true block.
   BBI.NonPredSize -= TII-RemoveBranch(*BBI.BB);
   MergeBlocks(BBI, TrueBBI);
+  // Remove entry to false edge.
+  if (BBI.BB-isSuccessor(FalseBBI.BB))
+BBI.BB-removeSuccessor(FalseBBI.BB);
   std::copy(BBI.BrCond.begin(), BBI.BrCond.end(),
 std::back_inserter(BBI.Predicate));
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/test/C++Frontend/2007-05-23-TryFinally.cpp

2007-06-07 Thread Duncan Sands


Changes in directory llvm/test/C++Frontend:

2007-05-23-TryFinally.cpp updated: 1.1 - 1.2
---
Log message:

Make this test pass if llvm-g++ was built without exception handling support.


---
Diffs of the changes:  (+1 -1)

 2007-05-23-TryFinally.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/test/C++Frontend/2007-05-23-TryFinally.cpp
diff -u llvm/test/C++Frontend/2007-05-23-TryFinally.cpp:1.1 
llvm/test/C++Frontend/2007-05-23-TryFinally.cpp:1.2
--- llvm/test/C++Frontend/2007-05-23-TryFinally.cpp:1.1 Wed May 30 05:16:19 2007
+++ llvm/test/C++Frontend/2007-05-23-TryFinally.cpp Thu Jun  7 04:00:48 2007
@@ -1,4 +1,4 @@
-// RUN: %llvmgxx %s -S -emit-llvm -O2 -o - | grep _Unwind_Resume | wc -l | 
grep {\[03\]}
+// RUN: %llvmgxx %s -S -emit-llvm -O2 -o - | grep -c {handle\\|_Unwind_Resume} 
| grep {\[14\]}
 
 struct One { };
 struct Two { };



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/test/CFrontend/2007-05-07-NestedStructReturn.c

2007-06-07 Thread Duncan Sands


Changes in directory llvm/test/CFrontend:

2007-05-07-NestedStructReturn.c updated: 1.1 - 1.2
---
Log message:

Make the struct bigger, in an attempt to get a struct return on more
platforms.


---
Diffs of the changes:  (+1 -1)

 2007-05-07-NestedStructReturn.c |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/test/CFrontend/2007-05-07-NestedStructReturn.c
diff -u llvm/test/CFrontend/2007-05-07-NestedStructReturn.c:1.1 
llvm/test/CFrontend/2007-05-07-NestedStructReturn.c:1.2
--- llvm/test/CFrontend/2007-05-07-NestedStructReturn.c:1.1 Wed May  9 
03:41:26 2007
+++ llvm/test/CFrontend/2007-05-07-NestedStructReturn.c Thu Jun  7 04:35:33 2007
@@ -1,6 +1,6 @@
 // RUN: %llvmgcc %s -S -fnested-functions -o - | grep {sret *%agg.result}
 
-struct X { int m, n; };
+struct X { int m, n, o, p; };
 
 struct X p(int n) {
   struct X c(int m) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/docs/WritingAnLLVMPass.html

2007-06-07 Thread Tanya Lattner


Changes in directory llvm/docs:

WritingAnLLVMPass.html updated: 1.61 - 1.62
---
Log message:

Correct typo. Should be not allowed


---
Diffs of the changes:  (+2 -2)

 WritingAnLLVMPass.html |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/docs/WritingAnLLVMPass.html
diff -u llvm/docs/WritingAnLLVMPass.html:1.61 
llvm/docs/WritingAnLLVMPass.html:1.62
--- llvm/docs/WritingAnLLVMPass.html:1.61   Fri May 18 00:38:44 2007
+++ llvm/docs/WritingAnLLVMPass.htmlThu Jun  7 11:44:52 2007
@@ -537,7 +537,7 @@
 li... emnot allowed/em to modify any ttFunction/tts that are not in
 the current SCC./li
 
-li... emallowed/em to inspect any Function's other than those in the
+li... emnot allowed/em to inspect any Function's other than those in the
 current SCC and the direct callees of the SCC./li
 
 li... emrequired/em to preserve the current CallGraph object, updating it
@@ -1809,7 +1809,7 @@
 
   a href=mailto:[EMAIL PROTECTED]Chris Lattner/abr
   a href=http://llvm.org;The LLVM Compiler Infrastructure/abr
-  Last modified: $Date: 2007/05/18 05:38:44 $
+  Last modified: $Date: 2007/06/07 16:44:52 $
 /address
 
 /body



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/IPO/InlineSimple.cpp

2007-06-07 Thread Tanya Lattner


Changes in directory llvm/lib/Transforms/IPO:

InlineSimple.cpp updated: 1.84 - 1.85
---
Log message:

Formating fixes.


---
Diffs of the changes:  (+4 -4)

 InlineSimple.cpp |8 
 1 files changed, 4 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/IPO/InlineSimple.cpp
diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.84 
llvm/lib/Transforms/IPO/InlineSimple.cpp:1.85
--- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.84   Wed Jun  6 16:59:26 2007
+++ llvm/lib/Transforms/IPO/InlineSimple.cppThu Jun  7 12:12:16 2007
@@ -291,12 +291,12 @@
   // Get llvm.noinline
   GlobalVariable *GV = M.getNamedGlobal(llvm.noinline);
   
-  if(GV == 0)
+  if (GV == 0)
 return false;
 
   const ConstantArray *InitList = 
dyn_castConstantArray(GV-getInitializer());
   
-  if(InitList == 0)
+  if (InitList == 0)
 return false;
 
   // Iterate over each element and add to the NeverInline set
@@ -310,8 +310,8 @@
 Elt = CE-getOperand(0);
 
 // Insert into set of functions to never inline
-if(const Function *f = dyn_castFunction(Elt))
-  NeverInline.insert(f);
+if (const Function *F = dyn_castFunction(Elt))
+  NeverInline.insert(F);
   }
   
   return false;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/Transforms/IPO/InlineSimple.cpp

2007-06-07 Thread Tanya Lattner
Fixed.

Thanks!
-Tanya

On Jun 7, 2007, at 12:14 AM, Duncan Sands wrote:

 Missing spaces after if:

 +  if(GV == 0)

 +  if(InitList == 0)

 +if(const Function *f = dyn_castFunction(Elt))

 Also, in this last if you call the function f but I guess
 F would be more consistent.

 Ciao,

 Duncan.
 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

2007-06-07 Thread Devang Patel
Nick,

On Jun 6, 2007, at 7:19 PM, Nick Lewycky wrote:

 Predicate simplifier uses this to get the DFS nums for a BB. We also
 pass around ETNode*s to avoid having a lot of functions doing BB- 
 ETNode
 lookups.

I am not familiar with predicate simplifier implementation, but why do  
such look ups ?

I am exploring the idea to make ETNode completely private unless there  
is a good reason.  Usually, a transformation needs dominance info,
it does not matter whether ETNode or DomTreeNode or SomeOtherNode is  
used as part of DomTree or ETForest or SomeJungle to get that info.

 Similarly with updateDFSNumbers. More than a performance issue, if the
 DFS nums aren't up to date predsimplify will crash (and if it didn't
 crash it wouldn't work; it needs correct DFS nums). I spoke with Dan
 Berlin about it and he says that there's no guarantee that the DFS  
 nums
 will be up to date upon entry to a pass, so I call it there.

If you're interested then the simple way is to invoke  
updateDFSNumbers() after each pass that claims that it preserves dom  
info.

-
Devang


 I'm open to suggestions.

 Nick

 Devang Patel wrote:
 +// FIXME : There is no need to make getNodeForBlock public. Fix
 +// predicate simplifier.
 ETNode *ETForest::getNodeForBlock(BasicBlock *BB) {
   ETNode *BBNode = Nodes[BB];
   if (BBNode) return BBNode;
 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

2007-06-07 Thread Nick Lewycky
Devang Patel wrote:
 On Jun 6, 2007, at 7:19 PM, Nick Lewycky wrote:
 
Predicate simplifier uses this to get the DFS nums for a BB. We also
pass around ETNode*s to avoid having a lot of functions doing BB- 

ETNode

lookups.
 
 I am not familiar with predicate simplifier implementation, but why do  
 such look ups ?
 
 I am exploring the idea to make ETNode completely private unless there  
 is a good reason.  Usually, a transformation needs dominance info,
 it does not matter whether ETNode or DomTreeNode or SomeOtherNode is  
 used as part of DomTree or ETForest or SomeJungle to get that info.

The data structure that predsimplify really needs is a dominator tree
with depth first search numberings on every block. Currently we simulate
that by combining both the DominatorTree and ETForest passes.

I chose what gets passed around based on performance. For example, if
you need both a BasicBlock * and a DominatorTree::Node, pass the DTNode
around because you can convert it to the BB in O(1) while converting a
BB to DTNode takes a map lookup.

Similarly, I pass ETNodes around to functions that don't care about
which BB is actually involved, but do need the DFS numbers for whatever
reason.

This is very pervasive; in my dev tree, ETNode is mentioned in 38 lines
of code in predsimplify, mostly function parameters. Six lines of code
do lookups turning blocks into ETNodes. If we passed around BasicBlock*
instead, there would need to be an additional 32 places that perform
BB-ETNode lookups. One of those would be inside the comparison operator
used to sort some vectors. In other words, it would almost certainly be
a performance disaster.

Similarly with updateDFSNumbers. More than a performance issue, if the
DFS nums aren't up to date predsimplify will crash (and if it didn't
crash it wouldn't work; it needs correct DFS nums). I spoke with Dan
Berlin about it and he says that there's no guarantee that the DFS  
nums
will be up to date upon entry to a pass, so I call it there.
 
 If you're interested then the simple way is to invoke  
 updateDFSNumbers() after each pass that claims that it preserves dom  
 info.

Ok. Passes that don't access DFS numbers directly (every pass except
predsimplify) would take a small performance hit as ETForest updates the
numberings. That doesn't make it wrong though.

Nick
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Analysis:

Dominators.h updated: 1.92 - 1.93
---
Log message:

Maintain ETNode as part of DomTreeNode. 
This adds redundancy for now.


---
Diffs of the changes:  (+60 -24)

 Dominators.h |   84 ++-
 1 files changed, 60 insertions(+), 24 deletions(-)


Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.92 
llvm/include/llvm/Analysis/Dominators.h:1.93
--- llvm/include/llvm/Analysis/Dominators.h:1.92Tue Jun  5 19:59:48 2007
+++ llvm/include/llvm/Analysis/Dominators.h Thu Jun  7 12:47:21 2007
@@ -63,6 +63,7 @@
 class DomTreeNode {
   BasicBlock *TheBB;
   DomTreeNode *IDom;
+  ETNode *ETN;
   std::vectorDomTreeNode* Children;
 public:
   typedef std::vectorDomTreeNode*::iterator iterator;
@@ -75,28 +76,14 @@
   
   inline BasicBlock *getBlock() const { return TheBB; }
   inline DomTreeNode *getIDom() const { return IDom; }
+  inline ETNode *getETNode() const { return ETN; }
   inline const std::vectorDomTreeNode* getChildren() const { return 
Children; }
   
-  /// properlyDominates - Returns true iff this dominates N and this != N.
-  /// Note that this is not a constant time operation!
-  ///
-  bool properlyDominates(const DomTreeNode *N) const {
-const DomTreeNode *IDom;
-if (this == 0 || N == 0) return false;
-while ((IDom = N-getIDom()) != 0  IDom != this)
-  N = IDom;   // Walk up the tree
-return IDom != 0;
-  }
-  
-  /// dominates - Returns true iff this dominates N.  Note that this is not a
-  /// constant time operation!
-  ///
-  inline bool dominates(const DomTreeNode *N) const {
-if (N == this) return true;  // A node trivially dominates itself.
-return properlyDominates(N);
+  inline DomTreeNode(BasicBlock *BB, DomTreeNode *iDom, ETNode *E) 
+: TheBB(BB), IDom(iDom), ETN(E) {
+if (IDom)
+  ETN-setFather(IDom-getETNode());
   }
-  
-  inline DomTreeNode(BasicBlock *BB, DomTreeNode *iDom) : TheBB(BB), 
IDom(iDom) {}
   inline DomTreeNode *addChild(DomTreeNode *C) { Children.push_back(C); return 
C; }
   void setIDom(DomTreeNode *NewIDom);
 };
@@ -107,12 +94,16 @@
 class DominatorTreeBase : public DominatorBase {
 
 protected:
-  std::mapBasicBlock*, DomTreeNode* DomTreeNodes;
   void reset();
   typedef std::mapBasicBlock*, DomTreeNode* DomTreeNodeMapType;
-
+  DomTreeNodeMapType DomTreeNodes;
   DomTreeNode *RootNode;
 
+  typedef std::mapBasicBlock*, ETNode* ETMapType;
+  ETMapType ETNodes;
+
+  bool DFSInfoValid;
+  unsigned int SlowQueries;
   // Information record used during immediate dominators computation.
   struct InfoRec {
 unsigned Semi;
@@ -134,7 +125,7 @@
 
   public:
   DominatorTreeBase(intptr_t ID, bool isPostDom) 
-: DominatorBase(ID, isPostDom) {}
+: DominatorBase(ID, isPostDom), DFSInfoValid(false), SlowQueries(0) {}
   ~DominatorTreeBase() { reset(); }
 
   virtual void releaseMemory() { reset(); }
@@ -161,6 +152,47 @@
   DomTreeNode *getRootNode() { return RootNode; }
   const DomTreeNode *getRootNode() const { return RootNode; }
 
+  /// properlyDominates - Returns true iff this dominates N and this != N.
+  /// Note that this is not a constant time operation!
+  ///
+  bool properlyDominates(const DomTreeNode *A, DomTreeNode *B) const {
+if (A == 0 || B == 0) return false;
+return dominatedBySlowTreeWalk(A, B);
+  }
+
+  bool dominatedBySlowTreeWalk(const DomTreeNode *A, 
+   const DomTreeNode *B) const {
+const DomTreeNode *IDom;
+if (A == 0 || B == 0) return false;
+while ((IDom = B-getIDom()) != 0  IDom != A)
+  B = IDom;   // Walk up the tree
+return IDom != 0;
+  }
+
+  void updateDFSNumbers();  
+  /// dominates - Returns true iff this dominates N.  Note that this is not a
+  /// constant time operation!
+  ///
+  inline bool dominates(const DomTreeNode *A, DomTreeNode *B) {
+if (B == A) return true;  // A node trivially dominates itself.
+
+ETNode *NodeA = A-getETNode();
+ETNode *NodeB = B-getETNode();
+
+if (DFSInfoValid)
+  return NodeB-DominatedBy(NodeA);
+
+// If we end up with too many slow queries, just update the
+// DFS numbers on the theory that we are going to keep querying.
+SlowQueries++;
+if (SlowQueries  32) {
+  updateDFSNumbers();
+  return NodeB-DominatedBy(NodeA);
+}
+//return NodeB-DominatedBySlow(NodeA);
+return dominatedBySlowTreeWalk(A, B);
+  }
+  
   
//======//
   // API to update (Post)DominatorTree information based on modifications to
   // the CFG...
@@ -172,7 +204,11 @@
 assert(getNode(BB) == 0  Block already in dominator tree!);
 DomTreeNode *IDomNode = getNode(DomBB);
 assert(IDomNode  Not immediate dominator specified for block!);
-return DomTreeNodes[BB] = IDomNode-addChild(new DomTreeNode(BB, 
IDomNode));
+DFSInfoValid = 

[llvm-commits] CVS: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp LCSSA.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Utils:

BreakCriticalEdges.cpp updated: 1.51 - 1.52
LCSSA.cpp updated: 1.45 - 1.46
---
Log message:

Maintain ETNode as part of DomTreeNode. 
This adds redundancy for now.


---
Diffs of the changes:  (+2 -2)

 BreakCriticalEdges.cpp |2 +-
 LCSSA.cpp  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
diff -u llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.51 
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.52
--- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.51   Mon Jun  4 
11:43:25 2007
+++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cppThu Jun  7 12:47:21 2007
@@ -217,7 +217,7 @@
 DestBBNode = DT-getNode(DestBB);
 while (!OtherPreds.empty()  NewBBDominatesDestBB) {
   if (DomTreeNode *OPNode = DT-getNode(OtherPreds.back()))
-NewBBDominatesDestBB = DestBBNode-dominates(OPNode);
+NewBBDominatesDestBB = DT-dominates(DestBBNode, OPNode);
   OtherPreds.pop_back();
 }
 OtherPreds.clear();


Index: llvm/lib/Transforms/Utils/LCSSA.cpp
diff -u llvm/lib/Transforms/Utils/LCSSA.cpp:1.45 
llvm/lib/Transforms/Utils/LCSSA.cpp:1.46
--- llvm/lib/Transforms/Utils/LCSSA.cpp:1.45Sun Jun  3 19:32:22 2007
+++ llvm/lib/Transforms/Utils/LCSSA.cpp Thu Jun  7 12:47:21 2007
@@ -157,7 +157,7 @@
 BasicBlock *BB = *BBI;
 DomTreeNode *ExitBBNode = DT-getNode(BB);
 Value *Phi = Phis[ExitBBNode];
-if (!Phi  InstrNode-dominates(ExitBBNode)) {
+if (!Phi  DT-dominates(InstrNode, ExitBBNode)) {
   PHINode *PN = new PHINode(Instr-getType(), Instr-getName()+.lcssa,
 BB-begin());
   PN-reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Analysis/PostDominators.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Analysis:

PostDominators.cpp updated: 1.72 - 1.73
---
Log message:

Maintain ETNode as part of DomTreeNode. 
This adds redundancy for now.


---
Diffs of the changes:  (+24 -4)

 PostDominators.cpp |   28 
 1 files changed, 24 insertions(+), 4 deletions(-)


Index: llvm/lib/Analysis/PostDominators.cpp
diff -u llvm/lib/Analysis/PostDominators.cpp:1.72 
llvm/lib/Analysis/PostDominators.cpp:1.73
--- llvm/lib/Analysis/PostDominators.cpp:1.72   Sun Jun  3 19:32:21 2007
+++ llvm/lib/Analysis/PostDominators.cppThu Jun  7 12:47:21 2007
@@ -165,7 +165,9 @@
   // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0)
   // which postdominates all real exits if there are multiple exit blocks.
   BasicBlock *Root = Roots.size() == 1 ? Roots[0] : 0;
-  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0);
+  ETNode *ERoot = new ETNode(Root);
+  ETNodes[Root] = ERoot;
+  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0, ERoot);
   
   // Loop over all of the reachable blocks in the function...
   for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
@@ -177,7 +179,11 @@
 
 // Add a new tree node for this BasicBlock, and link it as a child of
 // IDomNode
-BBNode = IPDomNode-addChild(new DomTreeNode(I, IPDomNode));
+ETNode *ET = new ETNode(I);
+ETNodes[I] = ET;
+DomTreeNode *C = new DomTreeNode(I, IPDomNode, ET);
+DomTreeNodes[I] = C;
+BBNode = IPDomNode-addChild(C);
   }
 }
 
@@ -185,6 +191,16 @@
   IDoms.clear();
   Info.clear();
   std::vectorBasicBlock*().swap(Vertex);
+
+  int dfsnum = 0;
+  // Iterate over all nodes in depth first order...
+  for (unsigned i = 0, e = Roots.size(); i != e; ++i)
+for (idf_iteratorBasicBlock* I = idf_begin(Roots[i]),
+   E = idf_end(Roots[i]); I != E; ++I) {
+  if (!getNodeForBlock(*I)-getETNode()-hasFather())
+getNodeForBlock(*I)-getETNode()-assignDFSNumber(dfsnum);
+}
+  DFSInfoValid = true;
 }
 
 
@@ -199,7 +215,11 @@
   
   // Add a new tree node for this BasicBlock, and link it as a child of
   // IDomNode
-  return BBNode = IPDomNode-addChild(new DomTreeNode(BB, IPDomNode));
+  ETNode *ET = new ETNode(BB);
+  ETNodes[BB] = ET;
+  DomTreeNode *C = new DomTreeNode(BB, IPDomNode, ET);
+  DomTreeNodes[BB] = C;
+  return BBNode = IPDomNode-addChild(C);
 }
 
 
//===--===//
@@ -303,7 +323,7 @@
 
 DomSetType::const_iterator CDFI = ChildDF.begin(), CDFE = ChildDF.end();
 for (; CDFI != CDFE; ++CDFI) {
-  if (!Node-properlyDominates(DT[*CDFI]))
+  if (!DT.properlyDominates(Node, DT[*CDFI]))
 S.insert(*CDFI);
 }
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/VMCore:

Dominators.cpp updated: 1.106 - 1.107
---
Log message:

Maintain ETNode as part of DomTreeNode. 
This adds redundancy for now.


---
Diffs of the changes:  (+38 -5)

 Dominators.cpp |   43 ++-
 1 files changed, 38 insertions(+), 5 deletions(-)


Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.106 
llvm/lib/VMCore/Dominators.cpp:1.107
--- llvm/lib/VMCore/Dominators.cpp:1.106Wed Jun  6 15:08:11 2007
+++ llvm/lib/VMCore/Dominators.cpp  Thu Jun  7 12:47:21 2007
@@ -233,8 +233,11 @@
 
 void DominatorTree::calculate(Function F) {
   BasicBlock* Root = Roots[0];
-  
-  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0); // Add a node for 
the root...
+
+  // Add a node for the root...
+  ETNode *ERoot = new ETNode(Root);
+  ETNodes[Root] = ERoot;
+  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0, ERoot);
 
   Vertex.push_back(0);
 
@@ -289,7 +292,9 @@
 
 // Add a new tree node for this BasicBlock, and link it as a child of
 // IDomNode
-DomTreeNode *C = new DomTreeNode(I, IDomNode);
+ETNode *ET = new ETNode(I);
+ETNodes[I] = ET;
+DomTreeNode *C = new DomTreeNode(I, IDomNode, ET);
 DomTreeNodes[I] = C;
 BBNode = IDomNode-addChild(C);
   }
@@ -299,8 +304,27 @@
   Info.clear();
   IDoms.clear();
   std::vectorBasicBlock*().swap(Vertex);
+
+  updateDFSNumbers();
+}
+
+void DominatorTreeBase::updateDFSNumbers()
+{
+  int dfsnum = 0;
+  // Iterate over all nodes in depth first order.
+  for (unsigned i = 0, e = Roots.size(); i != e; ++i)
+for (df_iteratorBasicBlock* I = df_begin(Roots[i]),
+   E = df_end(Roots[i]); I != E; ++I) {
+  BasicBlock *BB = *I;
+  ETNode *ETN = getNode(BB)-getETNode();
+  if (ETN  !ETN-hasFather())
+ETN-assignDFSNumber(dfsnum);
+  }
+  SlowQueries = 0;
+  DFSInfoValid = true;
 }
 
+
 // DominatorTreeBase::reset - Free all of the tree node memory.
 //
 void DominatorTreeBase::reset() {
@@ -326,6 +350,13 @@
 // Switch to new dominator
 IDom = NewIDom;
 IDom-Children.push_back(this);
+
+if (!ETN-hasFather())
+  ETN-setFather(IDom-getETNode());
+else if (ETN-getFather()-getDataBasicBlock() != IDom-getBlock()) {
+ETN-Split();
+ETN-setFather(IDom-getETNode());
+}
   }
 }
 
@@ -340,7 +371,9 @@
 
   // Add a new tree node for this BasicBlock, and link it as a child of
   // IDomNode
-  DomTreeNode *C = new DomTreeNode(BB, IDomNode);
+  ETNode *ET = new ETNode(BB);
+  ETNodes[BB] = ET;
+  DomTreeNode *C = new DomTreeNode(BB, IDomNode, ET);
   DomTreeNodes[BB] = C;
   return BBNode = IDomNode-addChild(C);
 }
@@ -463,7 +496,7 @@
   DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
   DomSetType parentSet = Frontiers[parentBB];
   for (; CDFI != CDFE; ++CDFI) {
-if (!parentNode-properlyDominates(DT[*CDFI]))
+if (!DT.properlyDominates(parentNode, DT[*CDFI]))
   parentSet.insert(*CDFI);
   }
   workList.pop_back();



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Analysis:

Dominators.h updated: 1.93 - 1.94
---
Log message:

Add BasicBlock level dominates(A,B) interface.


---
Diffs of the changes:  (+14 -2)

 Dominators.h |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.93 
llvm/include/llvm/Analysis/Dominators.h:1.94
--- llvm/include/llvm/Analysis/Dominators.h:1.93Thu Jun  7 12:47:21 2007
+++ llvm/include/llvm/Analysis/Dominators.h Thu Jun  7 13:39:40 2007
@@ -170,11 +170,16 @@
   }
 
   void updateDFSNumbers();  
+
   /// dominates - Returns true iff this dominates N.  Note that this is not a
   /// constant time operation!
   ///
   inline bool dominates(const DomTreeNode *A, DomTreeNode *B) {
-if (B == A) return true;  // A node trivially dominates itself.
+if (B == A) 
+  return true;  // A node trivially dominates itself.
+
+if (A == 0 || B == 0)
+  return false;
 
 ETNode *NodeA = A-getETNode();
 ETNode *NodeB = B-getETNode();
@@ -192,7 +197,14 @@
 //return NodeB-DominatedBySlow(NodeA);
 return dominatedBySlowTreeWalk(A, B);
   }
-  
+
+  inline bool dominates(BasicBlock *A, BasicBlock *B) {
+if (A == B) 
+  return true;
+
+return dominates(getNode(A), getNode(B));
+  }
+
   
//======//
   // API to update (Post)DominatorTree information based on modifications to
   // the CFG...



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GCSE.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Scalar:

GCSE.cpp updated: 1.59 - 1.60
---
Log message:

Use DominatorTree instead of ETForest.


---
Diffs of the changes:  (+3 -3)

 GCSE.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/Scalar/GCSE.cpp
diff -u llvm/lib/Transforms/Scalar/GCSE.cpp:1.59 
llvm/lib/Transforms/Scalar/GCSE.cpp:1.60
--- llvm/lib/Transforms/Scalar/GCSE.cpp:1.59Sun Jun  3 19:32:21 2007
+++ llvm/lib/Transforms/Scalar/GCSE.cpp Thu Jun  7 13:40:55 2007
@@ -68,9 +68,9 @@
   bool Changed = false;
 
   // Get pointers to the analysis results that we will be using...
-  ETForest EF = getAnalysisETForest();
-  ValueNumbering VN = getAnalysisValueNumbering();
   DominatorTree DT = getAnalysisDominatorTree();
+  ETForest ET = getAnalysisETForest();
+  ValueNumbering VN = getAnalysisValueNumbering();
 
   std::vectorValue* EqualValues;
 
@@ -145,7 +145,7 @@
 if (OtherI-getParent() == BB)
   Dominates = BlockInsts.count(OtherI);
 else
-  Dominates = EF.dominates(OtherI-getParent(), BB);
+  Dominates = ET.dominates(OtherI-getParent(), BB);
 
 if (Dominates) {
   // Okay, we found an instruction with the same value as this one



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GCSE.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Scalar:

GCSE.cpp updated: 1.60 - 1.61
---
Log message:

Use DominatorTree instead of ETForest.



---
Diffs of the changes:  (+1 -3)

 GCSE.cpp |4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)


Index: llvm/lib/Transforms/Scalar/GCSE.cpp
diff -u llvm/lib/Transforms/Scalar/GCSE.cpp:1.60 
llvm/lib/Transforms/Scalar/GCSE.cpp:1.61
--- llvm/lib/Transforms/Scalar/GCSE.cpp:1.60Thu Jun  7 13:40:55 2007
+++ llvm/lib/Transforms/Scalar/GCSE.cpp Thu Jun  7 13:45:06 2007
@@ -48,7 +48,6 @@
 // This transformation requires dominator and immediate dominator info
 virtual void getAnalysisUsage(AnalysisUsage AU) const {
   AU.setPreservesCFG();
-  AU.addRequiredETForest();
   AU.addRequiredDominatorTree();
   AU.addRequiredValueNumbering();
 }
@@ -69,7 +68,6 @@
 
   // Get pointers to the analysis results that we will be using...
   DominatorTree DT = getAnalysisDominatorTree();
-  ETForest ET = getAnalysisETForest();
   ValueNumbering VN = getAnalysisValueNumbering();
 
   std::vectorValue* EqualValues;
@@ -145,7 +143,7 @@
 if (OtherI-getParent() == BB)
   Dominates = BlockInsts.count(OtherI);
 else
-  Dominates = ET.dominates(OtherI-getParent(), BB);
+  Dominates = DT.dominates(OtherI-getParent(), BB);
 
 if (Dominates) {
   // Okay, we found an instruction with the same value as this one



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

2007-06-07 Thread Devang Patel

On Jun 7, 2007, at 10:46 AM, Nick Lewycky wrote:

 Devang Patel wrote:
 On Jun 6, 2007, at 7:19 PM, Nick Lewycky wrote:

 Predicate simplifier uses this to get the DFS nums for a BB. We also
 pass around ETNode*s to avoid having a lot of functions doing BB-

 ETNode

 lookups.

 I am not familiar with predicate simplifier implementation, but why  
 do
 such look ups ?

 I am exploring the idea to make ETNode completely private unless  
 there
 is a good reason.  Usually, a transformation needs dominance info,
 it does not matter whether ETNode or DomTreeNode or SomeOtherNode is
 used as part of DomTree or ETForest or SomeJungle to get that info.

 The data structure that predsimplify really needs is a dominator tree
 with depth first search numberings on every block. Currently we  
 simulate
 that by combining both the DominatorTree and ETForest passes.

 I chose what gets passed around based on performance. For example, if
 you need both a BasicBlock * and a DominatorTree::Node, pass the  
 DTNode
 around because you can convert it to the BB in O(1) while converting a
 BB to DTNode takes a map lookup.

 Similarly, I pass ETNodes around to functions that don't care about
 which BB is actually involved, but do need the DFS numbers for  
 whatever
 reason.

In that case what's the use of ETNode ?

 This is very pervasive; in my dev tree, ETNode is mentioned in 38  
 lines
 of code in predsimplify, mostly function parameters. Six lines of code
 do lookups turning blocks into ETNodes. If we passed around  
 BasicBlock*
 instead, there would need to be an additional 32 places that perform
 BB-ETNode lookups. One of those would be inside the comparison  
 operator
 used to sort some vectors. In other words, it would almost certainly  
 be
 a performance disaster.

 Similarly with updateDFSNumbers. More than a performance issue, if  
 the
 DFS nums aren't up to date predsimplify will crash (and if it didn't
 crash it wouldn't work; it needs correct DFS nums). I spoke with Dan
 Berlin about it and he says that there's no guarantee that the DFS
 nums
 will be up to date upon entry to a pass, so I call it there.

 If you're interested then the simple way is to invoke
 updateDFSNumbers() after each pass that claims that it preserves dom
 info.

 Ok. Passes that don't access DFS numbers directly (every pass except
 predsimplify) would take a small performance hit as ETForest updates  
 the
 numberings. That doesn't make it wrong though.

IMO, cost is part of promise I'm preserving info. We do not want to  
go in
the direction of preserving info partially, which is the case if DFS  
numbers are
out of sync at the end of a pass.

-
Devang

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

2007-06-07 Thread Nick Lewycky
Devang Patel wrote:
 On Jun 7, 2007, at 10:46 AM, Nick Lewycky wrote:
Similarly, I pass ETNodes around to functions that don't care about
which BB is actually involved, but do need the DFS numbers for  
whatever reason.
 
 In that case what's the use of ETNode ?

The DFS numbers. ETNode is the only way to see what the DFS in and DFS
out numbers are.

At a conceptual level, those numbers uniquely identify the scope and are
used in determining which InequalityGraph properties (also stored
per-ETNode) apply by comparing them for dominance, using the DFS numbers.

Yes we could pass BBs around and modify ETForest to return DFS numbers
from BBs directly, but it would probably be too slow.

 IMO, cost is part of promise I'm preserving info. We do not want to  
 go in
 the direction of preserving info partially, which is the case if DFS  
 numbers are
 out of sync at the end of a pass.

Sounds good to me.

Nick
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

2007-06-07 Thread Dale Johannesen


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.457 - 1.458
---
Log message:

Do not change the size of function arguments.  PR 1489: http://llvm.org/PR1489 .


---
Diffs of the changes:  (+9 -1)

 SelectionDAGISel.cpp |   10 +-
 1 files changed, 9 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.457 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.458
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.457Wed Jun  6 
05:05:18 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Thu Jun  7 16:07:15 2007
@@ -3993,7 +3993,15 @@
 Op = DAG.getNode(ExtOp, getTypeToTransformTo(VT), Op);
   } else {
 assert(MVT::isFloatingPoint(VT)  Not int or FP?);
-Op = DAG.getNode(ISD::FP_EXTEND, getTypeToTransformTo(VT), Op);
+// A true promotion would change the size of the argument.
+// Instead, pretend this is an int.  If FP objects are not
+// passed the same as ints, the original type should be Legal
+// and we should not get here.
+Op = DAG.getNode(ISD::BIT_CONVERT, 
+ VT==MVT::f32 ? MVT::i32 :
+ (VT==MVT::f64 ? MVT::i64 :
+  MVT::Other),
+ Op);
   }
   Ops.push_back(Op);
   Ops.push_back(DAG.getConstant(Flags, MVT::i32));



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Scalar:

CorrelatedExprs.cpp updated: 1.63 - 1.64
---
Log message:

Use DominatorTree instead of ETForest.



---
Diffs of the changes:  (+25 -23)

 CorrelatedExprs.cpp |   48 +---
 1 files changed, 25 insertions(+), 23 deletions(-)


Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp
diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.63 
llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.64
--- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.63 Mon Jun  4 18:45:02 2007
+++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp  Thu Jun  7 16:35:27 2007
@@ -223,7 +223,7 @@
   class VISIBILITY_HIDDEN CEE : public FunctionPass {
 std::mapValue*, unsigned RankMap;
 std::mapBasicBlock*, RegionInfo RegionInfoMap;
-ETForest *EF;
+DominatorTree *DT;
   public:
 static char ID; // Pass identification, replacement for typeid
 CEE() : FunctionPass((intptr_t)ID) {}
@@ -232,7 +232,7 @@
 
 // We don't modify the program, so we preserve all analyses
 virtual void getAnalysisUsage(AnalysisUsage AU) const {
-  AU.addRequiredETForest();
+  AU.addRequiredDominatorTree();
   AU.addRequiredID(BreakCriticalEdgesID);
 };
 
@@ -304,7 +304,7 @@
   // Traverse the dominator tree, computing information for each node in the
   // tree.  Note that our traversal will not even touch unreachable basic
   // blocks.
-  EF = getAnalysisETForest();
+  DT = getAnalysisDominatorTree();
 
   std::setBasicBlock* VisitedBlocks;
   bool Changed = TransformRegion(F.getEntryBlock(), VisitedBlocks);
@@ -351,14 +351,14 @@
   // blocks that are dominated by this one, we can safely propagate the
   // information down now.
   //
-  std::vectorBasicBlock* children;
-  EF-getETNodeChildren(BB, children);
+  DomTreeNode *BBDom = DT-getNode(BB);
   if (!RI.empty()) { // Time opt: only propagate if we can change something
-for (std::vectorBasicBlock*::iterator CI = children.begin(), 
- E = children.end(); CI != E; ++CI) {
-  assert(RegionInfoMap.find(*CI) == RegionInfoMap.end() 
+for (std::vectorDomTreeNode*::iterator DI = BBDom-begin(),
+   E = BBDom-end(); DI != E; ++DI) {
+  BasicBlock *ChildBB = (*DI)-getBlock();
+  assert(RegionInfoMap.find(ChildBB) == RegionInfoMap.end() 
  RegionInfo should be calculated in dominanace order!);
-  getRegionInfo(*CI) = RI;
+  getRegionInfo(ChildBB) = RI;
 }
   }
 
@@ -383,9 +383,11 @@
 }
 
   // Now that all of our successors have information, recursively process them.
-  for (std::vectorBasicBlock*::iterator CI = children.begin(), 
-   E = children.end(); CI != E; ++CI)
-Changed |= TransformRegion(*CI, VisitedBlocks);
+  for (std::vectorDomTreeNode*::iterator DI = BBDom-begin(),
+ E = BBDom-end(); DI != E; ++DI) {
+BasicBlock *ChildBB = (*DI)-getBlock();
+Changed |= TransformRegion(ChildBB, VisitedBlocks);
+  }
 
   return Changed;
 }
@@ -552,7 +554,7 @@
   // insert dead phi nodes, but it is more trouble to see if they are used than
   // to just blindly insert them.
   //
-  if (EF-dominates(OldSucc, Dest)) {
+  if (DT-dominates(OldSucc, Dest)) {
 // RegionExitBlocks - Find all of the blocks that are not dominated by 
Dest,
 // but have predecessors that are.  Additionally, prune down the set to 
only
 // include blocks that are dominated by OldSucc as well.
@@ -652,7 +654,7 @@
   for (Value::use_iterator I = Orig-use_begin(), E = Orig-use_end();
I != E; ++I)
 if (Instruction *User = dyn_castInstruction(*I))
-  if (EF-dominates(RegionDominator, User-getParent()))
+  if (DT-dominates(RegionDominator, User-getParent()))
 InstsToChange.push_back(User);
   else if (PHINode *PN = dyn_castPHINode(User)) {
 PHIsToChange.push_back(PN);
@@ -665,7 +667,7 @@
 PHINode *PN = PHIsToChange[i];
 for (unsigned j = 0, e = PN-getNumIncomingValues(); j != e; ++j)
   if (PN-getIncomingValue(j) == Orig 
-  EF-dominates(RegionDominator, PN-getIncomingBlock(j)))
+  DT-dominates(RegionDominator, PN-getIncomingBlock(j)))
 PN-setIncomingValue(j, New);
   }
 
@@ -679,7 +681,7 @@
   // values that correspond to basic blocks in the region.
   for (unsigned j = 0, e = PN-getNumIncomingValues(); j != e; ++j)
 if (PN-getIncomingValue(j) == Orig 
-EF-dominates(RegionDominator, PN-getIncomingBlock(j)))
+DT-dominates(RegionDominator, PN-getIncomingBlock(j)))
   PN-setIncomingValue(j, New);
 
 } else {
@@ -689,14 +691,14 @@
 
 static void CalcRegionExitBlocks(BasicBlock *Header, BasicBlock *BB,
  std::setBasicBlock* Visited,
- ETForest EF,
+ DominatorTree DT,
  std::vectorBasicBlock* RegionExitBlocks) {
   if (Visited.count(BB)) return;
   Visited.insert(BB);
 

[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.139 - 1.140
---
Log message:

Use DominatorTree instead of ETForest.


---
Diffs of the changes:  (+7 -8)

 LoopStrengthReduce.cpp |   15 +++
 1 files changed, 7 insertions(+), 8 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.139 
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.140
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.139 Tue Jun  5 
20:23:55 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp   Thu Jun  7 16:42:15 2007
@@ -111,7 +111,7 @@
 
   class VISIBILITY_HIDDEN LoopStrengthReduce : public LoopPass {
 LoopInfo *LI;
-ETForest *EF;
+DominatorTree *DT;
 ScalarEvolution *SE;
 const TargetData *TD;
 const Type *UIntPtrTy;
@@ -156,13 +156,12 @@
   // many analyses if they are around.
   AU.addPreservedID(LoopSimplifyID);
   AU.addPreservedLoopInfo();
-  AU.addPreservedETForest();
   AU.addPreservedDominanceFrontier();
   AU.addPreservedDominatorTree();
 
   AU.addRequiredID(LoopSimplifyID);
   AU.addRequiredLoopInfo();
-  AU.addRequiredETForest();
+  AU.addRequiredDominatorTree();
   AU.addRequiredTargetData();
   AU.addRequiredScalarEvolution();
 }
@@ -353,7 +352,7 @@
 /// the loop, resulting in reg-reg copies (if we use the pre-inc value when we
 /// should use the post-inc value).
 static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV,
-   Loop *L, ETForest *EF, Pass *P) {
+   Loop *L, DominatorTree *DT, Pass *P) {
   // If the user is in the loop, use the preinc value.
   if (L-contains(User-getParent())) return false;
   
@@ -361,7 +360,7 @@
   
   // Ok, the user is outside of the loop.  If it is dominated by the latch
   // block, use the post-inc value.
-  if (EF-dominates(LatchBlock, User-getParent()))
+  if (DT-dominates(LatchBlock, User-getParent()))
 return true;
 
   // There is one case we have to be careful of: PHI nodes.  These little guys
@@ -378,7 +377,7 @@
   for (unsigned i = 0, e = PN-getNumIncomingValues(); i != e; ++i)
 if (PN-getIncomingValue(i) == IV) {
   ++NumUses;
-  if (!EF-dominates(LatchBlock, PN-getIncomingBlock(i)))
+  if (!DT-dominates(LatchBlock, PN-getIncomingBlock(i)))
 return false;
 }
 
@@ -456,7 +455,7 @@
   // Okay, we found a user that we cannot reduce.  Analyze the instruction
   // and decide what to do with it.  If we are a use inside of the loop, 
use
   // the value before incrementation, otherwise use it after 
incrementation.
-  if (IVUseShouldUsePostIncValue(User, I, L, EF, this)) {
+  if (IVUseShouldUsePostIncValue(User, I, L, DT, this)) {
 // The value used will be incremented by the stride more than we are
 // expecting, so subtract this off.
 SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);
@@ -1400,7 +1399,7 @@
 bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager LPM) {
 
   LI = getAnalysisLoopInfo();
-  EF = getAnalysisETForest();
+  DT = getAnalysisDominatorTree();
   SE = getAnalysisScalarEvolution();
   TD = getAnalysisTargetData();
   UIntPtrTy = TD-getIntPtrType();



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Transforms/Utils/FunctionUtils.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Transforms/Utils:

FunctionUtils.h updated: 1.11 - 1.12
---
Log message:

Do not use ETForest as well as DomiantorTree.  DominatorTree is sufficient.


---
Diffs of the changes:  (+2 -2)

 FunctionUtils.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/Transforms/Utils/FunctionUtils.h
diff -u llvm/include/llvm/Transforms/Utils/FunctionUtils.h:1.11 
llvm/include/llvm/Transforms/Utils/FunctionUtils.h:1.12
--- llvm/include/llvm/Transforms/Utils/FunctionUtils.h:1.11 Sat Apr  7 
02:17:27 2007
+++ llvm/include/llvm/Transforms/Utils/FunctionUtils.h  Thu Jun  7 17:17:16 2007
@@ -24,13 +24,13 @@
 
   /// ExtractCodeRegion - rip out a sequence of basic blocks into a new 
function
   ///
-  Function* ExtractCodeRegion(ETForest DS, DominatorTree DT,
+  Function* ExtractCodeRegion(DominatorTree DT,
   const std::vectorBasicBlock* code,
   bool AggregateArgs = false);
 
   /// ExtractLoop - rip out a natural loop into a new function
   ///
-  Function* ExtractLoop(ETForest DS, DominatorTree DT, Loop *L,
+  Function* ExtractLoop(DominatorTree DT, Loop *L,
 bool AggregateArgs = false);
 
   /// ExtractBasicBlock - rip out a basic block into a new function



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/IPO/LoopExtractor.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/IPO:

LoopExtractor.cpp updated: 1.28 - 1.29
---
Log message:

Do not use ETForest as well as DomiantorTree.  DominatorTree is sufficient.


---
Diffs of the changes:  (+3 -5)

 LoopExtractor.cpp |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/IPO/LoopExtractor.cpp
diff -u llvm/lib/Transforms/IPO/LoopExtractor.cpp:1.28 
llvm/lib/Transforms/IPO/LoopExtractor.cpp:1.29
--- llvm/lib/Transforms/IPO/LoopExtractor.cpp:1.28  Sun May  6 08:37:16 2007
+++ llvm/lib/Transforms/IPO/LoopExtractor.cpp   Thu Jun  7 17:17:16 2007
@@ -45,7 +45,6 @@
 virtual void getAnalysisUsage(AnalysisUsage AU) const {
   AU.addRequiredID(BreakCriticalEdgesID);
   AU.addRequiredID(LoopSimplifyID);
-  AU.addRequiredETForest();
   AU.addRequiredDominatorTree();
   AU.addRequiredLoopInfo();
 }
@@ -78,7 +77,6 @@
   if (LI.begin() == LI.end())
 return false;
 
-  ETForest EF = getAnalysisETForest();
   DominatorTree DT = getAnalysisDominatorTree();
 
   // If there is more than one top-level loop in this function, extract all of
@@ -88,7 +86,7 @@
 for (LoopInfo::iterator i = LI.begin(), e = LI.end(); i != e; ++i) {
   if (NumLoops == 0) return Changed;
   --NumLoops;
-  Changed |= ExtractLoop(EF, DT, *i) != 0;
+  Changed |= ExtractLoop(DT, *i) != 0;
   ++NumExtracted;
 }
   } else {
@@ -118,7 +116,7 @@
 if (ShouldExtractLoop) {
   if (NumLoops == 0) return Changed;
   --NumLoops;
-  Changed |= ExtractLoop(EF, DT, TLL) != 0;
+  Changed |= ExtractLoop(DT, TLL) != 0;
   ++NumExtracted;
 } else {
   // Okay, this function is a minimal container around the specified loop.
@@ -128,7 +126,7 @@
   for (Loop::iterator i = TLL-begin(), e = TLL-end(); i != e; ++i) {
 if (NumLoops == 0) return Changed;
 --NumLoops;
-Changed |= ExtractLoop(EF, DT, *i) != 0;
+Changed |= ExtractLoop(DT, *i) != 0;
 ++NumExtracted;
   }
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Utils:

CodeExtractor.cpp updated: 1.56 - 1.57
---
Log message:

Do not use ETForest as well as DomiantorTree.  DominatorTree is sufficient.


---
Diffs of the changes:  (+15 -16)

 CodeExtractor.cpp |   31 +++
 1 files changed, 15 insertions(+), 16 deletions(-)


Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.56 
llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.57
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.56Mon Jun  4 11:43:25 2007
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Thu Jun  7 17:17:16 2007
@@ -44,14 +44,13 @@
   class VISIBILITY_HIDDEN CodeExtractor {
 typedef std::vectorValue* Values;
 std::setBasicBlock* BlocksToExtract;
-ETForest *EF;
 DominatorTree* DT;
 bool AggregateArgs;
 unsigned NumExitBlocks;
 const Type *RetTy;
   public:
-CodeExtractor(ETForest *ef = 0, DominatorTree* dt = 0, bool AggArgs = 
false)
-  : EF(ef), DT(dt), AggregateArgs(AggArgs||AggregateArgsOpt), 
NumExitBlocks(~0U) {}
+CodeExtractor(DominatorTree* dt = 0, bool AggArgs = false)
+  : DT(dt), AggregateArgs(AggArgs||AggregateArgsOpt), NumExitBlocks(~0U) {}
 
 Function *ExtractCodeRegion(const std::vectorBasicBlock* code);
 
@@ -141,17 +140,17 @@
 
   // Okay, update dominator sets. The blocks that dominate the new one are the
   // blocks that dominate TIBB plus the new block itself.
-  if (EF) {
-BasicBlock* idom = EF-getIDom(OldPred);
+  if (DT) {
+DomTreeNode *OPNode = DT-getNode(OldPred);
+DomTreeNode *IDomNode = OPNode-getIDom();
+BasicBlock* idom = IDomNode-getBlock();
 DT-addNewBlock(NewBB, idom);
-EF-addNewBlock(NewBB, idom);
 
 // Additionally, NewBB replaces OldPred as the immediate dominator of 
blocks
 Function *F = Header-getParent();
 for (Function::iterator I = F-begin(), E = F-end(); I != E; ++I)
-  if (EF-getIDom(I) == OldPred) {
+  if (DT-getIDomBlock(I) == OldPred) {
 DT-changeImmediateDominator(I, NewBB);
-EF-setImmediateDominator(I, NewBB);
   }
   }
 
@@ -509,12 +508,12 @@
   // In the extract block case, if the block we are extracting ends
   // with an invoke instruction, make sure that we don't emit a
   // store of the invoke value for the unwind block.
-  if (!EF  DefBlock != OldTarget)
+  if (!DT  DefBlock != OldTarget)
 DominatesDef = false;
 }
 
-if (EF)
-  DominatesDef = EF-dominates(DefBlock, OldTarget);
+if (DT)
+  DominatesDef = DT-dominates(DefBlock, OldTarget);
 
 if (DominatesDef) {
   if (AggregateArgs) {
@@ -728,16 +727,16 @@
 /// ExtractCodeRegion - slurp a sequence of basic blocks into a brand new
 /// function
 ///
-Function* llvm::ExtractCodeRegion(ETForest EF, DominatorTree DT,
+Function* llvm::ExtractCodeRegion(DominatorTree DT,
   const std::vectorBasicBlock* code,
   bool AggregateArgs) {
-  return CodeExtractor(EF, DT, AggregateArgs).ExtractCodeRegion(code);
+  return CodeExtractor(DT, AggregateArgs).ExtractCodeRegion(code);
 }
 
 /// ExtractBasicBlock - slurp a natural loop into a brand new function
 ///
-Function* llvm::ExtractLoop(ETForest EF, DominatorTree DF, Loop *L, bool 
AggregateArgs) {
-  return CodeExtractor(EF, DF, 
AggregateArgs).ExtractCodeRegion(L-getBlocks());
+Function* llvm::ExtractLoop(DominatorTree DT, Loop *L, bool AggregateArgs) {
+  return CodeExtractor(DT, AggregateArgs).ExtractCodeRegion(L-getBlocks());
 }
 
 /// ExtractBasicBlock - slurp a basic block into a brand new function
@@ -745,5 +744,5 @@
 Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) {
   std::vectorBasicBlock* Blocks;
   Blocks.push_back(BB);
-  return CodeExtractor(0, 0, AggregateArgs).ExtractCodeRegion(Blocks);
+  return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks);
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LICM.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Scalar:

LICM.cpp updated: 1.106 - 1.107
---
Log message:

Do not require ETForest. Now it is unused by LICM.


---
Diffs of the changes:  (+0 -3)

 LICM.cpp |3 ---
 1 files changed, 3 deletions(-)


Index: llvm/lib/Transforms/Scalar/LICM.cpp
diff -u llvm/lib/Transforms/Scalar/LICM.cpp:1.106 
llvm/lib/Transforms/Scalar/LICM.cpp:1.107
--- llvm/lib/Transforms/Scalar/LICM.cpp:1.106   Thu Jun  7 16:57:03 2007
+++ llvm/lib/Transforms/Scalar/LICM.cpp Thu Jun  7 17:21:15 2007
@@ -76,7 +76,6 @@
   AU.addRequiredID(LoopSimplifyID);
   AU.addRequiredLoopInfo();
   AU.addRequiredDominatorTree();
-  AU.addRequiredETForest();
   AU.addRequiredDominanceFrontier();  // For scalar promotion (mem2reg)
   AU.addRequiredAliasAnalysis();
 }
@@ -90,7 +89,6 @@
 // Various analyses that we use...
 AliasAnalysis *AA;   // Current AliasAnalysis information
 LoopInfo  *LI;   // Current LoopInfo
-ETForest  *ET;   // ETForest for the current loop..
 DominatorTree *DT;   // Dominator Tree for the current Loop...
 DominanceFrontier *DF;   // Current Dominance Frontier
 
@@ -220,7 +218,6 @@
   AA = getAnalysisAliasAnalysis();
   DF = getAnalysisDominanceFrontier();
   DT = getAnalysisDominatorTree();
-  ET = getAnalysisETForest();
 
   CurAST = new AliasSetTracker(*AA);
   // Collect Alias info from subloops



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LICM.cpp ScalarReplAggregates.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Scalar:

LICM.cpp updated: 1.105 - 1.106
ScalarReplAggregates.cpp updated: 1.96 - 1.97
---
Log message:

Use DominatorTree instead of ETForest.
This allows faster immediate domiantor walk.


---
Diffs of the changes:  (+5 -5)

 LICM.cpp |4 ++--
 ScalarReplAggregates.cpp |6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/LICM.cpp
diff -u llvm/lib/Transforms/Scalar/LICM.cpp:1.105 
llvm/lib/Transforms/Scalar/LICM.cpp:1.106
--- llvm/lib/Transforms/Scalar/LICM.cpp:1.105   Tue Jun  5 11:05:55 2007
+++ llvm/lib/Transforms/Scalar/LICM.cpp Thu Jun  7 16:57:03 2007
@@ -565,7 +565,7 @@
 if (AI) {
   std::vectorAllocaInst* Allocas;
   Allocas.push_back(AI);
-  PromoteMemToReg(Allocas, *ET, *DF, CurAST);
+  PromoteMemToReg(Allocas, *DT, *DF, CurAST);
 }
   }
 }
@@ -746,7 +746,7 @@
   PromotedAllocas.reserve(PromotedValues.size());
   for (unsigned i = 0, e = PromotedValues.size(); i != e; ++i)
 PromotedAllocas.push_back(PromotedValues[i].first);
-  PromoteMemToReg(PromotedAllocas, *ET, *DF, CurAST);
+  PromoteMemToReg(PromotedAllocas, *DT, *DF, CurAST);
 }
 
 /// FindPromotableValuesInLoop - Check the current loop for stores to definite


Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.96 
llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.97
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.96Wed May 30 
01:11:23 2007
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Thu Jun  7 16:57:03 2007
@@ -58,7 +58,7 @@
 // getAnalysisUsage - This pass does not require any passes, but we know it
 // will not alter the CFG, so say so.
 virtual void getAnalysisUsage(AnalysisUsage AU) const {
-  AU.addRequiredETForest();
+  AU.addRequiredDominatorTree();
   AU.addRequiredDominanceFrontier();
   AU.addRequiredTargetData();
   AU.setPreservesCFG();
@@ -138,7 +138,7 @@
 
 bool SROA::performPromotion(Function F) {
   std::vectorAllocaInst* Allocas;
-  ETForest ET = getAnalysisETForest();
+  DominatorTree DT = getAnalysisDominatorTree();
   DominanceFrontier DF = getAnalysisDominanceFrontier();
 
   BasicBlock BB = F.getEntryBlock();  // Get the entry node for the function
@@ -157,7 +157,7 @@
 
 if (Allocas.empty()) break;
 
-PromoteMemToReg(Allocas, ET, DF);
+PromoteMemToReg(Allocas, DT, DF);
 NumPromoted += Allocas.size();
 Changed = true;
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Transforms/Utils/PromoteMemToReg.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Transforms/Utils:

PromoteMemToReg.h updated: 1.12 - 1.13
---
Log message:

Use DominatorTree instead of ETForest.
This allows faster immediate domiantor walk.


---
Diffs of the changes:  (+2 -2)

 PromoteMemToReg.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/Transforms/Utils/PromoteMemToReg.h
diff -u llvm/include/llvm/Transforms/Utils/PromoteMemToReg.h:1.12 
llvm/include/llvm/Transforms/Utils/PromoteMemToReg.h:1.13
--- llvm/include/llvm/Transforms/Utils/PromoteMemToReg.h:1.12   Wed Apr 25 
13:41:11 2007
+++ llvm/include/llvm/Transforms/Utils/PromoteMemToReg.hThu Jun  7 
16:57:03 2007
@@ -20,7 +20,7 @@
 namespace llvm {
 
 class AllocaInst;
-class ETForest;
+class DominatorTree;
 class DominanceFrontier;
 class AliasSetTracker;
 
@@ -38,7 +38,7 @@
 /// made to the IR.
 ///
 void PromoteMemToReg(const std::vectorAllocaInst* Allocas,
- ETForest ET, DominanceFrontier DF,
+ DominatorTree DT, DominanceFrontier DF,
  AliasSetTracker *AST = 0);
 
 } // End llvm namespace



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Analysis:

Dominators.h updated: 1.96 - 1.97
---
Log message:

Add instruction level dominates(A,B) interface.


---
Diffs of the changes:  (+4 -0)

 Dominators.h |4 
 1 files changed, 4 insertions(+)


Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.96 
llvm/include/llvm/Analysis/Dominators.h:1.97
--- llvm/include/llvm/Analysis/Dominators.h:1.96Thu Jun  7 17:17:16 2007
+++ llvm/include/llvm/Analysis/Dominators.h Thu Jun  7 18:52:40 2007
@@ -219,6 +219,10 @@
 return dominates(getNode(A), getNode(B));
   }
 
+  // dominates - Return true if A dominates B. This performs the
+  // special checks necessary if A and B are in the same basic block.
+  bool dominates(Instruction *A, Instruction *B);
+
   
//======//
   // API to update (Post)DominatorTree information based on modifications to
   // the CFG...



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/VMCore:

Dominators.cpp updated: 1.107 - 1.108
---
Log message:

Add instruction level dominates(A,B) interface.


---
Diffs of the changes:  (+23 -0)

 Dominators.cpp |   23 +++
 1 files changed, 23 insertions(+)


Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.107 
llvm/lib/VMCore/Dominators.cpp:1.108
--- llvm/lib/VMCore/Dominators.cpp:1.107Thu Jun  7 12:47:21 2007
+++ llvm/lib/VMCore/Dominators.cpp  Thu Jun  7 18:52:40 2007
@@ -324,6 +324,29 @@
   DFSInfoValid = true;
 }
 
+// dominates - Return true if A dominates B. THis performs the
+// special checks necessary if A and B are in the same basic block.
+bool DominatorTreeBase::dominates(Instruction *A, Instruction *B) {
+  BasicBlock *BBA = A-getParent(), *BBB = B-getParent();
+  if (BBA != BBB) return dominates(BBA, BBB);
+  
+  // It is not possible to determine dominance between two PHI nodes 
+  // based on their ordering.
+  if (isaPHINode(A)  isaPHINode(B)) 
+return false;
+
+  // Loop through the basic block until we find A or B.
+  BasicBlock::iterator I = BBA-begin();
+  for (; *I != A  *I != B; ++I) /*empty*/;
+  
+  if(!IsPostDominators) {
+// A dominates B if it is found first in the basic block.
+return *I == A;
+  } else {
+// A post-dominates B if B is found first in the basic block.
+return *I == B;
+  }
+}
 
 // DominatorTreeBase::reset - Free all of the tree node memory.
 //



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Utils:

BreakCriticalEdges.cpp updated: 1.52 - 1.53
---
Log message:

Do not preserve ETForest.


---
Diffs of the changes:  (+5 -26)

 BreakCriticalEdges.cpp |   31 +--
 1 files changed, 5 insertions(+), 26 deletions(-)


Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
diff -u llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.52 
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.53
--- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.52   Thu Jun  7 
12:47:21 2007
+++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cppThu Jun  7 19:02:08 2007
@@ -40,7 +40,6 @@
 virtual bool runOnFunction(Function F);
 
 virtual void getAnalysisUsage(AnalysisUsage AU) const {
-  AU.addPreservedETForest();
   AU.addPreservedDominatorTree();
   AU.addPreservedDominanceFrontier();
   AU.addPreservedLoopInfo();
@@ -110,11 +109,11 @@
 }
 
 // SplitCriticalEdge - If this edge is a critical edge, insert a new node to
-// split the critical edge.  This will update ETForest, ImmediateDominator,
-// DominatorTree, and DominatorFrontier information if it is available, thus
-// calling this pass will not invalidate any of them.  This returns true if
-// the edge was split, false otherwise.  This ensures that all edges to that
-// dest go to one block instead of each going to a different block.
+// split the critical edge.  This will update DominatorTree, and 
DominatorFrontier 
+// information if it is available, thus calling this pass will not invalidate 
+// any of them.  This returns true if the edge was split, false otherwise. 
+// This ensures that all edges to that dest go to one block instead of each 
+// going to a different block.
 //
 bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
  bool MergeIdenticalEdges) {
@@ -181,26 +180,6 @@
   
   bool NewBBDominatesDestBB = true;
   
-  // Update the forest?
-  if (ETForest *EF = P-getAnalysisToUpdateETForest()) {
-// NewBB is dominated by TIBB.
-EF-addNewBlock(NewBB, TIBB);
-
-// If NewBBDominatesDestBB hasn't been computed yet, do so with EF.
-if (!OtherPreds.empty()) {
-  while (!OtherPreds.empty()  NewBBDominatesDestBB) {
-NewBBDominatesDestBB = EF-dominates(DestBB, OtherPreds.back());
-OtherPreds.pop_back();
-  }
-  OtherPreds.clear();
-}
-
-// If NewBBDominatesDestBB, then NewBB dominates DestBB, otherwise it
-// doesn't dominate anything.
-if (NewBBDominatesDestBB)
-  EF-setImmediateDominator(DestBB, NewBB);
-  }
-  
   // Should we update DominatorTree information?
   if (DominatorTree *DT = P-getAnalysisToUpdateDominatorTree()) {
 DomTreeNode *TINode = DT-getNode(TIBB);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Transforms/Utils:

BasicBlockUtils.h updated: 1.16 - 1.17
---
Log message:

Do not preserve ETForest.


---
Diffs of the changes:  (+9 -9)

 BasicBlockUtils.h |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)


Index: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
diff -u llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.16 
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.17
--- llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.16   Sat Apr  7 
02:17:27 2007
+++ llvm/include/llvm/Transforms/Utils/BasicBlockUtils.hThu Jun  7 
19:02:08 2007
@@ -61,15 +61,15 @@
 bool AllowIdenticalEdges = false);
 
 /// SplitCriticalEdge - If this edge is a critical edge, insert a new node to
-/// split the critical edge.  This will update ETForest, ImmediateDominator,
-/// DominatorTree, and DominatorFrontier information if it is available, thus
-/// calling this pass will not invalidate either of them.  This returns true if
-/// the edge was split, false otherwise.  If MergeIdenticalEdges is true (the
-/// default), *all* edges from TI to the specified successor will be merged 
into
-/// the same critical edge block.  This is most commonly interesting with 
switch
-/// instructions, which may have many edges to any one destination.  This
-/// ensures that all edges to that dest go to one block instead of each going 
to
-/// a different block, but isn't the standard definition of a critical edge.
+/// split the critical edge.  This will update DominatorTree, and 
DominatorFrontier 
+/// information if it is available, thus calling this pass will not invalidate 
+/// either of them. This returns true if the edge was split, false otherwise.  
+/// If MergeIdenticalEdges is true (the default), *all* edges from TI to the 
+/// specified successor will be merged into the same critical edge block.  
+/// This is most commonly interesting with switch instructions, which may 
+/// have many edges to any one destination.  This ensures that all edges to 
that 
+/// dest go to one block instead of each going to a different block, but isn't 
+/// the standard definition of a critical edge.
 ///
 bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0,
bool MergeIdenticalEdges = false);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Analysis/LoopInfo.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Analysis:

LoopInfo.cpp updated: 1.86 - 1.87
---
Log message:

Use DominatorTree instead of ETForest.


---
Diffs of the changes:  (+9 -9)

 LoopInfo.cpp |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)


Index: llvm/lib/Analysis/LoopInfo.cpp
diff -u llvm/lib/Analysis/LoopInfo.cpp:1.86 llvm/lib/Analysis/LoopInfo.cpp:1.87
--- llvm/lib/Analysis/LoopInfo.cpp:1.86 Wed May  2 20:11:53 2007
+++ llvm/lib/Analysis/LoopInfo.cpp  Thu Jun  7 19:17:13 2007
@@ -91,7 +91,7 @@
 //
 bool LoopInfo::runOnFunction(Function ) {
   releaseMemory();
-  Calculate(getAnalysisETForest());// Update
+  Calculate(getAnalysisDominatorTree());// Update
   return false;
 }
 
@@ -105,18 +105,18 @@
 }
 
 
-void LoopInfo::Calculate(ETForest EF) {
-  BasicBlock *RootNode = EF.getRoot();
+void LoopInfo::Calculate(DominatorTree DT) {
+  BasicBlock *RootNode = DT.getRootNode()-getBlock();
 
   for (df_iteratorBasicBlock* NI = df_begin(RootNode),
  NE = df_end(RootNode); NI != NE; ++NI)
-if (Loop *L = ConsiderForLoop(*NI, EF))
+if (Loop *L = ConsiderForLoop(*NI, DT))
   TopLevelLoops.push_back(L);
 }
 
 void LoopInfo::getAnalysisUsage(AnalysisUsage AU) const {
   AU.setPreservesAll();
-  AU.addRequiredETForest();
+  AU.addRequiredDominatorTree();
 }
 
 void LoopInfo::print(std::ostream OS, const Module* ) const {
@@ -136,7 +136,7 @@
   return isNotAlreadyContainedIn(SubLoop-getParentLoop(), ParentLoop);
 }
 
-Loop *LoopInfo::ConsiderForLoop(BasicBlock *BB, ETForest EF) {
+Loop *LoopInfo::ConsiderForLoop(BasicBlock *BB, DominatorTree DT) {
   if (BBMap.find(BB) != BBMap.end()) return 0;   // Haven't processed this 
node?
 
   std::vectorBasicBlock * TodoStack;
@@ -144,7 +144,7 @@
   // Scan the predecessors of BB, checking to see if BB dominates any of
   // them.  This identifies backedges which target this node...
   for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I)
-if (EF.dominates(BB, *I))   // If BB dominates it's predecessor...
+if (DT.dominates(BB, *I))   // If BB dominates it's predecessor...
   TodoStack.push_back(*I);
 
   if (TodoStack.empty()) return 0;  // No backedges to this block...
@@ -160,7 +160,7 @@
 TodoStack.pop_back();
 
 if (!L-contains(X)  // As of yet unprocessed??
-EF.dominates(EntryBlock, X)) {   // X is reachable from entry block?
+DT.dominates(EntryBlock, X)) {   // X is reachable from entry block?
   // Check to see if this block already belongs to a loop.  If this occurs
   // then we have a case where a loop that is supposed to be a child of the
   // current loop was processed before the current loop.  When this occurs,
@@ -192,7 +192,7 @@
   // If there are any loops nested within this loop, create them now!
   for (std::vectorBasicBlock*::iterator I = L-Blocks.begin(),
  E = L-Blocks.end(); I != E; ++I)
-if (Loop *NewLoop = ConsiderForLoop(*I, EF)) {
+if (Loop *NewLoop = ConsiderForLoop(*I, DT)) {
   L-SubLoops.push_back(NewLoop);
   NewLoop-ParentLoop = L;
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Analysis/LoopInfo.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Analysis:

LoopInfo.h updated: 1.67 - 1.68
---
Log message:

Use DominatorTree instead of ETForest.


---
Diffs of the changes:  (+3 -3)

 LoopInfo.h |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/include/llvm/Analysis/LoopInfo.h
diff -u llvm/include/llvm/Analysis/LoopInfo.h:1.67 
llvm/include/llvm/Analysis/LoopInfo.h:1.68
--- llvm/include/llvm/Analysis/LoopInfo.h:1.67  Sun May  6 08:37:15 2007
+++ llvm/include/llvm/Analysis/LoopInfo.h   Thu Jun  7 19:17:13 2007
@@ -35,7 +35,7 @@
 
 namespace llvm {
 
-class ETForest;
+class DominatorTree;
 class LoopInfo;
 class PHINode;
 class Instruction;
@@ -321,8 +321,8 @@
   void removeBlock(BasicBlock *BB);
 
 private:
-  void Calculate(ETForest EF);
-  Loop *ConsiderForLoop(BasicBlock *BB, ETForest EF);
+  void Calculate(DominatorTree DT);
+  Loop *ConsiderForLoop(BasicBlock *BB, DominatorTree DT);
   void MoveSiblingLoopInto(Loop *NewChild, Loop *NewParent);
   void InsertLoopInto(Loop *L, Loop *Parent);
 };



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Analysis:

Dominators.h updated: 1.97 - 1.98
---
Log message:

Add new method - nearestCommonDominator().


---
Diffs of the changes:  (+11 -0)

 Dominators.h |   11 +++
 1 files changed, 11 insertions(+)


Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.97 
llvm/include/llvm/Analysis/Dominators.h:1.98
--- llvm/include/llvm/Analysis/Dominators.h:1.97Thu Jun  7 18:52:40 2007
+++ llvm/include/llvm/Analysis/Dominators.h Thu Jun  7 19:21:17 2007
@@ -185,6 +185,17 @@
 
   void updateDFSNumbers();  
 
+  /// Return the nearest common dominator of A and B.
+  BasicBlock *nearestCommonDominator(BasicBlock *A, BasicBlock *B) const  {
+ETNode *NodeA = getNode(A)-getETNode();
+ETNode *NodeB = getNode(B)-getETNode();
+
+ETNode *Common = NodeA-NCA(NodeB);
+if (!Common)
+  return NULL;
+return Common-getDataBasicBlock();
+  }
+  
   /// dominates - Returns true iff this dominates N.  Note that this is not a
   /// constant time operation!
   ///



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp

2007-06-07 Thread Dale Johannesen


Changes in directory llvm/lib/CodeGen:

BranchFolding.cpp updated: 1.65 - 1.66
---
Log message:

Throttle tail merging; handling blocks with large numbers of predecessors
is too slow.


---
Diffs of the changes:  (+6 -2)

 BranchFolding.cpp |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.65 
llvm/lib/CodeGen/BranchFolding.cpp:1.66
--- llvm/lib/CodeGen/BranchFolding.cpp:1.65 Mon Jun  4 18:52:54 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp  Thu Jun  7 19:34:27 2007
@@ -564,6 +564,9 @@
   return MadeChange;
 }
 
+// Throttle for huge numbers of predecessors (compile speed problems)
+#define THRESHOLD 100
+
 bool BranchFolder::TailMergeBlocks(MachineFunction MF) {
 
   if (!EnableTailMerge) return false;
@@ -577,7 +580,8 @@
   MergePotentials.push_back(std::make_pair(HashEndOfMBB(I, 2U), I));
   }
   // See if we can do any tail merging on those.
-  MadeChange |= TryMergeBlocks(NULL, NULL);
+  if (MergePotentials.size()  THRESHOLD)
+MadeChange |= TryMergeBlocks(NULL, NULL);
 
   // Look at blocks (IBB) with multiple predecessors (PBB).
   // We change each predecessor to a canonical form, by
@@ -599,7 +603,7 @@
   // transformations.)
 
   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
-if (!I-succ_empty()  I-pred_size() = 2) {
+if (!I-succ_empty()  I-pred_size() = 2  I-pred_size()  THRESHOLD) 
{
   MachineBasicBlock *IBB = I;
   MachineBasicBlock *PredBB = prior(I);
   MergePotentials.clear();



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp

2007-06-07 Thread Chris Lattner
 BranchFolding.cpp updated: 1.65 - 1.66
 ---
 Log message:

 Throttle tail merging; handling blocks with large numbers of  
 predecessors
 is too slow.

Thanks Dale,

Please make this a hidden command line option like loop-unswitch- 
threshold.

-Chris


 ---
 Diffs of the changes:  (+6 -2)

  BranchFolding.cpp |8 ++--
  1 files changed, 6 insertions(+), 2 deletions(-)


 Index: llvm/lib/CodeGen/BranchFolding.cpp
 diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.65 llvm/lib/CodeGen/ 
 BranchFolding.cpp:1.66
 --- llvm/lib/CodeGen/BranchFolding.cpp:1.65   Mon Jun  4 18:52:54 2007
 +++ llvm/lib/CodeGen/BranchFolding.cppThu Jun  7 19:34:27 2007
 @@ -564,6 +564,9 @@
return MadeChange;
  }

 +// Throttle for huge numbers of predecessors (compile speed problems)
 +#define THRESHOLD 100
 +
  bool BranchFolder::TailMergeBlocks(MachineFunction MF) {

if (!EnableTailMerge) return false;
 @@ -577,7 +580,8 @@
MergePotentials.push_back(std::make_pair(HashEndOfMBB(I,  
 2U), I));
}
// See if we can do any tail merging on those.
 -  MadeChange |= TryMergeBlocks(NULL, NULL);
 +  if (MergePotentials.size()  THRESHOLD)
 +MadeChange |= TryMergeBlocks(NULL, NULL);

// Look at blocks (IBB) with multiple predecessors (PBB).
// We change each predecessor to a canonical form, by
 @@ -599,7 +603,7 @@
// transformations.)

for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I ! 
 = E; ++I) {
 -if (!I-succ_empty()  I-pred_size() = 2) {
 +if (!I-succ_empty()  I-pred_size() = 2  I-pred_size()  
  THRESHOLD) {
MachineBasicBlock *IBB = I;
MachineBasicBlock *PredBB = prior(I);
MergePotentials.clear();



 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GVNPRE.cpp

2007-06-07 Thread Owen Anderson


Changes in directory llvm/lib/Transforms/Scalar:

GVNPRE.cpp updated: 1.22 - 1.23
---
Log message:

Add partial redundancy elimination.


---
Diffs of the changes:  (+249 -84)

 GVNPRE.cpp |  333 +
 1 files changed, 249 insertions(+), 84 deletions(-)


Index: llvm/lib/Transforms/Scalar/GVNPRE.cpp
diff -u llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.22 
llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.23
--- llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.22  Tue Jun  5 20:27:49 2007
+++ llvm/lib/Transforms/Scalar/GVNPRE.cpp   Thu Jun  7 20:03:01 2007
@@ -27,6 +27,7 @@
 #include llvm/Analysis/PostDominators.h
 #include llvm/ADT/DepthFirstIterator.h
 #include llvm/ADT/Statistic.h
+#include llvm/Support/CFG.h
 #include llvm/Support/Compiler.h
 #include llvm/Support/Debug.h
 #include algorithm
@@ -64,6 +65,9 @@
   private:
 uint32_t nextValueNumber;
 typedef std::mapValue*, uint32_t, ExprLT ValueTable;
+ValueTable VN;
+std::setValue*, ExprLT MS;
+std::setInstruction* createdExpressions;
 
 virtual void getAnalysisUsage(AnalysisUsage AU) const {
   AU.setPreservesCFG();
@@ -73,25 +77,23 @@
   
 // Helper fuctions
 // FIXME: eliminate or document these better
-void dump(ValueTable VN, std::setValue* s);
-void dump_unique(ValueTable VN, std::setValue*, ExprLT s);
-void clean(ValueTable VN, std::setValue*, ExprLT set);
-bool add(ValueTable VN, std::setValue*, ExprLT MS, Value* V);
-Value* find_leader(std::setValue*, ExprLT vals, Value* v);
-Value* phi_translate(ValueTable VN, std::setValue*, ExprLT MS,
- std::setValue*, ExprLT set,
+void dump(std::setValue* s);
+void dump_unique(std::setValue*, ExprLT s);
+void clean(std::setValue*, ExprLT set);
+bool add(Value* V, uint32_t number);
+Value* find_leader(std::setValue*, ExprLT vals,
+   Value* v);
+Value* phi_translate(std::setValue*, ExprLT set,
  Value* V, BasicBlock* pred);
-void phi_translate_set(ValueTable VN, std::setValue*, ExprLT MS,
-   std::setValue*, ExprLT anticIn, BasicBlock* B,
+void phi_translate_set(std::setValue*, ExprLT anticIn, BasicBlock* B,
std::setValue*, ExprLT out);
 
-void topo_sort(ValueTable VN, std::setValue*, ExprLT set,
+void topo_sort(std::setValue*, ExprLT set,
std::vectorValue* vec);
 
 // For a given block, calculate the generated expressions, temporaries,
 // and the AVAIL_OUT set
-void CalculateAvailOut(ValueTable VN, std::setValue*, ExprLT MS,
-   DomTreeNode* DI,
+void CalculateAvailOut(DomTreeNode* DI,
std::setValue*, ExprLT currExps,
std::setPHINode* currPhis,
std::setValue* currTemps,
@@ -111,35 +113,33 @@
 
 
 
-bool GVNPRE::add(ValueTable VN, std::setValue*, ExprLT MS, Value* V) {
-  std::pairValueTable::iterator, bool ret = VN.insert(std::make_pair(V, 
nextValueNumber));
-  if (ret.second)
-nextValueNumber++;
+bool GVNPRE::add(Value* V, uint32_t number) {
+  std::pairValueTable::iterator, bool ret = VN.insert(std::make_pair(V, 
number));
   if (isaBinaryOperator(V) || isaPHINode(V))
 MS.insert(V);
   return ret.second;
 }
 
-Value* GVNPRE::find_leader(std::setValue*, ExprLT vals,
-   Value* v) {
-  ExprLT cmp;
+Value* GVNPRE::find_leader(std::setValue*, ExprLT vals, Value* v) {
   for (std::setValue*, ExprLT::iterator I = vals.begin(), E = vals.end();
-   I != E; ++I)
-if (!cmp(v, *I)  !cmp(*I, v))
+   I != E; ++I) {
+assert(VN.find(v) != VN.end()  Value not numbered?);
+assert(VN.find(*I) != VN.end()  Value not numbered?);
+if (VN[v] == VN[*I])
   return *I;
+  }
   
   return 0;
 }
 
-Value* GVNPRE::phi_translate(ValueTable VN, std::setValue*, ExprLT MS,
- std::setValue*, ExprLT set,
+Value* GVNPRE::phi_translate(std::setValue*, ExprLT set,
  Value* V, BasicBlock* pred) {
   if (V == 0)
 return 0;
   
   if (BinaryOperator* BO = dyn_castBinaryOperator(V)) {
 Value* newOp1 = isaInstruction(BO-getOperand(0))
-? phi_translate(VN, MS, set,
+? phi_translate(set,
   find_leader(set, BO-getOperand(0)),
   pred)
 : BO-getOperand(0);
@@ -147,7 +147,7 @@
   return 0;
 
 Value* newOp2 = isaInstruction(BO-getOperand(1))
-? phi_translate(VN, MS, set,
+? phi_translate(set,
   find_leader(set, BO-getOperand(1)),
   pred)
 : BO-getOperand(1);
@@ -155,12 +155,14 @@
   return 0;
 
 if 

[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h

2007-06-07 Thread Devang Patel


Changes in directory llvm/include/llvm/Analysis:

Dominators.h updated: 1.98 - 1.99
---
Log message:

Update LoopSimplify to require and preserve DominatorTree only.
Now LoopSimplify does not require nor preserve ETForest.


---
Diffs of the changes:  (+4 -0)

 Dominators.h |4 
 1 files changed, 4 insertions(+)


Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.98 
llvm/include/llvm/Analysis/Dominators.h:1.99
--- llvm/include/llvm/Analysis/Dominators.h:1.98Thu Jun  7 19:21:17 2007
+++ llvm/include/llvm/Analysis/Dominators.h Thu Jun  7 20:50:32 2007
@@ -195,6 +195,10 @@
   return NULL;
 return Common-getDataBasicBlock();
   }
+
+  /// isReachableFromEntry - Return true if A is dominated by the entry
+  /// block of the function containing it.
+  const bool isReachableFromEntry(BasicBlock* A);
   
   /// dominates - Returns true iff this dominates N.  Note that this is not a
   /// constant time operation!



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/VMCore:

Dominators.cpp updated: 1.108 - 1.109
---
Log message:

Update LoopSimplify to require and preserve DominatorTree only.
Now LoopSimplify does not require nor preserve ETForest.


---
Diffs of the changes:  (+12 -3)

 Dominators.cpp |   15 ---
 1 files changed, 12 insertions(+), 3 deletions(-)


Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.108 
llvm/lib/VMCore/Dominators.cpp:1.109
--- llvm/lib/VMCore/Dominators.cpp:1.108Thu Jun  7 18:52:40 2007
+++ llvm/lib/VMCore/Dominators.cpp  Thu Jun  7 20:50:32 2007
@@ -316,14 +316,23 @@
 for (df_iteratorBasicBlock* I = df_begin(Roots[i]),
E = df_end(Roots[i]); I != E; ++I) {
   BasicBlock *BB = *I;
-  ETNode *ETN = getNode(BB)-getETNode();
-  if (ETN  !ETN-hasFather())
-ETN-assignDFSNumber(dfsnum);
+  DomTreeNode *BBNode = getNode(BB);
+  if (BBNode) {
+ETNode *ETN = BBNode-getETNode();
+if (ETN  !ETN-hasFather())
+  ETN-assignDFSNumber(dfsnum);
+  }
   }
   SlowQueries = 0;
   DFSInfoValid = true;
 }
 
+/// isReachableFromEntry - Return true if A is dominated by the entry
+/// block of the function containing it.
+const bool DominatorTreeBase::isReachableFromEntry(BasicBlock* A) {
+  return dominates(A-getParent()-getEntryBlock(), A);
+}
+
 // dominates - Return true if A dominates B. THis performs the
 // special checks necessary if A and B are in the same basic block.
 bool DominatorTreeBase::dominates(Instruction *A, Instruction *B) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Utils/LoopSimplify.cpp

2007-06-07 Thread Devang Patel


Changes in directory llvm/lib/Transforms/Utils:

LoopSimplify.cpp updated: 1.99 - 1.100
---
Log message:

Update LoopSimplify to require and preserve DominatorTree only.
Now LoopSimplify does not require nor preserve ETForest.


---
Diffs of the changes:  (+26 -32)

 LoopSimplify.cpp |   58 ---
 1 files changed, 26 insertions(+), 32 deletions(-)


Index: llvm/lib/Transforms/Utils/LoopSimplify.cpp
diff -u llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.99 
llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.100
--- llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.99 Mon Jun  4 11:43:25 2007
+++ llvm/lib/Transforms/Utils/LoopSimplify.cpp  Thu Jun  7 20:50:32 2007
@@ -68,10 +68,8 @@
   // We need loop information to identify the loops...
   AU.addRequiredLoopInfo();
   AU.addRequiredDominatorTree();
-  AU.addRequiredETForest();
 
   AU.addPreservedLoopInfo();
-  AU.addPreservedETForest();
   AU.addPreservedDominatorTree();
   AU.addPreservedDominanceFrontier();
   AU.addPreservedID(BreakCriticalEdgesID);  // No critical edges added.
@@ -315,10 +313,10 @@
   // Can we eliminate this phi node now?
   if (Value *V = PN-hasConstantValue(true)) {
 Instruction *I = dyn_castInstruction(V);
-// If I is in NewBB, the ETForest call will fail, because NewBB isn't
-// registered in ETForest yet.  Handle this case explicitly.
+// If I is in NewBB, the Dominator call will fail, because NewBB isn't
+// registered in DominatorTree yet.  Handle this case explicitly.
 if (!I || (I-getParent() != NewBB 
-   getAnalysisETForest().dominates(I, PN))) {
+   getAnalysisDominatorTree().dominates(I, PN))) {
   PN-replaceAllUsesWith(V);
   if (AA) AA-deleteValue(PN);
   BB-getInstList().erase(PN);
@@ -429,13 +427,13 @@
 
 /// FindPHIToPartitionLoops - The first part of loop-nestification is to find a
 /// PHI node that tells us how to partition the loops.
-static PHINode *FindPHIToPartitionLoops(Loop *L, ETForest *EF,
+static PHINode *FindPHIToPartitionLoops(Loop *L, DominatorTree *DT,
 AliasAnalysis *AA) {
   for (BasicBlock::iterator I = L-getHeader()-begin(); isaPHINode(I); ) {
 PHINode *PN = castPHINode(I);
 ++I;
 if (Value *V = PN-hasConstantValue())
-  if (!isaInstruction(V) || EF-dominates(castInstruction(V), PN)) {
+  if (!isaInstruction(V) || DT-dominates(castInstruction(V), PN)) {
 // This is a degenerate PHI already, don't modify it!
 PN-replaceAllUsesWith(V);
 if (AA) AA-deleteValue(PN);
@@ -509,8 +507,8 @@
 /// created.
 ///
 Loop *LoopSimplify::SeparateNestedLoop(Loop *L) {
-  ETForest *EF = getAnalysisToUpdateETForest();
-  PHINode *PN = FindPHIToPartitionLoops(L, EF, AA);
+  DominatorTree *DT = getAnalysisToUpdateDominatorTree();
+  PHINode *PN = FindPHIToPartitionLoops(L, DT, AA);
   if (PN == 0) return 0;  // No known way to partition.
 
   // Pull out all predecessors that have varying values in the loop.  This
@@ -555,7 +553,7 @@
   // the Outer loop now.
   std::setBasicBlock* BlocksInL;
   for (pred_iterator PI = pred_begin(Header), E = pred_end(Header); PI!=E; 
++PI)
-if (EF-dominates(Header, *PI))
+if (DT-dominates(Header, *PI))
   AddBlockAndPredsToSet(*PI, Header, BlocksInL);
 
 
@@ -686,10 +684,10 @@
 // Returns true if BasicBlock A dominates at least one block in vector B
 // Helper function for UpdateDomInfoForRevectoredPreds
 static bool BlockDominatesAny(BasicBlock* A, const std::vectorBasicBlock* B,
-  ETForest ETF) {
+  DominatorTree DT) {
   for (std::vectorBasicBlock*::const_iterator BI = B.begin(), BE = B.end();
BI != BE; ++BI) {
-if (ETF.dominates(A, *BI))
+if (DT.dominates(A, *BI))
   return true;
   }
   return false;
@@ -715,8 +713,8 @@
  ++succ_begin(NewBB) == succ_end(NewBB) 
  NewBB should have a single successor!);
   BasicBlock *NewBBSucc = *succ_begin(NewBB);
-  ETForest ETF = getAnalysisETForest();
-  
+  DominatorTree DT = getAnalysisDominatorTree();
+
   // The newly inserted basic block will dominate existing basic blocks iff the
   // PredBlocks dominate all of the non-pred blocks.  If all predblocks 
dominate
   // the non-pred blocks, then they all must be the same block!
@@ -725,13 +723,13 @@
   {
 BasicBlock *OnePred = PredBlocks[0];
 unsigned i = 1, e = PredBlocks.size();
-for (i = 1; !ETF.isReachableFromEntry(OnePred); ++i) {
+for (i = 1; !DT.isReachableFromEntry(OnePred); ++i) {
   assert(i != e  Didn't find reachable pred?);
   OnePred = PredBlocks[i];
 }
 
 for (; i != e; ++i)
-  if (PredBlocks[i] != OnePred  ETF.isReachableFromEntry(OnePred)){
+  if (PredBlocks[i] != OnePred  DT.isReachableFromEntry(OnePred)){
 NewBBDominatesNewBBSucc = false;