mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
Introduce ABIAnalyses2
Architecture-agnostic and ABI-independent data-flow analyses that traverse the recovered functions in order to detect arguments and return values registers.
This commit is contained in:
committed by
Antonio Frighetto
parent
835089705e
commit
12c3ce2dba
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
//
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
#include "revng/MFP/MFP.h"
|
||||
#include "revng/Support/revng.h"
|
||||
|
||||
#include "Analyses.h"
|
||||
|
||||
namespace ABIAnalyses::UsedReturnValuesOfFunctionCall {
|
||||
using namespace llvm;
|
||||
using namespace ABIAnalyses;
|
||||
|
||||
std::map<const GlobalVariable *, State>
|
||||
analyze(const BasicBlock *CallSiteBlock, const GeneratedCodeBasicInfo &GCBI) {
|
||||
using MFI = MFIAnalysis<true, CoreLattice>;
|
||||
|
||||
std::map<const GlobalVariable *, State> RegYes{};
|
||||
MFI Instance{ { getPreCallHook(CallSiteBlock), GCBI } };
|
||||
MFI::LatticeElement InitialValue;
|
||||
MFI::LatticeElement ExtremalValue(CoreLattice::ExtremalLatticeElement);
|
||||
auto *Start = CallSiteBlock->getUniqueSuccessor();
|
||||
|
||||
if (!Start)
|
||||
return RegYes;
|
||||
|
||||
auto
|
||||
Results = MFP::getMaximalFixedPoint<MFI, MFI::GT, MFI::LGT>(Instance,
|
||||
Start,
|
||||
InitialValue,
|
||||
ExtremalValue,
|
||||
{ Start },
|
||||
{ Start });
|
||||
|
||||
for (auto &[BB, Result] : Results) {
|
||||
for (auto &[GV, RegState] : Result.OutValue) {
|
||||
if (RegState == CoreLattice::Yes) {
|
||||
RegYes[GV] = State::Yes;
|
||||
}
|
||||
}
|
||||
}
|
||||
return RegYes;
|
||||
}
|
||||
} // namespace ABIAnalyses::UsedReturnValuesOfFunctionCall
|
||||
Reference in New Issue
Block a user