From 6873bb1b325d230de83265daca94f5e1f969304b Mon Sep 17 00:00:00 2001 From: Izaak Beekman Date: Fri, 13 Dec 2024 10:23:45 -0500 Subject: [PATCH] Emit capitalized F file extensions for instrumented code --- CMakeLists.txt | 16 +++++++++++++--- src/fparse-llvm.in | 4 ++-- src/salt_instrument_flang_plugin.cpp | 10 ++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf3e8aa..e3e077b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -640,34 +640,44 @@ foreach(compiler IN LISTS fortran_compilers_to_test) STRING(TOUPPER ${compiler} upper_comp) add_test(NAME setup_${compiler}_dir COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${upper_comp}) + set_tests_properties(setup_${compiler}_dir + PROPERTIES + FIXTURES_SETUP ${upper_comp}_dir + ) endforeach() foreach(test_source IN LISTS FORTRAN_TESTS_SOURCES_LIST) # Get the name of the instrumented source file get_filename_component(TEST_BASE_NAME ${test_source} NAME_WLE) get_filename_component(TEST_LANG ${test_source} LAST_EXT) + # fparse-llvm is adding preprocessor directives and should emit uppercase file extensions (e.g., .F90) + string(TOUPPER ${TEST_LANG} TEST_LANG) set(TEST_INST_SOURCE ${TEST_BASE_NAME}.inst${TEST_LANG}) foreach(compiler IN LISTS fortran_compilers_to_test) STRING(TOUPPER ${compiler} upper_comp) if(${compiler} STREQUAL "gfortran") set(mapped_comp GCC) + set(EXTRA_FLAGS -Wpedantic -Wextra -Wno-missing-include-dirs -Werror) elseif(${compiler} STREQUAL "flang-new") set(mapped_comp CLANG) + set(EXTRA_FLAGS -Werror) elseif(${compiler} STREQUAL "flang") set(mapped_comp CLANG) + set(EXTRA_FLAGS -Werror) else() message(FATAL_ERROR "Unknown compiler: ${compiler}") endif() add_test(NAME compile_${upper_comp}_${test_source} - COMMAND ${TAUF90} ${TAU_F90_OPTS} -o ${TEST_BASE_NAME} ${CMAKE_BINARY_DIR}/${TEST_INST_SOURCE} + COMMAND ${TAUF90} ${TAU_F90_OPTS} -o ${TEST_BASE_NAME} -Wall ${EXTRA_FLAGS} ${CMAKE_BINARY_DIR}/${TEST_INST_SOURCE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${upper_comp} ) set_tests_properties(compile_${upper_comp}_${test_source} PROPERTIES ENVIRONMENT "TAU_MAKEFILE=${TAU_${mapped_comp}_MAKEFILE}" - DEPENDS "instrument_${test_source};setup_${compiler}_dir" - FAIL_REGULAR_EXPRESSION "[Ee]rror" + DEPENDS "instrument_${test_source}" + FIXTURES_REQUIRED ${upper_comp}_dir + FAIL_REGULAR_EXPRESSION "[^W][Ee]rror" ) # Profile with TAU and Verify profiles are created add_test(NAME run_${upper_comp}_${test_source} diff --git a/src/fparse-llvm.in b/src/fparse-llvm.in index a92fa9a..bbecda5 100755 --- a/src/fparse-llvm.in +++ b/src/fparse-llvm.in @@ -93,10 +93,10 @@ if [[ -z "${output_file:-}" ]]; then file_ext="" fi if [[ "${input_file}" == */* ]]; then - output_file="${input_file%.*}.inst${file_ext}" + output_file="${input_file%.*}.inst${file_ext//f/F}" output_file="$(pwd)/${output_file##*/}" else - output_file="$(pwd)/${input_file%.*}.inst${file_ext}" + output_file="$(pwd)/${input_file%.*}.inst${file_ext//f/F}" fi fi diff --git a/src/salt_instrument_flang_plugin.cpp b/src/salt_instrument_flang_plugin.cpp index 6d35aad..9daf83e 100644 --- a/src/salt_instrument_flang_plugin.cpp +++ b/src/salt_instrument_flang_plugin.cpp @@ -632,12 +632,18 @@ class SaltInstrumentAction final : public PluginParseTreeAction { const InstrumentationMap instMap = getInstrumentationMap(yamlTree); // Get the extension of the input file - // For input file 'filename.ext' we will output to 'filename.inst.ext' + // For input file 'filename.ext' we will output to 'filename.inst.Ext' + // Since we are adding preprocessor directives in the emitted code, + // the file extension should be capitalized. std::string inputFileExtension; if (auto const extPos = inputFilePath->find_last_of('.'); extPos == std::string::npos) { - inputFileExtension = "f90"; // Default if for some reason file has no extension + inputFileExtension = "F90"; // Default if for some reason file has no extension } else { inputFileExtension = inputFilePath->substr(extPos + 1); // Part of string past last '.' + // Capitalize the first character of inputFileExtension + if (!inputFileExtension.empty()) { + inputFileExtension[0] = std::toupper(inputFileExtension[0]); + } } // Open an output file for writing the instrumented code