This fixes an issue on ptx where we fail to output a declaration for a
variable. The testcase is c-torture/compile/pr34856.c, and the cause of
the problem is that the variable g is never inserted into the varpool,
which is where a future patch will look for references to variables not
defined in the current translation unit (ptx assembly requires
declarations for these too).
Bootstrapped and tested on x86_64-linux, ok?
Bernd
commit 968a508fdd5c413147b9c26d37633bf7ab7a7e65
Author: Bernd Schmidt <ber...@codesourcery.com>
Date: Thu Sep 11 14:35:01 2014 +0200
Fix handling of CONSTRUCTORs in gimple-walk.
* gimple-walk.c (walk_stmt_load_store_addr_ops): Look past casts when
dealing with CONSTRUCTORs.
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index f4f6757..593f0e2 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -695,13 +695,17 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
tree val;
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), ix, val)
- if (TREE_CODE (val) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (val, 0), arg, data);
- else if (TREE_CODE (val) == OBJ_TYPE_REF
- && TREE_CODE (OBJ_TYPE_REF_OBJECT (val)) == ADDR_EXPR)
- ret |= visit_addr (stmt,
- TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val),
- 0), arg, data);
+ {
+ while (CONVERT_EXPR_P (val))
+ val = TREE_OPERAND (val, 0);
+ if (TREE_CODE (val) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (val, 0), arg, data);
+ else if (TREE_CODE (val) == OBJ_TYPE_REF
+ && TREE_CODE (OBJ_TYPE_REF_OBJECT (val)) == ADDR_EXPR)
+ ret |= visit_addr (stmt,
+ TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val),
+ 0), arg, data);
+ }
}
lhs = gimple_assign_lhs (stmt);
if (TREE_CODE (lhs) == TARGET_MEM_REF