From d397a6b6b441ea96bba615da996c45df1a4fc220 Mon Sep 17 00:00:00 2001 From: yroux Date: Wed, 14 Jan 2015 12:53:04 +0000 Subject: [PATCH] 2015-01-14 Yvan Roux Fix Linaro PR #902 Partial Backport from trunk r211798. 2014-06-18 Radovan Obradovic Tom de Vries * config/arm/arm.c (arm_emit_call_insn): Add IP and CC clobbers to CALL_INSN_FUNCTION_USAGE. Backport from trunk r209800. 2014-04-25 Tom de Vries * expr.c (clobber_reg_mode): New function. * expr.h (clobber_reg): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/linaro/gcc-4_9-branch@219597 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.linaro | 17 +++++++++++++++++ gcc/config/arm/arm.c | 9 +++++++++ gcc/expr.c | 12 ++++++++++++ gcc/expr.h | 8 ++++++++ 4 files changed, 46 insertions(+) diff --git a/gcc/ChangeLog.linaro b/gcc/ChangeLog.linaro index 0657fd4..8795ac9 100644 --- a/gcc/ChangeLog.linaro +++ b/gcc/ChangeLog.linaro @@ -1,5 +1,22 @@ 2015-01-14 Yvan Roux + Fix Linaro PR #902 + + Partial Backport from trunk r211798. + 2014-06-18 Radovan Obradovic + Tom de Vries + + * config/arm/arm.c (arm_emit_call_insn): Add IP and CC clobbers to + CALL_INSN_FUNCTION_USAGE. + + Backport from trunk r209800. + 2014-04-25 Tom de Vries + + * expr.c (clobber_reg_mode): New function. + * expr.h (clobber_reg): New function. + +2015-01-14 Yvan Roux + Backport from trunk r211783. 2014-06-18 Charles Baylis diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 145fb27..1ef6b0f 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -17727,6 +17727,15 @@ arm_emit_call_insn (rtx pat, rtx addr) require_pic_register (); use_reg (&CALL_INSN_FUNCTION_USAGE (insn), cfun->machine->pic_reg); } + + if (TARGET_AAPCS_BASED) + { + /* For AAPCS, IP and CC can be clobbered by veneers inserted by the + linker. */ + rtx *fusage = &CALL_INSN_FUNCTION_USAGE (insn); + clobber_reg (fusage, gen_rtx_REG (word_mode, IP_REGNUM)); + clobber_reg (fusage, gen_rtx_REG (word_mode, CC_REGNUM)); + } } /* Output a 'call' insn. */ diff --git a/gcc/expr.c b/gcc/expr.c index 75ce5c2..06ae284 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -2343,6 +2343,18 @@ use_reg_mode (rtx *call_fusage, rtx reg, enum machine_mode mode) = gen_rtx_EXPR_LIST (mode, gen_rtx_USE (VOIDmode, reg), *call_fusage); } +/* Add a CLOBBER expression for REG to the (possibly empty) list pointed + to by CALL_FUSAGE. REG must denote a hard register. */ + +void +clobber_reg_mode (rtx *call_fusage, rtx reg, enum machine_mode mode) +{ + gcc_assert (REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER); + + *call_fusage + = gen_rtx_EXPR_LIST (mode, gen_rtx_CLOBBER (VOIDmode, reg), *call_fusage); +} + /* Add USE expressions to *CALL_FUSAGE for each of NREGS consecutive regs, starting at REGNO. All of these registers must be hard registers. */ diff --git a/gcc/expr.h b/gcc/expr.h index 524da67..1823feb 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -346,6 +346,7 @@ extern void copy_blkmode_from_reg (rtx, rtx, tree); /* Mark REG as holding a parameter for the next CALL_INSN. Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode. */ extern void use_reg_mode (rtx *, rtx, enum machine_mode); +extern void clobber_reg_mode (rtx *, rtx, enum machine_mode); extern rtx copy_blkmode_to_reg (enum machine_mode, tree); @@ -356,6 +357,13 @@ use_reg (rtx *fusage, rtx reg) use_reg_mode (fusage, reg, VOIDmode); } +/* Mark REG as clobbered by the call with FUSAGE as CALL_INSN_FUNCTION_USAGE. */ +static inline void +clobber_reg (rtx *fusage, rtx reg) +{ + clobber_reg_mode (fusage, reg, VOIDmode); +} + /* Mark NREGS consecutive regs, starting at REGNO, as holding parameters for the next CALL_INSN. */ extern void use_regs (rtx *, int, int); -- 2.7.4