mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Make sure constant subscript is truncated to ptr size if it may not fit.
llvm-svn: 64163
This commit is contained in:
parent
f47945d757
commit
44e58653af
@ -2699,8 +2699,15 @@ void SelectionDAGLowering::visitGetElementPtr(User &I) {
|
||||
if (CI->getZExtValue() == 0) continue;
|
||||
uint64_t Offs =
|
||||
TD->getTypePaddedSize(Ty)*cast<ConstantInt>(CI)->getSExtValue();
|
||||
SDValue OffsVal = DAG.getConstant(Offs, MVT::i64);
|
||||
unsigned PtrBits = TLI.getPointerTy().getSizeInBits();
|
||||
if (PtrBits < 64)
|
||||
OffsVal = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(),
|
||||
TLI.getPointerTy(), OffsVal);
|
||||
else
|
||||
OffsVal = DAG.getIntPtrConstant(Offs);
|
||||
N = DAG.getNode(ISD::ADD, getCurDebugLoc(), N.getValueType(), N,
|
||||
DAG.getIntPtrConstant(Offs));
|
||||
OffsVal);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
10
test/CodeGen/X86/negative-subscript.ll
Normal file
10
test/CodeGen/X86/negative-subscript.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: llvm-as < %s | llc -march=x86
|
||||
; rdar://6559995
|
||||
|
||||
@a = external global [255 x i8*], align 32
|
||||
|
||||
define i32 @main() nounwind {
|
||||
entry:
|
||||
store i8* bitcast (i8** getelementptr ([255 x i8*]* @a, i32 0, i32 -2147483624) to i8*), i8** getelementptr ([255 x i8*]* @a, i32 0, i32 16), align 32
|
||||
ret i32 0
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user