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

Duncan Sands baldrick at free.fr
Sun Aug 14 09:39:42 PDT 2011


Author: baldrick
Date: Sun Aug 14 11:39:42 2011
New Revision: 137588

URL: http://llvm.org/viewvc/llvm-project?rev=137588&view=rev
Log:
Have the routines to get globals associated with GCC declarations
always strip off pointer casts (this can appear spontaneously due
to the use of weak value handles).

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=137588&r1=137587&r2=137588&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Sun Aug 14 11:39:42 2011
@@ -132,8 +132,9 @@
 //===----------------------------------------------------------------------===//
 
 /// set_decl_llvm - Remember the LLVM value for a GCC declaration.
-Value *set_decl_llvm (tree t, Value *V) {
+Value *set_decl_llvm(tree t, Value *V) {
   assert(HAS_RTL_P(t) && "Expected a declaration with RTL!");
+  assert((!V || isa<GlobalValue>(V)) && "Expected a global value!");
   setCachedValue(t, V);
   return V;
 }
@@ -141,7 +142,8 @@
 /// get_decl_llvm - Retrieve the LLVM value for a GCC declaration, or NULL.
 Value *get_decl_llvm(tree t) {
   assert(HAS_RTL_P(t) && "Expected a declaration with RTL!");
-  return getCachedValue(t);
+  Value *V = getCachedValue(t);
+  return V ? V->stripPointerCasts() : 0;
 }
 
 /// set_decl_index - Associate a non-negative number with the given GCC
@@ -1447,7 +1449,7 @@
     return; // Do not process broken code.
 
   // Get or create LLVM global for our alias.
-  GlobalValue *V = cast<GlobalValue>(DECL_LLVM(decl)->stripPointerCasts());
+  GlobalValue *V = cast<GlobalValue>(DECL_LLVM(decl));
 
   bool weakref = lookup_attribute("weakref", DECL_ATTRIBUTES(decl));
   if (weakref)
@@ -1483,7 +1485,7 @@
     else
       assert(0 && "Unsuported global value");
   } else {
-    Aliasee = cast<GlobalValue>(DEFINITION_LLVM(target)->stripPointerCasts());
+    Aliasee = cast<GlobalValue>(DEFINITION_LLVM(target));
   }
 
   GlobalValue::LinkageTypes Linkage = GetLinkageForAlias(decl);





More information about the llvm-commits mailing list