mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 05:22:04 +00:00
Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*". ConstCaseIt is just a read-only iterator. CaseIt is read-write iterator; it allows to change case successor and case value. Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters. Main way of iterator usage looks like this: SwitchInst *SI = ... // intialize it somehow for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) { BasicBlock *BB = i.getCaseSuccessor(); ConstantInt *V = i.getCaseValue(); // Do something. } If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method. If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method. There are also related changes in llvm-clients: klee and clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -564,7 +564,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
|
||||
return;
|
||||
}
|
||||
|
||||
Succs[SI->resolveSuccessorIndex(SI->findCaseValue(CI))] = true;
|
||||
Succs[SI->findCaseValue(CI).getSuccessorIndex()] = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -623,14 +623,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
|
||||
if (CI == 0)
|
||||
return !SCValue.isUndefined();
|
||||
|
||||
// Make sure to skip the "default value" which isn't a value
|
||||
for (unsigned i = 0, E = SI->getNumCases(); i != E; ++i)
|
||||
if (SI->getCaseValue(i) == CI) // Found the taken branch.
|
||||
return SI->getCaseSuccessor(i) == To;
|
||||
|
||||
// If the constant value is not equal to any of the branches, we must
|
||||
// execute default branch.
|
||||
return SI->getDefaultDest() == To;
|
||||
return SI->findCaseValue(CI).getCaseSuccessor() == To;
|
||||
}
|
||||
|
||||
// Just mark all destinations executable!
|
||||
@@ -1495,12 +1488,12 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) {
|
||||
// If the input to SCCP is actually switch on undef, fix the undef to
|
||||
// the first constant.
|
||||
if (isa<UndefValue>(SI->getCondition())) {
|
||||
SI->setCondition(SI->getCaseValue(0));
|
||||
markEdgeExecutable(BB, SI->getCaseSuccessor(0));
|
||||
SI->setCondition(SI->caseBegin().getCaseValue());
|
||||
markEdgeExecutable(BB, SI->caseBegin().getCaseSuccessor());
|
||||
return true;
|
||||
}
|
||||
|
||||
markForcedConstant(SI->getCondition(), SI->getCaseValue(0));
|
||||
markForcedConstant(SI->getCondition(), SI->caseBegin().getCaseValue());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user