diff --git a/sapfor/experts/Sapfor_2017/_src/CFGraph/live_variable_analysis.h b/sapfor/experts/Sapfor_2017/_src/CFGraph/live_variable_analysis.h index b41680c..a697273 100644 --- a/sapfor/experts/Sapfor_2017/_src/CFGraph/live_variable_analysis.h +++ b/sapfor/experts/Sapfor_2017/_src/CFGraph/live_variable_analysis.h @@ -1,3 +1,5 @@ +#pragma once + #include "../Utils/SgUtils.h" #include "CFGraph.h" diff --git a/sapfor/experts/Sapfor_2017/_src/CFGraph/private_variables_analysis.h b/sapfor/experts/Sapfor_2017/_src/CFGraph/private_variables_analysis.h index 649b5cf..3653787 100644 --- a/sapfor/experts/Sapfor_2017/_src/CFGraph/private_variables_analysis.h +++ b/sapfor/experts/Sapfor_2017/_src/CFGraph/private_variables_analysis.h @@ -1,3 +1,5 @@ +#pragma once + #include "../Utils/SgUtils.h" #include "../GraphLoop/graph_loops.h" #include "CFGraph.h" diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp index f64f5e8..4a006d0 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp @@ -79,6 +79,7 @@ #include "Transformations/private_removing.h" #include "Transformations/fix_common_blocks.h" #include "Transformations/convert_to_c.h" +#include "Transformations/dead_code.h" #include "RenameSymbols/rename_symbols.h" #include "ProjectParameters/projectParameters.h" @@ -1169,6 +1170,12 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne covertToC(file); else if (curr_regime == INSERT_NO_DISTR_FLAGS_FROM_GUI) addPrivatesToArraysFromGUI(file, declaredArrays, distrStateFromGUI); + else if (curr_regime == REMOVE_DEAD_CODE_AND_UNPARSE) + { + auto funcsForFile = getObjectForFileFromMap(file_name, allFuncInfo_IR); + for (auto& func : funcsForFile) + removeDeadCode(func->funcPointer, allFuncInfo_IR, commonBlocks); + } else if (curr_regime == TEST_PASS) { //test pass @@ -2515,6 +2522,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam findFunctionsToInclude(true); break; // all these cases run UNPARSE_FILE after + case REMOVE_DEAD_CODE_AND_UNPARSE: case RENAME_SYMBOLS: case RESOLVE_PAR_REGIONS: case CREATE_PARALLEL_REGIONS: diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.h b/sapfor/experts/Sapfor_2017/_src/Sapfor.h index 670cd9c..a66f577 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.h +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.h @@ -165,6 +165,7 @@ enum passes { BUILD_IR, LIVE_ANALYSIS_IR, PRIVATE_ANALYSIS_IR, + REMOVE_DEAD_CODE_AND_UNPARSE, FIX_COMMON_BLOCKS, REMOVE_OMP_DIRS, @@ -343,6 +344,7 @@ static void setPassValues() passNames[CALL_GRAPH_IR] = "CALL_GRAPH_IR"; passNames[LIVE_ANALYSIS_IR] = "LIVE_ANALYSIS_IR"; passNames[PRIVATE_ANALYSIS_IR] = "PRIVATE_ANALYSIS_IR"; + passNames[REMOVE_DEAD_CODE_AND_UNPARSE] = "REMOVE_DEAD_CODE_AND_UNPARSE"; passNames[FIX_COMMON_BLOCKS] = "FIX_COMMON_BLOCKS"; passNames[REMOVE_OMP_DIRS] = "REMOVE_OMP_DIRS"; diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.cpp b/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.cpp index c5050d8..5fe5dad 100644 Binary files a/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.cpp and b/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.cpp differ diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.h b/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.h index e7f4f09..d513316 100644 Binary files a/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.h and b/sapfor/experts/Sapfor_2017/_src/Transformations/dead_code.h differ diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h index 3e68a6a..88ed1ba 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h @@ -306,6 +306,8 @@ void InitPassesDependencies(map> &passDepsIn, set Pass(REMOVE_OMP_DIRS) <= Pass(REMOVE_OMP_DIRS_TRANSFORM); + Pass(BUILD_IR) <= Pass(REMOVE_DEAD_CODE_AND_UNPARSE); + passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS, EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW, REVERSE_CREATED_NESTED_LOOPS, PREDICT_SCHEME, CALCULATE_STATS_SCHEME, REVERT_SPF_DIRS, CLEAR_SPF_DIRS, TRANSFORM_SHADOW_IF_FULL,