[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-06 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

Richard Biener  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #14 from Richard Biener  ---
Fixed.  Latent on branches of course, but lets wait for fallout at least.

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-06 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #13 from CVS Commits  ---
The master branch has been updated by Richard Biener :

https://gcc.gnu.org/g:b5254d6b75fe6be669396cd1261f1cba829cc451

commit r12-558-gb5254d6b75fe6be669396cd1261f1cba829cc451
Author: Richard Biener 
Date:   Wed May 5 10:15:27 2021 +0200

ipa/100373 - fix emutls lowering compare-debug issue

emutls figured that tls uses in debug-insns need lowering but
that obviously has effects on code-generation as can be seen
in the following IL diff with the new testcase:

[local count: 1073741824]:
-  a = 0;
+  # DEBUG BEGIN_STMT
   _4 = __builtin___emutls_get_address (&__emutls_v.b);
+  # DEBUG D#1 => *_4
+  # DEBUG d => (long int) D#1
+  # DEBUG BEGIN_STMT
+  a = 0;
+  # DEBUG BEGIN_STMT
   *_4 = 0;
   return;

where it figured the debug use of b in the original

   [local count: 1073741824]:
  # DEBUG BEGIN_STMT
  # DEBUG D#1 => b
  # DEBUG d => (long int) D#1
  # DEBUG BEGIN_STMT
  a = 0;

needs lowering (it maybe does when we want to produce perfect
debug but that's just bad luck).

The following patch fixes this by avoiding to create a new
emutls address when visiting debug stmts and instead resets them.
Another option might be to simply not lower debug stmt uses
but I have no way to verify actual debug info for this.

2021-05-05  Richard Biener  

PR ipa/100373
* tree-emutls.c (gen_emutls_addr): Pass in whether we're
dealing with a debug use and only query existing addresses
if so.
(lower_emutls_1): Avoid splitting out addresses for debug
stmts, reset the debug stmt when we fail to find existing
lowered addresses.
(lower_emutls_phi_arg): Set wi.stmt.

* gcc.dg/pr100373.c: New testcase.

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-05 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #12 from Iain Sandoe  ---
(In reply to Richard Biener from comment #11)
> Created attachment 50759 [details]
> updated patch
> 
> Fixed missing setting of wi.stmt in lower_emutls_phi_arg

I regstrapped r12-248+ first patch (I added the wi-stmt by hand) c.f. r12-247
and (a) bootstrap succeeded for patched (b) the testsuite showed nothing
unexpected.  This was on x86_64-darwin19, but I have no reason to expect any
significance to that version (or even arch).

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-05 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

Richard Biener  changed:

   What|Removed |Added

  Attachment #50756|0   |1
is obsolete||

--- Comment #11 from Richard Biener  ---
Created attachment 50759
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50759=edit
updated patch

Fixed missing setting of wi.stmt in lower_emutls_phi_arg

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-05 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #10 from Iain Sandoe  ---
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x0)
frame #0: 0x0001016a4bb3 cc1`::gimple_code(g=0x) at
gimple.h:1782
   1779 static inline enum gimple_code
   1780 gimple_code (const gimple *g)
   1781 {
-> 1782   return g->code;
   1783 }
   1784 
   1785 
Target 0: (cc1) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x0)
  * frame #0: 0x0001016a4bb3 cc1`::gimple_code(g=0x) at
gimple.h:1782
frame #1: 0x0001016a4f4f cc1`::is_gimple_debug(gs=0x)
at gimple.h:4773
frame #2: 0x0001016a7111 cc1`::lower_emutls_1(ptr=0x0001030d4358,
walk_subtrees=0x7ffeefbff2d4, cb_data=0x7ffeefbff370) at
tree-emutls.c:483
frame #3: 0x000101a76f53 cc1`walk_tree_1(tp=0x0001030d4358,
func=(cc1`::lower_emutls_1(tree *, int *, void *) at tree-emutls.c:457),
data=0x7ffeefbff370, pset=0x,
lh=0x)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) at tree.c:10959
frame #4: 0x0001016a75e3
cc1`::lower_emutls_phi_arg(phi=0x0001030d4300, i=0, d=0x7ffeefbff420)
at tree-emutls.c:601
frame #5: 0x0001016a77e3
cc1`::lower_emutls_function_body(node=0x000103045770) at tree-emutls.c:668
frame #6: 0x0001016a7ef4 cc1`::ipa_lower_emutls() at tree-emutls.c:806
frame #7: 0x0001016a7fe7
cc1`pass_ipa_lower_emutls::execute(this=0x00014530fa00,
(null)=0x) const at tree-emutls.c:846
frame #8: 0x0001014192cd cc1`execute_one_pass(pass=0x00014530fa00)
at passes.c:2567
frame #9: 0x00010141a39b
cc1`execute_ipa_pass_list(pass=0x00014530fa00) at passes.c:2996
frame #10: 0x000100cbb711 cc1`::ipa_passes() at cgraphunit.c:2154

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-05 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #9 from Richard Biener  ---
Created attachment 50756
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50756=edit
patch

This patch survives the new testcase with a cc1 cross to darwin and it does
produce expected results when I mangle it in different ways to hopefully catch
all paths in the code.

Actual bootstrap & regtest on a emutls target appreciated.

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-05 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

Richard Biener  changed:

   What|Removed |Added

   Last reconfirmed|2021-05-01 00:00:00 |2021-05-05
 Status|UNCONFIRMED |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org
 Ever confirmed|0   |1

--- Comment #8 from Richard Biener  ---
The difference appears in the IPA emultls pass:

--- a/t.i.072i.emutls   2021-05-05 10:07:19.344748567 +0200
+++ b/t.i.072i.emutls   2021-05-05 10:07:09.104642849 +0200
@@ -5,8 +5,13 @@
   int * _4;

[local count: 1073741824]:
-  a = 0;
+  # DEBUG BEGIN_STMT
   _4 = __builtin___emutls_get_address (&__emutls_v.b);
+  # DEBUG D#1 => *_4
+  # DEBUG d => (long int) D#1
+  # DEBUG BEGIN_STMT
+  a = 0;
+  # DEBUG BEGIN_STMT
   *_4 = 0;
   return;

I will have a closer look.

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-04 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #7 from Iain Sandoe  ---
of course, this could be exposing some prexisting problem (but i did check that
the previous revision did not show the problem).  -fno-ipa-ra makes no
difference.

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-04 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #6 from Iain Sandoe  ---
master @r12-438 doesn't fail compare debug (maybe some later change masks this)
 I think this will reproduce on a stage 1..

reduced:

a;
_Thread_local b;
c() {
  long d = b;
  a = 0;
  b = 0;
}

cc1 -fpreprocessed gmp_op.i -O2 -gtoggle -quiet -o a.s
cc1 -fpreprocessed gmp_op.i -O2 -quiet -o b.s
...

a.o.stripped:
(__TEXT,__text) section
_c:
subq$0x8, %rsp
0004leaq(%rip), %rdi
000bcallq   0x10
0010movl$0x0, -0x4(%rip)
001amovl$0x0, (%rax)
0020addq$0x8, %rsp
0024retq


b.o.stripped:
(__TEXT,__text) section
_c:
subq$0x8, %rsp
0004leaq(%rip), %rdi
000bmovl$0x0, -0x4(%rip)
0015callq   0x1a
001amovl$0x0, (%rax)
0020addq$0x8, %rsp
0024retq

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-04 Thread rguenther at suse dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #5 from rguenther at suse dot de  ---
On Tue, 4 May 2021, iains at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373
> 
> --- Comment #4 from Iain Sandoe  ---
> (In reply to Iain Sandoe from comment #3)
> > (In reply to Richard Biener from comment #2)
> > > Doesn't reproduce on x86_64-linux with bootstrapping with in-tree mpfr 
> > > 4.1.0
> > 
> > it might well be some corner-case, but Darwin is PIC by default, so it might
> > be worth trying --with-pic ?
> 
> and -gstrict-dwarf, -gdwarf-2

That shouldn't really matter.  If you have preprocessed source of
a miscomparing object and you can reproduce with that and
-fcompare-debug + options that would be a good first step.
Then creduce the result and look where it differs in code generation.

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-04 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #4 from Iain Sandoe  ---
(In reply to Iain Sandoe from comment #3)
> (In reply to Richard Biener from comment #2)
> > Doesn't reproduce on x86_64-linux with bootstrapping with in-tree mpfr 4.1.0
> 
> it might well be some corner-case, but Darwin is PIC by default, so it might
> be worth trying --with-pic ?

and -gstrict-dwarf, -gdwarf-2

(I do plan to bump the default to DWARF-4 for macOS 10.10+ during GCC12 but
it's tricky on the older systems without configury tests for suitable dsymutil
- those are written and mostly tested, but still in my Q)

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-04 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #3 from Iain Sandoe  ---
(In reply to Richard Biener from comment #2)
> Doesn't reproduce on x86_64-linux with bootstrapping with in-tree mpfr 4.1.0

it might well be some corner-case, but Darwin is PIC by default, so it might be
worth trying --with-pic ?

failing that, I'll have to figure out some way to debug it...

(the CPU was not, in the end relevant, it was more that on the older machines I
hadn't updated GMP & friends to newer versions.)

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-04 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #2 from Richard Biener  ---
Doesn't reproduce on x86_64-linux with bootstrapping with in-tree mpfr 4.1.0

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-03 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |UNCONFIRMED
 Ever confirmed|1   |0
 CC||rguenth at gcc dot gnu.org
   Target Milestone|--- |12.0
Version|unknown |12.0

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-02 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

--- Comment #1 from Iain Sandoe  ---
this happens with mpfr-4.x sources and not with mpfr-3.1.6.

[Bug bootstrap/100373] [12 Regression] Darwin, Compare-debug fail after r12-248-gb58dc0b803057

2021-05-01 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100373

Iain Sandoe  changed:

   What|Removed |Added

   Keywords||build
 Target||x86_64-darwin
   Last reconfirmed||2021-05-01
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW