[ARM] Fix cmse_nonsecure_entry return insn size
commit1b836787bea89adfac5623a035bee47a26b86cb6
authorthopre01 <thopre01@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Nov 2017 16:34:43 +0000 (9 16:34 +0000)
committerthopre01 <thopre01@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Nov 2017 16:34:43 +0000 (9 16:34 +0000)
treeb73603173913a3bac468233bff4b41854e42eebe
parent7be21691c63410c88b188094d24abd67ca6f803a
[ARM] Fix cmse_nonsecure_entry return insn size

A number of instructions are output in assembler form by
output_return_instruction () when compiling a function with the
cmse_nonsecure_entry attribute for Armv8-M Mainline with hardfloat float
ABI. However, the corresponding thumb2_cmse_entry_return insn pattern
does not account for all these instructions in its computing of the
length of the instruction.

This may lead GCC to use the wrong branching instruction due to
incorrect computation of the offset between the branch instruction's
address and the target address.

This commit fixes the mismatch between what output_return_instruction ()
does and what the pattern think it does and adds a note warning about
mismatch in the affected functions' heading comments to ensure code does
not get out of sync again.

Note: no test is provided because the C testcase is fragile (only works
on GCC 6) and the extracted RTL test fails to compile due to bugs in the
RTL frontend (PR82815 and PR82817)

2017-11-09  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    * config/arm/arm.c (output_return_instruction): Add comments to
    indicate requirement for cmse_nonsecure_entry return to account
    for the size of clearing instruction output here.
    (thumb_exit): Likewise.
    * config/arm/thumb2.md (thumb2_cmse_entry_return): Fix length for
    return in hardfloat mode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254601 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/config/arm/thumb2.md