[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 2 10:41:01 PST 2003


Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.100 -> 1.101

---
Log message:

Fix bug: Assembler/2003-02-02-ConstGlobal.ll


---
Diffs of the changes:

Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.100 llvm/lib/AsmParser/llvmAsmParser.y:1.101
--- llvm/lib/AsmParser/llvmAsmParser.y:1.100	Thu Jan 30 16:24:26 2003
+++ llvm/lib/AsmParser/llvmAsmParser.y	Sun Feb  2 10:40:20 2003
@@ -510,16 +510,16 @@
       // 1. If at least one of the globals is uninitialized or 
       // 2. If both initializers have the same value.
       //
-      // This can only be done if the const'ness of the vars is the same.
-      //
       if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
-        if (EGV->isConstant() == GV->isConstant() &&
-            (!EGV->hasInitializer() || !GV->hasInitializer() ||
-             EGV->getInitializer() == GV->getInitializer())) {
+        if (!EGV->hasInitializer() || !GV->hasInitializer() ||
+             EGV->getInitializer() == GV->getInitializer()) {
 
-          // Make sure the existing global version gets the initializer!
+          // Make sure the existing global version gets the initializer!  Make
+          // sure that it also gets marked const if the new version is.
           if (GV->hasInitializer() && !EGV->hasInitializer())
             EGV->setInitializer(GV->getInitializer());
+          if (GV->isConstant())
+            EGV->setConstant(true);
           
 	  delete GV;     // Destroy the duplicate!
           return true;   // They are equivalent!





More information about the llvm-commits mailing list