• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 20291299430

16 Dec 2025 10:55PM UTC coverage: 40.09% (+0.02%) from 40.075%
20291299430

push

github

web-flow
Merge pull request #396 from daisytuner/dde

makes dead data elimination a complete pass

13519 of 43713 branches covered (30.93%)

Branch coverage included in aggregate %.

6 of 9 new or added lines in 1 file covered. (66.67%)

11640 of 19043 relevant lines covered (61.12%)

87.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.89
/src/passes/dataflow/dead_data_elimination.cpp
1
#include "sdfg/passes/dataflow/dead_data_elimination.h"
2

3
#include "sdfg/analysis/data_dependency_analysis.h"
4

5
namespace sdfg {
6
namespace passes {
7

8
DeadDataElimination::DeadDataElimination() : Pass() {};
11✔
9

10
std::string DeadDataElimination::name() { return "DeadDataElimination"; };
×
11

12
bool DeadDataElimination::run_pass(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) {
18✔
13
    bool applied = false;
18✔
14

15
    auto& sdfg = builder.subject();
18✔
16
    auto& users = analysis_manager.get<analysis::Users>();
18✔
17
    auto& data_dependency_analysis = analysis_manager.get<analysis::DataDependencyAnalysis>();
18✔
18

19
    // Eliminate dead code, i.e., never read
20
    std::unordered_set<std::string> dead;
18✔
21
    for (auto& name : sdfg.containers()) {
43!
22
        if (!sdfg.is_transient(name)) {
25!
23
            continue;
10✔
24
        }
25
        if (sdfg.type(name).type_id() != types::TypeID::Scalar) {
15!
26
            continue;
×
27
        }
28

29
        if (users.num_views(name) > 0 || users.num_moves(name) > 0) {
15!
30
            continue;
×
31
        }
32
        if (users.num_reads(name) == 0 && users.num_writes(name) == 0) {
15!
33
            dead.insert(name);
1!
34
            applied = true;
1✔
35
            continue;
1✔
36
        }
37

38
        // Writes without reads
39
        bool all_definitions_removed = true;
14✔
40
        auto raws = data_dependency_analysis.definitions(name);
14!
41
        for (auto set : raws) {
43!
42
            if (set.second.size() > 0) {
29✔
43
                all_definitions_removed = false;
22✔
44
                continue;
22✔
45
            }
46
            if (data_dependency_analysis.is_undefined_user(*set.first)) {
7!
47
                continue;
×
48
            }
49

50
            auto write = set.first;
7✔
51
            if (auto transition = dynamic_cast<structured_control_flow::Transition*>(write->element())) {
7!
52
                transition->assignments().erase(symbolic::symbol(name));
6!
53
                applied = true;
6✔
54
            } else if (auto access_node = dynamic_cast<data_flow::AccessNode*>(write->element())) {
7!
55
                auto& graph = access_node->get_parent();
1!
56

57
                auto& src = (*graph.in_edges(*access_node).begin()).src();
1!
58
                if (auto tasklet = dynamic_cast<data_flow::Tasklet*>(&src)) {
1!
59
                    auto& block = dynamic_cast<structured_control_flow::Block&>(*graph.get_parent());
1!
60
                    builder.clear_node(block, *tasklet);
1!
61
                    applied = true;
1✔
62
                } else if (auto library_node = dynamic_cast<data_flow::LibraryNode*>(&src)) {
1!
63
                    if (!library_node->side_effect()) {
×
64
                        auto& block = dynamic_cast<structured_control_flow::Block&>(*graph.get_parent());
×
65
                        builder.clear_node(block, *library_node);
×
66
                        applied = true;
×
NEW
67
                    } else {
×
NEW
68
                        all_definitions_removed = false;
×
69
                    }
70
                }
×
71
            } else {
1✔
NEW
72
                all_definitions_removed = false;
×
73
            }
74
        }
29!
75

76
        if (all_definitions_removed) {
14✔
77
            dead.insert(name);
2!
78
        }
2✔
79
    }
14✔
80

81
    for (auto& name : dead) {
21✔
82
        builder.remove_container(name);
3!
83
    }
84

85
    return applied;
18✔
86
};
18✔
87

88
} // namespace passes
89
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc