]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/commitdiff
Make nocapture analysis work with addrspacecast
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 14 Jan 2014 19:11:52 +0000 (19:11 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 14 Jan 2014 19:11:52 +0000 (19:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199246 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CaptureTracking.cpp
lib/Transforms/IPO/FunctionAttrs.cpp
test/Transforms/FunctionAttrs/nocapture.ll

index 79fab1be441392401d281a62013523595abb7a49..960f86b86cde2f1cda88e82d3af858f332ac76fa 100644 (file)
@@ -145,6 +145,7 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
     case Instruction::GetElementPtr:
     case Instruction::PHI:
     case Instruction::Select:
+    case Instruction::AddrSpaceCast:
       // The original value is not captured via this if the new value isn't.
       Count = 0;
       for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end();
index 6e41f262fa6f1e4c0ad9f7cdb9ddf495589b5121..ea664506da2d7a56cfcf53e28e72d6e47705f9e6 100644 (file)
@@ -437,6 +437,7 @@ determinePointerReadAttrs(Argument *A,
     case Instruction::GetElementPtr:
     case Instruction::PHI:
     case Instruction::Select:
+    case Instruction::AddrSpaceCast:
       // The original value is not read/written via this if the new value isn't.
       for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end();
            UI != UE; ++UI) {
@@ -723,6 +724,7 @@ bool FunctionAttrs::IsFunctionMallocLike(Function *F,
         // Extend the analysis by looking upwards.
         case Instruction::BitCast:
         case Instruction::GetElementPtr:
+        case Instruction::AddrSpaceCast:
           FlowsToReturn.insert(RVI->getOperand(0));
           continue;
         case Instruction::Select: {
index 110bd03dac736ce63ac7d0846323f49e2beb6bf4..d2460c0b6ded01035e4a5b63f5454f6da39bc34a 100644 (file)
@@ -91,6 +91,21 @@ l:
        ret i32 %val
 }
 
+; CHECK: define i32 @nc1_addrspace(i32* %q, i32 addrspace(1)* nocapture %p, i1 %b)
+define i32 @nc1_addrspace(i32* %q, i32 addrspace(1)* %p, i1 %b) {
+e:
+       br label %l
+l:
+       %x = phi i32 addrspace(1)* [ %p, %e ]
+       %y = phi i32* [ %q, %e ]
+       %tmp = addrspacecast i32 addrspace(1)* %x to i32*               ; <i32*> [#uses=2]
+       %tmp2 = select i1 %b, i32* %tmp, i32* %y
+       %val = load i32* %tmp2          ; <i32> [#uses=1]
+       store i32 0, i32* %tmp
+       store i32* %y, i32** @g
+       ret i32 %val
+}
+
 ; CHECK: define void @nc2(i32* nocapture %p, i32* %q)
 define void @nc2(i32* %p, i32* %q) {
        %1 = call i32 @nc1(i32* %q, i32* %p, i1 0)              ; <i32> [#uses=0]