https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121424

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I found one location where we don't set the location on the debug statements:
```
diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc
index 3499b7f5829..bc859761516 100644
--- a/gcc/tree-into-ssa.cc
+++ b/gcc/tree-into-ssa.cc
@@ -1370,6 +1370,7 @@ rewrite_stmt (gimple_stmt_iterator *si)
          }
     }

+  location_t loc = gimple_location (stmt);
   /* Step 2.  Register the statement's DEF operands.  */
   if (register_defs_p (stmt))
     FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_ALL_DEFS)
@@ -1405,6 +1406,7 @@ rewrite_stmt (gimple_stmt_iterator *si)
        if (tracked_var)
          {
            gimple *note = gimple_build_debug_bind (tracked_var, name, stmt);
+           gimple_set_location (note, loc);
            gsi_insert_after (si, note, GSI_SAME_STMT);
          }
       }

```

But I am not 100% sure this will improve things.

I should note clang/LLVM does NOT duplicate the ret instruction at any
optimization level so it does not expose this oddity.

Reply via email to