aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/CodeMetrics.cpp
diff options
context:
space:
mode:
authorMicah Villmow <villmow@gmail.com>2012-10-11 17:21:41 +0000
committerMicah Villmow <villmow@gmail.com>2012-10-11 17:21:41 +0000
commit083189730e40a2da15e6b66e5b220b707febdb9e (patch)
tree6daffbfbb571af888a60f19b0933c443c8488107 /llvm/lib/Analysis/CodeMetrics.cpp
parentb1e3e5f553024fcdb5436081854f7d9c3f12852b (diff)
downloadllvm-083189730e40a2da15e6b66e5b220b707febdb9e.zip
llvm-083189730e40a2da15e6b66e5b220b707febdb9e.tar.gz
llvm-083189730e40a2da15e6b66e5b220b707febdb9e.tar.bz2
Add in the first iteration of support for llvm/clang/lldb to allow variable per address space pointer sizes to be optimized correctly.
llvm-svn: 165726
Diffstat (limited to 'llvm/lib/Analysis/CodeMetrics.cpp')
-rw-r--r--llvm/lib/Analysis/CodeMetrics.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp
index 651a54b..d669268 100644
--- a/llvm/lib/Analysis/CodeMetrics.cpp
+++ b/llvm/lib/Analysis/CodeMetrics.cpp
@@ -91,14 +91,16 @@ bool llvm::isInstructionFree(const Instruction *I, const DataLayout *TD) {
// which doesn't contain values outside the range of a pointer.
if (isa<IntToPtrInst>(CI) && TD &&
TD->isLegalInteger(Op->getType()->getScalarSizeInBits()) &&
- Op->getType()->getScalarSizeInBits() <= TD->getPointerSizeInBits())
+ Op->getType()->getScalarSizeInBits() <= TD->getPointerSizeInBits(
+ cast<IntToPtrInst>(CI)->getAddressSpace()))
return true;
// A ptrtoint cast is free so long as the result is large enough to store
// the pointer, and a legal integer type.
if (isa<PtrToIntInst>(CI) && TD &&
TD->isLegalInteger(Op->getType()->getScalarSizeInBits()) &&
- Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits())
+ Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits(
+ cast<PtrToIntInst>(CI)->getPointerAddressSpace()))
return true;
// trunc to a native type is free (assuming the target has compare and