aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-03-19 19:59:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-03-19 19:59:04 +0000
commit1b3bef43e3cb7fb0ab49b813839915514c1134cc (patch)
tree4e2442d6a94566cb299c81359f486700d3e84b6a
parent2548237983c47c61601b883bb9d6c9a803ef8ce4 (diff)
-rw-r--r--contrib/llvm-project/llvm/lib/IR/Operator.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/contrib/llvm-project/llvm/lib/IR/Operator.cpp b/contrib/llvm-project/llvm/lib/IR/Operator.cpp
index 18a1c84933e0..f9dbed31c44c 100644
--- a/contrib/llvm-project/llvm/lib/IR/Operator.cpp
+++ b/contrib/llvm-project/llvm/lib/IR/Operator.cpp
@@ -190,12 +190,14 @@ bool GEPOperator::collectOffset(
if (STy || ScalableType)
return false;
- // Insert an initial offset of 0 for V iff none exists already, then
- // increment the offset by IndexedSize.
- VariableOffsets.insert({V, APInt(BitWidth, 0)});
APInt IndexedSize =
APInt(BitWidth, DL.getTypeAllocSize(GTI.getIndexedType()));
- VariableOffsets[V] += IndexedSize;
+ // Insert an initial offset of 0 for V iff none exists already, then
+ // increment the offset by IndexedSize.
+ if (!IndexedSize.isZero()) {
+ VariableOffsets.insert({V, APInt(BitWidth, 0)});
+ VariableOffsets[V] += IndexedSize;
+ }
}
return true;
}