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

daisytuner / sdfglib / 15342553660

30 May 2025 08:25AM UTC coverage: 58.573% (+0.02%) from 58.553%
15342553660

Pull #44

github

web-flow
Merge 003852900 into ad9a83c5a
Pull Request #44: Add Structured Loops

52 of 103 new or added lines in 20 files covered. (50.49%)

2 existing lines in 2 files now uncovered.

8212 of 14020 relevant lines covered (58.57%)

109.72 hits per line

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

0.0
/src/analysis/loop_tree_analysis.cpp
1
#include "sdfg/analysis/loop_tree_analysis.h"
2

3
#include "sdfg/structured_control_flow/structured_loop.h"
4

5
namespace sdfg {
6
namespace analysis {
7

8
LoopTreeAnalysis::LoopTreeAnalysis(StructuredSDFG& sdfg) : Analysis(sdfg) {}
×
9

10
void LoopTreeAnalysis::run(structured_control_flow::ControlFlowNode& scope,
×
11
                           structured_control_flow::ControlFlowNode* parent_loop) {
12
    std::list<structured_control_flow::ControlFlowNode*> queue = {&scope};
×
13
    while (!queue.empty()) {
×
14
        auto current = queue.front();
×
15
        queue.pop_front();
×
16

17
        // Loop detected
18
        if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
×
19
            this->loop_tree_[while_stmt] = parent_loop;
×
NEW
20
        } else if (auto for_stmt =
×
NEW
21
                       dynamic_cast<structured_control_flow::StructuredLoop*>(current)) {
×
22
            this->loop_tree_[for_stmt] = parent_loop;
×
23
        }
×
24

25
        if (dynamic_cast<structured_control_flow::Block*>(current)) {
×
26
            continue;
×
27
        } else if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(current)) {
×
28
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
×
29
                queue.push_back(&sequence_stmt->at(i).first);
×
30
            }
×
31
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(current)) {
×
32
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
33
                queue.push_back(&if_else_stmt->at(i).first);
×
34
            }
×
35
        } else if (auto while_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
×
36
            this->run(while_stmt->root(), while_stmt);
×
NEW
37
        } else if (auto for_stmt =
×
NEW
38
                       dynamic_cast<structured_control_flow::StructuredLoop*>(current)) {
×
39
            this->run(for_stmt->root(), for_stmt);
×
40
        } else if (dynamic_cast<structured_control_flow::Kernel*>(current)) {
×
41
            continue;
×
42
        } else if (dynamic_cast<structured_control_flow::Break*>(current)) {
×
43
            continue;
×
44
        } else if (dynamic_cast<structured_control_flow::Continue*>(current)) {
×
45
            continue;
×
46
        } else if (dynamic_cast<structured_control_flow::Return*>(current)) {
×
47
            continue;
×
48
        } else {
49
            throw std::runtime_error("Unsupported control flow node type");
×
50
        }
51
    }
52
}
×
53

54
void LoopTreeAnalysis::run(AnalysisManager& analysis_manager) {
×
55
    this->loop_tree_.clear();
×
56
    this->run(this->sdfg_.root(), nullptr);
×
57
}
×
58

59
const std::unordered_map<structured_control_flow::ControlFlowNode*,
60
                         structured_control_flow::ControlFlowNode*>&
61
LoopTreeAnalysis::loop_tree() const {
×
62
    return this->loop_tree_;
×
63
}
64

65
structured_control_flow::ControlFlowNode* LoopTreeAnalysis::parent_loop(
×
66
    structured_control_flow::ControlFlowNode* loop) const {
67
    return this->loop_tree_.at(loop);
×
68
}
69

70
const std::vector<structured_control_flow::ControlFlowNode*> LoopTreeAnalysis::outermost_loops()
×
71
    const {
72
    std::vector<structured_control_flow::ControlFlowNode*> outermost_loops_;
×
73
    for (const auto& [loop, parent] : this->loop_tree_) {
×
74
        if (parent == nullptr) {
×
75
            outermost_loops_.push_back(loop);
×
76
        }
×
77
    }
78
    return outermost_loops_;
×
79
}
×
80

81
}  // namespace analysis
82
}  // 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