• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GCC with patches for Dreamcast


Commit MetaInfo

修訂b3bab6e7cad8be89405b47c4588eb0beeed72bbd (tree)
時間2021-09-30 03:42:47
作者Richard Sandiford <richard.sandiford@arm....>
Commiteralaskanemily

Log Message

Prevent -Og from deleting stores to write-only variables

This patch prevents -Og from deleting stores to write-only variables,
so that the values are still available when debugging. This seems
more convenient than forcing users to use attribute((used))
(probably conditionally, if it's not something they want in release
builds).

2019-07-29 Richard Sandiford <richard.sandiford@arm.com>

gcc/
* tree-cfg.c (execute_fixup_cfg): Don't delete stores to write-only
variables for -Og.

gcc/testsuite/
* c-c++-common/guality/Og-static-wo-1.c: New test.
* g++.dg/guality/guality.exp: Separate the c-c++-common tests into
"Og" and "general" tests. Run the latter at -O0 and -Og only.
* gcc.dg/guality/guality.exp: Likewise.

From-SVN: r273870

Change Summary

差異

--- /dev/null
+++ b/gcc/testsuite/c-c++-common/guality/Og-static-wo-1.c
@@ -0,0 +1,15 @@
1+/* { dg-do run } */
2+/* { dg-options "-g" } */
3+
4+#include "../../gcc.dg/nop.h"
5+
6+static int x = 0;
7+
8+int
9+main (void)
10+{
11+ asm volatile (NOP); /* { dg-final { gdb-test . "x" "0" } } */
12+ x = 1;
13+ asm volatile (NOP); /* { dg-final { gdb-test . "x" "1" } } */
14+ return 0;
15+}
--- a/gcc/testsuite/g++.dg/guality/guality.exp
+++ b/gcc/testsuite/g++.dg/guality/guality.exp
@@ -53,8 +53,22 @@ if {[check_guality "
5353 return 0;
5454 }
5555 "]} {
56- gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" ""
57- gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "" ""
56+ set general [list]
57+ set Og [list]
58+ foreach file [lsort [glob $srcdir/c-c++-common/guality/*.c]] {
59+ switch -glob -- [file tail $file] {
60+ Og-* { lappend Og $file }
61+ * { lappend general $file }
62+ }
63+ }
64+
65+ gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" ""
66+ gcc-dg-runtest $general "" ""
67+ set-torture-options \
68+ [list "-O0" "-Og"] \
69+ [list {}] \
70+ [list "-Og -flto"]
71+ gcc-dg-runtest $Og "" ""
5872 }
5973
6074 if [info exists guality_gdb_name] {
--- a/gcc/testsuite/gcc.dg/guality/guality.exp
+++ b/gcc/testsuite/gcc.dg/guality/guality.exp
@@ -53,8 +53,22 @@ if {[check_guality "
5353 return 0;
5454 }
5555 "]} {
56- gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "" ""
57- gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "" "-Wc++-compat"
56+ set general [list]
57+ set Og [list]
58+ foreach file [lsort [glob $srcdir/c-c++-common/guality/*.c]] {
59+ switch -glob -- [file tail $file] {
60+ Og-* { lappend Og $file }
61+ * { lappend general $file }
62+ }
63+ }
64+
65+ gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "" ""
66+ gcc-dg-runtest $general "" "-Wc++-compat"
67+ set-torture-options \
68+ [list "-O0" "-Og"] \
69+ [list {}] \
70+ [list "-Og -flto"]
71+ gcc-dg-runtest $Og "" "-Wc++-compat"
5872 }
5973
6074 if [info exists guality_gdb_name] {
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -9706,7 +9706,8 @@ execute_fixup_cfg (void)
97069706 Keep access when store has side effect, i.e. in case when source
97079707 is volatile. */
97089708 if (gimple_store_p (stmt)
9709- && !gimple_has_side_effects (stmt))
9709+ && !gimple_has_side_effects (stmt)
9710+ && !optimize_debug)
97109711 {
97119712 tree lhs = get_base_address (gimple_get_lhs (stmt));
97129713