Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify if-conditions. NFC. #1177

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1977,13 +1977,24 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
else
pullbackFD = m_Builder.HandleNestedDiffRequest(pullbackRequest);

// Clad failed to derive it.
// FIXME: Add support for reference arguments to the numerical diff. If
// it already correctly support reference arguments then confirm the
// support and add tests for the same.
if (!pullbackFD && !utils::HasAnyReferenceOrPointerArgument(FD) &&
!isa<CXXMethodDecl>(FD)) {
// Try numerically deriving it.
if (pullbackFD) {
if (MD) {
Expr* baseE = baseDiff.getExpr();
OverloadedDerivedFn = BuildCallExprToMemFn(
baseE, pullbackFD->getName(), pullbackCallArgs, Loc);
} else {
OverloadedDerivedFn =
m_Sema
.ActOnCallExpr(getCurrentScope(), BuildDeclRef(pullbackFD),
Loc, pullbackCallArgs, Loc, CUDAExecConfig)
.get();
}
} else if (!utils::HasAnyReferenceOrPointerArgument(FD) && !MD) {
// FIXME: Add support for reference arguments to the numerical diff. If
// it already correctly support reference arguments then confirm the
// support and add tests for the same.
//
// Clad failed to derive it. Try numerically deriving it.
if (NArgs == 1) {
OverloadedDerivedFn = GetSingleArgCentralDiffCall(
Clone(CE->getCallee()), DerivedCallArgs[0],
Expand All @@ -2003,18 +2014,6 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
block.insert(block.begin(), PreCallStmts.begin(), PreCallStmts.end());
return StmtDiff(Clone(CE));
}
} else if (pullbackFD) {
if (baseDiff.getExpr()) {
Expr* baseE = baseDiff.getExpr();
OverloadedDerivedFn = BuildCallExprToMemFn(
baseE, pullbackFD->getName(), pullbackCallArgs, Loc);
} else {
OverloadedDerivedFn =
m_Sema
.ActOnCallExpr(getCurrentScope(), BuildDeclRef(pullbackFD),
Loc, pullbackCallArgs, Loc, CUDAExecConfig)
.get();
}
}
}

Expand Down
Loading