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
This commit is contained in:
Nadav Rotem 2012-12-19 20:47:04 +00:00
parent 83ccac71ff
commit 521396ab37

View File

@ -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);