This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This is sort of the "final" state I ended up trying to teach the C frontend not to emit array-to-pointer decay as ADDR_EXPR (element-type*, array) but as ADDR_EXPR (element-type*, ARRAY_REF (element-type, array, 0)) for both type correctness and for possible simplifications of fold and the tree optimizers that will no longer have to handle &a as &a[0] specially if trying to optimize ARRAY_REF operations. While the patch to teach the C frontend to emit &a[0] is not complicated (see the c-typeck.c (default_function_array_conversion) patch chunk), there is a lot of fall-out in the frontend and in the optimizers. In the patch you will find intermixed (fold-const.c parts) code to fold more of address calculation with &a[i] especially in the case of char arrays which gets excercised quite a lot in the C testsuite. I also came along problems in fold_indirect_ref_1 (see also separate post) and fold_stmt. The gimplify.c chunk was applied to check if C no longer creates those "invalid" trees. Until other frontends are fixed, this is not safe. The patch was bootstrapped and tested on i686-pc-linux-gnu for the C language with the only remaining regression being c99-init-4.c (I didn't manage to find the place to fix). I'll stop right here until I get encouragement and help from other frontend maintainers to maybe fix all of the frontends (I know of at least gfortran that needs to be fixed) to really have a benefit of the patch. Other suggestions? Like f.e. how to fix c99-init-4.c? Thanks, Richard.
Attachment:
canonicalize-array-decay-C-2
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |