mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
utils: Fix segfault in flattencfg
v2: continue iterating through the rest of the bb use for loop v3: initialize FlattenCFG pass in ScalarOps add test v4: split off initializing flattencfg to a separate patch add comment Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215574 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -238,9 +238,13 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder,
|
||||
// Do branch inversion.
|
||||
BasicBlock *CurrBlock = LastCondBlock;
|
||||
bool EverChanged = false;
|
||||
while (1) {
|
||||
for (;CurrBlock != FirstCondBlock;
|
||||
CurrBlock = CurrBlock->getSinglePredecessor()) {
|
||||
BranchInst *BI = dyn_cast<BranchInst>(CurrBlock->getTerminator());
|
||||
CmpInst *CI = dyn_cast<CmpInst>(BI->getCondition());
|
||||
if (!CI)
|
||||
continue;
|
||||
|
||||
CmpInst::Predicate Predicate = CI->getPredicate();
|
||||
// Canonicalize icmp_ne -> icmp_eq, fcmp_one -> fcmp_oeq
|
||||
if ((Predicate == CmpInst::ICMP_NE) || (Predicate == CmpInst::FCMP_ONE)) {
|
||||
@ -248,9 +252,6 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder,
|
||||
BI->swapSuccessors();
|
||||
EverChanged = true;
|
||||
}
|
||||
if (CurrBlock == FirstCondBlock)
|
||||
break;
|
||||
CurrBlock = CurrBlock->getSinglePredecessor();
|
||||
}
|
||||
return EverChanged;
|
||||
}
|
||||
|
Reference in New Issue
Block a user