[llvm] [llvm][DebugInfo] Use formatv() instead of format() (PR #191308)

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 04:37:29 PDT 2026


https://github.com/kwk updated https://github.com/llvm/llvm-project/pull/191308

>From 385e306eb286248eb6aac6fd5643a3182971bca0 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Thu, 26 Mar 2026 19:58:31 +0000
Subject: [PATCH 1/2] [llvm][DebugInfo] Use formatv() instead of format()

This addresses all use-cases in `llvm/lib/DebugInfo`.

This relates to #35980.
---
 .../DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 18 ++---
 llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp  | 20 +++---
 llvm/lib/DebugInfo/DWARF/DWARFContext.cpp     | 20 +++---
 llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp  | 48 +++++++------
 llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp   | 68 ++++++++++---------
 llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp  | 18 +++--
 .../DebugInfo/DWARF/DWARFDebugPubTable.cpp    | 24 ++++---
 .../DebugInfo/DWARF/DWARFDebugRangeList.cpp   | 11 +--
 .../DebugInfo/DWARF/DWARFDebugRnglists.cpp    |  9 ++-
 llvm/lib/DebugInfo/DWARF/DWARFDie.cpp         | 12 ++--
 .../DWARF/DWARFExpressionPrinter.cpp          | 19 +++---
 llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp    | 41 ++++++-----
 llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp   | 26 ++++---
 llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp    | 27 +++++---
 llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp   | 18 ++---
 .../DWARF/DWARFUnwindTablePrinter.cpp         |  3 +-
 llvm/lib/DebugInfo/GSYM/GsymReader.cpp        |  7 +-
 .../DebugInfo/LogicalView/Core/LVCompare.cpp  |  4 +-
 .../DebugInfo/LogicalView/Core/LVElement.cpp  |  2 +-
 .../DebugInfo/LogicalView/Core/LVLocation.cpp | 28 ++++----
 .../DebugInfo/LogicalView/Core/LVObject.cpp   |  2 +-
 .../DebugInfo/LogicalView/Core/LVRange.cpp    | 10 +--
 .../DebugInfo/LogicalView/Core/LVReader.cpp   | 13 ++--
 .../DebugInfo/LogicalView/Core/LVScope.cpp    | 23 ++++---
 .../LogicalView/Readers/LVBinaryReader.cpp    | 22 +++---
 .../LogicalView/Readers/LVCodeViewVisitor.cpp |  2 +-
 .../LogicalView/Readers/LVDWARFReader.cpp     |  6 +-
 llvm/unittests/Support/FormatVariadicTest.cpp | 43 ++++++++++++
 28 files changed, 313 insertions(+), 231 deletions(-)

diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index e442b5182f6a4..91f4b50e043d1 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -32,7 +32,7 @@ static raw_ostream &operator<<(raw_ostream &OS, const Atom &A) {
   StringRef Str = dwarf::AtomTypeString(A.Value);
   if (!Str.empty())
     return OS << Str;
-  return OS << "DW_ATOM_unknown_" << format("%x", A.Value);
+  return OS << "DW_ATOM_unknown_" << formatv("{0:x-}", A.Value);
 }
 } // namespace
 
@@ -185,7 +185,7 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
     return false; // End of list
 
   DictScope NameScope(W, ("Name at 0x" + Twine::utohexstr(NameOffset)).str());
-  W.startLine() << format("String: 0x%08" PRIx64, StringOffset);
+  W.startLine() << formatv("String: {0:x+8}", StringOffset);
   W.getOStream() << " \"" << StringSection.getCStr(&StringOffset) << "\"\n";
 
   unsigned NumData = AccelSection.getU32(DataOffset);
@@ -193,7 +193,7 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
     ListScope DataScope(W, ("Data " + Twine(Data)).str());
     unsigned i = 0;
     for (auto &Atom : AtomForms) {
-      W.startLine() << format("Atom[%d]: ", i);
+      W.startLine() << formatv("Atom[{0:d}]: ", i);
       if (Atom.extractValue(AccelSection, DataOffset, FormParams)) {
         Atom.dump(W.getOStream());
         if (std::optional<uint64_t> Val = Atom.getAsUnsignedConstant()) {
@@ -859,7 +859,7 @@ void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
   if (Hash)
     W.printHex("Hash", *Hash);
 
-  W.startLine() << format("String: 0x%08" PRIx64, NTE.getStringOffset());
+  W.startLine() << formatv("String: {0:x+8}", NTE.getStringOffset());
   W.getOStream() << " \"" << NTE.getString() << "\"\n";
 
   uint64_t EntryOffset = NTE.getEntryOffset();
@@ -870,7 +870,7 @@ void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
 void DWARFDebugNames::NameIndex::dumpCUs(ScopedPrinter &W) const {
   ListScope CUScope(W, "Compilation Unit offsets");
   for (uint32_t CU = 0; CU < Hdr.CompUnitCount; ++CU)
-    W.startLine() << format("CU[%u]: 0x%08" PRIx64 "\n", CU, getCUOffset(CU));
+    W.startLine() << formatv("CU[{0}]: {1:x+8}\n", CU, getCUOffset(CU));
 }
 
 void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
@@ -879,8 +879,8 @@ void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
 
   ListScope TUScope(W, "Local Type Unit offsets");
   for (uint32_t TU = 0; TU < Hdr.LocalTypeUnitCount; ++TU)
-    W.startLine() << format("LocalTU[%u]: 0x%08" PRIx64 "\n", TU,
-                            getLocalTUOffset(TU));
+    W.startLine() << formatv("LocalTU[{0}]: {1:x+8}\n", TU,
+                             getLocalTUOffset(TU));
 }
 
 void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const {
@@ -889,8 +889,8 @@ void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const {
 
   ListScope TUScope(W, "Foreign Type Unit signatures");
   for (uint32_t TU = 0; TU < Hdr.ForeignTypeUnitCount; ++TU) {
-    W.startLine() << format("ForeignTU[%u]: 0x%016" PRIx64 "\n", TU,
-                            getForeignTUSignature(TU));
+    W.startLine() << formatv("ForeignTU[{0}]: {1:x+16}\n", TU,
+                             getForeignTUSignature(TU));
   }
 }
 
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp
index 0b74f352b4bb1..d0a0c4cb1f82b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp
@@ -52,13 +52,13 @@ static void printOperand(raw_ostream &OS, const DIDumpOptions &DumpOpts,
     if (!OpcodeName.empty())
       OS << " " << OpcodeName;
     else
-      OS << format(" Opcode %x", Opcode);
+      OS << formatv(" Opcode {0:x-}", Opcode);
     break;
   }
   case CFIProgram::OT_None:
     break;
   case CFIProgram::OT_Address:
-    OS << format(" %" PRIx64, Operand);
+    OS << formatv(" {0:x-}", Operand);
     Address = Operand;
     break;
   case CFIProgram::OT_Offset:
@@ -69,32 +69,32 @@ static void printOperand(raw_ostream &OS, const DIDumpOptions &DumpOpts,
     break;
   case CFIProgram::OT_FactoredCodeOffset: // Always Unsigned
     if (P.codeAlign())
-      OS << format(" %" PRId64, Operand * P.codeAlign());
+      OS << formatv(" {0}", Operand * P.codeAlign());
     else
-      OS << format(" %" PRId64 "*code_alignment_factor", Operand);
+      OS << formatv(" {0}*code_alignment_factor", Operand);
     if (Address && P.codeAlign()) {
       *Address += Operand * P.codeAlign();
-      OS << format(" to 0x%" PRIx64, *Address);
+      OS << formatv(" to {0:x+}", *Address);
     }
     break;
   case CFIProgram::OT_SignedFactDataOffset:
     if (P.dataAlign())
-      OS << format(" %" PRId64, int64_t(Operand) * P.dataAlign());
+      OS << formatv(" {0}", int64_t(Operand) * P.dataAlign());
     else
-      OS << format(" %" PRId64 "*data_alignment_factor", int64_t(Operand));
+      OS << formatv(" {0}*data_alignment_factor", int64_t(Operand));
     break;
   case CFIProgram::OT_UnsignedFactDataOffset:
     if (P.dataAlign())
-      OS << format(" %" PRId64, Operand * P.dataAlign());
+      OS << formatv(" {0:d}", int64_t(Operand * P.dataAlign()));
     else
-      OS << format(" %" PRId64 "*data_alignment_factor", Operand);
+      OS << formatv(" {0:d}*data_alignment_factor", Operand);
     break;
   case CFIProgram::OT_Register:
     OS << ' ';
     printRegister(OS, DumpOpts, Operand);
     break;
   case CFIProgram::OT_AddressSpace:
-    OS << format(" in addrspace%" PRId64, Operand);
+    OS << formatv(" in addrspace{0:d}", Operand);
     break;
   case CFIProgram::OT_Expression:
     assert(Instr.Expression && "missing DWARFExpression object");
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 6c14beab0aafe..d19879543d75a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -47,6 +47,8 @@
 #include "llvm/Support/DataExtractor.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -863,10 +865,10 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
     }
     // Report a gap in the table.
     if (Offset < ContributionHeader) {
-      OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset);
+      OS << formatv("{0:x+8}: Gap, length = ", Offset);
       OS << (ContributionHeader - Offset) << "\n";
     }
-    OS << format("0x%8.8" PRIx64 ": ", ContributionHeader);
+    OS << formatv("{0:x+8}: ", ContributionHeader);
     // In DWARF v5 the contribution size in the descriptor does not equal
     // the originally encoded length (it does not contain the length of the
     // version field and the padding, a total of 4 bytes). Add them back in
@@ -878,19 +880,20 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
     Offset = Contribution->Base;
     unsigned EntrySize = Contribution->getDwarfOffsetByteSize();
     while (Offset - Contribution->Base < Contribution->Size) {
-      OS << format("0x%8.8" PRIx64 ": ", Offset);
+      OS << formatv("{0:x+8}: ", Offset);
       uint64_t StringOffset =
           StrOffsetExt.getRelocatedValue(EntrySize, &Offset);
-      OS << format("%0*" PRIx64 " ", OffsetDumpWidth, StringOffset);
+      OS << formatv("{0:x-} ", fmt_align(StringOffset, AlignStyle::Right,
+                                         OffsetDumpWidth, '0'));
       const char *S = StrData.getCStr(&StringOffset);
       if (S)
-        OS << format("\"%s\"", S);
+        OS << formatv("\"{0}\"", S);
       OS << "\n";
     }
   }
   // Report a gap at the end of the table.
   if (Offset < SectionSize) {
-    OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset);
+    OS << formatv("{0:x+8}: Gap, length = ", Offset);
     OS << (SectionSize - Offset) << "\n";
   }
 }
@@ -1166,8 +1169,7 @@ void DWARFContext::dump(
         Parser.skip(DumpOpts.WarningHandler, DumpOpts.WarningHandler);
         continue;
       }
-      OS << "debug_line[" << format("0x%8.8" PRIx64, Parser.getOffset())
-         << "]\n";
+      OS << "debug_line[" << formatv("{0:x+8}", Parser.getOffset()) << "]\n";
       Parser.parseNext(DumpOpts.WarningHandler, DumpOpts.WarningHandler, &OS,
                        DumpOpts.Verbose);
     }
@@ -1184,7 +1186,7 @@ void DWARFContext::dump(
         DumpOpts.WarningHandler(std::move(Err));
         return;
       }
-      OS << format("0x%8.8" PRIx64 ": \"", StrOffset);
+      OS << formatv("{0:x+8}: \"", StrOffset);
       OS.write_escaped(CStr);
       OS << "\"\n";
       StrOffset = Offset;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index c61f757aba793..85167bf5c1ebd 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -24,6 +24,8 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cassert>
 #include <cinttypes>
