passlab / rexompiler

REX OpenMP Compiler
https://passlab.github.io/rexompiler/
Other
1 stars 1 forks source link

Clean up code: pros and cons #128

Closed ouankou closed 1 year ago

ouankou commented 1 year ago

In the ROSE source code, sometimes there are dead code blocks, e.g. #if 0 ..., or a large function that was commented out. The coding style is also not consistent, e.g. indentation, curly brackets, etc.

For the files we work on frequently, such as omp_lowering.cpp, we could clean up the code by reformatting the code, removing dead code blocks, etc. Then the code will be much easier to read. The drawback is that the formatted code will be significantly different from the original ROSE code, and it's more difficult to compare them when we synchronize with the ROSE upstream in the future.

ouankou commented 1 year ago

We decided not to synchronize with the ROSE upstream but only check-pick necessary commits. Therefore, for the modules we work on a lot, such as Omp AST constructor and Omp Lowering, we can remove the dead code and format the code properly.

ouankou commented 1 year ago

Reformatting is done by commit https://github.com/passlab/rexompiler/commit/6aa25db9170af222e060c36184b2c7afd0a2176e. clang-format, a tool in LLVM, is used. It could work independently or along with git.

Most dead code blocks in the lowering module are removed, except for some code that I'm not quite sure about yet. The order of including headers can't be changed. Otherwise, the compilation will fail. For the rest code in the lowering and AST constructor, I'll do cleanups while refactoring the code (e.g. remove unnecessary usage of global variables). It's not a top priority.