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 committed Mar 14, 2024
1 parent 8c6d93c commit 453043e
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 453043e

Please sign in to comment.