mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-03 19:32:35 +00:00
[LegacyPassManager] Move structural hashing into Pass classes. NFC.
Move structural hashing into virtual methods on Pass. This will allow MachineFunctionPass to override the method to add hashing of the MachineFunction. Differential Revision: https://reviews.llvm.org/D120123
This commit is contained in:
parent
0b6df40c52
commit
a3a4591856
@ -228,6 +228,16 @@ public:
|
||||
template <typename AnalysisType>
|
||||
AnalysisType &getAnalysisID(AnalysisID PI, Function &F,
|
||||
bool *Changed = nullptr);
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
/// Hash a module in order to detect when a module (or more specific) pass has
|
||||
/// modified it.
|
||||
uint64_t structuralHash(Module &M) const;
|
||||
|
||||
/// Hash a function in order to detect when a function (or more specific) pass
|
||||
/// has modified it.
|
||||
virtual uint64_t structuralHash(Function &F) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -28,9 +28,6 @@
|
||||
#include "llvm/IR/OptBisect.h"
|
||||
#include "llvm/IR/PassTimingInfo.h"
|
||||
#include "llvm/IR/PrintPasses.h"
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
#include "llvm/IR/StructuralHash.h"
|
||||
#endif
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
@ -472,7 +469,7 @@ bool CGPassManager::RunAllPassesOnSCC(CallGraphSCC &CurSCC, CallGraph &CG,
|
||||
initializeAnalysisImpl(P);
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
uint64_t RefHash = StructuralHash(CG.getModule());
|
||||
uint64_t RefHash = P->structuralHash(CG.getModule());
|
||||
#endif
|
||||
|
||||
// Actually run this pass on the current SCC.
|
||||
@ -482,7 +479,7 @@ bool CGPassManager::RunAllPassesOnSCC(CallGraphSCC &CurSCC, CallGraph &CG,
|
||||
Changed |= LocalChanged;
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
if (!LocalChanged && (RefHash != StructuralHash(CG.getModule()))) {
|
||||
if (!LocalChanged && (RefHash != P->structuralHash(CG.getModule()))) {
|
||||
llvm::errs() << "Pass modifies its input and doesn't report it: "
|
||||
<< P->getPassName() << "\n";
|
||||
llvm_unreachable("Pass modifies its input and doesn't report it");
|
||||
|
@ -19,9 +19,6 @@
|
||||
#include "llvm/IR/OptBisect.h"
|
||||
#include "llvm/IR/PassTimingInfo.h"
|
||||
#include "llvm/IR/PrintPasses.h"
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
#include "llvm/IR/StructuralHash.h"
|
||||
#endif
|
||||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/TimeProfiler.h"
|
||||
@ -193,12 +190,12 @@ bool LPPassManager::runOnFunction(Function &F) {
|
||||
PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader());
|
||||
TimeRegion PassTimer(getPassTimer(P));
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
uint64_t RefHash = StructuralHash(F);
|
||||
uint64_t RefHash = P->structuralHash(F);
|
||||
#endif
|
||||
LocalChanged = P->runOnLoop(CurrentLoop, *this);
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
if (!LocalChanged && (RefHash != StructuralHash(F))) {
|
||||
if (!LocalChanged && (RefHash != P->structuralHash(F))) {
|
||||
llvm::errs() << "Pass modifies its input and doesn't report it: "
|
||||
<< P->getPassName() << "\n";
|
||||
llvm_unreachable("Pass modifies its input and doesn't report it");
|
||||
|
@ -18,9 +18,6 @@
|
||||
#include "llvm/IR/OptBisect.h"
|
||||
#include "llvm/IR/PassTimingInfo.h"
|
||||
#include "llvm/IR/PrintPasses.h"
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
#include "llvm/IR/StructuralHash.h"
|
||||
#endif
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/Timer.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
@ -98,12 +95,12 @@ bool RGPassManager::runOnFunction(Function &F) {
|
||||
|
||||
TimeRegion PassTimer(getPassTimer(P));
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
uint64_t RefHash = StructuralHash(F);
|
||||
uint64_t RefHash = P->structuralHash(F);
|
||||
#endif
|
||||
LocalChanged = P->runOnRegion(CurrentRegion, *this);
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
if (!LocalChanged && (RefHash != StructuralHash(F))) {
|
||||
if (!LocalChanged && (RefHash != P->structuralHash(F))) {
|
||||
llvm::errs() << "Pass modifies its input and doesn't report it: "
|
||||
<< P->getPassName() << "\n";
|
||||
llvm_unreachable("Pass modifies its input and doesn't report it");
|
||||
|
@ -29,10 +29,6 @@
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
#include "llvm/IR/StructuralHash.h"
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
// See PassManagers.h for Pass Manager infrastructure overview.
|
||||
@ -1429,12 +1425,12 @@ bool FPPassManager::runOnFunction(Function &F) {
|
||||
PassManagerPrettyStackEntry X(FP, F);
|
||||
TimeRegion PassTimer(getPassTimer(FP));
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
uint64_t RefHash = StructuralHash(F);
|
||||
uint64_t RefHash = FP->structuralHash(F);
|
||||
#endif
|
||||
LocalChanged |= FP->runOnFunction(F);
|
||||
|
||||
#if defined(EXPENSIVE_CHECKS) && !defined(NDEBUG)
|
||||
if (!LocalChanged && (RefHash != StructuralHash(F))) {
|
||||
if (!LocalChanged && (RefHash != FP->structuralHash(F))) {
|
||||
llvm::errs() << "Pass modifies its input and doesn't report it: "
|
||||
<< FP->getPassName() << "\n";
|
||||
llvm_unreachable("Pass modifies its input and doesn't report it");
|
||||
@ -1543,13 +1539,13 @@ MPPassManager::runOnModule(Module &M) {
|
||||
TimeRegion PassTimer(getPassTimer(MP));
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
uint64_t RefHash = StructuralHash(M);
|
||||
uint64_t RefHash = MP->structuralHash(M);
|
||||
#endif
|
||||
|
||||
LocalChanged |= MP->runOnModule(M);
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
assert((LocalChanged || (RefHash == StructuralHash(M))) &&
|
||||
assert((LocalChanged || (RefHash == MP->structuralHash(M))) &&
|
||||
"Pass modifies its input and doesn't report it.");
|
||||
#endif
|
||||
|
||||
|
@ -27,6 +27,10 @@
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
#include "llvm/IR/StructuralHash.h"
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "ir"
|
||||
@ -133,6 +137,12 @@ LLVM_DUMP_METHOD void Pass::dump() const {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
uint64_t Pass::structuralHash(Module &M) const { return StructuralHash(M); }
|
||||
|
||||
uint64_t Pass::structuralHash(Function &F) const { return StructuralHash(F); }
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ImmutablePass Implementation
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user