Open Quuxplusone opened 3 years ago
Bugzilla Link | PR51963 |
Status | NEW |
Importance | P enhancement |
Reported by | David Bolvansky (david.bolvansky@gmail.com) |
Reported on | 2021-09-24 15:13:20 -0700 |
Last modified on | 2021-09-25 09:20:39 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | florian_hahn@apple.com, johannes@jdoerfert.de, llvm-bugs@lists.llvm.org, nikita.ppv@gmail.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
struct a
{
int b;
int c;
};
__attribute__ ((noclone, noinline))
void
test (struct a *a)
{
a->b = 0;
}
int
foo ()
{
struct a st = {1,2};
test (&st);
return st.c;
}
foo: # @foo
push rax
movabs rax, 8589934593
mov qword ptr [rsp], rax
mov rdi, rsp
call test
mov eax, dword ptr [rsp + 4] // Can be mov eax, 2
pop rcx
ret
One way to catch some of the easier cases would be to add a new attribute to indicate that the function writes a certain number of bytes for pointer arguments and/or globals + an analysis that adds the attribute.
It might also be useful to expose it via an attribute in C/C++.