On Sun, Jul 1, 2018 at 9:25 PM Tom de Vries <tdevr...@suse.de> wrote: > > On 07/01/2018 09:11 PM, Jakub Jelinek wrote: > > On Sun, Jul 01, 2018 at 06:19:20PM +0200, Tom de Vries wrote: > >> So, the local vla a is optimized away. > >> > >> This patch adds VOLATILE to 'a', which prevents it from being optimized > >> away, > >> and fixes the non-lto failures. > >> > >> Committed as obvious. > > > > That isn't obvious, it is just wrong. > > The intent of the testcase is to test how debugging of optimized code with > > VLAs works. With your change we don't test that anymore. Please revert. > > > > Hi, > > Sure, but ... if this is wrong, then for my understanding can you > explain to me how the fail should be addressed?
Given the array has size i + 1 it's upper bound should be 'i' and 'i' should be available via DW_OP_[GNU_]entry_value. I see it is <175> DW_AT_upper_bound : 10 byte block: 75 1 8 20 24 8 20 26 31 1c (DW_OP_breg5 (rdi): 1; DW_OP_const1u: 32; DW_OP_shl; DW_OP_const1u: 32; DW_OP_shra; DW_OP_lit1; DW_OP_minus) and %rdi is 1. Not sure why gdb fails to print it's length. Yes, the storage itself doesn't have a location but the type specifies the size. (gdb) ptype a type = char [variable length] (gdb) p sizeof(a) $3 = 0 this looks like a gdb bug to me? Btw, the location expression looks odd, if I deciper it correctly we end up with ((%rdi << 32) >> 32) - 1 which computes to 4 but the upper bound should be 5. The GIMPLE debug stmts compute the upper bound as (sizetype)((long)(i_1(D) + 1) - 1) vartrack correctly prints (debug_insn 7 26 8 2 (var_location:SI D#3 (plus:SI (entry_value:SI (reg:SI 5 di [ i ])) (const_int 1 [0x1]))) "/space/rguenther/src/gcc-slpcost/gcc/testsuite/gcc.dg/guality/vla-1.c":15 -1 (nil)) (debug_insn 8 7 9 2 (var_location:DI D#2 (sign_extend:DI (debug_expr:SI D#3))) "/space/rguenther/src/gcc-slpcost/gcc/testsuite/gcc.dg/guality/vla-1.c":15 -1 (nil)) (debug_insn 9 8 10 2 (var_location:DI D#1 (plus:DI (debug_expr:DI D#2) (const_int -1 [0xffffffffffffffff]))) "/space/rguenther/src/gcc-slpcost/gcc/testsuite/gcc.dg/guality/vla-1.c":15 -1 (nil)) (debug_insn 10 9 11 2 (var_location:DI D.1914 (debug_expr:DI D#1)) "/space/rguenther/src/gcc-slpcost/gcc/testsuite/gcc.dg/guality/vla-1.c":15 -1 (nil)) Richard. > [ FWIW, I considered this obvious, given the ok for "[testsuite] Fix > guality/pr45882.c for flto" ( > https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01304.html ) which seemed > similar to me. ] > > Thanks, > - Tom > > >> [testsuite/guality] Prevent optimization of local in vla-1.c > >> > >> 2018-07-01 Tom de Vries <tdevr...@suse.de> > >> > >> * gcc.dg/guality/prevent-optimization.h (VOLATILE): Define. > >> * gcc.dg/guality/vla-1.c (f1): Mark local vla a as VOLATILE. > > > > Jakub > >