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

daisytuner / docc / 22851518700

09 Mar 2026 11:34AM UTC coverage: 64.448% (+0.03%) from 64.415%
22851518700

Pull #556

github

web-flow
Merge 523df0a24 into 64dd02640
Pull Request #556: [MLIR] add support for linalg broadcast

24493 of 38004 relevant lines covered (64.45%)

386.53 hits per line

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

25.42
/sdfg/src/data_flow/library_nodes/stdlib/malloc.cpp
1
#include "sdfg/data_flow/library_nodes/stdlib/malloc.h"
2

3
namespace sdfg {
4
namespace stdlib {
5

6
MallocNode::MallocNode(
7
    size_t element_id,
8
    const DebugInfo& debug_info,
9
    const graph::Vertex vertex,
10
    data_flow::DataFlowGraph& parent,
11
    const symbolic::Expression size
12
)
13
    : LibraryNode(
21✔
14
          element_id,
21✔
15
          debug_info,
21✔
16
          vertex,
21✔
17
          parent,
21✔
18
          LibraryNodeType_Malloc,
21✔
19
          {"_ret"},
21✔
20
          {},
21✔
21
          true,
21✔
22
          data_flow::ImplementationType_NONE
21✔
23
      ),
21✔
24
      size_(size) {}
21✔
25

26
const symbolic::Expression MallocNode::size() const { return size_; }
4✔
27

28
void MallocNode::validate(const Function& function) const { LibraryNode::validate(function); }
4✔
29

30
symbolic::SymbolSet MallocNode::symbols() const { return symbolic::atoms(this->size_); }
19✔
31

32
std::unique_ptr<data_flow::DataFlowNode> MallocNode::
33
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
34
    return std::make_unique<MallocNode>(element_id, debug_info_, vertex, parent, size_);
×
35
}
×
36

37
void MallocNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
38
    this->size_ = symbolic::subs(this->size_, old_expression, new_expression);
×
39
}
×
40

41
std::string MallocNode::toStr() const { return LibraryNode::toStr() + "(" + size_->__str__() + ")"; }
×
42

43
nlohmann::json MallocNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
44
    const MallocNode& node = static_cast<const MallocNode&>(library_node);
×
45

46
    nlohmann::json j;
×
47
    j["code"] = node.code().value();
×
48

49
    sdfg::serializer::JSONSerializer serializer;
×
50
    j["size"] = serializer.expression(node.size());
×
51

52
    return j;
×
53
}
×
54

55
data_flow::LibraryNode& MallocNodeSerializer::deserialize(
56
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
57
) {
×
58
    assert(j.contains("code"));
×
59
    assert(j.contains("debug_info"));
×
60
    assert(j.contains("size"));
×
61

62
    auto code = j["code"].get<std::string>();
×
63
    if (code != LibraryNodeType_Malloc.value()) {
×
64
        throw InvalidSDFGException("Invalid library node code");
×
65
    }
×
66

67
    sdfg::serializer::JSONSerializer serializer;
×
68
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
69

70
    auto size = symbolic::parse(j.at("size"));
×
71

72
    return builder.add_library_node<MallocNode>(parent, debug_info, size);
×
73
}
×
74

75
MallocNodeDispatcher::MallocNodeDispatcher(
76
    codegen::LanguageExtension& language_extension,
77
    const Function& function,
78
    const data_flow::DataFlowGraph& data_flow_graph,
79
    const MallocNode& node
80
)
81
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
82

83
void MallocNodeDispatcher::dispatch_code(
84
    codegen::PrettyPrinter& stream,
85
    codegen::PrettyPrinter& globals_stream,
86
    codegen::CodeSnippetFactory& library_snippet_factory
87
) {
×
88
    auto& malloc_node = static_cast<const MallocNode&>(node_);
×
89

90
    auto& graph = malloc_node.get_parent();
×
91
    auto& oedge = *graph.out_edges(malloc_node).begin();
×
92

93
    stream << malloc_node.outputs().at(0);
×
94
    stream << " = ";
×
95
    stream << "("
×
96
           << language_extension_.type_cast(
×
97
                  language_extension_.external_prefix() + "malloc(" +
×
98
                      language_extension_.expression(malloc_node.size()) + ")",
×
99
                  oedge.base_type()
×
100
              )
×
101
           << ");";
×
102
    stream << std::endl;
×
103
}
×
104

105
} // namespace stdlib
106
} // 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