diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-12-02 03:05:41 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-12-02 03:05:41 +0000 |
commit | 4568158c4d304da17bc3c05409609d0f18efa573 (patch) | |
tree | 47afecf586ac9a7fa10891980557f223ebbe444d /llvm/lib/IR/ConstantFold.cpp | |
parent | 858c092daad5b707382194b698d5880c1c9b91ce (diff) | |
download | bcm5719-llvm-4568158c4d304da17bc3c05409609d0f18efa573.tar.gz bcm5719-llvm-4568158c4d304da17bc3c05409609d0f18efa573.zip |
IR: Change PointerType to derive from Type rather than SequentialType.
As proposed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2016-October/106640.html
This is for a couple of reasons:
- Values of type PointerType are unlike the other SequentialTypes (arrays
and vectors) in that they do not hold values of the element type. By moving
PointerType we can unify certain aspects of how the other SequentialTypes
are handled.
- PointerType will have no place in the SequentialType hierarchy once
pointee types are removed, so this is a necessary step towards removing
pointee types.
Differential Revision: https://reviews.llvm.org/D26595
llvm-svn: 288462
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 60f6fbb6f65..6360b4503a4 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -120,7 +120,6 @@ static Constant *FoldBitCast(Constant *V, Type *DestTy) { IdxList.push_back(Zero); } else if (SequentialType *STy = dyn_cast<SequentialType>(ElTy)) { - if (ElTy->isPointerTy()) break; // Can't index into pointers! ElTy = STy->getElementType(); IdxList.push_back(Zero); } else { @@ -2206,11 +2205,6 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, continue; } auto *STy = cast<SequentialType>(Ty); - if (isa<PointerType>(STy)) { - // We don't know if it's in range or not. - Unknown = true; - continue; - } if (isa<VectorType>(STy)) { // There can be awkward padding in after a non-power of two vector. Unknown = true; @@ -2222,7 +2216,7 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, CI)) // It's in range, skip to the next index. continue; - if (!isa<SequentialType>(Prev)) { + if (isa<StructType>(Prev)) { // It's out of range, but the prior dimension is a struct // so we can't do anything about it. Unknown = true; |