https://bugs.llvm.org/show_bug.cgi?id=33075

Reid Kleckner <r...@google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r...@google.com
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Reid Kleckner <r...@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:
https://godbolt.org/g/vZybVN

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.

Consider:

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to