llvm.org GIT mirror llvm / dbc18f5
Merging r264214: ------------------------------------------------------------------------ r264214 | Matthew.Arsenault | 2016-03-23 16:17:29 -0700 (Wed, 23 Mar 2016) | 2 lines AMDGPU: Promote alloca should skip volatiles ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@271729 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 years ago
2 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
300300 return false;
301301
302302 if (StoreInst *SI = dyn_cast_or_null(UseInst)) {
303 if (SI->isVolatile())
304 return false;
305
303306 // Reject if the stored value is not the pointer operand.
304307 if (SI->getPointerOperand() != Val)
308 return false;
309 } else if (LoadInst *LI = dyn_cast_or_null(UseInst)) {
310 if (LI->isVolatile())
311 return false;
312 } else if (AtomicRMWInst *RMW = dyn_cast_or_null(UseInst)) {
313 if (RMW->isVolatile())
314 return false;
315 } else if (AtomicCmpXchgInst *CAS
316 = dyn_cast_or_null(UseInst)) {
317 if (CAS->isVolatile())
305318 return false;
306319 }
307320
0 ; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s
1
2 ; CHECK-LABEL: @volatile_load(
3 ; CHECK: alloca [5 x i32]
4 ; CHECK load volatile i32, i32*
5 define void @volatile_load(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
6 entry:
7 %stack = alloca [5 x i32], align 4
8 %tmp = load i32, i32 addrspace(1)* %in, align 4
9 %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
10 %load = load volatile i32, i32* %arrayidx1
11 store i32 %load, i32 addrspace(1)* %out
12 ret void
13 }
14
15 ; CHECK-LABEL: @volatile_store(
16 ; CHECK: alloca [5 x i32]
17 ; CHECK store volatile i32 %tmp, i32*
18 define void @volatile_store(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
19 entry:
20 %stack = alloca [5 x i32], align 4
21 %tmp = load i32, i32 addrspace(1)* %in, align 4
22 %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
23 store volatile i32 %tmp, i32* %arrayidx1
24 ret void
25 }