From a8864abefcee775a0fee0f766c1f3cb247ca4ad9 Mon Sep 17 00:00:00 2001 From: Tim Shen Date: Thu, 25 Aug 2016 21:03:46 +0000 Subject: [PATCH] [MemCpy] Add comments for r279769 Differential Revision: https://reviews.llvm.org/D23846 llvm-svn: 279778 --- lib/Transforms/Scalar/MemCpyOptimizer.cpp | 3 ++- test/Transforms/MemCpyOpt/pr29105.ll | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 27c37cd5289..c6e8cde8f47 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -1110,7 +1110,8 @@ bool MemCpyOptPass::performMemCpyToMemSetOptzn(MemCpyInst *MemCpy, MemSetInst *MemSet) { AliasAnalysis &AA = LookupAliasAnalysis(); - // This only makes sense on memcpy(..., memset(...), ...). + // Make sure that memcpy(..., memset(...), ...), that is we are memsetting and + // memcpying from the same address. Otherwise it is hard to reason about. if (!AA.isMustAlias(MemSet->getRawDest(), MemCpy->getRawSource())) return false; diff --git a/test/Transforms/MemCpyOpt/pr29105.ll b/test/Transforms/MemCpyOpt/pr29105.ll index ad9f97e7a23..0d377837226 100644 --- a/test/Transforms/MemCpyOpt/pr29105.ll +++ b/test/Transforms/MemCpyOpt/pr29105.ll @@ -1,6 +1,7 @@ ; RUN: opt -memcpyopt -instcombine -S %s | FileCheck %s %Foo = type { [2048 x i64] } +; Make sure that all mempcy calls are converted to memset calls, or removed. ; CHECK-LABEL: @baz( ; CHECK-NOT: call void @llvm.memcpy define void @baz() unnamed_addr #0 {