[Bug target/69140] stack alignment + O1 breaks with Microsoft ABI

2016-01-06 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69140

--- Comment #14 from Justas L  ---
(In reply to Uroš Bizjak from comment #13)
> Justas, can you please test the following patch

Thank you, it indeed solves the problem.

[Bug target/69140] stack alignment + O1 breaks with Microsoft ABI

2016-01-06 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69140

--- Comment #16 from Justas L  ---
(In reply to Uroš Bizjak from comment #15)
> Please also do some runtime tests, I don't have the Wine source here ...

Wine compiles and runs with no apparent issues.

[Bug target/69140] stack alignment + O1 breaks with Microsoft ABI

2016-01-05 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69140

--- Comment #7 from Justas L  ---
(In reply to Eric Botcazou from comment #5)
> As expected, reverting the patch doesn't change anything on the 5 branch, so
> I'd suggest either filling a bug report for 'git bisect' or double checking
> its result next time.

Sorry, I indeed made a mistake - r230176 makes compilation fail with a
different error than the one I get with 5.3 release. However, after rerunning
git bisect and manually checking these revisions I can confirm that:

- r230165 is the last good revision in the 5 branch;
- r230176 is the first one that fails, but with a different error (internal
compiler error: in ix86_adjust_stack_and_probe, at config/i386/i386.c:11064);
- r230247 is the first one that fails with the error in choose_baseaddr;
- reverting r230176 from 5.3.0 release fixes the problem (i.e. both testcases
pass and Wine compiles and runs correctly)

Also, passing -v to the testcases shows that these additional options are
included by default, presumably from some distro (Arch) configuration:

-mtune=generic -march=x86-64 -fPIE -fstack-check=specific
-fstack-protector-strong

[Bug target/69140] stack alignment + O1 breaks with Microsoft ABI

2016-01-05 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69140

--- Comment #9 from Justas L  ---
Yes, forced stack alignment on x86_64 was introduced after 5.2, in r228728 for
pr66697. Also, I can confirm that adding -fno-omit-frame-pointer allows Wine to
compile normally.

[Bug target/69140] [5/6 regression] Stack alignment + O1 breaks on x86_64 [introduced by r230176 ]

2016-01-04 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69140

--- Comment #2 from Justas L  ---
Created attachment 37221
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37221=edit
testcase

This testcase throws the error when compiled with:

gcc -c -O2 -mincoming-stack-boundary=3 crypt_md4.i

[Bug target/69140] New: [5.3 regression] Stack alignment + O1 breaks on x86_64 [introduced by r230176 ]

2016-01-04 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69140

Bug ID: 69140
   Summary: [5.3 regression] Stack alignment + O1 breaks on x86_64
[introduced by r230176 ]
   Product: gcc
   Version: 5.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bucaneer at gmail dot com
  Target Milestone: ---

Compilation of 64bit Wine with GCC 5.3 fails when using both stack realignment
(-mincoming-stack-boundary=3) and optimization (-O1 or higher):

---
../../../wine/dlls/advapi32/crypt_md4.c:134:1: internal compiler error: in
choose_baseaddr, at config/i386/i386.c:10412
---

which refers to this assert in choose_baseaddr:

---
gcc_assert (base_reg != NULL);
---

This worked fine in some pre-5.3 dev builds (as confirmed when testing bug
66697 fix). git bisect identifies r230176 as the cause of the regression:

---
commit 6ca53fc513f4efdca56af52439ffc5a49b9e6e21
Author: ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Nov 11 14:56:17 2015 +

PR target/67265
* ira.c (ira_setup_eliminable_regset): Do not necessarily create the
frame pointer for stack checking if non-call exceptions aren't used.
* config/i386/i386.c (ix86_finalize_stack_realign_flags): Likewise.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@230176
138bc75d-0d04-0410-961f-82ee72b054a4
---

[Bug target/69140] [5/6 regression] Stack alignment + O1 breaks on x86_64 [introduced by r230176 ]

2016-01-04 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69140

--- Comment #3 from Justas L  ---
Created attachment 37222
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37222=edit
testcase2

The previous testcase fails only with -O2 or higher; this one fails with -O1:

gcc -c -O1 -mincoming-stack-boundary=3 chain.i

[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-07 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

--- Comment #24 from Justas L  ---
Oh, OK. I was looking at the patched code and forgot that part was patched.


[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-07 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

--- Comment #21 from Justas L  ---
(In reply to H.J. Lu from comment #20)
> -mstackrealign works correctly as designed on x86-64.  The
> issue is MIN_STACK_BOUNDARY.  When MIN_STACK_BOUNDARY is 128,
> you don't need to realign the stack if you only need 128-bit
> stack alignment.

When is MIN_STACK_BOUNDARY equal to 128? I thought it defaulted to 64 (8*8) for
x86_64 and 32 (4*8) for x86, no?


[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-06 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

--- Comment #17 from Justas L  ---
Yes, this one works fine too.


[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-06 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

--- Comment #18 from Justas L  ---
Out of curiosity, what could it be that makes -mincoming-stack-boundary=3
successfully deal with rogue code while -mstackrealign fails at that? Shouldn't
-mstackrealign do the same job without being told what the outside stack
alignment is, or am I misunderstanding it?


[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-06 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

--- Comment #12 from Justas L  ---
This one does not apply neatly on 5.2.0 and I have trouble getting the dev
version to compile, so I can't test it. Any chance of a backport?


[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-06 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

Justas L  changed:

   What|Removed |Added

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

--- Comment #14 from Justas L  ---
The backported patch works fine and does fix multiple instances of the Wine
issue. Marking the report as resolved.


[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-05 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

--- Comment #8 from Justas L  ---
I applied the first (testing) version of the patch on gcc 5.2.0 release source
(with slight modifications to make it apply). All new features work as
expected, as per the test in comment #2. However, compiling Wine with either
-mstackrealign or -mincoming-stack-boundary=3 fails, throwing this error:

-
../../../wine/dlls/dxerr8/dxerr8.c:135:1: internal compiler error: in
ix86_compute_frame_layout, at config/i386/i386.c:10212
-

which refers to this line in i386.c:

-
gcc_assert (INCOMING_STACK_BOUNDARY >= 128);
-

Commenting out the assert allows Wine to compile normally. (I assume the
correct fix would be to change the number to 64.) And compiling Wine with
-mincoming-stack-boundary=3 does fix the original issue (or at least the one
instance of it that I care about). So the gcc side of the issue is almost
resolved, with just the assert left to address.


[Bug target/66697] Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-10-04 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

--- Comment #4 from Justas L  ---
I haven't tested this yet, but I understand this global solution would affect
the performance of ALL functions, not only those that interface with outside
code, correct?

Wine already assigns the force_align_arg_pointer attribute to vulnerable
functions, so making it work for x86_64 would be the better, less disruptive
solution.


[Bug target/66697] New: Feature request: -mstackrealign and force_align_arg_pointer for x86_64

2015-06-29 Thread bucaneer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66697

Bug ID: 66697
   Summary: Feature request: -mstackrealign and
force_align_arg_pointer for x86_64
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bucaneer at gmail dot com
  Target Milestone: ---

-mstackrealign option and force_align_arg_pointer attribute work for 32bit x86,
but not x86_64.

In particular, this makes Wine unable to deal with some untidy 64bit Windows
apps: https://bugs.winehq.org/show_bug.cgi?id=27680