Skip to content

Commit

Permalink
Revert changes and fix codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Andriychuk committed Oct 14, 2024
1 parent 42e79eb commit 03255f3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 0 additions & 2 deletions lib/Differentiator/ActivityAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ bool VariedAnalyzer::VisitCallExpr(CallExpr* CE) {

bool VariedAnalyzer::VisitDeclStmt(DeclStmt* DS) {
for (Decl* D : DS->decls()) {
if (!isa<VarDecl>(D))
continue;
if (Expr* init = cast<VarDecl>(D)->getInit()) {
m_Varied = false;
TraverseStmt(init);
Expand Down
12 changes: 6 additions & 6 deletions lib/Differentiator/DiffPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ namespace clad {
bool enable_tbr_in_req = false;
bool disable_tbr_in_req = false;
bool enable_va_in_req = false;
bool disable_aa_in_req = false;
bool disable_va_in_req = false;
if (!A->getAnnotation().equals("E") &&
FD->getTemplateSpecializationArgs()) {
const auto template_arg = FD->getTemplateSpecializationArgs()->get(0);
Expand All @@ -687,14 +687,14 @@ namespace clad {
// Set option for Activity analysis.
enable_va_in_req =
clad::HasOption(bitmasked_opts_value, clad::opts::enable_va);
disable_aa_in_req =
clad::HasOption(bitmasked_opts_value, clad::opts::disable_aa);
disable_va_in_req =
clad::HasOption(bitmasked_opts_value, clad::opts::disable_va);
if (enable_tbr_in_req && disable_tbr_in_req) {
utils::EmitDiag(m_Sema, DiagnosticsEngine::Error, endLoc,
"Both enable and disable TBR options are specified.");
return true;
}
if (enable_va_in_req && disable_aa_in_req) {
if (enable_va_in_req && disable_va_in_req) {
utils::EmitDiag(m_Sema, DiagnosticsEngine::Error, endLoc,
"Both enable and disable AA options are specified.");
return true;
Expand All @@ -705,9 +705,9 @@ namespace clad {
} else {
request.EnableTBRAnalysis = m_Options.EnableTBRAnalysis;
}
if (enable_va_in_req || disable_aa_in_req) {
if (enable_va_in_req || disable_va_in_req) {
// override the default value of TBR analysis.
request.EnableVariedAnalysis = enable_va_in_req && !disable_aa_in_req;
request.EnableVariedAnalysis = enable_va_in_req && !disable_va_in_req;
} else {
request.EnableVariedAnalysis = m_Options.EnableVariedAnalysis;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,9 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
}

StmtDiff ReverseModeVisitor::VisitIntegerLiteral(const IntegerLiteral* IL) {
return StmtDiff(Clone(IL));
auto* Constant0 =
ConstantFolder::synthesizeLiteral(m_Context.IntTy, m_Context, 0);
return StmtDiff(Clone(IL), Constant0);
}

StmtDiff ReverseModeVisitor::VisitFloatingLiteral(const FloatingLiteral* FL) {
Expand Down
6 changes: 3 additions & 3 deletions test/Gradient/FunctionCalls.C
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,14 @@ double do_nothing(double* u, double* v, double* w) {
return u[0];
}

// CHECK: void do_nothing_pullback(double *u, double *v, double *w, double _d_y, double *_d_u, double *_d_v);
// CHECK: void do_nothing_pullback(double *u, double *v, double *w, double _d_y, double *_d_u, double *_d_v, double *_d_w);

double fn12(double x, double y) {
return do_nothing(&x, nullptr, 0);
}

// CHECK: void fn12_grad(double x, double y, double *_d_x, double *_d_y) {
// CHECK-NEXT: do_nothing_pullback(&x, nullptr, 0, 1, &*_d_x, nullptr);
// CHECK-NEXT: do_nothing_pullback(&x, nullptr, 0, 1, &*_d_x, nullptr, 0);
// CHECK-NEXT: }

double multiply(double* a, double* b) {
Expand Down Expand Up @@ -998,7 +998,7 @@ double sq_defined_later(double x) {
// CHECK-NEXT: *_d_b += _d_y;
// CHECK-NEXT: }

// CHECK: void do_nothing_pullback(double *u, double *v, double *w, double _d_y, double *_d_u, double *_d_v) {
// CHECK: void do_nothing_pullback(double *u, double *v, double *w, double _d_y, double *_d_u, double *_d_v, double *_d_w) {
// CHECK-NEXT: _d_u[0] += _d_y;
// CHECK-NEXT: }

Expand Down
6 changes: 5 additions & 1 deletion test/Misc/Args.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@

// RUN: clang -fsyntax-only -fplugin=%cladlib -Xclang -plugin-arg-clad -Xclang -enable-tbr \
// RUN: -Xclang -plugin-arg-clad -Xclang -disable-tbr %s 2>&1 | FileCheck --check-prefix=CHECK_TBR %s
// CHECK_TBR: -enable-tbr and -disable-tbr cannot be used together
// CHECK_TBR: -enable-tbr and -disable-tbr cannot be used together

// RUN: clang -fsyntax-only -fplugin=%cladlib -Xclang -plugin-arg-clad -Xclang -enable-va \
// RUN: -Xclang -plugin-arg-clad -Xclang -disable-va %s 2>&1 | FileCheck --check-prefix=CHECK_VA %s
// CHECK_VA: -enable-va and -disable-va cannot be used together
4 changes: 2 additions & 2 deletions tools/ClangPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class CladTimerGroup {
m_DO.DisableTBRAnalysis = true;
} else if (args[i] == "-enable-va") {
m_DO.EnableVariedAnalysis = true;
} else if (args[i] == "-disable-aa") {
} else if (args[i] == "-disable-va") {
m_DO.DisableActivityAnalysis = true;
} else if (args[i] == "-fcustom-estimation-model") {
m_DO.CustomEstimationModel = true;
Expand Down Expand Up @@ -375,7 +375,7 @@ class CladTimerGroup {
return false;
}
if (m_DO.EnableVariedAnalysis && m_DO.DisableActivityAnalysis) {
llvm::errs() << "clad: Error: -enable-va and -disable-aa cannot "
llvm::errs() << "clad: Error: -enable-va and -disable-va cannot "
"be used together.\n";
return false;
}
Expand Down

0 comments on commit 03255f3

Please sign in to comment.