[llvm] r372977 - [FlattenCFG] Silence static analyzer dyn_cast<BranchInst> null dereference warnings. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 06:33:15 PDT 2019
Author: rksimon
Date: Thu Sep 26 06:33:15 2019
New Revision: 372977
URL: http://llvm.org/viewvc/llvm-project?rev=372977&view=rev
Log:
[FlattenCFG] Silence static analyzer dyn_cast<BranchInst> null dereference warnings. NFCI.
The static analyzer is warning about a potential null dereferences, but we should be able to use cast<BranchInst> directly and if not assert will fire for us.
Modified:
llvm/trunk/lib/Transforms/Utils/FlattenCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/FlattenCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/FlattenCFG.cpp?rev=372977&r1=372976&r2=372977&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/FlattenCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/FlattenCFG.cpp Thu Sep 26 06:33:15 2019
@@ -251,8 +251,8 @@ bool FlattenCFGOpt::FlattenParallelAndOr
bool EverChanged = false;
for (; CurrBlock != FirstCondBlock;
CurrBlock = CurrBlock->getSinglePredecessor()) {
- BranchInst *BI = dyn_cast<BranchInst>(CurrBlock->getTerminator());
- CmpInst *CI = dyn_cast<CmpInst>(BI->getCondition());
+ auto *BI = cast<BranchInst>(CurrBlock->getTerminator());
+ auto *CI = dyn_cast<CmpInst>(BI->getCondition());
if (!CI)
continue;
@@ -278,7 +278,7 @@ bool FlattenCFGOpt::FlattenParallelAndOr
// Do the transformation.
BasicBlock *CB;
- BranchInst *PBI = dyn_cast<BranchInst>(FirstCondBlock->getTerminator());
+ BranchInst *PBI = cast<BranchInst>(FirstCondBlock->getTerminator());
bool Iteration = true;
IRBuilder<>::InsertPointGuard Guard(Builder);
Value *PC = PBI->getCondition();
@@ -444,7 +444,7 @@ bool FlattenCFGOpt::MergeIfRegion(BasicB
FirstEntryBlock->getInstList().pop_back();
FirstEntryBlock->getInstList()
.splice(FirstEntryBlock->end(), SecondEntryBlock->getInstList());
- BranchInst *PBI = dyn_cast<BranchInst>(FirstEntryBlock->getTerminator());
+ BranchInst *PBI = cast<BranchInst>(FirstEntryBlock->getTerminator());
Value *CC = PBI->getCondition();
BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
More information about the llvm-commits
mailing list