comparison llvm/lib/IR/AsmWriter.cpp @ 174:f935e5e0dbe7

merged
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 12:28:41 +0900
parents e8a9b4f4d755 0572611fdcc8
children dd44ba33042e
comparison
equal deleted inserted replaced
170:0d65220a63c8 174:f935e5e0dbe7
226 if (LID <= ID) 226 if (LID <= ID)
227 return LU->getOperandNo() < RU->getOperandNo(); 227 return LU->getOperandNo() < RU->getOperandNo();
228 return LU->getOperandNo() > RU->getOperandNo(); 228 return LU->getOperandNo() > RU->getOperandNo();
229 }); 229 });
230 230
231 if (std::is_sorted( 231 if (llvm::is_sorted(List, [](const Entry &L, const Entry &R) {
232 List.begin(), List.end(), 232 return L.second < R.second;
233 [](const Entry &L, const Entry &R) { return L.second < R.second; })) 233 }))
234 // Order is already correct. 234 // Order is already correct.
235 return; 235 return;
236 236
237 // Store the shuffle. 237 // Store the shuffle.
238 Stack.emplace_back(V, F, List.size()); 238 Stack.emplace_back(V, F, List.size());
460 static void PrintLLVMName(raw_ostream &OS, const Value *V) { 460 static void PrintLLVMName(raw_ostream &OS, const Value *V) {
461 PrintLLVMName(OS, V->getName(), 461 PrintLLVMName(OS, V->getName(),
462 isa<GlobalValue>(V) ? GlobalPrefix : LocalPrefix); 462 isa<GlobalValue>(V) ? GlobalPrefix : LocalPrefix);
463 } 463 }
464 464
465 static void PrintShuffleMask(raw_ostream &Out, Type *Ty, ArrayRef<int> Mask) {
466 Out << ", <";
467 if (isa<ScalableVectorType>(Ty))
468 Out << "vscale x ";
469 Out << Mask.size() << " x i32> ";
470 bool FirstElt = true;
471 if (all_of(Mask, [](int Elt) { return Elt == 0; })) {
472 Out << "zeroinitializer";
473 } else if (all_of(Mask, [](int Elt) { return Elt == UndefMaskElem; })) {
474 Out << "undef";
475 } else {
476 Out << "<";
477 for (int Elt : Mask) {
478 if (FirstElt)
479 FirstElt = false;
480 else
481 Out << ", ";
482 Out << "i32 ";
483 if (Elt == UndefMaskElem)
484 Out << "undef";
485 else
486 Out << Elt;
487 }
488 Out << ">";
489 }
490 }
491
465 namespace { 492 namespace {
466 493
467 class TypePrinting { 494 class TypePrinting {
468 public: 495 public:
469 TypePrinting(const Module *M = nullptr) : DeferredM(M) {} 496 TypePrinting(const Module *M = nullptr) : DeferredM(M) {}
562 case Type::VoidTyID: OS << "void"; return; 589 case Type::VoidTyID: OS << "void"; return;
563 #ifndef noCbC 590 #ifndef noCbC
564 case Type::__CodeTyID: OS << "void"; return; 591 case Type::__CodeTyID: OS << "void"; return;
565 #endif 592 #endif
566 case Type::HalfTyID: OS << "half"; return; 593 case Type::HalfTyID: OS << "half"; return;
594 case Type::BFloatTyID: OS << "bfloat"; return;
567 case Type::FloatTyID: OS << "float"; return; 595 case Type::FloatTyID: OS << "float"; return;
568 case Type::DoubleTyID: OS << "double"; return; 596 case Type::DoubleTyID: OS << "double"; return;
569 case Type::X86_FP80TyID: OS << "x86_fp80"; return; 597 case Type::X86_FP80TyID: OS << "x86_fp80"; return;
570 case Type::FP128TyID: OS << "fp128"; return; 598 case Type::FP128TyID: OS << "fp128"; return;
571 case Type::PPC_FP128TyID: OS << "ppc_fp128"; return; 599 case Type::PPC_FP128TyID: OS << "ppc_fp128"; return;
624 OS << '[' << ATy->getNumElements() << " x "; 652 OS << '[' << ATy->getNumElements() << " x ";
625 print(ATy->getElementType(), OS); 653 print(ATy->getElementType(), OS);
626 OS << ']'; 654 OS << ']';
627 return; 655 return;
628 } 656 }
629 case Type::VectorTyID: { 657 case Type::FixedVectorTyID:
658 case Type::ScalableVectorTyID: {
630 VectorType *PTy = cast<VectorType>(Ty); 659 VectorType *PTy = cast<VectorType>(Ty);
660 ElementCount EC = PTy->getElementCount();
631 OS << "<"; 661 OS << "<";
632 if (PTy->isScalable()) 662 if (EC.Scalable)
633 OS << "vscale x "; 663 OS << "vscale x ";
634 OS << PTy->getNumElements() << " x "; 664 OS << EC.Min << " x ";
635 print(PTy->getElementType(), OS); 665 print(PTy->getElementType(), OS);
636 OS << '>'; 666 OS << '>';
637 return; 667 return;
638 } 668 }
639 } 669 }
784 /// GUID map iterators. 814 /// GUID map iterators.
785 using guid_iterator = DenseMap<GlobalValue::GUID, unsigned>::iterator; 815 using guid_iterator = DenseMap<GlobalValue::GUID, unsigned>::iterator;
786 816
787 /// These functions do the actual initialization. 817 /// These functions do the actual initialization.
788 inline void initializeIfNeeded(); 818 inline void initializeIfNeeded();
789 void initializeIndexIfNeeded(); 819 int initializeIndexIfNeeded();
790 820
791 // Implementation Details 821 // Implementation Details
792 private: 822 private:
793 /// CreateModuleSlot - Insert the specified GlobalValue* into the slot table. 823 /// CreateModuleSlot - Insert the specified GlobalValue* into the slot table.
794 void CreateModuleSlot(const GlobalValue *V); 824 void CreateModuleSlot(const GlobalValue *V);
807 void CreateTypeIdSlot(StringRef Id); 837 void CreateTypeIdSlot(StringRef Id);
808 838
809 /// Add all of the module level global variables (and their initializers) 839 /// Add all of the module level global variables (and their initializers)
810 /// and function declarations, but not the contents of those functions. 840 /// and function declarations, but not the contents of those functions.
811 void processModule(); 841 void processModule();
812 void processIndex(); 842 // Returns number of allocated slots
843 int processIndex();
813 844
814 /// Add all of the functions arguments, basic blocks, and instructions. 845 /// Add all of the functions arguments, basic blocks, and instructions.
815 void processFunction(); 846 void processFunction();
816 847
817 /// Add the metadata directly attached to a GlobalObject. 848 /// Add the metadata directly attached to a GlobalObject.
921 952
922 if (TheFunction && !FunctionProcessed) 953 if (TheFunction && !FunctionProcessed)
923 processFunction(); 954 processFunction();
924 } 955 }
925 956
926 void SlotTracker::initializeIndexIfNeeded() { 957 int SlotTracker::initializeIndexIfNeeded() {
927 if (!TheIndex) 958 if (!TheIndex)
928 return; 959 return 0;
929 processIndex(); 960 int NumSlots = processIndex();
930 TheIndex = nullptr; ///< Prevent re-processing next time we're called. 961 TheIndex = nullptr; ///< Prevent re-processing next time we're called.
962 return NumSlots;
931 } 963 }
932 964
933 // Iterate through all the global variables, functions, and global 965 // Iterate through all the global variables, functions, and global
934 // variable initializers and create slots for them. 966 // variable initializers and create slots for them.
935 void SlotTracker::processModule() { 967 void SlotTracker::processModule() {
1020 1052
1021 ST_DEBUG("end processFunction!\n"); 1053 ST_DEBUG("end processFunction!\n");
1022 } 1054 }
1023 1055
1024 // Iterate through all the GUID in the index and create slots for them. 1056 // Iterate through all the GUID in the index and create slots for them.
1025 void SlotTracker::processIndex() { 1057 int SlotTracker::processIndex() {
1026 ST_DEBUG("begin processIndex!\n"); 1058 ST_DEBUG("begin processIndex!\n");
1027 assert(TheIndex); 1059 assert(TheIndex);
1028 1060
1029 // The first block of slots are just the module ids, which start at 0 and are 1061 // The first block of slots are just the module ids, which start at 0 and are
1030 // assigned consecutively. Since the StringMap iteration order isn't 1062 // assigned consecutively. Since the StringMap iteration order isn't
1039 GUIDNext = ModulePathNext; 1071 GUIDNext = ModulePathNext;
1040 1072
1041 for (auto &GlobalList : *TheIndex) 1073 for (auto &GlobalList : *TheIndex)
1042 CreateGUIDSlot(GlobalList.first); 1074 CreateGUIDSlot(GlobalList.first);
1043 1075
1076 for (auto &TId : TheIndex->typeIdCompatibleVtableMap())
1077 CreateGUIDSlot(GlobalValue::getGUID(TId.first));
1078
1044 // Start numbering the TypeIds after the GUIDs. 1079 // Start numbering the TypeIds after the GUIDs.
1045 TypeIdNext = GUIDNext; 1080 TypeIdNext = GUIDNext;
1046
1047 for (auto TidIter = TheIndex->typeIds().begin(); 1081 for (auto TidIter = TheIndex->typeIds().begin();
1048 TidIter != TheIndex->typeIds().end(); TidIter++) 1082 TidIter != TheIndex->typeIds().end(); TidIter++)
1049 CreateTypeIdSlot(TidIter->second.first); 1083 CreateTypeIdSlot(TidIter->second.first);
1050 1084
1051 for (auto &TId : TheIndex->typeIdCompatibleVtableMap())
1052 CreateGUIDSlot(GlobalValue::getGUID(TId.first));
1053
1054 ST_DEBUG("end processIndex!\n"); 1085 ST_DEBUG("end processIndex!\n");
1086 return TypeIdNext;
1055 } 1087 }
1056 1088
1057 void SlotTracker::processGlobalObjectMetadata(const GlobalObject &GO) { 1089 void SlotTracker::processGlobalObjectMetadata(const GlobalObject &GO) {
1058 SmallVector<std::pair<unsigned, MDNode *>, 4> MDs; 1090 SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
1059 GO.getAllMetadata(MDs); 1091 GO.getAllMetadata(MDs);
1349 &ignored); 1381 &ignored);
1350 Out << format_hex(apf.bitcastToAPInt().getZExtValue(), 0, /*Upper=*/true); 1382 Out << format_hex(apf.bitcastToAPInt().getZExtValue(), 0, /*Upper=*/true);
1351 return; 1383 return;
1352 } 1384 }
1353 1385
1354 // Either half, or some form of long double. 1386 // Either half, bfloat or some form of long double.
1355 // These appear as a magic letter identifying the type, then a 1387 // These appear as a magic letter identifying the type, then a
1356 // fixed number of hex digits. 1388 // fixed number of hex digits.
1357 Out << "0x"; 1389 Out << "0x";
1358 APInt API = APF.bitcastToAPInt(); 1390 APInt API = APF.bitcastToAPInt();
1359 if (&APF.getSemantics() == &APFloat::x87DoubleExtended()) { 1391 if (&APF.getSemantics() == &APFloat::x87DoubleExtended()) {
1377 /*Upper=*/true); 1409 /*Upper=*/true);
1378 } else if (&APF.getSemantics() == &APFloat::IEEEhalf()) { 1410 } else if (&APF.getSemantics() == &APFloat::IEEEhalf()) {
1379 Out << 'H'; 1411 Out << 'H';
1380 Out << format_hex_no_prefix(API.getZExtValue(), 4, 1412 Out << format_hex_no_prefix(API.getZExtValue(), 4,
1381 /*Upper=*/true); 1413 /*Upper=*/true);
1414 } else if (&APF.getSemantics() == &APFloat::BFloat()) {
1415 Out << 'R';
1416 Out << format_hex_no_prefix(API.getZExtValue(), 4,
1417 /*Upper=*/true);
1382 } else 1418 } else
1383 llvm_unreachable("Unsupported floating point type"); 1419 llvm_unreachable("Unsupported floating point type");
1384 return; 1420 return;
1385 } 1421 }
1386 1422
1476 Out << '>'; 1512 Out << '>';
1477 return; 1513 return;
1478 } 1514 }
1479 1515
1480 if (isa<ConstantVector>(CV) || isa<ConstantDataVector>(CV)) { 1516 if (isa<ConstantVector>(CV) || isa<ConstantDataVector>(CV)) {
1481 Type *ETy = CV->getType()->getVectorElementType(); 1517 auto *CVVTy = cast<VectorType>(CV->getType());
1518 Type *ETy = CVVTy->getElementType();
1482 Out << '<'; 1519 Out << '<';
1483 TypePrinter.print(ETy, Out); 1520 TypePrinter.print(ETy, Out);
1484 Out << ' '; 1521 Out << ' ';
1485 WriteAsOperandInternal(Out, CV->getAggregateElement(0U), &TypePrinter, 1522 WriteAsOperandInternal(Out, CV->getAggregateElement(0U), &TypePrinter,
1486 Machine, Context); 1523 Machine, Context);
1487 for (unsigned i = 1, e = CV->getType()->getVectorNumElements(); i != e;++i){ 1524 for (unsigned i = 1, e = CVVTy->getNumElements(); i != e; ++i) {
1488 Out << ", "; 1525 Out << ", ";
1489 TypePrinter.print(ETy, Out); 1526 TypePrinter.print(ETy, Out);
1490 Out << ' '; 1527 Out << ' ';
1491 WriteAsOperandInternal(Out, CV->getAggregateElement(i), &TypePrinter, 1528 WriteAsOperandInternal(Out, CV->getAggregateElement(i), &TypePrinter,
1492 Machine, Context); 1529 Machine, Context);
1545 1582
1546 if (CE->isCast()) { 1583 if (CE->isCast()) {
1547 Out << " to "; 1584 Out << " to ";
1548 TypePrinter.print(CE->getType(), Out); 1585 TypePrinter.print(CE->getType(), Out);
1549 } 1586 }
1587
1588 if (CE->getOpcode() == Instruction::ShuffleVector)
1589 PrintShuffleMask(Out, CE->getType(), CE->getShuffleMask());
1550 1590
1551 Out << ')'; 1591 Out << ')';
1552 return; 1592 return;
1553 } 1593 }
1554 1594
1615 bool ShouldSkipEmpty = true); 1655 bool ShouldSkipEmpty = true);
1616 void printMetadata(StringRef Name, const Metadata *MD, 1656 void printMetadata(StringRef Name, const Metadata *MD,
1617 bool ShouldSkipNull = true); 1657 bool ShouldSkipNull = true);
1618 template <class IntTy> 1658 template <class IntTy>
1619 void printInt(StringRef Name, IntTy Int, bool ShouldSkipZero = true); 1659 void printInt(StringRef Name, IntTy Int, bool ShouldSkipZero = true);
1660 void printAPInt(StringRef Name, APInt Int, bool IsUnsigned,
1661 bool ShouldSkipZero);
1620 void printBool(StringRef Name, bool Value, Optional<bool> Default = None); 1662 void printBool(StringRef Name, bool Value, Optional<bool> Default = None);
1621 void printDIFlags(StringRef Name, DINode::DIFlags Flags); 1663 void printDIFlags(StringRef Name, DINode::DIFlags Flags);
1622 void printDISPFlags(StringRef Name, DISubprogram::DISPFlags Flags); 1664 void printDISPFlags(StringRef Name, DISubprogram::DISPFlags Flags);
1623 template <class IntTy, class Stringifier> 1665 template <class IntTy, class Stringifier>
1624 void printDwarfEnum(StringRef Name, IntTy Value, Stringifier toString, 1666 void printDwarfEnum(StringRef Name, IntTy Value, Stringifier toString,
1688 void MDFieldPrinter::printInt(StringRef Name, IntTy Int, bool ShouldSkipZero) { 1730 void MDFieldPrinter::printInt(StringRef Name, IntTy Int, bool ShouldSkipZero) {
1689 if (ShouldSkipZero && !Int) 1731 if (ShouldSkipZero && !Int)
1690 return; 1732 return;
1691 1733
1692 Out << FS << Name << ": " << Int; 1734 Out << FS << Name << ": " << Int;
1735 }
1736
1737 void MDFieldPrinter::printAPInt(StringRef Name, APInt Int, bool IsUnsigned,
1738 bool ShouldSkipZero) {
1739 if (ShouldSkipZero && Int.isNullValue())
1740 return;
1741
1742 Out << FS << Name << ": ";
1743 Int.print(Out, !IsUnsigned);
1693 } 1744 }
1694 1745
1695 void MDFieldPrinter::printBool(StringRef Name, bool Value, 1746 void MDFieldPrinter::printBool(StringRef Name, bool Value,
1696 Optional<bool> Default) { 1747 Optional<bool> Default) {
1697 if (Default && Value == *Default) 1748 if (Default && Value == *Default)
1819 static void writeDIEnumerator(raw_ostream &Out, const DIEnumerator *N, 1870 static void writeDIEnumerator(raw_ostream &Out, const DIEnumerator *N,
1820 TypePrinting *, SlotTracker *, const Module *) { 1871 TypePrinting *, SlotTracker *, const Module *) {
1821 Out << "!DIEnumerator("; 1872 Out << "!DIEnumerator(";
1822 MDFieldPrinter Printer(Out); 1873 MDFieldPrinter Printer(Out);
1823 Printer.printString("name", N->getName(), /* ShouldSkipEmpty */ false); 1874 Printer.printString("name", N->getName(), /* ShouldSkipEmpty */ false);
1824 if (N->isUnsigned()) { 1875 Printer.printAPInt("value", N->getValue(), N->isUnsigned(),
1825 auto Value = static_cast<uint64_t>(N->getValue()); 1876 /*ShouldSkipZero=*/false);
1826 Printer.printInt("value", Value, /* ShouldSkipZero */ false); 1877 if (N->isUnsigned())
1827 Printer.printBool("isUnsigned", true); 1878 Printer.printBool("isUnsigned", true);
1828 } else {
1829 Printer.printInt("value", N->getValue(), /* ShouldSkipZero */ false);
1830 }
1831 Out << ")"; 1879 Out << ")";
1832 } 1880 }
1833 1881
1834 static void writeDIBasicType(raw_ostream &Out, const DIBasicType *N, 1882 static void writeDIBasicType(raw_ostream &Out, const DIBasicType *N,
1835 TypePrinting *, SlotTracker *, const Module *) { 1883 TypePrinting *, SlotTracker *, const Module *) {
1889 dwarf::LanguageString); 1937 dwarf::LanguageString);
1890 Printer.printMetadata("vtableHolder", N->getRawVTableHolder()); 1938 Printer.printMetadata("vtableHolder", N->getRawVTableHolder());
1891 Printer.printMetadata("templateParams", N->getRawTemplateParams()); 1939 Printer.printMetadata("templateParams", N->getRawTemplateParams());
1892 Printer.printString("identifier", N->getIdentifier()); 1940 Printer.printString("identifier", N->getIdentifier());
1893 Printer.printMetadata("discriminator", N->getRawDiscriminator()); 1941 Printer.printMetadata("discriminator", N->getRawDiscriminator());
1942 Printer.printMetadata("dataLocation", N->getRawDataLocation());
1894 Out << ")"; 1943 Out << ")";
1895 } 1944 }
1896 1945
1897 static void writeDISubroutineType(raw_ostream &Out, const DISubroutineType *N, 1946 static void writeDISubroutineType(raw_ostream &Out, const DISubroutineType *N,
1898 TypePrinting *TypePrinter, 1947 TypePrinting *TypePrinter,
1947 Printer.printBool("debugInfoForProfiling", N->getDebugInfoForProfiling(), 1996 Printer.printBool("debugInfoForProfiling", N->getDebugInfoForProfiling(),
1948 false); 1997 false);
1949 Printer.printNameTableKind("nameTableKind", N->getNameTableKind()); 1998 Printer.printNameTableKind("nameTableKind", N->getNameTableKind());
1950 Printer.printBool("rangesBaseAddress", N->getRangesBaseAddress(), false); 1999 Printer.printBool("rangesBaseAddress", N->getRangesBaseAddress(), false);
1951 Printer.printString("sysroot", N->getSysRoot()); 2000 Printer.printString("sysroot", N->getSysRoot());
2001 Printer.printString("sdk", N->getSDK());
1952 Out << ")"; 2002 Out << ")";
1953 } 2003 }
1954 2004
1955 static void writeDISubprogram(raw_ostream &Out, const DISubprogram *N, 2005 static void writeDISubprogram(raw_ostream &Out, const DISubprogram *N,
1956 TypePrinting *TypePrinter, SlotTracker *Machine, 2006 TypePrinting *TypePrinter, SlotTracker *Machine,
2059 MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); 2109 MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
2060 Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false); 2110 Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
2061 Printer.printString("name", N->getName()); 2111 Printer.printString("name", N->getName());
2062 Printer.printString("configMacros", N->getConfigurationMacros()); 2112 Printer.printString("configMacros", N->getConfigurationMacros());
2063 Printer.printString("includePath", N->getIncludePath()); 2113 Printer.printString("includePath", N->getIncludePath());
2114 Printer.printString("apinotes", N->getAPINotesFile());
2115 Printer.printMetadata("file", N->getRawFile());
2116 Printer.printInt("line", N->getLineNo());
2064 Out << ")"; 2117 Out << ")";
2065 } 2118 }
2066 2119
2067 2120
2068 static void writeDITemplateTypeParameter(raw_ostream &Out, 2121 static void writeDITemplateTypeParameter(raw_ostream &Out,
2072 const Module *Context) { 2125 const Module *Context) {
2073 Out << "!DITemplateTypeParameter("; 2126 Out << "!DITemplateTypeParameter(";
2074 MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); 2127 MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
2075 Printer.printString("name", N->getName()); 2128 Printer.printString("name", N->getName());
2076 Printer.printMetadata("type", N->getRawType(), /* ShouldSkipNull */ false); 2129 Printer.printMetadata("type", N->getRawType(), /* ShouldSkipNull */ false);
2130 Printer.printBool("defaulted", N->isDefault(), /* Default= */ false);
2077 Out << ")"; 2131 Out << ")";
2078 } 2132 }
2079 2133
2080 static void writeDITemplateValueParameter(raw_ostream &Out, 2134 static void writeDITemplateValueParameter(raw_ostream &Out,
2081 const DITemplateValueParameter *N, 2135 const DITemplateValueParameter *N,
2086 MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); 2140 MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
2087 if (N->getTag() != dwarf::DW_TAG_template_value_parameter) 2141 if (N->getTag() != dwarf::DW_TAG_template_value_parameter)
2088 Printer.printTag(N); 2142 Printer.printTag(N);
2089 Printer.printString("name", N->getName()); 2143 Printer.printString("name", N->getName());
2090 Printer.printMetadata("type", N->getRawType()); 2144 Printer.printMetadata("type", N->getRawType());
2145 Printer.printBool("defaulted", N->isDefault(), /* Default= */ false);
2091 Printer.printMetadata("value", N->getValue(), /* ShouldSkipNull */ false); 2146 Printer.printMetadata("value", N->getValue(), /* ShouldSkipNull */ false);
2092 Out << ")"; 2147 Out << ")";
2093 } 2148 }
2094 2149
2095 static void writeDIGlobalVariable(raw_ostream &Out, const DIGlobalVariable *N, 2150 static void writeDIGlobalVariable(raw_ostream &Out, const DIGlobalVariable *N,
2679 } 2734 }
2680 } 2735 }
2681 2736
2682 void AssemblyWriter::printModuleSummaryIndex() { 2737 void AssemblyWriter::printModuleSummaryIndex() {
2683 assert(TheIndex); 2738 assert(TheIndex);
2684 Machine.initializeIndexIfNeeded(); 2739 int NumSlots = Machine.initializeIndexIfNeeded();
2685 2740
2686 Out << "\n"; 2741 Out << "\n";
2687 2742
2688 // Print module path entries. To print in order, add paths to a vector 2743 // Print module path entries. To print in order, add paths to a vector
2689 // indexed by module slot. 2744 // indexed by module slot.
2741 Out << "^" << Machine.getGUIDSlot(GUID) 2796 Out << "^" << Machine.getGUIDSlot(GUID)
2742 << " = typeidCompatibleVTable: (name: \"" << TId.first << "\""; 2797 << " = typeidCompatibleVTable: (name: \"" << TId.first << "\"";
2743 printTypeIdCompatibleVtableSummary(TId.second); 2798 printTypeIdCompatibleVtableSummary(TId.second);
2744 Out << ") ; guid = " << GUID << "\n"; 2799 Out << ") ; guid = " << GUID << "\n";
2745 } 2800 }
2801
2802 // Don't emit flags when it's not really needed (value is zero by default).
2803 if (TheIndex->getFlags())
2804 Out << "^" << NumSlots << " = flags: " << TheIndex->getFlags() << "\n";
2746 } 2805 }
2747 2806
2748 static const char * 2807 static const char *
2749 getWholeProgDevirtResKindName(WholeProgramDevirtResolution::Kind K) { 2808 getWholeProgDevirtResKindName(WholeProgramDevirtResolution::Kind K) {
2750 switch (K) { 2809 switch (K) {
2773 llvm_unreachable("invalid WholeProgramDevirtResolution::ByArg kind"); 2832 llvm_unreachable("invalid WholeProgramDevirtResolution::ByArg kind");
2774 } 2833 }
2775 2834
2776 static const char *getTTResKindName(TypeTestResolution::Kind K) { 2835 static const char *getTTResKindName(TypeTestResolution::Kind K) {
2777 switch (K) { 2836 switch (K) {
2778 case TypeTestResolution::Unknown:
2779 return "unknown";
2780 case TypeTestResolution::Unsat: 2837 case TypeTestResolution::Unsat:
2781 return "unsat"; 2838 return "unsat";
2782 case TypeTestResolution::ByteArray: 2839 case TypeTestResolution::ByteArray:
2783 return "byteArray"; 2840 return "byteArray";
2784 case TypeTestResolution::Inline: 2841 case TypeTestResolution::Inline:
3211 } 3268 }
3212 } 3269 }
3213 3270
3214 static void PrintDSOLocation(const GlobalValue &GV, 3271 static void PrintDSOLocation(const GlobalValue &GV,
3215 formatted_raw_ostream &Out) { 3272 formatted_raw_ostream &Out) {
3216 // GVs with local linkage or non default visibility are implicitly dso_local, 3273 if (GV.isDSOLocal() && !GV.isImplicitDSOLocal())
3217 // so we don't print it.
3218 bool Implicit = GV.hasLocalLinkage() ||
3219 (!GV.hasExternalWeakLinkage() && !GV.hasDefaultVisibility());
3220 if (GV.isDSOLocal() && !Implicit)
3221 Out << "dso_local "; 3274 Out << "dso_local ";
3222 } 3275 }
3223 3276
3224 static void PrintDLLStorageClass(GlobalValue::DLLStorageClassTypes SCT, 3277 static void PrintDLLStorageClass(GlobalValue::DLLStorageClassTypes SCT,
3225 formatted_raw_ostream &Out) { 3278 formatted_raw_ostream &Out) {
3861 if (CI->getCallingConv() != CallingConv::C) { 3914 if (CI->getCallingConv() != CallingConv::C) {
3862 Out << " "; 3915 Out << " ";
3863 PrintCallingConv(CI->getCallingConv(), Out); 3916 PrintCallingConv(CI->getCallingConv(), Out);
3864 } 3917 }
3865 3918
3866 Operand = CI->getCalledValue(); 3919 Operand = CI->getCalledOperand();
3867 FunctionType *FTy = CI->getFunctionType(); 3920 FunctionType *FTy = CI->getFunctionType();
3868 Type *RetTy = FTy->getReturnType(); 3921 Type *RetTy = FTy->getReturnType();
3869 const AttributeList &PAL = CI->getAttributes(); 3922 const AttributeList &PAL = CI->getAttributes();
3870 3923
3871 if (PAL.hasAttributes(AttributeList::ReturnIndex)) 3924 if (PAL.hasAttributes(AttributeList::ReturnIndex))
3900 if (PAL.hasAttributes(AttributeList::FunctionIndex)) 3953 if (PAL.hasAttributes(AttributeList::FunctionIndex))
3901 Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttributes()); 3954 Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttributes());
3902 3955
3903 writeOperandBundles(CI); 3956 writeOperandBundles(CI);
3904 } else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) { 3957 } else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
3905 Operand = II->getCalledValue(); 3958 Operand = II->getCalledOperand();
3906 FunctionType *FTy = II->getFunctionType(); 3959 FunctionType *FTy = II->getFunctionType();
3907 Type *RetTy = FTy->getReturnType(); 3960 Type *RetTy = FTy->getReturnType();
3908 const AttributeList &PAL = II->getAttributes(); 3961 const AttributeList &PAL = II->getAttributes();
3909 3962
3910 // Print the calling convention being used. 3963 // Print the calling convention being used.
3943 Out << "\n to "; 3996 Out << "\n to ";
3944 writeOperand(II->getNormalDest(), true); 3997 writeOperand(II->getNormalDest(), true);
3945 Out << " unwind "; 3998 Out << " unwind ";
3946 writeOperand(II->getUnwindDest(), true); 3999 writeOperand(II->getUnwindDest(), true);
3947 } else if (const CallBrInst *CBI = dyn_cast<CallBrInst>(&I)) { 4000 } else if (const CallBrInst *CBI = dyn_cast<CallBrInst>(&I)) {
3948 Operand = CBI->getCalledValue(); 4001 Operand = CBI->getCalledOperand();
3949 FunctionType *FTy = CBI->getFunctionType(); 4002 FunctionType *FTy = CBI->getFunctionType();
3950 Type *RetTy = FTy->getReturnType(); 4003 Type *RetTy = FTy->getReturnType();
3951 const AttributeList &PAL = CBI->getAttributes(); 4004 const AttributeList &PAL = CBI->getAttributes();
3952 4005
3953 // Print the calling convention being used. 4006 // Print the calling convention being used.
4090 } else if (const AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(&I)) { 4143 } else if (const AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(&I)) {
4091 writeAtomic(RMWI->getContext(), RMWI->getOrdering(), 4144 writeAtomic(RMWI->getContext(), RMWI->getOrdering(),
4092 RMWI->getSyncScopeID()); 4145 RMWI->getSyncScopeID());
4093 } else if (const FenceInst *FI = dyn_cast<FenceInst>(&I)) { 4146 } else if (const FenceInst *FI = dyn_cast<FenceInst>(&I)) {
4094 writeAtomic(FI->getContext(), FI->getOrdering(), FI->getSyncScopeID()); 4147 writeAtomic(FI->getContext(), FI->getOrdering(), FI->getSyncScopeID());
4148 } else if (const ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(&I)) {
4149 PrintShuffleMask(Out, SVI->getType(), SVI->getShuffleMask());
4095 } 4150 }
4096 4151
4097 // Print Metadata info. 4152 // Print Metadata info.
4098 SmallVector<std::pair<unsigned, MDNode *>, 4> InstMD; 4153 SmallVector<std::pair<unsigned, MDNode *>, 4> InstMD;
4099 I.getAllMetadata(InstMD); 4154 I.getAllMetadata(InstMD);
4151 if (!Attr.isTypeAttribute()) { 4206 if (!Attr.isTypeAttribute()) {
4152 Out << Attr.getAsString(InAttrGroup); 4207 Out << Attr.getAsString(InAttrGroup);
4153 return; 4208 return;
4154 } 4209 }
4155 4210
4156 assert(Attr.hasAttribute(Attribute::ByVal) && "unexpected type attr"); 4211 assert((Attr.hasAttribute(Attribute::ByVal) ||
4157 4212 Attr.hasAttribute(Attribute::Preallocated)) &&
4158 Out << "byval"; 4213 "unexpected type attr");
4214
4215 if (Attr.hasAttribute(Attribute::ByVal)) {
4216 Out << "byval";
4217 } else {
4218 Out << "preallocated";
4219 }
4220
4159 if (Type *Ty = Attr.getValueAsType()) { 4221 if (Type *Ty = Attr.getValueAsType()) {
4160 Out << '('; 4222 Out << '(';
4161 TypePrinter.print(Ty, Out); 4223 TypePrinter.print(Ty, Out);
4162 Out << ')'; 4224 Out << ')';
4163 } 4225 }