diff --git a/lib/Differentiator/ActivityAnalyzer.cpp b/lib/Differentiator/ActivityAnalyzer.cpp index 24d295f3d..ac233700d 100644 --- a/lib/Differentiator/ActivityAnalyzer.cpp +++ b/lib/Differentiator/ActivityAnalyzer.cpp @@ -134,8 +134,6 @@ bool VariedAnalyzer::VisitCallExpr(CallExpr* CE) { bool VariedAnalyzer::VisitDeclStmt(DeclStmt* DS) { for (Decl* D : DS->decls()) { - if (!isa(D)) - continue; if (Expr* init = cast(D)->getInit()) { m_Varied = false; TraverseStmt(init); diff --git a/lib/Differentiator/DiffPlanner.cpp b/lib/Differentiator/DiffPlanner.cpp index 44a52ab93..c93b24749 100644 --- a/lib/Differentiator/DiffPlanner.cpp +++ b/lib/Differentiator/DiffPlanner.cpp @@ -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); @@ -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; @@ -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; } diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index 46b29c479..36c3ddddd 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -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) { diff --git a/test/Gradient/FunctionCalls.C b/test/Gradient/FunctionCalls.C index 41a8f63b7..e7df7695b 100644 --- a/test/Gradient/FunctionCalls.C +++ b/test/Gradient/FunctionCalls.C @@ -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) { @@ -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: } diff --git a/test/Misc/Args.C b/test/Misc/Args.C index 35b7c3e5f..d263d782f 100644 --- a/test/Misc/Args.C +++ b/test/Misc/Args.C @@ -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 \ No newline at end of file +// 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 \ No newline at end of file diff --git a/tools/ClangPlugin.h b/tools/ClangPlugin.h index f17f7e41b..89b62ce8f 100644 --- a/tools/ClangPlugin.h +++ b/tools/ClangPlugin.h @@ -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; @@ -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; }