Skip to content

Commit

Permalink
Control the function calls CSE with flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mscuttari committed Dec 6, 2024
1 parent c9ed297 commit 6f8d717
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .jenkins/version_llvm.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b47e09d30e8b32017a7f32b04cc170fdcacb6a99
b041c3f3f22cdf0d6d3b8253d576f18a07f5bb74
1 change: 1 addition & 0 deletions include/public/marco/Frontend/CodegenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct CodegenOptions : public clang::CodeGenOptions {
int64_t sccSolvingBySubstitutionMaxIterations = 100;
int64_t sccSolvingBySubstitutionMaxEquationsInSCC = 5;
bool cse = false;
bool functionCallsCSE = false;
bool equationsRuntimeScheduling = false;
bool omp = false;
bool singleValuedInductionElimination = false;
Expand Down
6 changes: 6 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ static void parseCodegenArgs(marco::frontend::CodegenOptions &options,
options.variablesToParametersPromotion = true;
options.inlining = true;
options.cse = true;
options.functionCallsCSE = true;
options.loopFusion = true;
}

Expand All @@ -527,6 +528,7 @@ static void parseCodegenArgs(marco::frontend::CodegenOptions &options,
if (options.optLevel.getSizeLevel() > 0) {
options.debug = false;
options.cse = true;
options.functionCallsCSE = true;
options.singleValuedInductionElimination = true;
options.variablesPruning = true;
options.loopFusion = true;
Expand Down Expand Up @@ -583,6 +585,10 @@ static void parseCodegenArgs(marco::frontend::CodegenOptions &options,
options.cse =
args.hasFlag(options::OPT_cse, options::OPT_no_cse, options.cse);

options.functionCallsCSE = args.hasFlag(options::OPT_function_calls_cse,
options::OPT_no_function_calls_cse,
options.functionCallsCSE);

options.equationsRuntimeScheduling =
args.hasFlag(options::OPT_equations_runtime_scheduling,
options::OPT_no_equations_runtime_scheduling,
Expand Down
4 changes: 3 additions & 1 deletion lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,9 @@ void CodeGenAction::buildMLIRLoweringPipeline(mlir::PassManager &pm) {
pm.addPass(mlir::bmodelica::createEquationTemplatesCreationPass());

// Eliminate repeated function calls
pm.addPass(mlir::bmodelica::createCallCSEPass());
if (ci.getCodeGenOptions().functionCallsCSE) {
pm.addPass(mlir::bmodelica::createCallCSEPass());
}

// Materialize the derivatives.
pm.addPass(mlir::bmodelica::createDerivativesMaterializationPass());
Expand Down

0 comments on commit 6f8d717

Please sign in to comment.