SA: reorganize the way functions are registered

This commit is contained in:
Alessandro Di Federico
2019-03-04 20:28:22 +01:00
parent baef567365
commit c2d39fb702
3 changed files with 40 additions and 29 deletions
+30
View File
@@ -145,6 +145,36 @@ bool StackAnalysis<AnalyzeABI>::runOnModule(Module &M) {
}
}
for (CFEP &Function : Functions) {
using IFS = IntraproceduralFunctionSummary;
BasicBlock *Entry = Function.Entry;
llvm::Optional<const IFS *> Cached = TheCache.get(Entry);
revng_assert(Cached or TheCache.isFakeFunction(Entry));
// Has this function been analyzed already? If so, only now we register it
// in the ResultsPool.
FunctionType::Values Type;
if (TheCache.isFakeFunction(Entry))
Type = FunctionType::Fake;
else if (TheCache.isIndirectTailCall(Entry))
Type = FunctionType::IndirectTailCall;
else if (TheCache.isNoReturnFunction(Entry))
Type = FunctionType::NoReturn;
else
Type = FunctionType::Regular;
// Regular functions need to be composed by at least a basic block
if (Cached) {
const IFS *Summary = *Cached;
if (Type == FunctionType::Regular)
revng_assert(Summary->BranchesType.size() != 0);
Results.registerFunction(Entry, Type, Summary);
} else {
Results.registerFunction(Entry, Type, nullptr);
}
}
std::stringstream Output;
GrandResult = Results.finalize(&M);
GrandResult.dump(&M, Output);