aboutsummaryrefslogtreecommitdiffstats
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
commit521396ab378ba3578cdfdda7422ba8bd79ffee40 (patch)
tree530c3931cf83f1d80da522347b9a5385c7bf479b
parent83ccac71ff5458597f53c502b048052586ad4d41 (diff)
downloadexternal_llvm-521396ab378ba3578cdfdda7422ba8bd79ffee40.zip
external_llvm-521396ab378ba3578cdfdda7422ba8bd79ffee40.tar.gz
external_llvm-521396ab378ba3578cdfdda7422ba8bd79ffee40.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170586 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/ValueTracking.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 64e132e..5421cbe 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/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);