[PATCH] D21920: Fix for Bug 26903 adds support to inline __builtin_mempcpy

Sunita_Marathe via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 21:38:19 PDT 2016


Sunita_Marathe created this revision.
Sunita_Marathe added a subscriber: llvm-commits.
Sunita_Marathe changed the visibility of this Differential Revision from "Public (No Login Required)" to "All Users".
Sunita_Marathe changed the edit policy of this Differential Revision from "All Users" to "Sunita_Marathe".

Since mempcpy differs from memcpy in just the return pointer, it seems desirable to utilize the existing codegen support for memcpy while lowering mempcpy so as to benefit from its existing inlining heuristics etc.

__builtin_memcpy is represented in the IR as the memcpy intrinsic.  
One motivation is that the intrinsic serves as the canonicalized form for the different memcpy idioms which the compiler recognizes, such as structure copy idiom and loop idiom etc. 

Similar considerations to the above do not seem to apply for mempcpy, i.e. to justify representing a mempcpy call in the IR as a memcpy intrinsic or a new mempcpy intrinsic.

So I have chosen to treat mempcpy as a special function which is handled during SelectionDAG building in a manner similar to other special functions such as LibFunc::memcmp. 
The DAG for a call to mempcpy is built by calling SelectionDAG::getMemcpy() followed by adjustment of the dst pointer.


http://reviews.llvm.org/D21920

Files:
  include/llvm/Analysis/TargetLibraryInfo.def
  include/llvm/Analysis/TargetLibraryInfo.h
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
  test/CodeGen/Generic/mempcpy_call.ll
  test/CodeGen/X86/mempcpy_ret_val.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21920.62461.patch
Type: text/x-patch
Size: 6235 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160701/38d332ea/attachment.bin>


More information about the llvm-commits mailing list