[llvm] 4e10a18 - [DebugInfo] Make DIELocList::SizeOf() more explicit. NFCI.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 01:05:05 PDT 2020


Author: Igor Kudrin
Date: 2020-08-03T15:03:37+07:00
New Revision: 4e10a18972a4569fe6b13e60becb44514b35c52e

URL: https://github.com/llvm/llvm-project/commit/4e10a18972a4569fe6b13e60becb44514b35c52e
DIFF: https://github.com/llvm/llvm-project/commit/4e10a18972a4569fe6b13e60becb44514b35c52e.diff

LOG: [DebugInfo] Make DIELocList::SizeOf() more explicit. NFCI.

DIELocList is used with a limited number of DWARF forms, see the only
place where it is instantiated, DwarfCompileUnit::addLocationList().

The patch marks the unexpected execution path in DIELocList::SizeOf()
as unreachable, to reduce ambiguity.

Differential Revision: https://reviews.llvm.org/D84092

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DIE.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
index 713a15dd0939..03219637f216 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -809,13 +809,17 @@ void DIEBlock::print(raw_ostream &O) const {
 //===----------------------------------------------------------------------===//
 
 unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
-  if (Form == dwarf::DW_FORM_loclistx)
+  switch (Form) {
+  case dwarf::DW_FORM_loclistx:
     return getULEB128Size(Index);
-  if (Form == dwarf::DW_FORM_data4)
+  case dwarf::DW_FORM_data4:
     return 4;
-  if (Form == dwarf::DW_FORM_sec_offset)
+  case dwarf::DW_FORM_sec_offset:
+    // FIXME: add support for DWARF64
     return 4;
-  return AP->MAI->getCodePointerSize();
+  default:
+    llvm_unreachable("DIE Value form not supported yet");
+  }
 }
 
 /// EmitValue - Emit label value.


        


More information about the llvm-commits mailing list