[llvm] [AsmPrinter][DebugNames] Implement DW_IDX_parent entries (PR #77457)

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 10:54:02 PST 2024


================
@@ -395,36 +401,83 @@ void Dwarf5AccelTableWriter::Header::emit(Dwarf5AccelTableWriter &Ctx) {
   Asm->OutStreamer->emitBytes({AugmentationString, AugmentationStringSize});
 }
 
-static uint32_t constexpr LowerBitSize = dwarf::DW_IDX_type_hash;
+enum IdxParentEncoding : uint8_t {
+  NoIndexedParent = 0, // Parent information present but parent isn't indexed.
+  Ref4 = 1,            // Parent information present and parent is indexed.
+  NoParent = 2,        // Parent information missing.
+};
+
+static uint32_t constexpr NumBitsIdxParent = 2;
+
+uint8_t encodeIdxParent(std::optional<dwarf::Form> MaybeParentForm) {
+  if (!MaybeParentForm)
+    return NoParent;
+  switch (*MaybeParentForm) {
+  case dwarf::Form::DW_FORM_flag_present:
+    return NoIndexedParent;
+  case dwarf::Form::DW_FORM_ref4:
+    return Ref4;
+  default:
+    break;
+  }
+  // This is not crashing on bad input: we should only reach this if the
+  // internal compiler logic is faulty; see getFormForIdxParent.
+  llvm_unreachable("Bad form for IDX_parent");
----------------
adrian-prantl wrote:

Out of curiosity, could this be moved in the place of the `break`?

https://github.com/llvm/llvm-project/pull/77457


More information about the llvm-commits mailing list