diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-10-16 10:38:18 +0000 | 
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-10-16 10:38:18 +0000 | 
| commit | c598ef7f2432ab72fda58113cbe7a11a1a7e130c (patch) | |
| tree | fd3d024d22991b975ad09f09fa18812fd19a7e3d /llvm | |
| parent | b13d257028a671439aea51f0ddd66c81134592bf (diff) | |
| download | bcm5719-llvm-c598ef7f2432ab72fda58113cbe7a11a1a7e130c.tar.gz bcm5719-llvm-c598ef7f2432ab72fda58113cbe7a11a1a7e130c.zip  | |
SimpleLoopUnswitch - fix uninitialized variable and null dereference warnings. NFCI.
llvm-svn: 374986
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 5 | 
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index e7621de82ff..ac832b9b456 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -1909,7 +1909,7 @@ static void unswitchNontrivialInvariants(    // We can only unswitch switches, conditional branches with an invariant    // condition, or combining invariant conditions with an instruction. -  assert((SI || BI->isConditional()) && +  assert((SI || (BI && BI->isConditional())) &&           "Can only unswitch switches and conditional branch!");    bool FullUnswitch = SI || BI->getCondition() == Invariants[0];    if (FullUnswitch) @@ -2724,7 +2724,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,      return Cost * (SuccessorsCount - 1);    };    Instruction *BestUnswitchTI = nullptr; -  int BestUnswitchCost; +  int BestUnswitchCost = 0;    ArrayRef<Value *> BestUnswitchInvariants;    for (auto &TerminatorAndInvariants : UnswitchCandidates) {      Instruction &TI = *TerminatorAndInvariants.first; @@ -2756,6 +2756,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,        BestUnswitchInvariants = Invariants;      }    } +  assert(BestUnswitchTI && "Failed to find loop unswitch candidate");    if (BestUnswitchCost >= UnswitchThreshold) {      LLVM_DEBUG(dbgs() << "Cannot unswitch, lowest cost found: "  | 

