Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-08-04 Thread Yvan Roux
On 11 July 2017 at 12:26, Yvan Roux  wrote:
> On 3 July 2017 at 12:48, Yvan Roux  wrote:
>> On 27 June 2017 at 13:14, Yvan Roux  wrote:
>>> Hi Wilco
>>>
>>> On 27 June 2017 at 12:53, Wilco Dijkstra  wrote:
 Hi Yvan,

> Here is the backport of Wilco's patch (r237607) along with Kyrill's
> one (r244643, which removed the remaining occurences of
> aarch64_nopcrelative_literal_loads).  To fix the issue the original
> patch has to be modified, to keep aarch64_pcrelative_literal_loads
> test for large models in aarch64_classify_symbol.

 The patch looks good to me, however I can't approve it.
>>>
>>> ok thanks for the review.
>>>
> On trunk and gcc-7-branch the :lo12: relocations are not generated
> because of Wilco's fix for pr78733 (r243456 and 243486), but my
> understanding is that the bug is still present since compiling
> gcc.target/aarch64/pr78733.c with -mcmodel=large brings back the
> :lo12: relocations (I'll submit a patch to add the test back if my
> understanding is correct).

 You're right, eventhough -mpc-relative-literal-loads doesn't make much 
 sense
 in the large memory model, it seems best to keep the option orthogonal to
 enable the workaround. I've prepared a patch to fix this on trunk/GCC7.
 It also adds a test which we should add to your changes to GCC6 too.
>>>
>>> ok, I think it is what kugan's proposed earlier today in:
>>>
>>> https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01967.html
>>>
>>> I agree that -mpc-relative-literal-loads and large memory model
>>> doesn't make much sense, now it is what is used in kernel build
>>> system, but if you handle that in a bigger fix already, that's awesome
>>> :)
>>
>> ping?
>> https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01708.html
>
> ping

ping^3

I can include the new testcase added recently on trunk by Wilco
(gcc.target/aarch64/pr79041-2.c) if needed.

>>> Thanks
>>> Yvan
>>>
 Wilco


Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-07-11 Thread Yvan Roux
On 3 July 2017 at 12:48, Yvan Roux  wrote:
> On 27 June 2017 at 13:14, Yvan Roux  wrote:
>> Hi Wilco
>>
>> On 27 June 2017 at 12:53, Wilco Dijkstra  wrote:
>>> Hi Yvan,
>>>
 Here is the backport of Wilco's patch (r237607) along with Kyrill's
 one (r244643, which removed the remaining occurences of
 aarch64_nopcrelative_literal_loads).  To fix the issue the original
 patch has to be modified, to keep aarch64_pcrelative_literal_loads
 test for large models in aarch64_classify_symbol.
>>>
>>> The patch looks good to me, however I can't approve it.
>>
>> ok thanks for the review.
>>
 On trunk and gcc-7-branch the :lo12: relocations are not generated
 because of Wilco's fix for pr78733 (r243456 and 243486), but my
 understanding is that the bug is still present since compiling
 gcc.target/aarch64/pr78733.c with -mcmodel=large brings back the
 :lo12: relocations (I'll submit a patch to add the test back if my
 understanding is correct).
>>>
>>> You're right, eventhough -mpc-relative-literal-loads doesn't make much sense
>>> in the large memory model, it seems best to keep the option orthogonal to
>>> enable the workaround. I've prepared a patch to fix this on trunk/GCC7.
>>> It also adds a test which we should add to your changes to GCC6 too.
>>
>> ok, I think it is what kugan's proposed earlier today in:
>>
>> https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01967.html
>>
>> I agree that -mpc-relative-literal-loads and large memory model
>> doesn't make much sense, now it is what is used in kernel build
>> system, but if you handle that in a bigger fix already, that's awesome
>> :)
>
> ping?
> https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01708.html

ping

