Skip to content

Commit

Permalink
[bug] Cherry-pick "Fix dereferencing nullptr (taichi-dev#6763)" (taic…
Browse files Browse the repository at this point in the history
…hi-dev#6769)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
strongoier and pre-commit-ci[bot] committed Nov 30, 2022
1 parent e4a1129 commit 0f25b95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions taichi/transforms/loop_invariant_detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class LoopInvariantDetector : public BasicStmtVisitor {
bool is_invariant = true;

for (Stmt *operand : stmt->get_operands()) {
if (operand == nullptr)
continue;
is_invariant &= is_operand_loop_invariant_impl(operand, current_scope);
}

Expand Down
2 changes: 2 additions & 0 deletions taichi/transforms/make_thread_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ std::vector<std::pair<T *, AtomicOpType>> find_global_reduction_destinations(
}
}
for (auto &op : stmt->get_operands()) {
if (op == nullptr)
continue;
// Make sure the values of related atomic operations are not used.
if (auto atomic = op->cast<AtomicOpStmt>()) {
if (irpass::analysis::maybe_same_address(atomic->dest,
Expand Down

0 comments on commit 0f25b95

Please sign in to comment.