[llvm] r216865 - Ignore lifetime intrinsics in use list for MemCpyOptimizer. Patch by Luqman Aden, review by Hal Finkel.
Nick Lewycky
nicholas at mxc.ca
Sun Aug 31 23:03:11 PDT 2014
Author: nicholas
Date: Mon Sep 1 01:03:11 2014
New Revision: 216865
URL: http://llvm.org/viewvc/llvm-project?rev=216865&view=rev
Log:
Ignore lifetime intrinsics in use list for MemCpyOptimizer. Patch by Luqman Aden, review by Hal Finkel.
Added:
llvm/trunk/test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=216865&r1=216864&r2=216865&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Sep 1 01:03:11 2014
@@ -679,6 +679,10 @@ bool MemCpyOpt::performCallSlotOptzn(Ins
srcUseList.push_back(UU);
else
return false;
+ } else if (const IntrinsicInst *IT = dyn_cast<IntrinsicInst>(U)) {
+ if (IT->getIntrinsicID() != Intrinsic::lifetime_start &&
+ IT->getIntrinsicID() != Intrinsic::lifetime_end)
+ continue;
} else if (U != C && U != cpy) {
return false;
}
Added: llvm/trunk/test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll?rev=216865&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll (added)
+++ llvm/trunk/test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll Mon Sep 1 01:03:11 2014
@@ -0,0 +1,28 @@
+; RUN: opt -basicaa -memcpyopt -instcombine -S < %s | FileCheck %s
+
+target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo([8 x i64]* noalias nocapture sret dereferenceable(64)) {
+entry-block:
+ %a = alloca [8 x i64], align 8
+ %1 = bitcast [8 x i64]* %a to i8*
+ call void @llvm.lifetime.start(i64 64, i8* %1)
+ call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 64, i32 8, i1 false)
+ %2 = bitcast [8 x i64]* %0 to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %1, i64 64, i32 8, i1 false)
+ call void @llvm.lifetime.end(i64 64, i8* %1)
+ ret void
+
+; CHECK-LABEL: @foo(
+; CHECK: %1 = bitcast
+; CHECK: call void @llvm.memset
+; CHECK-NOT: call void @llvm.memcpy
+; CHECK: ret void
+}
+
+declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
+declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
+
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) nounwind
+declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind
More information about the llvm-commits
mailing list