mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
cf79b2d6e3
This new pass: - Adds CSV alias information (previously done by `JTM::aliasAnalysis`) - Optionally segregates the direct stack accesses from all the other memory accesses by adding further alias information - Canonicalizes the inttoptr + add + ptrtoint into a getelementptr, in order to have typesafe pointer arithmetics and allow optimizations to happen.
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#pragma once
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "llvm/IR/IRBuilder.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "llvm/IR/MDBuilder.h"
|
|
#include "llvm/IR/PassManager.h"
|
|
#include "llvm/IR/Value.h"
|
|
|
|
#include "revng/BasicAnalyses/GeneratedCodeBasicInfo.h"
|
|
#include "revng/Support/revng.h"
|
|
|
|
struct CSVAliasAnalysisInterface {
|
|
GeneratedCodeBasicInfo *GCBI;
|
|
llvm::MDNode *AliasDomain;
|
|
friend class SegregateDirectStackAccesses;
|
|
|
|
protected:
|
|
CSVAliasAnalysisInterface() : GCBI(nullptr) {}
|
|
};
|
|
|
|
template<bool SegregateStackAccesses = false>
|
|
class CSVAliasAnalysisPass
|
|
: public CSVAliasAnalysisInterface,
|
|
public llvm::PassInfoMixin<CSVAliasAnalysisPass<SegregateStackAccesses>> {
|
|
struct CSVAliasInfo {
|
|
llvm::MDNode *AliasScope;
|
|
llvm::MDNode *AliasSet;
|
|
llvm::MDNode *NoAliasSet;
|
|
};
|
|
std::map<const llvm::GlobalVariable *, CSVAliasInfo> CSVAliasInfoMap;
|
|
std::vector<llvm::Metadata *> AllCSVScopes;
|
|
|
|
public:
|
|
CSVAliasAnalysisPass() = default;
|
|
|
|
llvm::PreservedAnalyses
|
|
run(llvm::Function &F, llvm::FunctionAnalysisManager &FAM);
|
|
|
|
private:
|
|
void initializeAliasInfo(llvm::Module &M);
|
|
void decorateMemoryAccesses(llvm::Instruction &I);
|
|
};
|