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

daisytuner / sdfglib / 17651658650

11 Sep 2025 04:58PM UTC coverage: 61.012% (+1.3%) from 59.755%
17651658650

Pull #219

github

web-flow
Merge 742a12367 into f744ac9f5
Pull Request #219: stdlib Library Nodes and ConstantNodes

499 of 1681 new or added lines in 81 files covered. (29.68%)

95 existing lines in 36 files now uncovered.

9718 of 15928 relevant lines covered (61.01%)

108.0 hits per line

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

50.31
/src/deepcopy/structured_sdfg_deep_copy.cpp
1
#include "sdfg/deepcopy/structured_sdfg_deep_copy.h"
2

3
#include "sdfg/element.h"
4

5
namespace sdfg {
6
namespace deepcopy {
7

8
void StructuredSDFGDeepCopy::append(structured_control_flow::Sequence& root, structured_control_flow::Sequence& source) {
18✔
9
    for (size_t i = 0; i < source.size(); i++) {
31✔
10
        auto child = source.at(i);
13✔
11
        auto& node = child.first;
13✔
12
        auto& trans = child.second;
13✔
13

14
        if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&node)) {
13✔
15
            auto& block = this->builder_.add_block(
3✔
16
                root,
3✔
17
                block_stmt->dataflow(),
3✔
18
                trans.assignments(),
3✔
19
                this->builder_.debug_info().get_region(block_stmt->debug_info().indices())
3✔
20
            );
21
            this->node_mapping[block_stmt] = &block;
3✔
22
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&node)) {
13✔
23
            auto& new_seq = this->builder_.add_sequence(
2✔
24
                root, trans.assignments(), this->builder_.debug_info().get_region(sequence_stmt->debug_info().indices())
2✔
25
            );
26
            this->node_mapping[sequence_stmt] = &new_seq;
2✔
27
            this->append(new_seq, *sequence_stmt);
2✔
28
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&node)) {
10✔
29
            auto& new_scope = this->builder_.add_if_else(
×
30
                root, trans.assignments(), this->builder_.debug_info().get_region(if_else_stmt->debug_info().indices())
×
31
            );
32
            this->node_mapping[if_else_stmt] = &new_scope;
×
33
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
34
                auto branch = if_else_stmt->at(i);
×
35
                auto& new_branch = this->builder_.add_case(
×
36
                    new_scope,
×
37
                    branch.second,
×
38
                    this->builder_.debug_info().get_region(branch.first.debug_info().indices())
×
39
                );
40
                this->node_mapping[&branch.first] = &new_branch;
×
41
                this->append(new_branch, branch.first);
×
42
            }
×
43
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&node)) {
8✔
44
            auto& new_scope = this->builder_.add_while(
3✔
45
                root, trans.assignments(), this->builder_.debug_info().get_region(loop_stmt->debug_info().indices())
3✔
46
            );
47
            this->node_mapping[loop_stmt] = &new_scope;
3✔
48
            this->append(new_scope.root(), loop_stmt->root());
3✔
49
        } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&node)) {
8✔
50
            auto& new_cont = this->builder_.add_continue(
1✔
51
                root, trans.assignments(), this->builder_.debug_info().get_region(cont_stmt->debug_info().indices())
1✔
52
            );
53
            this->node_mapping[cont_stmt] = &new_cont;
1✔
54
        } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&node)) {
5✔
55
            auto& new_br = this->builder_.add_break(
1✔
56
                root, trans.assignments(), this->builder_.debug_info().get_region(br_stmt->debug_info().indices())
1✔
57
            );
58
            this->node_mapping[br_stmt] = &new_br;
1✔
59
        } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&node)) {
4✔
60
            auto& new_ret = this->builder_.add_return(
1✔
61
                root,
1✔
62
                ret_stmt->data(),
1✔
63
                ret_stmt->unreachable(),
1✔
64
                trans.assignments(),
1✔
65
                this->builder_.debug_info().get_region(ret_stmt->debug_info().indices())
1✔
66
            );
67
            this->node_mapping[ret_stmt] = &new_ret;
1✔
68
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&node)) {
3✔
69
            auto& new_scope = this->builder_.add_for(
1✔
70
                root,
1✔
71
                for_stmt->indvar(),
1✔
72
                for_stmt->condition(),
1✔
73
                for_stmt->init(),
1✔
74
                for_stmt->update(),
1✔
75
                trans.assignments(),
1✔
76
                this->builder_.debug_info().get_region(for_stmt->debug_info().indices())
1✔
77
            );
78
            this->node_mapping[for_stmt] = &new_scope;
1✔
79
            this->append(new_scope.root(), for_stmt->root());
1✔
80
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
2✔
81
            auto& new_scope = this->builder_.add_map(
1✔
82
                root,
1✔
83
                map_stmt->indvar(),
1✔
84
                map_stmt->condition(),
1✔
85
                map_stmt->init(),
1✔
86
                map_stmt->update(),
1✔
87
                map_stmt->schedule_type(),
1✔
88
                trans.assignments(),
1✔
89
                this->builder_.debug_info().get_region(map_stmt->debug_info().indices())
1✔
90
            );
91
            this->node_mapping[map_stmt] = &new_scope;
1✔
92
            this->append(new_scope.root(), map_stmt->root());
1✔
93
        } else {
1✔
94
            throw std::runtime_error("Deep copy not implemented");
×
95
        }
