diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-27 14:01:27 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-27 14:01:27 +0000 |
commit | f549b28db58e79eb1edce3a640bfa890bef1c6f6 (patch) | |
tree | 8bf61b8be7e8989d8c213faaeb4fb64ab0561c76 /gcc | |
parent | 11d686e25f7f40db2e4161ab80ff70021169a33f (diff) | |
download | gcc-f549b28db58e79eb1edce3a640bfa890bef1c6f6.tar.gz |
2007-06-27 Richard Guenther <rguenther@suse.de>
PR middle-end/32492
* tree.h (fold_convertible_p): Declare.
* fold-const.c (fold_convertible_p): New function.
* gimplify.c (gimplify_call_expr): Use fold_convertible_p
instead of lang_hooks.types_compatible_p.
* gcc.dg/inline-22.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126054 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fold-const.c | 34 | ||||
-rw-r--r-- | gcc/gimplify.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/inline-22.c | 7 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
6 files changed, 57 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 321298c46f5..2f148acf787 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2007-06-27 Richard Guenther <rguenther@suse.de> + + PR middle-end/32492 + * tree.h (fold_convertible_p): Declare. + * fold-const.c (fold_convertible_p): New function. + * gimplify.c (gimplify_call_expr): Use fold_convertible_p + instead of lang_hooks.types_compatible_p. + 2007-06-26 Jan Hubicka <jh@suse.cz> * fwprop.c (try_fwprop_subst): Use validate_unshare_change. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e2d57c99c11..d806e7afc70 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2211,6 +2211,40 @@ build_zero_vector (tree type) return build_vector (type, list); } +/* Returns true, if ARG is convertible to TYPE using a NOP_EXPR. */ + +bool +fold_convertible_p (tree type, tree arg) +{ + tree orig = TREE_TYPE (arg); + + if (type == orig) + return true; + + if (TREE_CODE (arg) == ERROR_MARK + || TREE_CODE (type) == ERROR_MARK + || TREE_CODE (orig) == ERROR_MARK) + return false; + + if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig)) + return true; + + switch (TREE_CODE (type)) + { + case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: + case POINTER_TYPE: case REFERENCE_TYPE: + case OFFSET_TYPE: + if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig) + || TREE_CODE (orig) == OFFSET_TYPE) + return true; + return (TREE_CODE (orig) == VECTOR_TYPE + && tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig))); + + default: + return TREE_CODE (type) == TREE_CODE (orig); + } +} + /* Convert expression ARG to type TYPE. Used by the middle-end for simple conversions in preference to calling the front-end's convert. */ diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 7f5615e344d..d935ec17f6e 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2141,8 +2141,7 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value) if (!p || TREE_VALUE (p) == error_mark_node || CALL_EXPR_ARG (*expr_p, i) == error_mark_node - || !lang_hooks.types_compatible_p - (TREE_TYPE (CALL_EXPR_ARG (*expr_p, i)), TREE_VALUE (p))) + || !fold_convertible_p (TREE_VALUE (p), CALL_EXPR_ARG (*expr_p, i))) { CALL_CANNOT_INLINE_P (*expr_p) = 1; break; @@ -2155,8 +2154,7 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value) if (!p || p == error_mark_node || CALL_EXPR_ARG (*expr_p, i) == error_mark_node - || !lang_hooks.types_compatible_p - (TREE_TYPE (CALL_EXPR_ARG (*expr_p, i)), TREE_TYPE (p))) + || !fold_convertible_p (TREE_TYPE (p), CALL_EXPR_ARG (*expr_p, i))) { CALL_CANNOT_INLINE_P (*expr_p) = 1; break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 006c1fa1dd7..9f350e7b8df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-06-27 Richard Guenther <rguenther@suse.de> + + PR middle-end/32492 + * gcc.dg/inline-22.c: New testcase. + 2007-06-26 Hui-May Chang <hm.chang@apple.com> * gcc.target/i386/large-size-array-3.c: Remove the larger size of diff --git a/gcc/testsuite/gcc.dg/inline-22.c b/gcc/testsuite/gcc.dg/inline-22.c new file mode 100644 index 00000000000..6d790f97402 --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-22.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-funit-at-a-time" } */ +/* Verify we can inline without a complete prototype and with promoted + arguments. See also PR32492. */ +__attribute__((always_inline)) void f1() {} +__attribute__((always_inline)) void f2(char x) {} +void f3() { f1(); f2(0); } diff --git a/gcc/tree.h b/gcc/tree.h index 28169d7a543..942ab5f14d4 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4444,6 +4444,7 @@ extern tree fold_build2_initializer (enum tree_code, tree, tree, tree); extern tree fold_build3_initializer (enum tree_code, tree, tree, tree, tree); extern tree fold_build_call_array (tree, tree, int, tree *); extern tree fold_build_call_array_initializer (tree, tree, int, tree *); +extern bool fold_convertible_p (tree, tree); extern tree fold_convert (tree, tree); extern tree fold_single_bit_test (enum tree_code, tree, tree, tree); extern tree fold_ignored_result (tree); |