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

daisytuner / docc / 23087278095

14 Mar 2026 11:44AM UTC coverage: 63.927% (+0.3%) from 63.617%
23087278095

push

github

web-flow
Merge pull request #568 from daisytuner/dead-data-elimination

Working on memory ownership & escape analysis

475 of 637 new or added lines in 28 files covered. (74.57%)

6 existing lines in 3 files now uncovered.

26010 of 40687 relevant lines covered (63.93%)

402.05 hits per line

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

83.81
/sdfg/src/data_flow/access_node.cpp
1
#include "sdfg/data_flow/access_node.h"
2

3
#include <unordered_set>
4
#include "sdfg/data_flow/data_flow_graph.h"
5
#include "sdfg/function.h"
6

7
namespace sdfg {
8
namespace data_flow {
9

10
AccessNode::AccessNode(
11
    size_t element_id,
12
    const DebugInfo& debug_info,
13
    const graph::Vertex vertex,
14
    DataFlowGraph& parent,
15
    const std::string& data
16
)
17
    : DataFlowNode(element_id, debug_info, vertex, parent), data_(data) {
5,605✔
18

19
      };
5,605✔
20

21
void AccessNode::validate(const Function& function) const {
7,484✔
22
    if (!function.exists(this->data_)) {
7,484✔
23
        throw InvalidSDFGException("Access node " + this->data_ + " uses non-existent variable");
×
24
    }
×
25

26
    auto& graph = this->get_parent();
7,484✔
27

28
    if (graph.out_degree(*this) > 1) {
7,484✔
29
        MemletType type = (*graph.out_edges(*this).begin()).type();
177✔
30
        for (auto& oedge : graph.out_edges(*this)) {
355✔
31
            if (oedge.type() != type) {
355✔
32
                throw InvalidSDFGException("Access node " + this->data() + " used with multiple memlet types");
×
33
            }
×
34
        }
355✔
35
    }
177✔
36

37
    if (graph.in_degree(*this) > 1) {
7,484✔
38
        MemletType type = (*graph.in_edges(*this).begin()).type();
5✔
39
        for (auto& iedge : graph.in_edges(*this)) {
10✔
40
            if (iedge.type() != type) {
10✔
41
                throw InvalidSDFGException("Access node " + this->data() + " used with multiple memlet types");
×
42
            }
×
43
        }
10✔
44
    }
5✔
45
}
7,484✔
46

47
const std::string& AccessNode::data() const { return this->data_; };
23,907✔
48

49
void AccessNode::data(const std::string data) { this->data_ = data; }
48✔
50

51
bool AccessNode::side_effect() const { return get_parent().in_degree(*this) > 0; }
82✔
52

53
std::unique_ptr<DataFlowNode> AccessNode::clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph& parent)
54
    const {
40✔
55
    return std::unique_ptr<AccessNode>(new AccessNode(element_id, this->debug_info_, vertex, parent, this->data_));
40✔
56
};
40✔
57

58
void AccessNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
187✔
59
    if (SymEngine::is_a<SymEngine::Symbol>(*old_expression) && SymEngine::is_a<SymEngine::Symbol>(*new_expression)) {
187✔
60
        auto old_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(old_expression);
166✔
61
        if (this->data_ == old_symbol->get_name()) {
166✔
62
            auto new_symbol = SymEngine::rcp_static_cast<const SymEngine::Symbol>(new_expression);
32✔
63
            this->data_ = new_symbol->get_name();
32✔
64
        }
32✔
65
    }
166✔
66
};
187✔
67

68
namespace {
69
bool is_special_constant(const std::string& data) {
72✔
70
    static const std::unordered_set<std::string> constants = {
72✔
71
        "true",
72✔
72
        "false",
72✔
73
        "INT8_MIN",
72✔
74
        "INT8_MAX",
72✔
75
        "UINT8_MAX",
72✔
76
        "INT16_MIN",
72✔
77
        "INT16_MAX",
72✔
78
        "UINT16_MAX",
72✔
79
        "INT32_MIN",
72✔
80
        "INT32_MAX",
72✔
81
        "UINT32_MAX",
72✔
82
        "INT64_MIN",
72✔
83
        "INT64_MAX",
72✔
84
        "UINT64_MAX",
72✔
85
    };
72✔
86
    return constants.find(data) != constants.end();
72✔
87
}
72✔
88
} // namespace
89

90
ConstantNode::ConstantNode(
91
    size_t element_id,
92
    const DebugInfo& debug_info,
93
    const graph::Vertex vertex,
94
    DataFlowGraph& parent,
95
    const std::string& data,
96
    const types::IType& type
97
)
98
    : AccessNode(element_id, debug_info, vertex, parent, data), type_(type.clone()) {};
257✔
99

100
void ConstantNode::validate(const Function& function) const {
379✔
101
    if (function.exists(this->data_)) {
379✔
102
        throw InvalidSDFGException("ConstantNode " + this->data_ + " uses variable");
×
103
    }
×
104

105
    auto& graph = this->get_parent();
379✔
106
    if (graph.in_degree(*this) > 0) {
379✔
107
        throw InvalidSDFGException("ConstantNode " + this->data_ + " has incoming edges");
×
108
    }
×
109

110
    switch (this->type_->type_id()) {
379✔
111
        case types::TypeID::Scalar: {
337✔
112
            auto& scalar_type = static_cast<const types::Scalar&>(*this->type_);
337✔
113
            switch (scalar_type.primitive_type()) {
337✔
114
                case types::PrimitiveType::Bool:
×
115
                case types::PrimitiveType::Int8:
×
116
                case types::PrimitiveType::Int16:
×
117
                case types::PrimitiveType::Int32:
47✔
118
                case types::PrimitiveType::Int64:
50✔
119
                case types::PrimitiveType::UInt8:
50✔
120
                case types::PrimitiveType::UInt16:
50✔
121
                case types::PrimitiveType::UInt32:
64✔
122
                case types::PrimitiveType::UInt64: {
72✔
123
                    auto data = this->data();
72✔
124
                    if (is_special_constant(data)) {
72✔
125
                        break;
×
126
                    }
×
127

128
                    try {
72✔
129
                        helpers::parse_number_signed(data);
72✔
130
                    } catch (const std::exception& e) {
72✔
NEW
131
                        throw InvalidSDFGException("ConstantNode " + data + " has non-integer scalar type");
×
132
                    }
×
133
                    break;
72✔
134
                }
72✔
135
                default:
265✔
136
                    break;
265✔
137
            }
337✔
138
            break;
337✔
139
        }
337✔
140
        default:
337✔
141
            break;
42✔
142
    }
379✔
143
}
379✔
144

145
const types::IType& ConstantNode::type() const { return *this->type_; };
207✔
146

147
std::unique_ptr<DataFlowNode> ConstantNode::clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph& parent)
148
    const {
5✔
149
    return std::unique_ptr<
5✔
150
        ConstantNode>(new ConstantNode(element_id, this->debug_info_, vertex, parent, this->data(), *this->type_));
5✔
151
};
5✔
152

153
} // namespace data_flow
154
} // 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