1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-29 23:12:55 +01:00
llvm-mirror/lib
Chris Lattner 9aec97df10 Implement an annoying part of the Darwin/X86 abi: the callee of a struct
return argument pops the hidden struct pointer if present, not the caller.

For example, in this testcase:

struct X { int D, E, F, G; };
struct X bar() {
  struct X a;
  a.D = 0;
  a.E = 1;
  a.F = 2;
  a.G = 3;
  return a;
}
void foo(struct X *P) {
  *P = bar();
}

We used to emit:

_foo:
        subl $28, %esp
        movl 32(%esp), %eax
        movl %eax, (%esp)
        call _bar
        addl $28, %esp
        ret
_bar:
        movl 4(%esp), %eax
        movl $0, (%eax)
        movl $1, 4(%eax)
        movl $2, 8(%eax)
        movl $3, 12(%eax)
        ret

This is correct on Linux/X86 but not Darwin/X86.  With this patch, we now
emit:

_foo:
        subl $28, %esp
        movl 32(%esp), %eax
        movl %eax, (%esp)
        call _bar
***     addl $24, %esp
        ret
_bar:
        movl 4(%esp), %eax
        movl $0, (%eax)
        movl $1, 4(%eax)
        movl $2, 8(%eax)
        movl $3, 12(%eax)
***     ret $4

For the record, GCC emits (which is functionally equivalent to our new code):

_bar:
        movl    4(%esp), %eax
        movl    $3, 12(%eax)
        movl    $2, 8(%eax)
        movl    $1, 4(%eax)
        movl    $0, (%eax)
        ret     $4
_foo:
        pushl   %esi
        subl    $40, %esp
        movl    48(%esp), %esi
        leal    16(%esp), %eax
        movl    %eax, (%esp)
        call    _bar
        subl    $4, %esp
        movl    16(%esp), %eax
        movl    %eax, (%esi)
        movl    20(%esp), %eax
        movl    %eax, 4(%esi)
        movl    24(%esp), %eax
        movl    %eax, 8(%esi)
        movl    28(%esp), %eax
        movl    %eax, 12(%esi)
        addl    $40, %esp
        popl    %esi
        ret

This fixes SingleSource/Benchmarks/CoyoteBench/fftbench with LLC and the
JIT, and fixes the X86-backend portion of PR729.  The CBE still needs to
be updated.

llvm-svn: 28438
2006-05-23 18:50:38 +00:00
..
Analysis Remove dead variable 2006-05-12 17:41:45 +00:00
AsmParser Regenerate 2006-05-19 21:28:53 +00:00
Bytecode Fix misencoding of calling conventions 2006-05-19 21:57:37 +00:00
CodeGen -enable-unsafe-fp-math implies -enable-finite-only-fp-math 2006-05-23 18:18:46 +00:00
Debugger Add the README files to the distribution. 2006-04-13 06:39:24 +00:00
ExecutionEngine Make this print the right start pointer 2006-05-16 06:45:50 +00:00
Linker Add shufflevector support 2006-04-08 01:19:47 +00:00
Support For PR777: 2006-05-15 22:12:42 +00:00
System Bug noticed, by inspection. Filename can be null. 2006-05-14 19:00:53 +00:00
Target Implement an annoying part of the Darwin/X86 abi: the callee of a struct 2006-05-23 18:50:38 +00:00
Transforms Silence a bogus gcc warning 2006-05-20 23:14:03 +00:00
VMCore Print csretcc calls like this: 2006-05-19 21:58:52 +00:00
Makefile Make some changes suggested by Chris: 2006-05-17 22:55:35 +00:00