[llvm-dev] Why did "llvm.memcpy" changed when emitting an object file?
Gaier, Bjoern via llvm-dev
llvm-dev at lists.llvm.org
Thu May 9 01:04:20 PDT 2019
Hello Johannes and Tim,
Thank you for your answers! They really helped me.
Can I influence if intrinsics are lowered or not?
I set llvm::EngineBuilder::setOptLevel to "llvm::CodeGenOpt::Aggressive"
And I couldn't find any flag in llvm::TargetOptions that might effect this behavior.
Kind greetings
Björn
-----Original Message-----
From: Doerfert, Johannes <jdoerfert at anl.gov>
Sent: Donnerstag, 9. Mai 2019 08:55
To: Gaier, Bjoern <Bjoern.Gaier at horiba.com>
Cc: llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Why did "llvm.memcpy" changed when emitting an object file?
Hi Björn,
Your observation is correct, LLVM can "recreate" actual function calls for intrinsics calls.
Generally, there is no single way LLVM intrinsics are lowered. It depends on the intrinsic and the target (afaik). Some, especially target specific ones, are lowered to assembly sequences. Others, are simply dropped or replaced by one of their arguments (some annotations).
Memory operations, among others, can be "lowered" to calls to library calls, e.g., in IntrinsicLowering::LowerIntrinsicCall. Though, memcpy can also be lowered to a sequence of load/stores in
SelectionDAG::getMemcpy() (via getMemcpyLoadsAndStores). I guess the fact that you use the JIT interface might be a reason you see the former lowering but I don't know for sure.
I hope this general answer helps, otherwise you can probably get a more detailed response from a backend person.
Cheers,
Johannes
On 05/09, Gaier, Bjoern via llvm-dev wrote:
> Dear LLVM-Mailing list,
>
> I have a beginners question again - please don't be mad at me!
>
> I was playing around with llvm::Module instance and ended in iterating over all global values and functions. I then noticed the function "llvm.memcpy". As I understood, this is an intrinsic coming from the LLVM.
>
> 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. I checked the iteration of the functions and were not able to locate any "memcpy" there, this is why I'm assuming the intrinsic changed.
>
> I wonder if this is true - 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. Did I maybe configured the EngineBuilder wrong? Or the ExecutionEngine itself?
>
> Kind greetings
> Björn
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
> Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi
> Fukushima. Junichi Tajika
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
Johannes Doerfert
Researcher
Argonne National Laboratory
Lemont, IL 60439, USA
jdoerfert at anl.gov
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
More information about the llvm-dev
mailing list