[llvm-commits] [llvm] r64163 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp test/CodeGen/X86/negative-subscript.ll
Evan Cheng
evan.cheng at apple.com
Mon Feb 9 12:54:38 PST 2009
Author: evancheng
Date: Mon Feb 9 14:54:38 2009
New Revision: 64163
URL: http://llvm.org/viewvc/llvm-project?rev=64163&view=rev
Log:
Make sure constant subscript is truncated to ptr size if it may not fit.
Added:
llvm/trunk/test/CodeGen/X86/negative-subscript.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=64163&r1=64162&r2=64163&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon Feb 9 14:54:38 2009
@@ -2699,8 +2699,15 @@
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;
}
Added: llvm/trunk/test/CodeGen/X86/negative-subscript.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/negative-subscript.ll?rev=64163&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/negative-subscript.ll (added)
+++ llvm/trunk/test/CodeGen/X86/negative-subscript.ll Mon Feb 9 14:54:38 2009
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | llc -march=x86
+; rdar://6559995
+
+ at 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
+}
More information about the llvm-commits
mailing list