From a03b5bbbabdd89acdeffef5a650114a7a3da04ec Mon Sep 17 00:00:00 2001 From: Alessandro Di Federico Date: Wed, 4 May 2022 11:46:33 +0200 Subject: [PATCH] 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. --- lib/EarlyFunctionAnalysis/EarlyFunctionAnalysis.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/EarlyFunctionAnalysis/EarlyFunctionAnalysis.cpp b/lib/EarlyFunctionAnalysis/EarlyFunctionAnalysis.cpp index 263b0c589..655b9c8b5 100644 --- a/lib/EarlyFunctionAnalysis/EarlyFunctionAnalysis.cpp +++ b/lib/EarlyFunctionAnalysis/EarlyFunctionAnalysis.cpp @@ -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 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)) {