souffle  2.0.2-371-g6315b36
Public Member Functions | Static Public Attributes | Private Attributes
souffle::ast::analysis::RedundantRelationsAnalysis Class Reference

Analysis pass identifying relations which do not contribute to the computation of the output relations. More...

#include <RedundantRelations.h>

Inheritance diagram for souffle::ast::analysis::RedundantRelationsAnalysis:
Inheritance graph
Collaboration diagram for souffle::ast::analysis::RedundantRelationsAnalysis:
Collaboration graph

Public Member Functions

const std::set< const Relation * > & getRedundantRelations () const
 
void print (std::ostream &os) const override
 print the analysis result in HTML format More...
 
 RedundantRelationsAnalysis ()
 
void run (const TranslationUnit &translationUnit) override
 run analysis for a Ast translation unit More...
 
- Public Member Functions inherited from souffle::ast::analysis::Analysis
 Analysis (std::string identifier)
 
virtual const std::string & getName () const
 get name of the analysis More...
 
virtual ~Analysis ()=default
 

Static Public Attributes

static constexpr const char * name = "redundant-relations"
 

Private Attributes

PrecedenceGraphAnalysisprecedenceGraph = nullptr
 
std::set< const Relation * > redundantRelations
 

Additional Inherited Members

- Protected Attributes inherited from souffle::ast::analysis::Analysis
const std::string identifier
 

Detailed Description

Analysis pass identifying relations which do not contribute to the computation of the output relations.

Definition at line 44 of file RedundantRelations.h.

Constructor & Destructor Documentation

◆ RedundantRelationsAnalysis()

souffle::ast::analysis::RedundantRelationsAnalysis::RedundantRelationsAnalysis ( )
inline

Definition at line 48 of file RedundantRelations.h.

50 :
51  PrecedenceGraphAnalysis* precedenceGraph = nullptr;

Member Function Documentation

◆ getRedundantRelations()

const std::set<const Relation*>& souffle::ast::analysis::RedundantRelationsAnalysis::getRedundantRelations ( ) const
inline

Definition at line 54 of file RedundantRelations.h.

◆ print()

void souffle::ast::analysis::RedundantRelationsAnalysis::print ( std::ostream &  ) const
overridevirtual

print the analysis result in HTML format

Reimplemented from souffle::ast::analysis::Analysis.

Definition at line 83 of file RedundantRelations.cpp.

◆ run()

void souffle::ast::analysis::RedundantRelationsAnalysis::run ( const TranslationUnit )
overridevirtual

run analysis for a Ast translation unit

Implements souffle::ast::analysis::Analysis.

Definition at line 41 of file RedundantRelations.cpp.

43  : relations) {
44  if (ioType->isOutput(r)) {
45  work.insert(r);
46  }
47  }
48 
49  /* Find all relations which are not redundant for the computations of the
50  output relations. */
51  while (!work.empty()) {
52  /* Chose one element in the work set and add it to notRedundant */
53  const Relation* u = *(work.begin());
54  work.erase(work.begin());
55  notRedundant.insert(u);
56 
57  /* Find all predecessors of u and add them to the worklist
58  if they are not in the set notRedundant */
59  for (const Relation* predecessor : precedenceGraph->graph().predecessors(u)) {
60  if (notRedundant.count(predecessor) == 0u) {
61  work.insert(predecessor);
62  }
63  }
64  }
65 
66  /* All remaining relations are redundant. */
67  redundantRelations.clear();
68  for (const Relation* r : relations) {
69  if (notRedundant.count(r) == 0u) {
70  redundantRelations.insert(r);
71  }
72  }
73 }
74 
75 void RedundantRelationsAnalysis::print(std::ostream& os) const {
76  os << redundantRelations << std::endl;
77 }
78 
79 } // namespace souffle::ast::analysis

Field Documentation

◆ name

constexpr const char* souffle::ast::analysis::RedundantRelationsAnalysis::name = "redundant-relations"
staticconstexpr

Definition at line 46 of file RedundantRelations.h.

◆ precedenceGraph

PrecedenceGraphAnalysis* souffle::ast::analysis::RedundantRelationsAnalysis::precedenceGraph = nullptr
private

Definition at line 59 of file RedundantRelations.h.

◆ redundantRelations

std::set<const Relation*> souffle::ast::analysis::RedundantRelationsAnalysis::redundantRelations
private

Definition at line 61 of file RedundantRelations.h.


The documentation for this class was generated from the following files:
souffle::ast::analysis::RedundantRelationsAnalysis::precedenceGraph
PrecedenceGraphAnalysis * precedenceGraph
Definition: RedundantRelations.h:59
souffle::ast::analysis::PrecedenceGraphAnalysis::graph
const Graph< const Relation *, NameComparison > & graph() const
Definition: PrecedenceGraph.h:54
souffle::ast::analysis::RedundantRelationsAnalysis::redundantRelations
std::set< const Relation * > redundantRelations
Definition: RedundantRelations.h:61
relations
std::vector< Own< Relation > > relations
Definition: ComponentInstantiation.cpp:65
souffle::ast::analysis::RedundantRelationsAnalysis::print
void print(std::ostream &os) const override
print the analysis result in HTML format
Definition: RedundantRelations.cpp:83