Commit b3be2694 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/43845 (Segfault when using __attribute__((const)), versions 4.4.3 and 4.6)

2010-04-22  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43845
	* tree-ssa-pre.c (create_component_ref_by_pieces_1): Properly
	lookup the CALL_EXPR function and arguments.

	* gcc.c-torture/compile/pr43845.c: New testcase.

From-SVN: r158641
parent 038eab67
2010-04-22 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43845
* tree-ssa-pre.c (create_component_ref_by_pieces_1): Properly
lookup the CALL_EXPR function and arguments.
2010-04-22 Nick Clifton <nickc@redhat.com> 2010-04-22 Nick Clifton <nickc@redhat.com>
* config/stormy16/stormy16.c * config/stormy16/stormy16.c
......
2010-04-22 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43845
* gcc.c-torture/compile/pr43845.c: New testcase.
2010-04-22 Bernd Schmidt <bernds@codesourcery.com> 2010-04-22 Bernd Schmidt <bernds@codesourcery.com>
PR middle-end/29274 PR middle-end/29274
......
typedef int __attribute__ ((const)) (*x264_pixel_cmp_t)(void);
typedef struct {
x264_pixel_cmp_t ssd;
} x264_pixel_function_t;
int x264_pixel_ssd_wxh (x264_pixel_function_t *pf, int i_width) {
int i_ssd = 0, x;
for (x = 0; x < i_width; x++)
i_ssd += pf->ssd();
return i_ssd;
}
...@@ -2631,31 +2631,46 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, ...@@ -2631,31 +2631,46 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref,
{ {
case CALL_EXPR: case CALL_EXPR:
{ {
tree folded, sc = currop->op1; tree folded, sc = NULL_TREE;
unsigned int nargs = 0; unsigned int nargs = 0;
tree *args = XNEWVEC (tree, VEC_length (vn_reference_op_s, tree fn, *args;
ref->operands) - 1); if (TREE_CODE (currop->op0) == FUNCTION_DECL)
fn = currop->op0;
else
{
pre_expr op0 = get_or_alloc_expr_for (currop->op0);
fn = find_or_generate_expression (block, op0, stmts, domstmt);
if (!fn)
return NULL_TREE;
}
if (currop->op1)
{
pre_expr scexpr = get_or_alloc_expr_for (currop->op1);
sc = find_or_generate_expression (block, scexpr, stmts, domstmt);
if (!sc)
return NULL_TREE;
}
args = XNEWVEC (tree, VEC_length (vn_reference_op_s,
ref->operands) - 1);
while (*operand < VEC_length (vn_reference_op_s, ref->operands)) while (*operand < VEC_length (vn_reference_op_s, ref->operands))
{ {
args[nargs] = create_component_ref_by_pieces_1 (block, ref, args[nargs] = create_component_ref_by_pieces_1 (block, ref,
operand, stmts, operand, stmts,
domstmt); domstmt);
if (!args[nargs])
{
free (args);
return NULL_TREE;
}
nargs++; nargs++;
} }
folded = build_call_array (currop->type, folded = build_call_array (currop->type,
TREE_CODE (currop->op0) == FUNCTION_DECL (TREE_CODE (fn) == FUNCTION_DECL
? build_fold_addr_expr (currop->op0) ? build_fold_addr_expr (fn) : fn),
: currop->op0,
nargs, args); nargs, args);
free (args); free (args);
if (sc) if (sc)
{ CALL_EXPR_STATIC_CHAIN (folded) = sc;
pre_expr scexpr = get_or_alloc_expr_for (sc);
sc = find_or_generate_expression (block, scexpr, stmts, domstmt);
if (!sc)
return NULL_TREE;
CALL_EXPR_STATIC_CHAIN (folded) = sc;
}
return folded; return folded;
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment