Bug 42800 - [4.5 Regression] VLA DW_AT_upper_bound is no longer emitted
Summary: [4.5 Regression] VLA DW_AT_upper_bound is no longer emitted
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P1 normal
Target Milestone: 4.5.0
Assignee: Jason Merrill
URL:
Keywords: patch, wrong-debug
Depends on:
Blocks: 42801
  Show dependency treegraph
 
Reported: 2010-01-19 10:05 UTC by Jan Kratochvil
Modified: 2010-02-23 18:32 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-02-19 18:01:22


Attachments
patch (1.19 KB, patch)
2010-02-20 05:16 UTC, Jason Merrill
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-01-19 10:05:16 UTC
FAIL: gcc (GCC) 4.5.0 20100119 (experimental)
PASS: gcc (GCC) 4.4.3 20100119 (prerelease)
PASS: gcc-4.4.2-20.fc12.x86_64 (Fedora 12)
-------------------------------------------------------------------------------
gcc -c -o vla.o vla.c -Wall -g
-------------------------------------------------------------------------------
This is a 4.4 -> 4.5 debug regression.
-------------------------------------------------------------------------------
int
f (int i)
{
  char a[i];

  return a[0];
}
-------------------------------------------------------------------------------
FAIL:
    < c>   DW_AT_producer    : (indirect string, offset: 0x11): GNU C 4.5.0 20100119 (experimental)	
 <2><5c>: Abbrev Number: 4 (DW_TAG_variable)
    <5d>   DW_AT_name        : a	
    <61>   DW_AT_type        : <0x71>	
    <65>   DW_AT_location    : 3 byte block: 91 60 6 	(DW_OP_fbreg: -32; DW_OP_deref)
 <1><71>: Abbrev Number: 6 (DW_TAG_array_type)
    <72>   DW_AT_type        : <0x83>	
 <2><7a>: Abbrev Number: 7 (DW_TAG_subrange_type)
    <7b>   DW_AT_type        : <0x80>	
-------------------------------------------------------------------------------
PASS:
    < c>   DW_AT_producer    : (indirect string, offset: 0x17): GNU C 4.4.3 20100119 (prerelease)	
 <2><5c>: Abbrev Number: 4 (DW_TAG_variable)
    <5d>   DW_AT_name        : a	
    <61>   DW_AT_type        : <0x71>	
    <65>   DW_AT_location    : 3 byte block: 91 68 6 	(DW_OP_fbreg: -24; DW_OP_deref)
 <1><71>: Abbrev Number: 6 (DW_TAG_array_type)
    <72>   DW_AT_type        : <0x87>	
 <2><7a>: Abbrev Number: 7 (DW_TAG_subrange_type)
    <7b>   DW_AT_type        : <0x84>	
    <7f>   DW_AT_upper_bound : 3 byte block: 91 60 6 	(DW_OP_fbreg: -32; DW_OP_deref)
Comment 1 H.J. Lu 2010-01-19 15:43:55 UTC
It is caused by Expand from SSA:

http://gcc.gnu.org/ml/gcc-cvs/2009-04/msg01459.html
Comment 2 Michael Matz 2010-01-19 15:49:03 UTC
What's the brokenness?  The missing upper bound in the subrange type?
Comment 3 H.J. Lu 2010-01-19 15:52:53 UTC
(In reply to comment #2)
> What's the brokenness?  The missing upper bound in the subrange type?
> 

It blocks PR 42801.
Comment 4 Jakub Jelinek 2010-01-19 17:19:24 UTC
Yes.  This is -O0, so we definitely should ensure that the debug info has the correct upper bound.
Look at gimplify_type_sizes which for -O0 clears DECL_IGNORED_P on the temporaries to make sure they are not optimized out.  That worked well in 4.4, but probably doesn't work any longer.
Comment 5 Jason Merrill 2010-02-19 20:13:35 UTC
The problem is that instantiate_decl_rtl isn't being run on the rtl for the upper bound temporary, because it isn't visible to instantiate_decls.  This happens because even though the temp got added to cfun->local_decls, expand_used_vars clears it out before instantiate_decls gets a chance to look at it.
Comment 6 Jason Merrill 2010-02-19 20:59:13 UTC
Yeah, the Expand from SSA patch broke Jakub's fix for PR 34037.  I'm testing a patch that just tweaks the logic a bit to make it work again.
Comment 7 Jason Merrill 2010-02-20 05:16:35 UTC
Created attachment 19929 [details]
patch
Comment 8 Jason Merrill 2010-02-23 18:32:37 UTC
Fixed.
Comment 9 Jason Merrill 2010-02-23 18:32:44 UTC
Subject: Bug 42800

Author: jason
Date: Tue Feb 23 18:32:09 2010
New Revision: 157014

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157014
Log:
	PR debug/42800
	* cfgexpand.c (expand_used_vars): Keep artificial non-ignored vars
	in cfun->local_decls even if they have register types.

Added:
    trunk/gcc/testsuite/c-c++-common/dwarf2/
    trunk/gcc/testsuite/c-c++-common/dwarf2/vla1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgexpand.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp
    trunk/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp