Index: lib/Transforms/Utils/BuildLibCalls.cpp =================================================================== --- lib/Transforms/Utils/BuildLibCalls.cpp +++ lib/Transforms/Utils/BuildLibCalls.cpp @@ -88,6 +88,14 @@ return true; } +static bool setDoesNotAlias(Function &F, unsigned ArgNo) { + if (F.hasParamAttribute(ArgNo, Attribute::NoAlias)) + return false; + F.addParamAttr(ArgNo, Attribute::NoAlias); + ++NumNoAlias; + return true; +} + static bool setOnlyReadsMemory(Function &F, unsigned ArgNo) { if (F.hasParamAttribute(ArgNo, Attribute::ReadOnly)) return false; @@ -175,6 +183,9 @@ return Changed; case LibFunc_strcpy: case LibFunc_strncpy: + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotAlias(F, 1); + LLVM_FALLTHROUGH; case LibFunc_strcat: case LibFunc_strncat: Changed |= setReturnedArg(F, 0); @@ -249,12 +260,14 @@ case LibFunc_sprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 0); + Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; case LibFunc_snprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 0); + Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; @@ -291,6 +304,9 @@ Changed |= setDoesNotCapture(F, 1); return Changed; case LibFunc_memcpy: + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotAlias(F, 1); + LLVM_FALLTHROUGH; case LibFunc_memmove: Changed |= setReturnedArg(F, 0); LLVM_FALLTHROUGH; Index: lib/Transforms/Utils/SimplifyLibCalls.cpp =================================================================== --- lib/Transforms/Utils/SimplifyLibCalls.cpp +++ lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -460,9 +460,6 @@ if (Dst == Src) // strcpy(x,x) -> x return Src; - CI->addParamAttr(0, Attribute::NoAlias); - CI->addParamAttr(1, Attribute::NoAlias); - // See if we can get the length of the input string. uint64_t Len = GetStringLength(Src); if (Len == 0) @@ -505,9 +502,6 @@ Value *Src = CI->getArgOperand(1); Value *LenOp = CI->getArgOperand(2); - CI->addParamAttr(0, Attribute::NoAlias); - CI->addParamAttr(1, Attribute::NoAlias); - // See if we can get the length of the input string. uint64_t SrcLen = GetStringLength(Src); if (SrcLen == 0) @@ -989,9 +983,6 @@ if (ConstantInt *LenC = dyn_cast(Size)) annotateDereferenceableBytes(CI, {0, 1}, LenC->getZExtValue()); - CI->addParamAttr(0, Attribute::NoAlias); - CI->addParamAttr(1, Attribute::NoAlias); - if (isIntrinsic) return nullptr; Index: test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll =================================================================== --- test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll +++ test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll @@ -8,7 +8,7 @@ define void @foo(i8* nocapture %p, i8* nocapture %q, i8* nocapture %s) nounwind { ; CHECK: @foo -; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 dereferenceable(16) %p, i8* noalias align 1 dereferenceable(16) %q, i64 16, i1 false), !tbaa !0 +; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) %p, i8* align 1 dereferenceable(16) %q, i64 16, i1 false), !tbaa !0 ; CHECK-NEXT: store i8 2, i8* %s, align 1, !tbaa [[TAGA:!.*]] ; CHECK-NEXT: ret void tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 16, i1 false), !tbaa !2 Index: test/Other/cgscc-devirt-iteration.ll =================================================================== --- test/Other/cgscc-devirt-iteration.ll +++ test/Other/cgscc-devirt-iteration.ll @@ -96,7 +96,7 @@ } declare i8* @memcpy(i8*, i8*, i64) -; CHECK-LABEL: declare i8* @memcpy( +; CHECK-LABEL: i8* @memcpy( ; The @test3 function checks that when we refine an indirect call to an ; intrinsic we still revisit the SCC pass. This also covers cases where the Index: test/Other/cgscc-libcall-update.ll =================================================================== --- test/Other/cgscc-libcall-update.ll +++ test/Other/cgscc-libcall-update.ll @@ -18,7 +18,7 @@ %tmp3 = call i64 @llvm.objectsize.i64.p0i8(i8* %tmp2, i1 false, i1 true, i1 false) %tmp4 = call i8* @__strncpy_chk(i8* %arg2, i8* %tmp2, i64 1023, i64 %tmp3) ; CHECK-NOT: call -; CHECK: call i8* @strncpy(i8* noalias %arg2, i8* noalias nonnull %tmp2, i64 1023) +; CHECK: call i8* @strncpy(i8* %arg2, i8* nonnull %tmp2, i64 1023) ; CHECK-NOT: call ret i8* %tmp4 Index: test/Transforms/InferFunctionAttrs/annotate.ll =================================================================== --- test/Transforms/InferFunctionAttrs/annotate.ll +++ test/Transforms/InferFunctionAttrs/annotate.ll @@ -628,7 +628,7 @@ ; CHECK: declare i32 @memcmp(i8* nocapture, i8* nocapture, i64) [[G2]] declare i32 @memcmp(i8*, i8*, i64) -; CHECK: declare i8* @memcpy(i8* returned, i8* nocapture readonly, i64) [[G1]] +; CHECK: declare i8* @memcpy(i8* noalias returned, i8* noalias nocapture readonly, i64) [[G1]] declare i8* @memcpy(i8*, i8*, i64) ; CHECK: declare i8* @mempcpy(i8*, i8* nocapture readonly, i64) [[G1]] @@ -793,10 +793,10 @@ ; CHECK: declare x86_fp80 @sinl(x86_fp80) [[G0]] declare x86_fp80 @sinl(x86_fp80) -; CHECK: declare i32 @snprintf(i8* nocapture, i64, i8* nocapture readonly, ...) [[G1]] +; CHECK: declare i32 @snprintf(i8* noalias nocapture, i64, i8* nocapture readonly, ...) [[G1]] declare i32 @snprintf(i8*, i64, i8*, ...) -; CHECK: declare i32 @sprintf(i8* nocapture, i8* nocapture readonly, ...) [[G1]] +; CHECK: declare i32 @sprintf(i8* noalias nocapture, i8* nocapture readonly, ...) [[G1]] declare i32 @sprintf(i8*, i8*, ...) ; CHECK: declare double @sqrt(double) [[G0]] @@ -844,7 +844,7 @@ ; CHECK: declare i32 @strcoll(i8* nocapture, i8* nocapture) [[G2]] declare i32 @strcoll(i8*, i8*) -; CHECK: declare i8* @strcpy(i8* returned, i8* nocapture readonly) [[G1]] +; CHECK: declare i8* @strcpy(i8* noalias returned, i8* noalias nocapture readonly) [[G1]] declare i8* @strcpy(i8*, i8*) ; CHECK: declare i64 @strcspn(i8* nocapture, i8* nocapture) [[G2]] @@ -865,7 +865,7 @@ ; CHECK: declare i32 @strncmp(i8* nocapture, i8* nocapture, i64) [[G2]] declare i32 @strncmp(i8*, i8*, i64) -; CHECK: declare i8* @strncpy(i8* returned, i8* nocapture readonly, i64) [[G1]] +; CHECK: declare i8* @strncpy(i8* noalias returned, i8* noalias nocapture readonly, i64) [[G1]] declare i8* @strncpy(i8*, i8*, i64) ; CHECK: declare noalias i8* @strndup(i8* nocapture readonly, i64) [[G1]] Index: test/Transforms/InstCombine/annotate-noalias.ll =================================================================== --- test/Transforms/InstCombine/annotate-noalias.ll +++ test/Transforms/InstCombine/annotate-noalias.ll @@ -1,78 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -instcombine -S < %s | FileCheck %s - - -declare i8* @memcpy(i8* nocapture, i8* nocapture, i64) -declare i8* @strncpy(i8* nocapture, i8* nocapture, i64) -declare i8* @strcpy(i8* nocapture, i8* nocapture) - -define i8* @memcpy_const_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { -; CHECK-LABEL: @memcpy_const_size_noalias( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 dereferenceable(16) [[D:%.*]], i8* noalias align 1 dereferenceable(16) [[S:%.*]], i64 16, i1 false) -; CHECK-NEXT: ret i8* [[D]] -; - %call = tail call i8* @memcpy(i8* %d, i8* %s, i64 16) - ret i8* %call -} - -define i8* @memcpy_const_zero_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { -; CHECK-LABEL: @memcpy_const_zero_size_noalias( -; CHECK-NEXT: ret i8* [[D:%.*]] -; - %call = tail call i8* @memcpy(i8* %d, i8* %s, i64 0) - ret i8* %call -} - -define i8* @memcpy_nonconst_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s, i64 %n) { -; CHECK-LABEL: @memcpy_nonconst_size_noalias( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 [[D:%.*]], i8* noalias align 1 [[S:%.*]], i64 [[N:%.*]], i1 false) -; CHECK-NEXT: ret i8* [[D]] -; - %call = tail call i8* @memcpy(i8* %d, i8* %s, i64 %n) - ret i8* %call -} - -define i8* @strncpy_const_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { -; CHECK-LABEL: @strncpy_const_size_noalias( -; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strncpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]], i64 16) -; CHECK-NEXT: ret i8* [[CALL]] -; - %call = tail call i8* @strncpy(i8* %d, i8* %s, i64 16) - ret i8* %call -} - -define i8* @strncpy_const_zero_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { -; CHECK-LABEL: @strncpy_const_zero_size_noalias( -; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strncpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]], i64 0) -; CHECK-NEXT: ret i8* [[CALL]] -; - %call = tail call i8* @strncpy(i8* %d, i8* %s, i64 0) - ret i8* %call -} - -define i8* @strncpy_nonconst_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s, i64 %n) { -; CHECK-LABEL: @strncpy_nonconst_size_noalias( -; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strncpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]], i64 [[N:%.*]]) -; CHECK-NEXT: ret i8* [[CALL]] -; - %call = tail call i8* @strncpy(i8* %d, i8* %s, i64 %n) - ret i8* %call -} - -define i8* @strcpy_const_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { -; CHECK-LABEL: @strcpy_const_size_noalias( -; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strcpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]]) -; CHECK-NEXT: ret i8* [[CALL]] -; - %call = tail call i8* @strcpy(i8* %d, i8* %s) - ret i8* %call -} - -define i8* @strcpy_nonconst_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { -; CHECK-LABEL: @strcpy_nonconst_size_noalias( -; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strcpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]]) -; CHECK-NEXT: ret i8* [[CALL]] -; - %call = tail call i8* @strcpy(i8* %d, i8* %s) - ret i8* %call -} Index: test/Transforms/InstCombine/mem-deref-bytes.ll =================================================================== --- test/Transforms/InstCombine/mem-deref-bytes.ll +++ test/Transforms/InstCombine/mem-deref-bytes.ll @@ -84,7 +84,7 @@ define i8* @memcpy_const_size_set_deref(i8* nocapture readonly %d, i8* nocapture readonly %s) { ; CHECK-LABEL: @memcpy_const_size_set_deref( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 dereferenceable(64) [[D:%.*]], i8* noalias align 1 dereferenceable(64) [[S:%.*]], i64 64, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(64) [[D:%.*]], i8* align 1 dereferenceable(64) [[S:%.*]], i64 64, i1 false) ; CHECK-NEXT: ret i8* [[D]] ; %call = tail call i8* @memcpy(i8* %d, i8* %s, i64 64) @@ -120,7 +120,7 @@ define i8* @llvm_memcpy_const_size_set_deref(i8* nocapture readonly %d, i8* nocapture readonly %s) { ; CHECK-LABEL: @llvm_memcpy_const_size_set_deref( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 dereferenceable(16) [[D:%.*]], i8* noalias align 1 dereferenceable(16) [[S:%.*]], i64 16, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) [[D:%.*]], i8* align 1 dereferenceable(16) [[S:%.*]], i64 16, i1 false) ; CHECK-NEXT: ret i8* [[D]] ; call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %d, i8* align 1 %s, i64 16, i1 false) Index: test/Transforms/InstCombine/memcpy-1.ll =================================================================== --- test/Transforms/InstCombine/memcpy-1.ll +++ test/Transforms/InstCombine/memcpy-1.ll @@ -11,7 +11,7 @@ define i8* @test_simplify1(i8* %mem1, i8* %mem2, i32 %size) { ; CHECK-LABEL: @test_simplify1( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 [[MEM1:%.*]], i8* noalias align 1 [[MEM2:%.*]], i32 [[SIZE:%.*]], i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[MEM1:%.*]], i8* align 1 [[MEM2:%.*]], i32 [[SIZE:%.*]], i1 false) ; CHECK-NEXT: ret i8* [[MEM1]] ; %ret = call i8* @memcpy(i8* %mem1, i8* %mem2, i32 %size) @@ -22,7 +22,7 @@ define i8* @test_simplify2(i8* %mem1, i8* %mem2, i32 %size) { ; CHECK-LABEL: @test_simplify2( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 [[MEM1:%.*]], i8* noalias align 1 [[MEM2:%.*]], i32 [[SIZE:%.*]], i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[MEM1:%.*]], i8* align 1 [[MEM2:%.*]], i32 [[SIZE:%.*]], i1 false) ; CHECK-NEXT: ret i8* [[MEM1]] ; %ret = call i8* @memcpy(i8* %mem1, i8* %mem2, i32 %size) strictfp Index: test/Transforms/InstCombine/memcpy-from-global.ll =================================================================== --- test/Transforms/InstCombine/memcpy-from-global.ll +++ test/Transforms/InstCombine/memcpy-from-global.ll @@ -78,7 +78,7 @@ ; CHECK-LABEL: @test2( ; CHECK-NEXT: [[B1:%.*]] = alloca [124 x i8], align 8 ; CHECK-NEXT: [[B1_SUB:%.*]] = getelementptr inbounds [124 x i8], [124 x i8]* [[B1]], i64 0, i64 0 -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nonnull align 8 dereferenceable(124) [[B1_SUB]], i8* noalias align 16 dereferenceable(124) getelementptr inbounds (%T, %T* @G, i64 0, i32 0), i64 124, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(124) [[B1_SUB]], i8* align 16 dereferenceable(124) getelementptr inbounds (%T, %T* @G, i64 0, i32 0), i64 124, i1 false) ; CHECK-NEXT: call void @bar(i8* nonnull [[B1_SUB]]) ; CHECK-NEXT: ret void ; @@ -101,7 +101,7 @@ ; CHECK-LABEL: @test2_no_null_opt( ; CHECK-NEXT: [[B1:%.*]] = alloca [124 x i8], align 8 ; CHECK-NEXT: [[B1_SUB:%.*]] = getelementptr inbounds [124 x i8], [124 x i8]* [[B1]], i64 0, i64 0 -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 8 dereferenceable(124) [[B1_SUB]], i8* noalias align 16 dereferenceable(124) getelementptr inbounds (%T, %T* @G, i64 0, i32 0), i64 124, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 dereferenceable(124) [[B1_SUB]], i8* align 16 dereferenceable(124) getelementptr inbounds (%T, %T* @G, i64 0, i32 0), i64 124, i1 false) ; CHECK-NEXT: call void @bar(i8* [[B1_SUB]]) ; CHECK-NEXT: ret void ; @@ -125,7 +125,7 @@ ; CHECK-NEXT: [[B1:%.*]] = alloca [124 x i8], align 8 ; CHECK-NEXT: [[B1_SUB:%.*]] = getelementptr inbounds [124 x i8], [124 x i8]* [[B1]], i64 0, i64 0 ; CHECK-NEXT: [[B:%.*]] = addrspacecast i8* [[B1_SUB]] to i8 addrspace(1)* -; CHECK-NEXT: call void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* noalias align 4 dereferenceable(124) [[B]], i8 addrspace(1)* noalias align 4 dereferenceable(124) addrspacecast (i8* getelementptr inbounds (%T, %T* @G, i64 0, i32 0) to i8 addrspace(1)*), i64 124, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* align 4 dereferenceable(124) [[B]], i8 addrspace(1)* align 4 dereferenceable(124) addrspacecast (i8* getelementptr inbounds (%T, %T* @G, i64 0, i32 0) to i8 addrspace(1)*), i64 124, i1 false) ; CHECK-NEXT: call void @bar_as1(i8 addrspace(1)* [[B]]) ; CHECK-NEXT: ret void ; @@ -234,7 +234,7 @@ ; CHECK-LABEL: @test8( ; CHECK-NEXT: [[AL:%.*]] = alloca [[U:%.*]], align 16 ; CHECK-NEXT: [[A:%.*]] = bitcast %U* [[AL]] to i8* -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nonnull align 16 dereferenceable(20) [[A]], i8* noalias align 4 dereferenceable(20) bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*), i64 20, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 16 dereferenceable(20) [[A]], i8* align 4 dereferenceable(20) bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*), i64 20, i1 false) ; CHECK-NEXT: call void @bar(i8* nonnull [[A]]) #2 ; CHECK-NEXT: ret void ; @@ -250,7 +250,7 @@ ; CHECK-LABEL: @test8_addrspacecast( ; CHECK-NEXT: [[AL:%.*]] = alloca [[U:%.*]], align 16 ; CHECK-NEXT: [[A:%.*]] = bitcast %U* [[AL]] to i8* -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p1i8.i64(i8* noalias nonnull align 16 dereferenceable(20) [[A]], i8 addrspace(1)* noalias align 4 dereferenceable(20) addrspacecast (i8* bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*) to i8 addrspace(1)*), i64 20, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p1i8.i64(i8* nonnull align 16 dereferenceable(20) [[A]], i8 addrspace(1)* align 4 dereferenceable(20) addrspacecast (i8* bitcast (%U* getelementptr inbounds ([2 x %U], [2 x %U]* @H, i64 0, i64 1) to i8*) to i8 addrspace(1)*), i64 20, i1 false) ; CHECK-NEXT: call void @bar(i8* nonnull [[A]]) #2 ; CHECK-NEXT: ret void ; @@ -294,8 +294,8 @@ ; CHECK-NEXT: entry: ; CHECK-NEXT: [[CC:%.*]] = alloca [1000000 x i8], align 16 ; CHECK-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1000000 x i8], [1000000 x i8]* [[CC]], i64 0, i64 0 -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nonnull align 16 dereferenceable(3) [[ARRAYDECAY]], i8* noalias align 16 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i64 0, i64 0), i64 3, i1 false) -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 16 dereferenceable(1000000) getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i64 0, i64 0), i8* noalias nonnull align 16 dereferenceable(1000000) [[ARRAYDECAY]], i64 1000000, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 16 dereferenceable(3) [[ARRAYDECAY]], i8* align 16 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i64 0, i64 0), i64 3, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 dereferenceable(1000000) getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i64 0, i64 0), i8* nonnull align 16 dereferenceable(1000000) [[ARRAYDECAY]], i64 1000000, i1 false) ; CHECK-NEXT: ret void ; entry: @@ -311,7 +311,7 @@ define void @test10_same_global() { ; CHECK-LABEL: @test10_same_global( ; CHECK-NEXT: entry: -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 16 dereferenceable(3) getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i64 0, i64 0), i8* noalias align 16 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i64 0, i64 0), i64 3, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 dereferenceable(3) getelementptr inbounds ([1000000 x i8], [1000000 x i8]* @bbb, i64 0, i64 0), i8* align 16 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @_ZL3KKK, i64 0, i64 0), i64 3, i1 false) ; CHECK-NEXT: ret void ; entry: Index: test/Transforms/InstCombine/memcpy-to-load.ll =================================================================== --- test/Transforms/InstCombine/memcpy-to-load.ll +++ test/Transforms/InstCombine/memcpy-to-load.ll @@ -34,7 +34,7 @@ define void @copy_3_bytes(i8* %d, i8* %s) { ; ALL-LABEL: @copy_3_bytes( -; ALL-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(3) [[D:%.*]], i8* noalias align 1 dereferenceable(3) [[S:%.*]], i32 3, i1 false) +; ALL-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(3) [[D:%.*]], i8* align 1 dereferenceable(3) [[S:%.*]], i32 3, i1 false) ; ALL-NEXT: ret void ; call void @llvm.memcpy.p0i8.p0i8.i32(i8* %d, i8* %s, i32 3, i1 false) @@ -57,7 +57,7 @@ define void @copy_5_bytes(i8* %d, i8* %s) { ; ALL-LABEL: @copy_5_bytes( -; ALL-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(5) [[D:%.*]], i8* noalias align 1 dereferenceable(5) [[S:%.*]], i32 5, i1 false) +; ALL-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(5) [[D:%.*]], i8* align 1 dereferenceable(5) [[S:%.*]], i32 5, i1 false) ; ALL-NEXT: ret void ; call void @llvm.memcpy.p0i8.p0i8.i32(i8* %d, i8* %s, i32 5, i1 false) @@ -78,7 +78,7 @@ define void @copy_16_bytes(i8* %d, i8* %s) { ; ALL-LABEL: @copy_16_bytes( -; ALL-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(16) [[D:%.*]], i8* noalias align 1 dereferenceable(16) [[S:%.*]], i32 16, i1 false) +; ALL-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(16) [[D:%.*]], i8* align 1 dereferenceable(16) [[S:%.*]], i32 16, i1 false) ; ALL-NEXT: ret void ; call void @llvm.memcpy.p0i8.p0i8.i32(i8* %d, i8* %s, i32 16, i1 false) Index: test/Transforms/InstCombine/memcpy.ll =================================================================== --- test/Transforms/InstCombine/memcpy.ll +++ test/Transforms/InstCombine/memcpy.ll @@ -29,7 +29,7 @@ define void @test3(i8* %d, i8* %s) { ; CHECK-LABEL: @test3( -; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 4 dereferenceable(17179869184) [[D:%.*]], i8* noalias align 4 dereferenceable(17179869184) [[S:%.*]], i64 17179869184, i1 false) +; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(17179869184) [[D:%.*]], i8* align 4 dereferenceable(17179869184) [[S:%.*]], i64 17179869184, i1 false) ; CHECK-NEXT: ret void ; tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %d, i8* align 4 %s, i64 17179869184, i1 false) Index: test/Transforms/InstCombine/memcpy_chk-1.ll =================================================================== --- test/Transforms/InstCombine/memcpy_chk-1.ll +++ test/Transforms/InstCombine/memcpy_chk-1.ll @@ -18,7 +18,7 @@ define i8* @test_simplify1() { ; CHECK-LABEL: @test_simplify1( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 4 dereferenceable(1824) bitcast (%struct.T1* @t1 to i8*), i8* noalias align 4 dereferenceable(1824) bitcast (%struct.T2* @t2 to i8*), i64 1824, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(1824) bitcast (%struct.T1* @t1 to i8*), i8* align 4 dereferenceable(1824) bitcast (%struct.T2* @t2 to i8*), i64 1824, i1 false) ; CHECK-NEXT: ret i8* bitcast (%struct.T1* @t1 to i8*) ; %dst = bitcast %struct.T1* @t1 to i8* @@ -29,7 +29,7 @@ define i8* @test_simplify2() { ; CHECK-LABEL: @test_simplify2( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 4 dereferenceable(1824) bitcast (%struct.T1* @t1 to i8*), i8* noalias align 4 dereferenceable(1824) bitcast (%struct.T3* @t3 to i8*), i64 1824, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 dereferenceable(1824) bitcast (%struct.T1* @t1 to i8*), i8* align 4 dereferenceable(1824) bitcast (%struct.T3* @t3 to i8*), i64 1824, i1 false) ; CHECK-NEXT: ret i8* bitcast (%struct.T1* @t1 to i8*) ; %dst = bitcast %struct.T1* @t1 to i8* @@ -65,7 +65,7 @@ define i8* @test_simplify_return_indcall(i8* ()* %alloc) { ; CHECK-LABEL: @test_simplify_return_indcall( ; CHECK-NEXT: [[DST:%.*]] = call i8* [[ALLOC:%.*]]() -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 dereferenceable(1824) [[DST]], i8* noalias align 4 dereferenceable(1824) bitcast (%struct.T2* @t2 to i8*), i64 1824, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(1824) [[DST]], i8* align 4 dereferenceable(1824) bitcast (%struct.T2* @t2 to i8*), i64 1824, i1 false) ; CHECK-NEXT: ret i8* [[DST]] ; %src = bitcast %struct.T2* @t2 to i8* Index: test/Transforms/InstCombine/memmove.ll =================================================================== --- test/Transforms/InstCombine/memmove.ll +++ test/Transforms/InstCombine/memmove.ll @@ -19,7 +19,7 @@ define void @test2(i8* %A, i32 %N) { ;; dest can't alias source since we can't write to source! ; CHECK-LABEL: @test2( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 [[A:%.*]], i8* noalias align 16 getelementptr inbounds ([33 x i8], [33 x i8]* @S, i64 0, i64 0), i32 [[N:%.*]], i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[A:%.*]], i8* align 16 getelementptr inbounds ([33 x i8], [33 x i8]* @S, i64 0, i64 0), i32 [[N:%.*]], i1 false) ; CHECK-NEXT: ret void ; call void @llvm.memmove.p0i8.p0i8.i32(i8* %A, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @S, i32 0, i32 0), i32 %N, i1 false) Index: test/Transforms/InstCombine/objsize.ll =================================================================== --- test/Transforms/InstCombine/objsize.ll +++ test/Transforms/InstCombine/objsize.ll @@ -163,7 +163,7 @@ ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = tail call noalias i8* @malloc(i32 20) #0 ; CHECK-NEXT: [[TMP1:%.*]] = load i8*, i8** @s, align 8 -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(10) [[TMP0]], i8* noalias align 1 dereferenceable(10) [[TMP1]], i32 10, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(10) [[TMP0]], i8* align 1 dereferenceable(10) [[TMP1]], i32 10, i1 false) ; CHECK-NEXT: ret i8* [[TMP0]] ; entry: Index: test/Transforms/InstCombine/sprintf-1.ll =================================================================== --- test/Transforms/InstCombine/sprintf-1.ll +++ test/Transforms/InstCombine/sprintf-1.ll @@ -21,11 +21,11 @@ define void @test_simplify1(i8* %dst) { ; CHECK-LABEL: @test_simplify1( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(13) [[DST:%.*]], i8* noalias align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 13, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(13) [[DST:%.*]], i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 13, i1 false) ; CHECK-NEXT: ret void ; ; CHECK-IPRINTF-LABEL: @test_simplify1( -; CHECK-IPRINTF-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(13) [[DST:%.*]], i8* noalias align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 13, i1 false) +; CHECK-IPRINTF-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(13) [[DST:%.*]], i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 13, i1 false) ; CHECK-IPRINTF-NEXT: ret void ; %fmt = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0 @@ -87,13 +87,13 @@ ; CHECK-LABEL: @test_simplify5( ; CHECK-NEXT: [[STRLEN:%.*]] = call i32 @strlen(i8* [[STR:%.*]]) ; CHECK-NEXT: [[LENINC:%.*]] = add i32 [[STRLEN]], 1 -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 [[DST:%.*]], i8* noalias align 1 [[STR]], i32 [[LENINC]], i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[DST:%.*]], i8* align 1 [[STR]], i32 [[LENINC]], i1 false) ; CHECK-NEXT: ret void ; ; CHECK-IPRINTF-LABEL: @test_simplify5( ; CHECK-IPRINTF-NEXT: [[STRLEN:%.*]] = call i32 @strlen(i8* [[STR:%.*]]) ; CHECK-IPRINTF-NEXT: [[LENINC:%.*]] = add i32 [[STRLEN]], 1 -; CHECK-IPRINTF-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 [[DST:%.*]], i8* noalias align 1 [[STR]], i32 [[LENINC]], i1 false) +; CHECK-IPRINTF-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[DST:%.*]], i8* align 1 [[STR]], i32 [[LENINC]], i1 false) ; CHECK-IPRINTF-NEXT: ret void ; %fmt = getelementptr [3 x i8], [3 x i8]* @percent_s, i32 0, i32 0 Index: test/Transforms/InstCombine/stpcpy-1.ll =================================================================== --- test/Transforms/InstCombine/stpcpy-1.ll +++ test/Transforms/InstCombine/stpcpy-1.ll @@ -1,3 +1,4 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; Test that the stpcpy library call simplifier works correctly. ; RUN: opt < %s -instcombine -S | FileCheck %s ; @@ -13,34 +14,39 @@ define i8* @test_simplify1() { ; CHECK-LABEL: @test_simplify1( +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(6) getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @hello, i32 0, i32 0), i32 6, i1 false) +; CHECK-NEXT: ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 5) +; %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0 %src = getelementptr [6 x i8], [6 x i8]* @hello, i32 0, i32 0 %ret = call i8* @stpcpy(i8* %dst, i8* %src) -; CHECK: @llvm.memcpy.p0i8.p0i8.i32 -; CHECK-NEXT: getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 5) ret i8* %ret } define i8* @test_simplify2() { ; CHECK-LABEL: @test_simplify2( +; CHECK-NEXT: [[STRLEN:%.*]] = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0)) +; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [32 x i8], [32 x i8]* @a, i32 0, i32 [[STRLEN]] +; CHECK-NEXT: ret i8* [[TMP1]] +; %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0 %ret = call i8* @stpcpy(i8* %dst, i8* %dst) -; CHECK: [[LEN:%[a-z]+]] = call i32 @strlen -; CHECK-NEXT: getelementptr inbounds [32 x i8], [32 x i8]* @a, i32 0, i32 [[LEN]] ret i8* %ret } define i8* @test_no_simplify1() { ; CHECK-LABEL: @test_no_simplify1( +; CHECK-NEXT: [[RET:%.*]] = call i8* @stpcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @b, i32 0, i32 0)) +; CHECK-NEXT: ret i8* [[RET]] +; %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0 %src = getelementptr [32 x i8], [32 x i8]* @b, i32 0, i32 0 %ret = call i8* @stpcpy(i8* %dst, i8* %src) -; CHECK: call i8* @stpcpy ret i8* %ret } Index: test/Transforms/InstCombine/stpcpy_chk-1.ll =================================================================== --- test/Transforms/InstCombine/stpcpy_chk-1.ll +++ test/Transforms/InstCombine/stpcpy_chk-1.ll @@ -14,7 +14,7 @@ define i8* @test_simplify1() { ; CHECK-LABEL: @test_simplify1( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 11) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 @@ -26,7 +26,7 @@ define i8* @test_simplify2() { ; CHECK-LABEL: @test_simplify2( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 11) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 @@ -38,7 +38,7 @@ define i8* @test_simplify3() { ; CHECK-LABEL: @test_simplify3( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 11) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 Index: test/Transforms/InstCombine/strcpy_chk-1.ll =================================================================== --- test/Transforms/InstCombine/strcpy_chk-1.ll +++ test/Transforms/InstCombine/strcpy_chk-1.ll @@ -14,7 +14,7 @@ define i8* @test_simplify1() { ; CHECK-LABEL: @test_simplify1( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 @@ -26,7 +26,7 @@ define i8* @test_simplify2() { ; CHECK-LABEL: @test_simplify2( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 @@ -38,7 +38,7 @@ define i8* @test_simplify3() { ; CHECK-LABEL: @test_simplify3( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 @@ -52,7 +52,7 @@ define i8* @test_simplify4() { ; CHECK-LABEL: @test_simplify4( -; CHECK-NEXT: [[STRCPY:%.*]] = call i8* @strcpy(i8* noalias getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias getelementptr inbounds ([60 x i8], [60 x i8]* @b, i32 0, i32 0)) +; CHECK-NEXT: [[STRCPY:%.*]] = call i8* @strcpy(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @b, i32 0, i32 0)) ; CHECK-NEXT: ret i8* [[STRCPY]] ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 Index: test/Transforms/InstCombine/strncpy_chk-1.ll =================================================================== --- test/Transforms/InstCombine/strncpy_chk-1.ll +++ test/Transforms/InstCombine/strncpy_chk-1.ll @@ -14,7 +14,7 @@ define i8* @test_simplify1() { ; CHECK-LABEL: @test_simplify1( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 @@ -26,7 +26,7 @@ define i8* @test_simplify2() { ; CHECK-LABEL: @test_simplify2( -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 dereferenceable(12) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 12, i1 false) ; CHECK-NEXT: ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0) ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 @@ -38,7 +38,7 @@ define i8* @test_simplify3() { ; CHECK-LABEL: @test_simplify3( -; CHECK-NEXT: [[STRNCPY:%.*]] = call i8* @strncpy(i8* noalias getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* noalias getelementptr inbounds ([60 x i8], [60 x i8]* @b, i32 0, i32 0), i32 12) +; CHECK-NEXT: [[STRNCPY:%.*]] = call i8* @strncpy(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i32 0, i32 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @b, i32 0, i32 0), i32 12) ; CHECK-NEXT: ret i8* [[STRNCPY]] ; %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0 Index: test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll =================================================================== --- test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll +++ test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll @@ -34,7 +34,7 @@ ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(64) [[SRET_CAST]], i8 0, i64 64, i1 false) ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(32) [[A_CAST]], i8 42, i64 32, i1 false) ; CHECK-NEXT: [[OUT_CAST:%.*]] = bitcast [8 x i64]* [[OUT:%.*]] to i8* -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nonnull align 8 dereferenceable(64) [[OUT_CAST]], i8* noalias nonnull align 8 dereferenceable(64) [[A_CAST]], i64 64, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(64) [[OUT_CAST]], i8* nonnull align 8 dereferenceable(64) [[A_CAST]], i64 64, i1 false) ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 64, i8* nonnull [[A_CAST]]) ; CHECK-NEXT: ret void ;