<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 13, 2016 at 10:25 AM, Andrew Kaylor via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: akaylor<br>
Date: Wed Jul 13 12:25:11 2016<br>
New Revision: 275284<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=275284&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=275284&view=rev</a><br>
Log:<br>
Fix for Bug 26903, adds support to inline __builtin_mempcpy<br>
<br>
Patch by Sunita Marathe<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D21920" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21920</a><br>
<br>
<br>
Added:<br>
    llvm/trunk/test/CodeGen/Generic/mempcpy_call.ll<br>
    llvm/trunk/test/CodeGen/X86/mempcpy_ret_val.ll<br>
Modified:<br>
    llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def<br>
    llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h<br>
    llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h<br>
    llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp<br>
    llvm/trunk/test/Transforms/InferFunctionAttrs/annotate.ll<br>
    llvm/trunk/test/Transforms/InferFunctionAttrs/no-proto.ll<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def?rev=275284&r1=275283&r2=275284&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def?rev=275284&r1=275283&r2=275284&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def (original)<br>
+++ llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def Wed Jul 13 12:25:11 2016<br>
@@ -734,6 +734,9 @@ TLI_DEFINE_STRING_INTERNAL("memcpy")<br>
 /// void *memmove(void *s1, const void *s2, size_t n);<br>
 TLI_DEFINE_ENUM_INTERNAL(memmove)<br>
 TLI_DEFINE_STRING_INTERNAL("memmove")<br>
+/// void *mempcpy(void *s1, const void *s2, size_t n);<br>
+TLI_DEFINE_ENUM_INTERNAL(mempcpy)<br>
+TLI_DEFINE_STRING_INTERNAL("mempcpy")<br>
 // void *memrchr(const void *s, int c, size_t n);<br>
 TLI_DEFINE_ENUM_INTERNAL(memrchr)<br>
 TLI_DEFINE_STRING_INTERNAL("memrchr")<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h?rev=275284&r1=275283&r2=275284&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h?rev=275284&r1=275283&r2=275284&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h Wed Jul 13 12:25:11 2016<br>
@@ -251,7 +251,7 @@ public:<br>
     case LibFunc::exp2:      case LibFunc::exp2f:      case LibFunc::exp2l:<br>
     case LibFunc::memcmp:    case LibFunc::strcmp:     case LibFunc::strcpy:<br>
     case LibFunc::stpcpy:    case LibFunc::strlen:     case LibFunc::strnlen:<br>
-    case LibFunc::memchr:<br>
+    case LibFunc::memchr:    case LibFunc::mempcpy:<br>
       return true;<br>
     }<br>
     return false;<br>
<br>
Modified: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp?rev=275284&r1=275283&r2=275284&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp?rev=275284&r1=275283&r2=275284&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp Wed Jul 13 12:25:11 2016<br>
@@ -642,6 +642,7 @@ bool TargetLibraryInfoImpl::isValidProto<br>
       return false;<br>
   // fallthrough<br>
   case LibFunc::memcpy:<br>
+  case LibFunc::mempcpy:<br>
   case LibFunc::memmove:<br>
     return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&<br>
             FTy.getParamType(0)->isPointerTy() &&<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=275284&r1=275283&r2=275284&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=275284&r1=275283&r2=275284&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Jul 13 12:25:11 2016<br>
@@ -6039,6 +6039,48 @@ bool SelectionDAGBuilder::visitMemChrCal<br>
   return false;<br>
 }<br>
<br>
+///<br>
+/// visitMemPCpyCall -- lower a mempcpy call as a memcpy followed by code to<br>
+/// to adjust the dst pointer by the size of the copied memory.<br>
+bool SelectionDAGBuilder::visitMemPCpyCall(const CallInst &I) {<br></blockquote><div><br></div><div>Shouldn't the lowering be done in SimplifyLibCalls, as opposed to SelectionDAG?<br><br></div><div>Also, what's the fourth argument to mempcpy?  I can't find any documentation that mentions it.<br></div><div><br></div><div>-Eli<br></div></div></div></div>