Skip to content

Commit c7479f2

Browse files
committed
Use right address space pointer size
llvm-svn: 194940
1 parent a0f6c18 commit c7479f2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,10 @@ SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV, SDLoc DL,
11261126
unsigned char TargetFlags) {
11271127
assert((TargetFlags == 0 || isTargetGA) &&
11281128
"Cannot set target flags on target-independent globals");
1129+
const TargetLowering *TLI = TM.getTargetLowering();
11291130

11301131
// Truncate (with sign-extension) the offset value to the pointer size.
1131-
unsigned BitWidth = TM.getTargetLowering()->getPointerTy().getSizeInBits();
1132+
unsigned BitWidth = TLI->getPointerTypeSizeInBits(GV->getType());
11321133
if (BitWidth < 64)
11331134
Offset = SignExtend64(Offset, BitWidth);
11341135

llvm/test/CodeGen/R600/32-bit-local-address-space.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,14 @@ define void @infer_ptr_alignment_global_offset(float addrspace(1)* %out, i32 %ti
7373
store float %val, float addrspace(1)* %out
7474
ret void
7575
}
76+
77+
78+
@ptr = addrspace(3) global i32 addrspace(3)* null
79+
@dst = addrspace(3) global [16384 x i32] zeroinitializer
80+
81+
; SI-LABEL: @global_ptr:
82+
; SI-CHECK: DS_WRITE_B32
83+
define void @global_ptr() nounwind {
84+
store i32 addrspace(3)* getelementptr ([16384 x i32] addrspace(3)* @dst, i32 0, i32 16), i32 addrspace(3)* addrspace(3)* @ptr
85+
ret void
86+
}

0 commit comments

Comments
 (0)