[gcc r13-10464] tree-optimization/124627 - inlining and elided debug stmts

Richard Biener via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:9c3648f74565225a21bdb670c5826897b01aa806

commit r13-10464-g9c3648f74565225a21bdb670c5826897b01aa806
Author: Richard Biener <[email protected]>
Date:   Wed Mar 25 09:40:56 2026 +0100

    tree-optimization/124627 - inlining and elided debug stmts
    
    When we fixup a noreturn call during inlining we can end up eliding
    debug stmts, so we have to make sure to not re-instantiate SSA
    operands on those later when processing all debug stmts.
    
            PR tree-optimization/124627
            * tree-inline.cc (copy_debug_stmts): Only copy debug
            stmts that are still in the IL.
    
    (cherry picked from commit 415a00e0aae8b39ca81debfcdf82f9c53af203e7)

Diff:
---
 gcc/tree-inline.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index f97344b59d18..12465954b309 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -3296,7 +3296,9 @@ copy_debug_stmts (copy_body_data *id)
     return;
 
   for (gdebug *stmt : id->debug_stmts)
-    copy_debug_stmt (stmt, id);
+    /* But avoid re-processing debug stmts that have been elided.  */
+    if (gimple_bb (stmt))
+      copy_debug_stmt (stmt, id);
 
   id->debug_stmts.release ();
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.