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

daisytuner / sdfglib / 20263852258

16 Dec 2025 09:58AM UTC coverage: 40.086% (-0.2%) from 40.252%
20263852258

push

github

web-flow
Merge pull request #392 from daisytuner/for2map-performance

refactors passes to improve performance

13621 of 43972 branches covered (30.98%)

Branch coverage included in aggregate %.

126 of 173 new or added lines in 14 files covered. (72.83%)

55 existing lines in 8 files now uncovered.

11633 of 19027 relevant lines covered (61.14%)

90.79 hits per line

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

50.86
/src/visitor/structured_sdfg_visitor.cpp
1
#include "sdfg/visitor/structured_sdfg_visitor.h"
2

3
namespace sdfg {
4
namespace visitor {
5

6
StructuredSDFGVisitor::
7
    StructuredSDFGVisitor(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager)
70✔
8
    : builder_(builder), analysis_manager_(analysis_manager) {}
70✔
9

10
bool StructuredSDFGVisitor::visit() { return this->visit_internal(builder_.subject().root()); }
15✔
11

12
bool StructuredSDFGVisitor::visit_internal(structured_control_flow::Sequence& parent) {
21✔
13
    if (this->accept(parent)) {
21✔
14
        return true;
6✔
15
    }
16

17
    for (size_t i = 0; i < parent.size(); i++) {
23✔
18
        auto& current = parent.at(i).first;
19✔
19

20
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&current)) {
19!
21
            if (this->accept(*block_stmt)) {
2✔
22
                return true;
1✔
23
            }
24
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&current)) {
18!
25
            if (this->visit_internal(*sequence_stmt)) {
2✔
26
                return true;
1✔
27
            }
28
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&current)) {
16!
29
            if (this->accept(*if_else_stmt)) {
2✔
30
                return true;
1✔
31
            }
32

33
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
1!
UNCOV
34
                if (this->visit_internal(if_else_stmt->at(i).first)) {
×
35
                    return true;
×
36
                }
UNCOV
37
            }
×
38
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&current)) {
14!
39
            if (this->accept(*for_stmt)) {
2✔
40
                return true;
1✔
41
            }
42

43
            if (this->visit_internal(for_stmt->root())) {
1!
44
                return true;
×
45
            }
46
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&current)) {
12!
47
            if (this->accept(*map_stmt)) {
1!
48
                return true;
1✔
49
            }
50

UNCOV
51
            if (this->visit_internal(map_stmt->root())) {
×
UNCOV
52
                return true;
×
53
            }
54
        } else if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(&current)) {
10!
55
            if (this->accept(*while_stmt)) {
4✔
56
                return true;
1✔
57
            }
58

59
            if (this->visit_internal(while_stmt->root())) {
3✔
60
                return true;
2✔
61
            }
62
        } else if (auto continue_stmt = dynamic_cast<structured_control_flow::Continue*>(&current)) {
7!
63
            if (this->accept(*continue_stmt)) {
2✔
64
                return true;
1✔
65
            }
66
        } else if (auto break_stmt = dynamic_cast<structured_control_flow::Break*>(&current)) {
5!
67
            if (this->accept(*break_stmt)) {
2✔
68
                return true;
1✔
69
            }
70
        } else if (auto return_stmt = dynamic_cast<structured_control_flow::Return*>(&current)) {
3!
71
            if (this->accept(*return_stmt)) {
2✔
72
                return true;
1✔
73
            }
74
        }
1✔
75
    }
8✔
76

77
    return false;
4✔
78
};
21✔
79

80
bool StructuredSDFGVisitor::accept(structured_control_flow::Block& node) { return false; };
98✔
81

82
bool StructuredSDFGVisitor::accept(structured_control_flow::Sequence& node) { return false; };
106✔
83

84
bool StructuredSDFGVisitor::accept(structured_control_flow::Return& node) { return false; };
1✔
85

86
bool StructuredSDFGVisitor::accept(structured_control_flow::IfElse& node) { return false; };
2✔
87

88
bool StructuredSDFGVisitor::accept(structured_control_flow::While& node) { return false; };
1✔
89

90
bool StructuredSDFGVisitor::accept(structured_control_flow::Continue& node) { return false; };
1✔
91

92
bool StructuredSDFGVisitor::accept(structured_control_flow::Break& node) { return false; };
1✔
93

94
bool StructuredSDFGVisitor::accept(structured_control_flow::For& node) { return false; };
12✔
95

UNCOV
96
bool StructuredSDFGVisitor::accept(structured_control_flow::Map& node) { return false; };
×
97

98
NonStoppingStructuredSDFGVisitor::NonStoppingStructuredSDFGVisitor(
55✔
99
    builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager
100
)
101
    : StructuredSDFGVisitor(builder, analysis_manager), applied_(false) {}
55✔
102

