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

2007-06-04 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.107 -> 1.108
---
Log message:

When rebuilding constant structs, make sure to honor the isPacked bit.
This fixes PR1491: http://llvm.org/PR1491  and 
GlobalOpt/2007-06-04-PackedStruct.ll


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

 GlobalOpt.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.107 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.108
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.107 Tue May 15 01:42:04 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Mon Jun  4 17:23:42 2007
@@ -1625,7 +1625,7 @@
 Elts[Idx] = EvaluateStoreInto(Elts[Idx], Val, Addr, OpNo+1);
 
 // Return the modified struct.
-return ConstantStruct::get(Elts);
+return ConstantStruct::get(&Elts[0], Elts.size(), STy->isPacked());
   } else {
 ConstantInt *CI = cast(Addr->getOperand(OpNo));
 const ArrayType *ATy = cast(Init->getType());



___
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/GlobalOpt.cpp

2007-05-14 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.106 -> 1.107
---
Log message:

selects can also reach here


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

 GlobalOpt.cpp |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.106 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.107
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.106 Sun May 13 16:28:07 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Tue May 15 01:42:04 2007
@@ -623,9 +623,10 @@
   Loads.push_back(LI);
   Changed |= OptimizeAwayTrappingUsesOfValue(LI, LV);
 } else {
-  // If we get here we could have stores, loads, or phi nodes whose values
+  // If we get here we could have stores, selects, or phi nodes whose 
values
   // are loaded.
-  assert((isa(*GUI) || isa(*GUI)) &&
+  assert((isa(*GUI) || isa(*GUI) ||
+  isa(*GUI)) &&
  "Only expect load and stores!");
 }
 



___
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/GlobalOpt.cpp

2007-05-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.105 -> 1.106
---
Log message:

Fix Transforms/GlobalOpt/2007-05-13-Crash.ll


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

 GlobalOpt.cpp |5 -
 1 files changed, 4 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.105 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.106
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.105 Sun May  6 08:37:16 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sun May 13 16:28:07 2007
@@ -623,7 +623,10 @@
   Loads.push_back(LI);
   Changed |= OptimizeAwayTrappingUsesOfValue(LI, LV);
 } else {
-  assert(isa(*GUI) && "Only expect load and stores!");
+  // If we get here we could have stores, loads, or phi nodes whose values
+  // are loaded.
+  assert((isa(*GUI) || isa(*GUI)) &&
+ "Only expect load and stores!");
 }
 
   if (Changed) {



___
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/GlobalOpt.cpp

2007-04-12 Thread Lauro Ramos Venancio


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.100 -> 1.101
---
Log message:

Implement the "thread_local" keyword.


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

 GlobalOpt.cpp |   26 +++---
 1 files changed, 19 insertions(+), 7 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.100 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.101
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.100 Thu Apr  5 16:09:42 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Apr 12 13:32:50 2007
@@ -390,7 +390,9 @@
   assert(In && "Couldn't get element of initializer?");
   GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false,
GlobalVariable::InternalLinkage,
-   In, 
GV->getName()+"."+utostr(i));
+   In, GV->getName()+"."+utostr(i),
+   (Module *)NULL,
+   GV->isThreadLocal());
   Globals.insert(GV, NGV);
   NewGlobals.push_back(NGV);
 }
@@ -413,7 +415,9 @@
 
   GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false,
GlobalVariable::InternalLinkage,
-   In, 
GV->getName()+"."+utostr(i));
+   In, GV->getName()+"."+utostr(i),
+   (Module *)NULL,
+   GV->isThreadLocal());
   Globals.insert(GV, NGV);
   NewGlobals.push_back(NGV);
 }
@@ -699,7 +703,9 @@
   Constant *Init = UndefValue::get(MI->getAllocatedType());
   GlobalVariable *NewGV = new GlobalVariable(MI->getAllocatedType(), false,
  GlobalValue::InternalLinkage, 
Init,
- GV->getName()+".body");
+ GV->getName()+".body",
+ (Module *)NULL,
+ GV->isThreadLocal());
   GV->getParent()->getGlobalList().insert(GV, NewGV);
 
   // Anything that used the malloc now uses the global directly.
@@ -714,7 +720,8 @@
   // keep track of whether the global was initialized yet or not.
   GlobalVariable *InitBool =
 new GlobalVariable(Type::Int1Ty, false, GlobalValue::InternalLinkage,
-   ConstantInt::getFalse(), GV->getName()+".init");
+   ConstantInt::getFalse(), GV->getName()+".init",
+   (Module *)NULL, GV->isThreadLocal());
   bool InitBoolUsed = false;
 
   // Loop over all uses of GV, processing them in turn.
@@ -943,7 +950,8 @@
 GlobalVariable *NGV =
   new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage,
  Constant::getNullValue(PFieldTy),
- GV->getName() + ".f" + utostr(FieldNo), GV);
+ GV->getName() + ".f" + utostr(FieldNo), GV,
+ GV->isThreadLocal());
 FieldGlobals.push_back(NGV);
 
 MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(),
@@ -1145,7 +1153,9 @@
   // Create the new global, initializing it to false.
   GlobalVariable *NewGV = new GlobalVariable(Type::Int1Ty, false,
  GlobalValue::InternalLinkage, ConstantInt::getFalse(),
- GV->getName()+".b");
+ GV->getName()+".b",
+ (Module *)NULL,
+ GV->isThreadLocal());
   GV->getParent()->getGlobalList().insert(GV, NewGV);
 
   Constant *InitVal = GV->getInitializer();
@@ -1519,7 +1529,9 @@
   
   // Create the new global and insert it next to the existing list.
   GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(),
-   GCL->getLinkage(), CA);
+   GCL->getLinkage(), CA, "",
+   (Module *)NULL,
+   GCL->isThreadLocal());
   GCL->getParent()->getGlobalList().insert(GCL, NGV);
   NGV->takeName(GCL);
   



___
llvm-commits mailing list
[EMAIL PROTECTED]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-05 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.99 -> 1.100
---
Log message:

