[llvm-commits] [release_20] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Tanya Lattner
tonic at nondot.org
Thu May 17 23:04:10 PDT 2007
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.762 -> 1.762.2.1
---
Log message:
Merge from mainline.
---
Diffs of the changes: (+16 -7)
InstructionCombining.cpp | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.762 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.762.2.1
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.762 Sun May 6 08:37:16 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 18 01:03:55 2007
@@ -6449,16 +6449,25 @@
while (Offset) {
if (const StructType *STy = dyn_cast<StructType>(GEPIdxTy)) {
const StructLayout *SL = TD->getStructLayout(STy);
- unsigned Elt = SL->getElementContainingOffset(Offset);
- NewIndices.push_back(ConstantInt::get(Type::Int32Ty, Elt));
+ if (Offset < (int64_t)SL->getSizeInBytes()) {
+ unsigned Elt = SL->getElementContainingOffset(Offset);
+ NewIndices.push_back(ConstantInt::get(Type::Int32Ty, Elt));
- Offset -= SL->getElementOffset(Elt);
- GEPIdxTy = STy->getElementType(Elt);
+ Offset -= SL->getElementOffset(Elt);
+ GEPIdxTy = STy->getElementType(Elt);
+ } else {
+ // Otherwise, we can't index into this, bail out.
+ Offset = 0;
+ OrigBase = 0;
+ }
} else if (isa<ArrayType>(GEPIdxTy) || isa<VectorType>(GEPIdxTy)) {
const SequentialType *STy = cast<SequentialType>(GEPIdxTy);
- uint64_t EltSize = TD->getTypeSize(STy->getElementType());
- NewIndices.push_back(ConstantInt::get(IntPtrTy, Offset/EltSize));
- Offset %= EltSize;
+ if (uint64_t EltSize = TD->getTypeSize(STy->getElementType())) {
+ NewIndices.push_back(ConstantInt::get(IntPtrTy,Offset/EltSize));
+ Offset %= EltSize;
+ } else {
+ NewIndices.push_back(ConstantInt::get(IntPtrTy, 0));
+ }
GEPIdxTy = STy->getElementType();
} else {
// Otherwise, we can't index into this, bail out.
More information about the llvm-commits
mailing list