103
bool NonStoppingStructuredSDFGVisitor::visit() {
55✔
104
    this->visit_internal(builder_.subject().root());
55✔
105
    return this->applied_;
55✔
106
}
107

108
bool NonStoppingStructuredSDFGVisitor::visit_internal(structured_control_flow::Sequence& parent) {
121✔
109
    applied_ |= this->accept(parent);
121✔
110

111
    for (size_t i = 0; i < parent.size(); i++) {
287✔
112
        auto& current = parent.at(i).first;
166✔
113

114
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&current)) {
166!
115
            applied_ |= this->accept(*block_stmt);
115✔
116
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&current)) {
166!
117
            this->visit_internal(*sequence_stmt);
3✔
118
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&current)) {
51!
119
            applied_ |= this->accept(*if_else_stmt);
16✔
120

121
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
47✔
122
                this->visit_internal(if_else_stmt->at(i).first);
31!
123
            }
31✔
124
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&current)) {
48!
125
            applied_ |= this->accept(*for_stmt);
20✔
126
            this->visit_internal(for_stmt->root());
20✔
127
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&current)) {
32!
128
            applied_ |= this->accept(*map_stmt);
12✔
129
            this->visit_internal(map_stmt->root());
12✔
130
        } else if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(&current)) {
12!
131
            applied_ |= this->accept(*while_stmt);
×
132
            this->visit_internal(while_stmt->root());
×
133
        } else if (auto continue_stmt = dynamic_cast<structured_control_flow::Continue*>(&current)) {
×
134
            applied_ |= this->accept(*continue_stmt);
×
135
        } else if (auto break_stmt = dynamic_cast<structured_control_flow::Break*>(&current)) {
×
136
            applied_ |= this->accept(*break_stmt);
×
137
        } else if (auto return_stmt = dynamic_cast<structured_control_flow::Return*>(&current)) {
×
138
            applied_ |= this->accept(*return_stmt);
×
139
        }
×
140
    }
166✔
141

142
    return false;
121✔
143
};
×
144

145
bool ActualStructuredSDFGVisitor::visit(sdfg::structured_control_flow::ControlFlowNode& node) { return dispatch(node); }
×
146

147
bool ActualStructuredSDFGVisitor::dispatch(ControlFlowNode& node) {
×
148
    //// ARGH. The most inefficient variant of them all. Is there a good way to
149
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
×
150
        return this->visit(*block_stmt);
×
151
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
×
152
        return this->visit(*sequence_stmt);
×
153
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&node)) {
×
154
        return this->visit(*if_else_stmt);
×
155
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&node)) {
×
156
        return this->visit(*for_stmt);
×
157
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
×
158
        return this->visit(*map_stmt);
×
159
    } else if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
×
160
        return this->visit(*while_stmt);
×
161
    } else if (auto continue_stmt = dynamic_cast<structured_control_flow::Continue*>(&node)) {
×
162
        return this->visit(*continue_stmt);
×
163
    } else if (auto break_stmt = dynamic_cast<structured_control_flow::Break*>(&node)) {
×
164
        return this->visit(*break_stmt);
×
165
    } else if (auto return_stmt = dynamic_cast<structured_control_flow::Return*>(&node)) {
×
166
        return this->visit(*return_stmt);
×
167
    }
168

169
    return false;
×
170
}
×
171

172

173
ActualStructuredSDFGVisitor::ActualStructuredSDFGVisitor() {}
×
174

175
bool ActualStructuredSDFGVisitor::visit(Block& node) { return false; }
×
176
bool ActualStructuredSDFGVisitor::visit(Sequence& node) {
×
177
    for (int i = 0; i < node.size(); ++i) {
×
178
        visit(node.at(i).first);
×
179
    }
×
180

181
    return true;
×
182
}
183
bool ActualStructuredSDFGVisitor::visit(Return& node) { return false; }
×
184
bool ActualStructuredSDFGVisitor::visit(IfElse& node) {
×
185
    for (int i = 0; i < node.size(); ++i) {
×
186
        visit(node.at(i).first);
×
187
    }
×
188

189
    return true;
×
190
}
×
191
bool ActualStructuredSDFGVisitor::visit(For& node) { return handleStructuredLoop(node); }
×
192
bool ActualStructuredSDFGVisitor::visit(Map& node) { return handleStructuredLoop(node); }
×
193
bool ActualStructuredSDFGVisitor::handleStructuredLoop(StructuredLoop& loop) { return visit(loop.root()); }
×
194
bool ActualStructuredSDFGVisitor::visit(While& node) { return visit(node.root()); }
×
195
bool ActualStructuredSDFGVisitor::visit(Continue& node) { return false; }
×
196
bool ActualStructuredSDFGVisitor::visit(Break& node) { return false; }
×
197
} // namespace visitor
198
} // 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