Skip to content

Commit

Permalink
Remove redundant checks from VisitCallExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi authored and vgvassilev committed Mar 18, 2024
1 parent 925700c commit 1e0c774
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,21 +1722,12 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
for (auto* argDerivative : CallArgDx) {
Expr* gradArgExpr = nullptr;
const Expr* arg = CE->getArg(idx);
if (utils::IsReferenceOrPointerArg(arg)) {
if (argDerivative) {
if (utils::isArrayOrPointerType(argDerivative->getType()) ||
isCladArrayType(argDerivative->getType()) ||
!argDerivative->isLValue())
gradArgExpr = argDerivative;
else
gradArgExpr =
BuildOp(UnaryOperatorKind::UO_AddrOf, argDerivative);
}
} else {
Expr* gradVarExpr = CallArgDx[idx];
if (utils::isArrayOrPointerType(arg->getType()) ||
isCladArrayType(argDerivative->getType()))
gradArgExpr = argDerivative;
else
gradArgExpr =
BuildOp(UO_AddrOf, gradVarExpr, m_Function->getLocation());
}
BuildOp(UO_AddrOf, argDerivative, m_Function->getLocation());
DerivedCallOutputArgs.push_back(gradArgExpr);
idx++;
}
Expand All @@ -1745,13 +1736,6 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
if ((pullback == nullptr) && FD->getReturnType()->isLValueReferenceType())
pullback = getZeroInit(FD->getReturnType().getNonReferenceType());

// FIXME: Remove this restriction.
if (!FD->getReturnType()->isVoidType()) {
assert((pullback && !FD->getReturnType()->isVoidType()) &&
"Call to function returning non-void type with no dfdx() is not "
"supported!");
}

if (FD->getReturnType()->isVoidType()) {
assert(pullback == nullptr && FD->getReturnType()->isVoidType() &&
"Call to function returning void type should not have any "
Expand Down

0 comments on commit 1e0c774

Please sign in to comment.