[PATCH] Fix PR85020
Richard Biener
rguenther@suse.de
Thu Mar 22 14:23:00 GMT 2018
The following fixes profiledbootstrap with LTO for Ada where we
end up with references to later optimized out decls in the early debug
parts.
The fix is to avoid running into
/* Try harder to get a rtl. If this symbol ends up not being emitted
in the current CU, resolve_addr will remove the expression
referencing
it. */
if (rtl == NULL_RTX
...
rtl = make_decl_rtl_for_debug (decl);
in rtl_for_decl_location as the comment already says the symbol can
end up not being emitted which is fatal for early debug. For now
this is conditionalized on LTO emission.
This should then trigger the use of DW_OP_GNU_variable_value but
for the Ada ACATS testcase I was looking at to debug the issue
(c330001, resp. c330001_0-c330001_1.ads) this doesn't work
because the constraints are not met (we're in global context and
the upper bound decl is global as well). Jakub, do you remember
a reason for having any constraints here? I've reworked the
constraints to allow the globals (eventually using decl_function_context
on this may also allow other not-quite-local cases? But it already
allowed local statics). Maybe we can simply drop the restriction
alltogether?
Bootstrap and regtest running on x86_64-unknown-linux-gnu,
profiledbootstrap with LTO on x86_64-unknown-linux-gnu.
Eric, can you generate a gnat.dg LTO testcase from (reduced) c330001?
OK for trunk?
Thanks,
Richard.
2018-03-22 Richard Biener <rguenther@suse.de>
PR debug/85020
* dwarf2out.c (loc_list_from_tree_1): Relax restriction on
what decls we refer to via DW_OP_GNU_variable_value, respective
allow globals from global context.
(rtl_for_decl_location): Do not generate RTL early when
we are going to emit early debug for LTO.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 258720)
+++ gcc/dwarf2out.c (working copy)
@@ -18204,14 +18204,15 @@ loc_list_from_tree_1 (tree loc, int want
rtl = rtl_for_decl_location (loc);
if (rtl == NULL_RTX)
{
+ tree fn_ctx;
if (TREE_CODE (loc) != FUNCTION_DECL
&& early_dwarf
- && current_function_decl
&& want_address != 1
&& ! DECL_IGNORED_P (loc)
&& (INTEGRAL_TYPE_P (TREE_TYPE (loc))
|| POINTER_TYPE_P (TREE_TYPE (loc)))
- && DECL_CONTEXT (loc) == current_function_decl
+ && (!(fn_ctx = decl_function_context (loc))
+ || fn_ctx == current_function_decl)
&& (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (loc)))
<= DWARF2_ADDR_SIZE))
{
@@ -19878,6 +19879,7 @@ rtl_for_decl_location (tree decl)
in the current CU, resolve_addr will remove the expression referencing
it. */
if (rtl == NULL_RTX
+ && !(early_dwarf && (flag_generate_lto || flag_generate_offload))
&& VAR_P (decl)
&& !DECL_EXTERNAL (decl)
&& TREE_STATIC (decl)
More information about the Gcc-patches
mailing list