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

LLVM llvm at cs.uiuc.edu
Sat Jul 17 17:02:01 PDT 2004



Changes in directory llvm/lib/VMCore:

Value.cpp updated: 1.46 -> 1.47

---
Log message:

bug 122: http://llvm.cs.uiuc.edu/PR122 :
- Correct isa<Constant> for GlobalValue subclass


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

Index: llvm/lib/VMCore/Value.cpp
diff -u llvm/lib/VMCore/Value.cpp:1.46 llvm/lib/VMCore/Value.cpp:1.47
--- llvm/lib/VMCore/Value.cpp:1.46	Wed Jul  7 13:07:46 2004
+++ llvm/lib/VMCore/Value.cpp	Sat Jul 17 19:01:50 2004
@@ -15,6 +15,7 @@
 #include "llvm/SymbolTable.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Constant.h"
+#include "llvm/GlobalValue.h"
 #include "Support/LeakDetector.h"
 #include <algorithm>
 #include <iostream>
@@ -71,7 +72,10 @@
     // Must handle Constants specially, we cannot call replaceUsesOfWith on a
     // constant!
     if (Constant *C = dyn_cast<Constant>(U.getUser())) {
-      C->replaceUsesOfWithOnConstant(this, New, true);
+      if (!isa<GlobalValue>(C))
+        C->replaceUsesOfWithOnConstant(this, New, true);
+      else 
+        U.set(New);
     } else {
       U.set(New);
     }
@@ -97,7 +101,7 @@
 void User::replaceUsesOfWith(Value *From, Value *To) {
   if (From == To) return;   // Duh what?
 
-  assert(!isa<Constant>(this) &&
+  assert(!isa<Constant>(this) || isa<GlobalValue>(this) &&
          "Cannot call User::replaceUsesofWith on a constant!");
 
   for (unsigned i = 0, E = getNumOperands(); i != E; ++i)
@@ -108,3 +112,4 @@
       setOperand(i, To); // Fix it now...
     }
 }
+





More information about the llvm-commits mailing list