This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [testsuite] Fix guality/pr45882.c for flto
- From: Richard Biener <rguenther at suse dot de>
- To: Tom de Vries <tdevries at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org, Cary Coutant <ccoutant at gmail dot com>, Jason Merrill <jason at redhat dot com>
- Date: Thu, 21 Jun 2018 14:52:31 +0200 (CEST)
- Subject: Re: [testsuite] Fix guality/pr45882.c for flto
- References: <20180621123342.fqyitbmaxpkcayih@localhost.localdomain>
On Thu, 21 Jun 2018, Tom de Vries wrote:
> Hi,
>
> Atm this test in pr45882.c:
> ...
> int d = a[i]; /* { dg-final { gdb-test 16 "d" "112" } } */
> ...
> fails as follows with -flto:
> ...
> FAIL: gcc.dg/guality/pr45882.c -O2 -flto -fuse-linker-plugin \
> -fno-fat-lto-objects line 16 d == 112
> ...
>
> In more detail, gdb fails to print the value of d:
> ...
> Breakpoint 1, foo (i=i@entry=7, j=j@entry=7) at pr45882.c:16
> 16 ++v;
> $1 = <optimized out>
> $2 = 112
> <optimized out> != 112
> ...
>
> Variable d is a local variable in function foo, initialized from global array a.
> When compiling, first cddce1 removes the initialization of d in foo, given
> that d is not used afterwards. Then ipa marks array a as write-only, and
> removes the stores to array a in main. This invalidates the location
> expression for d, which points to a[i], so it is removed, which is why gdb
> ends up printing <optimized out> for d.
>
> This patches fixes the fail by adding attribute used to array a, preventing
> array a from being marked as write-only.
>
> Tested on x86_64.
>
> OK for trunk?
OK.
Richard.
> Thanks,
> - Tom
>
> [testsuite] Fix guality/pr45882.c for flto
>
> 2018-06-21 Tom de Vries <tdevries@suse.de>
>
> * gcc.dg/guality/pr45882.c (a): Add used attribute.
>
> ---
> gcc/testsuite/gcc.dg/guality/pr45882.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/testsuite/gcc.dg/guality/pr45882.c b/gcc/testsuite/gcc.dg/guality/pr45882.c
> index 5ca22d4f4ad..ece35238a30 100644
> --- a/gcc/testsuite/gcc.dg/guality/pr45882.c
> +++ b/gcc/testsuite/gcc.dg/guality/pr45882.c
> @@ -3,7 +3,7 @@
> /* { dg-options "-g" } */
>
> extern void abort (void);
> -int a[1024];
> +int a[1024] __attribute__((used));
> volatile short int v;
>
> __attribute__((noinline,noclone,used)) int
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)