aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEvgeny Stupachenko <evstupac@gmail.com>2014-10-31 13:30:06 +0000
committerIlya Enkovich <ienkovich@gcc.gnu.org>2014-10-31 13:30:06 +0000
commit9a2db19920ccf87adac7ec25807ca0608d9d022e (patch)
treefaa0a80a8c3e2c8b636f651c7f2a8d46a39e61c6 /gcc
parentbae83890e2d8b168f7503acd2df9a460fd5443a3 (diff)
downloadgcc-9a2db19920ccf87adac7ec25807ca0608d9d022e.zip
gcc-9a2db19920ccf87adac7ec25807ca0608d9d022e.tar.gz
gcc-9a2db19920ccf87adac7ec25807ca0608d9d022e.tar.bz2
re PR target/63534 (Bootstrap failure on x86_64/i686-linux)
gcc/ PR target/63534 * config/i386/i386.c (ix86_init_pic_reg): Emit SET_GOT to REAL_PIC_OFFSET_TABLE_REGNUM for mcount profiling. (ix86_save_reg): Save REAL_PIC_OFFSET_TABLE_REGNUM when profiling using mcount in 32bit PIC mode. (ix86_elim_entry_set_got): New. (ix86_expand_prologue): For the mcount profiling emit new SET_GOT in PROLOGUE, delete initial if possible. gcc/testsuite/ PR target/63534 * gcc.target/i386/mcount_pic.c: New. From-SVN: r216975
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/i386/i386.c72
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/i386/mcount_pic.c15
4 files changed, 93 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index af7e3d4..ae60aef 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2014-10-31 Evgeny Stupachenko <evstupac@gmail.com>
+
+ PR target/63534
+ * config/i386/i386.c (ix86_init_pic_reg): Emit SET_GOT to
+ REAL_PIC_OFFSET_TABLE_REGNUM for mcount profiling.
+ (ix86_save_reg): Save REAL_PIC_OFFSET_TABLE_REGNUM when profiling
+ using mcount in 32bit PIC mode.
+ (ix86_elim_entry_set_got): New.
+ (ix86_expand_prologue): For the mcount profiling emit new SET_GOT
+ in PROLOGUE, delete initial if possible.
+
2014-10-31 Eric Botcazou <ebotcazou@adacore.com>
* ipa-inline.c (want_inline_small_function_p): Fix typo and formatting.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 139b07c..9b22445 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6205,8 +6205,15 @@ ix86_init_pic_reg (void)
}
else
{
- rtx insn = emit_insn (gen_set_got (pic_offset_table_rtx));
+ /* If there is future mcount call in the function it is more profitable
+ to emit SET_GOT into ABI defined REAL_PIC_OFFSET_TABLE_REGNUM. */
+ rtx reg = crtl->profile
+ ? gen_rtx_REG (Pmode, REAL_PIC_OFFSET_TABLE_REGNUM)
+ : pic_offset_table_rtx;
+ rtx insn = emit_insn (gen_set_got (reg));
RTX_FRAME_RELATED_P (insn) = 1;
+ if (crtl->profile)
+ emit_move_insn (pic_offset_table_rtx, reg);
add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
}
@@ -9486,15 +9493,23 @@ ix86_select_alt_pic_regnum (void)
static bool
ix86_save_reg (unsigned int regno, bool maybe_eh_return)
{
- if (pic_offset_table_rtx
- && !ix86_use_pseudo_pic_reg ()
- && regno == REAL_PIC_OFFSET_TABLE_REGNUM
- && (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
- || crtl->profile
- || crtl->calls_eh_return
- || crtl->uses_const_pool
- || cfun->has_nonlocal_label))
- return ix86_select_alt_pic_regnum () == INVALID_REGNUM;
+ if (regno == REAL_PIC_OFFSET_TABLE_REGNUM
+ && pic_offset_table_rtx)
+ {
+ if (ix86_use_pseudo_pic_reg ())
+ {
+ /* REAL_PIC_OFFSET_TABLE_REGNUM used by call to
+ _mcount in prologue. */
+ if (!TARGET_64BIT && flag_pic && crtl->profile)
+ return true;
+ }
+ else if (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
+ || crtl->profile
+ || crtl->calls_eh_return
+ || crtl->uses_const_pool
+ || cfun->has_nonlocal_label)
+ return ix86_select_alt_pic_regnum () == INVALID_REGNUM;
+ }
if (crtl->calls_eh_return && maybe_eh_return)
{
@@ -10833,6 +10848,29 @@ ix86_finalize_stack_realign_flags (void)
crtl->stack_realign_finalized = true;
}
+/* Delete SET_GOT right after entry block if it is allocated to reg. */
+
+static void
+ix86_elim_entry_set_got (rtx reg)
+{
+ basic_block bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb;
+ rtx_insn *c_insn = BB_HEAD (bb);
+ if (!NONDEBUG_INSN_P (c_insn))
+ c_insn = next_nonnote_nondebug_insn (c_insn);
+ if (c_insn && NONJUMP_INSN_P (c_insn))
+ {
+ rtx pat = PATTERN (c_insn);
+ if (GET_CODE (pat) == PARALLEL)
+ {
+ rtx vec = XVECEXP (pat, 0, 0);
+ if (GET_CODE (vec) == SET
+ && XINT (XEXP (vec, 1), 1) == UNSPEC_SET_GOT
+ && REGNO (XEXP (vec, 0)) == REGNO (reg))
+ delete_insn (c_insn);
+ }
+ }
+}
+
/* Expand the prologue into a bunch of separate insns. */
void
@@ -11286,6 +11324,20 @@ ix86_expand_prologue (void)
if (!sse_registers_saved)
ix86_emit_save_sse_regs_using_mov (frame.sse_reg_save_offset);
+ /* For the mcount profiling on 32 bit PIC mode we need to emit SET_GOT
+ in PROLOGUE. */
+ if (!TARGET_64BIT && pic_offset_table_rtx && crtl->profile && !flag_fentry)
+ {
+ rtx pic = gen_rtx_REG (Pmode, REAL_PIC_OFFSET_TABLE_REGNUM);
+ insn = emit_insn (gen_set_got (pic));
+ RTX_FRAME_RELATED_P (insn) = 1;
+ add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
+ emit_insn (gen_prologue_use (pic));
+ /* Deleting already emmitted SET_GOT if exist and allocated to
+ REAL_PIC_OFFSET_TABLE_REGNUM. */
+ ix86_elim_entry_set_got (pic);
+ }
+
if (crtl->drap_reg && !crtl->stack_realign_needed)
{
/* vDRAP is setup but after reload it turns out stack realign
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2072879..719986c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2014-10-31 Evgeny Stupachenko <evstupac@gmail.com>
+ PR target/63534
+ * gcc.target/i386/mcount_pic.c: New.
+
+2014-10-31 Evgeny Stupachenko <evstupac@gmail.com>
+
* gcc.target/i386/pr23098.c: Remove xfail.
2014-10-31 Eric Botcazou <ebotcazou@adacore.com>
diff --git a/gcc/testsuite/gcc.target/i386/mcount_pic.c b/gcc/testsuite/gcc.target/i386/mcount_pic.c
new file mode 100644
index 0000000..6132cdf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mcount_pic.c
@@ -0,0 +1,15 @@
+/* PR target/63534 */
+/* Check correct mcount generation. */
+/* { dg-do run } */
+/* { dg-require-effective-target fpic } */
+/* { dg-require-effective-target ia32 } */
+/* { dg-options "-O2 -fpic -p -save-temps" } */
+
+int main ()
+{
+ return 0;
+}
+
+/* { dg-final { scan-assembler "mcount" } } */
+/* { dg-final { scan-assembler "get_pc_thunk" } } */
+/* { dg-final { cleanup-saved-temps } } */