[llvm-bugs] [Bug 33075] Assignment to struct passed by value modifies caller's stack frame

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 17 10:38:05 PDT 2017


Reid Kleckner <rnk at google.com> changed:

           What    |Removed                     |Added
                 CC|                            |rnk at google.com
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Reid Kleckner <rnk at google.com> ---
This is correct behavior. The caller should not expect arguments passed in
memory to retain their original values, just as it would not expect the
argument registers to be preserved.

GCC does the same thing:

I had to modify the example to escape 's' to preserve the dead store of 666.

ABIs have been this way forever. Legacy ABIs (32-bit x86) pass all arguments in
memory, and for those ABIs, compilers typically store to argument memory at
-O0. They don't do a copy.


$ echo 'void f(int a) { ++a; }' | gcc -x c - -m32 -S -o -
        .file   ""
        .globl  _f
        .def    _f;     .scl    2;      .type   32;     .endef
        pushl   %ebp
        movl    %esp, %ebp
        addl    $1, 8(%ebp)
        popl    %ebp

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170517/99b7344c/attachment.html>

More information about the llvm-bugs mailing list