Skip to content

Commit 6a119f6

Browse files
committed
Use const Stmt& in AddAtomicMutex.cpp
1 parent 0245101 commit 6a119f6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/AddAtomicMutex.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Internal {
1313
namespace {
1414

1515
/** Collect names of all stores matching the producer name inside a statement. */
16-
Scope<void> collect_producer_store_names(Stmt s, const std::string &producer_name) {
16+
Scope<void> collect_producer_store_names(const Stmt &s, const std::string &producer_name) {
1717
Scope<void> store_names;
1818
visit_with(s, [&](auto *self, const Store *op) {
1919
self->visit_base(op);
@@ -27,7 +27,7 @@ Scope<void> collect_producer_store_names(Stmt s, const std::string &producer_nam
2727

2828
/** Find Store inside of an Atomic node for the designated producer
2929
* and return their indices. */
30-
Expr find_producer_store_index(Stmt s, const std::string &producer_name) {
30+
Expr find_producer_store_index(const Stmt &s, const std::string &producer_name) {
3131
Expr index;
3232
visit_with(
3333
s,
@@ -70,7 +70,7 @@ Expr find_producer_store_index(Stmt s, const std::string &producer_name) {
7070
/** Throws an assertion for cases where the indexing on left-hand-side of
7171
* an atomic update references to itself.
7272
* e.g. f(clamp(f(r), 0, 100)) = f(r) + 1 should be rejected. */
73-
bool check_atomic_validity(Stmt s) {
73+
bool check_atomic_validity(const Stmt &s) {
7474
bool any_atomic = false;
7575
visit_with(s, [&](auto *self, const Atomic *op) {
7676
any_atomic = true;
@@ -95,7 +95,7 @@ bool check_atomic_validity(Stmt s) {
9595
* where the let binding contains the Store location. Use for checking whether
9696
* we need a mutex lock for Atomic since some lowering pass before lifted a let
9797
* binding from the Store node (currently only SplitTuple would do this). */
98-
bool find_atomic_let_bindings(Stmt s, const Scope<void> &store_names) {
98+
bool find_atomic_let_bindings(const Stmt &s, const Scope<void> &store_names) {
9999
bool found = false;
100100
std::string inside_store;
101101
Scope<Expr> let_bindings;
@@ -162,7 +162,7 @@ Stmt remove_unnecessary_mutex_use(const Stmt &s) {
162162
}
163163

164164
/** Replace the indices in the Store nodes with the specified variable. */
165-
Stmt replace_store_index_with_var(Stmt s, const std::string &producer_name, Expr var) {
165+
Stmt replace_store_index_with_var(const Stmt &s, const std::string &producer_name, Expr var) {
166166
return mutate_with(s, [&](auto *self, const Store *op) {
167167
if (op->name == producer_name || starts_with(op->name, producer_name + ".")) {
168168
return Store::make(op->name, op->value, var, op->param, op->predicate, op->alignment);
@@ -190,7 +190,7 @@ Stmt allocate_mutex(const std::string &mutex_name, Expr extent, const Stmt &body
190190
}
191191

192192
/** Add mutex allocation & lock & unlock if required. */
193-
Stmt inject_atomic_mutex(Stmt s, const std::vector<Function> &o) {
193+
Stmt inject_atomic_mutex(const Stmt &s, const std::vector<Function> &o) {
194194
// Maps from a producer name to a mutex name, for all encountered atomic
195195
// nodes.
196196
Scope<std::string> needs_mutex_allocation;

0 commit comments

Comments
 (0)