[llvm] r199246 - Make nocapture analysis work with addrspacecast
Matt Arsenault
Matthew.Arsenault at amd.com
Tue Jan 14 11:11:53 PST 2014
Author: arsenm
Date: Tue Jan 14 13:11:52 2014
New Revision: 199246
URL: http://llvm.org/viewvc/llvm-project?rev=199246&view=rev
Log:
Make nocapture analysis work with addrspacecast
Modified:
llvm/trunk/lib/Analysis/CaptureTracking.cpp
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll
Modified: llvm/trunk/lib/Analysis/CaptureTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CaptureTracking.cpp?rev=199246&r1=199245&r2=199246&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CaptureTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/CaptureTracking.cpp Tue Jan 14 13:11:52 2014
@@ -145,6 +145,7 @@ void llvm::PointerMayBeCaptured(const Va
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();
Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=199246&r1=199245&r2=199246&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Tue Jan 14 13:11:52 2014
@@ -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
// Extend the analysis by looking upwards.
case Instruction::BitCast:
case Instruction::GetElementPtr:
+ case Instruction::AddrSpaceCast:
FlowsToReturn.insert(RVI->getOperand(0));
continue;
case Instruction::Select: {
Modified: llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll?rev=199246&r1=199245&r2=199246&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll (original)
+++ llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll Tue Jan 14 13:11:52 2014
@@ -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]
More information about the llvm-commits
mailing list