Fix Transforms/GlobalOpt/2007-04-05-Crash.ll


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

 GlobalOpt.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.99 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.100
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.99  Thu Mar  1 18:28:51 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Apr  5 16:09:42 2007
@@ -1347,7 +1347,7 @@
 if (GV->getType()->getElementType() != Type::Int1Ty &&
 !GV->getType()->getElementType()->isFloatingPoint() &&
 !isa(GV->getType()->getElementType()) &&
-!GS.HasPHIUser) {
+!GS.HasPHIUser && !GS.isNotSuitableForSRA) {
   DOUT << "   *** SHRINKING TO BOOL: " << *GV;
   ShrinkGlobalToBoolean(GV, SOVConstant);
   ++NumShrunkToBool;



___
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/GlobalOpt.cpp SimplifyLibCalls.cpp

2007-03-01 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.98 -> 1.99
SimplifyLibCalls.cpp updated: 1.93 -> 1.94
---
Log message:

Prefer non-virtual calls to ConstantInt::isZero over virtual calls to 
Constant::isNullValue() in situations where it is possible.


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

 GlobalOpt.cpp|2 +-
 SimplifyLibCalls.cpp |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.98 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.99
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.98  Wed Feb 14 20:26:10 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Mar  1 18:28:51 2007
@@ -1155,7 +1155,7 @@
   // instead of a select to synthesize the desired value.
   bool IsOneZero = false;
   if (ConstantInt *CI = dyn_cast(OtherVal))
-IsOneZero = InitVal->isNullValue() && CI->equalsInt(1);
+IsOneZero = InitVal->isNullValue() && CI->isOne();
 
   while (!GV->use_empty()) {
 Instruction *UI = cast(GV->use_back());


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.93 
llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.94
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.93   Mon Feb 12 23:58:53 2007
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cppThu Mar  1 18:28:51 2007
@@ -584,7 +584,7 @@
 for (uint64_t i = 0; i < len; ++i) {
   if (ConstantInt* CI = dyn_cast(CA->getOperand(i))) {
 // Check for the null terminator
-if (CI->isNullValue())
+if (CI->isZero())
   break; // we found end of string
 else if (CI->getSExtValue() == chr) {
   char_found = true;
@@ -2023,7 +2023,7 @@
   // Check to make sure that the first operand of the GEP is an integer and
   // has value 0 so that we are sure we're indexing into the initializer.
   if (ConstantInt* op1 = dyn_cast(GEP->getOperand(1))) {
-if (!op1->isNullValue())
+if (!op1->isZero())
   return false;
   } else
 return false;
@@ -2069,7 +2069,7 @@
   for (len = start_idx; len < max_elems; len++) {
 if (ConstantInt *CI = dyn_cast(A->getOperand(len))) {
   // Check for the null terminator
-  if (CI->isNullValue())
+  if (CI->isZero())
 break; // we found end of string
 } else
   return false; // This array isn't suitable, non-int initializer



___
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/GlobalOpt.cpp

2007-02-14 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.97 -> 1.98
---
Log message:

For PR1195: http://llvm.org/PR1195 :
Rename PackedType -> VectorType, ConstantPacked -> ConstantVector, and
PackedTyID -> VectorTyID. No functional changes.


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

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


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.97 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.98
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.97  Mon Feb 12 16:56:41 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Wed Feb 14 20:26:10 2007
@@ -278,7 +278,7 @@
 if (IdxV < CS->getNumOperands()) return CS->getOperand(IdxV);
   } else if (ConstantArray *CA = dyn_cast(Agg)) {
 if (IdxV < CA->getNumOperands()) return CA->getOperand(IdxV);
-  } else if (ConstantPacked *CP = dyn_cast(Agg)) {
+  } else if (ConstantVector *CP = dyn_cast(Agg)) {
 if (IdxV < CP->getNumOperands()) return CP->getOperand(IdxV);
   } else if (isa(Agg)) {
 if (const StructType *STy = dyn_cast(Agg->getType())) {
@@ -398,7 +398,7 @@
 unsigned NumElements = 0;
 if (const ArrayType *ATy = dyn_cast(STy))
   NumElements = ATy->getNumElements();
-else if (const PackedType *PTy = dyn_cast(STy))
+else if (const VectorType *PTy = dyn_cast(STy))
   NumElements = PTy->getNumElements();
 else
   assert(0 && "Unknown aggregate sequential type!");
@@ -1346,7 +1346,7 @@
   if (Constant *SOVConstant = dyn_cast(GS.StoredOnceValue))
 if (GV->getType()->getElementType() != Type::Int1Ty &&
 !GV->getType()->getElementType()->isFloatingPoint() &&
-!isa(GV->getType()->getElementType()) &&
+!isa(GV->getType()->getElementType()) &&
 !GS.HasPHIUser) {
   DOUT << "   *** SHRINKING TO BOOL: " << *GV;
   ShrinkGlobalToBoolean(GV, SOVConstant);



___
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/GlobalOpt.cpp

2007-02-01 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.93 -> 1.94
---
Log message:

Changes to support making the shift instructions be true BinaryOperators.
This feature is needed in order to support shifts of more than 255 bits
on large integer types.  This changes the syntax for llvm assembly to 
make shl, ashr and lshr instructions look like a binary operator:
   shl i32 %X, 1
instead of
   shl i32 %X, i8 1
Additionally, this should help a few passes perform additional optimizations.


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

 GlobalOpt.cpp |4 
 1 files changed, 4 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.93 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.94
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.93  Wed Jan 31 13:59:55 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Feb  1 20:16:22 2007
@@ -1728,10 +1728,6 @@
   InstResult = ConstantExpr::get(BO->getOpcode(),
  getVal(Values, BO->getOperand(0)),
  getVal(Values, BO->getOperand(1)));
-} else if (ShiftInst *SI = dyn_cast(CurInst)) {
-  InstResult = ConstantExpr::get(SI->getOpcode(),
- getVal(Values, SI->getOperand(0)),
- getVal(Values, SI->getOperand(1)));
 } else if (CmpInst *CI = dyn_cast(CurInst)) {
   InstResult = ConstantExpr::getCompare(CI->getPredicate(),
 getVal(Values, CI->getOperand(0)),



___
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/GlobalOpt.cpp SimplifyLibCalls.cpp

2007-01-31 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.92 -> 1.93
SimplifyLibCalls.cpp updated: 1.90 -> 1.91
---
Log message:

eliminate temporary vectors


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

 GlobalOpt.cpp|   11 +--
 SimplifyLibCalls.cpp |9 +++--
 2 files changed, 8 insertions(+), 12 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.92 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.93
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.92  Tue Jan 30 22:40:53 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Wed Jan 31 13:59:55 2007
@@ -452,11 +452,11 @@
 &Idxs[0], Idxs.size());
   } else {
 GetElementPtrInst *GEPI = cast(GEP);
-std::vector Idxs;
+SmallVector Idxs;
 Idxs.push_back(NullInt);
 for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
   Idxs.push_back(GEPI->getOperand(i));
-NewPtr = new GetElementPtrInst(NewPtr, Idxs,
+NewPtr = new GetElementPtrInst(NewPtr, &Idxs[0], Idxs.size(),
GEPI->getName()+"."+utostr(Val), GEPI);
   }
 GEP->replaceAllUsesWith(NewPtr);
@@ -684,10 +684,9 @@
 MallocInst *NewMI =
   new MallocInst(NewTy, Constant::getNullValue(Type::Int32Ty),
  MI->getAlignment(), MI->getName(), MI);
-std::vector Indices;
-Indices.push_back(Constant::getNullValue(Type::Int32Ty));
-Indices.push_back(Indices[0]);
-Value *NewGEP = new GetElementPtrInst(NewMI, Indices,
+Value* Indices[2];
+Indices[0] = Indices[1] = Constant::getNullValue(Type::Int32Ty);
+Value *NewGEP = new GetElementPtrInst(NewMI, Indices, 2,
   NewMI->getName()+".el0", MI);
 MI->replaceAllUsesWith(NewGEP);
 MI->eraseFromParent();


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.90 
llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.91
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.90   Tue Jan 30 14:08:38 2007
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cppWed Jan 31 13:59:55 2007
@@ -505,10 +505,8 @@
 // Now that we have the destination's length, we must index into the
 // destination's pointer to get the actual memcpy destination (end of
 // the string .. we're concatenating).
-std::vector idx;
-idx.push_back(strlen_inst);
 GetElementPtrInst* gep =
-  new GetElementPtrInst(dest,idx,dest->getName()+".indexed",ci);
+  new GetElementPtrInst(dest, strlen_inst, dest->getName()+".indexed", ci);
 
 // We have enough information to now generate the memcpy call to
 // do the concatenation for us.
@@ -596,9 +594,8 @@
 // strchr(s,c)  -> offset_of_in(c,s)
 //(if c is a constant integer and s is a constant string)
 if (char_found) {
-  std::vector indices;
-  indices.push_back(ConstantInt::get(Type::Int64Ty,offset));
-  GetElementPtrInst* GEP = new GetElementPtrInst(ci->getOperand(1),indices,
+  Value* Idx = ConstantInt::get(Type::Int64Ty,offset);
+  GetElementPtrInst* GEP = new GetElementPtrInst(ci->getOperand(1), Idx, 
   ci->getOperand(1)->getName()+".strchr",ci);
   ci->replaceAllUsesWith(GEP);
 } else {



___
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/GlobalOpt.cpp

2007-01-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.91 -> 1.92
---
Log message:

eliminate temporary vectors


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

 GlobalOpt.cpp |   21 -
 1 files changed, 12 insertions(+), 9 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.91 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.92
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.91  Tue Jan 30 17:46:24 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Tue Jan 30 22:40:53 2007
@@ -25,6 +25,7 @@
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include 
@@ -443,11 +444,12 @@
 // Form a shorter GEP if needed.
 if (GEP->getNumOperands() > 3)
   if (ConstantExpr *CE = dyn_cast(GEP)) {
-std::vector Idxs;
+SmallVector Idxs;
 Idxs.push_back(NullInt);
 for (unsigned i = 3, e = CE->getNumOperands(); i != e; ++i)
   Idxs.push_back(CE->getOperand(i));
-NewPtr = ConstantExpr::getGetElementPtr(cast(NewPtr), Idxs);
+NewPtr = ConstantExpr::getGetElementPtr(cast(NewPtr),
+&Idxs[0], Idxs.size());
   } else {
 GetElementPtrInst *GEPI = cast(GEP);
 std::vector Idxs;
@@ -576,16 +578,17 @@
   }
 } else if (GetElementPtrInst *GEPI = dyn_cast(I)) {
   // Should handle GEP here.
-  std::vector Indices;
-  Indices.reserve(GEPI->getNumOperands()-1);
+  SmallVector Idxs;
+  Idxs.reserve(GEPI->getNumOperands()-1);
   for (unsigned i = 1, e = GEPI->getNumOperands(); i != e; ++i)
 if (Constant *C = dyn_cast(GEPI->getOperand(i)))
-  Indices.push_back(C);
+  Idxs.push_back(C);
 else
   break;
-  if (Indices.size() == GEPI->getNumOperands()-1)
+  if (Idxs.size() == GEPI->getNumOperands()-1)
 Changed |= OptimizeAwayTrappingUsesOfValue(GEPI,
-ConstantExpr::getGetElementPtr(NewV, Indices));
+ConstantExpr::getGetElementPtr(NewV, &Idxs[0],
+   Idxs.size()));
   if (GEPI->use_empty()) {
 Changed = true;
 GEPI->eraseFromParent();
@@ -1744,10 +1747,10 @@
getVal(Values, SI->getOperand(2)));
 } else if (GetElementPtrInst *GEP = dyn_cast(CurInst)) {
   Constant *P = getVal(Values, GEP->getOperand(0));
-  std::vector GEPOps;
+  SmallVector GEPOps;
   for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
 GEPOps.push_back(getVal(Values, GEP->getOperand(i)));
-  InstResult = ConstantExpr::getGetElementPtr(P, GEPOps);
+  InstResult = ConstantExpr::getGetElementPtr(P, &GEPOps[0], 
GEPOps.size());
 } else if (LoadInst *LI = dyn_cast(CurInst)) {
   if (LI->isVolatile()) return false;  // no volatile accesses.
   InstResult = ComputeLoadResult(getVal(Values, LI->getOperand(0)),



___
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/GlobalOpt.cpp

2007-01-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.90 -> 1.91
---
Log message:

Adjust #includes to match movement of constant folding code from transformutils 
to libanalysis.


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

 GlobalOpt.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.90 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.91
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.90  Tue Jan 30 17:14:52 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Tue Jan 30 17:46:24 2007
@@ -22,9 +22,9 @@
 #include "llvm/IntrinsicInst.h"
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
-#include "llvm/Support/Debug.h"
+#include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Target/TargetData.h"
-#include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include 



___
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/GlobalOpt.cpp

2007-01-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.89 -> 1.90
---
Log message:

adjust to api change


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

 GlobalOpt.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.89 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.90
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.89  Tue Jan 30 14:08:38 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Tue Jan 30 17:14:52 2007
@@ -1775,7 +1775,8 @@
   
   if (Callee->isDeclaration()) {
 // If this is a function we can constant fold, do it.
-if (Constant *C = ConstantFoldCall(Callee, Formals)) {
+if (Constant *C = ConstantFoldCall(Callee, &Formals[0],
+   Formals.size())) {
   InstResult = C;
 } else {
   return false;



___
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/GlobalOpt.cpp

2007-01-20 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.87 -> 1.88
---
Log message:

For PR970: http://llvm.org/PR970 :
Clean up handling of isFloatingPoint() and dealing with PackedType.
Patch by Gordon Henriksen!


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

 GlobalOpt.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.87 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.88
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.87  Fri Jan 12 12:30:11 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sat Jan 20 18:29:25 2007
@@ -1343,6 +1343,7 @@
   if (Constant *SOVConstant = dyn_cast(GS.StoredOnceValue))
 if (GV->getType()->getElementType() != Type::Int1Ty &&
 !GV->getType()->getElementType()->isFloatingPoint() &&
+!isa(GV->getType()->getElementType()) &&
 !GS.HasPHIUser) {
   DOUT << "   *** SHRINKING TO BOOL: " << *GV;
   ShrinkGlobalToBoolean(GV, SOVConstant);



___
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/GlobalOpt.cpp

2007-01-12 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.86 -> 1.87
---
Log message:

Branch conditions must be i1


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

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


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.86 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.87
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.86  Thu Jan 11 22:24:45 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Fri Jan 12 12:30:11 2007
@@ -1799,10 +1799,8 @@
 } else {
   ConstantInt *Cond =
 dyn_cast(getVal(Values, BI->getCondition()));
+  if (!Cond) return false;  // Cannot determine.
 
-  // Cannot determine.
-  if (!Cond || Cond->getType() != Type::Int1Ty) 
-return false;  
   NewBB = BI->getSuccessor(!Cond->getZExtValue());  
 }
   } else if (SwitchInst *SI = dyn_cast(CurInst)) {



___
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/GlobalOpt.cpp

2007-01-11 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.85 -> 1.86
---
Log message:

Implement review feedback for the ConstantBool->ConstantInt merge. Chris
recommended that getBoolValue be replaced with getZExtValue and that
get(bool) be replaced by get(const Type*, uint64_t). This implements
those changes.


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

 GlobalOpt.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.85 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.86
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.85  Thu Jan 11 12:21:29 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Jan 11 22:24:45 2007
@@ -1161,7 +1161,7 @@
   // Only do this if we weren't storing a loaded value.
   Value *StoreVal;
   if (StoringOther || SI->getOperand(0) == InitVal)
-StoreVal = ConstantInt::get(StoringOther);
+StoreVal = ConstantInt::get(Type::Int1Ty, StoringOther);
   else {
 // Otherwise, we are storing a previously loaded copy.  To do this,
 // change the copy from copying the original value to just copying the
@@ -1803,7 +1803,7 @@
   // Cannot determine.
   if (!Cond || Cond->getType() != Type::Int1Ty) 
 return false;  
-  NewBB = BI->getSuccessor(!Cond->getBoolValue());  
+  NewBB = BI->getSuccessor(!Cond->getZExtValue());  
 }
   } else if (SwitchInst *SI = dyn_cast(CurInst)) {
 ConstantInt *Val =



___
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/GlobalOpt.cpp LowerSetJmp.cpp SimplifyLibCalls.cpp

2007-01-11 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.84 -> 1.85
LowerSetJmp.cpp updated: 1.36 -> 1.37
SimplifyLibCalls.cpp updated: 1.83 -> 1.84
---
Log message:

Rename BoolTy as Int1Ty. Patch by Sheng Zhou.


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

 GlobalOpt.cpp|   10 +-
 LowerSetJmp.cpp  |2 +-
 SimplifyLibCalls.cpp |2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.84 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.85
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.84  Thu Jan 11 06:24:14 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Jan 11 12:21:29 2007
@@ -710,7 +710,7 @@
   // If there is a comparison against null, we will insert a global bool to
   // keep track of whether the global was initialized yet or not.
   GlobalVariable *InitBool =
-new GlobalVariable(Type::BoolTy, false, GlobalValue::InternalLinkage,
+new GlobalVariable(Type::Int1Ty, false, GlobalValue::InternalLinkage,
ConstantInt::getFalse(), GV->getName()+".init");
   bool InitBoolUsed = false;
 
@@ -1139,13 +1139,13 @@
 /// values ever stored into GV are its initializer and OtherVal.
 static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
   // Create the new global, initializing it to false.
-  GlobalVariable *NewGV = new GlobalVariable(Type::BoolTy, false,
+  GlobalVariable *NewGV = new GlobalVariable(Type::Int1Ty, false,
  GlobalValue::InternalLinkage, ConstantInt::getFalse(),
  GV->getName()+".b");
   GV->getParent()->getGlobalList().insert(GV, NewGV);
 
   Constant *InitVal = GV->getInitializer();
-  assert(InitVal->getType() != Type::BoolTy && "No reason to shrink to bool!");
+  assert(InitVal->getType() != Type::Int1Ty && "No reason to shrink to bool!");
 
   // If initialized to zero and storing one into the global, we can use a cast
   // instead of a select to synthesize the desired value.
@@ -1341,7 +1341,7 @@
   // Otherwise, if the global was not a boolean, we can shrink it to be a
   // boolean.
   if (Constant *SOVConstant = dyn_cast(GS.StoredOnceValue))
-if (GV->getType()->getElementType() != Type::BoolTy &&
+if (GV->getType()->getElementType() != Type::Int1Ty &&
 !GV->getType()->getElementType()->isFloatingPoint() &&
 !GS.HasPHIUser) {
   DOUT << "   *** SHRINKING TO BOOL: " << *GV;
@@ -1801,7 +1801,7 @@
 dyn_cast(getVal(Values, BI->getCondition()));
 
   // Cannot determine.
-  if (!Cond || Cond->getType() != Type::BoolTy) 
+  if (!Cond || Cond->getType() != Type::Int1Ty) 
 return false;  
   NewBB = BI->getSuccessor(!Cond->getBoolValue());  
 }


Index: llvm/lib/Transforms/IPO/LowerSetJmp.cpp
diff -u llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.36 
llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.37
--- llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.36Sun Jan  7 00:59:47 2007
+++ llvm/lib/Transforms/IPO/LowerSetJmp.cpp Thu Jan 11 12:21:29 2007
@@ -223,7 +223,7 @@
 
   // bool __llvm_sjljeh_is_longjmp_exception()
   IsLJException = M.getOrInsertFunction("__llvm_sjljeh_is_longjmp_exception",
-Type::BoolTy, (Type *)0);
+Type::Int1Ty, (Type *)0);
 
   // int __llvm_sjljeh_get_longjmp_value()
   GetLJValue = M.getOrInsertFunction("__llvm_sjljeh_get_longjmp_value",


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.83 
llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.84
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.83   Sun Jan  7 15:45:41 2007
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cppThu Jan 11 12:21:29 2007
@@ -940,7 +940,7 @@
   cast(IC->getOperand(1))->isNullValue())
 continue;
 } else if (CastInst *CI = dyn_cast(User))
-  if (CI->getType() == Type::BoolTy)
+  if (CI->getType() == Type::Int1Ty)
 continue;
 // Unknown instruction.
 return false;



___
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/GlobalOpt.cpp

2007-01-11 Thread Zhou Sheng


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.83 -> 1.84
---
Log message:

For PR1043: http://llvm.org/PR1043 :
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.


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

 GlobalOpt.cpp |   21 -
 1 files changed, 12 insertions(+), 9 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.83 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.84
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.83  Tue Jan  9 17:29:37 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Jan 11 06:24:14 2007
@@ -711,7 +711,7 @@
   // keep track of whether the global was initialized yet or not.
   GlobalVariable *InitBool =
 new GlobalVariable(Type::BoolTy, false, GlobalValue::InternalLinkage,
-   ConstantBool::getFalse(), GV->getName()+".init");
+   ConstantInt::getFalse(), GV->getName()+".init");
   bool InitBoolUsed = false;
 
   // Loop over all uses of GV, processing them in turn.
@@ -731,7 +731,7 @@
   default: assert(0 && "Unknown ICmp Predicate!");
   case ICmpInst::ICMP_ULT:
   case ICmpInst::ICMP_SLT:
-LV = ConstantBool::getFalse();   // X < null -> always false
+LV = ConstantInt::getFalse();   // X < null -> always false
 break;
   case ICmpInst::ICMP_ULE:
   case ICmpInst::ICMP_SLE:
@@ -753,7 +753,7 @@
 } else {
   StoreInst *SI = cast(GV->use_back());
   // The global is initialized when the store to it occurs.
-  new StoreInst(ConstantBool::getTrue(), InitBool, SI);
+  new StoreInst(ConstantInt::getTrue(), InitBool, SI);
   SI->eraseFromParent();
 }
 
@@ -1140,7 +1140,7 @@
 static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
   // Create the new global, initializing it to false.
   GlobalVariable *NewGV = new GlobalVariable(Type::BoolTy, false,
- GlobalValue::InternalLinkage, ConstantBool::getFalse(),
+ GlobalValue::InternalLinkage, ConstantInt::getFalse(),
  GV->getName()+".b");
   GV->getParent()->getGlobalList().insert(GV, NewGV);
 
@@ -1161,7 +1161,7 @@
   // Only do this if we weren't storing a loaded value.
   Value *StoreVal;
   if (StoringOther || SI->getOperand(0) == InitVal)
-StoreVal = ConstantBool::get(StoringOther);
+StoreVal = ConstantInt::get(StoringOther);
   else {
 // Otherwise, we are storing a previously loaded copy.  To do this,
 // change the copy from copying the original value to just copying the
@@ -1797,10 +1797,13 @@
 if (BI->isUnconditional()) {
   NewBB = BI->getSuccessor(0);
 } else {
-  ConstantBool *Cond =
-dyn_cast(getVal(Values, BI->getCondition()));
-  if (!Cond) return false;  // Cannot determine.
-  NewBB = BI->getSuccessor(!Cond->getValue());  
+  ConstantInt *Cond =
+dyn_cast(getVal(Values, BI->getCondition()));
+
+  // Cannot determine.
+  if (!Cond || Cond->getType() != Type::BoolTy) 
+return false;  
+  NewBB = BI->getSuccessor(!Cond->getBoolValue());  
 }
   } else if (SwitchInst *SI = dyn_cast(CurInst)) {
 ConstantInt *Val =



___
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/GlobalOpt.cpp

2007-01-09 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.82 -> 1.83
---
Log message:

Fix a bug in heap-sra that caused compilation failure of office-ispell.



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

 GlobalOpt.cpp |   22 +++---
 1 files changed, 19 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.82 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.83
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.82  Sat Dec 30 23:48:39 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Tue Jan  9 17:29:37 2007
@@ -1016,9 +1016,25 @@
   // loads, and all uses of those loads are simple.  Rewrite them to use loads
   // of the per-field globals instead.
   while (!GV->use_empty()) {
-LoadInst *LI = cast(GV->use_back());
-RewriteUsesOfLoadForHeapSRoA(LI, FieldGlobals);
-LI->eraseFromParent();
+if (LoadInst *LI = dyn_cast(GV->use_back())) {
+  RewriteUsesOfLoadForHeapSRoA(LI, FieldGlobals);
+  LI->eraseFromParent();
+} else {
+  // Must be a store of null.
+  StoreInst *SI = cast(GV->use_back());
+  assert(isa(SI->getOperand(0)) &&
+ cast(SI->getOperand(0))->isNullValue() &&
+ "Unexpected heap-sra user!");
+  
+  // Insert a store of null into each global.
+  for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) {
+Constant *Null = 
+  Constant::getNullValue(FieldGlobals[i]->getType()->getElementType());
+new StoreInst(Null, FieldGlobals[i], SI);
+  }
+  // Erase the original store.
+  SI->eraseFromParent();
+}
   }
 
   // The old global is now dead, remove it.



___
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/GlobalOpt.cpp SimplifyLibCalls.cpp

2006-12-22 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.80 -> 1.81
SimplifyLibCalls.cpp updated: 1.79 -> 1.80
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and 
been replaced with ICmpInst and FCmpInst.


---
Diffs of the changes:  (+55 -49)

 GlobalOpt.cpp|   64 ---
 SimplifyLibCalls.cpp |   40 +++
 2 files changed, 55 insertions(+), 49 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.80 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.81
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.80  Tue Dec 19 16:09:18 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sat Dec 23 00:05:41 2006
@@ -238,7 +238,7 @@
   if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
 GS.isNotSuitableForSRA = true;
 GS.HasPHIUser = true;
-  } else if (isa(I)) {
+  } else if (isa(I)) {
 GS.isNotSuitableForSRA = true;
   } else if (isa(I) || isa(I)) {
 if (I->getOperand(1) == V)
@@ -507,7 +507,7 @@
   if (!AllUsesOfValueWillTrapIfNull(CI)) return false;
 } else if (GetElementPtrInst *GEPI = dyn_cast(*UI)) {
   if (!AllUsesOfValueWillTrapIfNull(GEPI)) return false;
-} else if (isa(*UI) &&
+} else if (isa(*UI) &&
isa(UI->getOperand(1))) {
   // Ignore setcc X, null
 } else {
@@ -720,29 +720,33 @@
 if (LoadInst *LI = dyn_cast(GV->use_back())) {
   while (!LI->use_empty()) {
 Use &LoadUse = LI->use_begin().getUse();
-if (!isa(LoadUse.getUser()))
+if (!isa(LoadUse.getUser()))
   LoadUse = RepValue;
 else {
-  // Replace the setcc X, 0 with a use of the bool value.
-  SetCondInst *SCI = cast(LoadUse.getUser());
-  Value *LV = new LoadInst(InitBool, InitBool->getName()+".val", SCI);
+  ICmpInst *CI = cast(LoadUse.getUser());
+  // Replace the cmp X, 0 with a use of the bool value.
+  Value *LV = new LoadInst(InitBool, InitBool->getName()+".val", CI);
   InitBoolUsed = true;
-  switch (SCI->getOpcode()) {
-  default: assert(0 && "Unknown opcode!");
-  case Instruction::SetLT:
+  switch (CI->getPredicate()) {
+  default: assert(0 && "Unknown ICmp Predicate!");
+  case ICmpInst::ICMP_ULT:
+  case ICmpInst::ICMP_SLT:
 LV = ConstantBool::getFalse();   // X < null -> always false
 break;
-  case Instruction::SetEQ:
-  case Instruction::SetLE:
-LV = BinaryOperator::createNot(LV, "notinit", SCI);
+  case ICmpInst::ICMP_ULE:
+  case ICmpInst::ICMP_SLE:
+  case ICmpInst::ICMP_EQ:
+LV = BinaryOperator::createNot(LV, "notinit", CI);
 break;
-  case Instruction::SetNE:
-  case Instruction::SetGE:
-  case Instruction::SetGT:
+  case ICmpInst::ICMP_NE:
+  case ICmpInst::ICMP_UGE:
+  case ICmpInst::ICMP_SGE:
+  case ICmpInst::ICMP_UGT:
+  case ICmpInst::ICMP_SGT:
 break;  // no change.
   }
-  SCI->replaceAllUsesWith(LV);
-  SCI->eraseFromParent();
+  CI->replaceAllUsesWith(LV);
+  CI->eraseFromParent();
 }
   }
   LI->eraseFromParent();
@@ -783,7 +787,7 @@
 static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Instruction *V,
   GlobalVariable *GV) {
   for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI)
-if (isa(*UI) || isa(*UI)) {
+if (isa(*UI) || isa(*UI)) {
   // Fine, ignore.
 } else if (StoreInst *SI = dyn_cast(*UI)) {
   if (SI->getOperand(0) == V && SI->getOperand(1) != GV)
@@ -832,8 +836,8 @@
   for (Value::use_iterator UI = LI->use_begin(), E = LI->use_end(); UI != 
E; 
++UI) {
 // Comparison against null is ok.
-if (SetCondInst *SCI = dyn_cast(*UI)) {
-  if (!isa(SCI->getOperand(1)))
+if (ICmpInst *ICI = dyn_cast(*UI)) {
+  if (!isa(ICI->getOperand(1)))
 return false;
   continue;
 }
@@ -865,7 +869,7 @@
 Instruction *User = Ptr->use_back();
 
 // If this is a comparison against null, handle it.
-if (SetCondInst *SCI = dyn_cast(User)) {
+if (ICmpInst *SCI = dyn_cast(User)) {
   assert(isa(SCI->getOperand(1)));
   // If we have a setcc of the loaded pointer, we can use a setcc of any
   // field.
@@ -877,9 +881,9 @@
 NPtr = InsertedLoadsForPtr.back();
   }
   
-  Value *New = new SetCondInst(SCI->getOpcode(), NPtr,
-   Constant::getNullValue(NPtr->getType()),
-   SCI->getName(), SCI);

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

2006-12-12 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.78 -> 1.79
---
Log message:

Replace inferred getCast(V,Ty) calls with more strict variants.
Rename getZeroExtend and getSignExtend to getZExt and getSExt to match
the the casting mnemonics in the rest of LLVM.


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

 GlobalOpt.cpp |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.78 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.79
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.78  Wed Dec  6 19:30:31 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Tue Dec 12 17:36:14 2006
@@ -708,8 +708,8 @@
 
   Constant *RepValue = NewGV;
   if (NewGV->getType() != GV->getType()->getElementType())
-RepValue = ConstantExpr::getCast(Instruction::BitCast,
- RepValue, 
GV->getType()->getElementType());
+RepValue = ConstantExpr::getBitCast(RepValue, 
+GV->getType()->getElementType());
 
   // If there is a comparison against null, we will insert a global bool to
   // keep track of whether the global was initialized yet or not.
@@ -1058,8 +1058,7 @@
   GV->getInitializer()->isNullValue()) {
 if (Constant *SOVC = dyn_cast(StoredOnceVal)) {
   if (GV->getInitializer()->getType() != SOVC->getType())
-SOVC = ConstantExpr::getCast(Instruction::BitCast,
- SOVC, GV->getInitializer()->getType());
+SOVC = ConstantExpr::getBitCast(SOVC, GV->getInitializer()->getType());
 
   // Optimize away any trapping uses of the loaded value.
   if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC))
@@ -1510,7 +1509,7 @@
   if (!GCL->use_empty()) {
 Constant *V = NGV;
 if (V->getType() != GCL->getType())
-  V = ConstantExpr::getCast(Instruction::BitCast, V, GCL->getType());
+  V = ConstantExpr::getBitCast(V, GCL->getType());
 GCL->replaceAllUsesWith(V);
   }
   GCL->eraseFromParent();



___
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/GlobalOpt.cpp Internalize.cpp

2006-12-06 Thread Bill Wendling


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.77 -> 1.78
Internalize.cpp updated: 1.38 -> 1.39
---
Log message:

Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.


---
Diffs of the changes:  (+19 -20)

 GlobalOpt.cpp   |   36 ++--
 Internalize.cpp |3 +--
 2 files changed, 19 insertions(+), 20 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.77 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.78
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.77  Wed Dec  6 11:46:32 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Wed Dec  6 19:30:31 2006
@@ -494,17 +494,17 @@
   // Will trap.
 } else if (StoreInst *SI = dyn_cast(*UI)) {
   if (SI->getOperand(0) == V) {
-//llvm_cerr << "NONTRAPPING USE: " << **UI;
+//cerr << "NONTRAPPING USE: " << **UI;
 return false;  // Storing the value.
   }
 } else if (CallInst *CI = dyn_cast(*UI)) {
   if (CI->getOperand(0) != V) {
-//llvm_cerr << "NONTRAPPING USE: " << **UI;
+//cerr << "NONTRAPPING USE: " << **UI;
 return false;  // Not calling the ptr
   }
 } else if (InvokeInst *II = dyn_cast(*UI)) {
   if (II->getOperand(0) != V) {
-//llvm_cerr << "NONTRAPPING USE: " << **UI;
+//cerr << "NONTRAPPING USE: " << **UI;
 return false;  // Not calling the ptr
   }
 } else if (CastInst *CI = dyn_cast(*UI)) {
@@ -515,7 +515,7 @@
isa(UI->getOperand(1))) {
   // Ignore setcc X, null
 } else {
-  //llvm_cerr << "NONTRAPPING USE: " << **UI;
+  //cerr << "NONTRAPPING USE: " << **UI;
   return false;
 }
   return true;
@@ -533,7 +533,7 @@
   // Ignore stores to the global.
 } else {
   // We don't know or understand this user, bail out.
-  //llvm_cerr << "UNKNOWN USER OF GLOBAL!: " << **UI;
+  //cerr << "UNKNOWN USER OF GLOBAL!: " << **UI;
   return false;
 }
 
@@ -1206,25 +1206,25 @@
 
   if (!AnalyzeGlobal(GV, GS, PHIUsers)) {
 #if 0
-llvm_cerr << "Global: " << *GV;
-llvm_cerr << "  isLoaded = " << GS.isLoaded << "\n";
-llvm_cerr << "  StoredType = ";
+cerr << "Global: " << *GV;
+cerr << "  isLoaded = " << GS.isLoaded << "\n";
+cerr << "  StoredType = ";
 switch (GS.StoredType) {
-case GlobalStatus::NotStored: llvm_cerr << "NEVER STORED\n"; break;
-case GlobalStatus::isInitializerStored: llvm_cerr << "INIT STORED\n"; 
break;
-case GlobalStatus::isStoredOnce: llvm_cerr << "STORED ONCE\n"; break;
-case GlobalStatus::isStored: llvm_cerr << "stored\n"; break;
+case GlobalStatus::NotStored: cerr << "NEVER STORED\n"; break;
+case GlobalStatus::isInitializerStored: cerr << "INIT STORED\n"; break;
+case GlobalStatus::isStoredOnce: cerr << "STORED ONCE\n"; break;
+case GlobalStatus::isStored: cerr << "stored\n"; break;
 }
 if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue)
-  llvm_cerr << "  StoredOnceValue = " << *GS.StoredOnceValue << "\n";
+  cerr << "  StoredOnceValue = " << *GS.StoredOnceValue << "\n";
 if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions)
-  llvm_cerr << "  AccessingFunction = " << GS.AccessingFunction->getName()
+  cerr << "  AccessingFunction = " << GS.AccessingFunction->getName()
 << "\n";
-llvm_cerr << "  HasMultipleAccessingFunctions =  "
+cerr << "  HasMultipleAccessingFunctions =  "
   << GS.HasMultipleAccessingFunctions << "\n";
-llvm_cerr << "  HasNonInstructionUser = " << 
GS.HasNonInstructionUser<<"\n";
-llvm_cerr << "  isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n";
-llvm_cerr << "\n";
+cerr << "  HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n";
+cerr << "  isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n";
+cerr << "\n";
 #endif
 
 // If this is a first class global and has only one accessing function


Index: llvm/lib/Transforms/IPO/Internalize.cpp
diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.38 
llvm/lib/Transforms/IPO/Internalize.cpp:1.39
--- llvm/lib/Transforms/IPO/Internalize.cpp:1.38Wed Dec  6 11:46:32 2006
+++ llvm/lib/Transforms/IPO/Internalize.cpp Wed Dec  6 19:30:31 2006
@@ -74,8 +74,7 @@
   // Load the APIFile...
   std::ifstream In(Filename);
   if (!In.good()) {
-llvm_cerr << "WARNING: Internalize couldn't load file '" << Filename
-  << "'!\n";
+cerr << "WARNING: Internalize couldn't load file '" << Filename << "'!\n";
 return;   // Do not internalize anything...
   }
   while (In) {



___
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/GlobalOpt.cpp

2006-11-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.74 -> 1.75
---
Log message:

One more bugfix, 3 cases of making casts explicit.


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

 GlobalOpt.cpp |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.74 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.75
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.74  Thu Nov 30 11:26:08 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Nov 30 11:32:29 2006
@@ -572,7 +572,8 @@
   }
 } else if (CastInst *CI = dyn_cast(I)) {
   Changed |= OptimizeAwayTrappingUsesOfValue(CI,
-ConstantExpr::getCast(NewV, 
CI->getType()));
+ConstantExpr::getCast(CI->getOpcode(),
+  NewV, CI->getType()));
   if (CI->use_empty()) {
 Changed = true;
 CI->eraseFromParent();
@@ -670,7 +671,7 @@
 /// variable, and transforms the program as if it always contained the result 
of
 /// the specified malloc.  Because it is always the result of the specified
 /// malloc, there is no reason to actually DO the malloc.  Instead, turn the
-/// malloc into a global, and any laods of GV as uses of the new global.
+/// malloc into a global, and any loads of GV as uses of the new global.
 static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
  MallocInst *MI) {
   DOUT << "PROMOTING MALLOC GLOBAL: " << *GV << "  MALLOC = " << *MI;
@@ -707,7 +708,8 @@
 
   Constant *RepValue = NewGV;
   if (NewGV->getType() != GV->getType()->getElementType())
-RepValue = ConstantExpr::getCast(RepValue, 
GV->getType()->getElementType());
+RepValue = ConstantExpr::getCast(Instruction::BitCast,
+ RepValue, 
GV->getType()->getElementType());
 
   // If there is a comparison against null, we will insert a global bool to
   // keep track of whether the global was initialized yet or not.
@@ -1056,7 +1058,8 @@
   GV->getInitializer()->isNullValue()) {
 if (Constant *SOVC = dyn_cast(StoredOnceVal)) {
   if (GV->getInitializer()->getType() != SOVC->getType())
-SOVC = ConstantExpr::getCast(SOVC, GV->getInitializer()->getType());
+SOVC = ConstantExpr::getCast(Instruction::BitCast,
+ SOVC, GV->getInitializer()->getType());
 
   // Optimize away any trapping uses of the loaded value.
   if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC))
@@ -1507,7 +1510,7 @@
   if (!GCL->use_empty()) {
 Constant *V = NGV;
 if (V->getType() != GCL->getType())
-  V = ConstantExpr::getCast(V, GCL->getType());
+  V = ConstantExpr::getCast(Instruction::BitCast, V, GCL->getType());
 GCL->replaceAllUsesWith(V);
   }
   GCL->eraseFromParent();



___
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/GlobalOpt.cpp

2006-11-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.75 -> 1.76
---
Log message:

make it clear that this is always a zext


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

 GlobalOpt.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.75 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.76
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.75  Thu Nov 30 11:32:29 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Nov 30 11:35:08 2006
@@ -1177,7 +1177,7 @@
   LoadInst *NLI = new LoadInst(NewGV, Name+".b", LI);
   Value *NSI;
   if (IsOneZero)
-NSI = CastInst::createInferredCast(NLI, LI->getType(), Name, LI);
+NSI = new ZExtInst(NLI, LI->getType(), Name, LI);
   else
 NSI = new SelectInst(NLI, OtherVal, InitVal, Name, LI);
   LI->replaceAllUsesWith(NSI);



___
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/GlobalOpt.cpp

2006-11-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.73 -> 1.74
---
Log message:

Fix a bug in globalopt due to the recent cast patch.


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

 GlobalOpt.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.73 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.74
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.73  Sun Nov 26 19:05:10 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Nov 30 11:26:08 2006
@@ -1713,7 +1713,8 @@
  getVal(Values, SI->getOperand(0)),
  getVal(Values, SI->getOperand(1)));
 } else if (CastInst *CI = dyn_cast(CurInst)) {
-  InstResult = ConstantExpr::getCast(getVal(Values, CI->getOperand(0)),
+  InstResult = ConstantExpr::getCast(CI->getOpcode(),
+ getVal(Values, CI->getOperand(0)),
  CI->getType());
 } else if (SelectInst *SI = dyn_cast(CurInst)) {
   InstResult = ConstantExpr::getSelect(getVal(Values, SI->getOperand(0)),



___
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/GlobalOpt.cpp IndMemRemoval.cpp InlineSimple.cpp LowerSetJmp.cpp RaiseAllocations.cpp SimplifyLibCalls.cpp

2006-11-26 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.72 -> 1.73
IndMemRemoval.cpp updated: 1.5 -> 1.6
InlineSimple.cpp updated: 1.75 -> 1.76
LowerSetJmp.cpp updated: 1.31 -> 1.32
RaiseAllocations.cpp updated: 1.30 -> 1.31
SimplifyLibCalls.cpp updated: 1.72 -> 1.73
---
Log message:

For PR950: http://llvm.org/PR950 :
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


---
Diffs of the changes:  (+68 -53)

 GlobalOpt.cpp|4 +-
 IndMemRemoval.cpp|3 +
 InlineSimple.cpp |9 +
 LowerSetJmp.cpp  |6 ++-
 RaiseAllocations.cpp |   12 ---
 SimplifyLibCalls.cpp |   87 +--
 6 files changed, 68 insertions(+), 53 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.72 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.73
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.72  Sun Nov 26 04:02:32 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sun Nov 26 19:05:10 2006
@@ -329,7 +329,7 @@
 if (Init)
   SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE);
 Changed |= CleanupConstantGlobalUsers(CE, SubInit);
-  } else if (CE->getOpcode() == Instruction::Cast &&
+  } else if (CE->getOpcode() == Instruction::BitCast && 
  isa(CE->getType())) {
 // Pointer cast, delete any stores and memsets to the global.
 Changed |= CleanupConstantGlobalUsers(CE, 0);
@@ -1174,7 +1174,7 @@
   LoadInst *NLI = new LoadInst(NewGV, Name+".b", LI);
   Value *NSI;
   if (IsOneZero)
-NSI = new CastInst(NLI, LI->getType(), Name, LI);
+NSI = CastInst::createInferredCast(NLI, LI->getType(), Name, LI);
   else
 NSI = new SelectInst(NLI, OtherVal, InitVal, Name, LI);
   LI->replaceAllUsesWith(NSI);


Index: llvm/lib/Transforms/IPO/IndMemRemoval.cpp
diff -u llvm/lib/Transforms/IPO/IndMemRemoval.cpp:1.5 
llvm/lib/Transforms/IPO/IndMemRemoval.cpp:1.6
--- llvm/lib/Transforms/IPO/IndMemRemoval.cpp:1.5   Sun Nov 26 04:02:32 2006
+++ llvm/lib/Transforms/IPO/IndMemRemoval.cpp   Sun Nov 26 19:05:10 2006
@@ -74,7 +74,8 @@
  GlobalValue::LinkOnceLinkage, 
  "malloc_llvm_bounce", &M);
   BasicBlock* bb = new BasicBlock("entry",FN);
-  Instruction* c = new CastInst(FN->arg_begin(), Type::UIntTy, "c", bb);
+  Instruction* c = 
+CastInst::createInferredCast(FN->arg_begin(), Type::UIntTy, "c", bb);
   Instruction* a = new MallocInst(Type::SByteTy, c, "m", bb);
   new ReturnInst(a, bb);
   ++NumBounce;


Index: llvm/lib/Transforms/IPO/InlineSimple.cpp
diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.75 
llvm/lib/Transforms/IPO/InlineSimple.cpp:1.76
--- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.75   Thu Nov  2 14:25:50 2006
+++ llvm/lib/Transforms/IPO/InlineSimple.cppSun Nov 26 19:05:10 2006
@@ -141,14 +141,11 @@
  II != E; ++II) {
   if (isa(II)) continue;  // Debug intrinsics don't 
count.
   
-  // Noop casts don't count.
+  // Noop casts, including ptr <-> int,  don't count.
   if (const CastInst *CI = dyn_cast(II)) {
-const Type *OpTy = CI->getOperand(0)->getType();
-if (CI->getType()->isLosslesslyConvertibleTo(OpTy))
+if (CI->isLosslessCast() || isa(CI) || 
+isa(CI))
   continue;
-if ((isa(CI->getType()) && OpTy->isInteger()) ||
-(isa(OpTy) && CI->getType()->isInteger()))
-  continue;  // ptr <-> int is *probably* noop cast.
   } else if (const GetElementPtrInst *GEPI =
  dyn_cast(II)) {
 // If a GEP has all constant indices, it will probably be folded with


Index: llvm/lib/Transforms/IPO/LowerSetJmp.cpp
diff -u llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.31 
llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.32
--- llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.31Thu Nov  2 14:25:50 2006
+++ llvm/lib/Transforms/IPO/LowerSetJmp.cpp Sun Nov 26 19:05:10 2006
@@ -259,7 +259,8 @@
   // same parameters as "longjmp", except that the buffer is cast to a
   // char*. It returns "void", so it doesn't need to replace any of
   // Inst's uses and doesn't get a name.
-  CastInst* CI = new CastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst);
+  CastInst* CI = 
+new BitCastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst);
   new CallInst(ThrowLongJmp, make_vector(CI, Inst->getOperand(2), 0),
"", Inst);
 
@@ -375,7 +376,8 @@
 
   // Add this setjmp to the setjmp map.
   const Type* SBPTy = PointerType::get(Type::SByteTy);
-  CastInst* BufPtr = new CastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", 
Inst);
+  Ca

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

2006-11-01 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.69 -> 1.70
---
Log message:

Fix GlobalOpt/2006-11-01-ShrinkGlobalPhiCrash.ll and McGill/chomp


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

 GlobalOpt.cpp |   22 ++
 1 files changed, 14 insertions(+), 8 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.69 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.70
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.69  Fri Oct 20 02:07:24 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Wed Nov  1 12:03:33 2006
@@ -104,17 +104,20 @@
   /// ever stored to this global, keep track of what value it is.
   Value *StoredOnceValue;
 
-  // AccessingFunction/HasMultipleAccessingFunctions - These start out
-  // null/false.  When the first accessing function is noticed, it is recorded.
-  // When a second different accessing function is noticed,
-  // HasMultipleAccessingFunctions is set to true.
+  /// AccessingFunction/HasMultipleAccessingFunctions - These start out
+  /// null/false.  When the first accessing function is noticed, it is 
recorded.
+  /// When a second different accessing function is noticed,
+  /// HasMultipleAccessingFunctions is set to true.
   Function *AccessingFunction;
   bool HasMultipleAccessingFunctions;
 
-  // HasNonInstructionUser - Set to true if this global has a user that is not
-  // an instruction (e.g. a constant expr or GV initializer).
+  /// HasNonInstructionUser - Set to true if this global has a user that is not
+  /// an instruction (e.g. a constant expr or GV initializer).
   bool HasNonInstructionUser;
 
+  /// HasPHIUser - Set to true if this global has a user that is a PHI node.
+  bool HasPHIUser;
+  
   /// isNotSuitableForSRA - Keep track of whether any SRA preventing users of
   /// the global exist.  Such users include GEP instruction with variable
   /// indexes, and non-gep/load/store users like constant expr casts.
@@ -122,7 +125,8 @@
 
   GlobalStatus() : isLoaded(false), StoredType(NotStored), StoredOnceValue(0),
AccessingFunction(0), HasMultipleAccessingFunctions(false),
-   HasNonInstructionUser(false), isNotSuitableForSRA(false) {}
+   HasNonInstructionUser(false), HasPHIUser(false),
+   isNotSuitableForSRA(false) {}
 };
 
 
@@ -238,6 +242,7 @@
 if (PHIUsers.insert(PN).second)  // Not already visited.
   if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
 GS.isNotSuitableForSRA = true;
+GS.HasPHIUser = true;
   } else if (isa(I)) {
 GS.isNotSuitableForSRA = true;
   } else if (isa(I) || isa(I)) {
@@ -1321,7 +1326,8 @@
   // boolean.
   if (Constant *SOVConstant = dyn_cast(GS.StoredOnceValue))
 if (GV->getType()->getElementType() != Type::BoolTy &&
-!GV->getType()->getElementType()->isFloatingPoint()) {
+!GV->getType()->getElementType()->isFloatingPoint() &&
+!GS.HasPHIUser) {
   DEBUG(std::cerr << "   *** SHRINKING TO BOOL: " << *GV);
   ShrinkGlobalToBoolean(GV, SOVConstant);
   ++NumShrunkToBool;



___
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/GlobalOpt.cpp

2006-09-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.67 -> 1.68
---
Log message:

Fix debug output


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

 GlobalOpt.cpp |3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.67 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.68
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.67  Sat Sep 30 18:32:09 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sat Sep 30 18:32:50 2006
@@ -913,7 +913,7 @@
 /// PerformHeapAllocSRoA - MI is an allocation of an array of structures.  
Break
 /// it up into multiple allocations of arrays of the fields.
 static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst 
*MI){
-  /*DEBUG*/(std::cerr << "SROA HEAP ALLOC: " << *GV << "  MALLOC = " << *MI);
+  DEBUG(std::cerr << "SROA HEAP ALLOC: " << *GV << "  MALLOC = " << *MI);
   const StructType *STy = cast(MI->getAllocatedType());
 
   // There is guaranteed to be at least one use of the malloc (storing
@@ -1872,7 +1872,6 @@
 
 
 
-
 /// OptimizeGlobalCtorsList - Simplify and evaluation global ctors if possible.
 /// Return true if anything changed.
 bool GlobalOpt::OptimizeGlobalCtorsList(GlobalVariable *&GCL) {



___
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/GlobalOpt.cpp

2006-09-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.66 -> 1.67
---
Log message:

Implement SRA of heap allocations.


---
Diffs of the changes:  (+266 -10)

 GlobalOpt.cpp |  276 +++---
 1 files changed, 266 insertions(+), 10 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.66 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.67
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.66  Sat Sep 30 14:40:30 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sat Sep 30 18:32:09 2006
@@ -36,6 +36,7 @@
   Statistic<> NumMarked   ("globalopt", "Number of globals marked constant");
   Statistic<> NumSRA  ("globalopt", "Number of aggregate globals broken "
"into scalars");
+  Statistic<> NumHeapSRA  ("globalopt", "Number of heap objects SRA'd");
   Statistic<> NumSubstitute("globalopt",
 "Number of globals with initializers stored into 
them");
   Statistic<> NumDeleted  ("globalopt", "Number of globals deleted");
@@ -794,9 +795,235 @@
   return false;
 }
   return true;
+}
 
+/// ReplaceUsesOfMallocWithGlobal - The Alloc pointer is stored into GV
+/// somewhere.  Transform all uses of the allocation into loads from the
+/// global and uses of the resultant pointer.  Further, delete the store into
+/// GV.  This assumes that these value pass the 
+/// 'ValueIsOnlyUsedLocallyOrStoredToOneGlobal' predicate.
+static void ReplaceUsesOfMallocWithGlobal(Instruction *Alloc, 
+  GlobalVariable *GV) {
+  while (!Alloc->use_empty()) {
+Instruction *U = Alloc->use_back();
+if (StoreInst *SI = dyn_cast(U)) {
+  // If this is the store of the allocation into the global, remove it.
+  if (SI->getOperand(1) == GV) {
+SI->eraseFromParent();
+continue;
+  }
+}
+
+// Insert a load from the global, and use it instead of the malloc.
+Value *NL = new LoadInst(GV, GV->getName()+".val", U);
+U->replaceUsesOfWith(Alloc, NL);
+  }
 }
 
+/// GlobalLoadUsesSimpleEnoughForHeapSRA - If all users of values loaded from
+/// GV are simple enough to perform HeapSRA, return true.
+static bool GlobalLoadUsesSimpleEnoughForHeapSRA(GlobalVariable *GV) {
+  for (Value::use_iterator UI = GV->use_begin(), E = GV->use_end(); UI != E; 
+   ++UI)
+if (LoadInst *LI = dyn_cast(*UI)) {
+  // We permit two users of the load: setcc comparing against the null
+  // pointer, and a getelementptr of a specific form.
+  for (Value::use_iterator UI = LI->use_begin(), E = LI->use_end(); UI != 
E; 
+   ++UI) {
+// Comparison against null is ok.
+if (SetCondInst *SCI = dyn_cast(*UI)) {
+  if (!isa(SCI->getOperand(1)))
+return false;
+  continue;
+}
+
+// getelementptr is also ok, but only a simple form.
+GetElementPtrInst *GEPI = dyn_cast(*UI);
+if (!GEPI) return false;
+
+// Must index into the array and into the struct.
+if (GEPI->getNumOperands() < 3)
+  return false;
+
+// Otherwise the GEP is ok.
+continue;
+  }
+}
+  return true;
+}
+
+/// RewriteUsesOfLoadForHeapSRoA - We are performing Heap SRoA on a global.  
Ptr
+/// is a value loaded from the global.  Eliminate all uses of Ptr, making them
+/// use FieldGlobals instead.  All uses of loaded values satisfy
+/// GlobalLoadUsesSimpleEnoughForHeapSRA.
+static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Ptr, 
+ const std::vector &FieldGlobals) 
{
+  std::vector InsertedLoadsForPtr;
+  //InsertedLoadsForPtr.resize(FieldGlobals.size());
+  while (!Ptr->use_empty()) {
+Instruction *User = Ptr->use_back();
+
+// If this is a comparison against null, handle it.
+if (SetCondInst *SCI = dyn_cast(User)) {
+  assert(isa(SCI->getOperand(1)));
+  // If we have a setcc of the loaded pointer, we can use a setcc of any
+  // field.
+  Value *NPtr;
+  if (InsertedLoadsForPtr.empty()) {
+NPtr = new LoadInst(FieldGlobals[0], Ptr->getName()+".f0", Ptr);
+InsertedLoadsForPtr.push_back(Ptr);
+  } else {
+NPtr = InsertedLoadsForPtr.back();
+  }
+  
+  Value *New = new SetCondInst(SCI->getOpcode(), NPtr,
+   Constant::getNullValue(NPtr->getType()),
+   SCI->getName(), SCI);
+  SCI->replaceAllUsesWith(New);
+  SCI->eraseFromParent();
+  continue;
+}
+
+// Otherwise, this should be: 'getelementptr Ptr, Idx, uint FieldNo ...'
+GetElementPtrInst *GEPI = cast(User);
+assert(GEPI->getNumOperands() >= 3 && 
isa(GEPI->getOperand(2))
+   && "Unexpected GEPI!");
+
+// Load the pointer for this field.
+unsigned FieldNo = cast(GEPI->getOperand(2))->getValue();
+if (InsertedLoadsForPtr.

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

2006-09-30 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.65 -> 1.66
---
Log message:

Add some ifdef'd out debug info


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

 GlobalOpt.cpp |   33 ++---
 1 files changed, 30 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.65 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.66
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.65  Thu Sep 28 18:35:21 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sat Sep 30 14:40:30 2006
@@ -831,6 +831,10 @@
   if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC))
 return true;
 } else if (MallocInst *MI = dyn_cast(StoredOnceVal)) {
+  // If this is a malloc of an abstract type, don't touch it.
+  if (!MI->getAllocatedType()->isSized())
+return false;
+  
   // If we have a global that is only initialized with a fixed size malloc,
   // and if all users of the malloc trap, and if the malloc'd address is 
not
   // put anywhere else, transform the program to use global memory instead
@@ -839,15 +843,15 @@
   // that we restrict this transformation to only working on small
   // allocations (2048 bytes currently), as we don't want to introduce a 
16M
   // global or something.
-  if (ConstantInt *NElements = dyn_cast(MI->getArraySize()))
-if (MI->getAllocatedType()->isSized() &&
-NElements->getRawValue()*
+  if (ConstantInt *NElements = dyn_cast(MI->getArraySize())) {
+if (NElements->getRawValue()*
  TD.getTypeSize(MI->getAllocatedType()) < 2048 &&
 AllUsesOfLoadedValueWillTrapIfNull(GV) &&
 ValueIsOnlyUsedLocallyOrStoredToOneGlobal(MI, GV)) {
   GVI = OptimizeGlobalAddressOfMalloc(GV, MI);
   return true;
 }
+  }
 }
   }
 
@@ -938,6 +942,28 @@
   }
 
   if (!AnalyzeGlobal(GV, GS, PHIUsers)) {
+#if 0
+std::cerr << "Global: " << *GV;
+std::cerr << "  isLoaded = " << GS.isLoaded << "\n";
+std::cerr << "  StoredType = ";
+switch (GS.StoredType) {
+case GlobalStatus::NotStored: std::cerr << "NEVER STORED\n"; break;
+case GlobalStatus::isInitializerStored: std::cerr << "INIT STORED\n"; 
break;
+case GlobalStatus::isStoredOnce: std::cerr << "STORED ONCE\n"; break;
+case GlobalStatus::isStored: std::cerr << "stored\n"; break;
+}
+if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue)
+  std::cerr << "  StoredOnceValue = " << *GS.StoredOnceValue << "\n";
+if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions)
+  std::cerr << "  AccessingFunction = " << GS.AccessingFunction->getName()
+<< "\n";
+std::cerr << "  HasMultipleAccessingFunctions =  "
+  << GS.HasMultipleAccessingFunctions << "\n";
+std::cerr << "  HasNonInstructionUser = " << 
GS.HasNonInstructionUser<<"\n";
+std::cerr << "  isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n";
+std::cerr << "\n";
+#endif
+
 // If this is a first class global and has only one accessing function
 // and this function is main (which we know is not recursive we can make
 // this global a local variable) we replace the global with a local alloca
@@ -963,6 +989,7 @@
   ++NumLocalized;
   return true;
 }
+
 // If the global is never loaded (but may be stored to), it is dead.
 // Delete it now.
 if (!GS.isLoaded) {



___
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/GlobalOpt.cpp

2006-09-28 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.64 -> 1.65
---
Log message:


Eliminate ConstantBool::True and ConstantBool::False.  Instead, provide
ConstantBool::getTrue() and ConstantBool::getFalse().


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

 GlobalOpt.cpp |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.64 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.65
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.64  Thu Sep 14 13:23:27 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Sep 28 18:35:21 2006
@@ -709,7 +709,7 @@
   // keep track of whether the global was initialized yet or not.
   GlobalVariable *InitBool =
 new GlobalVariable(Type::BoolTy, false, GlobalValue::InternalLinkage,
-   ConstantBool::False, GV->getName()+".init");
+   ConstantBool::getFalse(), GV->getName()+".init");
   bool InitBoolUsed = false;
 
   // Loop over all uses of GV, processing them in turn.
@@ -728,7 +728,7 @@
   switch (SCI->getOpcode()) {
   default: assert(0 && "Unknown opcode!");
   case Instruction::SetLT:
-LV = ConstantBool::False;   // X < null -> always false
+LV = ConstantBool::getFalse();   // X < null -> always false
 break;
   case Instruction::SetEQ:
   case Instruction::SetLE:
@@ -747,7 +747,7 @@
 } else {
   StoreInst *SI = cast(GV->use_back());
   // The global is initialized when the store to it occurs.
-  new StoreInst(ConstantBool::True, InitBool, SI);
+  new StoreInst(ConstantBool::getTrue(), InitBool, SI);
   SI->eraseFromParent();
 }
 
@@ -859,7 +859,8 @@
 static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
   // Create the new global, initializing it to false.
   GlobalVariable *NewGV = new GlobalVariable(Type::BoolTy, false,
- GlobalValue::InternalLinkage, ConstantBool::False, 
GV->getName()+".b");
+ GlobalValue::InternalLinkage, ConstantBool::getFalse(),
+ GV->getName()+".b");
   GV->getParent()->getGlobalList().insert(GV, NewGV);
 
   Constant *InitVal = GV->getInitializer();



___
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/GlobalOpt.cpp SimplifyLibCalls.cpp

2006-09-14 Thread Anton Korobeynikov


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.63 -> 1.64
SimplifyLibCalls.cpp updated: 1.68 -> 1.69
---
Log message:

Adding dllimport, dllexport and external weak linkage types.
DLL* linkages got full (I hope) codegeneration support in C & both x86 
assembler backends.
External weak linkage added for future use, we don't provide any 
codegeneration, etc. support for it.


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

 GlobalOpt.cpp|4 ++--
 SimplifyLibCalls.cpp |6 --
 2 files changed, 6 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.63 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.64
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.63  Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Thu Sep 14 13:23:27 2006
@@ -1245,7 +1245,7 @@
 static bool isSimpleEnoughPointerToCommit(Constant *C) {
   if (GlobalVariable *GV = dyn_cast(C)) {
 if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
-  return false;  // do not allow weak/linkonce linkage.
+  return false;  // do not allow weak/linkonce/dllimport/dllexport linkage.
 return !GV->isExternal();  // reject external globals.
   }
   if (ConstantExpr *CE = dyn_cast(C))
@@ -1254,7 +1254,7 @@
 isa(CE->getOperand(0))) {
   GlobalVariable *GV = cast(CE->getOperand(0));
   if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
-return false;  // do not allow weak/linkonce linkage.
+return false;  // do not allow weak/linkonce/dllimport/dllexport 
linkage.
   return GV->hasInitializer() &&
  ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE);
 }


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.68 
llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.69
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.68   Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cppThu Sep 14 13:23:27 2006
@@ -178,8 +178,10 @@
 // All the "well-known" functions are external and have external 
linkage
 // because they live in a runtime library somewhere and were (probably)
 // not compiled by LLVM.  So, we only act on external functions that
-// have external linkage and non-empty uses.
-if (!FI->isExternal() || !FI->hasExternalLinkage() || FI->use_empty())
+// have external or dllimport linkage and non-empty uses.
+if (!FI->isExternal() ||
+!(FI->hasExternalLinkage() || FI->hasDLLImportLinkage()) ||
+FI->use_empty())
   continue;
 
 // Get the optimization class that pertains to this 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/GlobalOpt.cpp

2006-07-07 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.61 -> 1.62
---
Log message:

Fix PR820: http://llvm.org/PR820  and 
Transforms/GlobalOpt/2006-07-07-InlineAsmCrash.ll


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

 GlobalOpt.cpp |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.61 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.62
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.61  Sun Jan 22 17:32:06 2006
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Fri Jul  7 16:37:01 2006
@@ -1450,6 +1450,9 @@
   AI->getName()));
   InstResult = AllocaTmps.back(); 
 } else if (CallInst *CI = dyn_cast(CurInst)) {
+  // Cannot handle inline asm.
+  if (isa(CI->getOperand(0))) return false;
+
   // Resolve function pointers.
   Function *Callee = dyn_cast(getVal(Values, CI->getOperand(0)));
   if (!Callee) return false;  // Cannot resolve.



___
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/GlobalOpt.cpp

2005-11-05 Thread Nate Begeman


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.59 -> 1.60
---
Log message:

Add support alignment of allocation instructions.
Add support for specifying alignment and size of setjmp jmpbufs.

No targets currently do anything with this information, nor is it presrved
in the bytecode representation.  That's coming up next.


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

 GlobalOpt.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.59 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.60
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.59  Tue Oct 25 06:18:06 2005
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Sat Nov  5 03:21:28 2005
@@ -678,7 +678,7 @@
  (unsigned)NElements->getRawValue());
 MallocInst *NewMI =
   new MallocInst(NewTy, Constant::getNullValue(Type::UIntTy),
- MI->getName(), MI);
+ MI->getAlignment(), MI->getName(), MI);
 std::vector Indices;
 Indices.push_back(Constant::getNullValue(Type::IntTy));
 Indices.push_back(Indices[0]);
@@ -950,6 +950,7 @@
   DEBUG(std::cerr << "LOCALIZING GLOBAL: " << *GV);
   Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin();
   const Type* ElemTy = GV->getType()->getElementType();
+  // FIXME: Pass Global's alignment when globals have alignment
   AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI);
   if (!isa(GV->getInitializer()))
 new StoreInst(GV->getInitializer(), Alloca, FirstI);



___
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/GlobalOpt.cpp

2005-10-25 Thread Alkis Evlogimenos


Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.58 -> 1.59
---
Log message:

Stop using deprecated types

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

 GlobalOpt.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.58 
llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.59
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.58  Tue Sep 27 17:28:11 2005
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp   Tue Oct 25 06:18:06 2005
@@ -1113,7 +1113,8 @@
 /// FindGlobalCtors - Find the llvm.globalctors list, verifying that all
 /// initializers have an init priority of 65535.
 GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) {
-  for (Module::giterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end();
+   I != E; ++I)
 if (I->getName() == "llvm.global_ctors") {
   // Found it, verify it's an array of { int, void()* }.
   const ArrayType *ATy 
=dyn_cast(I->getType()->getElementType());



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