From e675ddc6b9562871c3a49fc3bc2a5145abf9d6d8 Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Tue, 12 Apr 2022 19:45:48 +0800 Subject: [PATCH] [autodiff] Fix nullptr during adjoint codegen (#4771) --- taichi/transforms/auto_diff.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/taichi/transforms/auto_diff.cpp b/taichi/transforms/auto_diff.cpp index 81c50adf19a57..82f65de408bbc 100644 --- a/taichi/transforms/auto_diff.cpp +++ b/taichi/transforms/auto_diff.cpp @@ -656,6 +656,7 @@ class MakeAdjoint : public IRVisitor { // for _ in range(5) // q += a[i] if (stmt->is() && + (stmt->parent->parent_stmt != nullptr) && stmt->parent->parent_stmt->is()) { // Check whether this GlobalLoadStmt is in the body of a for-loop by // searching in the backup forward pass If not (Case 1), the alloca