>> Thanks
>> Yvan
>>
>>> Wilco


Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-07-03 Thread Yvan Roux
On 27 June 2017 at 13:14, Yvan Roux  wrote:
> Hi Wilco
>
> On 27 June 2017 at 12:53, Wilco Dijkstra  wrote:
>> Hi Yvan,
>>
>>> Here is the backport of Wilco's patch (r237607) along with Kyrill's
>>> one (r244643, which removed the remaining occurences of
>>> aarch64_nopcrelative_literal_loads).  To fix the issue the original
>>> patch has to be modified, to keep aarch64_pcrelative_literal_loads
>>> test for large models in aarch64_classify_symbol.
>>
>> The patch looks good to me, however I can't approve it.
>
> ok thanks for the review.
>
>>> On trunk and gcc-7-branch the :lo12: relocations are not generated
>>> because of Wilco's fix for pr78733 (r243456 and 243486), but my
>>> understanding is that the bug is still present since compiling
>>> gcc.target/aarch64/pr78733.c with -mcmodel=large brings back the
>>> :lo12: relocations (I'll submit a patch to add the test back if my
>>> understanding is correct).
>>
>> You're right, eventhough -mpc-relative-literal-loads doesn't make much sense
>> in the large memory model, it seems best to keep the option orthogonal to
>> enable the workaround. I've prepared a patch to fix this on trunk/GCC7.
>> It also adds a test which we should add to your changes to GCC6 too.
>
> ok, I think it is what kugan's proposed earlier today in:
>
> https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01967.html
>
> I agree that -mpc-relative-literal-loads and large memory model
> doesn't make much sense, now it is what is used in kernel build
> system, but if you handle that in a bigger fix already, that's awesome
> :)

ping?
https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01708.html

> Thanks
> Yvan
>
>> Wilco


Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-06-27 Thread Yvan Roux
Hi Wilco

On 27 June 2017 at 12:53, Wilco Dijkstra  wrote:
> Hi Yvan,
>
>> Here is the backport of Wilco's patch (r237607) along with Kyrill's
>> one (r244643, which removed the remaining occurences of
>> aarch64_nopcrelative_literal_loads).  To fix the issue the original
>> patch has to be modified, to keep aarch64_pcrelative_literal_loads
>> test for large models in aarch64_classify_symbol.
>
> The patch looks good to me, however I can't approve it.

ok thanks for the review.

>> On trunk and gcc-7-branch the :lo12: relocations are not generated
>> because of Wilco's fix for pr78733 (r243456 and 243486), but my
>> understanding is that the bug is still present since compiling
>> gcc.target/aarch64/pr78733.c with -mcmodel=large brings back the
>> :lo12: relocations (I'll submit a patch to add the test back if my
>> understanding is correct).
>
> You're right, eventhough -mpc-relative-literal-loads doesn't make much sense
> in the large memory model, it seems best to keep the option orthogonal to
> enable the workaround. I've prepared a patch to fix this on trunk/GCC7.
> It also adds a test which we should add to your changes to GCC6 too.

ok, I think it is what kugan's proposed earlier today in:

https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01967.html

I agree that -mpc-relative-literal-loads and large memory model
doesn't make much sense, now it is what is used in kernel build
system, but if you handle that in a bigger fix already, that's awesome
:)

Thanks
Yvan

> Wilco


Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-06-27 Thread Wilco Dijkstra
Hi Yvan,

> Here is the backport of Wilco's patch (r237607) along with Kyrill's
> one (r244643, which removed the remaining occurences of
> aarch64_nopcrelative_literal_loads).  To fix the issue the original
> patch has to be modified, to keep aarch64_pcrelative_literal_loads
> test for large models in aarch64_classify_symbol.

The patch looks good to me, however I can't approve it.

> On trunk and gcc-7-branch the :lo12: relocations are not generated
> because of Wilco's fix for pr78733 (r243456 and 243486), but my
> understanding is that the bug is still present since compiling
> gcc.target/aarch64/pr78733.c with -mcmodel=large brings back the
> :lo12: relocations (I'll submit a patch to add the test back if my
> understanding is correct).

You're right, eventhough -mpc-relative-literal-loads doesn't make much sense
in the large memory model, it seems best to keep the option orthogonal to
enable the workaround. I've prepared a patch to fix this on trunk/GCC7.
It also adds a test which we should add to your changes to GCC6 too.

Wilco

Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-06-27 Thread Yvan Roux
Hi,

On 22 June 2017 at 20:42, Yvan Roux  wrote:
> Hi all,
>
> On 16 January 2017 at 16:34, Kyrill Tkachov  
> wrote:
>>
>> On 13/01/17 16:35, James Greenhalgh wrote:
>>>
>>> On Wed, Jan 11, 2017 at 04:32:45PM +, Kyrill Tkachov wrote:

 Hi all,

 In this PR we generated ADRP/ADD instructions with :lo12: relocations on
 symbols even though -mpc-relative-literal-loads is used. This is due to
 the
 confusing double-negative logic of the nopcrelative_literal_loads aarch64
 variable and its relation to the aarch64_nopcrelative_literal_loads
 global
 variable in the GCC 6 branch.

 Wilco fixed this on trunk as part of a larger patch (r237607) and parts
 of
 that patch were backported, but other parts weren't and that patch now
 doesn't apply cleanly to the branch.
