[llvm-commits] [llvm] r111820 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Devang Patel dpatel at apple.com
Mon Aug 23 11:25:56 PDT 2010


Author: dpatel
Date: Mon Aug 23 13:25:56 2010
New Revision: 111820

URL: http://llvm.org/viewvc/llvm-project?rev=111820&view=rev
Log:
Handle qualified constants that are directly folded by FE.
PR 7920.

Modified:
    llvm/trunk/include/llvm/Analysis/DebugInfo.h
    llvm/trunk/lib/Analysis/DebugInfo.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=111820&r1=111819&r2=111820&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Aug 23 13:25:56 2010
@@ -290,6 +290,9 @@
 
     unsigned getEncoding() const { return getUnsignedField(9); }
 
+    /// Verify - Verify that a basic type descriptor is well formed.
+    bool Verify() const;
+
     /// print - print basic type.
     void print(raw_ostream &OS) const;
 
@@ -313,6 +316,9 @@
     /// return base type size.
     uint64_t getOriginalTypeSize() const;
 
+    /// Verify - Verify that a derived type descriptor is well formed.
+    bool Verify() const;
+
     /// print - print derived type.
     void print(raw_ostream &OS) const;
 

Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=111820&r1=111819&r2=111820&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Aug 23 13:25:56 2010
@@ -303,6 +303,16 @@
   return true;
 }
 
+/// Verify - Verify that a basic type descriptor is well formed.
+bool DIBasicType::Verify() const {
+  return isBasicType();
+}
+
+/// Verify - Verify that a derived type descriptor is well formed.
+bool DIDerivedType::Verify() const {
+  return isDerivedType();
+}
+
 /// Verify - Verify that a composite type descriptor is well formed.
 bool DICompositeType::Verify() const {
   if (!DbgNode)

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=111820&r1=111819&r2=111820&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 23 13:25:56 2010
@@ -1861,6 +1861,21 @@
   return I->second;
 }
 
+/// isUnsignedDIType - Return true if type encoding is unsigned.
+static bool isUnsignedDIType(DIType Ty) {
+  DIDerivedType DTy(Ty);
+  if (DTy.Verify())
+    return isUnsignedDIType(DTy.getTypeDerivedFrom());
+
+  DIBasicType BTy(Ty);
+  if (BTy.Verify()) {
+    unsigned Encoding = BTy.getEncoding();
+    if (Encoding == dwarf::DW_ATE_unsigned ||
+        Encoding == dwarf::DW_ATE_unsigned_char)
+      return true;
+  }
+  return false;
+}
 
 /// constructGlobalVariableDIE - Construct global variable DIE.
 void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
@@ -1930,17 +1945,12 @@
     } 
   } else if (Constant *C = GV.getConstant()) {
     if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
-      DIBasicType BTy(GTy);
-      if (BTy.Verify()) {
-        unsigned Encoding = BTy.getEncoding();
-        if (Encoding == dwarf::DW_ATE_unsigned ||
-            Encoding == dwarf::DW_ATE_unsigned_char)
+      if (isUnsignedDIType(GTy))
           addUInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_udata,
                   CI->getZExtValue());
         else
           addSInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata,
                  CI->getSExtValue());
-      }
     }
   }
   return;





More information about the llvm-commits mailing list