96
    }
13✔
97
};
18✔
98

99
void StructuredSDFGDeepCopy::
100
    insert(structured_control_flow::Sequence& root, structured_control_flow::ControlFlowNode& source) {
11✔
101
    if (auto block_stmt = dynamic_cast<structured_control_flow::Block*>(&source)) {
11✔
102
        auto& block = this->builder_.add_block(
×
103
            root, block_stmt->dataflow(), {}, this->builder_.debug_info().get_region(block_stmt->debug_info().indices())
×
104
        );
105
        this->node_mapping[block_stmt] = &block;
×
106
    } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(&source)) {
11✔
107
        auto& new_seq =
11✔
108
            this->builder_
22✔
109
                .add_sequence(root, {}, this->builder_.debug_info().get_region(sequence_stmt->debug_info().indices()));
11✔
110
        this->node_mapping[sequence_stmt] = &new_seq;
11✔
111
        this->append(new_seq, *sequence_stmt);
11✔
112
    } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(&source)) {
11✔
113
        auto& new_scope = this->builder_.add_if_else(root);
×
114
        this->node_mapping[if_else_stmt] = &new_scope;
×
115
        for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
116
            auto branch = if_else_stmt->at(i);
×
117
            auto& new_branch = this->builder_.add_case(
×
118
                new_scope, branch.second, this->builder_.debug_info().get_region(branch.first.debug_info().indices())
×
119
            );
120
            this->node_mapping[&branch.first] = &new_branch;
×
121
            this->append(new_branch, branch.first);
×
122
        }
×
123
    } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(&source)) {
×
124
        auto& new_scope =
×
125
            this->builder_
×
126
                .add_while(root, {}, this->builder_.debug_info().get_region(loop_stmt->debug_info().indices()));
×
127
        this->node_mapping[loop_stmt] = &new_scope;
×
128
        this->append(new_scope.root(), loop_stmt->root());
×
129
    } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&source)) {
×
130
        auto& new_scope = this->builder_.add_for(
×
131
            root,
×
132
            for_stmt->indvar(),
×
133
            for_stmt->condition(),
×
134
            for_stmt->init(),
×
135
            for_stmt->update(),
×
136
            {},
×
137
            this->builder_.debug_info().get_region(for_stmt->debug_info().indices())
×
138
        );
139
        this->node_mapping[for_stmt] = &new_scope;
×
140
        this->append(new_scope.root(), for_stmt->root());
×
141
    } else if (auto cont_stmt = dynamic_cast<structured_control_flow::Continue*>(&source)) {
×
142
        auto& new_cont =
×
143
            this->builder_
×
144
                .add_continue(root, {}, this->builder_.debug_info().get_region(cont_stmt->debug_info().indices()));
×
145
        this->node_mapping[cont_stmt] = &new_cont;
×
146
    } else if (auto br_stmt = dynamic_cast<structured_control_flow::Break*>(&source)) {
×
147
        auto& new_br =
×
148
            this->builder_.add_break(root, {}, this->builder_.debug_info().get_region(br_stmt->debug_info().indices()));
×
149
        this->node_mapping[br_stmt] = &new_br;
×
150
    } else if (auto ret_stmt = dynamic_cast<structured_control_flow::Return*>(&source)) {
×
NEW
151
        auto& new_ret = this->builder_.add_return(
×
NEW
152
            root,
×
NEW
153
            ret_stmt->data(),
×
NEW
154
            ret_stmt->unreachable(),
×
NEW
155
            {},
×
NEW
156
            this->builder_.debug_info().get_region(ret_stmt->debug_info().indices())
×
157
        );
158
        this->node_mapping[ret_stmt] = &new_ret;
×
159
    } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&source)) {
×
160
        auto& new_scope = this->builder_.add_map(
×
161
            root,
×
162
            map_stmt->indvar(),
×
163
            map_stmt->condition(),
×
164
            map_stmt->init(),
×
165
            map_stmt->update(),
×
166
            map_stmt->schedule_type(),
×
167
            {},
×
168
            this->builder_.debug_info().get_region(map_stmt->debug_info().indices())
×
169
        );
170
        this->node_mapping[map_stmt] = &new_scope;
×
171
        this->append(new_scope.root(), map_stmt->root());
×
172
    } else {
×
173
        throw std::runtime_error("Deep copy not implemented");
×
174
    }
175
};
11✔
176

177
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(
22✔
178
    builder::StructuredSDFGBuilder& builder,
179
    structured_control_flow::Sequence& root,
180
    structured_control_flow::ControlFlowNode& source
181
)
182
    : builder_(builder), root_(root), source_(source) {};
22✔
183

184
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
185
StructuredSDFGDeepCopy::copy() {
11✔
186
    this->node_mapping.clear();
11✔
187
    this->insert(this->root_, this->source_);
11✔
188
    return this->node_mapping;
11✔
189
};
190

191
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
192
StructuredSDFGDeepCopy::insert() {
×
193
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
×
194
        this->node_mapping.clear();
×
195
        this->append(this->root_, *seq_source);
×
196
        return this->node_mapping;
×
197
    } else {
198
        throw std::runtime_error("Source node must be a sequence");
×
199
    }
200
};
×
201

202
} // namespace deepcopy
203
} // 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