[llvm-commits] [llvm-gcc-4.2] r60815 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Evan Cheng evan.cheng at apple.com
Tue Dec 9 16:21:14 PST 2008


Author: evancheng
Date: Tue Dec  9 18:21:14 2008
New Revision: 60815

URL: http://llvm.org/viewvc/llvm-project?rev=60815&view=rev
Log:
- If a struct / union type is a forward declaration, mark it as such.
- If a previously created type is a forward declaration and the type definition is now available, emit a new type descriptor. The correct solution is fix up the previously emitted type descriptor but is not always possible given the MachineModuleInfo horribleness. We'll fix this once we migrate to API defined in DebugInfo.h which allows direct manipulation of LLVM ir which represents debug info.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=60815&r1=60814&r2=60815&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Dec  9 18:21:14 2008
@@ -457,7 +457,13 @@
   
   // Check to see if the compile unit already has created this type.
   TypeDesc *Slot = TypeCache[type];
-  if (Slot) return Slot;
+  if (Slot && !(Slot->isForwardDecl() && TYPE_SIZE(type) != 0))
+    // FIXME: If previously created type is just a forward declaration, emit
+    // a new descriptor for the type definition. The correct fix is to *fix*
+    // up the llvm ir (since MMI may have already been converted to llvm). But
+    // that's correctly not doable. We'll fix this when we convert to the new
+    // API in DebugInfo.h
+    return Slot;
   
   // Ty will have contain the resulting type.
   TypeDesc *Ty = NULL;
@@ -642,6 +648,13 @@
       // Set the slot early to prevent recursion difficulties.
       // Any other use of the type should include the qualifiers.
       TypeCache[type] = AddTypeQualifiers(type, Unit, StructTy);
+
+      // If it's a forward declaration, mark it as such.
+      if (TYPE_SIZE(type) == 0) {
+        StructTy->setIsForwardDecl();
+        break;
+      }
+
       // Prepare to add the fields.
       std::vector<DebugInfoDesc *> &Elements = StructTy->getElements();
       





More information about the llvm-commits mailing list