Skip to content

Commit

Permalink
Remove redundant argument cloning.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Sep 8, 2023
1 parent b033a42 commit 820c29e
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,17 +1888,6 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
m_ExternalSource->ActBeforeFinalizingVisitCallExpr(
CE, OverloadedDerivedFn, DerivedCallArgs, ArgResultDecls, asGrad);

// FIXME: Why are we cloning args here? We already created different
// expressions for call to original function and call to gradient.
// Re-clone function arguments again, since they are required at 2 places:
// call to gradient and call to original function. At this point, each arg
// is either a simple expression or a reference to a temporary variable.
// Therefore cloning it has constant complexity.
std::transform(std::begin(CallArgs),
std::end(CallArgs),
std::begin(CallArgs),
[this](Expr* E) { return Clone(E); });

Expr* call = nullptr;

if (FD->getReturnType()->isReferenceType()) {
Expand Down

0 comments on commit 820c29e

Please sign in to comment.