>>>
>>> As I commented to Jakub at the time he made the first partial backport,
>>> I'd much rather just see all of Wilco's patch backported. We're not on
>>> the verge of a 6 release now, so please just backport Wilco's patch (as
>>> should have been done all along if this had been correctly identified as
>>> a fix rather than a clean-up).
>>
>>
>> Unfortunately simply backporting the patch does not fix this PR.
>> The aarch64_classify_symbol changes do not have the desired effect
>> and the :lo12: relocations are generated.
>> I'll look into it, but I believe that would require a bigger change than
>> this one-liner.
>
> Here is the backport of Wilco's patch (r237607) along with Kyrill's
> one (r244643, which removed the remaining occurences of
> aarch64_nopcrelative_literal_loads).  To fix the issue the original
> patch has to be modified, to keep aarch64_pcrelative_literal_loads
> test for large models in aarch64_classify_symbol.
>
> On trunk and gcc-7-branch the :lo12: relocations are not generated
> because of Wilco's fix for pr78733 (r243456 and 243486), but my
> understanding is that the bug is still present since compiling
> gcc.target/aarch64/pr78733.c with -mcmodel=large brings back the
> :lo12: relocations (I'll submit a patch to add the test back if my
> understanding is correct).
>
> Cross built and regtested without issue for aarch64-linux-gnu,
> aarch64-none-elf and aarch64_be-none-elf targets
>
> OK for gcc-6-branch ?

Sorry for the fast ping, but since a 6.4 rc1 is planned for tomorrow,
do you think that this fix can be part of it ?

> Thanks
> Yvan
>
> gcc/ChangeLog
> 2017-06-22  Yvan Roux  
>
> PR target/79041
> Backport from mainline
> 2016-06-20  Wilco Dijkstra  
>
> * config/aarch64/aarch64.opt
> (mpc-relative-literal-loads): Rename internal option name.
> * config/aarch64/aarch64.c
> (aarch64_nopcrelative_literal_loads): Rename to
> aarch64_pcrelative_literal_loads.
> (aarch64_expand_mov_immediate): Likewise.
> (aarch64_secondary_reload): Likewise.
> (aarch64_can_use_per_function_literal_pools_p): Likewise.
> (aarch64_classify_symbol): Likewise.
> (aarch64_override_options_after_change_1): Rename and simplify logic.
>
> 2016-01-19  Kyrylo Tkachov  
>
> * config/aarch64/aarch64-protos.h(aarch64_nopcrelative_literal_loads):
> Delete.
> * config/aarch64/aarch64.md
> (aarch64_reload_movcp): Delete reference to
> aarch64_nopcrelative_literal_loads.
> (aarch64_reload_movcp): Likewise.
>
> gcc/testsuite/ChangeLog
> 2017-06-22  Yvan Roux  
>
> PR target/79041
> * gcc.target/aarch64/pr79041.c: New test.


Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-06-22 Thread Yvan Roux
Hi all,

On 16 January 2017 at 16:34, Kyrill Tkachov  wrote:
>
> On 13/01/17 16:35, James Greenhalgh wrote:
>>
>> On Wed, Jan 11, 2017 at 04:32:45PM +, Kyrill Tkachov wrote:
>>>
>>> Hi all,
>>>
>>> In this PR we generated ADRP/ADD instructions with :lo12: relocations on
>>> symbols even though -mpc-relative-literal-loads is used. This is due to
>>> the
>>> confusing double-negative logic of the nopcrelative_literal_loads aarch64
>>> variable and its relation to the aarch64_nopcrelative_literal_loads
>>> global
>>> variable in the GCC 6 branch.
>>>
>>> Wilco fixed this on trunk as part of a larger patch (r237607) and parts
>>> of
>>> that patch were backported, but other parts weren't and that patch now
>>> doesn't apply cleanly to the branch.
>>
>> As I commented to Jakub at the time he made the first partial backport,
>> I'd much rather just see all of Wilco's patch backported. We're not on
>> the verge of a 6 release now, so please just backport Wilco's patch (as
>> should have been done all along if this had been correctly identified as
>> a fix rather than a clean-up).
>
>
> Unfortunately simply backporting the patch does not fix this PR.
> The aarch64_classify_symbol changes do not have the desired effect
> and the :lo12: relocations are generated.
> I'll look into it, but I believe that would require a bigger change than
> this one-liner.

