[llvm] 414b9be - [DebugInfo] Make DIEDelta::SizeOf() more explicit. NFCI.

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


Author: Igor Kudrin
Date: 2020-08-03T15:04:15+07:00
New Revision: 414b9bec6deb542f7ca729585b1e592cac8ccb30

URL: https://github.com/llvm/llvm-project/commit/414b9bec6deb542f7ca729585b1e592cac8ccb30
DIFF: https://github.com/llvm/llvm-project/commit/414b9bec6deb542f7ca729585b1e592cac8ccb30.diff

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

The patch restricts DIEDelta::SizeOf() to accept only DWARF forms that
are actually used in the LLVM codebase. This should make the use of the
class more explicit and help to avoid issues similar to fixed in D83958
and D84094.

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

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 b041f94de075..0524d666810c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -549,10 +549,15 @@ void DIEDelta::emitValue(const AsmPrinter *AP, dwarf::Form Form) const {
 /// SizeOf - Determine size of delta value in bytes.
 ///
 unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
-  if (Form == dwarf::DW_FORM_data4) return 4;
-  if (Form == dwarf::DW_FORM_sec_offset) return 4;
-  if (Form == dwarf::DW_FORM_strp) return 4;
-  return AP->MAI->getCodePointerSize();
+  switch (Form) {
+  case dwarf::DW_FORM_data4:
+    return 4;
+  case dwarf::DW_FORM_sec_offset:
+    // FIXME: add support for DWARF64
+    return 4;
+  default:
+    llvm_unreachable("DIE Value form not supported yet");
+  }
 }
 
 LLVM_DUMP_METHOD


        


More information about the llvm-commits mailing list