This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/66655] New: [5.1 Regression] miscompilation due to ipa-ra on MinGW
- From: "amonakov at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Jun 2015 18:44:27 +0000
- Subject: [Bug target/66655] New: [5.1 Regression] miscompilation due to ipa-ra on MinGW
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66655
Bug ID: 66655
Summary: [5.1 Regression] miscompilation due to ipa-ra on
MinGW
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: amonakov at gcc dot gnu.org
Target Milestone: ---
Target: x86_64-w64-mingw32
Created attachment 35846
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35846&action=edit
testcase
Attached is a testcase that, when compiled with a MinGW GCC 5.1, aborts on
execution. Swapping the order of .o files in the final link, or compiling
main.cc with -O2 will produce a correct executable.
The failure is caused by interplay of -fipa-ra (enabled by default at -O2) and
MinGW's treatment of symbols that would normally be weak on ELF platforms.
When compiling c.cc, ipa-ra does not save/restore %rax around the call to
S::set (a static inline class method), apparently since the body emitted in
that translation unit does not indeed clobber %rax and is not considered
replaceable. On Linux, S::set is weak and optimization is not performed.
However, S::set is also emitted when compiling main.cc, and its copy in main.o
clobbers %rax since optimization is not enabled. During final link, the copy of
S::set from main.o is used, producing a broken executable.
(this issue is reduced from a miscompiled Clang produced by mingw-w64 5.1
cross-compiler)