From 0f25b95e0208099a7372687c431d9974fd8ccc9a Mon Sep 17 00:00:00 2001 From: Yi Xu Date: Wed, 30 Nov 2022 17:44:30 +0800 Subject: [PATCH] [bug] Cherry-pick "Fix dereferencing nullptr (#6763)" (#6769) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- taichi/transforms/loop_invariant_detector.h | 2 ++ taichi/transforms/make_thread_local.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/taichi/transforms/loop_invariant_detector.h b/taichi/transforms/loop_invariant_detector.h index d9ce963c505ca..3913b7bd46733 100644 --- a/taichi/transforms/loop_invariant_detector.h +++ b/taichi/transforms/loop_invariant_detector.h @@ -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); } diff --git a/taichi/transforms/make_thread_local.cpp b/taichi/transforms/make_thread_local.cpp index d88e8fcd946af..8756551610016 100644 --- a/taichi/transforms/make_thread_local.cpp +++ b/taichi/transforms/make_thread_local.cpp @@ -76,6 +76,8 @@ std::vector> 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()) { if (irpass::analysis::maybe_same_address(atomic->dest,