This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/6810: GCC 3.1 generates incorrect code if -O2 -mcpu=pentium3 -fomit-frame-pointer are specified



>Number:         6810
>Category:       optimization
>Synopsis:       GCC 3.1 generates incorrect code if -O2 -mcpu=pentium3 -fomit-frame-pointer are specified
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri May 24 21:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Peter Joachim
>Release:        gcc version 3.1
>Organization:
>Environment:
Windows NT 4.0 SP6, Pentium III (Coppermine) 850 MHz, Cygwin
>Description:
Compiling the code sample using -O2 -march=pentium3 -fomit-frame-pointer generates code that does not correctly calculate the addresses of local variables.
Namely the address of local array c1 in testfunc2 is not correctly passed to dummy_func.
The reason is the leal instruction (*) in the prologue to testfunc2 that incorrectly appears before _alloca is called, but should be placed after the _alloca call.
_testfunc2:
        pushl   %ebp
        movl    $24076, %eax
        pushl   %edi
        pushl   %esi
        pushl   %ebx
        leal    18064(%esp), %esi (*)
        call    __alloca
        movl    %esi, 8(%esp)
>How-To-Repeat:
Correct code is generated with -fno-omit-frame-pointer:
$ gcc -Wall -O2 -march=pentium3 -fno-omit-frame-pointer -fverbose-asm bugofp.i -o bugofp.exe
$ ./bugofp.exe
a1a1a1a1 a2a2a2a2 a3a3a3a3 a4a4a4a4 a5a5a5a5 a6a6a6a6 a7a7a7a7 a8a8a8a8 a9a9a9a9 aaaaaaaa abababab acacacac

-fomit-frame-pointer triggers the bug:
$ gcc -Wall -O2 -march=pentium3 -fomit-frame-pointer -fverbose-asm bugofp.i -o bugofp.exe
$ ./bugofp.exe
a1a1a1a1 a2a2a2a2 0 a4a4a4a4 a5a5a5a5 a6a6a6a6 a7a7a7a7 a8a8a8a8 a9a9a9a9 aaaaaaaa abababab acacacac
>Fix:
Don't specify -march=pentium3 -fomit-frame-pointer
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bugofp.i.bz2"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bugofp.i.bz2"

QlpoOTFBWSZTWQrPLYoABYpfgH06W////5MkAg6/79/6YBA+8BufcPb7u7CVmvs1u8gLK9t3vZp9
9fcPVNAyfVt2z616A64qHEcMSCMiNT0ap6n6TFPU2U9T9JH6p6h6IAAAAaapvUyhQaaA9T1GgGgD
QAAaA0aAkJTJNU9Ro9T1PSA8mkxqGgAAABoASaSRNEIxJ6JpH+qT0EGgNB6J6gDR6jJoIklNIymT
0wmTRPJGygGjQ0ADIAASIQhDRMCjFT2TTSQPRA0aNPSAGjJuOFjCMEZIwJEgeikoijAV2gdWdUKy
CyfewPvTZbSgjF8NskzYpXChVhtr/GaEgw1Y2pfhyUtbR9zfeMrJpU2c6zSTNIJEk0gpUrWMbWta
VLZrLzIq9J00YqiRVYqWhVYiqDqlQKJbZUhUAWSCxZEcS4oolJSlrFtpWrRosbSopWKFSU43n+ad
NpJ3SQkm8ICxEgEdCJSIA3zRw4MMMGuRiuPW9QhBINRTFuA0uhOJVCbuqCJyiQaWNmGLPsDAYB8Y
fQG9hgEtaBAn7alM8U0vrHW7ks2WMWCQ2VQxIrcykxIouTlQ3ammESSfwHG1bLV2ru30CWakNYqo
1qx/MslVFVwgz7AfNo4yKUtbVkSVCrC0uNhlkBjJHExBEyMQtK0qgjRssEaLdqGCGaC3LIraU4tV
8tOxpZqe8JygcHge3iAfyPUTwYHkg9Ih4hYLBYpmGkkNSFEYSSUKSksJmY+RvX/Dx7Z8AVFQCrha
PI7gPsaO3BXNpeqadcNVUkkkk5Jx8nJuviBfJ5ZscbmOWWtHK+qT4RFG2BYyV9jjBRQWfiZUNWrU
hFqQqkOV2Uctsyts8qCcMw9r5EwXjVEh7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bBvptg9cHRE44t6NoB
UQzAF9wITXOIAxgoZUV7aJfhcVjzzW6RvYpWq1loipuHYhvaOwd5Y1xwAFjAb0AlvCAzOuxAdznB
mS21q+8BjYjkB0kU2bbbb4GRoTztHi16Ftx0r380j53qYJBNLxYh4a3c1RgkrVIQaoFrEKXHp06G
uHtUtVrBQVCzp2tGxH/F3JFOFCQCs8tigA==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]