[llvm] r275284 - Fix for Bug 26903, adds support to inline __builtin_mempcpy

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 11:07:38 PDT 2016


On Wed, Jul 13, 2016 at 10:25 AM, Andrew Kaylor via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: akaylor
> Date: Wed Jul 13 12:25:11 2016
> New Revision: 275284
>
> URL: http://llvm.org/viewvc/llvm-project?rev=275284&view=rev
> Log:
> Fix for Bug 26903, adds support to inline __builtin_mempcpy
>
> Patch by Sunita Marathe
>
> Differential Revision: http://reviews.llvm.org/D21920
>
>
> Added:
>     llvm/trunk/test/CodeGen/Generic/mempcpy_call.ll
>     llvm/trunk/test/CodeGen/X86/mempcpy_ret_val.ll
> Modified:
>     llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def
>     llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h
>     llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
>     llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp
>     llvm/trunk/test/Transforms/InferFunctionAttrs/annotate.ll
>     llvm/trunk/test/Transforms/InferFunctionAttrs/no-proto.ll
>
> Modified: llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def?rev=275284&r1=275283&r2=275284&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def (original)
> +++ llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.def Wed Jul 13
> 12:25:11 2016
> @@ -734,6 +734,9 @@ TLI_DEFINE_STRING_INTERNAL("memcpy")
>  /// void *memmove(void *s1, const void *s2, size_t n);
>  TLI_DEFINE_ENUM_INTERNAL(memmove)
>  TLI_DEFINE_STRING_INTERNAL("memmove")
> +/// void *mempcpy(void *s1, const void *s2, size_t n);
> +TLI_DEFINE_ENUM_INTERNAL(mempcpy)
> +TLI_DEFINE_STRING_INTERNAL("mempcpy")
>  // void *memrchr(const void *s, int c, size_t n);
>  TLI_DEFINE_ENUM_INTERNAL(memrchr)
>  TLI_DEFINE_STRING_INTERNAL("memrchr")
>
> Modified: llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h?rev=275284&r1=275283&r2=275284&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h (original)
> +++ llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h Wed Jul 13
> 12:25:11 2016
> @@ -251,7 +251,7 @@ public:
>      case LibFunc::exp2:      case LibFunc::exp2f:      case
> LibFunc::exp2l:
>      case LibFunc::memcmp:    case LibFunc::strcmp:     case
> LibFunc::strcpy:
>      case LibFunc::stpcpy:    case LibFunc::strlen:     case
> LibFunc::strnlen:
> -    case LibFunc::memchr:
> +    case LibFunc::memchr:    case LibFunc::mempcpy:
>        return true;
>      }
>      return false;
>
> Modified: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp?rev=275284&r1=275283&r2=275284&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp (original)
> +++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp Wed Jul 13 12:25:11 2016
> @@ -642,6 +642,7 @@ bool TargetLibraryInfoImpl::isValidProto
>        return false;
>    // fallthrough
>    case LibFunc::memcpy:
> +  case LibFunc::mempcpy:
>    case LibFunc::memmove:
>      return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0)
> &&
>              FTy.getParamType(0)->isPointerTy() &&
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=275284&r1=275283&r2=275284&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Jul 13
> 12:25:11 2016
> @@ -6039,6 +6039,48 @@ bool SelectionDAGBuilder::visitMemChrCal
>    return false;
>  }
>
> +///
> +/// visitMemPCpyCall -- lower a mempcpy call as a memcpy followed by code
> to
> +/// to adjust the dst pointer by the size of the copied memory.
> +bool SelectionDAGBuilder::visitMemPCpyCall(const CallInst &I) {
>

Shouldn't the lowering be done in SimplifyLibCalls, as opposed to
SelectionDAG?

Also, what's the fourth argument to mempcpy?  I can't find any
documentation that mentions it.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160713/d17f1bcc/attachment.html>


More information about the llvm-commits mailing list