Here is the backport of Wilco's patch (r237607) along with Kyrill's
one (r244643, which removed the remaining occurences of
aarch64_nopcrelative_literal_loads).  To fix the issue the original
patch has to be modified, to keep aarch64_pcrelative_literal_loads
test for large models in aarch64_classify_symbol.

On trunk and gcc-7-branch the :lo12: relocations are not generated
because of Wilco's fix for pr78733 (r243456 and 243486), but my
understanding is that the bug is still present since compiling
gcc.target/aarch64/pr78733.c with -mcmodel=large brings back the
:lo12: relocations (I'll submit a patch to add the test back if my
understanding is correct).

Cross built and regtested without issue for aarch64-linux-gnu,
aarch64-none-elf and aarch64_be-none-elf targets

OK for gcc-6-branch ?

Thanks
Yvan

gcc/ChangeLog
2017-06-22  Yvan Roux  

PR target/79041
Backport from mainline
2016-06-20  Wilco Dijkstra  

* config/aarch64/aarch64.opt
(mpc-relative-literal-loads): Rename internal option name.
* config/aarch64/aarch64.c
(aarch64_nopcrelative_literal_loads): Rename to
aarch64_pcrelative_literal_loads.
(aarch64_expand_mov_immediate): Likewise.
(aarch64_secondary_reload): Likewise.
(aarch64_can_use_per_function_literal_pools_p): Likewise.
(aarch64_classify_symbol): Likewise.
(aarch64_override_options_after_change_1): Rename and simplify logic.

2016-01-19  Kyrylo Tkachov  

* config/aarch64/aarch64-protos.h(aarch64_nopcrelative_literal_loads):
Delete.
* config/aarch64/aarch64.md
(aarch64_reload_movcp): Delete reference to
aarch64_nopcrelative_literal_loads.
(aarch64_reload_movcp): Likewise.

gcc/testsuite/ChangeLog
2017-06-22  Yvan Roux  

PR target/79041
* gcc.target/aarch64/pr79041.c: New test.
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index fa97e29..7b10ff6 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -436,7 +436,6 @@ int aarch64_ccmp_mode_to_code (enum machine_mode mode);
 bool extract_base_offset_in_addr (rtx mem, rtx *base, rtx *offset);
 bool aarch64_operands_ok_for_ldpstp (rtx *, bool, enum machine_mode);
 bool aarch64_operands_adjust_ok_for_ldpstp (rtx *, bool, enum machine_mode);
-extern bool aarch64_nopcrelative_literal_loads;
 
 extern void aarch64_asm_output_pool_epilogue (FILE *, const char *,
 	  tree, HOST_WIDE_INT);
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index e79165b..9b06320 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -152,7 +152,7 @@ enum aarch64_processor aarch64_tune = cortexa53;
 unsigned long aarch64_tune_flags = 0;
 
 /* Global flag for PC relative loads.  */
-bool aarch64_nopcrelative_literal_loads;
+bool aarch64_pcrelative_literal_loads;
 
 /* Support for command line parsing of boolean flags in the tuning
structures.  */
@@ -1703,7 +1703,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
 	 we need to expand the literal pool access carefully.
 	 This is something that needs to be done in a number
 	 of places, so could well live as a separate function.  */
-	  if (aarch64_nopcrelative_literal_loads)
+	  if (!aarch64_pcrelative_literal_loads)
 	{
 	  gcc_assert (can_create_pseudo_p ());
 	  base = gen_reg_rtx (ptr_mode);
@@ -4028,7 +4028,7 @@ 

Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-01-16 Thread Kyrill Tkachov


On 13/01/17 16:35, James Greenhalgh wrote:

On Wed, Jan 11, 2017 at 04:32:45PM +, Kyrill Tkachov wrote:

Hi all,

In this PR we generated ADRP/ADD instructions with :lo12: relocations on
symbols even though -mpc-relative-literal-loads is used. This is due to the
confusing double-negative logic of the nopcrelative_literal_loads aarch64
variable and its relation to the aarch64_nopcrelative_literal_loads global
variable in the GCC 6 branch.

Wilco fixed this on trunk as part of a larger patch (r237607) and parts of
that patch were backported, but other parts weren't and that patch now
doesn't apply cleanly to the branch.

As I commented to Jakub at the time he made the first partial backport,
I'd much rather just see all of Wilco's patch backported. We're not on
the verge of a 6 release now, so please just backport Wilco's patch (as
should have been done all along if this had been correctly identified as
a fix rather than a clean-up).


