From: Elena Demikhovsky Date: Tue, 17 Nov 2015 19:30:51 +0000 (+0000) Subject: Vector of pointers in function attributes calculation X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=741a7722138d02a0b0141a56f3e6a5f290f2ffaa Vector of pointers in function attributes calculation While setting function attributes we check all instructions that may access memory. For a call instruction we check all arguments. The special check is required for pointers. I added vector-of-pointers to the call arguments types that should be checked. Differential Revision: http://reviews.llvm.org/D14693 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253363 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index edebc26d475..8a697c3e6af 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -154,7 +154,7 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, AAResults &AAR, for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); CI != CE; ++CI) { Value *Arg = *CI; - if (!Arg->getType()->isPointerTy()) + if (!Arg->getType()->isPtrOrPtrVectorTy()) continue; AAMDNodes AAInfo; diff --git a/test/Transforms/FunctionAttrs/readattrs.ll b/test/Transforms/FunctionAttrs/readattrs.ll index 7f22e6f2a2c..aabdfe8d200 100644 --- a/test/Transforms/FunctionAttrs/readattrs.ll +++ b/test/Transforms/FunctionAttrs/readattrs.ll @@ -65,3 +65,41 @@ entry: store i32 10, i32* %call, align 4 ret void } + +; CHECK: declare void @llvm.masked.scatter +declare void @llvm.masked.scatter.v4i32(<4 x i32>%val, <4 x i32*>, i32, <4 x i1>) + +; CHECK-NOT: readnone +; CHECK-NOT: readonly +; CHECK: define void @test9 +define void @test9(<4 x i32*> %ptrs, <4 x i32>%val) { + call void @llvm.masked.scatter.v4i32(<4 x i32>%val, <4 x i32*> %ptrs, i32 4, <4 x i1>) + ret void +} + +; CHECK: declare <4 x i32> @llvm.masked.gather +declare <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*>, i32, <4 x i1>, <4 x i32>) +; CHECK: readonly +; CHECK: define <4 x i32> @test10 +define <4 x i32> @test10(<4 x i32*> %ptrs) { + %res = call <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*> %ptrs, i32 4, <4 x i1>, <4 x i32>undef) + ret <4 x i32> %res +} + +; CHECK: declare <4 x i32> @test11_1 +declare <4 x i32> @test11_1(<4 x i32*>) argmemonly nounwind readonly +; CHECK: readonly +; CHECK-NOT: readnone +; CHECK: define <4 x i32> @test11_2 +define <4 x i32> @test11_2(<4 x i32*> %ptrs) { + %res = call <4 x i32> @test11_1(<4 x i32*> %ptrs) + ret <4 x i32> %res +} + +declare <4 x i32> @test12_1(<4 x i32*>) argmemonly nounwind +; CHECK-NOT: readnone +; CHECK: define <4 x i32> @test12_2 +define <4 x i32> @test12_2(<4 x i32*> %ptrs) { + %res = call <4 x i32> @test12_1(<4 x i32*> %ptrs) + ret <4 x i32> %res +}