[Bug tree-optimization/78810] New: [7 Regression] Optimized out volatile memory access
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 14 14:51:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78810
Bug ID: 78810
Summary: [7 Regression] Optimized out volatile memory access
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
Target Milestone: ---
Starting from r239778, Ruby 2.3 package can't be compiled.
$ cat /tmp/chunk.cpp
class NODE;
typedef unsigned long VALUE;
struct parser_params
{
};
struct parser_params *get_parser();
NODE *yycompile(parser_params *parser, VALUE a, VALUE b);
NODE*
rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
{
struct parser_params *parser;
parser = get_parser();
NODE *node = yycompile(parser, fname, start);
(*({volatile VALUE *rb_gc_guarded_ptr = (&(vparser));
rb_gc_guarded_ptr;}));
return node;
}
$ ./xgcc -B. /tmp/chunk.cpp -c -O2 -fdump-tree-optimized=/dev/stdout
;; Function NODE* rb_parser_compile_file_path(VALUE, VALUE, VALUE, int)
(_Z27rb_parser_compile_file_pathmmmi, funcdef_no=0, decl_uid=2287,
cgraph_uid=0, symbol_order=0)
NODE* rb_parser_compile_file_path(VALUE, VALUE, VALUE, int) (VALUE vparser,
VALUE fname, VALUE file, int start)
{
long unsigned int _1;
struct parser_params * _4;
struct NODE * _8;
<bb 2> [100.0%]:
_4 = get_parser ();
_1 = (long unsigned int) start_5(D);
_8 = yycompile (_4, fname_6(D), _1); [tail call]
return _8;
}
Testing following patch:
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 62eea8bb8a4..b92513fcf23 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1385,7 +1385,8 @@ non_rewritable_mem_ref_base (tree ref)
if (! DECL_P (decl))
return NULL_TREE;
if (! is_gimple_reg_type (TREE_TYPE (base))
- || VOID_TYPE_P (TREE_TYPE (base)))
+ || VOID_TYPE_P (TREE_TYPE (base))
+ || TREE_THIS_VOLATILE (decl) != TREE_THIS_VOLATILE (base))
return decl;
if ((TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE)
More information about the Gcc-bugs
mailing list