summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-12-19 20:47:04 +0000
committerNadav Rotem <nrotem@apple.com>2012-12-19 20:47:04 +0000
commit11350aafb4f77d7815bbf6875855585d8667da16 (patch)
tree8254f0a8d4c9431f3eb3263d407a2987159878bb /llvm/lib/Analysis
parent0fbf321af2f98fe82bb1abb0dda972419bc57fd1 (diff)
downloadbcm5719-llvm-11350aafb4f77d7815bbf6875855585d8667da16.tar.gz
bcm5719-llvm-11350aafb4f77d7815bbf6875855585d8667da16.zip
Fix a bug that was found by building clang with -fsanitize.
I introduced it in r166785. PR14291. If TD is unavailable use getScalarSizeInBits, but don't optimize pointers or vectors of pointers. llvm-svn: 170586
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 64e132e2e2b..5421cbe6940 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -433,7 +433,12 @@ void llvm::ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne,
unsigned SrcBitWidth;
// Note that we handle pointer operands here because of inttoptr/ptrtoint
// which fall through here.
- SrcBitWidth = TD->getTypeSizeInBits(SrcTy->getScalarType());
+ if(TD) {
+ SrcBitWidth = TD->getTypeSizeInBits(SrcTy->getScalarType());
+ } else {
+ SrcBitWidth = SrcTy->getScalarSizeInBits();
+ if (!SrcBitWidth) return;
+ }
assert(SrcBitWidth && "SrcBitWidth can't be zero");
KnownZero = KnownZero.zextOrTrunc(SrcBitWidth);
OpenPOWER on IntegriCloud