diff options
author | Duncan Sands <baldrick@free.fr> | 2010-01-06 08:45:52 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-01-06 08:45:52 +0000 |
commit | 7c422ac216fe39fc9c402a704cf296cca9dc5b22 (patch) | |
tree | de0f0e167e65367280cc1d2239699ff52840d87f /test/Transforms/FunctionAttrs | |
parent | eaba5102e4f581b2d99794bffcbf2f6d7c3c7dc2 (diff) | |
download | external_llvm-7c422ac216fe39fc9c402a704cf296cca9dc5b22.zip external_llvm-7c422ac216fe39fc9c402a704cf296cca9dc5b22.tar.gz external_llvm-7c422ac216fe39fc9c402a704cf296cca9dc5b22.tar.bz2 |
Partially address a README by having functionattrs consider calls to
memcpy, memset and other intrinsics that only access their arguments
to be readnone if the intrinsic's arguments all point to local memory.
This improves the testcase in the README to readonly, but it could in
theory be made readnone, however this would involve more sophisticated
analysis that looks through the memcpy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/FunctionAttrs')
-rw-r--r-- | test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll b/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll index 09eb468..460780d 100644 --- a/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll +++ b/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll @@ -1,6 +1,8 @@ -; RUN: opt < %s -functionattrs -S | grep readnone | count 2 +; RUN: opt < %s -functionattrs -S | grep readonly | count 3 -declare i32 @g(i32*) readnone +%struct.X = type { i32*, i32* } + +declare i32 @g(i32*) readonly define i32 @f() { %x = alloca i32 ; <i32*> [#uses=2] @@ -8,3 +10,30 @@ define i32 @f() { %y = call i32 @g(i32* %x) ; <i32> [#uses=1] ret i32 %y } + +define i32 @foo() nounwind { +entry: + %y = alloca %struct.X ; <%struct.X*> [#uses=2] + %x = alloca %struct.X ; <%struct.X*> [#uses=2] + %j = alloca i32 ; <i32*> [#uses=2] + %i = alloca i32 ; <i32*> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] + store i32 0, i32* %i, align 4 + store i32 1, i32* %j, align 4 + %0 = getelementptr inbounds %struct.X* %y, i32 0, i32 0 ; <i32**> [#uses=1] + store i32* %i, i32** %0, align 8 + %1 = getelementptr inbounds %struct.X* %x, i32 0, i32 1 ; <i32**> [#uses=1] + store i32* %j, i32** %1, align 8 + %x1 = bitcast %struct.X* %x to i8* ; <i8*> [#uses=2] + %y2 = bitcast %struct.X* %y to i8* ; <i8*> [#uses=1] + call void @llvm.memcpy.i64(i8* %x1, i8* %y2, i64 8, i32 1) + %2 = bitcast i8* %x1 to i32** ; <i32**> [#uses=1] + %3 = load i32** %2, align 8 ; <i32*> [#uses=1] + %4 = load i32* %3, align 4 ; <i32> [#uses=1] + br label %return + +return: ; preds = %entry + ret i32 %4 +} + +declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind |