mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
[DLA] Guard costly verify calls with VerifyLog
This commit is contained in:
@@ -99,7 +99,8 @@ bool CollapseIdentityAndInheritanceCC::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("after-collapse-equality.dot");
|
||||
|
||||
revng_assert(TS.verifyNoEquality());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyNoEquality());
|
||||
|
||||
revng_log(LogVerbose, "#### Merging Inheritance SCC: ... ");
|
||||
bool CollapsedInheritance = collapseInheritanceSCC(TS);
|
||||
@@ -108,13 +109,15 @@ bool CollapseIdentityAndInheritanceCC::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("after-collapse-inheritance.dot");
|
||||
|
||||
revng_assert(TS.verifyInheritanceDAG());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyInheritanceDAG());
|
||||
|
||||
// The following assertion is not really necessary.
|
||||
// In principle all the rest of the pipeline should work fine without it, but
|
||||
// I think that if it's triggered something might be wrong in how we emit
|
||||
// instance edges earlier. If it's ever triggered, please double check.
|
||||
revng_assert(TS.verifyInstanceDAG());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyInstanceDAG());
|
||||
|
||||
revng_log(LogVerbose, "#### Merging Mixed SCC: ... ");
|
||||
bool Removed = false;
|
||||
@@ -124,7 +127,8 @@ bool CollapseIdentityAndInheritanceCC::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("after-collapse.dot");
|
||||
|
||||
revng_assert(TS.verifyDAG());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG());
|
||||
|
||||
return CollapsedEqual or CollapsedInheritance or Removed;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ static Logger<> Log("dla-compute-upper-member-access");
|
||||
namespace dla {
|
||||
|
||||
bool ComputeUpperMemberAccesses::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree());
|
||||
bool Changed = false;
|
||||
|
||||
using LTSN = LayoutTypeSystemNode;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
|
||||
#include "revng/Support/Debug.h"
|
||||
#include "revng/Support/IRHelpers.h"
|
||||
|
||||
#include "DLAStep.h"
|
||||
@@ -99,6 +100,7 @@ bool StepT::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
}
|
||||
}
|
||||
}
|
||||
revng_assert(TS.verifyConsistency());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyConsistency());
|
||||
return TS.getNumLayouts() != 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Pass.h"
|
||||
|
||||
#include "revng/Support/Debug.h"
|
||||
#include "revng/Support/IRHelpers.h"
|
||||
|
||||
#include "DLAHelpers.h"
|
||||
@@ -844,7 +845,9 @@ bool StepT::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
}
|
||||
}
|
||||
}
|
||||
revng_assert(TS.verifyConsistency());
|
||||
revng_assert(TS.verifyInstanceDAG());
|
||||
if (VerifyLog.isEnabled()) {
|
||||
revng_assert(TS.verifyConsistency());
|
||||
revng_assert(TS.verifyInstanceDAG());
|
||||
}
|
||||
return Changed;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,8 @@ using MixedGT = llvm::GraphTraits<MixedNodeT>;
|
||||
|
||||
bool removeInstanceBackedgesFromInheritanceLoops(LayoutTypeSystem &TS) {
|
||||
bool Changed = false;
|
||||
revng_assert(TS.verifyInheritanceDAG());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyInheritanceDAG());
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("before-remove-instance-inheritance-loops.dot");
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ using CollapseSetIterCmp = std::integral_constant<decltype(IterCmp) &, IterCmp>;
|
||||
|
||||
bool MakeInheritanceTree::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
bool Changed = false;
|
||||
revng_assert(TS.verifyDAG());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG());
|
||||
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("before-make-inheritance-tree.dot");
|
||||
@@ -150,8 +151,10 @@ bool MakeInheritanceTree::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("after-make-inheritance-tree.dot");
|
||||
revng_assert(TS.verifyInheritanceTree());
|
||||
revng_assert(TS.verifyInheritanceDAG());
|
||||
if (VerifyLog.isEnabled()) {
|
||||
revng_assert(TS.verifyInheritanceTree());
|
||||
revng_assert(TS.verifyInheritanceDAG());
|
||||
}
|
||||
|
||||
if (Changed) {
|
||||
// Whenever we collapse nodes, we might end up creating loops of inheritance
|
||||
@@ -161,8 +164,10 @@ bool MakeInheritanceTree::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("after-final-inheritance-tree.dot");
|
||||
revng_assert(TS.verifyInheritanceTree());
|
||||
revng_assert(TS.verifyDAG());
|
||||
if (VerifyLog.isEnabled()) {
|
||||
revng_assert(TS.verifyInheritanceTree());
|
||||
revng_assert(TS.verifyDAG());
|
||||
}
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
||||
@@ -648,7 +648,8 @@ static Layout *makeLayout(const LayoutTypeSystem &TS,
|
||||
}
|
||||
|
||||
static bool makeLayouts(const LayoutTypeSystem &TS) {
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree());
|
||||
|
||||
std::map<const LTSN *, Layout *> LayoutCTypes;
|
||||
LayoutSet Layouts;
|
||||
|
||||
@@ -24,7 +24,8 @@ bool PruneLayoutNodesWithoutLayout::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
using LTSN = LayoutTypeSystemNode;
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("before-prune.dot");
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree());
|
||||
|
||||
std::set<const LTSN *> Visited;
|
||||
std::set<LTSN *> ToRemove;
|
||||
@@ -67,8 +68,9 @@ bool PruneLayoutNodesWithoutLayout::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
TS.removeNode(N);
|
||||
}
|
||||
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree()
|
||||
and TS.verifyLeafs());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG() and TS.verifyInheritanceTree()
|
||||
and TS.verifyLeafs());
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("after-prune.dot");
|
||||
return Changed;
|
||||
|
||||
@@ -98,7 +98,8 @@ bool RemoveTransitiveInheritanceEdges::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("before-remove-transitive-edges.dot");
|
||||
|
||||
revng_assert(TS.verifyDAG());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG());
|
||||
bool Changed = false;
|
||||
|
||||
for (LTSN *Root : llvm::nodes(&TS)) {
|
||||
@@ -196,7 +197,8 @@ bool RemoveTransitiveInheritanceEdges::runOnTypeSystem(LayoutTypeSystem &TS) {
|
||||
if (Log.isEnabled())
|
||||
TS.dumpDotOnFile("after-remove-transitive-edges.dot");
|
||||
|
||||
revng_assert(TS.verifyDAG());
|
||||
if (VerifyLog.isEnabled())
|
||||
revng_assert(TS.verifyDAG());
|
||||
|
||||
return Changed;
|
||||
} // namespace dla
|
||||
|
||||
@@ -498,7 +498,7 @@ void LayoutTypeSystem::removeNode(LayoutTypeSystemNode *N) {
|
||||
Layouts.erase(LayoutIt);
|
||||
}
|
||||
|
||||
static Logger<> VerifyDLALog("dla-verify");
|
||||
static Logger<> VerifyDLALog("dla-verify-strict");
|
||||
|
||||
bool LayoutTypeSystem::verifyConsistency() const {
|
||||
for (auto &NodeUPtr : Layouts) {
|
||||
|
||||
Reference in New Issue
Block a user