mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
76cb852c28
We implement the `GenericRegionInfo` analysis. The analysis accepts a template parameter which enables to run it on every graph which exposes `llvm::GraphTraits`. The `GenericRegionPass` is responsible for instantiating and running the analysis on a `llvm::Function`. The `GenericRegionInfo` analysis uses, and takes insipiration from the `GenericCycleInfo` LLVM analysis. The analysis exposes a tree of well nested `GenericRegion`s, which are constructed starting from the well nested tree of `GenericCycle`s. In addition, we perform the election of the `Head` of each `GenericRegion`, and the election of the retreating edges.
34 lines
916 B
C++
34 lines
916 B
C++
//
|
|
// Copyright rev.ng Labs Srl. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng-c/RestructureCFG/GenericRegionInfo.h"
|
|
#include "revng-c/RestructureCFG/GenericRegionPass.h"
|
|
|
|
char GenericRegionPass::ID = 0;
|
|
|
|
static constexpr const char *Flag = "generic-region-info";
|
|
using Reg = llvm::RegisterPass<GenericRegionPass>;
|
|
static Reg X(Flag, "Perform the generic region identification analysis");
|
|
|
|
bool GenericRegionPass::runOnFunction(llvm::Function &F) {
|
|
|
|
// Run the `GenericRegionInfo`
|
|
GRI.clear();
|
|
GRI.compute(&F);
|
|
|
|
// The goal of `RegionIdentificationPass` is to just perform an analysis
|
|
// which does not perform changes to the IR
|
|
return false;
|
|
}
|
|
|
|
void GenericRegionPass::getAnalysisUsage(llvm::AnalysisUsage &AU) const {
|
|
|
|
// This is a read only analysis, that does not touch the IR
|
|
AU.setPreservesAll();
|
|
}
|
|
|
|
const GenericRegionInfo<llvm::Function *> &GenericRegionPass::getResult() {
|
|
return GRI;
|
|
}
|