Unfortunately simply backporting the patch does not fix this PR.
The aarch64_classify_symbol changes do not have the desired effect
and the :lo12: relocations are generated.
I'll look into it, but I believe that would require a bigger change than this 
one-liner.

Thanks,
Kyri


Thanks,
James






Re: [PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-01-13 Thread James Greenhalgh
On Wed, Jan 11, 2017 at 04:32:45PM +, Kyrill Tkachov wrote:
> Hi all,
> 
> In this PR we generated ADRP/ADD instructions with :lo12: relocations on
> symbols even though -mpc-relative-literal-loads is used. This is due to the
> confusing double-negative logic of the nopcrelative_literal_loads aarch64
> variable and its relation to the aarch64_nopcrelative_literal_loads global
> variable in the GCC 6 branch.
> 
> Wilco fixed this on trunk as part of a larger patch (r237607) and parts of
> that patch were backported, but other parts weren't and that patch now
> doesn't apply cleanly to the branch.

As I commented to Jakub at the time he made the first partial backport,
I'd much rather just see all of Wilco's patch backported. We're not on
the verge of a 6 release now, so please just backport Wilco's patch (as
should have been done all along if this had been correctly identified as
a fix rather than a clean-up).

Thanks,
James




[PATCH][AArch64][GCC 6] PR target/79041: Correct -mpc-relative-literal-loads logic in aarch64_classify_symbol

2017-01-11 Thread Kyrill Tkachov

Hi all,

In this PR we generated ADRP/ADD instructions with :lo12: relocations on 
symbols even though -mpc-relative-literal-loads
is used. This is due to the confusing double-negative logic of the
nopcrelative_literal_loads aarch64 variable and its relation to the 
aarch64_nopcrelative_literal_loads global variable
in the GCC 6 branch.

Wilco fixed this on trunk as part of a larger patch (r237607) and parts of that 
patch were backported, but other parts weren't and
that patch now doesn't apply cleanly to the branch.

The actual bug here is that aarch64_classify_symbol uses 
nopcrelative_literal_loads instead of the correct 
aarch64_nopcrelative_literal_loads.
nopcrelative_literal_loads gets set to 1 if the user specifies 
-mpc-relative-literal-loads(!) whereas aarch64_nopcrelative_literal_loads gets
set to false, so that is the variable we want to check.

So this is the minimal patch that fixes this.

Bootstrapped and tested on aarch64-none-linux-gnu on the GCC 6 branch.

Ok for the branch?

Thanks,
Kyrill

2017-01-11  Kyrylo Tkachov  

PR target/79041
* config/aarch64/aarch64.c (aarch64_classify_symbol): Use
aarch64_nopcrelative_literal_loads instead of
nopcrelative_literal_loads.

2017-01-11  Kyrylo Tkachov  

PR target/79041
* gcc.target/aarch64/pr79041.c: New test.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 83dbd57..fa61289 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -9324,7 +9324,7 @@ aarch64_classify_symbol (rtx x, rtx offset)
 	  /* This is alright even in PIC code as the constant
 	 pool reference is always PC relative and within
 	 the same translation unit.  */
-	  if (nopcrelative_literal_loads
+	  if (aarch64_nopcrelative_literal_loads
 	  && CONSTANT_POOL_ADDRESS_P (x))
 	return SYMBOL_SMALL_ABSOLUTE;
 	  else
diff --git a/gcc/testsuite/gcc.target/aarch64/pr79041.c b/gcc/testsuite/gcc.target/aarch64/pr79041.c
new file mode 100644
index 000..a23b1ae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr79041.c
@@ -0,0 +1,26 @@
+/* PR target/79041.  Check that we don't generate the LO12 relocations
+   for -mpc-relative-literal-loads.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcmodel=large -mpc-relative-literal-loads" } */
+
+extern int strcmp (const char *, const char *);
+extern char *strcpy (char *, const char *);
+
+static struct
+{
+  char *b;
+  char *c;
+} d[] = {
+  {"0", "000"}, {"1", "111"},
+};
+
+void
+e (const char *b, char *c)
+{
+  int i;
+  for (i = 0; i < 1; ++i)
+if (!strcmp (d[i].b, b))
+  strcpy (c, d[i].c);
+}
+
+/* { dg-final { scan-assembler-not ":lo12:" } } */