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<CastInst>(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<Constant>(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

Reply via email to