From e10920d678c4d6046619e51770de1c9de0c3fe0a Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Wed, 6 Jan 2010 15:37:47 +0000 Subject: Fix a README item: have functionattrs look through selects and phi nodes when deciding which pointers point to local memory. I actually checked long ago how useful this is, and it isn't very: it hardly ever fires in the testsuite, but since Chris wants it here it is! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92836 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../FunctionAttrs/2008-10-04-LocalMemory.ll | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'test/Transforms/FunctionAttrs') diff --git a/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll b/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll index 460780d..c6c2e13 100644 --- a/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll +++ b/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll @@ -1,10 +1,11 @@ -; RUN: opt < %s -functionattrs -S | grep readonly | count 3 +; RUN: opt < %s -functionattrs -S | FileCheck %s %struct.X = type { i32*, i32* } -declare i32 @g(i32*) readonly +declare i32 @g(i32*) readnone define i32 @f() { +; CHECK: @f() readnone %x = alloca i32 ; [#uses=2] store i32 0, i32* %x %y = call i32 @g(i32* %x) ; [#uses=1] @@ -12,6 +13,7 @@ define i32 @f() { } define i32 @foo() nounwind { +; CHECK: @foo() nounwind readonly entry: %y = alloca %struct.X ; <%struct.X*> [#uses=2] %x = alloca %struct.X ; <%struct.X*> [#uses=2] @@ -36,4 +38,27 @@ return: ; preds = %entry ret i32 %4 } +define i32 @t(i32 %a, i32 %b, i32 %c) nounwind { +; CHECK: @t(i32 %a, i32 %b, i32 %c) nounwind readnone +entry: + %a.addr = alloca i32 ; [#uses=3] + %c.addr = alloca i32 ; [#uses=2] + store i32 %a, i32* %a.addr + store i32 %c, i32* %c.addr + %tmp = load i32* %a.addr ; [#uses=1] + %tobool = icmp ne i32 %tmp, 0 ; [#uses=1] + br i1 %tobool, label %if.then, label %if.else + +if.then: ; preds = %entry + br label %if.end + +if.else: ; preds = %entry + br label %if.end + +if.end: ; preds = %if.else, %if.then + %p.0 = phi i32* [ %a.addr, %if.then ], [ %c.addr, %if.else ] ; [#uses=1] + %tmp2 = load i32* %p.0 ; [#uses=1] + ret i32 %tmp2 +} + declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind -- cgit v1.1