https://gcc.gnu.org/g:552d2bf8ae215a5393cc0d0877bc1f6507d64d68

commit r17-6612-g552d2bf8ae215a5393cc0d0877bc1f6507d64d68
Author: Oleg Tolmatcev <[email protected]>
Date:   Mon Nov 23 11:50:45 2026 -0700

    [PATCH] codeview: Handle functions inlined by optimizer
    
    codeview_abstract_function ignored functions that were not declared
    inline, even when the optimizer inlined them.  This left
    inlinee_lines_htab null while write_binary_annotations tried to query it,
    causing an ICE.
    
    Record every abstract inlined function and guard the annotation lookup
    when the table is unavailable.
    
    gcc/
            * dwarf2codeview.cc (write_binary_annotations): Return if the 
inlinee
            lines hash table is unavailable.
            (codeview_abstract_function): Record functions inlined by the 
optimizer.
    
    gcc/testsuite/
            * g++.dg/debug/codeview/inline-nondeclared-1.C: New test.
    
    Signed-off-by: Oleg Tolmatcev <[email protected]>

Diff:
---
 gcc/dwarf2codeview.cc                                  |  6 +++---
 .../g++.dg/debug/codeview/inline-nondeclared-1.C       | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index 45c74f879c0d..2252b32d917d 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -3471,6 +3471,9 @@ write_binary_annotations (codeview_function *line_func, 
uint32_t func_id)
   codeview_function *top_parent;
   unsigned int line_no, label_num;
 
+  if (!inlinee_lines_htab)
+    return;
+
   slot = inlinee_lines_htab->find_slot_with_hash (func_id, func_id, NO_INSERT);
   if (!slot || !*slot)
     return;
@@ -7292,9 +7295,6 @@ codeview_abstract_function (tree decl)
   uint32_t func_id;
   struct dwarf_file_data *file;
 
-  if (!DECL_DECLARED_INLINE_P (decl))
-    return;
-
   die = lookup_decl_die (decl);
   if (!die)
     return;
diff --git a/gcc/testsuite/g++.dg/debug/codeview/inline-nondeclared-1.C 
b/gcc/testsuite/g++.dg/debug/codeview/inline-nondeclared-1.C
new file mode 100644
index 000000000000..da08dc4275fd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/codeview/inline-nondeclared-1.C
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-options "-O3 -gcodeview -Wno-attributes" }
+// { dg-final { scan-assembler "Lcv_inlineelines_start" } }
+
+// codeview_abstract_function must record functions inlined by the optimizer,
+// even if they were not declared inline.
+
+__attribute__ ((always_inline)) static int
+callee (int i)
+{
+  return i + 1;
+}
+
+int
+caller (int i)
+{
+  return callee (i);
+}

Reply via email to