llvm.org GIT mirror llvm / 85fbe68
Merging r259911: ------------------------------------------------------------------------ r259911 | Matthew.Arsenault | 2016-02-05 11:47:23 -0800 (Fri, 05 Feb 2016) | 5 lines AMDGPU: Preserve alignments on new created globals Also switch to internal linkage, and include the name of the function in the name. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@271639 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 years ago
3 changed file(s) with 40 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
354354 DEBUG(dbgs() << "Promoting alloca to local memory\n");
355355 LocalMemAvailable -= AllocaSize;
356356
357 Function *F = I.getParent()->getParent();
358
357359 Type *GVTy = ArrayType::get(I.getAllocatedType(), 256);
358360 GlobalVariable *GV = new GlobalVariable(
359 *Mod, GVTy, false, GlobalValue::ExternalLinkage, 0, I.getName(), 0,
360 GlobalVariable::NotThreadLocal, AMDGPUAS::LOCAL_ADDRESS);
361 *Mod, GVTy, false, GlobalValue::InternalLinkage,
362 UndefValue::get(GVTy),
363 Twine(F->getName()) + Twine('.') + I.getName(),
364 nullptr,
365 GlobalVariable::NotThreadLocal,
366 AMDGPUAS::LOCAL_ADDRESS);
367 GV->setUnnamedAddr(true);
368 GV->setAlignment(I.getAlignment());
361369
362370 FunctionType *FTy = FunctionType::get(
363371 Type::getInt32Ty(Mod->getContext()), false);
66 ; RUN: llc -show-mc-encoding -mattr=-promote-alloca -verify-machineinstrs -march=amdgcn -mcpu=tonga < %s | FileCheck %s -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC
77
88 declare i32 @llvm.r600.read.tidig.x() nounwind readnone
9
10 ; HSAOPT: @mova_same_clause.stack = internal unnamed_addr addrspace(3) global [256 x [5 x i32]] undef, align 4
11 ; HSAOPT: @high_alignment.stack = internal unnamed_addr addrspace(3) global [256 x [8 x i32]] undef, align 16
12
913
1014 ; FUNC-LABEL: {{^}}mova_same_clause:
1115
4549 %2 = load i32, i32* %arrayidx10, align 4
4650 store i32 %2, i32 addrspace(1)* %out, align 4
4751 %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
52 %3 = load i32, i32* %arrayidx12
53 %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
54 store i32 %3, i32 addrspace(1)* %arrayidx13
55 ret void
56 }
57
58 ; OPT-LABEL: @high_alignment(
59 ; OPT: getelementptr inbounds [256 x [8 x i32]], [256 x [8 x i32]] addrspace(3)* @high_alignment.stack, i32 0, i32 %{{[0-9]+}}
60 define void @high_alignment(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) {
61 entry:
62 %stack = alloca [8 x i32], align 16
63 %0 = load i32, i32 addrspace(1)* %in, align 4
64 %arrayidx1 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 %0
65 store i32 4, i32* %arrayidx1, align 4
66 %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
67 %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
68 %arrayidx3 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 %1
69 store i32 5, i32* %arrayidx3, align 4
70 %arrayidx10 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 0
71 %2 = load i32, i32* %arrayidx10, align 4
72 store i32 %2, i32 addrspace(1)* %out, align 4
73 %arrayidx12 = getelementptr inbounds [8 x i32], [8 x i32]* %stack, i32 0, i32 1
4874 %3 = load i32, i32* %arrayidx12
4975 %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
5076 store i32 %3, i32 addrspace(1)* %arrayidx13
1010 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) #1
1111
1212 ; CHECK-LABEL: @promote_with_memcpy(
13 ; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca, i32 0, i32 %{{[0-9]+}}
13 ; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @promote_with_memcpy.alloca, i32 0, i32 %{{[0-9]+}}
1414 ; CHECK: call void @llvm.memcpy.p3i8.p1i8.i32(i8 addrspace(3)* %alloca.bc, i8 addrspace(1)* %in.bc, i32 68, i32 4, i1 false)
1515 ; CHECK: call void @llvm.memcpy.p1i8.p3i8.i32(i8 addrspace(1)* %out.bc, i8 addrspace(3)* %alloca.bc, i32 68, i32 4, i1 false)
1616 define void @promote_with_memcpy(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
2424 }
2525
2626 ; CHECK-LABEL: @promote_with_memmove(
27 ; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca.1, i32 0, i32 %{{[0-9]+}}
27 ; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @promote_with_memmove.alloca, i32 0, i32 %{{[0-9]+}}
2828 ; CHECK: call void @llvm.memmove.p3i8.p1i8.i32(i8 addrspace(3)* %alloca.bc, i8 addrspace(1)* %in.bc, i32 68, i32 4, i1 false)
2929 ; CHECK: call void @llvm.memmove.p1i8.p3i8.i32(i8 addrspace(1)* %out.bc, i8 addrspace(3)* %alloca.bc, i32 68, i32 4, i1 false)
3030 define void @promote_with_memmove(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
3838 }
3939
4040 ; CHECK-LABEL: @promote_with_memset(
41 ; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca.2, i32 0, i32 %{{[0-9]+}}
41 ; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @promote_with_memset.alloca, i32 0, i32 %{{[0-9]+}}
4242 ; CHECK: call void @llvm.memset.p3i8.i32(i8 addrspace(3)* %alloca.bc, i8 7, i32 68, i32 4, i1 false)
4343 define void @promote_with_memset(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
4444 %alloca = alloca [17 x i32], align 16
5050 }
5151
5252 ; CHECK-LABEL: @promote_with_objectsize(
53 ; CHECK: [[PTR:%[0-9]+]] = getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca.3, i32 0, i32 %{{[0-9]+}}
53 ; CHECK: [[PTR:%[0-9]+]] = getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @promote_with_objectsize.alloca, i32 0, i32 %{{[0-9]+}}
5454 ; CHECK: call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* %alloca.bc, i1 false)
5555 define void @promote_with_objectsize(i32 addrspace(1)* %out) #0 {
5656 %alloca = alloca [17 x i32], align 16