[ARM] Fix cmse_nonsecure_entry return insn size
authorThomas Preud'homme <thomas.preudhomme@arm.com>
Thu, 9 Nov 2017 16:34:43 +0000 (16:34 +0000)
committerThomas Preud'homme <thopre01@gcc.gnu.org>
Thu, 9 Nov 2017 16:34:43 +0000 (16:34 +0000)
commit9f28fe39be68ca484d025ff49f783f050a0a2360
treeb73603173913a3bac468233bff4b41854e42eebe
parent9222c9e36869c345790b2b654e8cba059ec50b14
[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.

From-SVN: r254601
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/config/arm/thumb2.md