* Re: [PATCH] x86-64: Use R10 for profiling large model
@ 2021-01-08 9:24 Uros Bizjak
2021-01-08 12:50 ` H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: Uros Bizjak @ 2021-01-08 9:24 UTC (permalink / raw)
To: gcc-patches
> Since R10 is preserved when calling mcount, R10 can be used a scratch
> register to call mcount in large model.
Please mention that R10 can be used as a static chain registers and is
preserved when calling mcount for nested functions.
> gcc/
>
> PR target/98482
> * config/i386/i386.c (x86_function_profiler): Use R10 to call
> mcount in large model. Sorry for large model with PIC.
>
> gcc/testsuite/
>
> PR target/98482
> * gcc.target/i386/pr98482-1.c: New test.
> * gcc.target/i386/pr98482-1.c: Likewise.
OK with comment fixes.
Thanks,
Uros.
+ case CM_LARGE:
+ /* NB: R10 can be used as a scratch register here since
+ R10 is preserved when calling mcount. */
Also mention that R10 can be used as a static chain register and is
preserved when calling mcount for nested functions.
+ fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
+ mcount_name);
+ break;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86-64: Use R10 for profiling large model
2021-01-08 9:24 [PATCH] x86-64: Use R10 for profiling large model Uros Bizjak
@ 2021-01-08 12:50 ` H.J. Lu
2021-01-08 13:27 ` [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2021-01-08 12:50 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1098 bytes --]
On Fri, Jan 8, 2021 at 1:24 AM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> > Since R10 is preserved when calling mcount, R10 can be used a scratch
> > register to call mcount in large model.
>
> Please mention that R10 can be used as a static chain registers and is
> preserved when calling mcount for nested functions.
>
> > gcc/
> >
> > PR target/98482
> > * config/i386/i386.c (x86_function_profiler): Use R10 to call
> > mcount in large model. Sorry for large model with PIC.
> >
> > gcc/testsuite/
> >
> > PR target/98482
> > * gcc.target/i386/pr98482-1.c: New test.
> > * gcc.target/i386/pr98482-1.c: Likewise.
>
> OK with comment fixes.
>
> Thanks,
> Uros.
>
> + case CM_LARGE:
> + /* NB: R10 can be used as a scratch register here since
> + R10 is preserved when calling mcount. */
>
> Also mention that R10 can be used as a static chain register and is
> preserved when calling mcount for nested functions.
>
> + fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
> + mcount_name);
> + break;
This is the patch I am checking in.
Thanks.
--
H.J.
[-- Attachment #2: 0001-x86-64-Use-R10-for-profiling-large-model.patch --]
[-- Type: text/x-patch, Size: 3341 bytes --]
From 6ddaec60b84ccdfb11224440bfffa86112244d88 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 7 Jan 2021 14:27:49 -0800
Subject: [PATCH] x86-64: Use R10 for profiling large model
R10 is caller-saved. Although it can be used as a static chain register,
it is preserved when calling mcount for nested functions. Use R10 as a
scratch register to call mcount in large model.
gcc/
PR target/98482
* config/i386/i386.c (x86_function_profiler): Use R10 to call
mcount in large model. Sorry for large model with PIC.
gcc/testsuite/
PR target/98482
* gcc.target/i386/pr98482-1.c: New test.
* gcc.target/i386/pr98482-1.c: Likewise.
---
gcc/config/i386/i386.c | 26 +++++++++++++++++++++--
gcc/testsuite/gcc.target/i386/pr98482-1.c | 9 ++++++++
gcc/testsuite/gcc.target/i386/pr98482-2.c | 9 ++++++++
3 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr98482-1.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr98482-2.c
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fad50e7e537..d3068462fcd 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -20794,8 +20794,30 @@ x86_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
fprintf (file, "\tleaq\t%sP%d(%%rip),%%r11\n", LPREFIX, labelno);
#endif
- if (!TARGET_PECOFF && flag_pic)
- fprintf (file, "1:\tcall\t*%s@GOTPCREL(%%rip)\n", mcount_name);
+ if (!TARGET_PECOFF)
+ {
+ switch (ix86_cmodel)
+ {
+ case CM_LARGE:
+ /* NB: R10 is caller-saved. Although it can be used as a
+ static chain register, it is preserved when calling
+ mcount for nested functions. */
+ fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
+ mcount_name);
+ break;
+ case CM_LARGE_PIC:
+ sorry ("profiling %<-mcmodel=large%> with PIC is not supported");
+ break;
+ case CM_SMALL_PIC:
+ case CM_MEDIUM_PIC:
+ fprintf (file, "1:\tcall\t*%s@GOTPCREL(%%rip)\n",
+ mcount_name);
+ break;
+ default:
+ x86_print_call_or_nop (file, mcount_name);
+ break;
+ }
+ }
else
x86_print_call_or_nop (file, mcount_name);
}
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-1.c b/gcc/testsuite/gcc.target/i386/pr98482-1.c
new file mode 100644
index 00000000000..72d5ccb269c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr98482-1.c
@@ -0,0 +1,9 @@
+/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-require-effective-target mfentry } */
+/* { dg-options "-fprofile -mfentry -O2 -mcmodel=large" } */
+/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__, %r10\n\tcall\t\\*%r10" } } */
+
+void
+func (void)
+{
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-2.c b/gcc/testsuite/gcc.target/i386/pr98482-2.c
new file mode 100644
index 00000000000..aed3ca4b6ff
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr98482-2.c
@@ -0,0 +1,9 @@
+/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-require-effective-target mfentry } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-fpic -fprofile -mfentry -O2 -mcmodel=large" } */
+
+void
+func (void)
+{
+} /* { dg-message "sorry, unimplemented: profiling '-mcmodel=large' with PIC is not supported" } */
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC
2021-01-08 12:50 ` H.J. Lu
@ 2021-01-08 13:27 ` H.J. Lu
2021-01-08 14:31 ` Uros Bizjak
0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2021-01-08 13:27 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]
On Fri, Jan 8, 2021 at 4:50 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Jan 8, 2021 at 1:24 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > > Since R10 is preserved when calling mcount, R10 can be used a scratch
> > > register to call mcount in large model.
> >
> > Please mention that R10 can be used as a static chain registers and is
> > preserved when calling mcount for nested functions.
> >
> > > gcc/
> > >
> > > PR target/98482
> > > * config/i386/i386.c (x86_function_profiler): Use R10 to call
> > > mcount in large model. Sorry for large model with PIC.
> > >
> > > gcc/testsuite/
> > >
> > > PR target/98482
> > > * gcc.target/i386/pr98482-1.c: New test.
> > > * gcc.target/i386/pr98482-1.c: Likewise.
> >
> > OK with comment fixes.
> >
> > Thanks,
> > Uros.
> >
> > + case CM_LARGE:
> > + /* NB: R10 can be used as a scratch register here since
> > + R10 is preserved when calling mcount. */
> >
> > Also mention that R10 can be used as a static chain register and is
> > preserved when calling mcount for nested functions.
> >
> > + fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
> > + mcount_name);
> > + break;
>
> This is the patch I am checking in.
>
For NO_PROFILE_COUNTERS targets, R11 is a scratch register. We can use
R10 and R11 to call mcount in large model with PIC.
OK for master?
Thanks.
--
H.J.
[-- Attachment #2: 0001-x86-64-Use-R10-and-R11-for-profiling-large-model-wit.patch --]
[-- Type: text/x-patch, Size: 2260 bytes --]
From b2e0bccbdba630a1f7f8b601e19b7302e375e240 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 8 Jan 2021 05:20:19 -0800
Subject: [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC
For NO_PROFILE_COUNTERS targets, R11 is a scratch register. We can use
R10 and R11 to call mcount in large model with PIC.
gcc/
PR target/98482
* config/i386/i386.c (x86_function_profiler): Use R10 and R11
to call mcount in large model with PIC for NO_PROFILE_COUNTERS
targets.
gcc/testsuite/
PR target/98482
* gcc.target/i386/pr98482-2.c: Updated.
---
gcc/config/i386/i386.c | 10 ++++++++++
gcc/testsuite/gcc.target/i386/pr98482-2.c | 3 ++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index d3068462fcd..50380865acd 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -20806,7 +20806,17 @@ x86_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
mcount_name);
break;
case CM_LARGE_PIC:
+#ifdef NO_PROFILE_COUNTERS
+ fprintf (file, "1:\tmovabsq\t$_GLOBAL_OFFSET_TABLE_-1b, %%r11\n");
+ fprintf (file, "\tleaq\t1b(%%rip), %%r10\n");
+ fprintf (file, "\taddq\t%%r11, %%r10\n");
+ fprintf (file, "\tmovabsq\t$%s@PLTOFF, %%r11\n",
+ mcount_name);
+ fprintf (file, "\taddq\t%%r11, %%r10\n");
+ fprintf (file, "\tcall\t*%%r10\n");
+#else
sorry ("profiling %<-mcmodel=large%> with PIC is not supported");
+#endif
break;
case CM_SMALL_PIC:
case CM_MEDIUM_PIC:
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-2.c b/gcc/testsuite/gcc.target/i386/pr98482-2.c
index aed3ca4b6ff..0ee142db12c 100644
--- a/gcc/testsuite/gcc.target/i386/pr98482-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr98482-2.c
@@ -2,8 +2,9 @@
/* { dg-require-effective-target mfentry } */
/* { dg-require-effective-target fpic } */
/* { dg-options "-fpic -fprofile -mfentry -O2 -mcmodel=large" } */
+/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__@PLTOFF, %r11\n\taddq\t%r11, %r10\n\tcall\t\\*%r10" } } */
void
func (void)
{
-} /* { dg-message "sorry, unimplemented: profiling '-mcmodel=large' with PIC is not supported" } */
+}
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC
2021-01-08 13:27 ` [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC H.J. Lu
@ 2021-01-08 14:31 ` Uros Bizjak
2021-01-08 14:43 ` H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: Uros Bizjak @ 2021-01-08 14:31 UTC (permalink / raw)
To: H.J. Lu; +Cc: gcc-patches
On Fri, Jan 8, 2021 at 2:28 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Jan 8, 2021 at 4:50 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Fri, Jan 8, 2021 at 1:24 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> > >
> > > > Since R10 is preserved when calling mcount, R10 can be used a scratch
> > > > register to call mcount in large model.
> > >
> > > Please mention that R10 can be used as a static chain registers and is
> > > preserved when calling mcount for nested functions.
> > >
> > > > gcc/
> > > >
> > > > PR target/98482
> > > > * config/i386/i386.c (x86_function_profiler): Use R10 to call
> > > > mcount in large model. Sorry for large model with PIC.
> > > >
> > > > gcc/testsuite/
> > > >
> > > > PR target/98482
> > > > * gcc.target/i386/pr98482-1.c: New test.
> > > > * gcc.target/i386/pr98482-1.c: Likewise.
> > >
> > > OK with comment fixes.
> > >
> > > Thanks,
> > > Uros.
> > >
> > > + case CM_LARGE:
> > > + /* NB: R10 can be used as a scratch register here since
> > > + R10 is preserved when calling mcount. */
> > >
> > > Also mention that R10 can be used as a static chain register and is
> > > preserved when calling mcount for nested functions.
> > >
> > > + fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
> > > + mcount_name);
> > > + break;
> >
> > This is the patch I am checking in.
> >
>
> For NO_PROFILE_COUNTERS targets, R11 is a scratch register. We can use
> R10 and R11 to call mcount in large model with PIC.
>
> OK for master?
+ fprintf (file, "\tmovabsq\t$%s@PLTOFF, %%r11\n",
+ mcount_name);
Please put mcount_name in the same line (and please do the same for
case CM_MEDIUM_PIC).
OK with the above fixes.
Thanks,
Uros.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC
2021-01-08 14:31 ` Uros Bizjak
@ 2021-01-08 14:43 ` H.J. Lu
2021-01-08 16:45 ` [PATCH] x86-64: Require lp64 for PR target/98482 tests H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2021-01-08 14:43 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2000 bytes --]
On Fri, Jan 8, 2021 at 6:31 AM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> On Fri, Jan 8, 2021 at 2:28 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Fri, Jan 8, 2021 at 4:50 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Fri, Jan 8, 2021 at 1:24 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> > > >
> > > > > Since R10 is preserved when calling mcount, R10 can be used a scratch
> > > > > register to call mcount in large model.
> > > >
> > > > Please mention that R10 can be used as a static chain registers and is
> > > > preserved when calling mcount for nested functions.
> > > >
> > > > > gcc/
> > > > >
> > > > > PR target/98482
> > > > > * config/i386/i386.c (x86_function_profiler): Use R10 to call
> > > > > mcount in large model. Sorry for large model with PIC.
> > > > >
> > > > > gcc/testsuite/
> > > > >
> > > > > PR target/98482
> > > > > * gcc.target/i386/pr98482-1.c: New test.
> > > > > * gcc.target/i386/pr98482-1.c: Likewise.
> > > >
> > > > OK with comment fixes.
> > > >
> > > > Thanks,
> > > > Uros.
> > > >
> > > > + case CM_LARGE:
> > > > + /* NB: R10 can be used as a scratch register here since
> > > > + R10 is preserved when calling mcount. */
> > > >
> > > > Also mention that R10 can be used as a static chain register and is
> > > > preserved when calling mcount for nested functions.
> > > >
> > > > + fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
> > > > + mcount_name);
> > > > + break;
> > >
> > > This is the patch I am checking in.
> > >
> >
> > For NO_PROFILE_COUNTERS targets, R11 is a scratch register. We can use
> > R10 and R11 to call mcount in large model with PIC.
> >
> > OK for master?
>
> + fprintf (file, "\tmovabsq\t$%s@PLTOFF, %%r11\n",
> + mcount_name);
>
> Please put mcount_name in the same line (and please do the same for
> case CM_MEDIUM_PIC).
Fixed.
> OK with the above fixes.
>
> Thanks,
> Uros.
Here is the updated patch I am checking in.
Thanks.
--
H.J.
[-- Attachment #2: 0001-x86-64-Use-R10-and-R11-for-profiling-large-model-wit.patch --]
[-- Type: text/x-patch, Size: 2489 bytes --]
From a9b5c1263cada2e0b3d59aa8a65b8bbc841775f2 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 8 Jan 2021 05:20:19 -0800
Subject: [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC
For NO_PROFILE_COUNTERS targets, R11 is a scratch register. We can use
R10 and R11 to call mcount in large model with PIC.
gcc/
PR target/98482
* config/i386/i386.c (x86_function_profiler): Use R10 and R11
to call mcount in large model with PIC for NO_PROFILE_COUNTERS
targets.
gcc/testsuite/
PR target/98482
* gcc.target/i386/pr98482-2.c: Updated.
---
gcc/config/i386/i386.c | 12 ++++++++++--
gcc/testsuite/gcc.target/i386/pr98482-2.c | 3 ++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index d3068462fcd..d35af37a49c 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -20806,12 +20806,20 @@ x86_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
mcount_name);
break;
case CM_LARGE_PIC:
+#ifdef NO_PROFILE_COUNTERS
+ fprintf (file, "1:\tmovabsq\t$_GLOBAL_OFFSET_TABLE_-1b, %%r11\n");
+ fprintf (file, "\tleaq\t1b(%%rip), %%r10\n");
+ fprintf (file, "\taddq\t%%r11, %%r10\n");
+ fprintf (file, "\tmovabsq\t$%s@PLTOFF, %%r11\n", mcount_name);
+ fprintf (file, "\taddq\t%%r11, %%r10\n");
+ fprintf (file, "\tcall\t*%%r10\n");
+#else
sorry ("profiling %<-mcmodel=large%> with PIC is not supported");
+#endif
break;
case CM_SMALL_PIC:
case CM_MEDIUM_PIC:
- fprintf (file, "1:\tcall\t*%s@GOTPCREL(%%rip)\n",
- mcount_name);
+ fprintf (file, "1:\tcall\t*%s@GOTPCREL(%%rip)\n", mcount_name);
break;
default:
x86_print_call_or_nop (file, mcount_name);
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-2.c b/gcc/testsuite/gcc.target/i386/pr98482-2.c
index aed3ca4b6ff..0ee142db12c 100644
--- a/gcc/testsuite/gcc.target/i386/pr98482-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr98482-2.c
@@ -2,8 +2,9 @@
/* { dg-require-effective-target mfentry } */
/* { dg-require-effective-target fpic } */
/* { dg-options "-fpic -fprofile -mfentry -O2 -mcmodel=large" } */
+/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__@PLTOFF, %r11\n\taddq\t%r11, %r10\n\tcall\t\\*%r10" } } */
void
func (void)
{
-} /* { dg-message "sorry, unimplemented: profiling '-mcmodel=large' with PIC is not supported" } */
+}
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86-64: Require lp64 for PR target/98482 tests
2021-01-08 14:43 ` H.J. Lu
@ 2021-01-08 16:45 ` H.J. Lu
0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2021-01-08 16:45 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2266 bytes --]
On Fri, Jan 8, 2021 at 6:43 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Jan 8, 2021 at 6:31 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > On Fri, Jan 8, 2021 at 2:28 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Fri, Jan 8, 2021 at 4:50 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > >
> > > > On Fri, Jan 8, 2021 at 1:24 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> > > > >
> > > > > > Since R10 is preserved when calling mcount, R10 can be used a scratch
> > > > > > register to call mcount in large model.
> > > > >
> > > > > Please mention that R10 can be used as a static chain registers and is
> > > > > preserved when calling mcount for nested functions.
> > > > >
> > > > > > gcc/
> > > > > >
> > > > > > PR target/98482
> > > > > > * config/i386/i386.c (x86_function_profiler): Use R10 to call
> > > > > > mcount in large model. Sorry for large model with PIC.
> > > > > >
> > > > > > gcc/testsuite/
> > > > > >
> > > > > > PR target/98482
> > > > > > * gcc.target/i386/pr98482-1.c: New test.
> > > > > > * gcc.target/i386/pr98482-1.c: Likewise.
> > > > >
> > > > > OK with comment fixes.
> > > > >
> > > > > Thanks,
> > > > > Uros.
> > > > >
> > > > > + case CM_LARGE:
> > > > > + /* NB: R10 can be used as a scratch register here since
> > > > > + R10 is preserved when calling mcount. */
> > > > >
> > > > > Also mention that R10 can be used as a static chain register and is
> > > > > preserved when calling mcount for nested functions.
> > > > >
> > > > > + fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
> > > > > + mcount_name);
> > > > > + break;
> > > >
> > > > This is the patch I am checking in.
> > > >
> > >
> > > For NO_PROFILE_COUNTERS targets, R11 is a scratch register. We can use
> > > R10 and R11 to call mcount in large model with PIC.
> > >
> > > OK for master?
> >
> > + fprintf (file, "\tmovabsq\t$%s@PLTOFF, %%r11\n",
> > + mcount_name);
> >
> > Please put mcount_name in the same line (and please do the same for
> > case CM_MEDIUM_PIC).
>
> Fixed.
>
> > OK with the above fixes.
> >
> > Thanks,
> > Uros.
>
> Here is the updated patch I am checking in.
>
I am checking in this patch since -mcmodel=large is isn't
supported for x32.
--
H.J.
[-- Attachment #2: 0001-x86-64-Require-lp64-for-PR-target-98482-tests.patch --]
[-- Type: text/x-patch, Size: 1674 bytes --]
From e7797264b2b8bee6b9a429385d91af0858ee0c8a Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 8 Jan 2021 08:41:38 -0800
Subject: [PATCH] x86-64: Require lp64 for PR target/98482 tests
Require lp64 for PR target/98482 tests since -mcmodel=large is isn't
supported for x32.
PR target/98482
* gcc.target/i386/pr98482-1.c: Require lp64.
* gcc.target/i386/pr98482-1.c: Likewise.
---
gcc/testsuite/gcc.target/i386/pr98482-1.c | 2 +-
gcc/testsuite/gcc.target/i386/pr98482-2.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-1.c b/gcc/testsuite/gcc.target/i386/pr98482-1.c
index 72d5ccb269c..912cbe09191 100644
--- a/gcc/testsuite/gcc.target/i386/pr98482-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr98482-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
/* { dg-require-effective-target mfentry } */
/* { dg-options "-fprofile -mfentry -O2 -mcmodel=large" } */
/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__, %r10\n\tcall\t\\*%r10" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-2.c b/gcc/testsuite/gcc.target/i386/pr98482-2.c
index 0ee142db12c..03c62a4b67b 100644
--- a/gcc/testsuite/gcc.target/i386/pr98482-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr98482-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
/* { dg-require-effective-target mfentry } */
/* { dg-require-effective-target fpic } */
/* { dg-options "-fpic -fprofile -mfentry -O2 -mcmodel=large" } */
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86-64: Use R10 for profiling large model
@ 2021-01-07 23:49 H.J. Lu
0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2021-01-07 23:49 UTC (permalink / raw)
To: gcc-patches
Since R10 is preserved when calling mcount, R10 can be used a scratch
register to call mcount in large model.
gcc/
PR target/98482
* config/i386/i386.c (x86_function_profiler): Use R10 to call
mcount in large model. Sorry for large model with PIC.
gcc/testsuite/
PR target/98482
* gcc.target/i386/pr98482-1.c: New test.
* gcc.target/i386/pr98482-1.c: Likewise.
---
gcc/config/i386/i386.c | 25 +++++++++++++++++++++--
gcc/testsuite/gcc.target/i386/pr98482-1.c | 9 ++++++++
gcc/testsuite/gcc.target/i386/pr98482-2.c | 9 ++++++++
3 files changed, 41 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr98482-1.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr98482-2.c
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fad50e7e537..7a07ab8b5f5 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -20794,8 +20794,29 @@ x86_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
fprintf (file, "\tleaq\t%sP%d(%%rip),%%r11\n", LPREFIX, labelno);
#endif
- if (!TARGET_PECOFF && flag_pic)
- fprintf (file, "1:\tcall\t*%s@GOTPCREL(%%rip)\n", mcount_name);
+ if (!TARGET_PECOFF)
+ {
+ switch (ix86_cmodel)
+ {
+ case CM_LARGE:
+ /* NB: R10 can be used as a scratch register here since
+ R10 is preserved when calling mcount. */
+ fprintf (file, "1:\tmovabsq\t$%s, %%r10\n\tcall\t*%%r10\n",
+ mcount_name);
+ break;
+ case CM_LARGE_PIC:
+ sorry ("profiling %<-mcmodel=large%> with PIC is not supported");
+ break;
+ case CM_SMALL_PIC:
+ case CM_MEDIUM_PIC:
+ fprintf (file, "1:\tcall\t*%s@GOTPCREL(%%rip)\n",
+ mcount_name);
+ break;
+ default:
+ x86_print_call_or_nop (file, mcount_name);
+ break;
+ }
+ }
else
x86_print_call_or_nop (file, mcount_name);
}
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-1.c b/gcc/testsuite/gcc.target/i386/pr98482-1.c
new file mode 100644
index 00000000000..72d5ccb269c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr98482-1.c
@@ -0,0 +1,9 @@
+/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-require-effective-target mfentry } */
+/* { dg-options "-fprofile -mfentry -O2 -mcmodel=large" } */
+/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__, %r10\n\tcall\t\\*%r10" } } */
+
+void
+func (void)
+{
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr98482-2.c b/gcc/testsuite/gcc.target/i386/pr98482-2.c
new file mode 100644
index 00000000000..aed3ca4b6ff
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr98482-2.c
@@ -0,0 +1,9 @@
+/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-require-effective-target mfentry } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-fpic -fprofile -mfentry -O2 -mcmodel=large" } */
+
+void
+func (void)
+{
+} /* { dg-message "sorry, unimplemented: profiling '-mcmodel=large' with PIC is not supported" } */
--
2.29.2
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-01-08 16:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 9:24 [PATCH] x86-64: Use R10 for profiling large model Uros Bizjak
2021-01-08 12:50 ` H.J. Lu
2021-01-08 13:27 ` [PATCH] x86-64: Use R10 and R11 for profiling large model with PIC H.J. Lu
2021-01-08 14:31 ` Uros Bizjak
2021-01-08 14:43 ` H.J. Lu
2021-01-08 16:45 ` [PATCH] x86-64: Require lp64 for PR target/98482 tests H.J. Lu
-- strict thread matches above, loose matches on Subject: below --
2021-01-07 23:49 [PATCH] x86-64: Use R10 for profiling large model H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).