Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gcc (ARC): Prevent stores to the frame before the stack adjustment.
Bugfix: Fixes the problem of the ARC GCC compiler generating incorrect code when using the "-fno-omit-frame-pointer" option. ZEP-1243 ZEP-1403 Change-Id: Ied420305a81eb56f57eff00048a425c39278ef85 Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
- Loading branch information
1 parent
6b354ab
commit 96660c0
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
recipes-devtools-arc/gcc/files/cbd8e54244cd02bdcf4f1057be3ce96631f35ac3.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
From cbd8e54244cd02bdcf4f1057be3ce96631f35ac3 Mon Sep 17 00:00:00 2001 | ||
From: Claudiu Zissulescu <claziss@gmail.com> | ||
Date: Tue, 3 Jan 2017 12:06:28 -0500 | ||
Subject: [PATCH] [ARC] Prevent moving stores to the frame before the stack | ||
adjustment. | ||
|
||
If the stack pointer is needed, emit a special barrier that will prevent | ||
the scheduler from moving stores to the frame before the stack adjustment. | ||
|
||
2017-01-03 Claudiu Zissulescu <claziss@synopsys.com> | ||
|
||
* config/arc/arc.c (arc_expand_prologue): Emit a special barrier | ||
to prevent store reordering. | ||
* config/arc/arc.md (UNSPEC_ARC_STKTIE): Define. | ||
(type): Add block type. | ||
(stack_tie): Define special instruction to be used in | ||
expand_prologue. | ||
--- | ||
gcc/config/arc/arc.c | 10 +++++++++- | ||
gcc/config/arc/arc.md | 15 ++++++++++++++- | ||
2 files changed, 23 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c | ||
index 6f21fc3..110556c 100644 | ||
--- a/gcc/config/arc/arc.c | ||
+++ b/gcc/config/arc/arc.c | ||
@@ -3101,7 +3101,15 @@ arc_expand_prologue (void) | ||
frame_size_to_allocate -= first_offset; | ||
/* Allocate the stack frame. */ | ||
if (frame_size_to_allocate > 0) | ||
- frame_stack_add ((HOST_WIDE_INT) 0 - frame_size_to_allocate); | ||
+ { | ||
+ frame_stack_add ((HOST_WIDE_INT) 0 - frame_size_to_allocate); | ||
+ /* If the frame pointer is needed, emit a special barrier that | ||
+ will prevent the scheduler from moving stores to the frame | ||
+ before the stack adjustment. */ | ||
+ if (arc_frame_pointer_needed ()) | ||
+ emit_insn (gen_stack_tie (stack_pointer_rtx, | ||
+ hard_frame_pointer_rtx)); | ||
+ } | ||
|
||
/* Setup the gp register, if needed. */ | ||
if (crtl->uses_pic_offset_table) | ||
diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md | ||
index 16f71b3..448157c 100644 | ||
--- a/gcc/config/arc/arc.md | ||
+++ b/gcc/config/arc/arc.md | ||
@@ -135,6 +135,7 @@ | ||
UNSPEC_ARC_VMAC2HU | ||
UNSPEC_ARC_VMPY2H | ||
UNSPEC_ARC_VMPY2HU | ||
+ UNSPEC_ARC_STKTIE | ||
]) | ||
|
||
(define_c_enum "vunspec" [ | ||
@@ -204,7 +205,7 @@ | ||
simd_vcompare, simd_vpermute, simd_vpack, simd_vpack_with_acc, | ||
simd_valign, simd_valign_with_acc, simd_vcontrol, | ||
simd_vspecial_3cycle, simd_vspecial_4cycle, simd_dma, mul16_em, div_rem, | ||
- fpu" | ||
+ fpu, block" | ||
(cond [(eq_attr "is_sfunc" "yes") | ||
(cond [(match_test "!TARGET_LONG_CALLS_SET && (!TARGET_MEDIUM_CALLS || GET_CODE (PATTERN (insn)) != COND_EXEC)") (const_string "call") | ||
(match_test "flag_pic") (const_string "sfunc")] | ||
@@ -6480,6 +6481,18 @@ | ||
(set_attr "predicable" "yes,no,no,yes,no") | ||
(set_attr "cond" "canuse,nocond,nocond,canuse_limm,nocond")]) | ||
|
||
+(define_insn "stack_tie" | ||
+ [(set (mem:BLK (scratch)) | ||
+ (unspec:BLK [(match_operand:SI 0 "register_operand" "rb") | ||
+ (match_operand:SI 1 "register_operand" "rb")] | ||
+ UNSPEC_ARC_STKTIE))] | ||
+ "" | ||
+ "" | ||
+ [(set_attr "length" "0") | ||
+ (set_attr "iscompact" "false") | ||
+ (set_attr "type" "block")] | ||
+ ) | ||
+ | ||
;; include the arc-FPX instructions | ||
(include "fpx.md") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters