diff options
author | liuhongt <hongtao.liu@intel.com> | 2021-06-01 09:00:57 +0800 |
---|---|---|
committer | liuhongt <hongtao.liu@intel.com> | 2021-06-07 10:25:03 +0800 |
commit | 16465ceb06cc1f65cfca3c0eb2c1ee27ab03bdfd (patch) | |
tree | 7afa0001810636d4623eff17ba18d988d79b4ac4 /gcc/reg-stack.c | |
parent | 7d6987e90d1181de8dc51f9ba2313052faea080e (diff) | |
download | gcc-16465ceb06cc1f65cfca3c0eb2c1ee27ab03bdfd.zip gcc-16465ceb06cc1f65cfca3c0eb2c1ee27ab03bdfd.tar.gz gcc-16465ceb06cc1f65cfca3c0eb2c1ee27ab03bdfd.tar.bz2 |
CALL_INSN may not be a real function call.
Use "used" flag for CALL_INSN to indicate it's a fake call. If it's a
fake call, it won't have its own function stack.
gcc/ChangeLog
PR target/82735
* df-scan.c (df_get_call_refs): When call_insn is a fake call,
it won't use stack pointer reg.
* final.c (leaf_function_p): When call_insn is a fake call, it
won't affect caller as a leaf function.
* reg-stack.c (callee_clobbers_any_stack_reg): New.
(subst_stack_regs): When call_insn doesn't clobber any stack
reg, don't clear the arguments.
* rtl.c (shallow_copy_rtx): Don't clear flag used when orig is
a insn.
* shrink-wrap.c (requires_stack_frame_p): No need for stack
frame for a fake call.
* rtl.h (FAKE_CALL_P): New macro.
Diffstat (limited to 'gcc/reg-stack.c')
-rw-r--r-- | gcc/reg-stack.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c index 25210f0c..1d9ea03 100644 --- a/gcc/reg-stack.c +++ b/gcc/reg-stack.c @@ -174,6 +174,7 @@ #include "reload.h" #include "tree-pass.h" #include "rtl-iter.h" +#include "function-abi.h" #ifdef STACK_REGS @@ -2368,6 +2369,18 @@ subst_asm_stack_regs (rtx_insn *insn, stack_ptr regstack) } } } + +/* Return true if a function call is allowed to alter some or all bits + of any stack reg. */ +static bool +callee_clobbers_any_stack_reg (const function_abi & callee_abi) +{ + for (unsigned regno = FIRST_STACK_REG; regno <= LAST_STACK_REG; regno++) + if (callee_abi.clobbers_at_least_part_of_reg_p (regno)) + return true; + return false; +} + /* Substitute stack hard reg numbers for stack virtual registers in INSN. Non-stack register numbers are not changed. REGSTACK is the @@ -2382,7 +2395,10 @@ subst_stack_regs (rtx_insn *insn, stack_ptr regstack) bool control_flow_insn_deleted = false; int i; - if (CALL_P (insn)) + /* If the target of the call doesn't clobber any stack registers, + Don't clear the arguments. */ + if (CALL_P (insn) + && callee_clobbers_any_stack_reg (insn_callee_abi (insn))) { int top = regstack->top; |