We need to explicitly query the shadow here, because it is lazily initialized for arguments. Without opaque pointers this used to mostly work out, because there would be a bitcast to i8* present, and that would query the argument shadow.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I am not sure how this can help, I will try later today.
As I see it it just calculates the shadow address and these instructions will be removed as unused?
Shadow memory for arguments is lazily initialized. If we never call getShadow() for an argument, then we'll leave it uninitialized. In most cases this happens naturally, but for memcpy/memmove we call a builtin that will access the shadow internally, so we never perform the getShadow() call and never initialize the shadow.
I see. I suspect it does not work if instead of llvm.memcpy we have "call void @foo(i8* %p)" and "call void @foo_noundef(i8* noundef %p)"?
Most likely it would, as visitCallBase has it on all code paths, but could you add this into the test?
Could you clarify that the problem is specifically with byval argument in the patch description?
Also, I'm wondering if we should make this copy explicit, perhaps by checking if the argument has any uses in the function body. I'm not 100% convinced that this is the only place where we forget to copy the shadow.
This change LGTM as a quick fix.
Works locally, so I landed it to fix the bot.
I will address my and @eugenis suggestions separately.