[llvm-dev] Which assumptions do llvm.memcpy/memmove/memset.* make when the count is 0?

John Regehr via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 21 08:31:41 PDT 2017


> Here's the thread I read about it:
> http://lists.llvm.org/pipermail/cfe-dev/2017-January/052066.html . As
> I recall, the tl;dr was "optimizing these assumptions to death doesn't
> realistically buy us much of anything, and there's a nontrivial amount
> of real-world code that depends on this behavior."

Yeah, I recall that thread. The issue is that the current question comes 
from Rust whereas the previous discussion was freely mixing C/C++ and 
middle-end issues. We need to separate these.

I propose documenting in the LangRef that memcpy and related intrinsics 
are defined even when src and dst don't refer to valid storage as long 
as the length argument is zero. Then we commit to implementing that 
behavior. Is that OK with everyone? If so I can update the doc.

John



More information about the llvm-dev mailing list