aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlex Coplan <alex.coplan@arm.com>2021-05-11 13:11:09 +0100
committerAlex Coplan <alex.coplan@arm.com>2021-05-11 13:11:09 +0100
commit2ac1f0eb3887335b7a7e845812956fa436e72a91 (patch)
tree669c82dc015203eaa09cf5903e8b04b7adf6f3c6 /gcc
parent28de75d27685b2735612d264bb96f39001f4d836 (diff)
downloadgcc-2ac1f0eb3887335b7a7e845812956fa436e72a91.zip
gcc-2ac1f0eb3887335b7a7e845812956fa436e72a91.tar.gz
gcc-2ac1f0eb3887335b7a7e845812956fa436e72a91.tar.bz2
arm: Avoid emitting bogus CFA adjusts for CMSE nonsecure calls [PR99725]
The PR shows us attaching REG_CFA_ADJUST_CFA notes to stack pointer adjustments emitted in cmse_nonsecure_call_inline_register_clear (when -march=armv8.1-m.main). However, the stack pointer is not guaranteed to be the CFA reg. If we're at -O0 or we have -fno-omit-frame-pointer, then the frame pointer will be used as the CFA reg, and these notes on the sp adjustments will lead to ICEs in dwarf2out_frame_debug_adjust_cfa. This patch avoids emitting these notes if the current function has a frame pointer. gcc/ChangeLog: PR target/99725 * config/arm/arm.c (cmse_nonsecure_call_inline_register_clear): Avoid emitting CFA adjusts on the sp if we have the fp. gcc/testsuite/ChangeLog: PR target/99725 * gcc.target/arm/cmse/pr99725.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/arm/arm.c21
-rw-r--r--gcc/testsuite/gcc.target/arm/cmse/pr99725.c5
2 files changed, 18 insertions, 8 deletions
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 0371d98..2962071 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -18774,10 +18774,14 @@ cmse_nonsecure_call_inline_register_clear (void)
imm = gen_int_mode (- lazy_store_stack_frame_size, SImode);
add_insn = emit_insn (gen_addsi3 (stack_pointer_rtx,
stack_pointer_rtx, imm));
- arm_add_cfa_adjust_cfa_note (add_insn,
- - lazy_store_stack_frame_size,
- stack_pointer_rtx,
- stack_pointer_rtx);
+ /* If we have the frame pointer, then it will be the
+ CFA reg. Otherwise, the stack pointer is the CFA
+ reg, so we need to emit a CFA adjust. */
+ if (!frame_pointer_needed)
+ arm_add_cfa_adjust_cfa_note (add_insn,
+ - lazy_store_stack_frame_size,
+ stack_pointer_rtx,
+ stack_pointer_rtx);
emit_insn (gen_lazy_store_multiple_insn (stack_pointer_rtx));
}
/* Save VFP callee-saved registers. */
@@ -18815,10 +18819,11 @@ cmse_nonsecure_call_inline_register_clear (void)
rtx_insn *add_insn =
emit_insn (gen_addsi3 (stack_pointer_rtx,
stack_pointer_rtx, imm));
- arm_add_cfa_adjust_cfa_note (add_insn,
- lazy_store_stack_frame_size,
- stack_pointer_rtx,
- stack_pointer_rtx);
+ if (!frame_pointer_needed)
+ arm_add_cfa_adjust_cfa_note (add_insn,
+ lazy_store_stack_frame_size,
+ stack_pointer_rtx,
+ stack_pointer_rtx);
}
/* Restore VFP callee-saved registers. */
else
diff --git a/gcc/testsuite/gcc.target/arm/cmse/pr99725.c b/gcc/testsuite/gcc.target/arm/cmse/pr99725.c
new file mode 100644
index 0000000..284da18
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/cmse/pr99725.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mcmse -g" } */
+typedef int __attribute__((cmse_nonsecure_call)) (*t)();
+t f;
+void g() { f(); }