Wrap const MDNode * inside DIDescriptor.
[oota-llvm.git] / tools / llvm-bcanalyzer / llvm-bcanalyzer.cpp
index 01c6329520d954b00aec274c51f529ee534b8266..732ff11fe46deeb2014b6aff870ebe8cbf6c0b11 100644 (file)
@@ -32,6 +32,7 @@
 #include "llvm/Bitcode/LLVMBitCodes.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
@@ -236,6 +237,8 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
     case bitc::FUNC_CODE_INST_INSERTVAL:    return "INST_INSERTVAL";
     case bitc::FUNC_CODE_INST_CMP2:         return "INST_CMP2";
     case bitc::FUNC_CODE_INST_VSELECT:      return "INST_VSELECT";
+    case bitc::FUNC_CODE_DEBUG_LOC:         return "DEBUG_LOC";
+    case bitc::FUNC_CODE_DEBUG_LOC_AGAIN:   return "DEBUG_LOC_AGAIN";
     }
   case bitc::TYPE_SYMTAB_BLOCK_ID:
     switch (CodeID) {
@@ -258,9 +261,11 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
     default:return 0;
     case bitc::METADATA_STRING:      return "MDSTRING";
     case bitc::METADATA_NODE:        return "MDNODE";
+    case bitc::METADATA_FN_NODE:     return "FN_MDNODE";
     case bitc::METADATA_NAME:        return "METADATA_NAME";
     case bitc::METADATA_NAMED_NODE:  return "NAMEDMDNODE";
     case bitc::METADATA_KIND:        return "METADATA_KIND";
+    case bitc::METADATA_ATTACHMENT:  return "METADATA_ATTACHMENT";
     }
   }
 }
@@ -546,8 +551,8 @@ static int AnalyzeBitcode() {
     errs() << "         Total Size: ";
     PrintSize(Stats.NumBits);
     errs() << "\n";
-    errs() << "          % of file: "
-           << Stats.NumBits/(double)BufferSizeBits*100 << "\n";
+    double pct = (Stats.NumBits * 100.0) / BufferSizeBits;
+    errs() << "    Percent of file: " << format("%2.4f%%", pct) << "\n";
     if (Stats.NumInstances > 1) {
       errs() << "       Average Size: ";
       PrintSize(Stats.NumBits/(double)Stats.NumInstances);
@@ -563,9 +568,10 @@ static int AnalyzeBitcode() {
       errs() << "        Num Abbrevs: " << Stats.NumAbbrevs << "\n";
       errs() << "        Num Records: " << Stats.NumRecords << "\n";
     }
-    if (Stats.NumRecords)
-      errs() << "      % Abbrev Recs: " << (Stats.NumAbbreviatedRecords/
-                (double)Stats.NumRecords)*100 << "\n";
+    if (Stats.NumRecords) {
+      double pct = (Stats.NumAbbreviatedRecords * 100.0) / Stats.NumRecords;
+      errs() << "    Percent Abbrevs: " << format("%2.4f%%", pct) << "\n";
+    }
     errs() << "\n";
 
     // Print a histogram of the codes we see.