llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-lldb

Author: None (Sterling-Augustine)

<details>
<summary>Changes</summary>

…145081)"

This reverts commit cbf781f0bdf2f680abbe784faedeefd6f84c246e.

Breaks a couple of buildbots.

---

Patch is 96.13 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/145959.diff


54 Files Affected:

- (modified) bolt/include/bolt/Core/DIEBuilder.h (+1-1) 
- (modified) bolt/lib/Core/CMakeLists.txt (-1) 
- (modified) bolt/lib/Core/DIEBuilder.cpp (+1-1) 
- (modified) bolt/lib/Core/DebugNames.cpp (+1-1) 
- (modified) bolt/lib/Rewrite/CMakeLists.txt (-1) 
- (modified) bolt/lib/Rewrite/DWARFRewriter.cpp (+1-1) 
- (modified) lldb/source/Expression/DWARFExpression.cpp (+2-3) 
- (modified) lldb/source/Symbol/UnwindPlan.cpp (+3-3) 
- (modified) lldb/unittests/Symbol/PostfixExpressionTest.cpp (+2-3) 
- (modified) 
lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp 
(+2-3) 
- (modified) llvm/include/llvm/DWARFLinker/AddressesMap.h (+1-1) 
- (modified) llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h (+1-1) 
- (modified) llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h (+1-1) 
- (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h (+1-1) 
- (renamed) llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h (+4-146) 
- (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h (+1-1) 
- (renamed) llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractorSimple.h () 
- (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h (+2-2) 
- (renamed) llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h (+62-1) 
- (removed) llvm/include/llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h (-66) 
- (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h (+1-1) 
- (modified) llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt (-1) 
- (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-1) 
- (modified) llvm/lib/DWARFLinker/Classic/CMakeLists.txt (-1) 
- (modified) llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp (+1-1) 
- (modified) llvm/lib/DWARFLinker/Classic/DWARFLinkerCompileUnit.cpp (+1-1) 
- (modified) llvm/lib/DebugInfo/DWARF/CMakeLists.txt (+2-4) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp (+3-3) 
- (renamed) llvm/lib/DebugInfo/DWARF/DWARFCFIProgram.cpp (+146-2) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (+3-4) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp (+2-3) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+2-3) 
- (added) llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp (+538) 
- (removed) llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp (-311) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp (+1-1) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp (+1-1) 
- (removed) llvm/lib/DebugInfo/DWARF/LowLevel/CMakeLists.txt (-14) 
- (removed) llvm/lib/DebugInfo/DWARF/LowLevel/DWARFExpression.cpp (-253) 
- (modified) llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp (+3-3) 
- (modified) llvm/lib/ProfileData/CMakeLists.txt (-1) 
- (modified) llvm/lib/ProfileData/InstrProfCorrelator.cpp (+1-1) 
- (modified) llvm/tools/dsymutil/CMakeLists.txt (-1) 
- (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.cpp (+1-1) 
- (modified) llvm/tools/llvm-dwarfdump/CMakeLists.txt (-1) 
- (modified) llvm/tools/llvm-dwarfdump/Statistics.cpp (+1-1) 
- (modified) llvm/tools/llvm-dwarfutil/CMakeLists.txt (-1) 
- (modified) llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp (+1-1) 
- (modified) llvm/tools/llvm-objdump/CMakeLists.txt (-1) 
- (modified) llvm/tools/llvm-objdump/SourcePrinter.cpp (+2-3) 
- (modified) llvm/unittests/DebugInfo/DWARF/CMakeLists.txt (-1) 
- (modified) 
llvm/unittests/DebugInfo/DWARF/DWARFExpressionCompactPrinterTest.cpp (+2-3) 
- (modified) llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp 
(+1-1) 
- (modified) utils/bazel/llvm-project-overlay/bolt/BUILD.bazel (-2) 
- (modified) utils/bazel/llvm-project-overlay/llvm/BUILD.bazel (-24) 


``````````diff
diff --git a/bolt/include/bolt/Core/DIEBuilder.h 
b/bolt/include/bolt/Core/DIEBuilder.h
index e4a4fc6b2f258..32e455ad3030a 100644
--- a/bolt/include/bolt/Core/DIEBuilder.h
+++ b/bolt/include/bolt/Core/DIEBuilder.h
@@ -20,8 +20,8 @@
 #include "llvm/CodeGen/DIE.h"
 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
 #include "llvm/Support/Allocator.h"
 
 #include <list>
diff --git a/bolt/lib/Core/CMakeLists.txt b/bolt/lib/Core/CMakeLists.txt
index fc72dc023c590..8c1f5d0bb37b5 100644
--- a/bolt/lib/Core/CMakeLists.txt
+++ b/bolt/lib/Core/CMakeLists.txt
@@ -1,6 +1,5 @@
 set(LLVM_LINK_COMPONENTS
   DebugInfoDWARF
-  DebugInfoDWARFLowLevel
   Demangle
   MC
   MCDisassembler
diff --git a/bolt/lib/Core/DIEBuilder.cpp b/bolt/lib/Core/DIEBuilder.cpp
index b041dc5ea1cce..d36dbb3459249 100644
--- a/bolt/lib/Core/DIEBuilder.cpp
+++ b/bolt/lib/Core/DIEBuilder.cpp
@@ -14,11 +14,11 @@
 #include "llvm/CodeGen/DIE.h"
 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
 #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
diff --git a/bolt/lib/Core/DebugNames.cpp b/bolt/lib/Core/DebugNames.cpp
index a9d98a6ba879b..aa1c8f3d42d4b 100644
--- a/bolt/lib/Core/DebugNames.cpp
+++ b/bolt/lib/Core/DebugNames.cpp
@@ -8,8 +8,8 @@
 
 #include "bolt/Core/DebugNames.h"
 #include "bolt/Core/BinaryContext.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/LEB128.h"
 #include <cstdint>
diff --git a/bolt/lib/Rewrite/CMakeLists.txt b/bolt/lib/Rewrite/CMakeLists.txt
index 775036063dd5a..c83cf36982167 100644
--- a/bolt/lib/Rewrite/CMakeLists.txt
+++ b/bolt/lib/Rewrite/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Core
   DebugInfoDWARF
-  DebugInfoDWARFLowLevel
   JITLink
   MC
   Object
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp 
b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 0c1a1bac6c72e..9c9bdefe08429 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -24,10 +24,10 @@
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
 #include "llvm/MC/MCAsmBackend.h"
 #include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCObjectWriter.h"
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 2df27513a0b3f..661324338e801 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -36,8 +36,7 @@
 #include "lldb/Target/StackID.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
-#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -82,7 +81,7 @@ void DWARFExpression::DumpLocation(Stream *s, 
lldb::DescriptionLevel level,
   llvm::DIDumpOptions DumpOpts;
   DumpOpts.GetNameForDWARFReg = GetRegName;
   llvm::DWARFExpression E(m_data.GetAsLLVM(), m_data.GetAddressByteSize());
-  llvm::printDwarfExpression(&E, s->AsRawOstream(), DumpOpts, nullptr);
+  llvm::DWARFExpressionPrinter::print(&E, s->AsRawOstream(), DumpOpts, 
nullptr);
 }
 
 RegisterKind DWARFExpression::GetRegisterKind() const { return m_reg_kind; }
diff --git a/lldb/source/Symbol/UnwindPlan.cpp 
b/lldb/source/Symbol/UnwindPlan.cpp
index 9245e52732061..e9ac6b6cde295 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -17,8 +17,7 @@
 #include "lldb/Utility/Log.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/DebugInfo/DIContext.h"
-#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include <optional>
 
 using namespace lldb;
@@ -90,7 +89,8 @@ static void DumpDWARFExpr(Stream &s, llvm::ArrayRef<uint8_t> 
expr, Thread *threa
                              order_and_width->second);
     llvm::DWARFExpression E(data, order_and_width->second,
                             llvm::dwarf::DWARF32);
-    printDwarfExpression(&E, s.AsRawOstream(), llvm::DIDumpOptions(), nullptr);
+    llvm::DWARFExpressionPrinter::print(&E, s.AsRawOstream(),
+                                        llvm::DIDumpOptions(), nullptr);
   } else
     s.PutCString("dwarf-expr");
 }
diff --git a/lldb/unittests/Symbol/PostfixExpressionTest.cpp 
b/lldb/unittests/Symbol/PostfixExpressionTest.cpp
index f60b5d2c389ed..1e437da5133d9 100644
--- a/lldb/unittests/Symbol/PostfixExpressionTest.cpp
+++ b/lldb/unittests/Symbol/PostfixExpressionTest.cpp
@@ -11,8 +11,7 @@
 #include "lldb/Utility/StreamString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/DebugInfo/DIContext.h"
-#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
@@ -161,7 +160,7 @@ static std::string ParseAndGenerateDWARF(llvm::StringRef 
expr) {
   std::string result;
   llvm::raw_string_ostream os(result);
   llvm::DWARFExpression E(extractor, addr_size, llvm::dwarf::DWARF32);
-  llvm::printDwarfExpression(&E, os, llvm::DIDumpOptions(), nullptr);
+  llvm::DWARFExpressionPrinter::print(&E, os, llvm::DIDumpOptions(), nullptr);
   return result;
 }
 
diff --git 
a/lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp 
b/lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp
index c60688ef22939..d746e04f8a9fc 100644
--- 
a/lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp
+++ 
b/lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp
@@ -16,8 +16,7 @@
 #include "lldb/Utility/StreamBuffer.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/DebugInfo/DIContext.h"
-#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -41,7 +40,7 @@ CheckValidProgramTranslation(llvm::StringRef fpo_program,
   std::string result;
   llvm::raw_string_ostream os(result);
   llvm::DWARFExpression E(extractor, /*AddressSize=*/4, llvm::dwarf::DWARF32);
-  llvm::printDwarfExpression(&E, os, llvm::DIDumpOptions(), nullptr);
+  llvm::DWARFExpressionPrinter::print(&E, os, llvm::DIDumpOptions(), nullptr);
 
   // actual check
   ASSERT_EQ(expected_dwarf_expression, result);
diff --git a/llvm/include/llvm/DWARFLinker/AddressesMap.h 
b/llvm/include/llvm/DWARFLinker/AddressesMap.h
index e2215c70dc34e..a232aafadc5ce 100644
--- a/llvm/include/llvm/DWARFLinker/AddressesMap.h
+++ b/llvm/include/llvm/DWARFLinker/AddressesMap.h
@@ -12,8 +12,8 @@
 #include "llvm/ADT/AddressRanges.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
 #include <cstdint>
 
 namespace llvm {
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h 
b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
index 5b9535380aebf..b12d96812108e 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
@@ -20,7 +20,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/Support/Compiler.h"
 #include <map>
 
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h 
b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
index 99aeb0df076e6..17a18c4b029f4 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
@@ -16,7 +16,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/Support/Compiler.h"
 #include <map>
 namespace llvm {
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h
index 7d4bf8d923097..4723f00a4d241 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_DEBUGINFO_DWARF_DWARFCFIPRINTER_H
 #define LLVM_DEBUGINFO_DWARF_DWARFCFIPRINTER_H
 
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFCFIProgram.h"
+#include "llvm/DebugInfo/DWARF/DWARFCFIProgram.h"
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
diff --git a/llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFCFIProgram.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h
similarity index 50%
rename from llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFCFIProgram.h
rename to llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h
index bdad0b5ad7a5a..1d89ac3578c10 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFCFIProgram.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h
@@ -12,8 +12,8 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/iterator.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/TargetParser/Triple.h"
@@ -78,150 +78,8 @@ class CFIProgram {
   /// starting at *Offset and ending at EndOffset. *Offset is updated
   /// to EndOffset upon successful parsing, or indicates the offset
   /// where a problem occurred in case an error is returned.
-  template <typename T>
-  LLVM_ABI Error parse(DWARFDataExtractorBase<T> &Data, uint64_t *Offset,
-                       uint64_t EndOffset) {
-    // See DWARF standard v3, section 7.23
-    const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0;
-    const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f;
-
-    DataExtractor::Cursor C(*Offset);
-    while (C && C.tell() < EndOffset) {
-      uint8_t Opcode = Data.getRelocatedValue(C, 1);
-      if (!C)
-        break;
-
-      // Some instructions have a primary opcode encoded in the top bits.
-      if (uint8_t Primary = Opcode & DWARF_CFI_PRIMARY_OPCODE_MASK) {
-        // If it's a primary opcode, the first operand is encoded in the
-        // bottom bits of the opcode itself.
-        uint64_t Op1 = Opcode & DWARF_CFI_PRIMARY_OPERAND_MASK;
-        switch (Primary) {
-        case DW_CFA_advance_loc:
-        case DW_CFA_restore:
-          addInstruction(Primary, Op1);
-          break;
-        case DW_CFA_offset:
-          addInstruction(Primary, Op1, Data.getULEB128(C));
-          break;
-        default:
-          llvm_unreachable("invalid primary CFI opcode");
-        }
-        continue;
-      }
-
-      // Extended opcode - its value is Opcode itself.
-      switch (Opcode) {
-      default:
-        return createStringError(errc::illegal_byte_sequence,
-                                 "invalid extended CFI opcode 0x%" PRIx8,
-                                 Opcode);
-      case DW_CFA_nop:
-      case DW_CFA_remember_state:
-      case DW_CFA_restore_state:
-      case DW_CFA_GNU_window_save:
-      case DW_CFA_AARCH64_negate_ra_state_with_pc:
-        // No operands
-        addInstruction(Opcode);
-        break;
-      case DW_CFA_set_loc:
-        // Operands: Address
-        addInstruction(Opcode, Data.getRelocatedAddress(C));
-        break;
-      case DW_CFA_advance_loc1:
-        // Operands: 1-byte delta
-        addInstruction(Opcode, Data.getRelocatedValue(C, 1));
-        break;
-      case DW_CFA_advance_loc2:
-        // Operands: 2-byte delta
-        addInstruction(Opcode, Data.getRelocatedValue(C, 2));
-        break;
-      case DW_CFA_advance_loc4:
-        // Operands: 4-byte delta
-        addInstruction(Opcode, Data.getRelocatedValue(C, 4));
-        break;
-      case DW_CFA_restore_extended:
-      case DW_CFA_undefined:
-      case DW_CFA_same_value:
-      case DW_CFA_def_cfa_register:
-      case DW_CFA_def_cfa_offset:
-      case DW_CFA_GNU_args_size:
-        // Operands: ULEB128
-        addInstruction(Opcode, Data.getULEB128(C));
-        break;
-      case DW_CFA_def_cfa_offset_sf:
-        // Operands: SLEB128
-        addInstruction(Opcode, Data.getSLEB128(C));
-        break;
-      case DW_CFA_LLVM_def_aspace_cfa:
-      case DW_CFA_LLVM_def_aspace_cfa_sf: {
-        auto RegNum = Data.getULEB128(C);
-        auto CfaOffset = Opcode == DW_CFA_LLVM_def_aspace_cfa
-                             ? Data.getULEB128(C)
-                             : Data.getSLEB128(C);
-        auto AddressSpace = Data.getULEB128(C);
-        addInstruction(Opcode, RegNum, CfaOffset, AddressSpace);
-        break;
-      }
-      case DW_CFA_offset_extended:
-      case DW_CFA_register:
-      case DW_CFA_def_cfa:
-      case DW_CFA_val_offset: {
-        // Operands: ULEB128, ULEB128
-        // Note: We can not embed getULEB128 directly into function
-        // argument list. getULEB128 changes Offset and order of evaluation
-        // for arguments is unspecified.
-        uint64_t op1 = Data.getULEB128(C);
-        uint64_t op2 = Data.getULEB128(C);
-        addInstruction(Opcode, op1, op2);
-        break;
-      }
-      case DW_CFA_offset_extended_sf:
-      case DW_CFA_def_cfa_sf:
-      case DW_CFA_val_offset_sf: {
-        // Operands: ULEB128, SLEB128
-        // Note: see comment for the previous case
-        uint64_t op1 = Data.getULEB128(C);
-        uint64_t op2 = (uint64_t)Data.getSLEB128(C);
-        addInstruction(Opcode, op1, op2);
-        break;
-      }
-      case DW_CFA_def_cfa_expression: {
-        uint64_t ExprLength = Data.getULEB128(C);
-        addInstruction(Opcode, 0);
-        StringRef Expression = Data.getBytes(C, ExprLength);
-
-        DataExtractor Extractor(Expression, Data.isLittleEndian(),
-                                Data.getAddressSize());
-        // Note. We do not pass the DWARF format to DWARFExpression, because
-        // DW_OP_call_ref, the only operation which depends on the format, is
-        // prohibited in call frame instructions, see sec. 6.4.2 in DWARFv5.
-        Instructions.back().Expression =
-            DWARFExpression(Extractor, Data.getAddressSize());
-        break;
-      }
-      case DW_CFA_expression:
-      case DW_CFA_val_expression: {
-        uint64_t RegNum = Data.getULEB128(C);
-        addInstruction(Opcode, RegNum, 0);
-
-        uint64_t BlockLength = Data.getULEB128(C);
-        StringRef Expression = Data.getBytes(C, BlockLength);
-        DataExtractor Extractor(Expression, Data.isLittleEndian(),
-                                Data.getAddressSize());
-        // Note. We do not pass the DWARF format to DWARFExpression, because
-        // DW_OP_call_ref, the only operation which depends on the format, is
-        // prohibited in call frame instructions, see sec. 6.4.2 in DWARFv5.
-        Instructions.back().Expression =
-            DWARFExpression(Extractor, Data.getAddressSize());
-        break;
-      }
-      }
-    }
-
-    *Offset = C.tell();
-    return C.takeError();
-  }
+  LLVM_ABI Error parse(DWARFDataExtractor Data, uint64_t *Offset,
+                       uint64_t EndOffset);
 
   void addInstruction(const Instruction &I) { Instructions.push_back(I); }
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
index def291046c7db..005ccd208cdda 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
@@ -10,10 +10,10 @@
 #define LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
 
 #include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractorSimple.h"
 #include "llvm/DebugInfo/DWARF/DWARFObject.h"
 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
 #include "llvm/DebugInfo/DWARF/DWARFSection.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h"
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
diff --git 
a/llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractorSimple.h
similarity index 100%
rename from 
llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h
rename to llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractorSimple.h
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
index e0d60f605964f..3b367009a379d 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
@@ -12,8 +12,8 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/iterator.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFCFIProgram.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/DWARFCFIProgram.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/TargetParser/Triple.h"
diff --git a/llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
similarity index 67%
rename from llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h
rename to llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
index 06840b20f9690..ea414278c35d6 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
@@ -65,7 +65,7 @@ class DWARFExpression {
 
     /// Description of the encoding of one expression Op.
     struct Description {
-      DwarfVersion Version;     ///< Dwarf version where the Op was introduced.
+      DwarfVersion Version; ///< Dwarf version where the Op was introduced.
       SmallVector<Encoding> Op; ///< Encoding for Op operands.
 
       template <typename... Ts>
@@ -77,6 +77,7 @@ class DWARFExpression {
 
   private:
     friend class DWARFExpression::iterator;
+    friend class DWARFExpressionPrinter;
     friend class DWARFVerifier;
 
     uint8_t Opcode; ///< The Op Opcode, DW_OP_<something>.
@@ -155,6 +156,7 @@ class DWARFExpression {
 
   StringRef getData() const { return Data.getData(); }
 
+  friend class DWARFExpressionPrinter;
   friend class DWARFVerifier;
 
 private:
@@ -168,6 +170,65 @@ inline bool operator==(const DWARFExpression::iterator 
&LHS,
   return LHS.Expr == RHS.Expr && LHS.Offset == RHS.Offset;
 }
 
+// This functionality is separated from the main data structure so that nothing
+// in DWARFExpression.cpp needs build-time dependencies on DWARFUnit or other
+// higher-level Dwarf structures. This approach creates better layering and
+// allows DWARFExpression to be used from code which can't have dependencies on
+// those higher-level structures.
+
+class DWARFUnit;
+struct DIDumpOptions;
+class raw_o...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/145959
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to