[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/93519 As discussed in #89743, when using the Visual Studio solution generators, object library projects are displayed as a collection of non-editable *.obj files. To look for the corresponding source files, one has to browse (or search) to the library's obj.libname project. This patch tries to avoid this as much as possible. For Clang, there is already an exception for XCode. We handle MSVC_IDE the same way. For MLIR, this is more complicated. There are explicit references to the obj.libname target that only work when there is an object library. This patch cleans up the reasons for why an object library is needed: 1. The obj.libname is modified in the calling CMakeLists.txt. Note that with use-only references, `add_library( ALIAS )` could have been used. 2. An libMLIR.so (mlir-shlib) is also created. This works by adding linking the object libraries' object file into libMLIR.so (in addition to the library's own .so/.a). XCode is handled using the `-force_load` linker option instead. Windows is not even supported. This mechanism is different from LLVM's llvm-shlib that is created by linking static libraries with `-Wl,--whole-archive` (and `-Wl,-all_load` on MacOS). 3. The library might be added to an aggregate library. In-tree, the seems to be only libMLIR-C.so and the standalone example. It uses the object library and `-force_load` mechanism as above. Again, this is different from libLLVM-C.so. 4. Build an object library whenever it was before this patch, except when generating a Visual Studio solution. This condition could be removed, but I am trying to avoid build breakages of whatever configurations others use. This seem to not have worked with XCode because of the explicit references to obj.libname. I don't have access to XCode, but I tried to preserve the current working. IMHO there should be a common mechanism to build aggregate libraries for all LLVM projects instead of the 4 that we have now. As far as I can see, this means for LLVM there are the following changes on whether object libraries are created: 1. An object library is created even in XCode if FORCE_OBJECT_LIBRARY is set. I do not know how XCode handles it, but I also know CMake will abort otherwise. 2. An object library is created even for explicitly SHARED libraries for building libMLIR.so. Again, mlir-shlib does not work otherwise. libMLIR.so itself is created using SHARED so this is marking it as EXCLUDE_FROM_LIBMLIR. 3. For the second condition, it is now sensitive to whether the mlir-shlib is built at all (LLVM_BUILD_LLVM_DYLIB). However, an object library is still built using the fourth condition unless using the MSVC solution generator. That is, except with MSVC_IDE, when an object library was built before, it will also be an object library now. >From a08815e3b5e204c4f7eccbfbfcdb04d00ab7f895 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 28 May 2024 09:50:21 +0200 Subject: [PATCH] Avoid object libraries in the VS IDE --- clang/cmake/modules/AddClang.cmake | 6 ++- clang/lib/Support/CMakeLists.txt | 2 +- flang/cmake/modules/AddFlang.cmake | 21 +++--- mlir/cmake/modules/AddMLIR.cmake | 62 +++- mlir/lib/Dialect/GPU/CMakeLists.txt | 2 + mlir/lib/Target/LLVM/CMakeLists.txt | 4 ++ mlir/tools/mlir-shlib/CMakeLists.txt | 1 + 7 files changed, 70 insertions(+), 28 deletions(-) diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index a5ef639187d9d..9d09be1936847 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -96,8 +96,12 @@ macro(add_clang_library name) else() set(LIBTYPE STATIC) endif() -if(NOT XCODE) +if(NOT XCODE AND NOT MSVC_IDE) # The Xcode generator doesn't handle object libraries correctly. + # The Visual Studio CMake generator does handle object libraries + # correctly, but it is preferable to list the libraries with their + # source files (instead of the object files and the source files in + # a separate target in the "Object Libraries" folder) list(APPEND LIBTYPE OBJECT) endif() set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name}) diff --git a/clang/lib/Support/CMakeLists.txt b/clang/lib/Support/CMakeLists.txt index 8ea5620052ed8..de06271e914ae 100644 --- a/clang/lib/Support/CMakeLists.txt +++ b/clang/lib/Support/CMakeLists.txt @@ -15,7 +15,7 @@ set(clangSupport_sources add_clang_library(clangSupport ${clangSupport_sources}) -if (NOT XCODE) +if (TARGET obj.clangSupport) add_library(clangSupport_tablegen ALIAS obj.clangSupport) elseif (NOT LLVM_LINK_LLVM_DYLIB) add_library(clangSupport_tablegen ALIAS clangSupport) diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake index 3a5119b83831f..aeb4d862cf780 100644 ---
[clang-tools-extra] 5fb3830 - [clang-tools-extra] Remove redundant FOLDER property. NFC.
Author: Michael Kruse Date: 2024-05-27T17:42:32+02:00 New Revision: 5fb38307f372555cd22fd09ace86c3b1ccd2abb9 URL: https://github.com/llvm/llvm-project/commit/5fb38307f372555cd22fd09ace86c3b1ccd2abb9 DIFF: https://github.com/llvm/llvm-project/commit/5fb38307f372555cd22fd09ace86c3b1ccd2abb9.diff LOG: [clang-tools-extra] Remove redundant FOLDER property. NFC. This should have been removed from #89744 to address a review comment. Added: Modified: clang-tools-extra/clang-tidy/misc/CMakeLists.txt Removed: diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt index 0583671910526..35e29b9a7d136 100644 --- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -52,7 +52,6 @@ add_clang_library(clangTidyMiscModule genconfusable ClangDriverOptions ) -set_target_properties(clangTidyMiscModule PROPERTIES FOLDER "Clang Tools Extra/Libraries") clang_target_link_libraries(clangTidyMiscModule PRIVATE ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)
Meinersbur wrote: > This is basically names passed as FOLDER property are very generic. They are a little more specific than before (especially when considering Compiler-RT which put everything into "Compiler-RT/Misc"). Being more contextual would also require more maintenance, e.g. adding the right folder name for new artifacts. Only users of CMake's XCode or Visual Studio generators even see then, other would not even know something is off when this is not done. Hence the goal was to reduce maintenance, i.e. `add_clang_library` selects the folder name itself. It only has the type of the target available (here: library), so that's what it is restricted to. > Then this change is +- fine. Thank you https://github.com/llvm/llvm-project/pull/89744 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/89744 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)
Meinersbur wrote: > For me this entire change doesn't make sense. Could you elaborate on why? https://github.com/llvm/llvm-project/pull/89744 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/89744 >From 6f39beb9ee58d7c377dce6ba8ce69e71da5b8e09 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 23 Apr 2024 12:55:15 +0200 Subject: [PATCH 1/6] [llvm] Revise IDE folder structure --- llvm/CMakeLists.txt | 12 ++- llvm/cmake/modules/AddLLVM.cmake | 83 ++- llvm/cmake/modules/AddOCaml.cmake | 5 +- llvm/cmake/modules/AddSphinxTarget.cmake | 3 + llvm/cmake/modules/CrossCompile.cmake | 4 + .../modules/LLVMDistributionSupport.cmake | 8 ++ .../modules/LLVMExternalProjectUtils.cmake| 25 +- llvm/cmake/modules/TableGen.cmake | 7 +- llvm/docs/CMakeLists.txt | 1 + llvm/examples/Kaleidoscope/CMakeLists.txt | 2 +- llvm/include/llvm/Support/CMakeLists.txt | 2 +- llvm/lib/Support/BLAKE3/CMakeLists.txt| 1 + llvm/runtimes/CMakeLists.txt | 23 + llvm/test/CMakeLists.txt | 6 +- llvm/tools/opt-viewer/CMakeLists.txt | 1 + .../InlineAdvisorPlugin/CMakeLists.txt| 3 +- .../Analysis/InlineOrderPlugin/CMakeLists.txt | 2 +- llvm/unittests/CMakeLists.txt | 2 +- llvm/unittests/DebugInfo/BTF/CMakeLists.txt | 2 - .../DebugInfo/CodeView/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/DWARF/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/GSYM/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/MSF/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/PDB/CMakeLists.txt | 2 - llvm/unittests/ExecutionEngine/CMakeLists.txt | 2 - .../ExecutionEngine/JITLink/CMakeLists.txt| 2 - .../ExecutionEngine/MCJIT/CMakeLists.txt | 2 - .../ExecutionEngine/Orc/CMakeLists.txt| 2 - .../Support/CommandLineInit/CMakeLists.txt| 4 - .../Support/DynamicLibrary/CMakeLists.txt | 4 +- llvm/unittests/Target/AArch64/CMakeLists.txt | 2 - llvm/unittests/Target/AMDGPU/CMakeLists.txt | 2 - llvm/unittests/Target/ARM/CMakeLists.txt | 2 - llvm/unittests/Target/CMakeLists.txt | 3 - .../unittests/Target/LoongArch/CMakeLists.txt | 2 - llvm/unittests/Target/PowerPC/CMakeLists.txt | 2 - llvm/unittests/Target/RISCV/CMakeLists.txt| 2 - .../Target/WebAssembly/CMakeLists.txt | 2 - llvm/unittests/Target/X86/CMakeLists.txt | 2 - .../Transforms/Coroutines/CMakeLists.txt | 2 - llvm/unittests/Transforms/IPO/CMakeLists.txt | 2 - .../Transforms/Scalar/CMakeLists.txt | 2 - .../unittests/Transforms/Utils/CMakeLists.txt | 2 - .../Transforms/Vectorize/CMakeLists.txt | 2 - .../tools/llvm-cfi-verify/CMakeLists.txt | 2 - .../tools/llvm-exegesis/CMakeLists.txt| 2 - llvm/unittests/tools/llvm-mca/CMakeLists.txt | 2 - .../tools/llvm-profdata/CMakeLists.txt| 2 - .../tools/llvm-profgen/CMakeLists.txt | 2 - llvm/utils/LLVMVisualizers/CMakeLists.txt | 2 +- llvm/utils/TableGen/Basic/CMakeLists.txt | 1 - llvm/utils/TableGen/CMakeLists.txt| 2 - llvm/utils/TableGen/Common/CMakeLists.txt | 1 - llvm/utils/lit/CMakeLists.txt | 4 +- llvm/utils/llvm-locstats/CMakeLists.txt | 2 +- llvm/utils/mlgo-utils/CMakeLists.txt | 2 +- 56 files changed, 159 insertions(+), 112 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 43181af3bc195..48a6ab7d21f48 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1124,7 +1124,7 @@ configure_file( add_custom_target(srpm COMMAND cpack -G TGZ --config CPackSourceConfig.cmake -B ${LLVM_SRPM_DIR}/SOURCES COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' ${LLVM_SRPM_BINARY_SPECFILE}) -set_target_properties(srpm PROPERTIES FOLDER "Misc") +set_target_properties(srpm PROPERTIES FOLDER "LLVM/Misc") if(APPLE AND DARWIN_LTO_LIBRARY) set(CMAKE_EXE_LINKER_FLAGS @@ -1222,7 +1222,9 @@ if( LLVM_INCLUDE_UTILS ) add_subdirectory(utils/split-file) add_subdirectory(utils/mlgo-utils) if( LLVM_INCLUDE_TESTS ) +set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test") add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest) +set(LLVM_SUBPROJECT_TITLE) endif() else() if ( LLVM_INCLUDE_TESTS ) @@ -1286,7 +1288,7 @@ if( LLVM_INCLUDE_TESTS ) if(LLVM_ALL_LIT_DEPENDS OR LLVM_ALL_ADDITIONAL_TEST_DEPENDS) add_dependencies(test-depends ${LLVM_ALL_LIT_DEPENDS} ${LLVM_ALL_ADDITIONAL_TEST_DEPENDS}) endif() - set_target_properties(test-depends PROPERTIES FOLDER "Tests") + set_target_properties(test-depends PROPERTIES FOLDER "LLVM/Tests") add_dependencies(check-all test-depends) endif() @@ -1343,7 +1345,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) # Installing the headers needs to depend on generating any public # tablegen'd headers. add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen) -
[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)
@@ -51,6 +52,7 @@ add_clang_library(clangTidyMiscModule genconfusable ClangDriverOptions ) +set_target_properties(clangTidyMiscModule PROPERTIES FOLDER "Clang Tools Extra/Libraries") Meinersbur wrote: This `set_target_properties` is redundant here, the same folder is already set by `add_clang_library` in #89741. This must be a leftover from cleaning up when I changed `add_clang_library` to set the folder instead of each of them individually. Thanks for noticing. https://github.com/llvm/llvm-project/pull/89744 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/89153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/89755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/89755 >From 6f39beb9ee58d7c377dce6ba8ce69e71da5b8e09 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 23 Apr 2024 12:55:15 +0200 Subject: [PATCH 1/6] [llvm] Revise IDE folder structure --- llvm/CMakeLists.txt | 12 ++- llvm/cmake/modules/AddLLVM.cmake | 83 ++- llvm/cmake/modules/AddOCaml.cmake | 5 +- llvm/cmake/modules/AddSphinxTarget.cmake | 3 + llvm/cmake/modules/CrossCompile.cmake | 4 + .../modules/LLVMDistributionSupport.cmake | 8 ++ .../modules/LLVMExternalProjectUtils.cmake| 25 +- llvm/cmake/modules/TableGen.cmake | 7 +- llvm/docs/CMakeLists.txt | 1 + llvm/examples/Kaleidoscope/CMakeLists.txt | 2 +- llvm/include/llvm/Support/CMakeLists.txt | 2 +- llvm/lib/Support/BLAKE3/CMakeLists.txt| 1 + llvm/runtimes/CMakeLists.txt | 23 + llvm/test/CMakeLists.txt | 6 +- llvm/tools/opt-viewer/CMakeLists.txt | 1 + .../InlineAdvisorPlugin/CMakeLists.txt| 3 +- .../Analysis/InlineOrderPlugin/CMakeLists.txt | 2 +- llvm/unittests/CMakeLists.txt | 2 +- llvm/unittests/DebugInfo/BTF/CMakeLists.txt | 2 - .../DebugInfo/CodeView/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/DWARF/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/GSYM/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/MSF/CMakeLists.txt | 2 - llvm/unittests/DebugInfo/PDB/CMakeLists.txt | 2 - llvm/unittests/ExecutionEngine/CMakeLists.txt | 2 - .../ExecutionEngine/JITLink/CMakeLists.txt| 2 - .../ExecutionEngine/MCJIT/CMakeLists.txt | 2 - .../ExecutionEngine/Orc/CMakeLists.txt| 2 - .../Support/CommandLineInit/CMakeLists.txt| 4 - .../Support/DynamicLibrary/CMakeLists.txt | 4 +- llvm/unittests/Target/AArch64/CMakeLists.txt | 2 - llvm/unittests/Target/AMDGPU/CMakeLists.txt | 2 - llvm/unittests/Target/ARM/CMakeLists.txt | 2 - llvm/unittests/Target/CMakeLists.txt | 3 - .../unittests/Target/LoongArch/CMakeLists.txt | 2 - llvm/unittests/Target/PowerPC/CMakeLists.txt | 2 - llvm/unittests/Target/RISCV/CMakeLists.txt| 2 - .../Target/WebAssembly/CMakeLists.txt | 2 - llvm/unittests/Target/X86/CMakeLists.txt | 2 - .../Transforms/Coroutines/CMakeLists.txt | 2 - llvm/unittests/Transforms/IPO/CMakeLists.txt | 2 - .../Transforms/Scalar/CMakeLists.txt | 2 - .../unittests/Transforms/Utils/CMakeLists.txt | 2 - .../Transforms/Vectorize/CMakeLists.txt | 2 - .../tools/llvm-cfi-verify/CMakeLists.txt | 2 - .../tools/llvm-exegesis/CMakeLists.txt| 2 - llvm/unittests/tools/llvm-mca/CMakeLists.txt | 2 - .../tools/llvm-profdata/CMakeLists.txt| 2 - .../tools/llvm-profgen/CMakeLists.txt | 2 - llvm/utils/LLVMVisualizers/CMakeLists.txt | 2 +- llvm/utils/TableGen/Basic/CMakeLists.txt | 1 - llvm/utils/TableGen/CMakeLists.txt| 2 - llvm/utils/TableGen/Common/CMakeLists.txt | 1 - llvm/utils/lit/CMakeLists.txt | 4 +- llvm/utils/llvm-locstats/CMakeLists.txt | 2 +- llvm/utils/mlgo-utils/CMakeLists.txt | 2 +- 56 files changed, 159 insertions(+), 112 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 43181af3bc195..48a6ab7d21f48 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1124,7 +1124,7 @@ configure_file( add_custom_target(srpm COMMAND cpack -G TGZ --config CPackSourceConfig.cmake -B ${LLVM_SRPM_DIR}/SOURCES COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' ${LLVM_SRPM_BINARY_SPECFILE}) -set_target_properties(srpm PROPERTIES FOLDER "Misc") +set_target_properties(srpm PROPERTIES FOLDER "LLVM/Misc") if(APPLE AND DARWIN_LTO_LIBRARY) set(CMAKE_EXE_LINKER_FLAGS @@ -1222,7 +1222,9 @@ if( LLVM_INCLUDE_UTILS ) add_subdirectory(utils/split-file) add_subdirectory(utils/mlgo-utils) if( LLVM_INCLUDE_TESTS ) +set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test") add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest) +set(LLVM_SUBPROJECT_TITLE) endif() else() if ( LLVM_INCLUDE_TESTS ) @@ -1286,7 +1288,7 @@ if( LLVM_INCLUDE_TESTS ) if(LLVM_ALL_LIT_DEPENDS OR LLVM_ALL_ADDITIONAL_TEST_DEPENDS) add_dependencies(test-depends ${LLVM_ALL_LIT_DEPENDS} ${LLVM_ALL_ADDITIONAL_TEST_DEPENDS}) endif() - set_target_properties(test-depends PROPERTIES FOLDER "Tests") + set_target_properties(test-depends PROPERTIES FOLDER "LLVM/Tests") add_dependencies(check-all test-depends) endif() @@ -1343,7 +1345,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) # Installing the headers needs to depend on generating any public # tablegen'd headers. add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen) -
[libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/89755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [llvm] [libclc] Revise IDE folder structure (PR #89746)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/89746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Revise IDE folder structure (PR #89743)
Meinersbur wrote: Sorry for the notification noise. For some reason, when committing the parent PR, it closed this one. https://github.com/llvm/llvm-project/pull/89743 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Revise IDE folder structure (PR #89743)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/89743 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/89744 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Revise IDE folder structure (PR #89743)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/89743 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/92916 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
@@ -156,9 +156,9 @@ extern "C" void body(...) {} // IR-EMPTY: // IR-NEXT: [[FOR_INC]]: // IR-NEXT:%[[TMP34:.+]] = load i32, ptr %[[DOTTILE_0_IV_I]], align 4 -// IR-NEXT:%[[INC:.+]] = add nsw i32 %[[TMP34]], 1 +// IR-NEXT:%[[INC:.+]] = add i32 %[[TMP34]], 1 Meinersbur wrote: `nuw` would be an idea for a Clang extension in the footsteps of [vector extensions](https://releases.llvm.org/18.1.1/tools/clang/docs/LanguageExtensions.html#vectors-and-extended-vectors) or [`_ExtInt`](http://blog.llvm.org/2020/04/the-new-clang-extint-feature-provides.html) which also exposed a feature that LLVM always supported. E.g. ``` typedef unsigned nowrap_unsigned_t __attribute__((ext_no_wrap)); for (nowrap_unsigned_t i = 0; i < n; ++i) ``` or ``` int [[clang::]] ``` However, the language consequences are immense. https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
@@ -156,9 +156,9 @@ extern "C" void body(...) {} // IR-EMPTY: // IR-NEXT: [[FOR_INC]]: // IR-NEXT:%[[TMP34:.+]] = load i32, ptr %[[DOTTILE_0_IV_I]], align 4 -// IR-NEXT:%[[INC:.+]] = add nsw i32 %[[TMP34]], 1 +// IR-NEXT:%[[INC:.+]] = add i32 %[[TMP34]], 1 Meinersbur wrote: This is due to the change of using the type of `LoopHelper.NumIterations` (an unsigned integer) as the new loop's induction variable (instead of the original loop's iteration variable type). In iterator-based loops that type would be incompatible with `LoopHelper.NumIterations` which remains an integer. Even if the original loop variable is a signed integer (it could be a (`std::iota_view`)[https://en.cppreference.com/w/cpp/ranges/iota_view] over the same range), using and unsigned type is more correct as long as we start counting at 0. For instance, the loop ``` #pragma omp tile sizes(2) for (int i = INT_MIN; i < INT_MAX; ++i) ``` would overflow the `nsw` flag. The "most correct" fix would be to add the `nuw` flag. Unfortunately there is no AST expression we could create that would make CodeGen generate one. Alternatively, I could make generated loops start counting at `INT_MIN`. https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
@@ -182,17 +182,34 @@ class OMPLoopScope : public CodeGenFunction::RunCleanupsScope { } return false; }); - PreInits = cast_or_null(LD->getPreInits()); + PreInits = LD->getPreInits(); } else if (const auto *Tile = dyn_cast()) { - PreInits = cast_or_null(Tile->getPreInits()); + PreInits = Tile->getPreInits(); } else if (const auto *Unroll = dyn_cast()) { - PreInits = cast_or_null(Unroll->getPreInits()); + PreInits = Unroll->getPreInits(); } else { llvm_unreachable("Unknown loop-based directive kind."); } if (PreInits) { - for (const auto *I : PreInits->decls()) -CGF.EmitVarDecl(cast(*I)); + // CompoundStmts and DeclStmts are used as lists of PreInit statements and + // declarations. Since declarations must be visible in the the following + // that they initialize, unpack the ComboundStmt they are nested in. + SmallVector PreInitStmts; + if (auto *PreInitCompound = dyn_cast(PreInits)) +llvm::append_range(PreInitStmts, PreInitCompound->body()); + else +PreInitStmts.push_back(PreInits); + + for (const Stmt *S : PreInitStmts) { +// EmitStmt skips any OMPCapturedExprDecls, but needs to be emitted +// here. +if (auto *PreInitDecl = dyn_cast(S)) { Meinersbur wrote: Everything else is emitted in `CGF.EmitStmt(S);` at line 211. `CGF.EmitStmt(S)` does itself call `CGF.EmitVarDecl(S)` if passed a DeclStmts, so this special handling should not be necessary. It includes, however, an exception for `OMPCapturedExprDecl` (subclass of `VarDecl`) that are NOT emitted so we need to do this explicitly here. Otherwise, lines 203-212 would be just a single `CGF.EmitStmt(S)`. https://github.com/llvm/llvm-project/blob/a15b685c2d868eaf408d05baa50baa3c9f5cc740/clang/lib/CodeGen/CGDecl.cpp#L129 https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
@@ -182,17 +182,34 @@ class OMPLoopScope : public CodeGenFunction::RunCleanupsScope { } return false; }); - PreInits = cast_or_null(LD->getPreInits()); + PreInits = LD->getPreInits(); } else if (const auto *Tile = dyn_cast()) { - PreInits = cast_or_null(Tile->getPreInits()); + PreInits = Tile->getPreInits(); } else if (const auto *Unroll = dyn_cast()) { - PreInits = cast_or_null(Unroll->getPreInits()); + PreInits = Unroll->getPreInits(); } else { llvm_unreachable("Unknown loop-based directive kind."); } if (PreInits) { - for (const auto *I : PreInits->decls()) -CGF.EmitVarDecl(cast(*I)); + // CompoundStmts and DeclStmts are used as lists of PreInit statements and + // declarations. Since declarations must be visible in the the following + // that they initialize, unpack the ComboundStmt they are nested in. + SmallVector PreInitStmts; + if (auto *PreInitCompound = dyn_cast(PreInits)) Meinersbur wrote: This is explained in the summary. In essence, the init-statement for a C++20 foreach-loop does not need to be a DeclStmt, but can be an arbitrary Stmt. https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [driver] Do not warn about unused plugin flags. (PR #88948)
Meinersbur wrote: @jakeegan Sorry, didn't see you comment over an extended weekend. https://github.com/llvm/llvm-project/pull/88948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/91345 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/91459 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/91345 >From 855a84814eb8d263427bce7837af61e67eb2db95 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 7 May 2024 14:47:45 +0200 Subject: [PATCH 1/6] Make unique instances --- clang/lib/Sema/SemaOpenMP.cpp | 75 +++ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index cf5447f223d45..fff4c7350f0f7 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15109,6 +15109,8 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, SourceLocation StartLoc, SourceLocation EndLoc) { ASTContext = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + auto SizesClauses = OMPExecutableDirective::getClausesOfKind(Clauses); if (SizesClauses.empty()) { @@ -15137,6 +15139,7 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, NumLoops, AStmt, nullptr, nullptr); SmallVector PreInits; + CaptureVars CopyTransformer(SemaRef); // Create iteration variables for the generated loops. SmallVector FloorIndVars; @@ -15200,19 +15203,30 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, Expr *NumIterations = LoopHelper.NumIterations; auto *OrigCntVar = cast(LoopHelper.Counters[0]); QualType CntTy = OrigCntVar->getType(); -Expr *DimTileSize = SizesClause->getSizesRefs()[I]; -Scope *CurScope = SemaRef.getCurScope(); -// Commonly used variables. -DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, - OrigCntVar->getExprLoc()); -DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, -OrigCntVar->getExprLoc()); +// Commonly used variables. One of the constraints of an AST is that every +// node object must appear at most once, hence we define lamdas that create +// a new AST node at every use. +auto MakeDimTileSize = [ = this->SemaRef, , I, +SizesClause]() -> Expr * { + Expr *DimTileSize = SizesClause->getSizesRefs()[I]; + return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize)); +}; +auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; +auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; // For init-statement: auto .tile.iv = .floor.iv -SemaRef.AddInitializerToDecl(TileIndVars[I], - SemaRef.DefaultLvalueConversion(FloorIV).get(), - /*DirectInit=*/false); +SemaRef.AddInitializerToDecl( +TileIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(), +/*DirectInit=*/false); Decl *CounterDecl = TileIndVars[I]; StmtResult InitStmt = new (Context) DeclStmt(DeclGroupRef::Create(Context, , 1), @@ -15220,10 +15234,11 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, if (!InitStmt.isUsable()) return StmtError(); -// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize, -// NumIterations) -ExprResult EndOfTile = SemaRef.BuildBinOp( -CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize); +// For cond-expression: +// .tile.iv < min(.floor.iv + DimTileSize, NumIterations) +ExprResult EndOfTile = +SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, + MakeFloorIVRef(), MakeDimTileSize()); if (!EndOfTile.isUsable()) return StmtError(); ExprResult IsPartialTile = @@ -15238,25 +15253,28 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, return StmtError(); ExprResult CondExpr = SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT, - TileIV, MinTileAndIterSpace.get()); + MakeTileIVRef(), MinTileAndIterSpace.get()); if (!CondExpr.isUsable()) return StmtError(); // For incr-statement: ++.tile.iv ExprResult IncrStmt = SemaRef.BuildUnaryOp( -CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV); +CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef()); if (!IncrStmt.isUsable()) return StmtError(); // Statements to set the original iteration variable's value from the // logical iteration
[clang] f059058 - [Clang][OpenMP] Fix unused lambda capture warning.
Author: Michael Kruse Date: 2024-05-13T14:55:34+02:00 New Revision: f0590581aa01944a3bb502a622a412617d1efcbb URL: https://github.com/llvm/llvm-project/commit/f0590581aa01944a3bb502a622a412617d1efcbb DIFF: https://github.com/llvm/llvm-project/commit/f0590581aa01944a3bb502a622a412617d1efcbb.diff LOG: [Clang][OpenMP] Fix unused lambda capture warning. Added: Modified: clang/lib/Sema/SemaOpenMP.cpp Removed: diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index fff4c7350f0f7..2475f962fd0df 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15207,8 +15207,7 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, // Commonly used variables. One of the constraints of an AST is that every // node object must appear at most once, hence we define lamdas that create // a new AST node at every use. -auto MakeDimTileSize = [ = this->SemaRef, , I, -SizesClause]() -> Expr * { +auto MakeDimTileSize = [, I, SizesClause]() -> Expr * { Expr *DimTileSize = SizesClause->getSizesRefs()[I]; return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize)); }; @@ -15298,8 +15297,7 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, QualType CntTy = OrigCntVar->getType(); // Commonly used variables. -auto MakeDimTileSize = [ = this->SemaRef, , I, -SizesClause]() -> Expr * { +auto MakeDimTileSize = [, I, SizesClause]() -> Expr * { Expr *DimTileSize = SizesClause->getSizesRefs()[I]; return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize)); }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/91325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/91345 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)
https://github.com/Meinersbur ready_for_review https://github.com/llvm/llvm-project/pull/91325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)
Meinersbur wrote: Test failure is from unrelated test `DataFlowSanitizer-x86_64 :: release_shadow_space.c` https://github.com/llvm/llvm-project/pull/91325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/91325 >From 855a84814eb8d263427bce7837af61e67eb2db95 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 7 May 2024 14:47:45 +0200 Subject: [PATCH] Make unique instances --- clang/lib/Sema/SemaOpenMP.cpp | 75 +++ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index cf5447f223d450..fff4c7350f0f75 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15109,6 +15109,8 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, SourceLocation StartLoc, SourceLocation EndLoc) { ASTContext = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + auto SizesClauses = OMPExecutableDirective::getClausesOfKind(Clauses); if (SizesClauses.empty()) { @@ -15137,6 +15139,7 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, NumLoops, AStmt, nullptr, nullptr); SmallVector PreInits; + CaptureVars CopyTransformer(SemaRef); // Create iteration variables for the generated loops. SmallVector FloorIndVars; @@ -15200,19 +15203,30 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, Expr *NumIterations = LoopHelper.NumIterations; auto *OrigCntVar = cast(LoopHelper.Counters[0]); QualType CntTy = OrigCntVar->getType(); -Expr *DimTileSize = SizesClause->getSizesRefs()[I]; -Scope *CurScope = SemaRef.getCurScope(); -// Commonly used variables. -DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, - OrigCntVar->getExprLoc()); -DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, -OrigCntVar->getExprLoc()); +// Commonly used variables. One of the constraints of an AST is that every +// node object must appear at most once, hence we define lamdas that create +// a new AST node at every use. +auto MakeDimTileSize = [ = this->SemaRef, , I, +SizesClause]() -> Expr * { + Expr *DimTileSize = SizesClause->getSizesRefs()[I]; + return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize)); +}; +auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; +auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; // For init-statement: auto .tile.iv = .floor.iv -SemaRef.AddInitializerToDecl(TileIndVars[I], - SemaRef.DefaultLvalueConversion(FloorIV).get(), - /*DirectInit=*/false); +SemaRef.AddInitializerToDecl( +TileIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(), +/*DirectInit=*/false); Decl *CounterDecl = TileIndVars[I]; StmtResult InitStmt = new (Context) DeclStmt(DeclGroupRef::Create(Context, , 1), @@ -15220,10 +15234,11 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, if (!InitStmt.isUsable()) return StmtError(); -// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize, -// NumIterations) -ExprResult EndOfTile = SemaRef.BuildBinOp( -CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize); +// For cond-expression: +// .tile.iv < min(.floor.iv + DimTileSize, NumIterations) +ExprResult EndOfTile = +SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, + MakeFloorIVRef(), MakeDimTileSize()); if (!EndOfTile.isUsable()) return StmtError(); ExprResult IsPartialTile = @@ -15238,25 +15253,28 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, return StmtError(); ExprResult CondExpr = SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT, - TileIV, MinTileAndIterSpace.get()); + MakeTileIVRef(), MinTileAndIterSpace.get()); if (!CondExpr.isUsable()) return StmtError(); // For incr-statement: ++.tile.iv ExprResult IncrStmt = SemaRef.BuildUnaryOp( -CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV); +CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef()); if (!IncrStmt.isUsable()) return StmtError(); // Statements to set the original iteration variable's value from the // logical iteration
[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/91325 >From 42b1e6d435acaf8283ce7a0246f076a367ca876c Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 7 May 2024 14:47:45 +0200 Subject: [PATCH 1/2] Make unique instances --- clang/lib/Sema/SemaOpenMP.cpp | 75 +++ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index cf5447f223d45..1cffe051e5377 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15109,6 +15109,8 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, SourceLocation StartLoc, SourceLocation EndLoc) { ASTContext = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + auto SizesClauses = OMPExecutableDirective::getClausesOfKind(Clauses); if (SizesClauses.empty()) { @@ -15137,6 +15139,7 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, NumLoops, AStmt, nullptr, nullptr); SmallVector PreInits; + CaptureVars CopyTransformer(SemaRef); // Create iteration variables for the generated loops. SmallVector FloorIndVars; @@ -15200,19 +15203,30 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, Expr *NumIterations = LoopHelper.NumIterations; auto *OrigCntVar = cast(LoopHelper.Counters[0]); QualType CntTy = OrigCntVar->getType(); -Expr *DimTileSize = SizesClause->getSizesRefs()[I]; -Scope *CurScope = SemaRef.getCurScope(); -// Commonly used variables. -DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, - OrigCntVar->getExprLoc()); -DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, -OrigCntVar->getExprLoc()); +// Commonly used variables. One of the constraints of an AST is that every +// node object must appear at most once, hence we define lamdas that create +// a new AST node at every use. +auto MakeDimTileSize = [ = this->SemaRef, , I, +SizesClause]() -> Expr * { + Expr *DimTileSize = SizesClause->getSizesRefs()[I]; + return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize)); +}; +auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; +auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; // For init-statement: auto .tile.iv = .floor.iv -SemaRef.AddInitializerToDecl(TileIndVars[I], - SemaRef.DefaultLvalueConversion(FloorIV).get(), - /*DirectInit=*/false); +SemaRef.AddInitializerToDecl( +TileIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(), +/*DirectInit=*/false); Decl *CounterDecl = TileIndVars[I]; StmtResult InitStmt = new (Context) DeclStmt(DeclGroupRef::Create(Context, , 1), @@ -15220,10 +15234,11 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, if (!InitStmt.isUsable()) return StmtError(); -// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize, -// NumIterations) -ExprResult EndOfTile = SemaRef.BuildBinOp( -CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize); +// For cond-expression: +// .tile.iv < min(.floor.iv + DimTileSize, NumIterations) +ExprResult EndOfTile = +SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, + MakeFloorIVRef(), MakeDimTileSize()); if (!EndOfTile.isUsable()) return StmtError(); ExprResult IsPartialTile = @@ -15238,25 +15253,28 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, return StmtError(); ExprResult CondExpr = SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT, - TileIV, MinTileAndIterSpace.get()); + MakeTileIVRef(), MinTileAndIterSpace.get()); if (!CondExpr.isUsable()) return StmtError(); // For incr-statement: ++.tile.iv ExprResult IncrStmt = SemaRef.BuildUnaryOp( -CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV); +CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef()); if (!IncrStmt.isUsable()) return StmtError(); // Statements to set the original iteration variable's value from the // logical iteration
[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/91325 >From 42b1e6d435acaf8283ce7a0246f076a367ca876c Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 7 May 2024 14:47:45 +0200 Subject: [PATCH] Make unique instances --- clang/lib/Sema/SemaOpenMP.cpp | 75 +++ 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index cf5447f223d45..1cffe051e5377 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15109,6 +15109,8 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, SourceLocation StartLoc, SourceLocation EndLoc) { ASTContext = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + auto SizesClauses = OMPExecutableDirective::getClausesOfKind(Clauses); if (SizesClauses.empty()) { @@ -15137,6 +15139,7 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, NumLoops, AStmt, nullptr, nullptr); SmallVector PreInits; + CaptureVars CopyTransformer(SemaRef); // Create iteration variables for the generated loops. SmallVector FloorIndVars; @@ -15200,19 +15203,30 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, Expr *NumIterations = LoopHelper.NumIterations; auto *OrigCntVar = cast(LoopHelper.Counters[0]); QualType CntTy = OrigCntVar->getType(); -Expr *DimTileSize = SizesClause->getSizesRefs()[I]; -Scope *CurScope = SemaRef.getCurScope(); -// Commonly used variables. -DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, - OrigCntVar->getExprLoc()); -DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, -OrigCntVar->getExprLoc()); +// Commonly used variables. One of the constraints of an AST is that every +// node object must appear at most once, hence we define lamdas that create +// a new AST node at every use. +auto MakeDimTileSize = [ = this->SemaRef, , I, +SizesClause]() -> Expr * { + Expr *DimTileSize = SizesClause->getSizesRefs()[I]; + return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize)); +}; +auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; +auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, + OrigCntVar->getExprLoc()); +}; // For init-statement: auto .tile.iv = .floor.iv -SemaRef.AddInitializerToDecl(TileIndVars[I], - SemaRef.DefaultLvalueConversion(FloorIV).get(), - /*DirectInit=*/false); +SemaRef.AddInitializerToDecl( +TileIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(), +/*DirectInit=*/false); Decl *CounterDecl = TileIndVars[I]; StmtResult InitStmt = new (Context) DeclStmt(DeclGroupRef::Create(Context, , 1), @@ -15220,10 +15234,11 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, if (!InitStmt.isUsable()) return StmtError(); -// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize, -// NumIterations) -ExprResult EndOfTile = SemaRef.BuildBinOp( -CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize); +// For cond-expression: +// .tile.iv < min(.floor.iv + DimTileSize, NumIterations) +ExprResult EndOfTile = +SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, + MakeFloorIVRef(), MakeDimTileSize()); if (!EndOfTile.isUsable()) return StmtError(); ExprResult IsPartialTile = @@ -15238,25 +15253,28 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, return StmtError(); ExprResult CondExpr = SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT, - TileIV, MinTileAndIterSpace.get()); + MakeTileIVRef(), MinTileAndIterSpace.get()); if (!CondExpr.isUsable()) return StmtError(); // For incr-statement: ++.tile.iv ExprResult IncrStmt = SemaRef.BuildUnaryOp( -CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV); +CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef()); if (!IncrStmt.isUsable()) return StmtError(); // Statements to set the original iteration variable's value from the // logical iteration
[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/91325 One of the constraints of an AST is that every node object must appear at most once, hence we define lamdas that create a new AST node at every use. >From 1c1910b6885cd5be18cb15e364569f2a2f662955 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 7 May 2024 14:47:45 +0200 Subject: [PATCH] Make unique instances --- clang/lib/Sema/SemaOpenMP.cpp | 77 ++-- clang/test/OpenMP/tile_codegen.cpp| 58 +-- .../OpenMP/tile_codegen_for_dependent.cpp | 326 +++-- clang/test/OpenMP/tile_codegen_tile_for.cpp | 435 +- 4 files changed, 447 insertions(+), 449 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index cf5447f223d45..ba86bd4e62786 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15109,6 +15109,8 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, SourceLocation StartLoc, SourceLocation EndLoc) { ASTContext = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + auto SizesClauses = OMPExecutableDirective::getClausesOfKind(Clauses); if (SizesClauses.empty()) { @@ -15137,6 +15139,7 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, NumLoops, AStmt, nullptr, nullptr); SmallVector PreInits; + CaptureVars CopyTransformer(SemaRef); // Create iteration variables for the generated loops. SmallVector FloorIndVars; @@ -15194,25 +15197,37 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, // Once the original iteration values are set, append the innermost body. Stmt *Inner = Body; + auto MakeDimTileSize = [ = this->SemaRef, , , + SizesClause, CurScope](int I) -> Expr * { +Expr *DimTileSizeExpr = SizesClause->getSizesRefs()[I]; +return AssertSuccess(CopyTransformer.TransformExpr(DimTileSizeExpr)); + }; + // Create tile loops from the inside to the outside. for (int I = NumLoops - 1; I >= 0; --I) { OMPLoopBasedDirective::HelperExprs = LoopHelpers[I]; Expr *NumIterations = LoopHelper.NumIterations; auto *OrigCntVar = cast(LoopHelper.Counters[0]); -QualType CntTy = OrigCntVar->getType(); -Expr *DimTileSize = SizesClause->getSizesRefs()[I]; -Scope *CurScope = SemaRef.getCurScope(); - -// Commonly used variables. -DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy, - OrigCntVar->getExprLoc()); -DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy, -OrigCntVar->getExprLoc()); +QualType IVTy = NumIterations->getType(); + +// Commonly used variables. One of the constraints of an AST is that every +// node object must appear at most once, hence we define lamdas that create +// a new AST node at every use. +auto MakeTileIVRef = [ = this->SemaRef, , I, IVTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, TileIndVars[I], IVTy, + OrigCntVar->getExprLoc()); +}; +auto MakeFloorIVRef = [ = this->SemaRef, , I, IVTy, + OrigCntVar]() { + return buildDeclRefExpr(SemaRef, FloorIndVars[I], IVTy, + OrigCntVar->getExprLoc()); +}; // For init-statement: auto .tile.iv = .floor.iv -SemaRef.AddInitializerToDecl(TileIndVars[I], - SemaRef.DefaultLvalueConversion(FloorIV).get(), - /*DirectInit=*/false); +SemaRef.AddInitializerToDecl( +TileIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(), +/*DirectInit=*/false); Decl *CounterDecl = TileIndVars[I]; StmtResult InitStmt = new (Context) DeclStmt(DeclGroupRef::Create(Context, , 1), @@ -15220,10 +15235,11 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, if (!InitStmt.isUsable()) return StmtError(); -// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize, -// NumIterations) -ExprResult EndOfTile = SemaRef.BuildBinOp( -CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize); +// For cond-expression: +// .tile.iv < min(.floor.iv + DimTileSize, NumIterations) +ExprResult EndOfTile = +SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, + MakeFloorIVRef(), MakeDimTileSize(I)); if (!EndOfTile.isUsable()) return StmtError(); ExprResult IsPartialTile = @@ -15238,25 +15254,28 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, return StmtError(); ExprResult CondExpr =
[clang] [driver] Do not warn about unused plugin flags. (PR #88948)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/88948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [driver] Do not warn about unused plugin flags. (PR #88948)
Meinersbur wrote: I accidentally pushed a Foxtrot merge. Will push once the pre-merge bot is happy. Thanks for the review. https://github.com/llvm/llvm-project/pull/88948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [driver] Do not warn about unused plugin flags. (PR #88948)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/88948 >From d2cd62082b6967215e6fb7eb975377a01052b79a Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 16 Apr 2024 19:50:35 +0200 Subject: [PATCH 1/2] Do not warn about unused plugin flags. Plugins are not loaded without the -cc1 phase. Do not report them when running on a assembly file or when linking. Many build tools add these options to all driver invocations. See GH #88173. --- clang/include/clang/Driver/Options.td | 6 +++--- clang/test/Driver/clang-s-plugin.s| 5 + 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 clang/test/Driver/clang-s-plugin.s diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 086aedefc11878..73ad01f2be8861 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3645,14 +3645,14 @@ defm rwpi : BoolFOption<"rwpi", "Generate read-write position independent code (ARM only)">, NegFlag>; def fplugin_EQ : Joined<["-"], "fplugin=">, Group, - Flags<[NoXarchOption]>, MetaVarName<"">, + Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"">, HelpText<"Load the named plugin (dynamic shared object)">; def fplugin_arg : Joined<["-"], "fplugin-arg-">, - MetaVarName<"-">, + MetaVarName<"-">, Flags<[NoArgumentUnused]>, HelpText<"Pass to plugin ">; def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">, Group, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, - MetaVarName<"">, + MetaVarName<"">, Flags<[NoArgumentUnused]>, HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">, MarshallingInfoStringVector>; defm tocdata : BoolOption<"m","tocdata", diff --git a/clang/test/Driver/clang-s-plugin.s b/clang/test/Driver/clang-s-plugin.s new file mode 100644 index 00..81169b7bc5bbc8 --- /dev/null +++ b/clang/test/Driver/clang-s-plugin.s @@ -0,0 +1,5 @@ +// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s + +// Plugins are only relevant for the -cc1 phase. No warning should be raised +// when applied to assembly files. See GH #88173. +// CHECK-NOT: argument unused during compilation >From 6e22e57300eba3ba8506c056c091d19d4c249bc5 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 30 Apr 2024 14:56:57 +0200 Subject: [PATCH 2/2] Address reviewer comment --- clang/test/Driver/clang-s-plugin.s | 5 - clang/test/Driver/plugin-driver-args.cpp | 5 + 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 clang/test/Driver/clang-s-plugin.s diff --git a/clang/test/Driver/clang-s-plugin.s b/clang/test/Driver/clang-s-plugin.s deleted file mode 100644 index 81169b7bc5bbc8..00 --- a/clang/test/Driver/clang-s-plugin.s +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s - -// Plugins are only relevant for the -cc1 phase. No warning should be raised -// when applied to assembly files. See GH #88173. -// CHECK-NOT: argument unused during compilation diff --git a/clang/test/Driver/plugin-driver-args.cpp b/clang/test/Driver/plugin-driver-args.cpp index d6475b4b3d733a..6f0e6e2ba75251 100644 --- a/clang/test/Driver/plugin-driver-args.cpp +++ b/clang/test/Driver/plugin-driver-args.cpp @@ -20,3 +20,8 @@ // RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fplugin-arg-testname- -fsyntax-only %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PLUGIN-ARG2 // CHECK-NO-PLUGIN-ARG2: missing plugin argument for plugin testname in -fplugin-arg-testname- + +// Plugins are only relevant for the -cc1 phase. No warning should be raised +// when only using the assembler. See GH #88173. +// RUN: %clang -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror -x assembler %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PLUGIN-ASM +// CHECK-PLUGIN-ASM-NOT: argument unused during compilation ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)
Meinersbur wrote: As suggested, I split the patch into per-subproject patches: [LLVM](https://github.com/llvm/llvm-project/pull/89741) (dependency of the other patches) [BOLT](https://github.com/llvm/llvm-project/pull/89742) [Clang](https://github.com/llvm/llvm-project/pull/89743) [Clang-Tools-Extra](https://github.com/llvm/llvm-project/pull/89744) [Compiler-RT](https://github.com/llvm/llvm-project/pull/89753) [Flang](https://github.com/llvm/llvm-project/pull/89745) [libclc](https://github.com/llvm/llvm-project/pull/89746) [LLD](https://github.com/llvm/llvm-project/pull/89747) [LLDB](https://github.com/llvm/llvm-project/pull/89748) [MLIR](https://github.com/llvm/llvm-project/pull/89749) [OpenMP](https://github.com/llvm/llvm-project/pull/89750) [Polly](https://github.com/llvm/llvm-project/pull/89752) [Misc](https://github.com/llvm/llvm-project/pull/89755) https://github.com/llvm/llvm-project/pull/89153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/89153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)
@@ -406,5 +426,13 @@ function(llvm_ExternalProject_Add name source_dir) WORKING_DIRECTORY ${BINARY_DIR} VERBATIM USES_TERMINAL) +if (ARG_FOLDER) + set_target_properties(${target} PROPERTIES FOLDER "${ARG_FOLDER}") +endif () endforeach() + + #set_target_folder( + # TARGETS ${name} install-${name} ${name}-clobber ${name}-clear ${name}-clean ${ARG_EXTRA_TARGETS} + # FOLDER "${ARG_FOLDE}" + #) Meinersbur wrote: thanks https://github.com/llvm/llvm-project/pull/89153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)
@@ -56,11 +56,13 @@ endfunction() # Use provided strip tool instead of the default one. # TARGET_TRIPLE triple # Optional target triple to pass to the compiler +# FOLDER +# For IDEs, the Folder to put the targets into.= Meinersbur wrote: It's already called FOLDER in https://github.com/llvm/llvm-project/blob/main/llvm/cmake/modules/AddLLVM.cmake#L2080-L2083. I would prefer to keep it consistent. https://github.com/llvm/llvm-project/pull/89153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)
https://github.com/Meinersbur ready_for_review https://github.com/llvm/llvm-project/pull/89153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/88932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)
Meinersbur wrote: > IIRC it was unnecessary for the documentation because it gets built multiple > times, for the driver it's built once so it has to include all possible > variants the first time. > > I have no preference for how it's done, if the `%Program` thing works then > fine. We only need a `ForVariants` if it's something people see when > interacting with Flang itself I think. I didn't know this and experimented a bit. Indeed `%Program` in `HelpText` gets emitted as "Clang" in `flang-new --help`. `DocBrief` and `HelpText` are "Flang" for `FlangCommandLineReference.rst`. So `DocBriefForVariant` would not add new functionality, but might be useful so `DocBrief[ForVariant]` and `HelpText[ForVariant]` can use the same syntax and avoid confusion. I will merge this patch and work on `DocBriefForVariant` after that. https://github.com/llvm/llvm-project/pull/88932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [driver] Do not warn about unused plugin flags. (PR #88948)
https://github.com/Meinersbur ready_for_review https://github.com/llvm/llvm-project/pull/88948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)
@@ -807,8 +807,12 @@ def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">, "Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation">; def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>, Visibility<[ClangOption, FlangOption]>, - HelpText<"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " - "Clang will use the GCC installation with the largest version">; + HelpText< +"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " +"Clang will use the GCC installation with the largest version">, + HelpTextForVariants<[FlangOption], +"Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " Meinersbur wrote: Even though flang has a (non-standard) preprocessor, it doesn't add `-isystem` includes from gcc's dir. Hence referencing `include` could be confusing. https://github.com/llvm/llvm-project/pull/88932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)
Meinersbur wrote: > Do you mean that this PR fixes this, or that you noticed this problem while > working on this? I noticed this when working on the patch, .i.e that https://flang.llvm.org/docs/FlangCommandLineReference.html still mentioned Clang in several places and since it was common, I didn't want to fix it only for `--gcc-toolchain`. `HelpTextForVariants` was introduced later, reducing the number of "Clang" in FlangCommandLineReference already. This fixes `--gcc-toolchain`, but there is no list of warnings supported by Flang, so I don't have anything beyond what #81726 already did. > If it's the latter it may be as @banach-space mentioned to me, that the > `docbrief` is still shared between Flang and Clang. This could be solved in a > similar, albeit tedious way to what I did for the help text. The docbrief strings already use `%Program`/`GlobalDocumentation.Program` which seems to work and made me think that `HelpTextForVariants` was actually unnecessary. Would you like me to introduce `DocBriefForVariants`? > @Meinersbur Could you share an example? If it's a problem specific to > diagnostics then we should possibly just start separating Clang and Flang > diagnostics. That could mean a bit of duplication, but not too much, so I'm > not worried. ``` def Diag_Group : OptionGroup<"">, Group, DocName<"Diagnostic options">, DocBrief.str, !cond(!eq(GlobalDocumentation.Program, "Clang"): "See the :doc:`full list of warning and remark flags `.", true: "See Clang's Diagnostic Reference for a full list of warning and remark flags." ) )>; ``` https://github.com/llvm/llvm-project/pull/88932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)
https://github.com/Meinersbur ready_for_review https://github.com/llvm/llvm-project/pull/88932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/88932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [driver] Do not warn about unused plugin flags. (PR #88948)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/88948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Do not warn about unused plugin flags. (PR #88948)
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/88948 Plugins are not loaded without the -cc1 phase. Do not report them when running on an assembly file or when linking. Many build tools add these options to all driver invocations, including LLVM's build system. Fixes #88173 >From e5b10d3eba126454824c9f6fac4a575e07366ae6 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 16 Apr 2024 19:50:35 +0200 Subject: [PATCH] Do not warn about unused plugin flags. Plugins are not loaded without the -cc1 phase. Do not report them when running on a assembly file or when linking. Many build tools add these options to all driver invocations. See GH #88173. --- clang/include/clang/Driver/Options.td | 6 +++--- clang/test/Driver/clang-s-plugin.s| 5 + 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 clang/test/Driver/clang-s-plugin.s diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..c1d85c527d437b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3630,14 +3630,14 @@ defm rwpi : BoolFOption<"rwpi", "Generate read-write position independent code (ARM only)">, NegFlag>; def fplugin_EQ : Joined<["-"], "fplugin=">, Group, - Flags<[NoXarchOption]>, MetaVarName<"">, + Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"">, HelpText<"Load the named plugin (dynamic shared object)">; def fplugin_arg : Joined<["-"], "fplugin-arg-">, - MetaVarName<"-">, + MetaVarName<"-">, Flags<[NoArgumentUnused]>, HelpText<"Pass to plugin ">; def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">, Group, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, - MetaVarName<"">, + MetaVarName<"">, Flags<[NoArgumentUnused]>, HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">, MarshallingInfoStringVector>; defm tocdata : BoolOption<"m","tocdata", diff --git a/clang/test/Driver/clang-s-plugin.s b/clang/test/Driver/clang-s-plugin.s new file mode 100644 index 00..81169b7bc5bbc8 --- /dev/null +++ b/clang/test/Driver/clang-s-plugin.s @@ -0,0 +1,5 @@ +// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s + +// Plugins are only relevant for the -cc1 phase. No warning should be raised +// when applied to assembly files. See GH #88173. +// CHECK-NOT: argument unused during compilation ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] Avoid mentions of Clang in Flang's command line reference. (PR #88932)
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/88932 The help text was not updated in #87360. Clang is also mentioned for the diagnostic warnings reference, which mostly applies to C/C++/Obj-C, not Fortran. #81726 already tried to fix this, and I don't know a better solution. >From dd38c3f9aa30652242dfb5cf2e9bd53e8ff0e286 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 16 Apr 2024 15:20:29 +0200 Subject: [PATCH] Avoid mentions of Clang in Flang's command line reference. The help text was not updated in #87360. Clang is also mentioned for the diagnositic warnings reference, which mostly applies to C/C++/Obj-C, not Fortran. #81726 already tried to fix this, and I don't know a better solution. --- clang/include/clang/Driver/Options.td| 8 ++-- flang/test/Driver/driver-help-hidden.f90 | 2 +- flang/test/Driver/driver-help.f90| 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..d89b53e4049cf6 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -807,8 +807,12 @@ def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">, "Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation">; def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>, Visibility<[ClangOption, FlangOption]>, - HelpText<"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " - "Clang will use the GCC installation with the largest version">; + HelpText< +"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " +"Clang will use the GCC installation with the largest version">, + HelpTextForVariants<[FlangOption], +"Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " +"Flang will use the GCC installation with the largest version">; def gcc_triple_EQ : Joined<["--"], "gcc-triple=">, HelpText<"Search for the GCC installation with the specified triple.">; def CC : Flag<["-"], "CC">, Visibility<[ClangOption, CC1Option]>, diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90 index de2fe3048f993c..b5bb0f1c1b2560 100644 --- a/flang/test/Driver/driver-help-hidden.f90 +++ b/flang/test/Driver/driver-help-hidden.f90 @@ -109,7 +109,7 @@ ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! CHECK-NEXT: --gcc-install-dir= ! CHECK-NEXT: Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation -! CHECK-NEXT: --gcc-toolchain= Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version +! CHECK-NEXT: --gcc-toolchain= Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Flang will use the GCC installation with the largest version ! CHECK-NEXT: -gline-directives-only Emit debug line info directives only ! CHECK-NEXT: -gline-tables-only Emit debug line number tables only ! CHECK-NEXT: -gpulibcLink the LLVM C Library for GPUs diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90 index b258eb59c18629..0b0a493baf07f7 100644 --- a/flang/test/Driver/driver-help.f90 +++ b/flang/test/Driver/driver-help.f90 @@ -97,7 +97,7 @@ ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. ! HELP-NEXT: --gcc-install-dir= ! HELP-NEXT: Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation -! HELP-NEXT: --gcc-toolchain= Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version +! HELP-NEXT: --gcc-toolchain= Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Flang will use the GCC installation with the largest version ! HELP-NEXT: -gline-directives-only Emit debug line info directives only ! HELP-NEXT: -gline-tables-only Emit debug line number tables only ! HELP-NEXT: -gpulibcLink the LLVM C Library for GPUs ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add --gcc-toolchain and --gcc-install-dir options to flang. (PR #87360)
https://github.com/Meinersbur closed https://github.com/llvm/llvm-project/pull/87360 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add --gcc-toolchain and --gcc-install-dir options to flang. (PR #87360)
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/87360 The `--gcc-toolchain` and `--gcc-install-dir` option were previously only visible to the Clang driver, but not Flang. These determine which assembler, linker, and libraries to use, e.g. for cross-compiling, and therefore are relevant for Flang as well. Fixes #86729 >From 6abdea97edcb345c97c32e2770016c3956f869a2 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 2 Apr 2024 17:33:13 +0200 Subject: [PATCH] [flang] Add --gcc-toolchain and --gcc-install-dir options to flang --- clang/include/clang/Driver/Options.td| 2 ++ .../usr/bin/i386-unknown-linux-gnu-as| 1 + .../usr/bin/i386-unknown-linux-gnu-ld| 1 + .../usr/bin/i386-unknown-linux-gnu-ld.bfd| 1 + .../usr/bin/i386-unknown-linux-gnu-ld.gold | 1 + .../usr/bin/x86_64-unknown-linux-gnu-as | 1 + .../usr/bin/x86_64-unknown-linux-gnu-ld | 1 + .../usr/bin/x86_64-unknown-linux-gnu-ld.bfd | 1 + .../usr/bin/x86_64-unknown-linux-gnu-ld.gold | 1 + .../usr/i386-unknown-linux-gnu/bin/as| 1 + .../usr/i386-unknown-linux-gnu/bin/ld| 1 + .../usr/i386-unknown-linux-gnu/bin/ld.bfd| 1 + .../usr/i386-unknown-linux-gnu/bin/ld.gold | 1 + .../usr/i386-unknown-linux-gnu/lib/.keep | 0 .../usr/x86_64-unknown-linux-gnu/bin/as | 1 + .../usr/x86_64-unknown-linux-gnu/bin/ld | 1 + .../usr/x86_64-unknown-linux-gnu/bin/ld.bfd | 1 + .../usr/x86_64-unknown-linux-gnu/bin/ld.gold | 1 + .../usr/x86_64-unknown-linux-gnu/bin/ld.lld | 0 .../usr/x86_64-unknown-linux-gnu/lib/.keep | 0 flang/test/Driver/gcc-install-dir.f90| 16 flang/test/Driver/gcc-toolchain.f90 | 16 22 files changed, 50 insertions(+) create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-as create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld.bfd create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld.gold create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-as create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld.bfd create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld.gold create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/as create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld.bfd create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld.gold create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/lib/.keep create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/as create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld.bfd create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld.gold create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld.lld create mode 100644 flang/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/lib/.keep create mode 100644 flang/test/Driver/gcc-install-dir.f90 create mode 100644 flang/test/Driver/gcc-toolchain.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f5289fb00c895e..c3feff826d0036 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -802,9 +802,11 @@ def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"">, HelpText<"Search $prefix$file for executables, libraries, and data files. " "If $prefix is a directory, search $prefix/$file">; def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">, + Visibility<[ClangOption, FlangOption]>, HelpText<"Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " "Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation">; def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>, + Visibility<[ClangOption, FlangOption]>, HelpText<"Specify a directory
[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)
https://github.com/Meinersbur approved this pull request. The change works, as I managed to compile a single file. However, the resulting executable segfaults for me on Windows and I get a link error when compiling multiple HIP files. Those are unrelated. https://github.com/llvm/llvm-project/pull/84322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)
@@ -410,7 +410,10 @@ fatbinary(ArrayRef> InputFiles, Targets.push_back(Saver.save("hipv4-amdgcn-amd-amdhsa--" + Arch)); CmdArgs.push_back(Saver.save(llvm::join(Targets, ","))); - CmdArgs.push_back("-input=/dev/null"); + if (Triple.isOSWindows()) Meinersbur wrote: This does not depend on the target platform, but the host OS that runs clang-linker-wrapper (`#ifdef _WIN32`) https://github.com/llvm/llvm-project/pull/84322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/84322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Use the correct empty file on Windows (PR #84322)
https://github.com/Meinersbur requested changes to this pull request. https://github.com/llvm/llvm-project/pull/84322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang-tools-extra] [polly] [clang] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)
@@ -0,0 +1,32 @@ +//===-PollyDebug.inc -Provide support for debugging Polly passes-*- C++ -*-===// Meinersbur wrote: Please use a `.h` extension for this file, it's a normal header file https://github.com/llvm/llvm-project/pull/78549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [polly] [llvm] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/78549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [polly] [llvm] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)
@@ -0,0 +1,32 @@ +//===-PollyDebug.inc -Provide support for debugging Polly passes-*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// Functions to aid printing Debug Info of all polly passes. +// +//===--===// + +#ifndef POLLY_DEBUG_H +#define POLLY_DEBUG_H + +#include "llvm/Support/Debug.h" +namespace polly { +using namespace llvm; +bool getPollyDebugFlag(); +#ifndef NDEBUG +#undef LLVM_DEBUG +#define LLVM_DEBUG(X) \ Meinersbur wrote: This conflicts with an existing symbol in LLVM itself. I don't think it's a good idea to overload it for polly. You could call it `POLLY_DEBUG`. This will require a search, but IMHO highly preferably over a a header include fiasco. https://github.com/llvm/llvm-project/pull/78549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [polly] [clang-tools-extra] [llvm] [polly] Add polly-debug flag to print debug info from all parts of polly (PR #78549)
https://github.com/Meinersbur requested changes to this pull request. https://github.com/llvm/llvm-project/pull/78549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/72889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/72889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)
https://github.com/Meinersbur approved this pull request. PE file start with the magic bytes `MZ` (0x4D5A). Extracting sections can usually done with the [dumpbin.exe](https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170) tool. I don't know whether LLVM has means to do it itself as well. https://github.com/llvm/llvm-project/pull/72889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)
@@ -126,3 +126,8 @@ def version : Flag<["--", "-"], "version">, Flags<[HelpHidden]>, Alias; def whole_archive : Flag<["--", "-"], "whole-archive">, Flags<[HelpHidden]>; def no_whole_archive : Flag<["--", "-"], "no-whole-archive">, Flags<[HelpHidden]>; + +// COFF-style linker options. Meinersbur wrote: ```suggestion // link.exe-style linker options. ``` Can you change this as well? https://github.com/llvm/llvm-project/pull/72889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (PR #72889)
@@ -126,3 +126,8 @@ def version : Flag<["--", "-"], "version">, Flags<[HelpHidden]>, Alias; def whole_archive : Flag<["--", "-"], "whole-archive">, Flags<[HelpHidden]>; def no_whole_archive : Flag<["--", "-"], "no-whole-archive">, Flags<[HelpHidden]>; + +// COFF-style linker options. +def out : Joined<["/", "-", "/?", "-?"], "out:">, Flags<[HelpHidden]>; Meinersbur wrote: Feels strange to me, but justification is in 4b81e9f8d10214fbb2c8e1a367a60801a5dd5fed https://github.com/llvm/llvm-project/pull/72889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Accept some needed COFF linker arguments (PR #72889)
@@ -126,3 +126,8 @@ def version : Flag<["--", "-"], "version">, Flags<[HelpHidden]>, Alias; def whole_archive : Flag<["--", "-"], "whole-archive">, Flags<[HelpHidden]>; def no_whole_archive : Flag<["--", "-"], "no-whole-archive">, Flags<[HelpHidden]>; + +// COFF-style linker options. +def out : Joined<["/", "-", "/?", "-?"], "out:">, Flags<[HelpHidden]>; Meinersbur wrote: Why `/?` and `-?` in the permitted option prefix list? Wouldn't this allow e.g. `-?out:`? https://github.com/llvm/llvm-project/pull/72889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [LinkerWrapper] Accept some needed COFF linker arguments (PR #72889)
Meinersbur wrote: The command-line argument handling is not related to [PE](https://en.wikipedia.org/wiki/Portable_Executable)/COFF, but to Microsoft's `link.exe` command line interface, for instance [`/libpath:`](https://learn.microsoft.com/en-us/cpp/build/reference/libpath-additional-libpath?view=msvc-170). `/usr/bin/lld-link` is a `link.exe`-compatible interface for lld with an appropriate default triple, like `clang-cl` is for `clang`. IIRC, `lld` choses its command-line interface based on the `argv[0]` name, so should clang-linker-wrapper when passed `--linker-path=/usr/bin/lld-link` instead of `--linker-path=/usr/bin/lld`, but both should be able to generate PE files. That is, this patch is not necessarily wrong, but the commit message and "// COFF-style linker options." should refer to the command line interface instead. https://github.com/llvm/llvm-project/pull/72889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle variable declarations in BreakAfterAttributes (PR #71755)
Meinersbur wrote: @owenca You can run `ninja polly-update-format` which will use the in-tree `clang-format` to reformat all files. `git add` its changes, `git add --amend`, then push. https://github.com/llvm/llvm-project/pull/71755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] acec070 - [OpenMP] Fix partial unrolling off-by-one.
Author: Michael Kruse Date: 2022-05-20T15:19:52-05:00 New Revision: acec07005e038ab2891f235ae60ba2f0236bb952 URL: https://github.com/llvm/llvm-project/commit/acec07005e038ab2891f235ae60ba2f0236bb952 DIFF: https://github.com/llvm/llvm-project/commit/acec07005e038ab2891f235ae60ba2f0236bb952.diff LOG: [OpenMP] Fix partial unrolling off-by-one. Even though the comment description is ".unroll_inner.iv < NumIterations", the code emitted a BO_LE ('<=') operator for the inner loop that is to be unrolled. This lead to one additional copy of the body code in a partially unrolled. It only manifests when the unrolled loop is consumed by another loop-associated construct. Fix by using the BO_LT operator instead. The condition for the outer loop and the corresponding code for tiling correctly used BO_LT already. Fixes #55236 Added: Modified: clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp clang/test/OpenMP/unroll_codegen_for_partial.cpp clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp clang/test/OpenMP/unroll_codegen_tile_for.cpp clang/test/OpenMP/unroll_codegen_unroll_for.cpp clang/test/OpenMP/unroll_codegen_unroll_for_attr.cpp Removed: diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index e4305ba8c1718..42c3dbc181911 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -14483,11 +14483,11 @@ StmtResult Sema::ActOnOpenMPUnrollDirective(ArrayRef Clauses, if (!EndOfTile.isUsable()) return StmtError(); ExprResult InnerCond1 = BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), - BO_LE, MakeInnerRef(), EndOfTile.get()); + BO_LT, MakeInnerRef(), EndOfTile.get()); if (!InnerCond1.isUsable()) return StmtError(); ExprResult InnerCond2 = - BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LE, MakeInnerRef(), + BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT, MakeInnerRef(), MakeNumIterations()); if (!InnerCond2.isUsable()) return StmtError(); diff --git a/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c b/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c index 0bfed911077bf..94d7a14a0bb87 100644 --- a/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c +++ b/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c @@ -106,12 +106,12 @@ // CHECK-NEXT:%[[TMP15:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4 // CHECK-NEXT:%[[TMP16:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J7]], align 4 // CHECK-NEXT:%[[ADD21:.+]] = add nsw i32 %[[TMP16]], 4 -// CHECK-NEXT:%[[CMP22:.+]] = icmp sle i32 %[[TMP15]], %[[ADD21]] +// CHECK-NEXT:%[[CMP22:.+]] = icmp slt i32 %[[TMP15]], %[[ADD21]] // CHECK-NEXT:br i1 %[[CMP22]], label %[[LAND_RHS:.+]], label %[[LAND_END:.+]] // CHECK-EMPTY: // CHECK-NEXT: [[LAND_RHS]]: // CHECK-NEXT:%[[TMP17:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4 -// CHECK-NEXT:%[[CMP24:.+]] = icmp sle i32 %[[TMP17]], 8 +// CHECK-NEXT:%[[CMP24:.+]] = icmp slt i32 %[[TMP17]], 8 // CHECK-NEXT:br label %[[LAND_END]] // CHECK-EMPTY: // CHECK-NEXT: [[LAND_END]]: diff --git a/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c b/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c index 1a2bd117bf98c..c44b2b3202694 100644 --- a/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c +++ b/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c @@ -114,12 +114,12 @@ double sind(double); // CHECK-NEXT:%[[TMP15:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4 // CHECK-NEXT:%[[TMP16:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J7]], align 4 // CHECK-NEXT:%[[ADD21:.+]] = add nsw i32 %[[TMP16]], 2 -// CHECK-NEXT:%[[CMP22:.+]] = icmp sle i32 %[[TMP15]], %[[ADD21]] +// CHECK-NEXT:%[[CMP22:.+]] = icmp slt i32 %[[TMP15]], %[[ADD21]] // CHECK-NEXT:br i1 %[[CMP22]], label %[[LAND_RHS:.+]], label %[[LAND_END:.+]] // CHECK-EMPTY: // CHECK-NEXT: [[LAND_RHS]]: // CHECK-NEXT:%[[TMP17:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4 -// CHECK-NEXT:%[[CMP24:.+]] = icmp sle i32 %[[TMP17]], 8 +// CHECK-NEXT:%[[CMP24:.+]] = icmp slt i32 %[[TMP17]], 8 // CHECK-NEXT:br label %[[LAND_END]] // CHECK-EMPTY: // CHECK-NEXT: [[LAND_END]]: diff --git a/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp b/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp index cafda811d0d0c..693cbf851b991 100644 --- a/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp +++
[clang] 2d92ee9 - Reapply "[OpenMP] Refactor OMPScheduleType enum."
Author: Michael Kruse Date: 2022-04-18T21:56:47-05:00 New Revision: 2d92ee97f1afb3657579a46a7dd4611b61e9cc16 URL: https://github.com/llvm/llvm-project/commit/2d92ee97f1afb3657579a46a7dd4611b61e9cc16 DIFF: https://github.com/llvm/llvm-project/commit/2d92ee97f1afb3657579a46a7dd4611b61e9cc16.diff LOG: Reapply "[OpenMP] Refactor OMPScheduleType enum." This reverts commit af0285122f306573d9bcc4c4ad7f904cfdd4d869. The test "libomp::loop_dispatch.c" on builder openmp-gcc-x86_64-linux-debian fails from time-to-time. See #54969. This patch is unrelated. Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp clang/test/OpenMP/irbuilder_for_unsigned_auto.c clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c clang/test/OpenMP/irbuilder_for_unsigned_runtime.c llvm/include/llvm/Frontend/OpenMP/OMPConstants.h llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/Transforms/IPO/OpenMPOpt.cpp llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp mlir/test/Target/LLVMIR/openmp-llvm.mlir Removed: diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index e85c702907fa0..a249ef9d58d97 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3760,9 +3760,11 @@ void CodeGenFunction::EmitOMPForDirective(const OMPForDirective ) { CGM.getOpenMPRuntime().getOMPBuilder(); llvm::OpenMPIRBuilder::InsertPointTy AllocaIP( AllocaInsertPt->getParent(), AllocaInsertPt->getIterator()); - OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI, -AllocaIP, NeedsBarrier, SchedKind, -ChunkSize); + OMPBuilder.applyWorkshareLoop( + Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier, + SchedKind, ChunkSize, /*HasSimdModifier=*/false, + /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false, + /*HasOrderedClause=*/false); return; } diff --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c index f1dadc63a22a0..bf0383cdb956c 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c @@ -38,7 +38,7 @@ // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1) -// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 38, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) +// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 1073741862, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]] // CHECK-EMPTY: // CHECK-NEXT: [[OMP_LOOP_HEADER:.*]]: diff --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c index 39321ff3b7af0..8a126c2ea440a 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c @@ -38,7 +38,7 @@ // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1) -// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 35, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) +// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]] // CHECK-EMPTY: // CHECK-NEXT: [[OMP_LOOP_HEADER:.*]]: diff --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c index fd932a4f82070..09773a2bd6f17 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c @@ -38,7 +38,7 @@ // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1) -// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 35, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 5) +// CHECK-NEXT:
[clang] af02851 - Revert "[OpenMP] Refactor OMPScheduleType enum."
Author: Michael Kruse Date: 2022-04-18T14:38:31-05:00 New Revision: af0285122f306573d9bcc4c4ad7f904cfdd4d869 URL: https://github.com/llvm/llvm-project/commit/af0285122f306573d9bcc4c4ad7f904cfdd4d869 DIFF: https://github.com/llvm/llvm-project/commit/af0285122f306573d9bcc4c4ad7f904cfdd4d869.diff LOG: Revert "[OpenMP] Refactor OMPScheduleType enum." This reverts commit 9ec501da76fc1559cadd6d6dac32766bf4376a3d. It may have caused the openmp-gcc-x86_64-linux-debian buildbot to fail. https://lab.llvm.org/buildbot/#/builders/4/builds/20377 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp clang/test/OpenMP/irbuilder_for_unsigned_auto.c clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c clang/test/OpenMP/irbuilder_for_unsigned_runtime.c llvm/include/llvm/Frontend/OpenMP/OMPConstants.h llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/Transforms/IPO/OpenMPOpt.cpp llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp mlir/test/Target/LLVMIR/openmp-llvm.mlir Removed: diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index a249ef9d58d97..e85c702907fa0 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3760,11 +3760,9 @@ void CodeGenFunction::EmitOMPForDirective(const OMPForDirective ) { CGM.getOpenMPRuntime().getOMPBuilder(); llvm::OpenMPIRBuilder::InsertPointTy AllocaIP( AllocaInsertPt->getParent(), AllocaInsertPt->getIterator()); - OMPBuilder.applyWorkshareLoop( - Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier, - SchedKind, ChunkSize, /*HasSimdModifier=*/false, - /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false, - /*HasOrderedClause=*/false); + OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI, +AllocaIP, NeedsBarrier, SchedKind, +ChunkSize); return; } diff --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c index bf0383cdb956c..f1dadc63a22a0 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c @@ -38,7 +38,7 @@ // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1) -// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 1073741862, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) +// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 38, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]] // CHECK-EMPTY: // CHECK-NEXT: [[OMP_LOOP_HEADER:.*]]: diff --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c index 8a126c2ea440a..39321ff3b7af0 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c @@ -38,7 +38,7 @@ // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1) -// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) +// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 35, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1) // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]] // CHECK-EMPTY: // CHECK-NEXT: [[OMP_LOOP_HEADER:.*]]: diff --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c index 09773a2bd6f17..fd932a4f82070 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c @@ -38,7 +38,7 @@ // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1) -// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 %[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 5) +// CHECK-NEXT:
[clang] 9ec501d - [OpenMP] Refactor OMPScheduleType enum.
Author: Michael Kruse Date: 2022-04-18T14:03:17-05:00 New Revision: 9ec501da76fc1559cadd6d6dac32766bf4376a3d URL: https://github.com/llvm/llvm-project/commit/9ec501da76fc1559cadd6d6dac32766bf4376a3d DIFF: https://github.com/llvm/llvm-project/commit/9ec501da76fc1559cadd6d6dac32766bf4376a3d.diff LOG: [OpenMP] Refactor OMPScheduleType enum. The OMPScheduleType enum stores the constants from libomp's internal sched_type in kmp.h and are used by several kmp API functions. The enum values have an internal structure, namely each scheduling algorithm (e.g.) exists in four variants: unordered, orderend, normerge unordered, and nomerge ordered. This patch (basically a followup to D114940) splits the "ordered" and "nomerge" bits into separate flags, as was already done for the "monotonic" and "nonmonotonic", so we can apply bit flags operations on them. It also now contains all possible combinations according to kmp's sched_type. Deriving of the OMPScheduleType enum from clause parameters has been moved form MLIR's OpenMPToLLVMIRTranslation.cpp to OpenMPIRBuilder to make available for clang as well. Since the primary purpose of the flag is the binary interface to libomp, it has been made more private to LLVMFrontend. The primary interface for generating worksharing-loop using OpenMPIRBuilder code becomes `applyWorkshareLoop` which derives the OMPScheduleType automatically and calls the appropriate emitter function. While this is mostly a NFC refactor, it still applies the following functional changes: * The logic from OpenMPToLLVMIRTranslation to derive the OMPScheduleType also applies to clang. Most notably, it now applies the nonmonotonic flag for non-static schedules by default. * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was previously not applied if the simd modifier was used. I assume this was a bug, since the effect was due to `loop.schedule_modifier()` returning `mlir::omp::ScheduleModifier::none` instead of `llvm::Optional::None`. * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was set even if ordered was specified, in breach to what the comment before citing the OpenMP specification says. I assume this was an oversight. The ordered flag with parameter was not considered in this patch. Changes will need to be made (e.g. adding/modifying function parameters) when support for it is added. The lengthy names of the enum values can be discussed, for the moment this is avoiding reusing previously existing enum value names such as `StaticChunked` to avoid confusion. Reviewed By: peixin Differential Revision: https://reviews.llvm.org/D123403 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp clang/test/OpenMP/irbuilder_for_unsigned_auto.c clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c clang/test/OpenMP/irbuilder_for_unsigned_runtime.c llvm/include/llvm/Frontend/OpenMP/OMPConstants.h llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/Transforms/IPO/OpenMPOpt.cpp llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp mlir/test/Target/LLVMIR/openmp-llvm.mlir Removed: diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index e85c702907fa0..a249ef9d58d97 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3760,9 +3760,11 @@ void CodeGenFunction::EmitOMPForDirective(const OMPForDirective ) { CGM.getOpenMPRuntime().getOMPBuilder(); llvm::OpenMPIRBuilder::InsertPointTy AllocaIP( AllocaInsertPt->getParent(), AllocaInsertPt->getIterator()); - OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI, -AllocaIP, NeedsBarrier, SchedKind, -ChunkSize); + OMPBuilder.applyWorkshareLoop( + Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier, + SchedKind, ChunkSize, /*HasSimdModifier=*/false, + /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false, + /*HasOrderedClause=*/false); return; } diff --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c index f1dadc63a22a0..bf0383cdb956c 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c @@ -38,7 +38,7 @@ // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @1) -// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32
[clang] 8a9e4f2 - [Clang][OpenMPIRBuilder] Fix off-by-one error when dividing by stepsize.
Author: Michael Kruse Date: 2022-01-31T17:28:52-06:00 New Revision: 8a9e4f245b66b90839bdf34e91cb0901e3260dad URL: https://github.com/llvm/llvm-project/commit/8a9e4f245b66b90839bdf34e91cb0901e3260dad DIFF: https://github.com/llvm/llvm-project/commit/8a9e4f245b66b90839bdf34e91cb0901e3260dad.diff LOG: [Clang][OpenMPIRBuilder] Fix off-by-one error when dividing by stepsize. When the stepsize does not evenly divide the range's end, round-up to ensure that that last multiple of the stepsize before the reaching the upper boud is reached. For instance, the trip count of for (int i = 0; i < 7; i+=5) is two (i=0 and i=5), not (7-0)/5 == 1. Reviewed By: peixin Differential Revision: https://reviews.llvm.org/D118542 Added: clang/test/OpenMP/irbuilder_for_unsigned_down.c Modified: clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/irbuilder_for_unsigned.c clang/test/OpenMP/irbuilder_unroll_full.c clang/test/OpenMP/irbuilder_unroll_heuristic.c clang/test/OpenMP/irbuilder_unroll_partial_factor.c clang/test/OpenMP/irbuilder_unroll_partial_factor_for.c clang/test/OpenMP/irbuilder_unroll_partial_heuristic.c clang/test/OpenMP/irbuilder_unroll_partial_heuristic_constant_for.c clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c Removed: diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index ae91a6470471a..a500ad4f02209 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -5327,6 +5327,8 @@ static CapturedStmt *buildDistanceFunc(Sema , QualType LogicalTy, IntegerLiteral *Zero = IntegerLiteral::Create( Ctx, llvm::APInt(Ctx.getIntWidth(LogicalTy), 0), LogicalTy, {}); +IntegerLiteral *One = IntegerLiteral::Create( +Ctx, llvm::APInt(Ctx.getIntWidth(LogicalTy), 1), LogicalTy, {}); Expr *Dist; if (Rel == BO_NE) { // When using a != comparison, the increment can be +1 or -1. This can be @@ -5381,18 +5383,25 @@ static CapturedStmt *buildDistanceFunc(Sema , QualType LogicalTy, if (Rel == BO_LE || Rel == BO_GE) { // Add one to the range if the relational operator is inclusive. -Range = AssertSuccess(Actions.BuildBinOp( -nullptr, {}, BO_Add, Range, -Actions.ActOnIntegerConstant(SourceLocation(), 1).get())); +Range = +AssertSuccess(Actions.BuildBinOp(nullptr, {}, BO_Add, Range, One)); } - // Divide by the absolute step amount. + // Divide by the absolute step amount. If the range is not a multiple of + // the step size, rounding-up the effective upper bound ensures that the + // last iteration is included. + // Note that the rounding-up may cause an overflow in a temporry that + // could be avoided, but would have occured in a C-style for-loop as well. Expr *Divisor = BuildVarRef(NewStep); if (Rel == BO_GE || Rel == BO_GT) Divisor = AssertSuccess(Actions.BuildUnaryOp(nullptr, {}, UO_Minus, Divisor)); + Expr *DivisorMinusOne = + AssertSuccess(Actions.BuildBinOp(nullptr, {}, BO_Sub, Divisor, One)); + Expr *RangeRoundUp = AssertSuccess( + Actions.BuildBinOp(nullptr, {}, BO_Add, Range, DivisorMinusOne)); Dist = AssertSuccess( - Actions.BuildBinOp(nullptr, {}, BO_Div, Range, Divisor)); + Actions.BuildBinOp(nullptr, {}, BO_Div, RangeRoundUp, Divisor)); // If there is not at least one iteration, the range contains garbage. Fix // to zero in this case. diff --git a/clang/test/OpenMP/irbuilder_for_unsigned.c b/clang/test/OpenMP/irbuilder_for_unsigned.c index a7e70391c027b..928d99b9bfc72 100644 --- a/clang/test/OpenMP/irbuilder_for_unsigned.c +++ b/clang/test/OpenMP/irbuilder_for_unsigned.c @@ -123,14 +123,17 @@ extern "C" void workshareloop_unsigned(float *a, float *b, float *c, float *d) { // CHECK-NEXT:[[TMP7:%.*]] = load i32, i32* [[DOTSTART]], align 4 // CHECK-NEXT:[[SUB:%.*]] = sub i32 [[TMP6]], [[TMP7]] // CHECK-NEXT:[[TMP8:%.*]] = load i32, i32* [[DOTSTEP]], align 4 -// CHECK-NEXT:[[DIV:%.*]] = udiv i32 [[SUB]], [[TMP8]] +// CHECK-NEXT:[[SUB1:%.*]] = sub i32 [[TMP8]], 1 +// CHECK-NEXT:[[ADD:%.*]] = add i32 [[SUB]], [[SUB1]] +// CHECK-NEXT:[[TMP9:%.*]] = load i32, i32* [[DOTSTEP]], align 4 +// CHECK-NEXT:[[DIV:%.*]] = udiv i32 [[ADD]], [[TMP9]] // CHECK-NEXT:br label [[COND_END:%.*]] // CHECK: cond.false: // CHECK-NEXT:br label [[COND_END]] // CHECK: cond.end: // CHECK-NEXT:[[COND:%.*]] = phi i32 [ [[DIV]], [[COND_TRUE]] ], [ 0, [[COND_FALSE]] ] -// CHECK-NEXT:[[TMP9:%.*]] = load i32*, i32** [[DISTANCE_ADDR]], align 8 -// CHECK-NEXT:store i32 [[COND]], i32* [[TMP9]],
[clang] 8f099d1 - [Preprocessor] Fix warning: left and right subexpressions are identical. NFCI.
Author: Michael Kruse Date: 2021-11-05T00:43:40-05:00 New Revision: 8f099d17a1bee857ada3c5af032cfcb559252024 URL: https://github.com/llvm/llvm-project/commit/8f099d17a1bee857ada3c5af032cfcb559252024 DIFF: https://github.com/llvm/llvm-project/commit/8f099d17a1bee857ada3c5af032cfcb559252024.diff LOG: [Preprocessor] Fix warning: left and right subexpressions are identical. NFCI. This is reported by msvc as warning C6287: redundant code: the left and right subexpressions are identical EmittedDirectiveOnThisLine implies EmittedTokensOnThisLine making this an NFC change. To be on the safe side and because both of them are checked at other places as well, we continue to check both. Compiler warning reported here: https://reviews.llvm.org/D104601#2957333 Added: Modified: clang/lib/Frontend/PrintPreprocessedOutput.cpp Removed: diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 360fa1448b128..fadf0c054310d 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -700,7 +700,7 @@ void PrintPPOutputPPCallbacks::HandleWhitespaceBeforeTok(const Token , // - The whitespace is necessary to keep the tokens apart and there is not // already a newline between them if (RequireSpace || (!MinimizeWhitespace && Tok.hasLeadingSpace()) || -((EmittedTokensOnThisLine || EmittedTokensOnThisLine) && +((EmittedTokensOnThisLine || EmittedDirectiveOnThisLine) && AvoidConcat(PrevPrevTok, PrevTok, Tok))) OS << ' '; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1606022 - [Preprocessor] Fix newline before/after _Pragma.
Author: Michael Kruse Date: 2021-11-05T00:43:40-05:00 New Revision: 1606022fab2d90ed8ee6d15800ec1c2c293db20e URL: https://github.com/llvm/llvm-project/commit/1606022fab2d90ed8ee6d15800ec1c2c293db20e DIFF: https://github.com/llvm/llvm-project/commit/1606022fab2d90ed8ee6d15800ec1c2c293db20e.diff LOG: [Preprocessor] Fix newline before/after _Pragma. The PragmaAssumeNonNullHandler (and maybe others) passes an invalid SourceLocation to its callback, hence PrintPreprocessedOutput does not know how many lines to insert between the previous token and the pragma and does nothing. With this patch we instead assume that the unknown token is on the same line as the previous such that we can call the procedure that also emits semantically significant whitespace. Fixes bug reported here: https://reviews.llvm.org/D104601#3105044 Added: clang/test/Preprocessor/_Pragma-newline.c Modified: clang/lib/Frontend/PrintPreprocessedOutput.cpp Removed: diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index fadf0c054310d..45df86ef91cdb 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -188,19 +188,17 @@ class PrintPPOutputPPCallbacks : public PPCallbacks { /// @return Whether column adjustments are necessary. bool MoveToLine(const Token , bool RequireStartOfLine) { PresumedLoc PLoc = SM.getPresumedLoc(Tok.getLocation()); -if (PLoc.isInvalid()) - return false; +unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine; bool IsFirstInFile = Tok.isAtStartOfLine() && PLoc.getLine() == 1; -return MoveToLine(PLoc.getLine(), RequireStartOfLine) || IsFirstInFile; +return MoveToLine(TargetLine, RequireStartOfLine) || IsFirstInFile; } /// Move to the line of the provided source location. Returns true if a new /// line was inserted. bool MoveToLine(SourceLocation Loc, bool RequireStartOfLine) { PresumedLoc PLoc = SM.getPresumedLoc(Loc); -if (PLoc.isInvalid()) - return false; -return MoveToLine(PLoc.getLine(), RequireStartOfLine); +unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine; +return MoveToLine(TargetLine, RequireStartOfLine); } bool MoveToLine(unsigned LineNo, bool RequireStartOfLine); diff --git a/clang/test/Preprocessor/_Pragma-newline.c b/clang/test/Preprocessor/_Pragma-newline.c new file mode 100644 index 0..43628eaef4674 --- /dev/null +++ b/clang/test/Preprocessor/_Pragma-newline.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -E -o - %s | FileCheck %s +// RUN: %clang_cc1 -E -P -o - %s | FileCheck %s +// RUN: %clang_cc1 -E -fminimize-whitespace -o - %s | FileCheck %s +// RUN: %clang_cc1 -E -fminimize-whitespace -P -o - %s | FileCheck %s + +// The PragmaAssumeNonNullHandler (and maybe others) passes an invalid +// SourceLocation when inside a _Pragma. Ensure we still emit semantic +// newlines. +// See report at https://reviews.llvm.org/D104601#3105044 + +_Pragma("clang assume_nonnull begin") test _Pragma("clang assume_nonnull end") + +// CHECK: {{^}}#pragma clang assume_nonnull begin{{$}} +// CHECK: test +// CHECK: {{^}}#pragma clang assume_nonnull end{{$}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2130117 - [Clang][OpenMP] Allow loop-transformations with template parameters.
Author: Michael Kruse Date: 2021-10-06T12:21:04-05:00 New Revision: 2130117f92e51df73ac8c4b7e37f7f89178a89f2 URL: https://github.com/llvm/llvm-project/commit/2130117f92e51df73ac8c4b7e37f7f89178a89f2 DIFF: https://github.com/llvm/llvm-project/commit/2130117f92e51df73ac8c4b7e37f7f89178a89f2.diff LOG: [Clang][OpenMP] Allow loop-transformations with template parameters. Clang would reject #pragma omp for #pragma omp tile sizes(P) for (int i = 0; i < 128; ++i) {} where P is a template parameter, but the loop itself is not template-dependent. Because P context-dependent, the TransformedStmt cannot be generated and therefore is nullptr (until the template is instantiated by TreeTransform). The OMPForDirective would still expect the a loop is the dependent context and trigger an error. Fix by introducing a NumGeneratedLoops field to OMPLoopTransformation. This is used to distinguish the case where no TransformedStmt will be generated at all (e.g. #pragma omp unroll full) and template instantiation is needed. In the latter case, delay resolving the iteration space like when the for-loop itself is template-dependent until the template instatiation. A more radical solution would always delay the iteration space analysis until template instantiation, but would also break many test cases. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D24 Added: Modified: clang/include/clang/AST/StmtOpenMP.h clang/lib/AST/StmtOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/OpenMP/tile_ast_print.cpp clang/test/OpenMP/unroll_ast_print.cpp Removed: diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index 285426d26e21..60d47b93ba79 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -959,6 +959,9 @@ class OMPLoopBasedDirective : public OMPExecutableDirective { class OMPLoopTransformationDirective : public OMPLoopBasedDirective { friend class ASTStmtReader; + /// Number of loops generated by this loop transformation. + unsigned NumGeneratedLoops = 0; + protected: explicit OMPLoopTransformationDirective(StmtClass SC, OpenMPDirectiveKind Kind, @@ -967,10 +970,16 @@ class OMPLoopTransformationDirective : public OMPLoopBasedDirective { unsigned NumAssociatedLoops) : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops) {} + /// Set the number of loops generated by this loop transformation. + void setNumGeneratedLoops(unsigned Num) { NumGeneratedLoops = Num; } + public: /// Return the number of associated (consumed) loops. unsigned getNumAssociatedLoops() const { return getLoopsNumber(); } + /// Return the number of loops generated by this loop transformation. + unsigned getNumGeneratedLoops() { return NumGeneratedLoops; } + /// Get the de-sugared statements after after the loop transformation. /// /// Might be nullptr if either the directive generates no loops and is handled @@ -5058,7 +5067,9 @@ class OMPTileDirective final : public OMPLoopTransformationDirective { unsigned NumLoops) : OMPLoopTransformationDirective(OMPTileDirectiveClass, llvm::omp::OMPD_tile, StartLoc, EndLoc, - NumLoops) {} + NumLoops) { +setNumGeneratedLoops(3 * NumLoops); + } void setPreInits(Stmt *PreInits) { Data->getChildren()[PreInitsOffset] = PreInits; @@ -5163,7 +5174,7 @@ class OMPUnrollDirective final : public OMPLoopTransformationDirective { static OMPUnrollDirective * Create(const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef Clauses, Stmt *AssociatedStmt, - Stmt *TransformedStmt, Stmt *PreInits); + unsigned NumGeneratedLoops, Stmt *TransformedStmt, Stmt *PreInits); /// Build an empty '#pragma omp unroll' AST node for deserialization. /// diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp index c615463f42da..014274f46cae 100644 --- a/clang/lib/AST/StmtOpenMP.cpp +++ b/clang/lib/AST/StmtOpenMP.cpp @@ -138,9 +138,18 @@ bool OMPLoopBasedDirective::doForAllLoops( Stmt *TransformedStmt = Dir->getTransformedStmt(); if (!TransformedStmt) { -// May happen if the loop transformation does not result in a -// generated loop (such as full unrolling). -break; +unsigned NumGeneratedLoops = Dir->getNumGeneratedLoops(); +if (NumGeneratedLoops == 0) { + // May happen if the loop transformation does not result in a + // generated loop (such as full unrolling). +
[clang] f37e8b0 - [Clang][OpenMP] Infix OMPLoopTransformationDirective abstract class. NFC.
Author: Michael Kruse Date: 2021-10-06T10:49:07-05:00 New Revision: f37e8b0b831e61d3b6033829fff05d6d193ab735 URL: https://github.com/llvm/llvm-project/commit/f37e8b0b831e61d3b6033829fff05d6d193ab735 DIFF: https://github.com/llvm/llvm-project/commit/f37e8b0b831e61d3b6033829fff05d6d193ab735.diff LOG: [Clang][OpenMP] Infix OMPLoopTransformationDirective abstract class. NFC. Insert OMPLoopTransformationDirective between OMPLoopBasedDirective and the loop transformations OMPTileDirective and OMPUnrollDirective. This simplifies handling of loop transformations not requiring distinguishing between OMPTileDirective and OMPUnrollDirective anymore. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D19 Added: Modified: clang/include/clang/AST/StmtOpenMP.h clang/include/clang/Basic/StmtNodes.td clang/lib/AST/StmtOpenMP.cpp clang/lib/AST/StmtProfile.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/tools/libclang/CIndex.cpp Removed: diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index f028c3b32398..285426d26e21 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -889,22 +889,23 @@ class OMPLoopBasedDirective : public OMPExecutableDirective { /// Calls the specified callback function for all the loops in \p CurStmt, /// from the outermost to the innermost. - static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, -unsigned NumLoops, -llvm::function_ref Callback, -llvm::function_ref -OnTransformationCallback); + static bool + doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, +unsigned NumLoops, +llvm::function_ref Callback, +llvm::function_ref +OnTransformationCallback); static bool doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, llvm::function_ref Callback, -llvm::function_ref +llvm::function_ref OnTransformationCallback) { auto & = [Callback](unsigned Cnt, Stmt *CurStmt) { return Callback(Cnt, CurStmt); }; auto & = -[OnTransformationCallback](OMPLoopBasedDirective *A) { +[OnTransformationCallback](OMPLoopTransformationDirective *A) { OnTransformationCallback(A); }; return doForAllLoops(const_cast(CurStmt), TryImperfectlyNestedLoops, @@ -917,7 +918,7 @@ class OMPLoopBasedDirective : public OMPExecutableDirective { doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, llvm::function_ref Callback) { -auto & = [](OMPLoopBasedDirective *) {}; +auto & = [](OMPLoopTransformationDirective *) {}; return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, Callback, TransformCb); } @@ -954,6 +955,38 @@ class OMPLoopBasedDirective : public OMPExecutableDirective { } }; +/// The base class for all loop transformation directives. +class OMPLoopTransformationDirective : public OMPLoopBasedDirective { + friend class ASTStmtReader; + +protected: + explicit OMPLoopTransformationDirective(StmtClass SC, + OpenMPDirectiveKind Kind, + SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned NumAssociatedLoops) + : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops) {} + +public: + /// Return the number of associated (consumed) loops. + unsigned getNumAssociatedLoops() const { return getLoopsNumber(); } + + /// Get the de-sugared statements after after the loop transformation. + /// + /// Might be nullptr if either the directive generates no loops and is handled + /// directly in CodeGen, or resolving a template-dependence context is + /// required. + Stmt *getTransformedStmt() const; + + /// Return preinits statement. + Stmt *getPreInits() const; + + static bool classof(const Stmt *T) { +return T->getStmtClass() == OMPTileDirectiveClass || + T->getStmtClass() == OMPUnrollDirectiveClass; + } +}; + /// This is a common base class for loop directives ('omp simd', 'omp /// for', 'omp for simd' etc.). It is responsible for the loop code generation. /// @@ -5011,7 +5044,7 @@ class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective { }; /// This represents the '#pragma omp tile' loop transformation directive.
[clang] 666906a - [test] Fix indention. NFC.
Author: Michael Kruse Date: 2021-08-25T12:48:59-05:00 New Revision: 666906a8032709e59ca6c9fb7b7a5e05cafbd3bf URL: https://github.com/llvm/llvm-project/commit/666906a8032709e59ca6c9fb7b7a5e05cafbd3bf DIFF: https://github.com/llvm/llvm-project/commit/666906a8032709e59ca6c9fb7b7a5e05cafbd3bf.diff LOG: [test] Fix indention. NFC. Added: Modified: clang/test/Preprocessor/skip-empty-lines.c Removed: diff --git a/clang/test/Preprocessor/skip-empty-lines.c b/clang/test/Preprocessor/skip-empty-lines.c index 6d248d748e29..3f3915ec927b 100644 --- a/clang/test/Preprocessor/skip-empty-lines.c +++ b/clang/test/Preprocessor/skip-empty-lines.c @@ -20,7 +20,7 @@ more than 8 empty lines // Check behavior after varying number of lines without emitted tokens. -// LINEMARKERS: {{^}}# 1 "{{.*}}skip-empty-lines.c" 2 +// LINEMARKERS: {{^}}# 1 "{{.*}}skip-empty-lines.c" 2 // LINEMARKERS-NEXT: {{^}} int a ; // LINEMARKERS-NEXT: {{^}} int b ; // LINEMARKERS-EMPTY: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 66e37c9 - [Preprocessor] Elide empty line(s) at start of file.
Author: Michael Kruse Date: 2021-08-25T12:48:59-05:00 New Revision: 66e37c99ef5d7da1b17b3bbaa4ef05b633a473f7 URL: https://github.com/llvm/llvm-project/commit/66e37c99ef5d7da1b17b3bbaa4ef05b633a473f7 DIFF: https://github.com/llvm/llvm-project/commit/66e37c99ef5d7da1b17b3bbaa4ef05b633a473f7.diff LOG: [Preprocessor] Elide empty line(s) at start of file. In -P mode, PrintPPOutputPPCallbacks::MoveToLine started at least one newline if current and target line number mismatched. The method is also called when entering a new file, be it the main file or an include file. In this situation line numbers always almost mismatch, resulting in a newline for each occurance even if no tokens have been printed in-between. Empty lines at the beginning of the output must be trimmed because it may be parsed by scripts expecting the result to appear on the first output line, as done by LibreOffice's configure script. Fix by only emitting a newline if tokens have been printed so far using the EmittedTokensOnThisLine flag. Also adding a test case of FileChanged callbacks occuring with empty include files. This fixes llvm.org/PR51616 Added: clang/test/Preprocessor/print_empty_include.c clang/test/Preprocessor/print_empty_include.h Modified: clang/lib/Frontend/PrintPreprocessedOutput.cpp clang/test/Preprocessor/print_line_track.c Removed: diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 5c5fc751179d1..3a3b158aafdb7 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -293,7 +293,7 @@ bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo, WriteLineInfo(LineNo, nullptr, 0); } StartedNewLine = true; - } else if (!StartedNewLine) { + } else if (EmittedTokensOnThisLine) { // If we are not on the correct line and don't need to be line-correct, // at least ensure we start on a new line. OS << '\n'; diff --git a/clang/test/Preprocessor/print_empty_include.c b/clang/test/Preprocessor/print_empty_include.c new file mode 100644 index 0..04cda99223fed --- /dev/null +++ b/clang/test/Preprocessor/print_empty_include.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -E -P %s | count 1 +// Ensure no superfluous newlines are printed +// llvm.org/PR51616 + +#include "print_empty_include.h" +#include "print_empty_include.h" + +#define EXPANDED_TO_NOTHING +EXPANDED_TO_NOTHING + diff --git a/clang/test/Preprocessor/print_empty_include.h b/clang/test/Preprocessor/print_empty_include.h new file mode 100644 index 0..34b07013ed6d2 --- /dev/null +++ b/clang/test/Preprocessor/print_empty_include.h @@ -0,0 +1,4 @@ +#if 0 +intentionally empty +#endif + diff --git a/clang/test/Preprocessor/print_line_track.c b/clang/test/Preprocessor/print_line_track.c index fb2ccf270e242..156ae22693b85 100644 --- a/clang/test/Preprocessor/print_line_track.c +++ b/clang/test/Preprocessor/print_line_track.c @@ -3,7 +3,7 @@ * RUN: %clang_cc1 -E -P %s | grep 'a 3' * RUN: %clang_cc1 -E -P %s | grep 'b 16' * RUN: %clang_cc1 -E %s | not grep '# 0 ' - * RUN: %clang_cc1 -E -P %s | count 4 + * RUN: %clang_cc1 -E -P %s | count 2 * PR1848 PR3437 PR7360 */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b1de32d - [OMPIRBuilder] Clarify CanonicalLoopInfo. NFC.
Author: Michael Kruse Date: 2021-08-12T21:02:19-05:00 New Revision: b1de32d6ddd90046171ecee0047fbf448a97e16f URL: https://github.com/llvm/llvm-project/commit/b1de32d6ddd90046171ecee0047fbf448a97e16f DIFF: https://github.com/llvm/llvm-project/commit/b1de32d6ddd90046171ecee0047fbf448a97e16f.diff LOG: [OMPIRBuilder] Clarify CanonicalLoopInfo. NFC. Add in-source documentation on how CanonicalLoopInfo is intended to be used. In particular, clarify what parts of a CanonicalLoopInfo is considered part of the loop, that those parts must be side-effect free, and that InsertPoints to instructions outside those parts can be expected to be preserved after method calls implementing loop-associated directives. CanonicalLoopInfo are now invalidated after it does not describe canonical loop anymore and asserts when trying to use it afterwards. In addition, rename `createXYZWorkshareLoop` to `applyXYZWorkshareLoop` and remove the update location to avoid that the impression that they insert something from scratch at that location where in reality its InsertPoint is ignored. createStaticWorkshareLoop does not return a CanonicalLoopInfo anymore. First, it was not a canonical loop in the clarified sense (containing side-effects in form of calls to the OpenMP runtime). Second, it is ambiguous which of the two possible canonical loops it should actually return. It will not be needed before a feature expected to be introduced in OpenMP 6.0 Also see discussion in D105706. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D107540 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp Removed: diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index f71f7b24a36ae..2328dd8198426 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3621,7 +3621,8 @@ void CodeGenFunction::EmitOMPForDirective(const OMPForDirective ) { CGM.getOpenMPRuntime().getOMPBuilder(); llvm::OpenMPIRBuilder::InsertPointTy AllocaIP( AllocaInsertPt->getParent(), AllocaInsertPt->getIterator()); - OMPBuilder.createWorkshareLoop(Builder, CLI, AllocaIP, NeedsBarrier); + OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI, +AllocaIP, NeedsBarrier); return; } diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h index ef4e387ec8edc..9e242b04cc6a5 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -257,18 +257,17 @@ class OpenMPIRBuilder { /// /// * Sign of the step and the comparison operator might disagree: /// - /// for (int i = 0; i < 42; --i) + /// for (int i = 0; i < 42; i -= 1u) /// // /// \param Loc The insert and source location description. /// \param BodyGenCB Callback that will generate the loop body code. /// \param Start Value of the loop counter for the first iterations. - /// \param Stop Loop counter values past this will stop the the - /// iterations. + /// \param Stop Loop counter values past this will stop the loop. /// \param Step Loop counter increment after each iteration; negative - /// means counting down. \param IsSigned Whether Start, Stop - /// and Stop are signed integers. - /// \param InclusiveStop Whether \p Stop itself is a valid value for the loop + /// means counting down. + /// \param IsSigned Whether Start, Stop and Step are signed integers. + /// \param InclusiveStop Whether \p Stop itself is a valid value for the loop /// counter. /// \param ComputeIP Insertion point for instructions computing the trip /// count. Can be used to ensure the trip count is available @@ -335,7 +334,7 @@ class OpenMPIRBuilder { ///has a trip count of 0). This is permitted by the OpenMP specification. /// /// \param DLDebug location for instructions added for collapsing, - /// such as instructions to compute derive the input loop's + /// such as instructions to compute/derive the input loop's /// induction variables. /// \param Loops Loops in the loop nest to collapse. Loops are specified /// from outermost-to-innermost and every control flow of a @@ -358,8 +357,16 @@ class OpenMPIRBuilder { /// the current thread, updates the relevant instructions in the canonical /// loop and calls to an OpenMP
[clang] ba2be8d - [clang/OpenMP][docs] Update OpenMP support list for unroll.
Author: Michael Kruse Date: 2021-08-03T18:11:17-05:00 New Revision: ba2be8deba79f1aa64a86019e78bcd2536b14eb5 URL: https://github.com/llvm/llvm-project/commit/ba2be8deba79f1aa64a86019e78bcd2536b14eb5 DIFF: https://github.com/llvm/llvm-project/commit/ba2be8deba79f1aa64a86019e78bcd2536b14eb5.diff LOG: [clang/OpenMP][docs] Update OpenMP support list for unroll. Added: Modified: clang/docs/OpenMPSupport.rst Removed: diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 88d3107c21e7..7291a5cfc5a0 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -302,7 +302,7 @@ want to help with the implementation. +--+--+--+---+ | loop extension | Loop tiling transformation | :good:`done` | D76342 | +--+--+--+---+ -| loop extension | Loop unrolling transformation | :none:`worked on`| | +| loop extension | Loop unrolling transformation | :good:`done` | D99459 | +--+--+--+---+ | loop extension | 'reproducible'/'unconstrained' modifiers in 'order' clause | :none:`unclaimed`| | +--+--+--+---+ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0e25867 - [Preprocessor] Ensure newline after #pragma introduced by -fms-extensions.
Author: Michael Kruse Date: 2021-08-01T19:08:13-05:00 New Revision: 0e2586779ca6606a3df085f253a31b89b8ad8508 URL: https://github.com/llvm/llvm-project/commit/0e2586779ca6606a3df085f253a31b89b8ad8508 DIFF: https://github.com/llvm/llvm-project/commit/0e2586779ca6606a3df085f253a31b89b8ad8508.diff LOG: [Preprocessor] Ensure newline after #pragma introduced by -fms-extensions. The -fms-extensions converts __pragma (and _Pragma) into a #pragma that has to occur at the beginning of a line and end with a newline. This patch ensures that the newline after the #pragma is added even if Token::isAtStartOfLine() indicated that we should not start a newline. Committing relying post-commit review since the change is small, some downstream uses might be blocked without this fix, and to make clear the decision of the new -fminimize-whitespace feature (fix on main, revert on clang-13.x branch) suggested by @aaron.ballman in D104601. Differential Revision: https://reviews.llvm.org/D107183 Added: clang/test/Preprocessor/whitespace-ms-extensions.c Modified: clang/lib/Frontend/PrintPreprocessedOutput.cpp Removed: diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 1759485de24db..1a820ad985a4c 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -646,7 +646,9 @@ void PrintPPOutputPPCallbacks::HandleWhitespaceBeforeTok(const Token , !Tok.is(tok::annot_module_begin) && !Tok.is(tok::annot_module_end))) return; - if (!RequireSameLine && MoveToLine(Tok, /*RequireStartOfLine=*/false)) { + // EmittedDirectiveOnThisLine takes priority over RequireSameLine. + if ((!RequireSameLine || EmittedDirectiveOnThisLine) && + MoveToLine(Tok, /*RequireStartOfLine=*/EmittedDirectiveOnThisLine)) { if (MinimizeWhitespace) { // Avoid interpreting hash as a directive under -fpreprocessed. if (Tok.is(tok::hash)) diff --git a/clang/test/Preprocessor/whitespace-ms-extensions.c b/clang/test/Preprocessor/whitespace-ms-extensions.c new file mode 100644 index 0..5fd34fbc6a819 --- /dev/null +++ b/clang/test/Preprocessor/whitespace-ms-extensions.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s +// RUN: %clang_cc1 -E -P -fms-extensions %s -o - | FileCheck %s --check-prefix=MSEXT + +// -fms-extensions changes __pragma into #pragma +// Ensure that there is a newline after the #pragma line. + +#define MACRO\ +text \ +__pragma(PRAGMA) \ +after + +before MACRO text + + +// CHECK: before text __pragma(PRAGMA) after text + +// MSEXT: before text +// MSEXT-NEXT: #pragma PRAGMA +// MSEXT-NEXT: after text ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c6b0b16 - [Preprocessor] -E -P: Ensure newline after 8 skipped lines.
Author: Michael Kruse Date: 2021-07-28T22:50:54-05:00 New Revision: c6b0b16c0f55c34f4eaa05184815bbbe97f4b750 URL: https://github.com/llvm/llvm-project/commit/c6b0b16c0f55c34f4eaa05184815bbbe97f4b750 DIFF: https://github.com/llvm/llvm-project/commit/c6b0b16c0f55c34f4eaa05184815bbbe97f4b750.diff LOG: [Preprocessor] -E -P: Ensure newline after 8 skipped lines. The implementation of -fminimize-whitespace (D104601) revised the logic when to emit newlines. There was no case to handle when more than 8 lines were skippped in -P (DisableLineMarkers) mode and instead fell through the case intended for -fminimize-whitespace, i.e. emit nothing. This patch will emit one newline in this case. The newline logic is slightly reorganized. The `-P -fminimize-whitespace` case is handled explicitly and emitting at least one newline is the new fallback case. The choice between emitting a line marker or up to 7 empty lines is now a choice only with enabled line markers. The up to 8 newlines likely are fewer characters than a line directive, but in -P mode this had the paradoxic effect that it would print up to 7 empty lines, but none at all if more than 8 lines had to be skipped. Now with DisableLineMarkers, we don't consider printing empty lines (just start a new line) which matches gcc's behavior. The line-directive-output-mincol.c test is replaced with a more comprehensive test skip-empty-lines.c also testing the more than 8 skipped lines behaviour with all flag combinations. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D106924 Added: clang/test/Preprocessor/skip-empty-lines.c Modified: clang/lib/Frontend/PrintPreprocessedOutput.cpp clang/test/Preprocessor/minimize-whitespace.c Removed: clang/test/Preprocessor/line-directive-output-mincol.c diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index b7259569595d6..1759485de24db 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -276,20 +276,27 @@ bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo, // otherwise print a #line directive. if (CurLine == LineNo) { // Nothing to do if we are already on the correct line. - } else if (!StartedNewLine && (!MinimizeWhitespace || !DisableLineMarkers) && - LineNo - CurLine == 1) { + } else if (MinimizeWhitespace && DisableLineMarkers) { +// With -E -P -fminimize-whitespace, don't emit anything if not necessary. + } else if (!StartedNewLine && LineNo - CurLine == 1) { // Printing a single line has priority over printing a #line directive, even // when minimizing whitespace which otherwise would print #line directives // for every single line. OS << '\n'; StartedNewLine = true; - } else if (!MinimizeWhitespace && LineNo - CurLine <= 8) { -const char *NewLines = "\n\n\n\n\n\n\n\n"; -OS.write(NewLines, LineNo - CurLine); -StartedNewLine = true; } else if (!DisableLineMarkers) { -// Emit a #line or line marker. -WriteLineInfo(LineNo, nullptr, 0); +if (LineNo - CurLine <= 8) { + const char *NewLines = "\n\n\n\n\n\n\n\n"; + OS.write(NewLines, LineNo - CurLine); +} else { + // Emit a #line or line marker. + WriteLineInfo(LineNo, nullptr, 0); +} +StartedNewLine = true; + } else if (!StartedNewLine) { +// If we are not on the correct line and don't need to be line-correct, +// at least ensure we start on a new line. +OS << '\n'; StartedNewLine = true; } diff --git a/clang/test/Preprocessor/line-directive-output-mincol.c b/clang/test/Preprocessor/line-directive-output-mincol.c deleted file mode 100644 index 0f2466ebee971..0 --- a/clang/test/Preprocessor/line-directive-output-mincol.c +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -E -fminimize-whitespace %s 2>&1 | FileCheck %s -strict-whitespace - -// CHECK: # 6 "{{.*}}line-directive-output-mincol.c" -// CHECK-NEXT: int x; -// CHECK-NEXT: int y; -int x; -int y; -// CHECK-NEXT: # 10 "{{.*}}line-directive-output-mincol.c" -// CHECK-NEXT: int z; -int z; - diff --git a/clang/test/Preprocessor/minimize-whitespace.c b/clang/test/Preprocessor/minimize-whitespace.c index 3608e318dc135..137efe8393795 100644 --- a/clang/test/Preprocessor/minimize-whitespace.c +++ b/clang/test/Preprocessor/minimize-whitespace.c @@ -2,6 +2,12 @@ // RUN: %clang_cc1 -fminimize-whitespace -E -C %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINCCOL // RUN: %clang_cc1 -fminimize-whitespace -E -P %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINWS // RUN: %clang_cc1 -fminimize-whitespace -E -C -P %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINCWS +// The follow empty lines ensure that a #line directive is emitted instead of newline padding after the RUN
[clang] ae6b400 - [Preprocessor] Implement -fminimize-whitespace.
Author: Michael Kruse Date: 2021-07-25T23:30:57-05:00 New Revision: ae6b4238e5f319ffcfc713a15e459be8 URL: https://github.com/llvm/llvm-project/commit/ae6b4238e5f319ffcfc713a15e459be8 DIFF: https://github.com/llvm/llvm-project/commit/ae6b4238e5f319ffcfc713a15e459be8.diff LOG: [Preprocessor] Implement -fminimize-whitespace. This patch adds the -fminimize-whitespace with the following effects: * If combined with -E, remove as much non-line-breaking whitespace as possible. * If combined with -E -P, removes as much whitespace as possible, including line-breaks. The motivation is to reduce the amount of insignificant changes in the preprocessed output with source files where only whitespace has been changed (add/remove comments, clang-format, etc.) which is in particular useful with ccache. A patch for ccache for using this flag has been proposed to ccache as well: https://github.com/ccache/ccache/pull/815, which will use -fnormalize-whitespace when clang-13 has been detected, and additionally uses -P in "unify_mode". ccache already had a unify_mode in an older version which was removed because of problems that using the preprocessor itself does not have (such that the custom tokenizer did not recognize C++11 raw strings). This patch slightly reorganizes which part is responsible for adding newlines that are required for semantics. It is now either startNewLineIfNeeded() or MoveToLine() but never both; this avoids the ShouldUpdateCurrentLine workaround and avoids redundant lines being inserted in some cases. It also fixes a mandatory newline not inserted after a _Pragma("...") that is expanded into a #pragma. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104601 Added: clang/test/Preprocessor/line-directive-output-mincol.c clang/test/Preprocessor/minimize-whitespace-messages.c clang/test/Preprocessor/minimize-whitespace.c Modified: clang/docs/ClangCommandLineReference.rst clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/include/clang/Driver/Types.h clang/include/clang/Frontend/PreprocessorOutputOptions.h clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/Types.cpp clang/lib/Frontend/PrintPreprocessedOutput.cpp clang/lib/Lex/Preprocessor.cpp clang/test/Preprocessor/comment_save.c clang/test/Preprocessor/first-line-indent.c clang/test/Preprocessor/hash_line.c clang/test/Preprocessor/line-directive-output.c clang/test/Preprocessor/macro_space.c clang/test/Preprocessor/print_line_include.c clang/test/Preprocessor/stringize_space.c Removed: diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 74557c5bd581..35a3fdd382b4 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -2475,6 +2475,16 @@ Turn on loop unroller Use #line in preprocessed output +.. option:: -fminimize-whitespace, -fno-minimize-whitespace + +Ignore the whitespace from the input file when emitting preprocessor +output. It will only contain whitespace when necessary, e.g. to keep two +minus signs from merging into to an increment operator. Useful with the +-P option to normalize whitespace such that two files with only formatting +changes are equal. + +Only valid with -E on C-like inputs and incompatible with -traditional-cpp. + .. option:: -fvalidate-ast-input-files-content Compute and store the hash of input files used to build an AST. Files with mismatching mtime's are considered valid if both contents is identical diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index fc3704303a95..3b4daa59f66b 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -129,6 +129,8 @@ def err_drv_invalid_Xopenmp_target_with_args : Error< "invalid -Xopenmp-target argument: '%0', options requiring arguments are unsupported">; def err_drv_argument_only_allowed_with : Error< "invalid argument '%0' only allowed with '%1'">; +def err_drv_minws_unsupported_input_type : Error< + "'-fminimize-whitespace' invalid for input of type %0">; def err_drv_amdgpu_ieee_without_no_honor_nans : Error< "invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN handling">; def err_drv_argument_not_allowed_with : Error< diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1815cd4621e8..991408c0e2a1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1799,6 +1799,9 @@ def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">, defm use_line_directives : BoolFOption<"use-line-directives", PreprocessorOutputOpts<"UseLineDirectives">,
[clang] c41a8fb - [Clang][OpenMP] Refactor checking for mutually exclusive clauses. NFC.
Author: Michael Kruse Date: 2021-06-06T09:49:46-05:00 New Revision: c41a8fbfbb096995367947e5ef7d36501b04d493 URL: https://github.com/llvm/llvm-project/commit/c41a8fbfbb096995367947e5ef7d36501b04d493 DIFF: https://github.com/llvm/llvm-project/commit/c41a8fbfbb096995367947e5ef7d36501b04d493.diff LOG: [Clang][OpenMP] Refactor checking for mutually exclusive clauses. NFC. Multiple clauses are mutually exclusive. This patch refactors the functions that check for pairs of mutually exclusive clauses into a generalized function which also also accepts a list of clause types if which at most one can appear. NFC patch extracted out of D99459 by request. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D103666 Added: Modified: clang/lib/Sema/SemaOpenMP.cpp Removed: diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 514b3b9ed05fe..aae84bf3b35c3 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -10121,14 +10121,14 @@ Sema::ActOnOpenMPParallelSectionsDirective(ArrayRef Clauses, DSAStack->getTaskgroupReductionRef(), DSAStack->isCancelRegion()); } -/// detach and mergeable clauses are mutially exclusive, check for it. -static bool checkDetachMergeableClauses(Sema , -ArrayRef Clauses) { +/// Find and diagnose mutually exclusive clause kinds. +static bool checkMutuallyExclusiveClauses( +Sema , ArrayRef Clauses, +ArrayRef MutuallyExclusiveClauses) { const OMPClause *PrevClause = nullptr; bool ErrorFound = false; for (const OMPClause *C : Clauses) { -if (C->getClauseKind() == OMPC_detach || -C->getClauseKind() == OMPC_mergeable) { +if (llvm::is_contained(MutuallyExclusiveClauses, C->getClauseKind())) { if (!PrevClause) { PrevClause = C; } else if (PrevClause->getClauseKind() != C->getClauseKind()) { @@ -10153,7 +10153,8 @@ StmtResult Sema::ActOnOpenMPTaskDirective(ArrayRef Clauses, // OpenMP 5.0, 2.10.1 task Construct // If a detach clause appears on the directive, then a mergeable clause cannot // appear on the same directive. - if (checkDetachMergeableClauses(*this, Clauses)) + if (checkMutuallyExclusiveClauses(*this, Clauses, +{OMPC_detach, OMPC_mergeable})) return StmtError(); auto *CS = cast(AStmt); @@ -11457,28 +11458,6 @@ StmtResult Sema::ActOnOpenMPCancelDirective(ArrayRef Clauses, CancelRegion); } -static bool checkGrainsizeNumTasksClauses(Sema , - ArrayRef Clauses) { - const OMPClause *PrevClause = nullptr; - bool ErrorFound = false; - for (const OMPClause *C : Clauses) { -if (C->getClauseKind() == OMPC_grainsize || -C->getClauseKind() == OMPC_num_tasks) { - if (!PrevClause) -PrevClause = C; - else if (PrevClause->getClauseKind() != C->getClauseKind()) { -S.Diag(C->getBeginLoc(), diag::err_omp_clauses_mutually_exclusive) -<< getOpenMPClauseName(C->getClauseKind()) -<< getOpenMPClauseName(PrevClause->getClauseKind()); -S.Diag(PrevClause->getBeginLoc(), diag::note_omp_previous_clause) -<< getOpenMPClauseName(PrevClause->getClauseKind()); -ErrorFound = true; - } -} - } - return ErrorFound; -} - static bool checkReductionClauseWithNogroup(Sema , ArrayRef Clauses) { const OMPClause *ReductionClause = nullptr; @@ -11529,7 +11508,8 @@ StmtResult Sema::ActOnOpenMPTaskLoopDirective( // OpenMP, [2.9.2 taskloop Construct, Restrictions] // The grainsize clause and num_tasks clause are mutually exclusive and may // not appear on the same taskloop directive. - if (checkGrainsizeNumTasksClauses(*this, Clauses)) + if (checkMutuallyExclusiveClauses(*this, Clauses, +{OMPC_grainsize, OMPC_num_tasks})) return StmtError(); // OpenMP, [2.9.2 taskloop Construct, Restrictions] // If a reduction clause is present on the taskloop directive, the nogroup @@ -11577,7 +11557,8 @@ StmtResult Sema::ActOnOpenMPTaskLoopSimdDirective( // OpenMP, [2.9.2 taskloop Construct, Restrictions] // The grainsize clause and num_tasks clause are mutually exclusive and may // not appear on the same taskloop directive. - if (checkGrainsizeNumTasksClauses(*this, Clauses)) + if (checkMutuallyExclusiveClauses(*this, Clauses, +{OMPC_grainsize, OMPC_num_tasks})) return StmtError(); // OpenMP, [2.9.2 taskloop Construct, Restrictions] // If a reduction clause is present on the taskloop directive, the nogroup @@ -11615,7 +11596,8 @@ StmtResult Sema::ActOnOpenMPMasterTaskLoopDirective( // OpenMP, [2.9.2 taskloop Construct, Restrictions] // The grainsize clause and
[clang] d466ca0 - [Clang][OpenMP] Add static version of getSingleClause. NFC.
Author: Michael Kruse Date: 2021-06-06T09:17:42-05:00 New Revision: d466ca087aae958d1c0a965c561be07d2cb3e7e2 URL: https://github.com/llvm/llvm-project/commit/d466ca087aae958d1c0a965c561be07d2cb3e7e2 DIFF: https://github.com/llvm/llvm-project/commit/d466ca087aae958d1c0a965c561be07d2cb3e7e2.diff LOG: [Clang][OpenMP] Add static version of getSingleClause. NFC. The current method getSingleClause requires an instance of OMPExecutableDirective to be called. Introduce a static version taking a list of clauses as argument instead that can be used during parsing/Sema before any OMPExecutableDirective has been created. This is the same approach as taken for getClausesOfKind for getting more more than a single clause of a type which also has a method and static version. NFC patch extracted out of D99459 by request. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D103665 Added: Modified: clang/include/clang/AST/StmtOpenMP.h Removed: diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index 4d6774c1ad280..67ba77a5d1b06 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -460,17 +460,22 @@ class OMPExecutableDirective : public Stmt { /// directive). Returns nullptr if no clause of this kind is associated with /// the directive. template - const SpecificClause *getSingleClause() const { -auto Clauses = getClausesOfKind(); + static const SpecificClause *getSingleClause(ArrayRef Clauses) { +auto ClausesOfKind = getClausesOfKind(Clauses); -if (Clauses.begin() != Clauses.end()) { - assert(std::next(Clauses.begin()) == Clauses.end() && +if (ClausesOfKind.begin() != ClausesOfKind.end()) { + assert(std::next(ClausesOfKind.begin()) == ClausesOfKind.end() && "There are at least 2 clauses of the specified kind"); - return *Clauses.begin(); + return *ClausesOfKind.begin(); } return nullptr; } + template + const SpecificClause *getSingleClause() const { +return getSingleClause(clauses()); + } + /// Returns true if the current directive has one or more clauses of a /// specific kind. template ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 64e5a3b - [clang] Fix fail of OpenMP/tile_codegen_tile_for.cpp.
Author: Michael Kruse Date: 2021-06-02T21:02:05-05:00 New Revision: 64e5a3bbdde25af0fd9f2b9b8539e23f36c80601 URL: https://github.com/llvm/llvm-project/commit/64e5a3bbdde25af0fd9f2b9b8539e23f36c80601 DIFF: https://github.com/llvm/llvm-project/commit/64e5a3bbdde25af0fd9f2b9b8539e23f36c80601.diff LOG: [clang] Fix fail of OpenMP/tile_codegen_tile_for.cpp. Clang's version string can be customized using CLANG_VENDOR which the test did not consider. Change the test to accept any version string. Added: Modified: clang/test/OpenMP/tile_codegen_tile_for.cpp Removed: diff --git a/clang/test/OpenMP/tile_codegen_tile_for.cpp b/clang/test/OpenMP/tile_codegen_tile_for.cpp index 314446ca203bf..e4e5548b2f933 100644 --- a/clang/test/OpenMP/tile_codegen_tile_for.cpp +++ b/clang/test/OpenMP/tile_codegen_tile_for.cpp @@ -247,7 +247,7 @@ extern "C" void func(int start, int end, int step) { #endif /* HEADER */ // IR: ![[META0:[0-9]+]] = !{i32 1, !"wchar_size", i32 4} -// IR: ![[META1:[0-9]+]] = !{!"clang version {{[^"]*}}"} +// IR: ![[META1:[0-9]+]] = !{!"{{[^"]*}}"} // IR: ![[LOOP2]] = distinct !{![[LOOP2]], ![[LOOPPROP3:[0-9]+]]} // IR: ![[LOOPPROP3]] = !{!"llvm.loop.mustprogress"} // IR: ![[LOOP4]] = distinct !{![[LOOP4]], ![[LOOPPROP3]]} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 07a6beb - [Clang][OpenMP] Emit dependent PreInits before directive.
Author: Michael Kruse Date: 2021-06-02T16:59:35-05:00 New Revision: 07a6beb402150d25ec7c93a5747520ac2804731d URL: https://github.com/llvm/llvm-project/commit/07a6beb402150d25ec7c93a5747520ac2804731d DIFF: https://github.com/llvm/llvm-project/commit/07a6beb402150d25ec7c93a5747520ac2804731d.diff LOG: [Clang][OpenMP] Emit dependent PreInits before directive. The PreInits of a loop transformation (atm moment only tile) include the computation of the trip count. The trip count is needed by any loop-associated directives that consumes the transformation-generated loop. Hence, we must ensure that the PreInits of consumed loop transformations are emitted with the consuming directive. This is done by addinging the inner loop transformation's PreInits to the outer loop-directive's PreInits. The outer loop-directive will consume the de-sugared AST such that the inner PreInits are not emitted twice. The PreInits of a loop transformation are still emitted directly if its generated loop(s) are not associated with another loop-associated directive. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D102180 Added: clang/test/OpenMP/tile_codegen_for_dependent.cpp clang/test/OpenMP/tile_codegen_tile_for.cpp Modified: clang/include/clang/AST/StmtOpenMP.h clang/lib/AST/StmtOpenMP.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/tile_codegen.cpp Removed: diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index 4d14848830fa7..4d6774c1ad280 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -882,17 +882,45 @@ class OMPLoopBasedDirective : public OMPExecutableDirective { TryImperfectlyNestedLoops); } + /// Calls the specified callback function for all the loops in \p CurStmt, + /// from the outermost to the innermost. + static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, +unsigned NumLoops, +llvm::function_ref Callback, +llvm::function_ref +OnTransformationCallback); + static bool + doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops, +unsigned NumLoops, +llvm::function_ref Callback, +llvm::function_ref +OnTransformationCallback) { +auto & = [Callback](unsigned Cnt, Stmt *CurStmt) { + return Callback(Cnt, CurStmt); +}; +auto & = +[OnTransformationCallback](OMPLoopBasedDirective *A) { + OnTransformationCallback(A); +}; +return doForAllLoops(const_cast(CurStmt), TryImperfectlyNestedLoops, + NumLoops, NewCallback, NewTransformCb); + } + /// Calls the specified callback function for all the loops in \p CurStmt, /// from the outermost to the innermost. static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, -llvm::function_ref Callback); +llvm::function_ref Callback) { +auto & = [](OMPLoopBasedDirective *) {}; +return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, Callback, + TransformCb); + } static bool doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, llvm::function_ref Callback) { -auto & = [Callback](unsigned Cnt, Stmt *CurStmt) { +auto & = [Callback](unsigned Cnt, const Stmt *CurStmt) { return Callback(Cnt, CurStmt); }; return doForAllLoops(const_cast(CurStmt), TryImperfectlyNestedLoops, diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp index a9905949d7afa..dbb11e77ac51e 100644 --- a/clang/lib/AST/StmtOpenMP.cpp +++ b/clang/lib/AST/StmtOpenMP.cpp @@ -124,11 +124,15 @@ OMPLoopBasedDirective::tryToFindNextInnerLoop(Stmt *CurStmt, bool OMPLoopBasedDirective::doForAllLoops( Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, -llvm::function_ref Callback) { +llvm::function_ref Callback, +llvm::function_ref +OnTransformationCallback) { CurStmt = CurStmt->IgnoreContainers(); for (unsigned Cnt = 0; Cnt < NumLoops; ++Cnt) { -if (auto *Dir = dyn_cast(CurStmt)) +while (auto *Dir = dyn_cast(CurStmt)) { + OnTransformationCallback(Dir); CurStmt = Dir->getTransformedStmt(); +} if (auto *CanonLoop = dyn_cast(CurStmt)) CurStmt = CanonLoop->getLoopStmt(); if (Callback(Cnt, CurStmt)) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 344fa90253ec3..a03cbffc8e8f1 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++
[clang] 83ff0ff - [Clang][OpenMP] Allow unified_shared_memory for Pascal-generation GPUs.
Author: Michael Kruse Date: 2021-05-13T17:15:34-05:00 New Revision: 83ff0ff46337422171fb36f934bd56c2bc1be15c URL: https://github.com/llvm/llvm-project/commit/83ff0ff46337422171fb36f934bd56c2bc1be15c DIFF: https://github.com/llvm/llvm-project/commit/83ff0ff46337422171fb36f934bd56c2bc1be15c.diff LOG: [Clang][OpenMP] Allow unified_shared_memory for Pascal-generation GPUs. The Pascal architecture supports the page migration engine required for unified_shared_memory, as indicated by NVIDIA: * https://developer.nvidia.com/blog/unified-memory-cuda-beginners/ * https://developer.nvidia.com/blog/beyond-gpu-memory-limits-unified-memory-pascal/ * https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#um-requirements The limitation was introduced in D54493 which justified the cut-off by the requirement for unified addressing. However, Unified Virtual Addressing (UVA) is already available with sm20 (Fermi, Kepler, Maxwell): * https://docs.nvidia.com/cuda/gpudirect-rdma/index.html#basics-of-uva-cuda-memory-management Unified shared memory might even be possible with these, but with migration of entire allocations on kernel startup. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D101595 Added: Modified: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp clang/test/OpenMP/requires_codegen.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index fd492eaf705d0..2ceb3a4cd5ab6 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -4441,10 +4441,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective( case CudaArch::SM_37: case CudaArch::SM_50: case CudaArch::SM_52: - case CudaArch::SM_53: - case CudaArch::SM_60: - case CudaArch::SM_61: - case CudaArch::SM_62: { + case CudaArch::SM_53: { SmallString<256> Buffer; llvm::raw_svector_ostream Out(Buffer); Out << "Target architecture " << CudaArchToString(Arch) @@ -4452,6 +4449,9 @@ void CGOpenMPRuntimeGPU::processRequiresDirective( CGM.Error(Clause->getBeginLoc(), Out.str()); return; } + case CudaArch::SM_60: + case CudaArch::SM_61: + case CudaArch::SM_62: case CudaArch::SM_70: case CudaArch::SM_72: case CudaArch::SM_75: diff --git a/clang/test/OpenMP/requires_codegen.cpp b/clang/test/OpenMP/requires_codegen.cpp index 84821e89ed24f..1029a865b92a2 100644 --- a/clang/test/OpenMP/requires_codegen.cpp +++ b/clang/test/OpenMP/requires_codegen.cpp @@ -8,9 +8,9 @@ // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_50 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_52 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_53 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE -// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_60 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE -// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_61 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE -// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_62 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_60 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE_NO_ERR +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_61 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE_NO_ERR +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_62 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE_NO_ERR // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_70 -emit-llvm %s
[clang] 4b15b2d - [clang][OpenMP][docs] Update loop transformation status.
Author: Michael Kruse Date: 2021-03-05T17:26:55-06:00 New Revision: 4b15b2df23389be567814cedcfddc8008c354b3d URL: https://github.com/llvm/llvm-project/commit/4b15b2df23389be567814cedcfddc8008c354b3d DIFF: https://github.com/llvm/llvm-project/commit/4b15b2df23389be567814cedcfddc8008c354b3d.diff LOG: [clang][OpenMP][docs] Update loop transformation status. Mark tiling as done and unrolling as being worked on. Added: Modified: clang/docs/OpenMPSupport.rst Removed: diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index f0d8e8741304..e66d9a64a93f 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -298,9 +298,9 @@ want to help with the implementation. +--+--+--+---+ | device extension | assorted routines for querying interoperable properties | :none:`unclaimed`| | +--+--+--+---+ -| loop extension | Loop tiling transformation | :part:`worked on`| D76342 | +| loop extension | Loop tiling transformation | :good:`done` | D76342 | +--+--+--+---+ -| loop extension | Loop unrolling transformation | :none:`unclaimed`| | +| loop extension | Loop unrolling transformation | :none:`worked on`| | +--+--+--+---+ | loop extension | 'reproducible'/'unconstrained' modifiers in 'order' clause | :none:`unclaimed`| | +--+--+--+---+ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bc172e5 - [clang][StaticAnalyzer] Compilation fix.
Author: Michael Kruse Date: 2021-03-04T23:23:58-06:00 New Revision: bc172e532a89754d47fef1306064a26a4dc0a76b URL: https://github.com/llvm/llvm-project/commit/bc172e532a89754d47fef1306064a26a4dc0a76b DIFF: https://github.com/llvm/llvm-project/commit/bc172e532a89754d47fef1306064a26a4dc0a76b.diff LOG: [clang][StaticAnalyzer] Compilation fix. An enum was unhandled after landing of D94973. Add the new OMPCanonicalLoopClass to the list of unhandled cases. Added: Modified: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 465af24b2899..a388fc9e6e26 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1238,6 +1238,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred, case Stmt::SEHExceptStmtClass: case Stmt::SEHLeaveStmtClass: case Stmt::SEHFinallyStmtClass: +case Stmt::OMPCanonicalLoopClass: case Stmt::OMPParallelDirectiveClass: case Stmt::OMPSimdDirectiveClass: case Stmt::OMPForDirectiveClass: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 74ddacd - [Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.
Author: Malhar Date: 2021-02-13T17:35:54-06:00 New Revision: 74ddacd30de54e19b28218bc8563bd0f34f32cad URL: https://github.com/llvm/llvm-project/commit/74ddacd30de54e19b28218bc8563bd0f34f32cad DIFF: https://github.com/llvm/llvm-project/commit/74ddacd30de54e19b28218bc8563bd0f34f32cad.diff LOG: [Clang] Ensure vector predication loop metadata is always emitted when pragma is specified. This patch ensures that vector predication and vectorization width pragmas work together correctly/as expected. Specifically, this patch fixes the issue that when vectorization_width > 1, the vector predication behaviour (this would matter if it has NOT been disabled explicitly by a pragma) was getting ignored, which was incorrect. The fix here removes the dependence of vector predication on the vectorization width. The loop metadata corresponding to clang loop pragma vectorize_predicate is always emitted, if the pragma is specified, even if vectorization is disabled by vectorize_width(1) or vectorize(disable) since the option is also used for interleaving by the LoopVectorize pass. Reviewed By: dmgreen, Meinersbur Differential Revision: https://reviews.llvm.org/D94779 Added: Modified: clang/lib/CodeGen/CGLoopInfo.cpp clang/test/CodeGenCXX/pragma-loop-predicate.cpp Removed: diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 8ba40599cfaf..12a6cd8da603 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -250,12 +250,10 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes , Args.push_back(nullptr); Args.append(LoopProperties.begin(), LoopProperties.end()); - // Setting vectorize.predicate + // Setting vectorize.predicate when it has been specified and vectorization + // has not been disabled. bool IsVectorPredicateEnabled = false; - if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified && - Attrs.VectorizeEnable != LoopAttributes::Disable && - Attrs.VectorizeWidth < 1) { - + if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified) { IsVectorPredicateEnabled = (Attrs.VectorizePredicateEnable == LoopAttributes::Enable); @@ -303,7 +301,8 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes , //explicitly requested fixed-width vectorization, i.e. //vectorize.scalable.enable is false. if (Attrs.VectorizeEnable != LoopAttributes::Unspecified || - IsVectorPredicateEnabled || Attrs.VectorizeWidth > 1 || + (IsVectorPredicateEnabled && Attrs.VectorizeWidth != 1) || + Attrs.VectorizeWidth > 1 || Attrs.VectorizeScalable == LoopAttributes::Enable || (Attrs.VectorizeScalable == LoopAttributes::Disable && Attrs.VectorizeWidth != 1)) { diff --git a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp index ec8f82ef9b9e..8a25ed8de623 100644 --- a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp @@ -58,6 +58,49 @@ void test5(int *List, int Length) { List[i] = i * 2; } +// Check that vectorize_predicate is ignored when vectorization width is 1 +void test6(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test6{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]] + +#pragma clang loop vectorize_predicate(disable) vectorize_width(1) + for (int i = 0; i < Length; i++) +List[i] = i * 2; +} + + +// Check that vectorize_width(!=1) does not affect vectorize_predicate. +void test7(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test7{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]] + +#pragma clang loop vectorize_predicate(disable) vectorize_width(4) + for (int i = 0; i < Length; i++) +List[i] = i * 2; +} + + +// Check that vectorize_predicate is ignored when vectorization width is 1 +void test8(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test8{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP8:.*]] + +#pragma clang loop vectorize_predicate(enable) vectorize_width(1) + for (int i = 0; i < Length; i++) +List[i] = i * 2; +} + + +// Check that vectorize_width(!=1) does not affect vectorize_predicate. +void test9(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test9{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP9:.*]] + +#pragma clang loop vectorize_predicate(enable) vectorize_width(4) + for (int i = 0; i < Length; i++) +List[i] = i * 2; +} + // CHECK: ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], [[GEN3:![0-9]+]]} // CHECK: [[MP]] = !{!"llvm.loop.mustprogress"} // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true} @@ -73,4 +116,14 @@ void test5(int *List, int Length) { // CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]} // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1} -// CHECK-NEXT: ![[LOOP5]] =
[clang] e5dba2d - [OMPIRBuilder] Start 'Create' methods with lower case. NFC.
Author: Michael Kruse Date: 2020-11-09T19:35:11-06:00 New Revision: e5dba2d7e5a6ab8266954e13844355d795c8c88b URL: https://github.com/llvm/llvm-project/commit/e5dba2d7e5a6ab8266954e13844355d795c8c88b DIFF: https://github.com/llvm/llvm-project/commit/e5dba2d7e5a6ab8266954e13844355d795c8c88b.diff LOG: [OMPIRBuilder] Start 'Create' methods with lower case. NFC. For consistency with the IRBuilder, OpenMPIRBuilder has method names starting with 'Create'. However, the LLVM coding style has methods names starting with lower case letters, as all other OpenMPIRBuilder already methods do. The clang-tidy configuration used by Phabricator also warns about the naming violation, adding noise to the reviews. This patch renames all `OpenMPIRBuilder::CreateXYZ` methods to `OpenMPIRBuilder::createXYZ`, and updates all in-tree callers. I tested check-llvm, check-clang, check-mlir and check-flang to ensure that I did not miss a caller. Reviewed By: mehdi_amini, fghanim Differential Revision: https://reviews.llvm.org/D91109 Added: Modified: clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/lib/Transforms/IPO/OpenMPOpt.cpp llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp mlir/lib/Target/LLVMIR/ModuleTranslation.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 017e8f2e3472..3713c672b053 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2260,7 +2260,7 @@ void CGOpenMPRuntime::emitTaskyieldCall(CodeGenFunction , if (!CGF.HaveInsertPoint()) return; if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -OMPBuilder.CreateTaskyield(CGF.Builder); +OMPBuilder.createTaskyield(CGF.Builder); } else { // Build call __kmpc_omp_taskyield(loc, thread_id, 0); llvm::Value *Args[] = { @@ -2515,7 +2515,7 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction , SourceLocation Loc, auto *OMPRegionInfo = dyn_cast_or_null(CGF.CapturedStmtInfo); if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -CGF.Builder.restoreIP(OMPBuilder.CreateBarrier( +CGF.Builder.restoreIP(OMPBuilder.createBarrier( CGF.Builder, Kind, ForceSimpleCall, EmitChecks)); return; } @@ -2877,7 +2877,7 @@ void CGOpenMPRuntime::emitProcBindClause(CodeGenFunction , void CGOpenMPRuntime::emitFlush(CodeGenFunction , ArrayRef, SourceLocation Loc, llvm::AtomicOrdering AO) { if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -OMPBuilder.CreateFlush(CGF.Builder); +OMPBuilder.createFlush(CGF.Builder); } else { if (!CGF.HaveInsertPoint()) return; @@ -6187,7 +6187,7 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction , return; if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -OMPBuilder.CreateTaskwait(CGF.Builder); +OMPBuilder.createTaskwait(CGF.Builder); } else { // Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32 // global_tid); diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 5884dfd2bc3f..2fb4144930df 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -1614,11 +1614,11 @@ Address CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable( Allocator = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Allocator, CGM.VoidPtrTy); - llvm::Value *Addr = OMPBuilder.CreateOMPAlloc( + llvm::Value *Addr = OMPBuilder.createOMPAlloc( CGF.Builder, Size, Allocator, getNameWithSeparators({CVD->getName(), ".void.addr"}, ".", ".")); llvm::CallInst *FreeCI = - OMPBuilder.CreateOMPFree(CGF.Builder, Addr, Allocator); + OMPBuilder.createOMPFree(CGF.Builder, Addr, Allocator); CGF.EHStack.pushCleanup(NormalAndEHCleanup, FreeCI); Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( @@ -1646,7 +1646,7 @@ Address CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate( llvm::Twine CacheName = Twine(CGM.getMangledName(VD)).concat(Suffix); llvm::CallInst *ThreadPrivateCacheCall = - OMPBuilder.CreateCachedThreadPrivate(CGF.Builder, Data, Size, CacheName); + OMPBuilder.createCachedThreadPrivate(CGF.Builder, Data, Size, CacheName); return Address(ThreadPrivateCacheCall, VDAddr.getAlignment()); } @@ -1718,7 +1718,7 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective ) { llvm::OpenMPIRBuilder::InsertPointTy AllocaIP( AllocaInsertPt->getParent(), AllocaInsertPt->getIterator()); Builder.restoreIP( -OMPBuilder.CreateParallel(Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB, +OMPBuilder.createParallel(Builder,
[clang] 18eba16 - [OpenMP][docs] Update loop tiling status.
Author: Michael Kruse Date: 2020-07-31T13:01:55-05:00 New Revision: 18eba165e7ba80328a910cad3407599d8ff60f4f URL: https://github.com/llvm/llvm-project/commit/18eba165e7ba80328a910cad3407599d8ff60f4f DIFF: https://github.com/llvm/llvm-project/commit/18eba165e7ba80328a910cad3407599d8ff60f4f.diff LOG: [OpenMP][docs] Update loop tiling status. Added: Modified: clang/docs/OpenMPSupport.rst Removed: diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 28fbd7baebb2..af5e538b1435 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -266,7 +266,7 @@ want to help with the implementation. +--+--+--+---+ | misc extension | default(firstprivate) & default(private) | :part:`partial` | firstprivate done: D75591 | +--+--+--+---+ -| loop extension | Loop tiling transformation | :part:`claimed` | | +| loop extension | Loop tiling transformation | :part:`worked on`| D76342 | +--+--+--+---+ | device extension | 'present' map type modifier | :part:`mostly done` | D83061, D83062, D84422 | +--+--+--+---+ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits