Skip to content

Commit

Permalink
Deduce isInFunctionGlobalScope from the scopes and not from the lengt…
Browse files Browse the repository at this point in the history
…h of m_Reverse.
  • Loading branch information
PetroZarytskyi committed Feb 5, 2024
1 parent 9fa1bf8 commit deddb61
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2516,9 +2516,9 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
VarDeclDiff ReverseModeVisitor::DifferentiateVarDecl(const VarDecl* VD) {
StmtDiff initDiff;
Expr* VDDerivedInit = nullptr;
// FIXME: find a more reliable way to determine if the declaration
// is in the function global scope.
bool isInFunctionGlobalScope = m_Reverse.size() <= 2;
// We take the parent of the current scope because the main compound
// statement of the function has its own scope as well.
bool isInFunctionGlobalScope = getCurrentScope()->getParent()==m_DerivativeFnScope;
auto VDDerivedType = ComputeAdjointType(VD->getType());
auto VDCloneType = CloneType(VD->getType());
if (!isInFunctionGlobalScope)
Expand Down Expand Up @@ -2725,9 +2725,9 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
llvm::SmallVector<Decl*, 4> declsDiff;
// Need to put array decls inlined.
llvm::SmallVector<Decl*, 4> localDeclsDiff;
// FIXME: find a more reliable way to determine if the declaration
// is in the function global scope.
bool isInFunctionGlobalScope = m_Reverse.size() <= 2;
// We take the parent of the current scope because the main compound
// statement of the function has its own scope as well.
bool isInFunctionGlobalScope = getCurrentScope()->getParent()==m_DerivativeFnScope;
// For each variable declaration v, create another declaration _d_v to
// store derivatives for potential reassignments. E.g.
// double y = x;
Expand Down

0 comments on commit deddb61

Please sign in to comment.