diff options
author | Tom de Vries <tdevries@suse.de> | 2018-06-21 13:37:59 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2018-06-21 13:37:59 +0000 |
commit | d22d74e09dc48d1bffbcfd467fffaad7465d8676 (patch) | |
tree | d829ca102f3981e6f9d4a0833d827f42d756f730 /gcc | |
parent | 494e75321f6ce62918be661ef6b38c5888f0acaf (diff) | |
download | gcc-d22d74e09dc48d1bffbcfd467fffaad7465d8676.zip gcc-d22d74e09dc48d1bffbcfd467fffaad7465d8676.tar.gz gcc-d22d74e09dc48d1bffbcfd467fffaad7465d8676.tar.bz2 |
[testsuite] Fix guality/pr45882.c for flto
Atm this test in pr45882.c fails:
...
int d = a[i]; /* { dg-final { gdb-test 16 "d" "112" } } */
...
as follows:
...
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.
2018-06-21 Tom de Vries <tdevries@suse.de>
* gcc.dg/guality/pr45882.c (a): Add used attribute.
From-SVN: r261845
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/guality/pr45882.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 93ba5e1..977a22d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2018-06-21 Tom de Vries <tdevries@suse.de> + * gcc.dg/guality/pr45882.c (a): Add used attribute. + +2018-06-21 Tom de Vries <tdevries@suse.de> + PR tree-optimization/85859 * gcc.dg/pr85859.c: New test. diff --git a/gcc/testsuite/gcc.dg/guality/pr45882.c b/gcc/testsuite/gcc.dg/guality/pr45882.c index 5ca22d4..ece3523 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 |