[PATCH] D23167: emit_DW_AT_noreturn flag

Victor via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 09:10:19 PDT 2016


vleschuk created this revision.
vleschuk added a reviewer: asl.
vleschuk added a subscriber: llvm-commits.

Support for DW_AT_noreturn DWARF flag. Add it to debug info in case function is C++11 [[ noreturn ]] or C11 _Noreturn.

PS Corresponding clang patch is following

https://reviews.llvm.org/D23167

Files:
  include/llvm/IR/DebugInfoFlags.def
  include/llvm/IR/DebugInfoMetadata.h
  include/llvm/Support/Dwarf.h
  lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  lib/Support/Dwarf.cpp
  unittests/IR/DebugInfoTest.cpp

Index: unittests/IR/DebugInfoTest.cpp
===================================================================
--- unittests/IR/DebugInfoTest.cpp
+++ unittests/IR/DebugInfoTest.cpp
@@ -73,8 +73,9 @@
   CHECK_SPLIT(DINode::FlagRValueReference, {DINode::FlagRValueReference}, 0u);
   unsigned Flags[] = {DINode::FlagFwdDecl, DINode::FlagVector};
   CHECK_SPLIT(DINode::FlagFwdDecl | DINode::FlagVector, Flags, 0u);
-  CHECK_SPLIT(0x100000u, {}, 0x100000u);
-  CHECK_SPLIT(0x100000u | DINode::FlagVector, {DINode::FlagVector}, 0x100000u);
+  CHECK_SPLIT(0x200000u, {}, 0x200000u);
+  CHECK_SPLIT(0x200000u | DINode::FlagVector, {DINode::FlagVector}, 0x200000u);
+  CHECK_SPLIT(0x200000u | DINode::FlagNoReturn, {DINode::FlagNoReturn}, 0x200000u);
 #undef CHECK_SPLIT
 }
 
Index: lib/Support/Dwarf.cpp
===================================================================
--- lib/Support/Dwarf.cpp
+++ lib/Support/Dwarf.cpp
@@ -147,6 +147,7 @@
   case DW_AT_dwo_name:                   return "DW_AT_dwo_name";
   case DW_AT_reference:                  return "DW_AT_reference";
   case DW_AT_rvalue_reference:           return "DW_AT_rvalue_reference";
+  case DW_AT_noreturn:                   return "DW_AT_noreturn";
   case DW_AT_MIPS_loop_begin:            return "DW_AT_MIPS_loop_begin";
   case DW_AT_MIPS_tail_loop_begin:       return "DW_AT_MIPS_tail_loop_begin";
   case DW_AT_MIPS_epilog_begin:          return "DW_AT_MIPS_epilog_begin";
Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1248,6 +1248,9 @@
   if (SP->isRValueReference())
     addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
 
+  if (SP->isNoReturn())
+    addFlag(SPDie, dwarf::DW_AT_noreturn);
+
   if (SP->isProtected())
     addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
             dwarf::DW_ACCESS_protected);
Index: include/llvm/Support/Dwarf.h
===================================================================
--- include/llvm/Support/Dwarf.h
+++ include/llvm/Support/Dwarf.h
@@ -197,6 +197,7 @@
   DW_AT_reference = 0x77,
   DW_AT_rvalue_reference = 0x78,
   DW_AT_macros = 0x79,
+  DW_AT_noreturn = 0x87,
 
   DW_AT_lo_user = 0x2000,
   DW_AT_hi_user = 0x3fff,
Index: include/llvm/IR/DebugInfoMetadata.h
===================================================================
--- include/llvm/IR/DebugInfoMetadata.h
+++ include/llvm/IR/DebugInfoMetadata.h
@@ -1419,6 +1419,13 @@
     return getFlags() & FlagRValueReference;
   }
 
+  /// \brief Check if this is marked as noreturn
+  ///
+  /// Return true if this subprogram is C++11 noreturn or C11 _Noreturn
+  unsigned isNoReturn() const {
+    return getFlags() & FlagNoReturn;
+  }
+
   DIScopeRef getScope() const { return DIScopeRef(getRawScope()); }
 
   StringRef getName() const { return getStringOperand(2); }
Index: include/llvm/IR/DebugInfoFlags.def
===================================================================
--- include/llvm/IR/DebugInfoFlags.def
+++ include/llvm/IR/DebugInfoFlags.def
@@ -38,5 +38,6 @@
 HANDLE_DI_FLAG((3 << 16), VirtualInheritance)
 HANDLE_DI_FLAG((1 << 18), IntroducedVirtual)
 HANDLE_DI_FLAG((1 << 19), BitField)
+HANDLE_DI_FLAG((1 << 20), NoReturn)
 
 #undef HANDLE_DI_FLAG


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23167.66814.patch
Type: text/x-patch
Size: 3313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160804/0fab8f0e/attachment.bin>


More information about the llvm-commits mailing list