@@ -101,30 +103,34 @@ constexpr uint64_t getCIEId(bool IsDWARF64, bool IsEH) {
 void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
   // A CIE with a zero length is a terminator entry in the .eh_frame section.
   if (DumpOpts.IsEH && Length == 0) {
-    OS << format("%08" PRIx64, Offset) << " ZERO terminator\n";
+    OS << formatv("{0:x-8}", Offset) << " ZERO terminator\n";
     return;
   }
 
-  OS << format("%08" PRIx64, Offset)
-     << format(" %0*" PRIx64, IsDWARF64 ? 16 : 8, Length)
-     << format(" %0*" PRIx64, IsDWARF64 && !DumpOpts.IsEH ? 16 : 8,
-               getCIEId(IsDWARF64, DumpOpts.IsEH))
+  OS << formatv("{0:x-8}", Offset)
+     << formatv(" {0:x-}",
+                fmt_align(Length, AlignStyle::Right, IsDWARF64 ? 16 : 8, '0'))
+     << formatv(" {0:x-}",
+                fmt_align(getCIEId(IsDWARF64, DumpOpts.IsEH), AlignStyle::Right,
+                          IsDWARF64 && !DumpOpts.IsEH ? 16 : 8, '0'))
      << " CIE\n"
      << "  Format:                " << FormatString(IsDWARF64) << "\n";
   if (DumpOpts.IsEH && Version != 1)
     OS << "WARNING: unsupported CIE version\n";
-  OS << format("  Version:               %d\n", Version)
+  OS << formatv("  Version:               {0}\n", Version)
      << "  Augmentation:          \"" << Augmentation << "\"\n";
   if (Version >= 4) {
-    OS << format("  Address size:          %u\n", (uint32_t)AddressSize);
-    OS << format("  Segment desc size:     %u\n",
-                 (uint32_t)SegmentDescriptorSize);
+    OS << formatv("  Address size:          {0}\n", (uint32_t)AddressSize);
+    OS << formatv("  Segment desc size:     {0}\n",
+                  (uint32_t)SegmentDescriptorSize);
   }
-  OS << format("  Code alignment factor: %u\n", (uint32_t)CodeAlignmentFactor);
-  OS << format("  Data alignment factor: %d\n", (int32_t)DataAlignmentFactor);
-  OS << format("  Return address column: %d\n", (int32_t)ReturnAddressRegister);
+  OS << formatv("  Code alignment factor: {0}\n",
+                (uint32_t)CodeAlignmentFactor);
+  OS << formatv("  Data alignment factor: {0}\n", (int32_t)DataAlignmentFactor);
+  OS << formatv("  Return address column: {0}\n",
+                (int32_t)ReturnAddressRegister);
   if (Personality)
-    OS << format("  Personality Address: %016" PRIx64 "\n", *Personality);
+    OS << formatv("  Personality Address: {0:x-16}\n", *Personality);
   if (!AugmentationData.empty()) {
     OS << "  Augmentation data:    ";
     for (uint8_t Byte : AugmentationData)
@@ -148,19 +154,21 @@ void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
 }
 
 void FDE::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
-  OS << format("%08" PRIx64, Offset)
-     << format(" %0*" PRIx64, IsDWARF64 ? 16 : 8, Length)
-     << format(" %0*" PRIx64, IsDWARF64 && !DumpOpts.IsEH ? 16 : 8, CIEPointer)
+  OS << formatv("{0:x-8}", Offset)
+     << formatv(" {0:x-}",
+                fmt_align(Length, AlignStyle::Right, IsDWARF64 ? 16 : 8, '0'))
+     << formatv(" {0:x-}", fmt_align(CIEPointer, AlignStyle::Right,
+                                     IsDWARF64 && !DumpOpts.IsEH ? 16 : 8, '0'))
      << " FDE cie=";
   if (LinkedCIE)
-    OS << format("%08" PRIx64, LinkedCIE->getOffset());
+    OS << formatv("{0:x-8}", LinkedCIE->getOffset());
   else
     OS << "<invalid offset>";
-  OS << format(" pc=%08" PRIx64 "...%08" PRIx64 "\n", InitialLocation,
-               InitialLocation + AddressRange);
+  OS << formatv(" pc={0:x-8}...{1:x-8}\n", InitialLocation,
+                InitialLocation + AddressRange);
   OS << "  Format:       " << FormatString(IsDWARF64) << "\n";
   if (LSDAAddress)
-    OS << format("  LSDA Address: %016" PRIx64 "\n", *LSDAAddress);
+    OS << formatv("  LSDA Address: {0:x-16}\n", *LSDAAddress);
   printCFIProgram(CFIs, OS, DumpOpts, /*IndentLevel=*/1, InitialLocation);
   OS << "\n";
 
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 4cc234b801be6..5e813532aa435 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -17,6 +17,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
@@ -121,23 +122,25 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
     return;
   int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(FormParams.Format);
   OS << "Line table prologue:\n"
-     << format("    total_length: 0x%0*" PRIx64 "\n", OffsetDumpWidth,
-               TotalLength)
+     << formatv("    total_length: 0x{0:x-}\n",
+                fmt_align(TotalLength, AlignStyle::Right, OffsetDumpWidth, '0'))
      << "          format: " << dwarf::FormatString(FormParams.Format) << "\n"
-     << format("         version: %u\n", getVersion());
+     << formatv("         version: {0}\n", getVersion());
   if (!versionIsSupported(getVersion()))
     return;
   if (getVersion() >= 5)
-    OS << format("    address_size: %u\n", getAddressSize())
-       << format(" seg_select_size: %u\n", SegSelectorSize);
-  OS << format(" prologue_length: 0x%0*" PRIx64 "\n", OffsetDumpWidth,
-               PrologueLength)
-     << format(" min_inst_length: %u\n", MinInstLength)
-     << format(getVersion() >= 4 ? "max_ops_per_inst: %u\n" : "", MaxOpsPerInst)
-     << format(" default_is_stmt: %u\n", DefaultIsStmt)
-     << format("       line_base: %i\n", LineBase)
-     << format("      line_range: %u\n", LineRange)
-     << format("     opcode_base: %u\n", OpcodeBase);
+    OS << formatv("    address_size: {0}\n", getAddressSize())
+       << formatv(" seg_select_size: {0}\n", SegSelectorSize);
+  OS << formatv(
+            " prologue_length: 0x{0:x-}\n",
+            fmt_align(PrologueLength, AlignStyle::Right, OffsetDumpWidth, '0'))
+     << formatv(" min_inst_length: {0}\n", MinInstLength);
+  if (getVersion() >= 4)
+    OS << formatv("max_ops_per_inst: {0}\n", MaxOpsPerInst);
+  OS << formatv(" default_is_stmt: {0}\n", DefaultIsStmt)
+     << formatv("       line_base: {0}\n", static_cast<int>(LineBase))
+     << formatv("      line_range: {0}\n", LineRange)
+     << formatv("     opcode_base: {0}\n", OpcodeBase);
 
   for (uint32_t I = 0; I != StandardOpcodeLengths.size(); ++I)
     OS << formatv("standard_opcode_lengths[{0}] = {1}\n",
@@ -148,7 +151,7 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
     // DWARF v5 starts directory indexes at 0.
     uint32_t DirBase = getVersion() >= 5 ? 0 : 1;
     for (uint32_t I = 0; I != IncludeDirectories.size(); ++I) {
-      OS << format("include_directories[%3u] = ", I + DirBase);
+      OS << formatv("include_directories[{0,3:d}] = ", I + DirBase);
       IncludeDirectories[I].dump(OS, DumpOptions);
       OS << '\n';
     }
@@ -159,16 +162,16 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
     uint32_t FileBase = getVersion() >= 5 ? 0 : 1;
     for (uint32_t I = 0; I != FileNames.size(); ++I) {
       const FileNameEntry &FileEntry = FileNames[I];
-      OS << format("file_names[%3u]:\n", I + FileBase);
+      OS << formatv("file_names[{0,3:d}]:\n", I + FileBase);
       OS << "           name: ";
       FileEntry.Name.dump(OS, DumpOptions);
-      OS << '\n' << format("      dir_index: %" PRIu64 "\n", FileEntry.DirIdx);
+      OS << '\n' << formatv("      dir_index: {0}\n", FileEntry.DirIdx);
       if (ContentTypes.HasMD5)
         OS << "   md5_checksum: " << FileEntry.Checksum.digest() << '\n';
       if (ContentTypes.HasModTime)
-        OS << format("       mod_time: 0x%8.8" PRIx64 "\n", FileEntry.ModTime);
+        OS << formatv("       mod_time: {0:x+8}\n", FileEntry.ModTime);
       if (ContentTypes.HasLength)
-        OS << format("         length: 0x%8.8" PRIx64 "\n", FileEntry.Length);
+        OS << formatv("         length: {0:x+8}\n", FileEntry.Length);
       if (ContentTypes.HasSource) {
         auto Source = FileEntry.Source.getAsCString();
         if (!Source)
@@ -515,8 +518,9 @@ void DWARFDebugLine::Row::dumpTableHeader(raw_ostream &OS, unsigned Indent) {
 }
 
 void DWARFDebugLine::Row::dump(raw_ostream &OS) const {
-  OS << format("0x%16.16" PRIx64 " %6u %6u", Address.Address, Line, Column)
-     << format(" %6u %3u %13u %7u ", File, Isa, Discriminator, OpIndex)
+  OS << formatv("{0:x+16} {1,6:d} {2,6:d}", Address.Address, Line, Column)
+     << formatv(" {0,6:d} {1,3:d} {2,13:d} {3,7:d} ", File, Isa, Discriminator,
+                OpIndex)
      << (IsStmt ? " is_stmt" : "") << (BasicBlock ? " basic_block" : "")
      << (PrologueEnd ? " prologue_end" : "")
      << (EpilogueBegin ? " epilogue_begin" : "")
@@ -869,14 +873,14 @@ Error DWARFDebugLine::LineTable::parse(
     DataExtractor::Cursor Cursor(*OffsetPtr);
 
     if (Verbose)
-      *OS << format("0x%08.08" PRIx64 ": ", *OffsetPtr);
+      *OS << formatv("{0:x+8}: ", *OffsetPtr);
 
     uint64_t OpcodeOffset = *OffsetPtr;
     uint8_t Opcode = TableData.getU8(Cursor);
     size_t RowCount = Rows.size();
 
     if (Cursor && Verbose)
-      *OS << format("%02.02" PRIx8 " ", Opcode);
+      *OS << formatv("{0:x-2} ", Opcode);
 
     if (Opcode == 0) {
       // Extended Opcodes always start with a zero opcode followed by
@@ -1011,8 +1015,8 @@ Error DWARFDebugLine::LineTable::parse(
           FileEntry.Length = TableData.getULEB128(Cursor);
           Prologue.FileNames.push_back(FileEntry);
           if (Cursor && Verbose)
-            *OS << " (" << Name << ", dir=" << FileEntry.DirIdx << ", mod_time="
-                << format("(0x%16.16" PRIx64 ")", FileEntry.ModTime)
+            *OS << " (" << Name << ", dir=" << FileEntry.DirIdx
+                << ", mod_time=" << formatv("({0:x+16})", FileEntry.ModTime)
                 << ", length=" << FileEntry.Length << ")";
         }
         break;
@@ -1025,8 +1029,8 @@ Error DWARFDebugLine::LineTable::parse(
 
       default:
         if (Cursor && Verbose)
-          *OS << format("Unrecognized extended op 0x%02.02" PRIx8, SubOpcode)
-              << format(" length %" PRIx64, Len);
+          *OS << formatv("Unrecognized extended op {0:x+2}", SubOpcode)
+              << formatv(" length {0:x-}", Len);
         // Len doesn't include the zero opcode byte or the length itself, but
         // it does include the sub_opcode, so we have to adjust for that.
         TableData.skip(Cursor, Len - 1);
@@ -1049,7 +1053,7 @@ Error DWARFDebugLine::LineTable::parse(
         if (ByteCursor) {
           *OS << " (<parsing error>";
           do {
-            *OS << format(" %2.2" PRIx8, Byte);
+            *OS << formatv(" {0:x-2}", Byte);
             Byte = TableData.getU8(ByteCursor);
           } while (ByteCursor);
           *OS << ")";
@@ -1149,9 +1153,8 @@ Error DWARFDebugLine::LineTable::parse(
           ParsingState::OpcodeAdvanceResults Advance =
               State.advanceForOpcode(Opcode, OpcodeOffset);
           if (Verbose)
-            *OS << format(" (addr += 0x%16.16" PRIx64 ", op-index += %" PRIu8
-                          ")",
-                          Advance.AddrDelta, Advance.OpIndexDelta);
+            *OS << formatv(" (addr += {0:x+16}, op-index += {1})",
+                           Advance.AddrDelta, Advance.OpIndexDelta);
         }
         break;
 
@@ -1172,8 +1175,7 @@ Error DWARFDebugLine::LineTable::parse(
             State.Row.Address.Address += PCOffset;
             State.Row.OpIndex = 0;
             if (Verbose)
-              *OS << format(" (addr += 0x%4.4" PRIx16 ", op-index = 0)",
-                            PCOffset);
+              *OS << formatv(" (addr += {0:x+4}, op-index = 0)", PCOffset);
           }
         }
         break;
@@ -1222,7 +1224,7 @@ Error DWARFDebugLine::LineTable::parse(
             *OS << " (operands: ";
             ListSeparator LS;
             for (uint64_t Value : Operands)
-              *OS << LS << format("0x%16.16" PRIx64, Value);
+              *OS << LS << formatv("{0:x+16}", Value);
             *OS << ')';
           }
         }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
index 4d52046ba9ba9..1e16e7f9e78d6 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
@@ -13,6 +13,8 @@
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdint>
@@ -30,19 +32,20 @@ uint8_t DWARFDebugMacro::MacroHeader::getOffsetByteSize() const {
 
 void DWARFDebugMacro::MacroHeader::dumpMacroHeader(raw_ostream &OS) const {
   // FIXME: Add support for dumping opcode_operands_table
-  OS << format("macro header: version = 0x%04" PRIx16, Version)
-     << format(", flags = 0x%02" PRIx8, Flags)
+  OS << formatv("macro header: version = {0:x+4}", Version)
+     << formatv(", flags = {0:x+2}", Flags)
      << ", format = " << FormatString(getDwarfFormat());
   if (Flags & MACRO_DEBUG_LINE_OFFSET)
-    OS << format(", debug_line_offset = 0x%0*" PRIx64, 2 * getOffsetByteSize(),
-                 DebugLineOffset);
+    OS << formatv(", debug_line_offset = 0x{0:x-}",
+                  fmt_align(DebugLineOffset, AlignStyle::Right,
+                            2 * getOffsetByteSize(), '0'));
   OS << "\n";
 }
 
 void DWARFDebugMacro::dump(raw_ostream &OS) const {
   unsigned IndLevel = 0;
   for (const auto &Macros : MacroLists) {
-    OS << format("0x%08" PRIx64 ":\n", Macros.Offset);
+    OS << formatv("{0:x+8}:\n", Macros.Offset);
     if (Macros.IsDebugMacro)
       Macros.Header.dumpMacroHeader(OS);
     for (const Entry &E : Macros.Macros) {
@@ -89,8 +92,9 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const {
         OS << " filenum: " << E.File;
         break;
       case DW_MACRO_import:
-        OS << format(" - import offset: 0x%0*" PRIx64,
-                     2 * Macros.Header.getOffsetByteSize(), E.ImportOffset);
+        OS << formatv(" - import offset: 0x{0:x-}",
+                      fmt_align(E.ImportOffset, AlignStyle::Right,
+                                2 * Macros.Header.getOffsetByteSize(), '0'));
         break;
       case DW_MACRO_end_file:
         break;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
index 5031acdb54efc..494f5634bb764 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
@@ -7,12 +7,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h"
-#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
 #include "llvm/Support/DataExtractor.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdint>
 
@@ -93,24 +95,30 @@ void DWARFDebugPubTable::extract(
 void DWARFDebugPubTable::dump(raw_ostream &OS) const {
   for (const Set &S : Sets) {
     int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(S.Format);
-    OS << "length = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Length);
+    OS << "length = "
+       << formatv("0x{0:x-}",
+                  fmt_align(S.Length, AlignStyle::Right, OffsetDumpWidth, '0'));
     OS << ", format = " << dwarf::FormatString(S.Format);
-    OS << ", version = " << format("0x%04x", S.Version);
+    OS << ", version = " << formatv("{0:x+4}", S.Version);
     OS << ", unit_offset = "
-       << format("0x%0*" PRIx64, OffsetDumpWidth, S.Offset);
-    OS << ", unit_size = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Size)
+       << formatv("0x{0:x-}",
+                  fmt_align(S.Offset, AlignStyle::Right, OffsetDumpWidth, '0'));
+    OS << ", unit_size = "
+       << formatv("0x{0:x-}",
+                  fmt_align(S.Size, AlignStyle::Right, OffsetDumpWidth, '0'))
        << '\n';
     OS << (GnuStyle ? "Offset     Linkage  Kind     Name\n"
                     : "Offset     Name\n");
 
     for (const Entry &E : S.Entries) {
-      OS << format("0x%0*" PRIx64 " ", OffsetDumpWidth, E.SecOffset);
+      OS << formatv("0x{0:x-} ", fmt_align(E.SecOffset, AlignStyle::Right,
+                                           OffsetDumpWidth, '0'));
       if (GnuStyle) {
         StringRef EntryLinkage =
             GDBIndexEntryLinkageString(E.Descriptor.Linkage);
         StringRef EntryKind = dwarf::GDBIndexEntryKindString(E.Descriptor.Kind);
-        OS << format("%-8s", EntryLinkage.data()) << ' '
-           << format("%-8s", EntryKind.data()) << ' ';
+        OS << formatv("{0, -8}", EntryLinkage.data()) << ' '
+           << formatv("{0, -8}", EntryKind.data()) << ' ';
       }
       OS << '\"' << E.Name << "\"\n";
     }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
index db01719bed599..7c6a4fcf5b1f6 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 #include <cstdint>
@@ -68,20 +69,20 @@ void DWARFDebugRangeList::dump(raw_ostream &OS) const {
   const char *AddrFmt;
   switch (AddressSize) {
   case 2:
-    AddrFmt = "%08" PRIx64 " %04" PRIx64 " %04" PRIx64 "\n";
+    AddrFmt = "{0:x-8} {1:x-4} {2:x-4}\n";
     break;
   case 4:
-    AddrFmt = "%08" PRIx64 " %08" PRIx64 " %08" PRIx64 "\n";
+    AddrFmt = "{0:x-8} {1:x-8} {2:x-8}\n";
     break;
   case 8:
-    AddrFmt = "%08" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n";
+    AddrFmt = "{0:x-8} {1:x-16} {2:x-16}\n";
     break;
   default:
     llvm_unreachable("unsupported address size");
   }
   for (const RangeListEntry &RLE : Entries)
-    OS << format(AddrFmt, Offset, RLE.StartAddress, RLE.EndAddress);
-  OS << format("%08" PRIx64 " <End of list>\n", Offset);
+    OS << formatv(AddrFmt, Offset, RLE.StartAddress, RLE.EndAddress);
+  OS << formatv("{0:x-8} <End of list>\n", Offset);
 }
 
 DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges(
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
index b428c2adfe0b3..7ea2eb41e0b48 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
@@ -13,6 +13,8 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -189,12 +191,13 @@ void RangeListEntry::dump(
 
   if (DumpOpts.Verbose) {
     // Print the section offset in verbose mode.
-    OS << format("0x%8.8" PRIx64 ":", Offset);
+    OS << formatv("{0:x+8}:", Offset);
     auto EncodingString = dwarf::RangeListEncodingString(EntryKind);
     // Unsupported encodings should have been reported during parsing.
     assert(!EncodingString.empty() && "Unknown range entry encoding");
-    OS << format(" [%s%*c", EncodingString.data(),
-                 MaxEncodingStringLength - EncodingString.size() + 1, ']');
+    OS << formatv(" [{0}]",
+                  fmt_pad(EncodingString.data(), 0,
+                          MaxEncodingStringLength - EncodingString.size()));
     if (EntryKind != dwarf::DW_RLE_end_of_list)
       OS << ": ";
   }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index f8357ed216f5f..0c0ae08a3cd27 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -46,7 +46,7 @@ static void dumpApplePropertyAttribute(raw_ostream &OS, uint64_t Val) {
     if (!PropName.empty())
       OS << PropName;
     else
-      OS << format("DW_APPLE_PROPERTY_0x%" PRIx64, Bit);
+      OS << formatv("DW_APPLE_PROPERTY_{0:x+}", Bit);
     if (!(Val ^= Bit))
       break;
     OS << ", ";
@@ -678,7 +678,7 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
     uint32_t abbrCode = debug_info_data.getULEB128(&offset);
     if (DumpOpts.ShowAddresses)
       WithColor(OS, HighlightColor::Address).get()
-          << format("\n0x%8.8" PRIx64 ": ", Offset);
+          << formatv("\n{0:x+8}: ", Offset);
 
     if (abbrCode) {
       auto AbbrevDecl = getAbbreviationDeclarationPtr();
@@ -686,11 +686,11 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
         WithColor(OS, HighlightColor::Tag).get().indent(Indent)
             << formatv("{0}", getTag());
         if (DumpOpts.Verbose) {
-          OS << format(" [%u] %c", abbrCode,
-                       AbbrevDecl->hasChildren() ? '*' : ' ');
+          OS << formatv(" [{0}] {1}", abbrCode,
+                        AbbrevDecl->hasChildren() ? '*' : ' ');
           if (std::optional<uint32_t> ParentIdx = Die->getParentIdx())
-            OS << format(" (0x%8.8" PRIx64 ")",
-                         U->getDIEAtIndex(*ParentIdx).getOffset());
+            OS << formatv(" ({0:x+8})",
+                          U->getDIEAtIndex(*ParentIdx).getOffset());
         }
         OS << '\n';
 
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp
index 5a3c1dd057193..6416f7967c03f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp
@@ -29,19 +29,19 @@ static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS,
                                    unsigned Operand) {
   assert(Operand < Operands.size() && "operand out of bounds");
   if (!U) {
-    OS << format(" <base_type ref: 0x%" PRIx64 ">", Operands[Operand]);
+    OS << formatv(" <base_type ref: {0:x+}>", Operands[Operand]);
     return;
   }
   auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
   if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
     OS << " (";
     if (DumpOpts.Verbose)
-      OS << format("0x%08" PRIx64 " -> ", Operands[Operand]);
-    OS << format("0x%08" PRIx64 ")", U->getOffset() + Operands[Operand]);
+      OS << formatv("{0:x+8} -> ", Operands[Operand]);
+    OS << formatv("{0:x+8})", U->getOffset() + Operands[Operand]);
     if (auto Name = dwarf::toString(Die.find(dwarf::DW_AT_name)))
       OS << " \"" << *Name << "\"";
   } else {
-    OS << format(" <invalid base_type ref: 0x%" PRIx64 ">", Operands[Operand]);
+    OS << formatv(" <invalid base_type ref: {0:x+}>", Operands[Operand]);
   }
 }
 
@@ -142,7 +142,7 @@ static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
         case 2:
         case 3: // global as uint32
         case 4:
-          OS << format(" 0x%" PRIx64, Op->getRawOperand(Operand));
+          OS << formatv(" {0:x+}", Op->getRawOperand(Operand));
           break;
         default:
           assert(false);
@@ -150,14 +150,14 @@ static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
       } else if (Size == DWARFExpression::Operation::SizeBlock) {
         uint64_t Offset = Op->getRawOperand(Operand);
         for (unsigned i = 0; i < Op->getRawOperand(Operand - 1); ++i)
-          OS << format(" 0x%02x",
-                       static_cast<uint8_t>(Expr->getData()[Offset++]));
+          OS << formatv(" {0:x+2}",
+                        static_cast<uint8_t>(Expr->getData()[Offset++]));
       } else {
         if (Signed)
           OS << formatv(" {0:+d}", (int64_t)Op->getRawOperand(Operand));
         else if (Op->getCode() != DW_OP_entry_value &&
                  Op->getCode() != DW_OP_GNU_entry_value)
-          OS << format(" 0x%" PRIx64, Op->getRawOperand(Operand));
+          OS << formatv(" {0:x+}", Op->getRawOperand(Operand));
       }
     }
   }
@@ -176,7 +176,8 @@ void printDwarfExpression(const DWARFExpression *E, raw_ostream &OS,
     if (!printOp(&Op, OS, DumpOpts, E, U) && !DumpOpts.PrintRegisterOnly) {
       uint64_t FailOffset = Op.getEndOffset();
       while (FailOffset < E->getData().size())
-        OS << format(" %02x", static_cast<uint8_t>(E->getData()[FailOffset++]));
+        OS << formatv(" {0:x-2}",
+                      static_cast<uint8_t>(E->getData()[FailOffset++]));
       return;
     }
     if (!DumpOpts.PrintRegisterOnly) {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
index db6170c784f80..30f4b6141e6a3 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
@@ -24,13 +24,13 @@ using namespace llvm;
 // https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html
 
 void DWARFGdbIndex::dumpCUList(raw_ostream &OS) const {
-  OS << format("\n  CU list offset = 0x%x, has %" PRId64 " entries:",
-               CuListOffset, (uint64_t)CuList.size())
+  OS << formatv("\n  CU list offset = {0:x+}, has {1} entries:", CuListOffset,
+                (uint64_t)CuList.size())
      << '\n';
   uint32_t I = 0;
   for (const CompUnitEntry &CU : CuList)
-    OS << format("    %d: Offset = 0x%llx, Length = 0x%llx\n", I++, CU.Offset,
-                 CU.Length);
+    OS << formatv("    {0}: Offset = {1:x+}, Length = {2:x+}\n", I++, CU.Offset,
+                  CU.Length);
 }
 
 void DWARFGdbIndex::dumpTUList(raw_ostream &OS) const {
@@ -44,20 +44,19 @@ void DWARFGdbIndex::dumpTUList(raw_ostream &OS) const {
 }
 
 void DWARFGdbIndex::dumpAddressArea(raw_ostream &OS) const {
-  OS << format("\n  Address area offset = 0x%x, has %" PRId64 " entries:",
-               AddressAreaOffset, (uint64_t)AddressArea.size())
+  OS << formatv("\n  Address area offset = {0:x+}, has {1} entries:",
+                AddressAreaOffset, (uint64_t)AddressArea.size())
      << '\n';
   for (const AddressEntry &Addr : AddressArea)
-    OS << format(
-        "    Low/High address = [0x%llx, 0x%llx) (Size: 0x%llx), CU id = %d\n",
-        Addr.LowAddress, Addr.HighAddress, Addr.HighAddress - Addr.LowAddress,
-        Addr.CuIndex);
+    OS << formatv("    Low/High address = [{0:x+}, {1:x+}) (Size: {2:x+}), CU "
+                  "id = {3:d}\n",
+                  Addr.LowAddress, Addr.HighAddress,
+                  Addr.HighAddress - Addr.LowAddress, Addr.CuIndex);
 }
 
 void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
-  OS << format("\n  Symbol table offset = 0x%x, size = %" PRId64
-               ", filled slots:",
-               SymbolTableOffset, (uint64_t)SymbolTable.size())
+  OS << formatv("\n  Symbol table offset = {0:x+}, size = {1}, filled slots:",
+                SymbolTableOffset, (uint64_t)SymbolTable.size())
      << '\n';
 
   const auto FindCuVectorId = [&](uint32_t VecOffset) {
@@ -79,26 +78,26 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
     if (!E.NameOffset && !E.VecOffset)
       continue;
 
-    OS << format("    %d: Name offset = 0x%x, CU vector offset = 0x%x\n", I,
-                 E.NameOffset, E.VecOffset);
+    OS << formatv("    {0}: Name offset = {1:x+}, CU vector offset = {2:x+}\n",
+                  I, E.NameOffset, E.VecOffset);
 
     StringRef Name = ConstantPoolStrings.substr(
         ConstantPoolOffset - StringPoolOffset + E.NameOffset);
 
     const uint32_t CuVectorId = FindCuVectorId(E.VecOffset);
-    OS << format("      String name: %s, CU vector index: %d\n", Name.data(),
-                 CuVectorId);
+    OS << formatv("      String name: {0}, CU vector index: {1}\n", Name.data(),
+                  CuVectorId);
   }
 }
 
 void DWARFGdbIndex::dumpConstantPool(raw_ostream &OS) const {
-  OS << format("\n  Constant pool offset = 0x%x, has %" PRId64 " CU vectors:",
-               ConstantPoolOffset, (uint64_t)ConstantPoolVectors.size());
+  OS << formatv("\n  Constant pool offset = {0:x+}, has {1} CU vectors:",
+                ConstantPoolOffset, (uint64_t)ConstantPoolVectors.size());
   uint32_t I = 0;
   for (const auto &V : ConstantPoolVectors) {
-    OS << format("\n    %d(0x%x): ", I++, V.first);
+    OS << formatv("\n    {0}({1:x+}): ", I++, V.first);
     for (uint32_t Val : V.second)
-      OS << format("0x%x ", Val);
+      OS << formatv("{0:x+} ", Val);
   }
   OS << '\n';
 }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
index c0f4768b2e2f7..fe749515756cc 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
@@ -12,6 +12,8 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -78,25 +80,27 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
 void DWARFListTableHeader::dump(DataExtractor Data, raw_ostream &OS,
                                 DIDumpOptions DumpOpts) const {
   if (DumpOpts.Verbose)
-    OS << format("0x%8.8" PRIx64 ": ", HeaderOffset);
+    OS << formatv("{0:x+8}: ", HeaderOffset);
   int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format);
-  OS << format("%s list header: length = 0x%0*" PRIx64, ListTypeString.data(),
-               OffsetDumpWidth, HeaderData.Length)
+  OS << formatv("{0} list header: length = 0x{1:x-}", ListTypeString.data(),
+                fmt_align(HeaderData.Length, AlignStyle::Right, OffsetDumpWidth,
+                          '0'))
      << ", format = " << dwarf::FormatString(Format)
-     << format(", version = 0x%4.4" PRIx16 ", addr_size = 0x%2.2" PRIx8
-               ", seg_size = 0x%2.2" PRIx8
-               ", offset_entry_count = 0x%8.8" PRIx32 "\n",
-               HeaderData.Version, HeaderData.AddrSize, HeaderData.SegSize,
-               HeaderData.OffsetEntryCount);
+     << formatv(", version = {0:x+4}, addr_size = {1:x+2}"
+                ", seg_size = {2:x+2}"
+                ", offset_entry_count = {3:x+8}\n",
+                HeaderData.Version, HeaderData.AddrSize, HeaderData.SegSize,
+                HeaderData.OffsetEntryCount);
 
   if (HeaderData.OffsetEntryCount > 0) {
     OS << "offsets: [";
     for (uint32_t I = 0; I < HeaderData.OffsetEntryCount; ++I) {
       auto Off = *getOffsetEntry(Data, I);
-      OS << format("\n0x%0*" PRIx64, OffsetDumpWidth, Off);
+      OS << formatv("\n0x{0:x-}",
+                    fmt_align(Off, AlignStyle::Right, OffsetDumpWidth, '0'));
       if (DumpOpts.Verbose)
-        OS << format(" => 0x%08" PRIx64,
-                     Off + HeaderOffset + getHeaderSize(Format));
+        OS << formatv(" => {0:x+8}",
+                      Off + HeaderOffset + getHeaderSize(Format));
     }
     OS << "\n]\n";
   }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
index fe16ca06132be..e8bce6f4634bf 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
@@ -10,6 +10,8 @@
 #include "llvm/DebugInfo/DIContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 
@@ -22,27 +24,30 @@ void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
 
   if (DumpOpts.SummarizeTypes) {
     OS << "name = '" << Name << "'"
-       << ", type_signature = " << format("0x%016" PRIx64, getTypeHash())
-       << ", length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
+       << ", type_signature = " << formatv("{0:x+16}", getTypeHash())
+       << ", length = "
+       << formatv("0x{0:x-}", fmt_align(getLength(), AlignStyle::Right,
+                                        OffsetDumpWidth, '0'))
        << '\n';
     return;
   }
 
-  OS << format("0x%08" PRIx64, getOffset()) << ": Type Unit:"
-     << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
+  OS << formatv("{0:x+8}", getOffset()) << ": Type Unit:"
+     << " length = "
+     << formatv("0x{0:x-}",
+                fmt_align(getLength(), AlignStyle::Right, OffsetDumpWidth, '0'))
      << ", format = " << dwarf::FormatString(getFormat())
-     << ", version = " << format("0x%04x", getVersion());
+     << ", version = " << formatv("{0:x+4}", getVersion());
   if (getVersion() >= 5)
     OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
-  OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset());
+  OS << ", abbr_offset = " << formatv("{0:x+4}", getAbbrOffset());
   if (!getAbbreviations())
     OS << " (invalid)";
-  OS << ", addr_size = " << format("0x%02x", getAddressByteSize())
+  OS << ", addr_size = " << formatv("{0:x+2}", getAddressByteSize())
      << ", name = '" << Name << "'"
-     << ", type_signature = " << format("0x%016" PRIx64, getTypeHash())
-     << ", type_offset = " << format("0x%04" PRIx64, getTypeOffset())
-     << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
-     << ")\n";
+     << ", type_signature = " << formatv("{0:x+16}", getTypeHash())
+     << ", type_offset = " << formatv("{0:x+4}", getTypeOffset())
+     << " (next unit at " << formatv("{0:x+8}", getNextUnitOffset()) << ")\n";
 
   if (DWARFDie TU = getUnitDIE(false))
     TU.dump(OS, 0, DumpOpts);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
index a4487e2dc21be..6a293b6997887 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -12,6 +12,7 @@
 #include "llvm/Support/DataExtractor.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cinttypes>
 #include <cstdint>
@@ -113,7 +114,8 @@ bool DWARFUnitIndex::Header::parse(DataExtractor IndexData,
 }
 
 void DWARFUnitIndex::Header::dump(raw_ostream &OS) const {
-  OS << format("version = %u, units = %u, slots = %u\n\n", Version, NumUnits, NumBuckets);
+  OS << formatv("version = {0}, units = {1}, slots = {2}\n\n", Version,
+                NumUnits, NumBuckets);
 }
 
 bool DWARFUnitIndex::parse(DataExtractor IndexData) {
@@ -226,7 +228,7 @@ void DWARFUnitIndex::dump(raw_ostream &OS) const {
          << left_justify(Name,
                          Kind == DWARFSectionKind::DW_SECT_INFO ? 40 : 24);
     else
-      OS << format(" Unknown: %-15" PRIu32, RawSectionIds[i]);
+      OS << formatv(" Unknown: {0, -15}", RawSectionIds[i]);
   }
   OS << "\n----- ------------------";
   for (unsigned i = 0; i != Header.NumColumns; ++i) {
@@ -241,19 +243,17 @@ void DWARFUnitIndex::dump(raw_ostream &OS) const {
   for (unsigned i = 0; i != Header.NumBuckets; ++i) {
     auto &Row = Rows[i];
     if (auto *Contribs = Row.Contributions.get()) {
-      OS << format("%5u 0x%016" PRIx64 " ", i + 1, Row.Signature);
+      OS << formatv("{0,5:d} {1:x+16} ", i + 1, Row.Signature);
       for (unsigned i = 0; i != Header.NumColumns; ++i) {
         auto &Contrib = Contribs[i];
         DWARFSectionKind Kind = ColumnKinds[i];
         if (Kind == DWARFSectionKind::DW_SECT_INFO ||
             Kind == DWARFSectionKind::DW_SECT_EXT_TYPES)
-          OS << format("[0x%016" PRIx64 ", 0x%016" PRIx64 ") ",
-                       Contrib.getOffset(),
-                       Contrib.getOffset() + Contrib.getLength());
+          OS << formatv("[{0:x+16}, {1:x+16}) ", Contrib.getOffset(),
+                        Contrib.getOffset() + Contrib.getLength());
         else
-          OS << format("[0x%08" PRIx32 ", 0x%08" PRIx32 ") ",
-                       Contrib.getOffset32(),
-                       Contrib.getOffset32() + Contrib.getLength32());
+          OS << formatv("[{0:x+8}, {1:x+8}) ", Contrib.getOffset32(),
+                        Contrib.getOffset32() + Contrib.getLength32());
       }
       OS << '\n';
     }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp
index bdcda266ea69d..21af8d13689df 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp
@@ -12,6 +12,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cassert>
 #include <cinttypes>
@@ -153,7 +154,7 @@ static void printUnwindRow(const UnwindRow &Row, raw_ostream &OS,
                            DIDumpOptions DumpOpts, unsigned IndentLevel) {
   OS.indent(2 * IndentLevel);
   if (Row.hasAddress())
-    OS << format("0x%" PRIx64 ": ", Row.getAddress());
+    OS << formatv("{0:x+}: ", Row.getAddress());
   OS << "CFA=";
   printUnwindLocation(Row.getCFAValue(), OS, DumpOpts);
   if (Row.getRegisterLocations().hasLocations()) {
diff --git a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
index 0a5bb7caaee8c..de133bf89c09a 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
@@ -17,6 +17,7 @@
 #include "llvm/DebugInfo/GSYM/LineTable.h"
 #include "llvm/Support/BinaryStreamReader.h"
 #include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
@@ -398,7 +399,7 @@ void GsymReader::dump(raw_ostream &OS) {
   OS << " (ADDRESS)\n";
   OS << "====== =============================== \n";
   for (uint32_t I = 0; I < Header.NumAddresses; ++I) {
-    OS << format("[%4u] ", I);
+    OS << formatv("[{0,4:d}] ", I);
     switch (Hdr->AddrOffSize) {
     case 1: OS << HEX8(getAddrOffsets<uint8_t>()[I]); break;
     case 2: OS << HEX16(getAddrOffsets<uint16_t>()[I]); break;
@@ -413,13 +414,13 @@ void GsymReader::dump(raw_ostream &OS) {
   OS << "INDEX  Offset\n";
   OS << "====== ==========\n";
   for (uint32_t I = 0; I < Header.NumAddresses; ++I)
-    OS << format("[%4u] ", I) << HEX32(AddrInfoOffsets[I]) << "\n";
+    OS << formatv("[{0,4:d}] ", I) << HEX32(AddrInfoOffsets[I]) << "\n";
   // Dump the file table.
   OS << "\nFiles:\n";
   OS << "INDEX  DIRECTORY  BASENAME   PATH\n";
   OS << "====== ========== ========== ==============================\n";
   for (uint32_t I = 0; I < Files.size(); ++I) {
-    OS << format("[%4u] ", I) << HEX32(Files[I].Dir) << ' '
+    OS << formatv("[{0,4:d}] ", I) << HEX32(Files[I].Dir) << ' '
        << HEX32(Files[I].Base) << ' ';
     dump(OS, getFile(I));
     OS << "\n";
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVCompare.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVCompare.cpp
index 3cb2662f2f313..65e28fd27e1fa 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVCompare.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVCompare.cpp
@@ -405,10 +405,10 @@ void LVCompare::printSummary() const {
   auto PrintSeparator = [&]() { OS << Separator << "\n"; };
   auto PrintHeadingRow = [&](const char *T, const char *U, const char *V,
                              const char *W) {
-    OS << format("%-9s%9s  %9s  %9s\n", T, U, V, W);
+    OS << formatv("{0, -9}{1,9}  {2,9}  {3,9}\n", T, U, V, W);
   };
   auto PrintDataRow = [&](const char *T, unsigned U, unsigned V, unsigned W) {
-    OS << format("%-9s%9d  %9d  %9d\n", T, U, V, W);
+    OS << formatv("{0, -9}{1,9}  {2,9}  {3,9}\n", T, U, V, W);
   };
 
   OS << "\n";
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
index c6fb405baed1d..af443cc3d799f 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
@@ -529,7 +529,7 @@ void LVElement::printFileIndex(raw_ostream &OS, bool Full) const {
 
       OS << "  {Source} ";
       if (getInvalidFilename())
-        OS << format("[0x%08x]\n", Index);
+        OS << formatv("[{0:x+8}]\n", Index);
       else
         OS << formattedName(getPathname()) << "\n";
     }
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp
index 5cb017903675a..fafaab13d35e1 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp
@@ -33,7 +33,7 @@ std::string LVOperation::getOperandsDWARFInfo() {
     // 2.5.1.1 Literal encodings.
     //-----------------------------------------------------------------------
     if (dwarf::DW_OP_lit0 <= Code && Code <= dwarf::DW_OP_lit31) {
-      Stream << format("lit%d", Code - dwarf::DW_OP_lit0);
+      Stream << formatv("lit{0}", Code - dwarf::DW_OP_lit0);
       return;
     }
 
@@ -42,8 +42,8 @@ std::string LVOperation::getOperandsDWARFInfo() {
     //-----------------------------------------------------------------------
     if (dwarf::DW_OP_breg0 <= Code && Code <= dwarf::DW_OP_breg31) {
       std::string RegisterName(getReader().getRegisterName(Code, Operands));
-      Stream << format("breg%d+%d%s", Code - dwarf::DW_OP_breg0, Operands[0],
-                       RegisterName.c_str());
+      Stream << formatv("breg{0}+{1}{2}", Code - dwarf::DW_OP_breg0,
+                        Operands[0], RegisterName.c_str());
       return;
     }
 
@@ -52,12 +52,12 @@ std::string LVOperation::getOperandsDWARFInfo() {
     //-----------------------------------------------------------------------
     if (dwarf::DW_OP_reg0 <= Code && Code <= dwarf::DW_OP_reg31) {
       std::string RegisterName(getReader().getRegisterName(Code, Operands));
-      Stream << format("reg%d%s", Code - dwarf::DW_OP_reg0,
-                       RegisterName.c_str());
+      Stream << formatv("reg{0}{1}", Code - dwarf::DW_OP_reg0,
+                        RegisterName.c_str());
       return;
     }
 
-    Stream << format("#0x%02x ", Code) << hexString(Operands[0]) << " "
+    Stream << formatv("#{0:x+2} ", Code) << hexString(Operands[0]) << " "
            << hexString(Operands[1]) << "#";
   };
 
@@ -100,14 +100,14 @@ std::string LVOperation::getOperandsDWARFInfo() {
     break;
   case dwarf::DW_OP_bregx: {
     std::string RegisterName(getReader().getRegisterName(Opcode, Operands));
-    Stream << format("bregx %d%s+%d", Operands[0], RegisterName.c_str(),
-                     unsigned(Operands[1]));
+    Stream << formatv("bregx {0}{1}+{2}", Operands[0], RegisterName.c_str(),
+                      unsigned(Operands[1]));
     break;
   }
   case dwarf::DW_OP_regval_type: {
     std::string RegisterName(getReader().getRegisterName(Opcode, Operands));
-    Stream << format("regval_type %d%s+%d", Operands[0], RegisterName.c_str(),
-                     unsigned(Operands[1]));
+    Stream << formatv("regval_type {0}{1}+{2}", Operands[0],
+                      RegisterName.c_str(), unsigned(Operands[1]));
     break;
   }
 
@@ -390,7 +390,7 @@ std::string LVOperation::getOperandsCodeViewInfo() {
     break;
 
   default:
-    Stream << format("#0x%02x: ", Opcode) << hexString(Operands[0]) << " "
+    Stream << formatv("#{0:x+2}: ", Opcode) << hexString(Operands[0]) << " "
            << hexString(Operands[1]) << "#";
     break;
   }
@@ -639,10 +639,10 @@ void LVLocation::print(LVLocations *Locations, raw_ostream &OS, bool Full) {
     // The coverage is dependent on the kind of location.
     std::string String;
     raw_string_ostream Stream(String);
-    Stream << format("%.2f%%", Percentage);
+    Stream << formatv("{0:F2}%", Percentage);
     if (!Location->getIsLocationSimple())
-      Stream << format(" (%d/%d)", Symbol->getCoverageFactor(),
-                       Symbol->getParentScope()->getCoverageFactor());
+      Stream << formatv(" ({0}/{1})", Symbol->getCoverageFactor(),
+                        Symbol->getParentScope()->getCoverageFactor());
     Symbol->printAttributes(OS, Full, "{Coverage} ", Symbol, StringRef(String),
                             /*UseQuotes=*/false,
                             /*PrintRef=*/false);
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp
index 5ccbcbfa4f0aa..1f7d348dfdac8 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp
@@ -123,7 +123,7 @@ void LVObject::printAttributes(raw_ostream &OS, bool Full, StringRef Name,
   // Print the line.
   std::string TheLineNumber(Object.lineNumberAsString());
   std::string TheIndentation(Object.indentAsString());
-  OS << format(" %5s %s ", TheLineNumber.c_str(), TheIndentation.c_str());
+  OS << formatv(" {0,5} {1} ", TheLineNumber.c_str(), TheIndentation.c_str());
 
   OS << Name;
   if (PrintRef && options().getAttributeOffset())
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp
index 4dc4b588ad60d..81af6503260a8 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp
@@ -13,6 +13,7 @@
 #include "llvm/DebugInfo/LogicalView/Core/LVRange.h"
 #include "llvm/DebugInfo/LogicalView/Core/LVLocation.h"
 #include "llvm/DebugInfo/LogicalView/Core/LVOptions.h"
+#include "llvm/Support/FormatVariadic.h"
 
 using namespace llvm;
 using namespace llvm::logicalview;
@@ -81,7 +82,7 @@ void LVRange::addEntry(LVScope *Scope) {
 
 // Get the scope associated with the input address.
 LVScope *LVRange::getEntry(LVAddress Address) const {
-  LLVM_DEBUG({ dbgs() << format("Searching: 0x%08x\nFound: ", Address); });
+  LLVM_DEBUG({ dbgs() << formatv("Searching: {0:x+8}\nFound: ", Address); });
 
   LVScope *Target = nullptr;
   LVLevel TargetLevel = 0;
@@ -90,8 +91,9 @@ LVScope *LVRange::getEntry(LVAddress Address) const {
   for (LVRangesTree::find_iterator Iter = RangesTree.find(Address),
                                    End = RangesTree.find_end();
        Iter != End; ++Iter) {
-    LLVM_DEBUG(
-        { dbgs() << format("[0x%08x,0x%08x] ", Iter->left(), Iter->right()); });
+    LLVM_DEBUG({
+      dbgs() << formatv("[{0:x+8},{1:x+8}] ", Iter->left(), Iter->right());
+    });
     Scope = Iter->value();
     Level = Scope->getLevel();
     if (Level > TargetLevel) {
@@ -150,7 +152,7 @@ void LVRange::print(raw_ostream &OS, bool Full) const {
     Indentation = options().indentationSize();
     if (Indentation)
       OS << " ";
-    OS << format("[0x%08x,0x%08x] ", RangeEntry.lower(), RangeEntry.upper())
+    OS << formatv("[{0:x+8},{1:x+8}] ", RangeEntry.lower(), RangeEntry.upper())
        << formattedKind(Scope->kind()) << " " << formattedName(Scope->getName())
        << "\n";
   }
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
index d973a47f68732..6d55076a3de9b 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
@@ -70,22 +70,19 @@ bool checkIntegrityScopesTree(LVScope *Root) {
     });
 
     auto PrintIndex = [](unsigned Index) {
-      if (Index)
-        dbgs() << format("%8d: ", Index);
-      else
-        dbgs() << format("%8c: ", ' ');
+      dbgs() << formatv("{0,8}: ", Index ? Index : ' ');
     };
     auto PrintElement = [&](LVElement *Element, unsigned Index = 0) {
       PrintIndex(Index);
       std::string ElementName(Element->getName());
-      dbgs() << format("%15s ID=0x%08x '%s'\n", Element->kind(),
-                       Element->getID(), ElementName.c_str());
+      dbgs() << formatv("{0,15} ID={1:x+8} '{2}'\n", Element->kind(),
+                        Element->getID(), ElementName.c_str());
     };
 
     std::string RootName(Root->getName());
     dbgs() << formatv("{0}\n", fmt_repeat('=', 72));
-    dbgs() << format("Root: '%s'\nDuplicated elements: %d\n", RootName.c_str(),
-                     Duplicate.size());
+    dbgs() << formatv("Root: '{0}'\nDuplicated elements: {1}\n",
+                      RootName.c_str(), Duplicate.size());
     dbgs() << formatv("{0}\n", fmt_repeat('=', 72));
 
     unsigned Index = 0;
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
index e03932622b259..56da167926cb2 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
@@ -1184,10 +1184,10 @@ void LVScopeArray::printExtra(raw_ostream &OS, bool Full) const {
 void LVScopeCompileUnit::addSize(LVScope *Scope, LVOffset Lower,
                                  LVOffset Upper) {
   LLVM_DEBUG({
-    dbgs() << format(
-        "CU [0x%08" PRIx64 "], Scope [0x%08" PRIx64 "], Range [0x%08" PRIx64
-        ":0x%08" PRIx64 "], Size = %" PRId64 "\n",
-        getOffset(), Scope->getOffset(), Lower, Upper, Upper - Lower);
+    dbgs() << formatv("CU [{0:x+8}], Scope [{1:x+8}], Range [{2:x+8}"
+                      ":{3:x+8}], Size = {4}\n",
+                      getOffset(), Scope->getOffset(), Lower, Upper,
+                      Upper - Lower);
   });
 
   // There is no need to check for a previous entry, as we are traversing the
@@ -1482,7 +1482,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const {
   if (options().getInternalTag() && getReader().isBinaryTypeELF()) {
     PrintHeader("Unsupported DWARF Tags");
     for (LVTagOffsetsMap::const_reference Entry : DebugTags) {
-      OS << format("\n0x%02x", (unsigned)Entry.first) << ", "
+      OS << formatv("\n{0:x+2}", (unsigned)Entry.first) << ", "
          << dwarf::TagString(Entry.first) << "\n";
       unsigned Count = 0;
       for (const LVOffset &Offset : Entry.second)
@@ -1498,7 +1498,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const {
       // Symbol basic information.
       LVSymbol *Symbol = Entry.second;
       OS << hexSquareString(Entry.first) << " {Coverage} "
-         << format("%.2f%%", Symbol->getCoveragePercentage()) << " "
+         << formatv("{0:f2}%", Symbol->getCoveragePercentage()) << " "
          << formattedKind(Symbol->kind()) << " "
          << formattedName(Symbol->getName()) << "\n";
     }
@@ -1527,8 +1527,8 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const {
 void LVScopeCompileUnit::printTotals(raw_ostream &OS) const {
   OS << "\nTotals by lexical level:\n";
   for (size_t Index = 1; Index <= MaxSeenLevel; ++Index)
-    OS << format("[%03d]: %10d (%6.2f%%)\n", Index, Totals[Index].first,
-                 Totals[Index].second);
+    OS << formatv("[{0,0+3}]: {1,10} ({2,6:f2}%)\n", Index, Totals[Index].first,
+                  Totals[Index].second);
 }
 
 void LVScopeCompileUnit::printScopeSize(const LVScope *Scope, raw_ostream &OS) {
@@ -1540,7 +1540,7 @@ void LVScopeCompileUnit::printScopeSize(const LVScope *Scope, raw_ostream &OS) {
     // implementation-defined rounding inside printing functions.
     float Percentage =
         rint((float(Size) / CUContributionSize) * 100.0 * 100.0) / 100.0;
-    OS << format("%10" PRId64 " (%6.2f%%) : ", Size, Percentage);
+    OS << formatv("{0,10} ({1,6:f2}%) : ", Size, Percentage);
     Scope->print(OS);
 
     // Keep record of the total sizes at each lexical level.
@@ -1607,11 +1607,12 @@ void LVScopeCompileUnit::printSummary(raw_ostream &OS, const LVCounter &Counter,
                                       const char *Header) const {
   std::string Separator = std::string(29, '-');
   auto PrintSeparator = [&]() { OS << Separator << "\n"; };
+  const char *Fmt = "{0,-9}{1,9}  {2,9}\n";
   auto PrintHeadingRow = [&](const char *T, const char *U, const char *V) {
-    OS << format("%-9s%9s  %9s\n", T, U, V);
+    OS << formatv(Fmt, T, U, V);
   };
   auto PrintDataRow = [&](const char *T, unsigned U, unsigned V) {
-    OS << format("%-9s%9d  %9d\n", T, U, V);
+    OS << formatv(Fmt, T, U, V);
   };
 
   OS << "\n";
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
index 974fbd0997c01..c3d745f3fd113 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
@@ -496,8 +496,8 @@ Error LVBinaryReader::createInstructions(LVScope *Scope,
     dbgs() << "\nSectionIndex: " << format_decimal(SectionIndex, 3)
            << " Scope DIE: " << hexValue(Scope->getOffset()) << "\n"
            << "Address: " << hexValue(FirstAddress)
-           << format(" - Collected instructions lines: %d\n",
-                     Instructions.size());
+           << formatv(" - Collected instructions lines: {0}\n",
+                      Instructions.size());
     for (const LVLine *Line : Instructions)
       dbgs() << format_decimal(++Index, 5) << ": "
              << hexValue(Line->getOffset()) << ", (" << Line->getName()
@@ -584,7 +584,7 @@ void LVBinaryReader::processLines(LVLines *DebugLines,
   LLVM_DEBUG({
     size_t Index = 1;
     size_t PerLine = 4;
-    dbgs() << format("\nProcess debug lines: %d\n", DebugLines->size());
+    dbgs() << formatv("\nProcess debug lines: {0}\n", DebugLines->size());
     for (const LVLine *Line : *DebugLines) {
       dbgs() << format_decimal(Index, 5) << ": " << hexValue(Line->getOffset())
              << ", (" << Line->getLineNumber() << ")"
@@ -621,8 +621,8 @@ void LVBinaryReader::processLines(LVLines *DebugLines,
       size_t Index = 0;
       dbgs() << "\nSectionIndex: " << format_decimal(SectionIndex, 3)
              << " Scope DIE: " << hexValue(Scope->getOffset()) << "\n"
-             << format("Process instruction lines: %d\n",
-                       InstructionLines.size());
+             << formatv("Process instruction lines: {0}\n",
+                        InstructionLines.size());
       for (const LVLine *Line : InstructionLines)
         dbgs() << format_decimal(++Index, 5) << ": "
                << hexValue(Line->getOffset()) << ", (" << Line->getName()
@@ -649,7 +649,7 @@ void LVBinaryReader::processLines(LVLines *DebugLines,
             dbgs() << "Line " << (IsDebug ? "dbg:" : "ins:") << " ["
                    << hexValue(DebugAddress) << "]";
             if (IsDebug)
-              dbgs() << format(" %d", (*Iter)->getLineNumber());
+              dbgs() << formatv(" {0}", (*Iter)->getLineNumber());
             dbgs() << "\n";
           });
           // Instruction address before debug line.
@@ -657,7 +657,7 @@ void LVBinaryReader::processLines(LVLines *DebugLines,
             LLVM_DEBUG({
               dbgs() << "Inserted instruction address: "
                      << hexValue(InstructionAddress) << " before line: "
-                     << format("%d", (*Iter)->getLineNumber()) << " ["
+                     << formatv("{0}", (*Iter)->getLineNumber()) << " ["
                      << hexValue(DebugAddress) << "]\n";
             });
             Iter = DebugLines->insert(Iter, InstructionLine);
@@ -681,7 +681,7 @@ void LVBinaryReader::processLines(LVLines *DebugLines,
   }
 
   LLVM_DEBUG({
-    dbgs() << format("Lines after merge: %d\n", DebugLines->size());
+    dbgs() << formatv("Lines after merge: {0}\n", DebugLines->size());
     size_t Index = 0;
     for (const LVLine *Line : *DebugLines) {
       dbgs() << format_decimal(++Index, 5) << ": "
@@ -706,7 +706,7 @@ void LVBinaryReader::processLines(LVLines *DebugLines,
             size_t Index = 0;
             dbgs() << "\nSectionIndex: " << format_decimal(SectionIndex, 3)
                    << " Scope DIE: " << hexValue(Scope->getOffset()) << "\n"
-                   << format("Instruction lines: %d\n", Lines->size());
+                   << formatv("Instruction lines: {0}\n", Lines->size());
             for (const LVLine *Line : *Lines)
               dbgs() << format_decimal(++Index, 5) << ": "
                      << hexValue(Line->getOffset()) << ", (" << Line->getName()
@@ -901,7 +901,7 @@ void LVBinaryReader::includeInlineeLines(LVSectionIndex SectionIndex,
       for (const LVLine *Line : *InlineeLines)
         dbgs() << "[" << hexValue(Line->getAddress()) << "] "
                << Line->getLineNumber() << "\n";
-      dbgs() << format("Debug lines: %d\n", CULines.size());
+      dbgs() << formatv("Debug lines: {0}\n", CULines.size());
       for (const LVLine *Line : CULines)
         dbgs() << "Line address: " << hexValue(Line->getOffset()) << ", ("
                << Line->getLineNumber() << ")\n";
@@ -938,7 +938,7 @@ void LVBinaryReader::includeInlineeLines(LVSectionIndex SectionIndex,
   }
   LLVM_DEBUG({
     dbgs() << "Merged Inlined lines for: " << Function->getName() << "\n";
-    dbgs() << format("Debug lines: %d\n", CULines.size());
+    dbgs() << formatv("Debug lines: {0}\n", CULines.size());
     for (const LVLine *Line : CULines)
       dbgs() << "Line address: " << hexValue(Line->getOffset()) << ", ("
              << Line->getLineNumber() << ")\n";
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
index 3818dc3b9a026..5bd766d0fa0d0 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
@@ -3456,7 +3456,7 @@ void LVLogicalVisitor::printRecords(raw_ostream &OS) const {
         OS << "\n";
       }
     };
-    OS << format("%20s", Name.str().c_str());
+    OS << formatv("{0,20}", Name.str().c_str());
     NewLine();
   };
 
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
index 772d821dcda81..ca642ef421f60 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
@@ -210,7 +210,7 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
           FoundLowPC = false;
           // We are dealing with an index into the .debug_addr section.
           LLVM_DEBUG({
-            dbgs() << format("indexed (%8.8x) address = ", (uint32_t)UValue);
+            dbgs() << formatv("indexed ({0:x-8}) address = ", (uint32_t)UValue);
           });
         }
       }
@@ -263,8 +263,8 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
       if (!RangesOrError) {
         LLVM_DEBUG({
           std::string TheError(toString(RangesOrError.takeError()));
-          dbgs() << format("error decoding address ranges = ",
-                           TheError.c_str());
+          dbgs() << formatv("error decoding address ranges = {0}",
+                            TheError.c_str());
         });
         consumeError(RangesOrError.takeError());
         break;
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index a18c20c76eb7a..e5fb9c4b4fef9 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -412,8 +412,51 @@ TEST(FormatAndFormatvTest, EquivalentHexFormatting) {
             formatv("0x{0:x-}", fmt_align(N, AlignStyle::Right, HexDigits, '0'))
                 .str());
 
+  // More examples
+
+  EXPECT_EQ("0x0000000abc",
+            printToString(format("0x%0*" PRIx64, 10, 0xABCULL)));
+  EXPECT_EQ("0x0000000abc",
+            formatv("0x{0:x-}", fmt_align(0xABCULL, AlignStyle::Right, 10, '0'))
+                .str());
+
   EXPECT_EQ("0x000000fe", printToString(format("0x%8.8" PRIx64, 0xfeULL)));
   EXPECT_EQ("0x000000fe", formatv("{0:x+8}", 0xfeULL).str());
+
+  EXPECT_EQ("000000fe", printToString(format("%08" PRIx64, 0xfeULL)));
+  EXPECT_EQ("000000fe", formatv("{0:x-8}", 0xfeULL).str());
+
+  EXPECT_EQ("0x000000fb", printToString(format("0x%08.08" PRIx64, 0xfbULL)));
+  EXPECT_EQ("0x000000fb", formatv("{0:x+8}", 0xfbULL).str());
+
+  EXPECT_EQ("123", printToString(format("%x", 0x123)));
+  EXPECT_EQ("123", formatv("{0:x-}", 0x123).str());
+}
+
+TEST(FormatAndFormatvTest, StringPadding) {
+  // The expected string has 9 spaces after "abcd" and a closing bracket.
+  EXPECT_EQ("[abcd         ]",
+            printToString(format("[%s%*c", "abcd", 10, ']')));
+  // With formatv we can use padding but the closing bracket can be included in
+  // the format string and the padding needs to be one off.
+  EXPECT_EQ("[abcd         ]",
+            formatv("[{0}]", fmt_pad("abcd", 0, 10 - 1)).str());
+}
+
+TEST(FormatAndFormatvTest, Alignment) {
+  EXPECT_EQ("250            ", printToString(format("%-15" PRIu32, 0xfa)));
+  EXPECT_EQ("250            ", formatv("{0, -15}", 0xfa).str());
+  EXPECT_EQ("250            ",
+            formatv("{0}", fmt_align(0xfa, AlignStyle::Left, 15)).str());
+
+  EXPECT_EQ("  123", printToString(format("%5u", 123)));
+  EXPECT_EQ("  123", formatv("{0,5:d}", 123).str());
+
+  EXPECT_EQ("001", printToString(format("%03d", 1)));
+  EXPECT_EQ("001", formatv("{0,0+3}", 1).str());
+
+  EXPECT_EQ("foo      ", printToString(format("%-9s", "foo")));
+  EXPECT_EQ("foo      ", formatv("{0,-9}", "foo").str());
 }
 
 TEST(FormatAndFormatvTest, NonNegativePlusInteger) {

>From bd36b59f2dc168befbfed9487e3095f74ce99bce Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Mon, 13 Apr 2026 07:48:26 +0000
Subject: [PATCH 2/2] Format changes: x+ -> x and {0:d} -> {0}

---
 .../DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 12 ++++-----
 llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp  |  6 ++---
 llvm/lib/DebugInfo/DWARF/DWARFContext.cpp     | 10 ++++----
 llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp  | 13 ++++------
 llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp   | 25 +++++++++----------
 llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp  |  6 ++---
 .../DebugInfo/DWARF/DWARFDebugPubTable.cpp    |  2 +-
 .../DebugInfo/DWARF/DWARFDebugRnglists.cpp    |  2 +-
 llvm/lib/DebugInfo/DWARF/DWARFDie.cpp         |  6 ++---
 .../DWARF/DWARFExpressionPrinter.cpp          | 14 +++++------
 llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp    | 22 ++++++++--------
 llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp   | 11 ++++----
 llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp    | 16 ++++++------
 llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp   |  6 ++---
 .../DWARF/DWARFUnwindTablePrinter.cpp         |  2 +-
 llvm/lib/DebugInfo/GSYM/GsymReader.cpp        |  6 ++---
 .../DebugInfo/LogicalView/Core/LVElement.cpp  |  2 +-
 .../DebugInfo/LogicalView/Core/LVLocation.cpp |  4 +--
 .../DebugInfo/LogicalView/Core/LVRange.cpp    |  6 ++---
 .../DebugInfo/LogicalView/Core/LVReader.cpp   |  2 +-
 .../DebugInfo/LogicalView/Core/LVScope.cpp    |  6 ++---
 llvm/unittests/Support/FormatVariadicTest.cpp |  3 +++
 22 files changed, 90 insertions(+), 92 deletions(-)

diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 91f4b50e043d1..d37e75d46551c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -185,7 +185,7 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
     return false; // End of list
 
   DictScope NameScope(W, ("Name at 0x" + Twine::utohexstr(NameOffset)).str());
-  W.startLine() << formatv("String: {0:x+8}", StringOffset);
+  W.startLine() << formatv("String: {0:x8}", StringOffset);
   W.getOStream() << " \"" << StringSection.getCStr(&StringOffset) << "\"\n";
 
   unsigned NumData = AccelSection.getU32(DataOffset);
@@ -193,7 +193,7 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
     ListScope DataScope(W, ("Data " + Twine(Data)).str());
     unsigned i = 0;
     for (auto &Atom : AtomForms) {
-      W.startLine() << formatv("Atom[{0:d}]: ", i);
+      W.startLine() << formatv("Atom[{0}]: ", i);
       if (Atom.extractValue(AccelSection, DataOffset, FormParams)) {
         Atom.dump(W.getOStream());
         if (std::optional<uint64_t> Val = Atom.getAsUnsignedConstant()) {
@@ -859,7 +859,7 @@ void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
   if (Hash)
     W.printHex("Hash", *Hash);
 
-  W.startLine() << formatv("String: {0:x+8}", NTE.getStringOffset());
+  W.startLine() << formatv("String: {0:x8}", NTE.getStringOffset());
   W.getOStream() << " \"" << NTE.getString() << "\"\n";
 
   uint64_t EntryOffset = NTE.getEntryOffset();
@@ -870,7 +870,7 @@ void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
 void DWARFDebugNames::NameIndex::dumpCUs(ScopedPrinter &W) const {
   ListScope CUScope(W, "Compilation Unit offsets");
   for (uint32_t CU = 0; CU < Hdr.CompUnitCount; ++CU)
-    W.startLine() << formatv("CU[{0}]: {1:x+8}\n", CU, getCUOffset(CU));
+    W.startLine() << formatv("CU[{0}]: {1:x8}\n", CU, getCUOffset(CU));
 }
 
 void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
@@ -879,7 +879,7 @@ void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
 
   ListScope TUScope(W, "Local Type Unit offsets");
   for (uint32_t TU = 0; TU < Hdr.LocalTypeUnitCount; ++TU)
-    W.startLine() << formatv("LocalTU[{0}]: {1:x+8}\n", TU,
+    W.startLine() << formatv("LocalTU[{0}]: {1:x8}\n", TU,
                              getLocalTUOffset(TU));
 }
 
@@ -889,7 +889,7 @@ void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const {
 
   ListScope TUScope(W, "Foreign Type Unit signatures");
   for (uint32_t TU = 0; TU < Hdr.ForeignTypeUnitCount; ++TU) {
-    W.startLine() << formatv("ForeignTU[{0}]: {1:x+16}\n", TU,
+    W.startLine() << formatv("ForeignTU[{0}]: {1:x16}\n", TU,
                              getForeignTUSignature(TU));
   }
 }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp
index d0a0c4cb1f82b..0ba5a07a382ed 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp
@@ -85,16 +85,16 @@ static void printOperand(raw_ostream &OS, const DIDumpOptions &DumpOpts,
     break;
   case CFIProgram::OT_UnsignedFactDataOffset:
     if (P.dataAlign())
-      OS << formatv(" {0:d}", int64_t(Operand * P.dataAlign()));
+      OS << formatv(" {0}", int64_t(Operand * P.dataAlign()));
     else
-      OS << formatv(" {0:d}*data_alignment_factor", Operand);
+      OS << formatv(" {0}*data_alignment_factor", Operand);
     break;
   case CFIProgram::OT_Register:
     OS << ' ';
     printRegister(OS, DumpOpts, Operand);
     break;
   case CFIProgram::OT_AddressSpace:
-    OS << formatv(" in addrspace{0:d}", Operand);
+    OS << formatv(" in addrspace{0}", Operand);
     break;
   case CFIProgram::OT_Expression:
     assert(Instr.Expression && "missing DWARFExpression object");
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index d19879543d75a..e13a6f598aeb7 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -865,10 +865,10 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
     }
     // Report a gap in the table.
     if (Offset < ContributionHeader) {
-      OS << formatv("{0:x+8}: Gap, length = ", Offset);
+      OS << formatv("{0:x8}: Gap, length = ", Offset);
       OS << (ContributionHeader - Offset) << "\n";
     }
-    OS << formatv("{0:x+8}: ", ContributionHeader);
+    OS << formatv("{0:x8}: ", ContributionHeader);
     // In DWARF v5 the contribution size in the descriptor does not equal
     // the originally encoded length (it does not contain the length of the
     // version field and the padding, a total of 4 bytes). Add them back in
@@ -880,7 +880,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
     Offset = Contribution->Base;
     unsigned EntrySize = Contribution->getDwarfOffsetByteSize();
     while (Offset - Contribution->Base < Contribution->Size) {
-      OS << formatv("{0:x+8}: ", Offset);
+      OS << formatv("{0:x8}: ", Offset);
       uint64_t StringOffset =
           StrOffsetExt.getRelocatedValue(EntrySize, &Offset);
       OS << formatv("{0:x-} ", fmt_align(StringOffset, AlignStyle::Right,
@@ -893,7 +893,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
   }
   // Report a gap at the end of the table.
   if (Offset < SectionSize) {
-    OS << formatv("{0:x+8}: Gap, length = ", Offset);
+    OS << formatv("{0:x8}: Gap, length = ", Offset);
     OS << (SectionSize - Offset) << "\n";
   }
 }
@@ -1169,7 +1169,7 @@ void DWARFContext::dump(
         Parser.skip(DumpOpts.WarningHandler, DumpOpts.WarningHandler);
         continue;
       }
-      OS << "debug_line[" << formatv("{0:x+8}", Parser.getOffset()) << "]\n";
+      OS << "debug_line[" << formatv("{0:x8}", Parser.getOffset()) << "]\n";
       Parser.parseNext(DumpOpts.WarningHandler, DumpOpts.WarningHandler, &OS,
                        DumpOpts.Verbose);
     }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index 85167bf5c1ebd..a75cff4f77410 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -120,15 +120,12 @@ void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
   OS << formatv("  Version:               {0}\n", Version)
      << "  Augmentation:          \"" << Augmentation << "\"\n";
   if (Version >= 4) {
-    OS << formatv("  Address size:          {0}\n", (uint32_t)AddressSize);
-    OS << formatv("  Segment desc size:     {0}\n",
-                  (uint32_t)SegmentDescriptorSize);
+    OS << formatv("  Address size:          {0}\n", AddressSize);
+    OS << formatv("  Segment desc size:     {0}\n", SegmentDescriptorSize);
   }
-  OS << formatv("  Code alignment factor: {0}\n",
-                (uint32_t)CodeAlignmentFactor);
-  OS << formatv("  Data alignment factor: {0}\n", (int32_t)DataAlignmentFactor);
-  OS << formatv("  Return address column: {0}\n",
-                (int32_t)ReturnAddressRegister);
+  OS << formatv("  Code alignment factor: {0}\n", CodeAlignmentFactor);
+  OS << formatv("  Data alignment factor: {0}\n", DataAlignmentFactor);
+  OS << formatv("  Return address column: {0}\n", ReturnAddressRegister);
   if (Personality)
     OS << formatv("  Personality Address: {0:x-16}\n", *Personality);
   if (!AugmentationData.empty()) {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 5e813532aa435..e509421dd1f01 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -151,7 +151,7 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
     // DWARF v5 starts directory indexes at 0.
     uint32_t DirBase = getVersion() >= 5 ? 0 : 1;
     for (uint32_t I = 0; I != IncludeDirectories.size(); ++I) {
-      OS << formatv("include_directories[{0,3:d}] = ", I + DirBase);
+      OS << formatv("include_directories[{0,3}] = ", I + DirBase);
       IncludeDirectories[I].dump(OS, DumpOptions);
       OS << '\n';
     }
@@ -162,16 +162,16 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
     uint32_t FileBase = getVersion() >= 5 ? 0 : 1;
     for (uint32_t I = 0; I != FileNames.size(); ++I) {
       const FileNameEntry &FileEntry = FileNames[I];
-      OS << formatv("file_names[{0,3:d}]:\n", I + FileBase);
+      OS << formatv("file_names[{0,3}]:\n", I + FileBase);
       OS << "           name: ";
       FileEntry.Name.dump(OS, DumpOptions);
       OS << '\n' << formatv("      dir_index: {0}\n", FileEntry.DirIdx);
       if (ContentTypes.HasMD5)
         OS << "   md5_checksum: " << FileEntry.Checksum.digest() << '\n';
       if (ContentTypes.HasModTime)
-        OS << formatv("       mod_time: {0:x+8}\n", FileEntry.ModTime);
+        OS << formatv("       mod_time: {0:x8}\n", FileEntry.ModTime);
       if (ContentTypes.HasLength)
-        OS << formatv("         length: {0:x+8}\n", FileEntry.Length);
+        OS << formatv("         length: {0:x8}\n", FileEntry.Length);
       if (ContentTypes.HasSource) {
         auto Source = FileEntry.Source.getAsCString();
         if (!Source)
@@ -518,9 +518,8 @@ void DWARFDebugLine::Row::dumpTableHeader(raw_ostream &OS, unsigned Indent) {
 }
 
 void DWARFDebugLine::Row::dump(raw_ostream &OS) const {
-  OS << formatv("{0:x+16} {1,6:d} {2,6:d}", Address.Address, Line, Column)
-     << formatv(" {0,6:d} {1,3:d} {2,13:d} {3,7:d} ", File, Isa, Discriminator,
-                OpIndex)
+  OS << formatv("{0:x16} {1,6} {2,6}", Address.Address, Line, Column)
+     << formatv(" {0,6} {1,3} {2,13} {3,7} ", File, Isa, Discriminator, OpIndex)
      << (IsStmt ? " is_stmt" : "") << (BasicBlock ? " basic_block" : "")
      << (PrologueEnd ? " prologue_end" : "")
      << (EpilogueBegin ? " epilogue_begin" : "")
@@ -873,7 +872,7 @@ Error DWARFDebugLine::LineTable::parse(
     DataExtractor::Cursor Cursor(*OffsetPtr);
 
     if (Verbose)
-      *OS << formatv("{0:x+8}: ", *OffsetPtr);
+      *OS << formatv("{0:x8}: ", *OffsetPtr);
 
     uint64_t OpcodeOffset = *OffsetPtr;
     uint8_t Opcode = TableData.getU8(Cursor);
@@ -1016,7 +1015,7 @@ Error DWARFDebugLine::LineTable::parse(
           Prologue.FileNames.push_back(FileEntry);
           if (Cursor && Verbose)
             *OS << " (" << Name << ", dir=" << FileEntry.DirIdx
-                << ", mod_time=" << formatv("({0:x+16})", FileEntry.ModTime)
+                << ", mod_time=" << formatv("({0:x16})", FileEntry.ModTime)
                 << ", length=" << FileEntry.Length << ")";
         }
         break;
@@ -1029,7 +1028,7 @@ Error DWARFDebugLine::LineTable::parse(
 
       default:
         if (Cursor && Verbose)
-          *OS << formatv("Unrecognized extended op {0:x+2}", SubOpcode)
+          *OS << formatv("Unrecognized extended op {0:x2}", SubOpcode)
               << formatv(" length {0:x-}", Len);
         // Len doesn't include the zero opcode byte or the length itself, but
         // it does include the sub_opcode, so we have to adjust for that.
@@ -1153,7 +1152,7 @@ Error DWARFDebugLine::LineTable::parse(
           ParsingState::OpcodeAdvanceResults Advance =
               State.advanceForOpcode(Opcode, OpcodeOffset);
           if (Verbose)
-            *OS << formatv(" (addr += {0:x+16}, op-index += {1})",
+            *OS << formatv(" (addr += {0:x16}, op-index += {1})",
                            Advance.AddrDelta, Advance.OpIndexDelta);
         }
         break;
@@ -1175,7 +1174,7 @@ Error DWARFDebugLine::LineTable::parse(
             State.Row.Address.Address += PCOffset;
             State.Row.OpIndex = 0;
             if (Verbose)
-              *OS << formatv(" (addr += {0:x+4}, op-index = 0)", PCOffset);
+              *OS << formatv(" (addr += {0:x4}, op-index = 0)", PCOffset);
           }
         }
         break;
@@ -1224,7 +1223,7 @@ Error DWARFDebugLine::LineTable::parse(
             *OS << " (operands: ";
             ListSeparator LS;
             for (uint64_t Value : Operands)
-              *OS << LS << formatv("{0:x+16}", Value);
+              *OS << LS << formatv("{0:x16}", Value);
             *OS << ')';
           }
         }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
index 1e16e7f9e78d6..91c208eea9738 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp
@@ -32,8 +32,8 @@ uint8_t DWARFDebugMacro::MacroHeader::getOffsetByteSize() const {
 
 void DWARFDebugMacro::MacroHeader::dumpMacroHeader(raw_ostream &OS) const {
   // FIXME: Add support for dumping opcode_operands_table
-  OS << formatv("macro header: version = {0:x+4}", Version)
-     << formatv(", flags = {0:x+2}", Flags)
+  OS << formatv("macro header: version = {0:x4}", Version)
+     << formatv(", flags = {0:x2}", Flags)
      << ", format = " << FormatString(getDwarfFormat());
   if (Flags & MACRO_DEBUG_LINE_OFFSET)
     OS << formatv(", debug_line_offset = 0x{0:x-}",
@@ -45,7 +45,7 @@ void DWARFDebugMacro::MacroHeader::dumpMacroHeader(raw_ostream &OS) const {
 void DWARFDebugMacro::dump(raw_ostream &OS) const {
   unsigned IndLevel = 0;
   for (const auto &Macros : MacroLists) {
-    OS << formatv("{0:x+8}:\n", Macros.Offset);
+    OS << formatv("{0:x8}:\n", Macros.Offset);
     if (Macros.IsDebugMacro)
       Macros.Header.dumpMacroHeader(OS);
     for (const Entry &E : Macros.Macros) {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
index 494f5634bb764..c8d3757933d8e 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
@@ -99,7 +99,7 @@ void DWARFDebugPubTable::dump(raw_ostream &OS) const {
        << formatv("0x{0:x-}",
                   fmt_align(S.Length, AlignStyle::Right, OffsetDumpWidth, '0'));
     OS << ", format = " << dwarf::FormatString(S.Format);
-    OS << ", version = " << formatv("{0:x+4}", S.Version);
+    OS << ", version = " << formatv("{0:x4}", S.Version);
     OS << ", unit_offset = "
        << formatv("0x{0:x-}",
                   fmt_align(S.Offset, AlignStyle::Right, OffsetDumpWidth, '0'));
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
index 7ea2eb41e0b48..432bcd4cfc9ef 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
@@ -191,7 +191,7 @@ void RangeListEntry::dump(
 
   if (DumpOpts.Verbose) {
     // Print the section offset in verbose mode.
-    OS << formatv("{0:x+8}:", Offset);
+    OS << formatv("{0:x8}:", Offset);
     auto EncodingString = dwarf::RangeListEncodingString(EntryKind);
     // Unsupported encodings should have been reported during parsing.
     assert(!EncodingString.empty() && "Unknown range entry encoding");
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 0c0ae08a3cd27..0debac78d3549 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -46,7 +46,7 @@ static void dumpApplePropertyAttribute(raw_ostream &OS, uint64_t Val) {
     if (!PropName.empty())
       OS << PropName;
     else
-      OS << formatv("DW_APPLE_PROPERTY_{0:x+}", Bit);
+      OS << formatv("DW_APPLE_PROPERTY_{0:x}", Bit);
     if (!(Val ^= Bit))
       break;
     OS << ", ";
@@ -678,7 +678,7 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
     uint32_t abbrCode = debug_info_data.getULEB128(&offset);
     if (DumpOpts.ShowAddresses)
       WithColor(OS, HighlightColor::Address).get()
-          << formatv("\n{0:x+8}: ", Offset);
+          << formatv("\n{0:x8}: ", Offset);
 
     if (abbrCode) {
       auto AbbrevDecl = getAbbreviationDeclarationPtr();
@@ -689,7 +689,7 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
           OS << formatv(" [{0}] {1}", abbrCode,
                         AbbrevDecl->hasChildren() ? '*' : ' ');
           if (std::optional<uint32_t> ParentIdx = Die->getParentIdx())
-            OS << formatv(" ({0:x+8})",
+            OS << formatv(" ({0:x8})",
                           U->getDIEAtIndex(*ParentIdx).getOffset());
         }
         OS << '\n';
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp
index 6416f7967c03f..f5e692deeb782 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp
@@ -29,19 +29,19 @@ static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS,
                                    unsigned Operand) {
   assert(Operand < Operands.size() && "operand out of bounds");
   if (!U) {
-    OS << formatv(" <base_type ref: {0:x+}>", Operands[Operand]);
+    OS << formatv(" <base_type ref: {0:x}>", Operands[Operand]);
     return;
   }
   auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
   if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
     OS << " (";
     if (DumpOpts.Verbose)
-      OS << formatv("{0:x+8} -> ", Operands[Operand]);
-    OS << formatv("{0:x+8})", U->getOffset() + Operands[Operand]);
+      OS << formatv("{0:x8} -> ", Operands[Operand]);
+    OS << formatv("{0:x8})", U->getOffset() + Operands[Operand]);
     if (auto Name = dwarf::toString(Die.find(dwarf::DW_AT_name)))
       OS << " \"" << *Name << "\"";
   } else {
-    OS << formatv(" <invalid base_type ref: {0:x+}>", Operands[Operand]);
+    OS << formatv(" <invalid base_type ref: {0:x}>", Operands[Operand]);
   }
 }
 
@@ -142,7 +142,7 @@ static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
         case 2:
         case 3: // global as uint32
         case 4:
-          OS << formatv(" {0:x+}", Op->getRawOperand(Operand));
+          OS << formatv(" {0:x}", Op->getRawOperand(Operand));
           break;
         default:
           assert(false);
@@ -150,14 +150,14 @@ static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
       } else if (Size == DWARFExpression::Operation::SizeBlock) {
         uint64_t Offset = Op->getRawOperand(Operand);
         for (unsigned i = 0; i < Op->getRawOperand(Operand - 1); ++i)
-          OS << formatv(" {0:x+2}",
+          OS << formatv(" {0:x2}",
                         static_cast<uint8_t>(Expr->getData()[Offset++]));
       } else {
         if (Signed)
           OS << formatv(" {0:+d}", (int64_t)Op->getRawOperand(Operand));
         else if (Op->getCode() != DW_OP_entry_value &&
                  Op->getCode() != DW_OP_GNU_entry_value)
-          OS << formatv(" {0:x+}", Op->getRawOperand(Operand));
+          OS << formatv(" {0:x}", Op->getRawOperand(Operand));
       }
     }
   }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
index 30f4b6141e6a3..738ff01e79b02 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
@@ -24,12 +24,12 @@ using namespace llvm;
 // https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html
 
 void DWARFGdbIndex::dumpCUList(raw_ostream &OS) const {
-  OS << formatv("\n  CU list offset = {0:x+}, has {1} entries:", CuListOffset,
+  OS << formatv("\n  CU list offset = {0:x}, has {1} entries:", CuListOffset,
                 (uint64_t)CuList.size())
      << '\n';
   uint32_t I = 0;
   for (const CompUnitEntry &CU : CuList)
-    OS << formatv("    {0}: Offset = {1:x+}, Length = {2:x+}\n", I++, CU.Offset,
+    OS << formatv("    {0}: Offset = {1:x}, Length = {2:x}\n", I++, CU.Offset,
                   CU.Length);
 }
 
@@ -44,18 +44,18 @@ void DWARFGdbIndex::dumpTUList(raw_ostream &OS) const {
 }
 
 void DWARFGdbIndex::dumpAddressArea(raw_ostream &OS) const {
-  OS << formatv("\n  Address area offset = {0:x+}, has {1} entries:",
+  OS << formatv("\n  Address area offset = {0:x}, has {1} entries:",
                 AddressAreaOffset, (uint64_t)AddressArea.size())
      << '\n';
   for (const AddressEntry &Addr : AddressArea)
-    OS << formatv("    Low/High address = [{0:x+}, {1:x+}) (Size: {2:x+}), CU "
-                  "id = {3:d}\n",
+    OS << formatv("    Low/High address = [{0:x}, {1:x}) (Size: {2:x}), CU "
+                  "id = {3}\n",
                   Addr.LowAddress, Addr.HighAddress,
                   Addr.HighAddress - Addr.LowAddress, Addr.CuIndex);
 }
 
 void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
-  OS << formatv("\n  Symbol table offset = {0:x+}, size = {1}, filled slots:",
+  OS << formatv("\n  Symbol table offset = {0:x}, size = {1}, filled slots:",
                 SymbolTableOffset, (uint64_t)SymbolTable.size())
      << '\n';
 
@@ -78,8 +78,8 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
     if (!E.NameOffset && !E.VecOffset)
       continue;
 
-    OS << formatv("    {0}: Name offset = {1:x+}, CU vector offset = {2:x+}\n",
-                  I, E.NameOffset, E.VecOffset);
+    OS << formatv("    {0}: Name offset = {1:x}, CU vector offset = {2:x}\n", I,
+                  E.NameOffset, E.VecOffset);
 
     StringRef Name = ConstantPoolStrings.substr(
         ConstantPoolOffset - StringPoolOffset + E.NameOffset);
@@ -91,13 +91,13 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
 }
 
 void DWARFGdbIndex::dumpConstantPool(raw_ostream &OS) const {
-  OS << formatv("\n  Constant pool offset = {0:x+}, has {1} CU vectors:",
+  OS << formatv("\n  Constant pool offset = {0:x}, has {1} CU vectors:",
                 ConstantPoolOffset, (uint64_t)ConstantPoolVectors.size());
   uint32_t I = 0;
   for (const auto &V : ConstantPoolVectors) {
-    OS << formatv("\n    {0}({1:x+}): ", I++, V.first);
+    OS << formatv("\n    {0}({1:x}): ", I++, V.first);
     for (uint32_t Val : V.second)
-      OS << formatv("{0:x+} ", Val);
+      OS << formatv("{0:x} ", Val);
   }
   OS << '\n';
 }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
index fe749515756cc..6c1036ad18b7a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
@@ -80,15 +80,15 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
 void DWARFListTableHeader::dump(DataExtractor Data, raw_ostream &OS,
                                 DIDumpOptions DumpOpts) const {
   if (DumpOpts.Verbose)
-    OS << formatv("{0:x+8}: ", HeaderOffset);
+    OS << formatv("{0:x8}: ", HeaderOffset);
   int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format);
   OS << formatv("{0} list header: length = 0x{1:x-}", ListTypeString.data(),
                 fmt_align(HeaderData.Length, AlignStyle::Right, OffsetDumpWidth,
                           '0'))
      << ", format = " << dwarf::FormatString(Format)
-     << formatv(", version = {0:x+4}, addr_size = {1:x+2}"
-                ", seg_size = {2:x+2}"
-                ", offset_entry_count = {3:x+8}\n",
+     << formatv(", version = {0:x4}, addr_size = {1:x2}"
+                ", seg_size = {2:x2}"
+                ", offset_entry_count = {3:x8}\n",
                 HeaderData.Version, HeaderData.AddrSize, HeaderData.SegSize,
                 HeaderData.OffsetEntryCount);
 
@@ -99,8 +99,7 @@ void DWARFListTableHeader::dump(DataExtractor Data, raw_ostream &OS,
       OS << formatv("\n0x{0:x-}",
                     fmt_align(Off, AlignStyle::Right, OffsetDumpWidth, '0'));
       if (DumpOpts.Verbose)
-        OS << formatv(" => {0:x+8}",
-                      Off + HeaderOffset + getHeaderSize(Format));
+        OS << formatv(" => {0:x8}", Off + HeaderOffset + getHeaderSize(Format));
     }
     OS << "\n]\n";
   }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
index e8bce6f4634bf..490b453f8f380 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
@@ -24,7 +24,7 @@ void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
 
   if (DumpOpts.SummarizeTypes) {
     OS << "name = '" << Name << "'"
-       << ", type_signature = " << formatv("{0:x+16}", getTypeHash())
+       << ", type_signature = " << formatv("{0:x16}", getTypeHash())
        << ", length = "
        << formatv("0x{0:x-}", fmt_align(getLength(), AlignStyle::Right,
                                         OffsetDumpWidth, '0'))
@@ -32,22 +32,22 @@ void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
     return;
   }
 
-  OS << formatv("{0:x+8}", getOffset()) << ": Type Unit:"
+  OS << formatv("{0:x8}", getOffset()) << ": Type Unit:"
      << " length = "
      << formatv("0x{0:x-}",
                 fmt_align(getLength(), AlignStyle::Right, OffsetDumpWidth, '0'))
      << ", format = " << dwarf::FormatString(getFormat())
-     << ", version = " << formatv("{0:x+4}", getVersion());
+     << ", version = " << formatv("{0:x4}", getVersion());
   if (getVersion() >= 5)
     OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
-  OS << ", abbr_offset = " << formatv("{0:x+4}", getAbbrOffset());
+  OS << ", abbr_offset = " << formatv("{0:x4}", getAbbrOffset());
   if (!getAbbreviations())
     OS << " (invalid)";
-  OS << ", addr_size = " << formatv("{0:x+2}", getAddressByteSize())
+  OS << ", addr_size = " << formatv("{0:x2}", getAddressByteSize())
      << ", name = '" << Name << "'"
-     << ", type_signature = " << formatv("{0:x+16}", getTypeHash())
-     << ", type_offset = " << formatv("{0:x+4}", getTypeOffset())
-     << " (next unit at " << formatv("{0:x+8}", getNextUnitOffset()) << ")\n";
+     << ", type_signature = " << formatv("{0:x16}", getTypeHash())
+     << ", type_offset = " << formatv("{0:x4}", getTypeOffset())
+     << " (next unit at " << formatv("{0:x8}", getNextUnitOffset()) << ")\n";
 
   if (DWARFDie TU = getUnitDIE(false))
     TU.dump(OS, 0, DumpOpts);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
index 6a293b6997887..d2cd84bb4fc72 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -243,16 +243,16 @@ void DWARFUnitIndex::dump(raw_ostream &OS) const {
   for (unsigned i = 0; i != Header.NumBuckets; ++i) {
     auto &Row = Rows[i];
     if (auto *Contribs = Row.Contributions.get()) {
-      OS << formatv("{0,5:d} {1:x+16} ", i + 1, Row.Signature);
+      OS << formatv("{0,5} {1:x16} ", i + 1, Row.Signature);
       for (unsigned i = 0; i != Header.NumColumns; ++i) {
         auto &Contrib = Contribs[i];
         DWARFSectionKind Kind = ColumnKinds[i];
         if (Kind == DWARFSectionKind::DW_SECT_INFO ||
             Kind == DWARFSectionKind::DW_SECT_EXT_TYPES)
-          OS << formatv("[{0:x+16}, {1:x+16}) ", Contrib.getOffset(),
+          OS << formatv("[{0:x16}, {1:x16}) ", Contrib.getOffset(),
                         Contrib.getOffset() + Contrib.getLength());
         else
-          OS << formatv("[{0:x+8}, {1:x+8}) ", Contrib.getOffset32(),
+          OS << formatv("[{0:x8}, {1:x8}) ", Contrib.getOffset32(),
                         Contrib.getOffset32() + Contrib.getLength32());
       }
       OS << '\n';
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp
index 21af8d13689df..90ed1b5c70725 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp
@@ -154,7 +154,7 @@ static void printUnwindRow(const UnwindRow &Row, raw_ostream &OS,
                            DIDumpOptions DumpOpts, unsigned IndentLevel) {
   OS.indent(2 * IndentLevel);
   if (Row.hasAddress())
-    OS << formatv("{0:x+}: ", Row.getAddress());
+    OS << formatv("{0:x}: ", Row.getAddress());
   OS << "CFA=";
   printUnwindLocation(Row.getCFAValue(), OS, DumpOpts);
   if (Row.getRegisterLocations().hasLocations()) {
diff --git a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
index de133bf89c09a..1a20bd6310e7f 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp
@@ -399,7 +399,7 @@ void GsymReader::dump(raw_ostream &OS) {
   OS << " (ADDRESS)\n";
   OS << "====== =============================== \n";
   for (uint32_t I = 0; I < Header.NumAddresses; ++I) {
-    OS << formatv("[{0,4:d}] ", I);
+    OS << formatv("[{0,4}] ", I);
     switch (Hdr->AddrOffSize) {
     case 1: OS << HEX8(getAddrOffsets<uint8_t>()[I]); break;
     case 2: OS << HEX16(getAddrOffsets<uint16_t>()[I]); break;
@@ -414,13 +414,13 @@ void GsymReader::dump(raw_ostream &OS) {
   OS << "INDEX  Offset\n";
   OS << "====== ==========\n";
   for (uint32_t I = 0; I < Header.NumAddresses; ++I)
-    OS << formatv("[{0,4:d}] ", I) << HEX32(AddrInfoOffsets[I]) << "\n";
+    OS << formatv("[{0,4}] ", I) << HEX32(AddrInfoOffsets[I]) << "\n";
   // Dump the file table.
   OS << "\nFiles:\n";
   OS << "INDEX  DIRECTORY  BASENAME   PATH\n";
   OS << "====== ========== ========== ==============================\n";
   for (uint32_t I = 0; I < Files.size(); ++I) {
-    OS << formatv("[{0,4:d}] ", I) << HEX32(Files[I].Dir) << ' '
+    OS << formatv("[{0,4}] ", I) << HEX32(Files[I].Dir) << ' '
        << HEX32(Files[I].Base) << ' ';
     dump(OS, getFile(I));
     OS << "\n";
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
index af443cc3d799f..d805b44c6ca36 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
@@ -529,7 +529,7 @@ void LVElement::printFileIndex(raw_ostream &OS, bool Full) const {
 
       OS << "  {Source} ";
       if (getInvalidFilename())
-        OS << formatv("[{0:x+8}]\n", Index);
+        OS << formatv("[{0:x8}]\n", Index);
       else
         OS << formattedName(getPathname()) << "\n";
     }
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp
index fafaab13d35e1..6b739f596231d 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp
@@ -57,7 +57,7 @@ std::string LVOperation::getOperandsDWARFInfo() {
       return;
     }
 
-    Stream << formatv("#{0:x+2} ", Code) << hexString(Operands[0]) << " "
+    Stream << formatv("#{0:x2} ", Code) << hexString(Operands[0]) << " "
            << hexString(Operands[1]) << "#";
   };
 
@@ -390,7 +390,7 @@ std::string LVOperation::getOperandsCodeViewInfo() {
     break;
 
   default:
-    Stream << formatv("#{0:x+2}: ", Opcode) << hexString(Operands[0]) << " "
+    Stream << formatv("#{0:x2}: ", Opcode) << hexString(Operands[0]) << " "
            << hexString(Operands[1]) << "#";
     break;
   }
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp
index 81af6503260a8..1c1e1818d38cc 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVRange.cpp
@@ -82,7 +82,7 @@ void LVRange::addEntry(LVScope *Scope) {
 
 // Get the scope associated with the input address.
 LVScope *LVRange::getEntry(LVAddress Address) const {
-  LLVM_DEBUG({ dbgs() << formatv("Searching: {0:x+8}\nFound: ", Address); });
+  LLVM_DEBUG({ dbgs() << formatv("Searching: {0:x8}\nFound: ", Address); });
 
   LVScope *Target = nullptr;
   LVLevel TargetLevel = 0;
@@ -92,7 +92,7 @@ LVScope *LVRange::getEntry(LVAddress Address) const {
                                    End = RangesTree.find_end();
        Iter != End; ++Iter) {
     LLVM_DEBUG({
-      dbgs() << formatv("[{0:x+8},{1:x+8}] ", Iter->left(), Iter->right());
+      dbgs() << formatv("[{0:x8},{1:x8}] ", Iter->left(), Iter->right());
     });
     Scope = Iter->value();
     Level = Scope->getLevel();
@@ -152,7 +152,7 @@ void LVRange::print(raw_ostream &OS, bool Full) const {
     Indentation = options().indentationSize();
     if (Indentation)
       OS << " ";
-    OS << formatv("[{0:x+8},{1:x+8}] ", RangeEntry.lower(), RangeEntry.upper())
+    OS << formatv("[{0:x8},{1:x8}] ", RangeEntry.lower(), RangeEntry.upper())
        << formattedKind(Scope->kind()) << " " << formattedName(Scope->getName())
        << "\n";
   }
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
index 6d55076a3de9b..6ce1d7e282c32 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
@@ -75,7 +75,7 @@ bool checkIntegrityScopesTree(LVScope *Root) {
     auto PrintElement = [&](LVElement *Element, unsigned Index = 0) {
       PrintIndex(Index);
       std::string ElementName(Element->getName());
-      dbgs() << formatv("{0,15} ID={1:x+8} '{2}'\n", Element->kind(),
+      dbgs() << formatv("{0,15} ID={1:x8} '{2}'\n", Element->kind(),
                         Element->getID(), ElementName.c_str());
     };
 
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
index 56da167926cb2..0d5fb3348bd5a 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
@@ -1184,8 +1184,8 @@ void LVScopeArray::printExtra(raw_ostream &OS, bool Full) const {
 void LVScopeCompileUnit::addSize(LVScope *Scope, LVOffset Lower,
                                  LVOffset Upper) {
   LLVM_DEBUG({
-    dbgs() << formatv("CU [{0:x+8}], Scope [{1:x+8}], Range [{2:x+8}"
-                      ":{3:x+8}], Size = {4}\n",
+    dbgs() << formatv("CU [{0:x8}], Scope [{1:x8}], Range [{2:x8}"
+                      ":{3:x8}], Size = {4}\n",
                       getOffset(), Scope->getOffset(), Lower, Upper,
                       Upper - Lower);
   });
@@ -1482,7 +1482,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const {
   if (options().getInternalTag() && getReader().isBinaryTypeELF()) {
     PrintHeader("Unsupported DWARF Tags");
     for (LVTagOffsetsMap::const_reference Entry : DebugTags) {
-      OS << formatv("\n{0:x+2}", (unsigned)Entry.first) << ", "
+      OS << formatv("\n{0:x2}", (unsigned)Entry.first) << ", "
          << dwarf::TagString(Entry.first) << "\n";
       unsigned Count = 0;
       for (const LVOffset &Offset : Entry.second)
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index e5fb9c4b4fef9..1eba56e87453f 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -422,6 +422,7 @@ TEST(FormatAndFormatvTest, EquivalentHexFormatting) {
 
   EXPECT_EQ("0x000000fe", printToString(format("0x%8.8" PRIx64, 0xfeULL)));
   EXPECT_EQ("0x000000fe", formatv("{0:x+8}", 0xfeULL).str());
+  EXPECT_EQ("0x000000fe", formatv("{0:x8}", 0xfeULL).str());
 
   EXPECT_EQ("000000fe", printToString(format("%08" PRIx64, 0xfeULL)));
   EXPECT_EQ("000000fe", formatv("{0:x-8}", 0xfeULL).str());
@@ -451,6 +452,8 @@ TEST(FormatAndFormatvTest, Alignment) {
 
   EXPECT_EQ("  123", printToString(format("%5u", 123)));
   EXPECT_EQ("  123", formatv("{0,5:d}", 123).str());
+  EXPECT_EQ("  123",
+            formatv("{0}", fmt_align(123, AlignStyle::Right, 5)).str());
 
   EXPECT_EQ("001", printToString(format("%03d", 1)));
   EXPECT_EQ("001", formatv("{0,0+3}", 1).str());



More information about the llvm-commits mailing list