Question on llvm.mem* intrinsics

Hi there lowering experts,

Can the llvm.mem* intrinsics ever turn into a library call? Or do
they invariably turn into inline code?

This comes up because there was a patch to StackProtector to use
CaptureTracking instead of a home-grown analysis, which changes
the treatment of calls to intrinsics. (The old code treated them
as normal calls, the new code decides intrinsics can never capture.)
But if llvm.mem* intrinsics can turn into real function calls, we
need to pay attention to that.

Thanks,
--paulr

Hi there lowering experts,

Can the llvm.mem* intrinsics ever turn into a library call? Or do
they invariably turn into inline code?

These can certainly turn into library calls. See, for example, the code in:

SelectionDAG::getMemcpy (in SelectionDAG.cpp), which is called by the
code in SelectionDAGBuilder::visitIntrinsicCall (in
SelectionDAGBuilder.cpp) handling Intrinsic::memcpy.

-Hal

From: Finkel, Hal J. [mailto:hfinkel@anl.gov]
Sent: Tuesday, September 10, 2019 3:35 PM
To: Robinson, Paul; llvm-dev@lists.llvm.org
Subject: Re: [llvm-dev] Question on llvm.mem* intrinsics

> Hi there lowering experts,
>
> Can the llvm.mem* intrinsics ever turn into a library call? Or do
> they invariably turn into inline code?

These can certainly turn into library calls. See, for example, the code
in:

SelectionDAG::getMemcpy (in SelectionDAG.cpp), which is called by the
code in SelectionDAGBuilder::visitIntrinsicCall (in
SelectionDAGBuilder.cpp) handling Intrinsic::memcpy.

-Hal

Thanks Hal!

There are certainly places in LLVM that assume intrinsics are never
real calls. `isLoweredToCall()` returns false for all intrinsics.
I was suspicious about the mem* calls though, and happy to get a
confirmation.

--paulr