[llvm-commits] [dragonegg] r137584 - /dragonegg/trunk/src/Backend.cpp

Duncan Sands baldrick at free.fr
Sun Aug 14 04:53:41 PDT 2011


Author: baldrick
Date: Sun Aug 14 06:53:41 2011
New Revision: 137584

URL: http://llvm.org/viewvc/llvm-project?rev=137584&view=rev
Log:
A weakref alias to a global variable of type T (so type T* as a
GlobalValue) was getting type T* (so type T** as a GlobalValue).
While there, due to the use of weak value handles, the global
associated with a declaration may now be a bitcast of a global
value, rather than a global value - deal with this in the alias
code.

Modified:
    dragonegg/trunk/src/Backend.cpp

Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=137584&r1=137583&r2=137584&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Sun Aug 14 06:53:41 2011
@@ -1447,7 +1447,7 @@
     return; // Do not process broken code.
 
   // Get or create LLVM global for our alias.
-  GlobalValue *V = cast<GlobalValue>(DECL_LLVM(decl));
+  GlobalValue *V = cast<GlobalValue>(DECL_LLVM(decl)->stripPointerCasts());
 
   bool weakref = lookup_attribute("weakref", DECL_ATTRIBUTES(decl));
   if (weakref)
@@ -1471,7 +1471,7 @@
 
     // weakref to external symbol.
     if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
-      Aliasee = new GlobalVariable(*TheModule, GV->getType(),
+      Aliasee = new GlobalVariable(*TheModule, GV->getType()->getElementType(),
                                    GV->isConstant(),
                                    GlobalVariable::ExternalWeakLinkage, NULL,
                                    IDENTIFIER_POINTER(target));
@@ -1483,7 +1483,7 @@
     else
       assert(0 && "Unsuported global value");
   } else {
-    Aliasee = cast<GlobalValue>(DEFINITION_LLVM(target));
+    Aliasee = cast<GlobalValue>(DEFINITION_LLVM(target)->stripPointerCasts());
   }
 
   GlobalValue::LinkageTypes Linkage = GetLinkageForAlias(decl);





More information about the llvm-commits mailing list