]> granicus.if.org Git - clang/commit
IRgen/ABI/x86_64: Avoid passing small structs using byval sometimes.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 10 Mar 2012 01:03:58 +0000 (01:03 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 10 Mar 2012 01:03:58 +0000 (01:03 +0000)
commitedfac0302490d84419eb958c812c533b8df29785
treed7a79c2136df260ecca0d746a65f33bfb9961112
parentd1c84d3c0206abdf8787dc5c00aaf3b016ed3226
IRgen/ABI/x86_64: Avoid passing small structs using byval sometimes.

 - We do this when it is easy to determine that the backend will pass them on
   the stack properly by itself.

Currently LLVM codegen is really bad in some cases with byval, for example, on
the test case here (which is derived from Sema code, which likes to pass
SourceLocations around)::

  struct s47 { unsigned a; };
  void f47(int,int,int,int,int,int,struct s47);
  void test47(int a, struct s47 b) { f47(a, a, a, a, a, a, b); }

we used to emit code like this::

  ...
  movl %esi, -8(%rbp)
  movl -8(%rbp), %ecx
  movl %ecx, (%rsp)
  ...

to handle moving the struct onto the stack, which is just appalling.

Now we generate::

  movl %esi, (%rsp)

which seems better, no?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152462 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/TargetInfo.cpp
test/CodeGen/complex-indirect.c
test/CodeGen/x86_64-arguments.c