public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8964] middle-end/101824 - properly handle volatiles in nested fn lowering
@ 2021-09-06 8:50 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-09-06 8:50 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3f29e301f299a1b4e2c535affb964f0b97b7639c
commit r11-8964-g3f29e301f299a1b4e2c535affb964f0b97b7639c
Author: Richard Biener <rguenther@suse.de>
Date: Mon Aug 9 10:19:10 2021 +0200
middle-end/101824 - properly handle volatiles in nested fn lowering
When we build the COMPONENT_REF of a formerly volatile local off
the FRAME decl we have to make sure to mark the COMPONENT_REF
as TREE_THIS_VOLATILE. While the GIMPLE operand scanner looks
at the FIELD_DECL this is not how volatile GENERIC refs work.
2021-08-09 Richard Biener <rguenther@suse.de>
PR middle-end/101824
* tree-nested.c (get_frame_field): Mark the COMPONENT_REF as
volatile in case the variable was.
* gcc.dg/tree-ssa/pr101824.c: New testcase.
(cherry picked from commit bb169406cdc9e044eaec500dd742c2fed40f5488)
Diff:
---
gcc/testsuite/gcc.dg/tree-ssa/pr101824.c | 19 +++++++++++++++++++
gcc/tree-nested.c | 1 +
2 files changed, 20 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c b/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c
new file mode 100644
index 00000000000..d5987e14360
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr101824.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-pcom-details -fdump-tree-optimized" } */
+
+int main()
+{
+ volatile int y;
+ void bar()
+ {
+ __builtin_printf ("%d", y);
+ }
+ while (y)
+ ;
+ return 0;
+}
+
+/* Make sure the load from y is correctly interpreted as volatile, even
+ when going through FRAME. */
+/* { dg-final { scan-tree-dump-not "Executing predictive commoning" "pcom" } } */
+/* { dg-final { scan-tree-dump " ={v} FRAME" "optimized" } } */
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index cea917a4d58..968431fa22a 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1033,6 +1033,7 @@ get_frame_field (struct nesting_info *info, tree target_context,
}
x = build3 (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
+ TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (field);
return x;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-06 8:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 8:50 [gcc r11-8964] middle-end/101824 - properly handle volatiles in nested fn lowering Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).