EFA: update Block.End when appropriate

This change handle the situation in which getLastPC returns an invalid
MetaAddress. This is a new behavior introduce to handle queries on
`llvm::BasicBlock`s whose last PC is ambiguous.
This commit is contained in:
Alessandro Di Federico
2022-05-04 11:46:33 +02:00
parent 1b0b02a634
commit a03b5bbbab
@@ -1068,6 +1068,7 @@ FunctionEntrypointAnalyzer::collectDirectCFG(OutlinedFunction *F) {
MetaAddress Start = getBasicBlockPC(&BB);
efa::BasicBlock Block{ Start };
Block.End = getFinalAddressOfBasicBlock(&BB);
revng_assert(Block.End.isValid());
OnceQueue<BasicBlock *> Queue;
Queue.insert(&BB);
@@ -1082,7 +1083,7 @@ FunctionEntrypointAnalyzer::collectDirectCFG(OutlinedFunction *F) {
BasicBlock *Current = Queue.pop();
MetaAddress CurrentBlockEnd = getFinalAddressOfBasicBlock(Current);
if (CurrentBlockEnd > Block.End)
if (CurrentBlockEnd.isValid() and CurrentBlockEnd > Block.End)
Block.End = CurrentBlockEnd;
for (BasicBlock *Succ : successors(Current)) {