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]

Re: Ping: C-family stack check for threads


On 09/05/11 09:45, Ye Joey wrote:
+  /* check if we can use one of the argument registers r0..r3 as long as they
+   * not holding data*/
+  for (reg = 0; reg<= LAST_ARG_REGNUM&&  i<  2; reg++)
...
+ n = (reg + 1) % 4;
Avoid immediate register number.
use ARG_REGISTER (1) to replace "reg 0"
use NUM_ARG_REGS to replace "4"


The 4 is the number of argument registers so you are right to use NUM_ARG_REGS here.
The calculation should give the next possible argument register.
E.g. if the current register is r0, the next register is r1.
Except if the current register is r3, then the next register is r0.


I think the ARG_REGISTER macro will not reduce confusion.
  n = ( ARG_REGISTER(reg+1) + 1) % NUM_ARG_REGS;
identical to
  n = (reg + 1) % NUM_ARG_REGS;

regards
  Thomas Klein

gcc/ChangeLog

2011-09-05  Thomas Klein <th.r.klein@web.de>
    * opts.c (common_handle_option): introduce new parameters "direct" and
    "indirect"
    * flag-types.h (enum stack_check_type): Likewise

    * explow.c (allocate_dynamic_stack_space):
    - suppress stack probing if parameter "direct", "indirect" or if a
    stack-limit is given
    - do additional read of limit value if parameter "indirect" and a
    stack-limit symbol is given
    - emit a call to a stack_failure function [as an alternative to a trap
    call]
    (function probe_stack_range): if allowed to override the range porbe
    emit generic_limit_check_stack

    * config/arm/arm.c
    (stack_check_work_registers): new function to find possible working
    registers [only used by "stack check"]
    (emit_push_regs): add push RTL instruction without keeping regnumber
    and frame memory in mind.
    (emit_pop_regs): add pop RTL instruction to revert the above push
    (emit_stack_check_insns): new function to write RTL instructions for
    stack check at prologue stage.
    (arm_expand_prologue): stack check integration for ARM and Thumb-2
    (thumb1_output_function_prologue): stack check integration for Thumb-1

    * config/arm/arm.md
    (cbranchsi4_insn): allow compare and branch using stack pointer
    register [at thumb mode]
    (arm_cmpsi_insn): allow comparing using stack pointer register [at arm]
    (probe_stack): do not emit code when parameters "direct" or "indirect"
    is given, emit move code way same as in gcc/explow.c [function
    emit_stack_probe]
    (probe_stack_done): dummy to make sure probe_stack insns are not
    optimized away
    (generic_limit_check_stack): if stack-limit and parameter "generic" is
    given use the limit the same way as in function
    allocate_dynamic_stack_space
    (stack_failure): failure call used in stack check functions
    emit_stack_check_insns, generic_limit_check_stack or
    allocate_dynamic_stack_space [similar to a trap but avoid conflict with
    builtin_trap]

Attachment: stackCheck.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]