diff options
Diffstat (limited to 'lib/Analysis/LazyValueInfo.cpp')
| -rw-r--r-- | lib/Analysis/LazyValueInfo.cpp | 69 | 
1 files changed, 34 insertions, 35 deletions
diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp index a2b9015a8a1d8..6a9ae6440acec 100644 --- a/lib/Analysis/LazyValueInfo.cpp +++ b/lib/Analysis/LazyValueInfo.cpp @@ -662,13 +662,13 @@ namespace {    bool solveBlockValuePHINode(LVILatticeVal &BBLV, PHINode *PN, BasicBlock *BB);    bool solveBlockValueSelect(LVILatticeVal &BBLV, SelectInst *S,                               BasicBlock *BB); -  bool solveBlockValueBinaryOp(LVILatticeVal &BBLV, Instruction *BBI, +  bool solveBlockValueBinaryOp(LVILatticeVal &BBLV, BinaryOperator *BBI,                                 BasicBlock *BB); -  bool solveBlockValueCast(LVILatticeVal &BBLV, Instruction *BBI, +  bool solveBlockValueCast(LVILatticeVal &BBLV, CastInst *CI,                             BasicBlock *BB);    void intersectAssumeOrGuardBlockValueConstantRange(Value *Val,                                                       LVILatticeVal &BBLV, -                                              Instruction *BBI); +                                                     Instruction *BBI);    void solve(); @@ -849,12 +849,12 @@ bool LazyValueInfoImpl::solveBlockValueImpl(LVILatticeVal &Res,      return true;    }    if (BBI->getType()->isIntegerTy()) { -    if (isa<CastInst>(BBI)) -      return solveBlockValueCast(Res, BBI, BB); -     +    if (auto *CI = dyn_cast<CastInst>(BBI)) +      return solveBlockValueCast(Res, CI, BB); +      BinaryOperator *BO = dyn_cast<BinaryOperator>(BBI);      if (BO && isa<ConstantInt>(BO->getOperand(1))) -      return solveBlockValueBinaryOp(Res, BBI, BB); +      return solveBlockValueBinaryOp(Res, BO, BB);    }    DEBUG(dbgs() << " compute BB '" << BB->getName() @@ -1168,9 +1168,9 @@ bool LazyValueInfoImpl::solveBlockValueSelect(LVILatticeVal &BBLV,  }  bool LazyValueInfoImpl::solveBlockValueCast(LVILatticeVal &BBLV, -                                             Instruction *BBI, -                                             BasicBlock *BB) { -  if (!BBI->getOperand(0)->getType()->isSized()) { +                                            CastInst *CI, +                                            BasicBlock *BB) { +  if (!CI->getOperand(0)->getType()->isSized()) {      // Without knowing how wide the input is, we can't analyze it in any useful      // way.      BBLV = LVILatticeVal::getOverdefined(); @@ -1180,7 +1180,7 @@ bool LazyValueInfoImpl::solveBlockValueCast(LVILatticeVal &BBLV,    // Filter out casts we don't know how to reason about before attempting to    // recurse on our operand.  This can cut a long search short if we know we're    // not going to be able to get any useful information anways. -  switch (BBI->getOpcode()) { +  switch (CI->getOpcode()) {    case Instruction::Trunc:    case Instruction::SExt:    case Instruction::ZExt: @@ -1197,44 +1197,43 @@ bool LazyValueInfoImpl::solveBlockValueCast(LVILatticeVal &BBLV,    // Figure out the range of the LHS.  If that fails, we still apply the    // transfer rule on the full set since we may be able to locally infer    // interesting facts. -  if (!hasBlockValue(BBI->getOperand(0), BB)) -    if (pushBlockValue(std::make_pair(BB, BBI->getOperand(0)))) +  if (!hasBlockValue(CI->getOperand(0), BB)) +    if (pushBlockValue(std::make_pair(BB, CI->getOperand(0))))        // More work to do before applying this transfer rule.        return false;    const unsigned OperandBitWidth = -    DL.getTypeSizeInBits(BBI->getOperand(0)->getType()); +    DL.getTypeSizeInBits(CI->getOperand(0)->getType());    ConstantRange LHSRange = ConstantRange(OperandBitWidth); -  if (hasBlockValue(BBI->getOperand(0), BB)) { -    LVILatticeVal LHSVal = getBlockValue(BBI->getOperand(0), BB); -    intersectAssumeOrGuardBlockValueConstantRange(BBI->getOperand(0), LHSVal, -                                                  BBI); +  if (hasBlockValue(CI->getOperand(0), BB)) { +    LVILatticeVal LHSVal = getBlockValue(CI->getOperand(0), BB); +    intersectAssumeOrGuardBlockValueConstantRange(CI->getOperand(0), LHSVal, +                                                  CI);      if (LHSVal.isConstantRange())        LHSRange = LHSVal.getConstantRange();    } -  const unsigned ResultBitWidth = -    cast<IntegerType>(BBI->getType())->getBitWidth(); +  const unsigned ResultBitWidth = CI->getType()->getIntegerBitWidth();    // NOTE: We're currently limited by the set of operations that ConstantRange    // can evaluate symbolically.  Enhancing that set will allows us to analyze    // more definitions. -  auto CastOp = (Instruction::CastOps) BBI->getOpcode(); -  BBLV = LVILatticeVal::getRange(LHSRange.castOp(CastOp, ResultBitWidth)); +  BBLV = LVILatticeVal::getRange(LHSRange.castOp(CI->getOpcode(), +                                                 ResultBitWidth));    return true;  }  bool LazyValueInfoImpl::solveBlockValueBinaryOp(LVILatticeVal &BBLV, -                                                 Instruction *BBI, +                                                 BinaryOperator *BO,                                                   BasicBlock *BB) { -  assert(BBI->getOperand(0)->getType()->isSized() && +  assert(BO->getOperand(0)->getType()->isSized() &&           "all operands to binary operators are sized");    // Filter out operators we don't know how to reason about before attempting to    // recurse on our operand(s).  This can cut a long search short if we know -  // we're not going to be able to get any useful information anways. -  switch (BBI->getOpcode()) { +  // we're not going to be able to get any useful information anyways. +  switch (BO->getOpcode()) {    case Instruction::Add:    case Instruction::Sub:    case Instruction::Mul: @@ -1256,29 +1255,29 @@ bool LazyValueInfoImpl::solveBlockValueBinaryOp(LVILatticeVal &BBLV,    // Figure out the range of the LHS.  If that fails, use a conservative range,    // but apply the transfer rule anyways.  This lets us pick up facts from    // expressions like "and i32 (call i32 @foo()), 32" -  if (!hasBlockValue(BBI->getOperand(0), BB)) -    if (pushBlockValue(std::make_pair(BB, BBI->getOperand(0)))) +  if (!hasBlockValue(BO->getOperand(0), BB)) +    if (pushBlockValue(std::make_pair(BB, BO->getOperand(0))))        // More work to do before applying this transfer rule.        return false;    const unsigned OperandBitWidth = -    DL.getTypeSizeInBits(BBI->getOperand(0)->getType()); +    DL.getTypeSizeInBits(BO->getOperand(0)->getType());    ConstantRange LHSRange = ConstantRange(OperandBitWidth); -  if (hasBlockValue(BBI->getOperand(0), BB)) { -    LVILatticeVal LHSVal = getBlockValue(BBI->getOperand(0), BB); -    intersectAssumeOrGuardBlockValueConstantRange(BBI->getOperand(0), LHSVal, -                                                  BBI); +  if (hasBlockValue(BO->getOperand(0), BB)) { +    LVILatticeVal LHSVal = getBlockValue(BO->getOperand(0), BB); +    intersectAssumeOrGuardBlockValueConstantRange(BO->getOperand(0), LHSVal, +                                                  BO);      if (LHSVal.isConstantRange())        LHSRange = LHSVal.getConstantRange();    } -  ConstantInt *RHS = cast<ConstantInt>(BBI->getOperand(1)); +  ConstantInt *RHS = cast<ConstantInt>(BO->getOperand(1));    ConstantRange RHSRange = ConstantRange(RHS->getValue());    // NOTE: We're currently limited by the set of operations that ConstantRange    // can evaluate symbolically.  Enhancing that set will allows us to analyze    // more definitions. -  auto BinOp = (Instruction::BinaryOps) BBI->getOpcode(); +  Instruction::BinaryOps BinOp = BO->getOpcode();    BBLV = LVILatticeVal::getRange(LHSRange.binaryOp(BinOp, RHSRange));    return true;  }  | 
