aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorEli Friedman <efriedma@quicinc.com>2020-03-03 15:42:16 -0800
committerEli Friedman <efriedma@quicinc.com>2020-03-18 13:53:17 -0700
commite24e95fe900ab9d84017e4210b305d6c3a44abb0 (patch)
tree2675672877c8dd6896d36e4c06444e94cff1cfa7 /llvm/lib/IR/ConstantFold.cpp
parentc682a605eb47e8eb8e3dac19b514a8ae7506a25f (diff)
downloadllvm-e24e95fe900ab9d84017e4210b305d6c3a44abb0.zip
llvm-e24e95fe900ab9d84017e4210b305d6c3a44abb0.tar.gz
llvm-e24e95fe900ab9d84017e4210b305d6c3a44abb0.tar.bz2
Remove CompositeType class.
The existence of the class is more confusing than helpful, I think; the commonality is mostly just "GEP is legal", which can be queried using APIs on GetElementPtrInst. Differential Revision: https://reviews.llvm.org/D75660
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index dc78c55..3e2e74c 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -2389,10 +2389,11 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
SmallVector<Constant *, 8> NewIdxs;
Type *Ty = PointeeTy;
Type *Prev = C->getType();
+ auto GEPIter = gep_type_begin(PointeeTy, Idxs);
bool Unknown =
!isa<ConstantInt>(Idxs[0]) && !isa<ConstantDataVector>(Idxs[0]);
for (unsigned i = 1, e = Idxs.size(); i != e;
- Prev = Ty, Ty = cast<CompositeType>(Ty)->getTypeAtIndex(Idxs[i]), ++i) {
+ Prev = Ty, Ty = (++GEPIter).getIndexedType(), ++i) {
if (!isa<ConstantInt>(Idxs[i]) && !isa<ConstantDataVector>(Idxs[i])) {
// We don't know if it's in range or not.
Unknown = true;