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
This commit is contained in:
Nadav Rotem 2012-12-19 20:47:04 +00:00
parent 0fbf321af2
commit 11350aafb4
1 changed files with 6 additions and 1 deletions

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