From 3ad8b43cc279b385fa19728aa0b0cbc52694b931 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 --- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 3 ++- llvm/test/Transforms/MemCpyOpt/pr29105.ll | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 27c37cd..c6e8cde 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/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/llvm/test/Transforms/MemCpyOpt/pr29105.ll b/llvm/test/Transforms/MemCpyOpt/pr29105.ll index ad9f97e..0d37783 100644 --- a/llvm/test/Transforms/MemCpyOpt/pr29105.ll +++ b/llvm/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 { -- 2.7.4