on darwin<10, fallback to .weak_definition (PPC,X86)
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DIEHash.cpp
index 18264672ed2c0af3de0c03680475920b20756eec..11cc454b33c31331f50ddcf9e6ec4122a4f0c96e 100644 (file)
@@ -13,9 +13,9 @@
 
 #define DEBUG_TYPE "dwarfdebug"
 
-#include "DIE.h"
 #include "DIEHash.h"
-#include "DwarfCompileUnit.h"
+
+#include "DIE.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
@@ -91,10 +91,12 @@ void DIEHash::addParentContext(const DIE &Parent) {
   // outermost such construct...
   SmallVector<const DIE *, 1> Parents;
   const DIE *Cur = &Parent;
-  while (Cur->getTag() != dwarf::DW_TAG_compile_unit) {
+  while (Cur->getParent()) {
     Parents.push_back(Cur);
     Cur = Cur->getParent();
   }
+  assert(Cur->getTag() == dwarf::DW_TAG_compile_unit ||
+         Cur->getTag() == dwarf::DW_TAG_type_unit);
 
   // Reverse iterate over our list to go from the outermost construct to the
   // innermost.
@@ -413,7 +415,7 @@ void DIEHash::computeHash(const DIE &Die) {
        I != E; ++I) {
     // 7.27 Step 7
     // If C is a nested type entry or a member function entry, ...
-    if (isType((*I)->getTag())) {
+    if (isType((*I)->getTag()) || (*I)->getTag() == dwarf::DW_TAG_subprogram) {
       StringRef Name = getDIEStringAttr(**I, dwarf::DW_AT_name);
       // ... and has a DW_AT_name attribute
       if (!Name.empty()) {