Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen problem with 'complex' type on x86/linux #1362

Closed
nlewycky opened this issue Nov 8, 2006 · 10 comments
Closed

codegen problem with 'complex' type on x86/linux #1362

nlewycky opened this issue Nov 8, 2006 · 10 comments
Labels
backend:X86 bugzilla Issues migrated from bugzilla miscompilation

Comments

@nlewycky
Copy link
Contributor

nlewycky commented Nov 8, 2006

Bugzilla Link 990
Resolution FIXED
Resolved on Nov 07, 2018 00:17
Version 1.9
OS Linux
CC @asl

Extended Description

I've noticed a pattern in my testcase failures involving "csretcc". The bug
occurs with a simple testcase from the "cexp" man page:

// RUN: %llvmgcc -O2 -lm %s -o %s.exe
// RUN: ./%s.exe | grep "-1.000000+0.000000*i"
#include <stdio.h>

/* check that exp(ipi) == -1 /
#include <math.h> /
for atan /
#include <complex.h>
int main(void) {
double pi = 4
atan(1);
complex z = cexp(I
pi);
printf("%f+%f*i\n", creal(z), cimag(z));
}

With LLVM, this produces:

$ llvm-gcc -O0 csretcc.c -lm -o csretcc
$ ./csretcc
0.000000+0.000000*i
Segmentation fault

while with GCC, it works:

$ gcc -O0 csretcc.c -lm -o csretcc
$ ./csretcc
-1.000000+0.000000*i

In the bytecode, the call to "cexp" is called with "csretcc" calling convention.

@lattner
Copy link
Collaborator

lattner commented Nov 8, 2006

I don't have access to a linux box. Can you compile the reduced testcase at -O3 with both llvm and gcc
and include the output .s files?

Thanks,

-Chris

@nlewycky
Copy link
Contributor Author

nlewycky commented Nov 8, 2006

@nlewycky
Copy link
Contributor Author

nlewycky commented Nov 8, 2006

@asl
Copy link
Collaborator

asl commented Nov 9, 2006

LLVM definitely doesn't clean up stack properly. Adding "subl $4, esp" after
"call cexp" fixes llvm assembler output.

@asl
Copy link
Collaborator

asl commented Nov 9, 2006

Everything is ok for mingw32 target. It seems, something went odd in
X86TargetLowering::LowerCCCArguments() and X86TargetLowering::LowerCCCCallTo().
Do we need to use hidden pointer on Linux the same way as on Darwin?

@asl
Copy link
Collaborator

asl commented Nov 9, 2006

One small addition: "everything is ok for mingw32" was just because of
verboseless of wine. It just doesn't report any problems :) Stack adjustment is
also needed there.

@lattner
Copy link
Collaborator

lattner commented Nov 9, 2006

Looks like we'll need to tweak struct return lowering a bit for linux. Unfortunately it's too late for this to
hit 1.9 safely, but we can do this for 2.0.

-Chris

@asl
Copy link
Collaborator

asl commented Nov 9, 2006

Well, not only for linux but for mingw32 too. I'll try to figure out, what's
happening there.

@asl
Copy link
Collaborator

asl commented Nov 10, 2006

Fixed with
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061106/039746.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061106/039747.html

Will check linux nightlytesters for newly passed tests (should be at least
fftbench & bigfib).

@asl
Copy link
Collaborator

asl commented Nov 10, 2006

Well, comparing Reid's current nightly test status and the same from prev. days,
it seems, that 'Benchmarks/CoyoteBench/fftbench' and Benchmarks/Misc-C++/bigfib
are now running ok on linux. Hope, everything will be ok :)

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
jeanPerier pushed a commit to jeanPerier/llvm-project that referenced this issue Jan 4, 2022
[NFC] Standardize the use of SomeExpr in lowering.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla miscompilation
Projects
None yet
Development

No branches or pull requests

3 participants