summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DataLayout.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-17 18:22:36 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-17 18:22:36 +0000
commit5b4f5b088760ab7de3733cf3da391c10fbea3d22 (patch)
tree8b6a723d3fb4bb1d815c96f4aba1c0925fb59cbf /llvm/lib/IR/DataLayout.cpp
parent46e36f0953aabb5e5cd00ed8d296d60f9f71b424 (diff)
downloadbcm5719-llvm-5b4f5b088760ab7de3733cf3da391c10fbea3d22.tar.gz
bcm5719-llvm-5b4f5b088760ab7de3733cf3da391c10fbea3d22.zip
[IR] Implement DataLayout::getPointerTypeSizeInBits using getPointerSizeInBits directly
Currently we use getTypeSizeInBits which contains a switch statement to dispatch based on what the Type is. We know we always have a pointer type here, but the compiler isn't able to figure out that out to remove the switch. This patch changes it to just call handle the pointer type directly by calling getPointerSizeInBits without going through a switch. getPointerTypeSizeInBits is called pretty often, particularly by getOrEnforceKnownAlignment which is used by InstCombine. This should speed that up a little bit. Differential Revision: https://reviews.llvm.org/D31841 llvm-svn: 300475
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r--llvm/lib/IR/DataLayout.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 6f90ce59856..c72057ed146 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -608,11 +608,8 @@ unsigned DataLayout::getPointerSize(unsigned AS) const {
unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const {
assert(Ty->isPtrOrPtrVectorTy() &&
"This should only be called with a pointer or pointer vector type");
-
- if (Ty->isPointerTy())
- return getTypeSizeInBits(Ty);
-
- return getTypeSizeInBits(Ty->getScalarType());
+ Ty = Ty->getScalarType();
+ return getPointerSizeInBits(cast<PointerType>(Ty)->getAddressSpace());
}
/*!
OpenPOWER on IntegriCloud