[llvm-dev] Why did "llvm.memcpy" changed when emitting an object file?

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed May 8 23:46:44 PDT 2019

On Thu, 9 May 2019 at 07:21, Gaier, Bjoern via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> So far so good! I then emitted an object file with the llvm::ExecutionEngine and noticed an undefined references to "memcpy". Now I'm surprised! To me, it looks like that the intrinsic turned into a 'normal' function.

That sounds very likely.

> I always thought that intrinsics will be replaced by specific predefined assembly instructions, even the MSVC compiler provides a memcpy intrinsic, so I don't understand why this function would appear, when it was an intrinsic before.

LLVM assumes the runtime environment will provide basic string
functions (memcpy, and I think memset). Combine that with the fact
that @llvm.memcpy is more of a request to produce the best possible
memcpy rather than specifically to inline the sequence and we get the
behaviour you're seeing. LLVM will use an inline sequence if it thinks
that's going to be most efficient, otherwise it will call out to the
library one (typically when the number of bytes being copied is
unknown or large, and in -Oz mode).



More information about the llvm-dev mailing list