This is the mail archive of the gcc-patches@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] |
Hi The bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43129 describes how arm backend generates ineffecient code to load global variable's address in terms of both code size and performance when option -fpic is specified. It also describes how it can be improved by relocation R_ARM_GOT_PREL. This patch contains a new pass simplify-got to implement the suggested optimization. It is placed between gcse and ira. This new pass can also be applied to different targets when they satisfy 1. There should be at least 2 methods to load a global variable's address from GOT. Usually it means using different relocation types. 2. By default all global variable's address loading use the same method: first load the base address of GOT into a register pic_reg, then the real global variable's address is loaded as (SET offset_reg <the offset from GOT base to the GOT entry>) (SET address_reg (MEM (PLUS pic_reg offset_reg))) 3. If the number of global address loading is less than a target specific threshold the alternative method may be better. 4. The alternative method doesn't use the base of GOT (pic_reg). This patch depends on the arm relocation R_ARM_GOT_PREL which is only implemented in mainline binutils. So this patch won't be check in until the next major release of binutils. Test: x86_64 bootstrap. arm regression test on qemu. build CSiBE for arm with options "-Os -fpic -mthumb -fno-short-enums", the total size is: without simplify-got 2830665 with simplify-got 2825737 ChangeLog: 2010-04-13 Wei Guozhi <carrot@google.com> PR/43129 tree-pass.h (pass_simplify_got): New variable declaration. timevar.def (TV_SIMPLIFY_GOT): New timevar id. passes.c (init_optimization_passes): Add the new pass. simplify-got.c : New file implement simplify-got pass. Makefile.in (simplify-got.o): New object. hooks.h (hook_rtx_void_null): New function declaration. hooks.c (hook_rtx_void_null): New function. target.h (simplify_got_access): New structure contains simplify-got related hooks. target-def.h (TARGET_GET_PIC_REG): Define hook TARGET_GET_PIC_REG. (TARGET_CLEAR_PIC_REG): Likewise. (TARGET_LOADED_GLOBAL_VAR): Likewise. (TARGET_MAX_USAGE_TO_AVOID_PIC_REG): Likewise. (TARGET_LOAD_GLOBAL_ADDRESS): Likewise. doc/tm.texi (TARGET_GET_PIC_REG): Document this new hook. (TARGET_CLEAR_PIC_REG): Likewise. (TARGET_LOADED_GLOBAL_VAR): Likewise. (TARGET_MAX_USAGE_TO_AVOID_PIC_REG): Likewise. (TARGET_LOAD_GLOBAL_ADDRESS): Likewise. config/arm/arm.md (UNSPEC_GOT_PREL_SYM): New unspec value. config/arm/arm.c (arm_get_pic_reg): New function. (arm_clear_pic_reg): New function. (arm_max_usage_to_avoid_pic_reg): New function. (arm_loaded_global_var): New function. (arm_load_global_address): New function. (arm_output_addr_const_extra): Output const expression for new relocation R_ARM_GOT_PREL. 2010-04-13 Wei Guozhi <carrot@google.com> PR/43129 gcc.target/arm/got1.c: New testcase. gcc.target/arm/got2.c: New testcase. thanks Wei Guozhi
Attachment:
got.diff
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |