diff options
author | Dan Gohman <gohman@apple.com> | 2008-04-21 23:59:07 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-04-21 23:59:07 +0000 |
commit | 61a921344090457f9429e44c7906ea75ce97e020 (patch) | |
tree | 14e1e665a355f7ff167f531a2bb2d3155f3baa9e /lib/Target/X86/README-X86-64.txt | |
parent | f1f12f91e804d77ed301d006a412c169966e8ac9 (diff) | |
download | llvm-61a921344090457f9429e44c7906ea75ce97e020.tar.gz llvm-61a921344090457f9429e44c7906ea75ce97e020.tar.bz2 llvm-61a921344090457f9429e44c7906ea75ce97e020.tar.xz |
Implement an x86-64 ABI detail of passing structs by hidden first
argument. The x86-64 ABI requires the incoming value of %rdi to
be copied to %rax on exit from a function that is returning a
large C struct.
Also, add a README-X86-64 entry detailing the missed optimization
opportunity and proposing an alternative approach.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/README-X86-64.txt')
-rw-r--r-- | lib/Target/X86/README-X86-64.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Target/X86/README-X86-64.txt b/lib/Target/X86/README-X86-64.txt index 359b83d01a..594a66f832 100644 --- a/lib/Target/X86/README-X86-64.txt +++ b/lib/Target/X86/README-X86-64.txt @@ -236,3 +236,24 @@ on the result of the movb). //===---------------------------------------------------------------------===// +The x86-64 ABI for hidden-argument struct returns requires that the +incoming value of %rdi be copied into %rax by the callee upon return. + +The idea is that it saves callers from having to remember this value, +which would often require a callee-saved register. Callees usually +need to keep this value live for most of their body anyway, so it +doesn't add a significant burden on them. + +We currently implement this in codegen, however this is suboptimal +because it means that it would be quite awkward to implement the +optimization for callers. + +A better implementation would be to relax the LLVM IR rules for sret +arguments to allow a function with an sret argument to have a non-void +return type, and to have the front-end to set up the sret argument value +as the return value of the function. The front-end could more easily +emit uses of the returned struct value to be in terms of the function's +lowered return value, and it would free non-C frontends from a +complication only required by a C-based ABI. + +//===---------------------------------------------------------------------===// |