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

vla5924-practice / compiler-project / 14009064270

22 Mar 2025 01:32PM UTC coverage: 82.886%. Remained the same
14009064270

push

github

web-flow
Perform convergent transformation within CascadeTransform (#197)

By default, `Transform` will be run once for each operation it supports
(optionally with recursion if `recurse` method returns true). To perform
convergent transformations (e.g. canonicalization), `CascadeTransform`
will be used.

124 of 136 new or added lines in 6 files covered. (91.18%)

4756 of 5738 relevant lines covered (82.89%)

269.1 hits per line

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

87.5
/compiler/lib/backend/optree/optimizer/optimizer.cpp
1
#include "optimizer/optimizer.hpp"
2

3
#include "compiler/optree/operation.hpp"
4
#include "compiler/optree/program.hpp"
5
#include "compiler/utils/debug.hpp"
6
#include "compiler/utils/helpers.hpp"
7

8
#include "optimizer/opt_builder.hpp"
9
#include "optimizer/transform.hpp"
10

11
using namespace optree;
12
using namespace optree::optimizer;
13

14
using dbg = utils::DebugPrinter;
15

16
namespace {
17

18
void runTransform(const BaseTransform::Ptr &transform, const OptBuilder::Notifier &notifier, const Operation::Ptr &op) {
25✔
19
    bool canRun = transform->canRun(op);
25✔
20
    if (transform->recurse() || (!canRun && !transform->recurse())) {
25✔
NEW
21
        for (const auto &childOp : utils::advanceEarly(op->body)) {
×
NEW
22
            runTransform(transform, notifier, childOp);
×
23
        }
24
    }
25
    if (!canRun)
25✔
NEW
26
        return;
×
27
    OptBuilder builder(notifier);
25✔
28
    builder.setInsertPointBefore(op);
25✔
29
    COMPILER_DEBUG(dbg::get() << "Run " << transform->name() << " on " << op->dump() << "{\n");
25✔
30
    transform->run(op, builder);
25✔
31
    COMPILER_DEBUG(dbg::get() << "}\n\n");
25✔
32
}
25✔
33

34
} // namespace
35

36
Optimizer &Optimizer::add(const BaseTransform::Ptr &transform) {
25✔
37
    transforms.emplace_back(transform);
25✔
38
    return *this;
25✔
39
}
40

41
void Optimizer::process(const Operation::Ptr &op) const {
25✔
42
    OptBuilder::Notifier empty;
25✔
43
    for (const auto &transform : transforms)
50✔
44
        runTransform(transform, empty, op);
25✔
45
}
25✔
46

47
void Optimizer::process(Program &program) const {
25✔
48
    process(program.root);
25✔
49
}
25✔
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