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

daisytuner / sdfglib / 17637380013

11 Sep 2025 07:29AM UTC coverage: 59.755% (+0.6%) from 59.145%
17637380013

push

github

web-flow
New debug info (#210)

* initial draft

* update data structure and construction logic

* finalize DebugInfo draft

* fix tests

* Update serializer and fix tests

* fix append bug

* update data structure

* sdfg builder update

* const ref vectors

* update implementation and partial tests

* compiling state

* update serializer interface

* update dot test

* reset interface to debug_info in json to maintain compatibility with tools

* first review batch

* second batch of changes

* merge fixes

777 of 1111 new or added lines in 46 files covered. (69.94%)

11 existing lines in 11 files now uncovered.

9755 of 16325 relevant lines covered (59.75%)

115.06 hits per line

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

50.0
/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✔
NEW
29
            auto& new_scope = this->builder_.add_if_else(
×
NEW
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);
×
NEW
35
                auto& new_branch = this->builder_.add_case(
×
NEW
36
                    new_scope,
×
NEW
37
                    branch.second,
×
NEW
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, trans.assignments(), this->builder_.debug_info().get_region(ret_stmt->debug_info().indices())
1✔
62
            );
63
            this->node_mapping[ret_stmt] = &new_ret;
1✔
64
        } else if (auto for_stmt = dynamic_cast<structured_control_flow::For*>(&node)) {
3✔
65
            auto& new_scope = this->builder_.add_for(
1✔
66
                root,
1✔
67
                for_stmt->indvar(),
1✔
68
                for_stmt->condition(),
1✔
69
                for_stmt->init(),
1✔
70
                for_stmt->update(),
1✔
71
                trans.assignments(),
1✔
72
                this->builder_.debug_info().get_region(for_stmt->debug_info().indices())
1✔
73
            );
74
            this->node_mapping[for_stmt] = &new_scope;
1✔
75
            this->append(new_scope.root(), for_stmt->root());
1✔
76
        } else if (auto map_stmt = dynamic_cast<structured_control_flow::Map*>(&node)) {
2✔
77
            auto& new_scope = this->builder_.add_map(
1✔
78
                root,
1✔
79
                map_stmt->indvar(),
1✔
80
                map_stmt->condition(),
1✔
81
                map_stmt->init(),
1✔
82
                map_stmt->update(),
1✔
83
                map_stmt->schedule_type(),
1✔
84
                trans.assignments(),
1✔
85
                this->builder_.debug_info().get_region(map_stmt->debug_info().indices())
1✔
86
            );
87
            this->node_mapping[map_stmt] = &new_scope;
1✔
88
            this->append(new_scope.root(), map_stmt->root());
1✔
89
        } else {
1✔
90
            throw std::runtime_error("Deep copy not implemented");
×
91
        }
92
    }
13✔
93
};
18✔
94

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

169
StructuredSDFGDeepCopy::StructuredSDFGDeepCopy(
22✔
170
    builder::StructuredSDFGBuilder& builder,
171
    structured_control_flow::Sequence& root,
172
    structured_control_flow::ControlFlowNode& source
173
)
174
    : builder_(builder), root_(root), source_(source) {};
22✔
175

176
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
177
StructuredSDFGDeepCopy::copy() {
11✔
178
    this->node_mapping.clear();
11✔
179
    this->insert(this->root_, this->source_);
11✔
180
    return this->node_mapping;
11✔
181
};
182

183
std::unordered_map<const structured_control_flow::ControlFlowNode*, const structured_control_flow::ControlFlowNode*>
184
StructuredSDFGDeepCopy::insert() {
×
185
    if (auto seq_source = dynamic_cast<structured_control_flow::Sequence*>(&this->source_)) {
×
186
        this->node_mapping.clear();
×
187
        this->append(this->root_, *seq_source);
×
188
        return this->node_mapping;
×
189
    } else {
190
        throw std::runtime_error("Source node must be a sequence");
×
191
    }
192
};
×
193

194
} // namespace deepcopy
195
} // 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