[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
@@ -0,0 +1,3 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ nightlark wrote: Another thought, I expect most end users will eventually be installing from a PyPI package -- the sdist and wheel files uploaded there will already have the necessary version information in it, so the number of people that see the fallback version will mostly be developers installing from their forks if they didn't copy tags as well. https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)
@@ -2916,6 +2917,12 @@ instrumentation: $ LLVM_PROFILE_FILE="code-%m.profraw" ./code + Although rare, binary signatures used by the ``%m`` specifier can have + collisions. In this case, the ``%b`` specifier, which expands to the binary + ID (build ID), can be added. To use it, the program should be compiled with petrhosek wrote: ```suggestion ID (build ID in ELF and COFF), can be added. To use it, the program should be compiled with ``` https://github.com/llvm/llvm-project/pull/123963 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] fix diagnostic to correctly handle singular and plural cases for redundant qualifiers on base class type (PR #125943)
https://github.com/a-tarasyuk closed https://github.com/llvm/llvm-project/pull/125943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c7dc836 - [Clang] fix diagnostic to correctly handle singular and plural cases for redundant qualifiers on base class type (#125943)
Author: Oleksandr T. Date: 2025-02-06T10:37:23+02:00 New Revision: c7dc836bbe3658a9210a944b850450f5ae7b50a4 URL: https://github.com/llvm/llvm-project/commit/c7dc836bbe3658a9210a944b850450f5ae7b50a4 DIFF: https://github.com/llvm/llvm-project/commit/c7dc836bbe3658a9210a944b850450f5ae7b50a4.diff LOG: [Clang] fix diagnostic to correctly handle singular and plural cases for redundant qualifiers on base class type (#125943) Fixes #125942 Added: Modified: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/test/SemaCXX/warn-base-type-qualifiers.cpp Removed: diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 7b3b932c482baa2..bcae9e9f3009387 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -490,7 +490,7 @@ def warn_qual_return_type : Warning< "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">, InGroup, DefaultIgnore; def warn_qual_base_type : Warning< - "'%0' qualifier%s1 on base class type %2 have no effect">, + "'%0' qualifier%s1 on base class type %2 %plural{1:has|:have}1 no effect">, InGroup, DefaultIgnore; def warn_deprecated_redundant_constexpr_static_def : Warning< diff --git a/clang/test/SemaCXX/warn-base-type-qualifiers.cpp b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp index b9fd577c574b99a..7c775a552dd8861 100644 --- a/clang/test/SemaCXX/warn-base-type-qualifiers.cpp +++ b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp @@ -8,7 +8,7 @@ template using add_const_t = typename add_const::type; class A { }; typedef const A A_Const; -class B : public A_Const { }; // expected-warning {{'const' qualifier on base class type 'A_Const' (aka 'const A') have no effect}} \ +class B : public A_Const { }; // expected-warning {{'const' qualifier on base class type 'A_Const' (aka 'const A') has no effect}} \ // expected-note {{base class 'A_Const' (aka 'const A') specified here}} typedef const volatile A A_Const_Volatile; @@ -19,7 +19,7 @@ struct D { D(int); }; -template struct E : T { // expected-warning {{'const' qualifier on base class type 'const D' have no effect}} \ +template struct E : T { // expected-warning {{'const' qualifier on base class type 'const D' has no effect}} \ // expected-note {{base class 'const D' specified here}} using T::T; E(int &) : E(0) {} @@ -27,7 +27,7 @@ template struct E : T { // expected-warning {{'const' qualifier on E e(1); // expected-note {{in instantiation of template class 'E' requested here}} template -struct G : add_const::type { // expected-warning {{'const' qualifier on base class type 'add_const::type' (aka 'const D') have no effect}} \ +struct G : add_const::type { // expected-warning {{'const' qualifier on base class type 'add_const::type' (aka 'const D') has no effect}} \ // expected-note {{base class 'add_const::type' (aka 'const D') specified here}} using T::T; G(int &) : G(0) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/123963 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add -ftime-trace scopes for region-store bindings and removeDead (PR #125884)
https://github.com/necto edited https://github.com/llvm/llvm-project/pull/125884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/126026 >From f938ba2240e03756ac7597eedd0b5ac3ad1ece3e Mon Sep 17 00:00:00 2001 From: ergawy Date: Wed, 5 Feb 2025 23:31:15 -0600 Subject: [PATCH] [flang][OpenMP] Upstream first part of `do concurrent` mapping This PR starts the effort to upstream AMD's internal implementation of `do concurrent` to OpenMP mapping. This replaces #77285 since we extended this WIP quite a bit on our fork over the past year. An important part of this PR is a document that describes the current status downstream, the upstreaming status, and next steps to make this pass much more useful. In addition to this document, this PR also contains the skeleton of the pass (no useful transformations are done yet) and some testing for the added command line options. --- clang/include/clang/Driver/Options.td | 4 + clang/lib/Driver/ToolChains/Flang.cpp | 3 +- flang/docs/DoConcurrentConversionToOpenMP.md | 380 ++ flang/docs/index.md | 1 + .../include/flang/Frontend/CodeGenOptions.def | 2 + flang/include/flang/Frontend/CodeGenOptions.h | 5 + flang/include/flang/Optimizer/OpenMP/Passes.h | 2 + .../include/flang/Optimizer/OpenMP/Passes.td | 30 ++ flang/include/flang/Optimizer/OpenMP/Utils.h | 26 ++ .../flang/Optimizer/Passes/Pipelines.h| 11 +- flang/lib/Frontend/CompilerInvocation.cpp | 30 ++ flang/lib/Frontend/FrontendActions.cpp| 31 +- flang/lib/Optimizer/OpenMP/CMakeLists.txt | 1 + .../OpenMP/DoConcurrentConversion.cpp | 104 + flang/lib/Optimizer/Passes/Pipelines.cpp | 9 +- .../Transforms/DoConcurrent/basic_host.f90| 53 +++ .../DoConcurrent/command_line_options.f90 | 18 + flang/tools/bbc/bbc.cpp | 20 +- 18 files changed, 720 insertions(+), 10 deletions(-) create mode 100644 flang/docs/DoConcurrentConversionToOpenMP.md create mode 100644 flang/include/flang/Optimizer/OpenMP/Utils.h create mode 100644 flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp create mode 100644 flang/test/Transforms/DoConcurrent/basic_host.f90 create mode 100644 flang/test/Transforms/DoConcurrent/command_line_options.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c0749c418b7bcec..7fc22bcdff17cd2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6901,6 +6901,10 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group, HelpText<"Emit hermetic module files (no nested USE association)">; + +def do_concurrent_parallel_EQ : Joined<["-"], "fdo-concurrent-parallel=">, + HelpText<"Try to map `do concurrent` loops to OpenMP [none|host|device]">, + Values<"none,host,device">; } // let Visibility = [FC1Option, FlangOption] def J : JoinedOrSeparate<["-"], "J">, diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index e4019c434968744..cf08ec1b900ad90 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -153,7 +153,8 @@ void Flang::addCodegenOptions(const ArgList &Args, CmdArgs.push_back("-fversion-loops-for-stride"); Args.addAllArgs(CmdArgs, - {options::OPT_flang_experimental_hlfir, + {options::OPT_do_concurrent_parallel_EQ, + options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_fno_ppc_native_vec_elem_order, options::OPT_fppc_native_vec_elem_order, diff --git a/flang/docs/DoConcurrentConversionToOpenMP.md b/flang/docs/DoConcurrentConversionToOpenMP.md new file mode 100644 index 000..d40383a06a47b6c --- /dev/null +++ b/flang/docs/DoConcurrentConversionToOpenMP.md @@ -0,0 +1,380 @@ + + +# `DO CONCURENT` mapping to OpenMP + +```{contents} +--- +local: +--- +``` + +This document seeks to describe the effort to parallelize `do concurrent` loops +by mapping them to OpenMP worksharing constructs. The goals of this document +are: +* Describing how to instruct `flang` to map `DO CONCURENT` loops to OpenMP + constructs. +* Tracking the current status of such mapping. +* Describing the limitations of the current implmenentation. +* Describing next steps. +* Tracking the current upstreaming status (from the AMD ROCm fork). + +## Usage + +In order to enable `do concurrent` to OpenMP mapping, `flang` adds a new +compiler flag: `-fdo-concurrent-parallel`. This flags has 3 possible values: +1. `host`: this maps `do concurent` loops to run in parallel on the host CPU. + This maps such loops to the equivalent of `omp parallel do`. +2. `device`: this maps `do concurent` loops to run in parallel on a device + (GPU). This maps such loops to the equivalent of `om
[clang] d2b45ce - [clang-format] Add BreakBeforeTemplateCloser option (#118046)
Author: leijurv Date: 2025-02-06T01:15:47-08:00 New Revision: d2b45ce100d641a8f1690e30843bb9c5ea71ab86 URL: https://github.com/llvm/llvm-project/commit/d2b45ce100d641a8f1690e30843bb9c5ea71ab86 DIFF: https://github.com/llvm/llvm-project/commit/d2b45ce100d641a8f1690e30843bb9c5ea71ab86.diff LOG: [clang-format] Add BreakBeforeTemplateCloser option (#118046) In clang-format, multiline templates have the `>` on the same line as the last parameter: ```c++ template < typename Foo, typename Bar> void foo() { ``` I would like to add an option to put the `>` on the next line, like this: ```c++ template < typename Foo, typename Bar > void foo() { ``` An example of a large project that uses this style is NVIDIA's CUTLASS, here is an example: https://github.com/NVIDIA/cutlass/blob/main/include/cutlass/epilogue/dispatch_policy.hpp#L149-L156 My reasoning is that it reminds me of this style of braces: ```c++ if (foo()) { bar(); baz();} ``` Most people agree this is better: ```c++ if (foo()) { bar(); baz(); } ``` - Co-authored-by: Owen Pan Added: Modified: clang/docs/ClangFormatStyleOptions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Format/Format.h clang/lib/Format/ContinuationIndenter.cpp clang/lib/Format/ContinuationIndenter.h clang/lib/Format/Format.cpp clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp Removed: diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index bbb912eb10e94d7..ce38a3a9ba1f739 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -3421,6 +3421,35 @@ the configuration (without a prefix: ``Auto``). +.. _BreakBeforeTemplateCloser: + +**BreakBeforeTemplateCloser** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ ` + If ``true``, break before a template closing bracket (``>``) when there is + a line break after the matching opening bracket (``<``). + + .. code-block:: c++ + + true: + template + + template + + template < + typename Foo, + typename Bar + > + + false: + template + + template + + template < + typename Foo, + typename Bar> + .. _BreakBeforeTernaryOperators: **BreakBeforeTernaryOperators** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ ` diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index bd26c41a41793f7..159b45946d7051f 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -231,6 +231,8 @@ AST Matchers clang-format +- Adds ``BreakBeforeTemplateCloser`` option. + libclang diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 6f432d1d5031542..fbc9291ae950d41 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -2252,6 +2252,33 @@ struct FormatStyle { /// \version 16 BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon; + /// If ``true``, break before a template closing bracket (``>``) when there is + /// a line break after the matching opening bracket (``<``). + /// \code + ///true: + ///template + /// + ///template + /// + ///template < + ///typename Foo, + ///typename Bar + ///> + /// + ///false: + ///template + /// + ///template + /// + ///template < + ///typename Foo, + ///typename Bar> + /// \endcode + /// \version 21 + bool BreakBeforeTemplateCloser; + /// If ``true``, ternary operators will be placed after line breaks. /// \code ///true: @@ -5251,6 +5278,7 @@ struct FormatStyle { BreakBeforeBraces == R.BreakBeforeBraces && BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations && BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon && + BreakBeforeTemplateCloser == R.BreakBeforeTemplateCloser && BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators && BreakBinaryOperations == R.BreakBinaryOperations && BreakConstructorInitializers == R.BreakConstructorInitializers && diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 6f7d213c0b55996..3e51b4aab10824a 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -349,6 +349,13 @@ bool ContinuationIndenter::canBreak(const LineState &State) { } } + // Don't allow breaking before a closing brace of a block-indented braced list + // initializer if there isn't already a break. + if (Current.is(tok::r_brace) && Current.MatchingParen && + Current.isBlockIndentedInitRBrace(Style)) { +retu
[clang] [clang-format] Add BreakBeforeTemplateCloser option (PR #118046)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/118046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add BreakBeforeTemplateCloser option (PR #118046)
github-actions[bot] wrote: @leijurv Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/118046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Parse warning-suppression-mapping after setting up diagengine (PR #125714)
https://github.com/kadircet updated https://github.com/llvm/llvm-project/pull/125714 From b210fc4d5a12eeed12c1746012da41d0c50a79b4 Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Tue, 4 Feb 2025 17:30:16 +0100 Subject: [PATCH] [clang] Parse warning-suppression-mapping after setting up diagengine We can emit diagnostics while parsing warning-suppression-mapping, make sure command line flags take affect when emitting those. --- clang/lib/Basic/Warnings.cpp | 23 +-- clang/unittests/Basic/DiagnosticTest.cpp | 9 + 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp index da0304463007b65..5f48e0ec8155434 100644 --- a/clang/lib/Basic/Warnings.cpp +++ b/clang/lib/Basic/Warnings.cpp @@ -73,16 +73,6 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, else Diags.setExtensionHandlingBehavior(diag::Severity::Ignored); - if (!Opts.DiagnosticSuppressionMappingsFile.empty()) { -if (auto FileContents = -VFS.getBufferForFile(Opts.DiagnosticSuppressionMappingsFile)) { - Diags.setDiagSuppressionMapping(**FileContents); -} else if (ReportDiags) { - Diags.Report(diag::err_drv_no_such_file) - << Opts.DiagnosticSuppressionMappingsFile; -} - } - SmallVector _Diags; const IntrusiveRefCntPtr< DiagnosticIDs > DiagIDs = Diags.getDiagnosticIDs(); @@ -237,4 +227,17 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, } } } + + // Process suppression mappings file after processing other warning flags + // (like -Wno-unknown-warning-option) as we can emit extra warnings during + // processing. + if (!Opts.DiagnosticSuppressionMappingsFile.empty()) { +if (auto FileContents = +VFS.getBufferForFile(Opts.DiagnosticSuppressionMappingsFile)) { + Diags.setDiagSuppressionMapping(**FileContents); +} else if (ReportDiags) { + Diags.Report(diag::err_drv_no_such_file) + << Opts.DiagnosticSuppressionMappingsFile; +} + } } diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp index b26f72a2fb0ee5a..88fa1800f0ff2a4 100644 --- a/clang/unittests/Basic/DiagnosticTest.cpp +++ b/clang/unittests/Basic/DiagnosticTest.cpp @@ -346,4 +346,13 @@ TEST_F(SuppressionMappingTest, IsIgnored) { EXPECT_FALSE(Diags.isIgnored(diag::warn_unused_function, SM.getLocForStartOfFile(ClangID))); } + +TEST_F(SuppressionMappingTest, ParsingRespectsOtherWarningOpts) { + Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt"; + FS->addFile("foo.txt", /*ModificationTime=*/{}, + llvm::MemoryBuffer::getMemBuffer("[non-existing-warning]")); + Diags.getDiagnosticOptions().Warnings.push_back("no-unknown-warning-option"); + clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS); + EXPECT_THAT(diags(), IsEmpty()); +} } // namespace ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ecb016a - [clang] Parse warning-suppression-mapping after setting up diagengine (#125714)
Author: kadir çetinkaya Date: 2025-02-06T10:18:38+01:00 New Revision: ecb016a87d89aed36b8f5d8102e15d8eb0e57108 URL: https://github.com/llvm/llvm-project/commit/ecb016a87d89aed36b8f5d8102e15d8eb0e57108 DIFF: https://github.com/llvm/llvm-project/commit/ecb016a87d89aed36b8f5d8102e15d8eb0e57108.diff LOG: [clang] Parse warning-suppression-mapping after setting up diagengine (#125714) We can emit diagnostics while parsing warning-suppression-mapping, make sure command line flags take affect when emitting those. Added: Modified: clang/lib/Basic/Warnings.cpp clang/unittests/Basic/DiagnosticTest.cpp Removed: diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp index da0304463007b65..5f48e0ec8155434 100644 --- a/clang/lib/Basic/Warnings.cpp +++ b/clang/lib/Basic/Warnings.cpp @@ -73,16 +73,6 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, else Diags.setExtensionHandlingBehavior(diag::Severity::Ignored); - if (!Opts.DiagnosticSuppressionMappingsFile.empty()) { -if (auto FileContents = -VFS.getBufferForFile(Opts.DiagnosticSuppressionMappingsFile)) { - Diags.setDiagSuppressionMapping(**FileContents); -} else if (ReportDiags) { - Diags.Report(diag::err_drv_no_such_file) - << Opts.DiagnosticSuppressionMappingsFile; -} - } - SmallVector _Diags; const IntrusiveRefCntPtr< DiagnosticIDs > DiagIDs = Diags.getDiagnosticIDs(); @@ -237,4 +227,17 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, } } } + + // Process suppression mappings file after processing other warning flags + // (like -Wno-unknown-warning-option) as we can emit extra warnings during + // processing. + if (!Opts.DiagnosticSuppressionMappingsFile.empty()) { +if (auto FileContents = +VFS.getBufferForFile(Opts.DiagnosticSuppressionMappingsFile)) { + Diags.setDiagSuppressionMapping(**FileContents); +} else if (ReportDiags) { + Diags.Report(diag::err_drv_no_such_file) + << Opts.DiagnosticSuppressionMappingsFile; +} + } } diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp index b26f72a2fb0ee5a..88fa1800f0ff2a4 100644 --- a/clang/unittests/Basic/DiagnosticTest.cpp +++ b/clang/unittests/Basic/DiagnosticTest.cpp @@ -346,4 +346,13 @@ TEST_F(SuppressionMappingTest, IsIgnored) { EXPECT_FALSE(Diags.isIgnored(diag::warn_unused_function, SM.getLocForStartOfFile(ClangID))); } + +TEST_F(SuppressionMappingTest, ParsingRespectsOtherWarningOpts) { + Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt"; + FS->addFile("foo.txt", /*ModificationTime=*/{}, + llvm::MemoryBuffer::getMemBuffer("[non-existing-warning]")); + Diags.getDiagnosticOptions().Warnings.push_back("no-unknown-warning-option"); + clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS); + EXPECT_THAT(diags(), IsEmpty()); +} } // namespace ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Parse warning-suppression-mapping after setting up diagengine (PR #125714)
kadircet wrote: /cherry-pick ecb016a87d89aed36b8f5d8102e15d8eb0e57108 https://github.com/llvm/llvm-project/pull/125714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] [C++20] [Modules] Add scanning cache (PR #125988)
https://github.com/kadircet requested changes to this pull request. instead of introducing a new concept of `ProjectModulesCache` and requiring each `ProjectModules` implementation to know about it and work with it; what about introducing a: ```cpp class CachingProjectModules : public ProjectModules { public: CachingProjectModules(GlobalCompilationDatabase &CDB); // Implements rest of the operations with a cache overlay. ...; // Whenever cache is invalid/empty, queries `CDB` for underlying `ProjectModules` // and updates/builds a cache using it. }; ``` into `ModulesBuilder.cpp` and have an instance of this in `ModulesBuilderImpl`? That way we can centralize how the caching will work and won't need to maintain multiple implementations that play with it. As for cache validation, i think it's fine to invalidate based on file contents and whenever there's a mismatch we can query `CDB` again. WDYT? https://github.com/llvm/llvm-project/pull/125988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SVE ACLE] Allow default zero initialisation for svcount_t. (PR #69321)
@@ -1738,6 +1738,12 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) { if (const auto *NC = dyn_cast(C)) return getValue(NC->getGlobalValue()); +if (VT == MVT::aarch64svcount) { + assert(C->isNullValue() && "Can only zero this target type!"); + return DAG.getNode(ISD::BITCAST, getCurSDLoc(), VT, paulwalker-arm wrote: I agree, it looks like an omission on my part when landing the original work. If you're happy to fix then that would be great, otherwise just let me know and I'll follow up. https://github.com/llvm/llvm-project/pull/69321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move fma to the CLC library (PR #126052)
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/126052 This builtin is a little more involved than others as targets deal with fma in various different ways. Fundamentally, the CLC __clc_fma builtin compiles to __builtin_elementwise_fma, which compiles to the @llvm.fma intrinsic. However, in the case of fp32 fma some targets call the __clc_sw_fma function, which provides a software implementation of the builtin. This in principle is controlled by the __CLC_HAVE_HW_FMA32 macro and may be a runtime decision, depending on how the target defines that macro. All targets build the CLC fma functions for all types. This is to the CLC library can have a reliable internal implementation for its own purposes. For AMD/NVPTX targets there are no meaningful changes to the generated LLVM bytecode. Some blocks of code have moved around, which confounds llvm-diff. For the clspv and SPIR-V/Mesa targets, only fp32 fma is of interest. Its use in libclc is tightly controlled by checking __CLC_HAVE_HW_FMA32 first. This can either be a compile-time constant (1, for clspv) or a runtime function for SPIR-V/Mesa. The SPIR-V/Mesa target only provided fp32 fma in the OpenCL layer. It unconditionally mapped that to the __clc_sw_fma builtin, even though the generic version in theory had a runtime toggle through __CLC_HAVE_HW_FMA32 specifically for that target. Callers of fma, though, would end up using the ExtInst fma, *not* calling the _Z3fmafff function provided by libclc. This commit keeps this system in place in the OpenCL layer, by mapping fma to __clc_sw_fma. Where other builtins would previously call fma (i.e., result in the ExtInst), they now call __clc_fma. This function checks the __CLC_HAVE_HW_FMA32 runtime toggle, which selects between the slow version or the quick version. The quick version is the LLVM fma intrinsic which llvm-spirv translates to the ExtInst. The clspv target had its own software implementation of fp32 fma, which it called unconditionally - even though __CLC_HAVE_HW_FMA32 is 1 for that target. This is potentially just so its library ships a software version which it can fall back on. In the OpenCL layer, the target doesn't provide fp64 fma, and maps fp16 fma to fp32 mad. This commit keeps this system roughly in place: in the OpenCL layer it maps fp32 fma to __clc_sw_fma, and fp16 fma to mad. Where builtins would previously call into fma, they now call __clc_fma, which compiles to the LLVM intrinsic. If this goes through a translation to SPIR-V it will become the fma ExtInst, or the intrinsic could be replaced by the _Z3fmafff software implementation. The clspv and SPIR-V/Mesa targets could potentially be cleaned up later, depending on their needs. >From 7f3b8ec68b8d5f26e038228b6cff46ea220a3dcf Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 28 Jan 2025 12:19:23 + Subject: [PATCH 1/2] [libclc] Move fma to the CLC library This builtin is a little more involved than others as targets deal with fma in various different ways. Fundamentally, the CLC __clc_fma builtin compiles to __builtin_elementwise_fma, which compiles to the @llvm.fma intrinsic. However, in the case of fp32 fma some targets call the __clc_sw_fma function, which provides a software implementation of the builtin. This in principle is controlled by the __CLC_HAVE_HW_FMA32 macro and may be a runtime decision, depending on how the target defines that macro. All targets build the CLC fma functions for all types. This is to the CLC library can have a reliable internal implementation for its own purposes. For AMD/NVPTX targets there are no meaningful changes to the generated LLVM bytecode. Some blocks of code have moved around, which confounds llvm-diff. For the clspv and SPIR-V/Mesa targets, only fp32 fma is of interest. Its use in libclc is tightly controlled by checking __CLC_HAVE_HW_FMA32 first. This can either be a compile-time constant (0, for clspv) or a runtime function for SPIR-V/Mesa. The SPIR-V/Mesa target only provided fp32 fma in the OpenCL layer. It unconditionally mapped that to the __clc_sw_fma builtin, even though the generic version in theory had a runtime toggle through __CLC_HAVE_HW_FMA32 specifically for that target. Callers of fma, though, would end up using the ExtInst fma, *not* calling the _Z3fmafff function provided by libclc. This commit keeps this system in place in the OpenCL layer, by mapping fma to __clc_sw_fma. Where other builtins would previously call fma (i.e., result in the ExtInst), they now call __clc_fma. This function checks the __CLC_HAVE_HW_FMA32 runtime toggle, which selects between the slow version or the quick version. The quick version is the LLVM fma intrinsic which llvm-spirv translates to the ExtInst. The clspv target had its own software implementation of fp32 fma, which it called unconditionally - even though __CLC_HAVE_HW_FMA32 is 1 for that target. This is potentially just so its library ships a software version which it can fall ba
[libclc] [libclc] Move fma to the CLC library (PR #126052)
frasercrmck wrote: FYI @rjodinchr this breaks downstream clspv testing. ``` # | declare !kernel_arg_name !7 float @llvm.fma.f32(float, float, float) #2 # | Unsupported llvm intrinsic # | UNREACHABLE executed at /clspv/lib/SPIRVProducerPass.cpp:2390! ``` I was wondering if clspv should be translating `llvm.fma` to `OpExtInst fma` as `llvm-spirv` does. https://github.com/llvm/llvm-project/pull/126052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add a generic OOO CPU (PR #120712)
@@ -0,0 +1,494 @@ +//===-- RISCVSchedGenericOOO.td - Generic O3 Processor -*- tablegen -*-===// +// +// 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 +// +//===--===// + +//===--===// +// We assume that: +// * 6-issue out-of-order CPU with 192 ROB entries. +// * Units: +// * IXU (Integer ALU Unit): 4 units, only one can execute division. +// * FXU (Floating-point Unit): 2 units. +// * LSU (Load/Store Unit): 2 units. +// * VXU (Vector Unit): 1 unit. +// * Latency: +// * Integer instructions: 1 cycle. +// * Multiplication instructions: 4 cycles. +// * Multiplication/Division instructions: 7-13 cycles. +// * Floating-point instructions: 2-6 cycles. +// * Vector instructions: 2-6 cycles. +// * Load/Store: +// * IXU: 4 cycles. +// * FXU: 4 cycles. +// * VXU: 6 cycles. +// * Integer/floating-point/vector div/rem/sqrt/... are non-pipelined. +//===--===// + +def GenericOOOModel : SchedMachineModel { + int IssueWidth = 6; + int MicroOpBufferSize = 192; + int LoadLatency = 4; + int MispredictPenalty = 8; + let CompleteModel = 0; +} + +let SchedModel = GenericOOOModel in { +//===--===// +// Resource groups +//===--===// +def GenericOOODIV : ProcResource<1>; +def GenericOOOIXU : ProcResource<3>; +def GenericOOOALU : ProcResGroup<[GenericOOODIV, GenericOOOIXU]>; +def GenericOOOLSU : ProcResource<2>; +def GenericOOOFPU : ProcResource<2>; +// TODO: Add vector scheduling. +// def GenericOOOVXU : ProcResource<1>; + +//===--===// +// Branches +//===--===// +def : WriteRes; wangpc-pp wrote: Good point! https://github.com/llvm/llvm-project/pull/120712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (PR #125998)
https://github.com/Meinersbur approved this pull request. https://github.com/llvm/llvm-project/pull/125998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (PR #125998)
https://github.com/tblah approved this pull request. Thanks for coming back to this @brad0 https://github.com/llvm/llvm-project/pull/125998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/126026 >From 03d500e28d76ab356537f771dd75ecce4010bd48 Mon Sep 17 00:00:00 2001 From: ergawy Date: Wed, 5 Feb 2025 23:31:15 -0600 Subject: [PATCH] [flang][OpenMP] Upstream first part of `do concurrent` mapping This PR starts the effort to upstream AMD's internal implementation of `do concurrent` to OpenMP mapping. This replaces #77285 since we extended this WIP quite a bit on our fork over the past year. An important part of this PR is a document that describes the current status downstream, the upstreaming status, and next steps to make this pass much more useful. In addition to this document, this PR also contains the skeleton of the pass (no useful transformations are done yet) and some testing for the added command line options. --- clang/include/clang/Driver/Options.td | 4 + clang/lib/Driver/ToolChains/Flang.cpp | 3 +- flang/docs/DoConcurrentConversionToOpenMP.md | 380 ++ flang/docs/index.md | 1 + .../include/flang/Frontend/CodeGenOptions.def | 2 + flang/include/flang/Frontend/CodeGenOptions.h | 5 + flang/include/flang/Optimizer/OpenMP/Passes.h | 2 + .../include/flang/Optimizer/OpenMP/Passes.td | 30 ++ flang/include/flang/Optimizer/OpenMP/Utils.h | 26 ++ .../flang/Optimizer/Passes/Pipelines.h| 11 +- flang/lib/Frontend/CompilerInvocation.cpp | 30 ++ flang/lib/Frontend/FrontendActions.cpp| 31 +- flang/lib/Optimizer/OpenMP/CMakeLists.txt | 1 + .../OpenMP/DoConcurrentConversion.cpp | 104 + flang/lib/Optimizer/Passes/Pipelines.cpp | 9 +- .../Transforms/DoConcurrent/basic_host.f90| 53 +++ .../DoConcurrent/command_line_options.f90 | 18 + flang/tools/bbc/bbc.cpp | 20 +- 18 files changed, 720 insertions(+), 10 deletions(-) create mode 100644 flang/docs/DoConcurrentConversionToOpenMP.md create mode 100644 flang/include/flang/Optimizer/OpenMP/Utils.h create mode 100644 flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp create mode 100644 flang/test/Transforms/DoConcurrent/basic_host.f90 create mode 100644 flang/test/Transforms/DoConcurrent/command_line_options.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c0749c418b7bcec..7fc22bcdff17cd2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6901,6 +6901,10 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group, HelpText<"Emit hermetic module files (no nested USE association)">; + +def do_concurrent_parallel_EQ : Joined<["-"], "fdo-concurrent-parallel=">, + HelpText<"Try to map `do concurrent` loops to OpenMP [none|host|device]">, + Values<"none,host,device">; } // let Visibility = [FC1Option, FlangOption] def J : JoinedOrSeparate<["-"], "J">, diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index e4019c434968744..cf08ec1b900ad90 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -153,7 +153,8 @@ void Flang::addCodegenOptions(const ArgList &Args, CmdArgs.push_back("-fversion-loops-for-stride"); Args.addAllArgs(CmdArgs, - {options::OPT_flang_experimental_hlfir, + {options::OPT_do_concurrent_parallel_EQ, + options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_fno_ppc_native_vec_elem_order, options::OPT_fppc_native_vec_elem_order, diff --git a/flang/docs/DoConcurrentConversionToOpenMP.md b/flang/docs/DoConcurrentConversionToOpenMP.md new file mode 100644 index 000..6805061859556a1 --- /dev/null +++ b/flang/docs/DoConcurrentConversionToOpenMP.md @@ -0,0 +1,380 @@ + + +# `DO CONCURENT` mapping to OpenMP + +```{contents} +--- +local: +--- +``` + +This document seeks to describe the effort to parallelize `do concurrent` loops +by mapping them to OpenMP worksharing constructs. The goals of this document +are: +* Describing how to instruct `flang` to map `DO CONCURENT` loops to OpenMP + constructs. +* Tracking the current status of such mapping. +* Describing the limitations of the current implmenentation. +* Describing next steps. +* Tracking the current upstreaming status (from the AMD ROCm fork). + +## Usage + +In order to enable `do concurrent` to OpenMP mapping, `flang` adds a new +compiler flag: `-fdo-concurrent-parallel`. This flags has 3 possible values: +1. `host`: this maps `do concurent` loops to run in parallel on the host CPU. + This maps such loops to the equivalent of `omp parallel do`. +2. `device`: this maps `do concurent` loops to run in parallel on a device + (GPU). This maps such loops to the equivalent of `om
[clang] d1de75a - [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (#125998)
Author: Brad Smith Date: 2025-02-06T04:36:47-05:00 New Revision: d1de75acea0da55316cd7827563e064105868f0f URL: https://github.com/llvm/llvm-project/commit/d1de75acea0da55316cd7827563e064105868f0f DIFF: https://github.com/llvm/llvm-project/commit/d1de75acea0da55316cd7827563e064105868f0f.diff LOG: [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (#125998) Also link with libexecinfo on FreeBSD, NetBSD, OpenBSD and DragonFly for the backtrace functions. Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp flang/test/Driver/linker-flags.f90 Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index c3c22a419f352a3..699aadec86dcba9 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1340,6 +1340,11 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); addArchSpecificRPath(TC, Args, CmdArgs); + +// needs libexecinfo for backtrace functions +if (TC.getTriple().isOSFreeBSD() || TC.getTriple().isOSNetBSD() || +TC.getTriple().isOSOpenBSD() || TC.getTriple().isOSDragonFly()) + CmdArgs.push_back("-lexecinfo"); } // libomp needs libatomic for atomic operations if using libgcc diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index ac9500d7c45cecd..b998cbaa6227c35 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -5,10 +5,10 @@ ! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib ! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib ! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,BSD,BSD-F128%f128-lib ! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU,HAIKU-F128%f128-lib ! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW,MINGW-F128%f128-lib ! RUN: %flang -### -rtlib=compiler-rt --target=aarch64-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,COMPILER-RT @@ -36,6 +36,14 @@ ! UNIX-SAME: "-lFortranRuntime" "-lFortranDecimal" "-lm" ! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a" +! BSD-LABEL: "{{.*}}ld{{(\.exe)?}}" +! BSD-SAME: "[[object_file]]" +! BSD-F128NONE-NOT: FortranFloat128Math +! BSD-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed" +! BSD-SAME: -lFortranRuntime +! BSD-SAME: -lFortranDecimal +! BSD-SAME: -lexecinfo + ! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}" ! DARWIN-SAME: "[[object_file]]" ! DARWIN-F128NONE-NOT: FortranFloat128Math ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (PR #125998)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/125998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
nightlark wrote: @Endilll the Python bindings seem like part of LLVM that you have expertise in, if you also want to review this PR. https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Use getFileName and do not use realpath names (PR #126039)
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/126039 None >From fedb0a7b6d30870a3d7f7c77f8d431fdba3d3a7d Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Thu, 6 Feb 2025 09:47:24 + Subject: [PATCH] [analyzer] Use getFileName and do not use realpath names --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 4100812c4623e90..13677ed341d0c4c 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -299,7 +299,8 @@ std::string timeTraceName(const BugReportEquivClass &EQ) { return ("Flushing EQC " + BT.getDescription()).str(); } -llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) { +llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ, + const SourceManager &SM) { // Must be called only when constructing non-bogus TimeTraceScope assert(llvm::timeTraceProfilerEnabled()); @@ -309,9 +310,7 @@ llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) { const BugReport *R = BugReports.front().get(); const auto &BT = R->getBugType(); auto Loc = R->getLocation().asLocation(); - std::string File = ""; - if (const auto *Entry = Loc.getFileEntry()) -File = Entry->tryGetRealPathName().str(); + std::string File = SM.getFilename(Loc).str(); return {BT.getCheckerName().str(), std::move(File), static_cast(Loc.getLineNumber())}; } @@ -3150,8 +3149,9 @@ BugReport *PathSensitiveBugReporter::findReportInEquivalenceClass( } void BugReporter::FlushReport(BugReportEquivClass &EQ) { - llvm::TimeTraceScope TCS{timeTraceName(EQ), - [&EQ]() { return timeTraceMetadata(EQ); }}; + llvm::TimeTraceScope TCS{timeTraceName(EQ), [&]() { + return timeTraceMetadata(EQ, getSourceManager()); + }}; SmallVector bugReports; BugReport *report = findReportInEquivalenceClass(EQ, bugReports); if (!report) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Claiming "threadset clause" for implementation. (PR #126023)
https://github.com/SunilKuravinakop updated https://github.com/llvm/llvm-project/pull/126023 >From cf86e7a2333c36b9cf98d48f51548c847a8c0705 Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop Date: Thu, 6 Feb 2025 02:18:30 -0600 Subject: [PATCH 1/2] Claiming "threadset clause" for implementation. --- clang/docs/OpenMPSupport.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 673c34bf08a4a40..8a7fc0f09708804 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,6 +363,8 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | ++=+===+===+==+ +| threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | +-+---+---+--+ >From b2e4dda18925891b8919c8bf4ea400c852f60dde Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop Date: Thu, 6 Feb 2025 03:06:50 -0600 Subject: [PATCH 2/2] Correcting wrong separator that was used for the new entry of threadset clause. --- clang/docs/OpenMPSupport.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 8a7fc0f09708804..606660519be5856 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,7 +363,7 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | -+=+===+===+==+ ++-+---+---+--+ | threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Use getFileName and do not use realpath names (PR #126039)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-static-analyzer-1 Author: Utkarsh Saxena (usx95) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/126039.diff 1 Files Affected: - (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (+6-6) ``diff diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 4100812c4623e90..13677ed341d0c4c 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -299,7 +299,8 @@ std::string timeTraceName(const BugReportEquivClass &EQ) { return ("Flushing EQC " + BT.getDescription()).str(); } -llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) { +llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ, + const SourceManager &SM) { // Must be called only when constructing non-bogus TimeTraceScope assert(llvm::timeTraceProfilerEnabled()); @@ -309,9 +310,7 @@ llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) { const BugReport *R = BugReports.front().get(); const auto &BT = R->getBugType(); auto Loc = R->getLocation().asLocation(); - std::string File = ""; - if (const auto *Entry = Loc.getFileEntry()) -File = Entry->tryGetRealPathName().str(); + std::string File = SM.getFilename(Loc).str(); return {BT.getCheckerName().str(), std::move(File), static_cast(Loc.getLineNumber())}; } @@ -3150,8 +3149,9 @@ BugReport *PathSensitiveBugReporter::findReportInEquivalenceClass( } void BugReporter::FlushReport(BugReportEquivClass &EQ) { - llvm::TimeTraceScope TCS{timeTraceName(EQ), - [&EQ]() { return timeTraceMetadata(EQ); }}; + llvm::TimeTraceScope TCS{timeTraceName(EQ), [&]() { + return timeTraceMetadata(EQ, getSourceManager()); + }}; SmallVector bugReports; BugReport *report = findReportInEquivalenceClass(EQ, bugReports); if (!report) `` https://github.com/llvm/llvm-project/pull/126039 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
https://github.com/Endilll commented: Thank you for working on this I know too little of packaging in Python to approve, but let's try to get more eyes on this. CC @DeinAlptraum @sighingnow https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
@@ -0,0 +1,36 @@ +[build-system] +requires = ["setuptools>=42", "setuptools_scm==8.1.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "clang" +description = "libclang python bindings" +readme = {file = "README.txt", content-type = "text/plain"} + +license = {text = "Apache-2.0 WITH LLVM-exception"} +authors = [ +{ name = "LLVM" } +] +keywords = ["llvm", "clang", "libclang"] +classifiers = [ +"Intended Audience :: Developers", +"Development Status :: 5 - Production/Stable", +"Topic :: Software Development :: Compilers", +"Operating System :: OS Independent", +"Programming Language :: Python :: 3", +] +dynamic = ["version"] + +[project.urls] +Homepage = "https://clang.llvm.org/"; +Download = "https://llvm.org/releases/download.html"; +Discussions = "https://discourse.llvm.org/"; +"Issue Tracker" = "https://github.com/llvm/llvm-project/issues"; +"Source Code" = "https://github.com/llvm/llvm-project/tree/main/clang/bindings/python"; + +[tool.setuptools_scm] +root = "../../.." +version_file = "clang/_version.py" +version_scheme = "no-guess-dev" +# Regex version capture group gets x.y.z with optional -rcN, -aN, -bN suffixes; -init is just consumed +tag_regex = "^llvmorg-(?P\\d+(?:\\.\\d+)*(?:-(?:rc|a|b)\\d+)?)(?:.*)$" Endilll wrote: What are `-aN` and `-bN` suffixes? I don't think we've ever used them. https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
@@ -0,0 +1,34 @@ +[build-system] +requires = ["setuptools>=42", "setuptools_scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "clang" +description = "libclang python bindings" +readme = {file = "README.txt", content-type = "text/plain"} + +license = { text = "Apache-2.0 with LLVM exception" } +authors = [ +{ name = "LLVM" } +] +keywords = ["llvm", "clang", "libclang"] +classifiers = [ +"Intended Audience :: Developers", +"License :: OSI Approved :: Apache Software License", +"Development Status :: 5 - Production/Stable", +"Topic :: Software Development :: Compilers", +"Operating System :: OS Independent", +"Programming Language :: Python :: 3", +] +dynamic = ["version"] + +[project.urls] +Homepage = "http://clang.llvm.org/"; +Download = "http://llvm.org/releases/download.html"; Endilll wrote: > Is there an official documentation site with info for the clang python > bindings? I don't think there is, but the most promising route seems to get https://libclang.readthedocs.io official and regularly updated. https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
https://github.com/Endilll edited https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)
https://github.com/ivanaivanovska updated https://github.com/llvm/llvm-project/pull/125492 >From 54c7b3c1fb149b82c26927d0fd831d8786f70ac3 Mon Sep 17 00:00:00 2001 From: Ivana Ivanovska Date: Mon, 2 Dec 2024 14:17:06 + Subject: [PATCH 1/2] Optimize -Wunsafe-buffer-usage. --- clang/lib/Analysis/UnsafeBufferUsage.cpp | 1427 ++ 1 file changed, 906 insertions(+), 521 deletions(-) diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp index c064aa30e8aedc6..4520d28d9e94522 100644 --- a/clang/lib/Analysis/UnsafeBufferUsage.cpp +++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -8,30 +8,32 @@ #include "clang/Analysis/Analyses/UnsafeBufferUsage.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTTypeTraits.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclCXX.h" #include "clang/AST/DynamicRecursiveASTVisitor.h" #include "clang/AST/Expr.h" #include "clang/AST/FormatString.h" +#include "clang/AST/ParentMapContext.h" #include "clang/AST/Stmt.h" #include "clang/AST/StmtVisitor.h" #include "clang/AST/Type.h" -#include "clang/ASTMatchers/ASTMatchFinder.h" -#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Basic/SourceLocation.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/APSInt.h" +#include "llvm/ADT/STLFunctionalExtras.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" -#include #include #include +#include #include using namespace llvm; using namespace clang; -using namespace ast_matchers; #ifndef NDEBUG namespace { @@ -68,7 +70,7 @@ static std::string getDREAncestorString(const DeclRefExpr *DRE, if (StParents.size() > 1) return "unavailable due to multiple parents"; -if (StParents.size() == 0) +if (StParents.empty()) break; St = StParents.begin()->get(); if (St) @@ -76,10 +78,39 @@ static std::string getDREAncestorString(const DeclRefExpr *DRE, } while (St); return SS.str(); } + } // namespace #endif /* NDEBUG */ -namespace clang::ast_matchers { +namespace { +// Using a custom matcher instead of ASTMatchers to achieve better performance. +class FastMatcher { +public: + virtual bool matches(const DynTypedNode &DynNode, ASTContext &Ctx, + const UnsafeBufferUsageHandler &Handler) = 0; + virtual ~FastMatcher() = default; +}; + +class MatchResult { + +public: + template const T *getNodeAs(StringRef ID) const { +auto It = Nodes.find(std::string(ID)); +if (It == Nodes.end()) { + return nullptr; +} +return It->second.get(); + } + + void addNode(StringRef ID, const DynTypedNode &Node) { +Nodes[std::string(ID)] = Node; + } + +private: + llvm::StringMap Nodes; +}; +} // namespace + // A `RecursiveASTVisitor` that traverses all descendants of a given node "n" // except for those belonging to a different callable of "n". class MatchDescendantVisitor : public DynamicRecursiveASTVisitor { @@ -87,13 +118,11 @@ class MatchDescendantVisitor : public DynamicRecursiveASTVisitor { // Creates an AST visitor that matches `Matcher` on all // descendants of a given node "n" except for the ones // belonging to a different callable of "n". - MatchDescendantVisitor(const internal::DynTypedMatcher *Matcher, - internal::ASTMatchFinder *Finder, - internal::BoundNodesTreeBuilder *Builder, - internal::ASTMatchFinder::BindKind Bind, + MatchDescendantVisitor(FastMatcher &Matcher, bool FindAll, const bool ignoreUnevaluatedContext) - : Matcher(Matcher), Finder(Finder), Builder(Builder), Bind(Bind), -Matches(false), ignoreUnevaluatedContext(ignoreUnevaluatedContext) { + : Matcher(&Matcher), FindAll(FindAll), Matches(false), +ignoreUnevaluatedContext(ignoreUnevaluatedContext), +ActiveASTContext(nullptr), Handler(nullptr) { ShouldVisitTemplateInstantiations = true; ShouldVisitImplicitCode = false; // TODO: let's ignore implicit code for now } @@ -104,7 +133,6 @@ class MatchDescendantVisitor : public DynamicRecursiveASTVisitor { Matches = false; if (const Stmt *StmtNode = DynNode.get()) { TraverseStmt(const_cast(StmtNode)); - *Builder = ResultBindings; return Matches; } return false; @@ -186,106 +214,212 @@ class MatchDescendantVisitor : public DynamicRecursiveASTVisitor { return DynamicRecursiveASTVisitor::TraverseStmt(Node); } + void setASTContext(ASTContext &Context) { ActiveASTContext = &Context; } + + void setHandler(const UnsafeBufferUsageHandler &NewHandler) { +Handler = &NewHandler; + } + private: // Sets 'Matched' to true if 'Matcher' matches 'Node' // // Returns 'true' if traversal should continue after this function // returns, i.e. if no match is found or 'Bind'
[clang] [Clang] disallow attributes on void parameters (PR #124920)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/124920 >From bd731e4be65fc9c1746aa6a8f63d206eb54bb2be Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 29 Jan 2025 15:17:06 +0200 Subject: [PATCH 01/13] [Clang] disallow attributes on void parameters --- clang/docs/ReleaseNotes.rst| 2 ++ clang/lib/Parse/ParseDecl.cpp | 7 +++ clang/test/Parser/cxx0x-attributes.cpp | 9 + 3 files changed, 18 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 7fafe2807bd3883..0c87e52007d5463 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -100,6 +100,8 @@ Removed Compiler Flags Attribute Changes in Clang -- +- Clang now disallows the use of attributes on void parameters. (#GH108819) + Improvements to Clang's diagnostics --- diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index f136d5007e8a5f0..0b88dd4449b1e28 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -7986,6 +7986,13 @@ void Parser::ParseParameterDeclarationClause( if (getLangOpts().HLSL) MaybeParseHLSLAnnotations(DS.getAttributes()); +if (ParmDeclarator.getIdentifier() == nullptr && +ParmDeclarator.getDeclarationAttributes().size() && +ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) { + SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range; + Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << AttrRange; +} + if (Tok.is(tok::kw_requires)) { // User tried to define a requires clause in a parameter declaration, // which is surely not a function declaration. diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp index fad3010c98b9c28..13fcdd142fa841f 100644 --- a/clang/test/Parser/cxx0x-attributes.cpp +++ b/clang/test/Parser/cxx0x-attributes.cpp @@ -453,3 +453,12 @@ namespace P2361 { } alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced attributes; expected attributes here}} + +namespace GH108819 { +void a([[maybe_unused]] void) {} // expected-error {{an attribute list cannot appear here}} \ + // expected-warning {{use of the 'maybe_unused' attribute is a C++17 extension}} +void b([[deprecated]] void) {} // expected-error {{an attribute list cannot appear here}} \ + // expected-warning {{use of the 'deprecated' attribute is a C++14 extension}} +void c([[clang::lifetimebound]] void) {} // expected-error {{an attribute list cannot appear here}} +void d([[clang::annotate("a", "b", 1)]] void) {} // expected-error {{an attribute list cannot appear here}} +} >From 063f76730ebfd289f5340d0d8477a43a5ea965c2 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 29 Jan 2025 15:54:48 +0200 Subject: [PATCH 02/13] remove unnecessary name check --- clang/lib/Parse/ParseDecl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 0b88dd4449b1e28..934c16c95915203 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -7986,8 +7986,7 @@ void Parser::ParseParameterDeclarationClause( if (getLangOpts().HLSL) MaybeParseHLSLAnnotations(DS.getAttributes()); -if (ParmDeclarator.getIdentifier() == nullptr && -ParmDeclarator.getDeclarationAttributes().size() && +if (ParmDeclarator.getDeclarationAttributes().size() && ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) { SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range; Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << AttrRange; >From 3f3431513ad59111794953d27e64608b3ce2e6e1 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 29 Jan 2025 16:07:18 +0200 Subject: [PATCH 03/13] use empty instead of size --- clang/lib/Parse/ParseDecl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 934c16c95915203..963b59565953d45 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -7986,7 +7986,7 @@ void Parser::ParseParameterDeclarationClause( if (getLangOpts().HLSL) MaybeParseHLSLAnnotations(DS.getAttributes()); -if (ParmDeclarator.getDeclarationAttributes().size() && +if (!ParmDeclarator.getDeclarationAttributes().empty() && ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) { SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range; Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << AttrRange; >From 9919006df9ec32023b2bf179b72f9ebaf977bd08
[clang] [llvm] [Clang][Driver] Add an option to control loop-interchange (PR #125830)
https://github.com/sjoerdmeijer updated https://github.com/llvm/llvm-project/pull/125830 >From 1a655ebd2bb01f54af6c42a373fb19e91dc56e5a Mon Sep 17 00:00:00 2001 From: Sjoerd Meijer Date: Thu, 6 Feb 2025 03:00:24 -0800 Subject: [PATCH] [Clang][Driver] Add an option to control loop-interchange This introduces options -floop-interchange and -fno-loop-interchange to enable/disable the loop-interchange pass. This is part of the work that tries to get that pass enabled by default (#124911), where it was remarked that a user facing option to control this would be convenient to have. The option (name) is the same as GCC's. --- clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td| 4 clang/lib/CodeGen/BackendUtil.cpp| 2 ++ clang/lib/Driver/ToolChains/Clang.cpp| 2 ++ clang/lib/Frontend/CompilerInvocation.cpp| 7 +++ clang/test/Driver/clang_f_opts.c | 7 +++ llvm/include/llvm/Passes/PassBuilder.h | 4 llvm/lib/Passes/PassBuilderPipelines.cpp | 7 --- 8 files changed, 31 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 1ab8c7fb4d3c33c..22e6bf4aae6db50 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -319,6 +319,7 @@ CODEGENOPT(TimePassesPerRun , 1, 0) ///< Set when -ftime-report=per-pass-run is CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is enabled. VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity (in microseconds), ///< traced by time profiler +CODEGENOPT(InterchangeLoops , 1, 0) ///< Run loop-interchange. CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled. CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled. CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index df705104d9ea314..f49bba96bcd90c5 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4161,6 +4161,10 @@ def ftrap_function_EQ : Joined<["-"], "ftrap-function=">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Issue call to specified function rather than a trap instruction">, MarshallingInfoString>; +def floop_interchange : Flag<["-"], "floop-interchange">, Group, + HelpText<"Enable the loop interchange pass">, Visibility<[ClangOption, CC1Option]>; +def fno_loop_interchange: Flag<["-"], "fno-loop-interchange">, Group, + HelpText<"Disable the loop interchange pass">, Visibility<[ClangOption, CC1Option]>; def funroll_loops : Flag<["-"], "funroll-loops">, Group, HelpText<"Turn on loop unroller">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>; def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 3e65eeb3755d2ff..0f20fba09e44409 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -881,6 +881,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline( PipelineTuningOptions PTO; PTO.LoopUnrolling = CodeGenOpts.UnrollLoops; + PTO.LoopInterchange = CodeGenOpts.InterchangeLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. PTO.LoopInterleaving = CodeGenOpts.UnrollLoops; @@ -1305,6 +1306,7 @@ runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex, initTargetOptions(CI, Diags, Conf.Options); Conf.SampleProfile = std::move(SampleProfile); Conf.PTO.LoopUnrolling = CGOpts.UnrollLoops; + Conf.PTO.LoopInterchange = CGOpts.InterchangeLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 33f08cf28feca18..bb7ddb93e338c04 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7041,6 +7041,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings); Args.AddLastArg(CmdArgs, options::OPT_funroll_loops, options::OPT_fno_unroll_loops); + Args.AddLastArg(CmdArgs, options::OPT_floop_interchange, + options::OPT_fno_loop_interchange); Args.AddLastArg(CmdArgs, options::OPT_fstrict_flex_arrays_EQ); diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 3bf124e4827be96..cb030473908fa6c 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1665,6 +1665,11 @@ void CompilerInv
[clang] [llvm] [Clang][Driver] Add an option to control loop-interchange (PR #125830)
@@ -316,6 +312,7 @@ PipelineTuningOptions::PipelineTuningOptions() { LoopVectorization = true; SLPVectorization = false; LoopUnrolling = true; + LoopInterchange = false; sjoerdmeijer wrote: Good idea, that's now fixed. https://github.com/llvm/llvm-project/pull/125830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)
@@ -2610,6 +2610,9 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings( // The Callback function that performs analyses: auto CallAnalyzers = [&](const Decl *Node) -> void { +if (isa(Node) && Node->hasAttr()) Fznamznon wrote: The attribute can be applied to a `FunctionDecl` or a `FieldDecl`. Is the check `isa(Node)` necessary? It seems the `CallableVisitor` won't do anything for `FieldDecl`s anyway. https://github.com/llvm/llvm-project/pull/125671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][Driver] Add an option to control loop-interchange (PR #125830)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff cb714e74cc0efd5bfdb3e5e80978239425bd83d4 1a655ebd2bb01f54af6c42a373fb19e91dc56e5a --extensions cpp,c,h -- clang/lib/CodeGen/BackendUtil.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/Driver/clang_f_opts.c llvm/include/llvm/Passes/PassBuilder.h llvm/lib/Passes/PassBuilderPipelines.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 9977605c3c..fd59535a15 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -200,9 +200,9 @@ static cl::opt ExtraVectorizerPasses( static cl::opt RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden, cl::desc("Run the NewGVN pass")); -static cl::opt EnableLoopInterchange( -"enable-loopinterchange", cl::init(false), cl::Hidden, -cl::desc("Enable the LoopInterchange Pass")); +static cl::opt +EnableLoopInterchange("enable-loopinterchange", cl::init(false), cl::Hidden, + cl::desc("Enable the LoopInterchange Pass")); static cl::opt EnableUnrollAndJam("enable-unroll-and-jam", cl::init(false), cl::Hidden, `` https://github.com/llvm/llvm-project/pull/125830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Stop parsing warning suppression mappings in driver (PR #125722)
https://github.com/kadircet updated https://github.com/llvm/llvm-project/pull/125722 From 4b24e73d39da9ad9badb2411363082a44046fc3f Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Tue, 4 Feb 2025 17:45:55 +0100 Subject: [PATCH] [clang] Stop parsing warning suppression mappings in driver This gets rid of some extra IO from driver startup, and possiblity of emitting warnings twice. --- .../test/Driver/warning-suppression-mappings-not-parsed.cpp | 5 + clang/tools/driver/driver.cpp| 4 2 files changed, 9 insertions(+) create mode 100644 clang/test/Driver/warning-suppression-mappings-not-parsed.cpp diff --git a/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp new file mode 100644 index 000..8f52fb1c6cc7d6c --- /dev/null +++ b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp @@ -0,0 +1,5 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: echo '[unknown-warning]' > %t/foo.txt +// RUN: %clang -fdriver-only --warning-suppression-mappings=%t/foo.txt %s | FileCheck -allow-empty %s +// CHECK-NOT: unknown warning option 'unknown-warning' diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index 74923247b7ee169..00c00cea16f470f 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -318,6 +318,10 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { IntrusiveRefCntPtr DiagOpts = CreateAndPopulateDiagOpts(Args); + // Driver's diagnostics don't use suppression mappings, so don't bother + // parsing them. CC1 still receives full args, so this doesn't impact other + // actions. + DiagOpts->DiagnosticSuppressionMappingsFile.clear(); TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)
llvmbot wrote: @llvm/pr-subscribers-flang-driver Author: Kareem Ergawy (ergawy) Changes This PR starts the effort to upstream AMD's internal implementation of `do concurrent` to OpenMP mapping. This replaces #77285 since we extended this WIP quite a bit on our fork over the past year. An important part of this PR is a document that describes the current status downstream, the upstreaming status, and next steps to make this pass much more useful. In addition to this document, this PR also contains the skeleton of the pass (no useful transformations are done yet) and some testing for the added command line options. --- Patch is 36.89 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126026.diff 17 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+4) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (+2-1) - (added) flang/docs/DoConcurrentConversionToOpenMP.md (+380) - (modified) flang/include/flang/Frontend/CodeGenOptions.def (+2) - (modified) flang/include/flang/Frontend/CodeGenOptions.h (+5) - (modified) flang/include/flang/Optimizer/OpenMP/Passes.h (+2) - (modified) flang/include/flang/Optimizer/OpenMP/Passes.td (+30) - (added) flang/include/flang/Optimizer/OpenMP/Utils.h (+26) - (modified) flang/include/flang/Optimizer/Passes/Pipelines.h (+10-1) - (modified) flang/lib/Frontend/CompilerInvocation.cpp (+30) - (modified) flang/lib/Frontend/FrontendActions.cpp (+26-5) - (modified) flang/lib/Optimizer/OpenMP/CMakeLists.txt (+1) - (added) flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp (+104) - (modified) flang/lib/Optimizer/Passes/Pipelines.cpp (+7-2) - (added) flang/test/Transforms/DoConcurrent/basic_host.f90 (+53) - (added) flang/test/Transforms/DoConcurrent/command_line_options.f90 (+18) - (modified) flang/tools/bbc/bbc.cpp (+19-1) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c0749c418b7bcec..7fc22bcdff17cd2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6901,6 +6901,10 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group, HelpText<"Emit hermetic module files (no nested USE association)">; + +def do_concurrent_parallel_EQ : Joined<["-"], "fdo-concurrent-parallel=">, + HelpText<"Try to map `do concurrent` loops to OpenMP [none|host|device]">, + Values<"none,host,device">; } // let Visibility = [FC1Option, FlangOption] def J : JoinedOrSeparate<["-"], "J">, diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index e4019c434968744..cf08ec1b900ad90 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -153,7 +153,8 @@ void Flang::addCodegenOptions(const ArgList &Args, CmdArgs.push_back("-fversion-loops-for-stride"); Args.addAllArgs(CmdArgs, - {options::OPT_flang_experimental_hlfir, + {options::OPT_do_concurrent_parallel_EQ, + options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_fno_ppc_native_vec_elem_order, options::OPT_fppc_native_vec_elem_order, diff --git a/flang/docs/DoConcurrentConversionToOpenMP.md b/flang/docs/DoConcurrentConversionToOpenMP.md new file mode 100644 index 000..d40383a06a47b6c --- /dev/null +++ b/flang/docs/DoConcurrentConversionToOpenMP.md @@ -0,0 +1,380 @@ + + +# `DO CONCURENT` mapping to OpenMP + +```{contents} +--- +local: +--- +``` + +This document seeks to describe the effort to parallelize `do concurrent` loops +by mapping them to OpenMP worksharing constructs. The goals of this document +are: +* Describing how to instruct `flang` to map `DO CONCURENT` loops to OpenMP + constructs. +* Tracking the current status of such mapping. +* Describing the limitations of the current implmenentation. +* Describing next steps. +* Tracking the current upstreaming status (from the AMD ROCm fork). + +## Usage + +In order to enable `do concurrent` to OpenMP mapping, `flang` adds a new +compiler flag: `-fdo-concurrent-parallel`. This flags has 3 possible values: +1. `host`: this maps `do concurent` loops to run in parallel on the host CPU. + This maps such loops to the equivalent of `omp parallel do`. +2. `device`: this maps `do concurent` loops to run in parallel on a device + (GPU). This maps such loops to the equivalent of `omp target teams + distribute parallel do`. +3. `none`: this disables `do concurrent` mapping altogether. In such case, such + loops are emitted as sequential loops. + +The above compiler switch is currently avaialble only when OpenMP is also +enabled. So you need to provide the following options to flang in order to +enable it: +``` +flang ... -fopenmp -fdo-concurrent-
[clang] [clang] Stop parsing warning suppression mappings in driver (PR #125722)
https://github.com/kadircet milestoned https://github.com/llvm/llvm-project/pull/125722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Update __cpp_concepts macro (PR #87998)
https://github.com/frederick-vs-ja edited https://github.com/llvm/llvm-project/pull/87998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] d4144ca - [libclc][NFC] Clang-format two files
Author: Fraser Cormack Date: 2025-02-06T09:04:27Z New Revision: d4144ca27da174da3f8e7e3472e788b4246fd04e URL: https://github.com/llvm/llvm-project/commit/d4144ca27da174da3f8e7e3472e788b4246fd04e DIFF: https://github.com/llvm/llvm-project/commit/d4144ca27da174da3f8e7e3472e788b4246fd04e.diff LOG: [libclc][NFC] Clang-format two files Pre-commit changes to avoid noise in an upcoming PR. Added: Modified: libclc/generic/lib/math/clc_fmod.cl libclc/generic/lib/math/clc_remainder.cl Removed: diff --git a/libclc/generic/lib/math/clc_fmod.cl b/libclc/generic/lib/math/clc_fmod.cl index 35298b7e42d5c01..a4a2ab791df68a6 100644 --- a/libclc/generic/lib/math/clc_fmod.cl +++ b/libclc/generic/lib/math/clc_fmod.cl @@ -30,158 +30,156 @@ #include #include -_CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y) -{ -int ux = as_int(x); -int ax = ux & EXSIGNBIT_SP32; -float xa = as_float(ax); -int sx = ux ^ ax; -int ex = ax >> EXPSHIFTBITS_SP32; - -int uy = as_int(y); -int ay = uy & EXSIGNBIT_SP32; -float ya = as_float(ay); -int ey = ay >> EXPSHIFTBITS_SP32; - -float xr = as_float(0x3f80 | (ax & 0x007f)); -float yr = as_float(0x3f80 | (ay & 0x007f)); -int c; -int k = ex - ey; - -while (k > 0) { -c = xr >= yr; -xr -= c ? yr : 0.0f; -xr += xr; ---k; -} - +_CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y) { + int ux = as_int(x); + int ax = ux & EXSIGNBIT_SP32; + float xa = as_float(ax); + int sx = ux ^ ax; + int ex = ax >> EXPSHIFTBITS_SP32; + + int uy = as_int(y); + int ay = uy & EXSIGNBIT_SP32; + float ya = as_float(ay); + int ey = ay >> EXPSHIFTBITS_SP32; + + float xr = as_float(0x3f80 | (ax & 0x007f)); + float yr = as_float(0x3f80 | (ay & 0x007f)); + int c; + int k = ex - ey; + + while (k > 0) { c = xr >= yr; xr -= c ? yr : 0.0f; +xr += xr; +--k; + } -int lt = ex < ey; - -xr = lt ? xa : xr; -yr = lt ? ya : yr; + c = xr >= yr; + xr -= c ? yr : 0.0f; + int lt = ex < ey; -float s = as_float(ey << EXPSHIFTBITS_SP32); -xr *= lt ? 1.0f : s; + xr = lt ? xa : xr; + yr = lt ? ya : yr; -c = ax == ay; -xr = c ? 0.0f : xr; + float s = as_float(ey << EXPSHIFTBITS_SP32); + xr *= lt ? 1.0f : s; -xr = as_float(sx ^ as_int(xr)); + c = ax == ay; + xr = c ? 0.0f : xr; -c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | ay == 0; -xr = c ? as_float(QNANBITPATT_SP32) : xr; + xr = as_float(sx ^ as_int(xr)); -return xr; + c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | + ay == 0; + xr = c ? as_float(QNANBITPATT_SP32) : xr; + return xr; } _CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_fmod, float, float); #ifdef cl_khr_fp64 -_CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) -{ -ulong ux = as_ulong(x); -ulong ax = ux & ~SIGNBIT_DP64; -ulong xsgn = ux ^ ax; -double dx = as_double(ax); -int xexp = convert_int(ax >> EXPSHIFTBITS_DP64); -int xexp1 = 11 - (int) __clc_clz(ax & MANTBITS_DP64); -xexp1 = xexp < 1 ? xexp1 : xexp; - -ulong uy = as_ulong(y); -ulong ay = uy & ~SIGNBIT_DP64; -double dy = as_double(ay); -int yexp = convert_int(ay >> EXPSHIFTBITS_DP64); -int yexp1 = 11 - (int) __clc_clz(ay & MANTBITS_DP64); -yexp1 = yexp < 1 ? yexp1 : yexp; - -// First assume |x| > |y| - -// Set ntimes to the number of times we need to do a -// partial remainder. If the exponent of x is an exact multiple -// of 53 larger than the exponent of y, and the mantissa of x is -// less than the mantissa of y, ntimes will be one too large -// but it doesn't matter - it just means that we'll go round -// the loop below one extra time. -int ntimes = __clc_max(0, (xexp1 - yexp1) / 53); -double w = ldexp(dy, ntimes * 53); -w = ntimes == 0 ? dy : w; -double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; - -// Each time round the loop we compute a partial remainder. -// This is done by subtracting a large multiple of w -// from x each time, where w is a scaled up version of y. -// The subtraction must be performed exactly in quad -// precision, though the result at each stage can -// fit exactly in a double precision number. -int i; -double t, v, p, pp; - -for (i = 0; i < ntimes; i++) { -// Compute integral multiplier -t = __clc_trunc(dx / w); - -// Compute w * t in quad precision -p = w * t; -pp = fma(w, t, -p); - -// Subtract w * t from dx -v = dx - p; -dx = v + (((dx - v) - p) - pp); - -// If t was one too large, dx will be negative. Add back one w. -dx += dx < 0.0 ? w : 0.0; - -// Scale w down by 2^(-53) for the next iteration -
[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)
https://github.com/ergawy created https://github.com/llvm/llvm-project/pull/126026 This PR starts the effort to upstream AMD's internal implementation of `do concurrent` to OpenMP mapping. This replaces #77285 since we extended this WIP quite a bit on our fork over the past year. An important part of this PR is a document that describes the current status downstream, the upstreaming status, and next steps to make this pass much more useful. In addition to this document, this PR also contains the skeleton of the pass (no useful transformations are done yet) and some testing for the added command line options. >From 93576eadc75bece4e49cff2b95519287cb98b8d7 Mon Sep 17 00:00:00 2001 From: ergawy Date: Wed, 5 Feb 2025 23:31:15 -0600 Subject: [PATCH] [flang][OpenMP] Upstream first part of `do concurrent` mapping This PR starts the effort to upstream AMD's internal implementation of `do concurrent` to OpenMP mapping. This replaces #77285 since we extended this WIP quite a bit on our fork over the past year. An important part of this PR is a document that describes the current status downstream, the upstreaming status, and next steps to make this pass much more useful. In addition to this document, this PR also contains the skeleton of the pass (no useful transformations are done yet) and some testing for the added command line options. --- clang/include/clang/Driver/Options.td | 4 + clang/lib/Driver/ToolChains/Flang.cpp | 3 +- flang/docs/DoConcurrentConversionToOpenMP.md | 380 ++ .../include/flang/Frontend/CodeGenOptions.def | 2 + flang/include/flang/Frontend/CodeGenOptions.h | 5 + flang/include/flang/Optimizer/OpenMP/Passes.h | 2 + .../include/flang/Optimizer/OpenMP/Passes.td | 30 ++ flang/include/flang/Optimizer/OpenMP/Utils.h | 26 ++ .../flang/Optimizer/Passes/Pipelines.h| 11 +- flang/lib/Frontend/CompilerInvocation.cpp | 30 ++ flang/lib/Frontend/FrontendActions.cpp| 31 +- flang/lib/Optimizer/OpenMP/CMakeLists.txt | 1 + .../OpenMP/DoConcurrentConversion.cpp | 104 + flang/lib/Optimizer/Passes/Pipelines.cpp | 9 +- .../Transforms/DoConcurrent/basic_host.f90| 53 +++ .../DoConcurrent/command_line_options.f90 | 18 + flang/tools/bbc/bbc.cpp | 20 +- 17 files changed, 719 insertions(+), 10 deletions(-) create mode 100644 flang/docs/DoConcurrentConversionToOpenMP.md create mode 100644 flang/include/flang/Optimizer/OpenMP/Utils.h create mode 100644 flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp create mode 100644 flang/test/Transforms/DoConcurrent/basic_host.f90 create mode 100644 flang/test/Transforms/DoConcurrent/command_line_options.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c0749c418b7bcec..7fc22bcdff17cd2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6901,6 +6901,10 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group, HelpText<"Emit hermetic module files (no nested USE association)">; + +def do_concurrent_parallel_EQ : Joined<["-"], "fdo-concurrent-parallel=">, + HelpText<"Try to map `do concurrent` loops to OpenMP [none|host|device]">, + Values<"none,host,device">; } // let Visibility = [FC1Option, FlangOption] def J : JoinedOrSeparate<["-"], "J">, diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index e4019c434968744..cf08ec1b900ad90 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -153,7 +153,8 @@ void Flang::addCodegenOptions(const ArgList &Args, CmdArgs.push_back("-fversion-loops-for-stride"); Args.addAllArgs(CmdArgs, - {options::OPT_flang_experimental_hlfir, + {options::OPT_do_concurrent_parallel_EQ, + options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_fno_ppc_native_vec_elem_order, options::OPT_fppc_native_vec_elem_order, diff --git a/flang/docs/DoConcurrentConversionToOpenMP.md b/flang/docs/DoConcurrentConversionToOpenMP.md new file mode 100644 index 000..d40383a06a47b6c --- /dev/null +++ b/flang/docs/DoConcurrentConversionToOpenMP.md @@ -0,0 +1,380 @@ + + +# `DO CONCURENT` mapping to OpenMP + +```{contents} +--- +local: +--- +``` + +This document seeks to describe the effort to parallelize `do concurrent` loops +by mapping them to OpenMP worksharing constructs. The goals of this document +are: +* Describing how to instruct `flang` to map `DO CONCURENT` loops to OpenMP + constructs. +* Tracking the current status of such mapping. +* Describing the limitations of the current implmenentation. +* Describing next steps. +* Tracking the current
[clang] [clang] Stop parsing warning suppression mappings in driver (PR #125722)
https://github.com/kadircet closed https://github.com/llvm/llvm-project/pull/125722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] df22bbe - [clang] Stop parsing warning suppression mappings in driver (#125722)
Author: kadir çetinkaya Date: 2025-02-06T10:02:42+01:00 New Revision: df22bbe2beb57687c76402bc0cfdf7901a31cf29 URL: https://github.com/llvm/llvm-project/commit/df22bbe2beb57687c76402bc0cfdf7901a31cf29 DIFF: https://github.com/llvm/llvm-project/commit/df22bbe2beb57687c76402bc0cfdf7901a31cf29.diff LOG: [clang] Stop parsing warning suppression mappings in driver (#125722) This gets rid of some extra IO from driver startup, and possiblity of emitting warnings twice. Added: clang/test/Driver/warning-suppression-mappings-not-parsed.cpp Modified: clang/tools/driver/driver.cpp Removed: diff --git a/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp new file mode 100644 index 000..8f52fb1c6cc7d6c --- /dev/null +++ b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp @@ -0,0 +1,5 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: echo '[unknown-warning]' > %t/foo.txt +// RUN: %clang -fdriver-only --warning-suppression-mappings=%t/foo.txt %s | FileCheck -allow-empty %s +// CHECK-NOT: unknown warning option 'unknown-warning' diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index 74923247b7ee169..00c00cea16f470f 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -318,6 +318,10 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { IntrusiveRefCntPtr DiagOpts = CreateAndPopulateDiagOpts(Args); + // Driver's diagnostics don't use suppression mappings, so don't bother + // parsing them. CC1 still receives full args, so this doesn't impact other + // actions. + DiagOpts->DiagnosticSuppressionMappingsFile.clear(); TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Stop parsing warning suppression mappings in driver (PR #125722)
kadircet wrote: /cherry-pick df22bbe2beb57687c76402bc0cfdf7901a31cf29 https://github.com/llvm/llvm-project/pull/125722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Claiming "threadset clause" for implementation. (PR #126023)
https://github.com/SunilKuravinakop updated https://github.com/llvm/llvm-project/pull/126023 >From cf86e7a2333c36b9cf98d48f51548c847a8c0705 Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop Date: Thu, 6 Feb 2025 02:18:30 -0600 Subject: [PATCH 1/2] Claiming "threadset clause" for implementation. --- clang/docs/OpenMPSupport.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 673c34bf08a4a40..8a7fc0f09708804 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,6 +363,8 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | ++=+===+===+==+ +| threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | +-+---+---+--+ >From b2e4dda18925891b8919c8bf4ea400c852f60dde Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop Date: Thu, 6 Feb 2025 03:06:50 -0600 Subject: [PATCH 2/2] Correcting wrong separator that was used for the new entry of threadset clause. --- clang/docs/OpenMPSupport.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 8a7fc0f09708804..606660519be5856 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,7 +363,7 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | -+=+===+===+==+ ++-+---+---+--+ | threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)
https://github.com/ergawy edited https://github.com/llvm/llvm-project/pull/126026 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Stop parsing warning suppression mappings in driver (PR #125722)
llvmbot wrote: /pull-request llvm/llvm-project#126027 https://github.com/llvm/llvm-project/pull/125722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add -ftime-trace scopes for region-store bindings and removeDead (PR #125884)
@@ -1031,6 +1032,7 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out, const LocationContext *LC, const Stmt *DiagnosticStmt, ProgramPoint::Kind K) { + llvm::TimeTraceScope TimeScope("ExprEngine::removeDead"); necto wrote: I have considered it thanks you your comment. I wasn't aware of it. Unfortunately, it has the following drawbacks: - it might be non-portable, which would cause a headache in the tests - it produces a full function signature, which I find too verbose for a label - it hides the real name of the time scope, which might make it slightly less clear On the other hand, I can use the [`__func__`](https://en.cppreference.com/w/cpp/language/function#func) variable that is portable and short. Yet, it still suffers from the third, admittedly, rather small disadvantage, plus it omits the namespace and the class qualifiers, which I find would obscure the trace. However, it spares some repetition and protects against some C&P bugs. I have no strong preference one way or the other. Do you think I should use it instead? https://github.com/llvm/llvm-project/pull/125884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add -ftime-trace scopes for region-store bindings and removeDead (PR #125884)
https://github.com/necto edited https://github.com/llvm/llvm-project/pull/125884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Parse warning-suppression-mapping after setting up diagengine (PR #125714)
https://github.com/kadircet milestoned https://github.com/llvm/llvm-project/pull/125714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Parse warning-suppression-mapping after setting up diagengine (PR #125714)
llvmbot wrote: /pull-request llvm/llvm-project#126030 https://github.com/llvm/llvm-project/pull/125714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Claiming "threadset clause" for implementation. (PR #126023)
https://github.com/SunilKuravinakop updated https://github.com/llvm/llvm-project/pull/126023 >From cf86e7a2333c36b9cf98d48f51548c847a8c0705 Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop Date: Thu, 6 Feb 2025 02:18:30 -0600 Subject: [PATCH 1/2] Claiming "threadset clause" for implementation. --- clang/docs/OpenMPSupport.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 673c34bf08a4a40..8a7fc0f09708804 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,6 +363,8 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | ++=+===+===+==+ +| threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | +-+---+---+--+ >From b2e4dda18925891b8919c8bf4ea400c852f60dde Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop Date: Thu, 6 Feb 2025 03:06:50 -0600 Subject: [PATCH 2/2] Correcting wrong separator that was used for the new entry of threadset clause. --- clang/docs/OpenMPSupport.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 8a7fc0f09708804..606660519be5856 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,7 +363,7 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | -+=+===+===+==+ ++-+---+---+--+ | threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Emit warnings about incorrect AVR interrupt/signal handlers (PR #125997)
https://github.com/jacquesguan edited https://github.com/llvm/llvm-project/pull/125997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Emit warnings about incorrect AVR interrupt/signal handlers (PR #125997)
@@ -351,8 +351,8 @@ def warn_arm_interrupt_vfp_clobber : Warning< def err_arm_interrupt_called : Error< "interrupt service routine cannot be called directly">; def warn_interrupt_attribute_invalid : Warning< jacquesguan wrote: Maybe change this name since it also contains 'signal' now? https://github.com/llvm/llvm-project/pull/125997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Emit warnings about incorrect AVR interrupt/signal handlers (PR #125997)
@@ -351,8 +351,8 @@ def warn_arm_interrupt_vfp_clobber : Warning< def err_arm_interrupt_called : Error< "interrupt service routine cannot be called directly">; def warn_interrupt_attribute_invalid : Warning< - "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to " - "functions that have %select{no parameters|a 'void' return type}1">, + "%select{MIPS|MSP430|RISC-V|AVR}0 '%1' attribute only applies to " jacquesguan wrote: If only support `interrupt` and `signal`, I think we should use the `select{}` format. https://github.com/llvm/llvm-project/pull/125997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][Driver] Add an option to control loop-interchange (PR #125830)
https://github.com/sjoerdmeijer updated https://github.com/llvm/llvm-project/pull/125830 >From 72c1ccc8cbe7fa9734496a2f9b79fb9f73f126ab Mon Sep 17 00:00:00 2001 From: Sjoerd Meijer Date: Thu, 6 Feb 2025 03:00:24 -0800 Subject: [PATCH] [Clang][Driver] Add an option to control loop-interchange This introduces options -floop-interchange and -fno-loop-interchange to enable/disable the loop-interchange pass. This is part of the work that tries to get that pass enabled by default (#124911), where it was remarked that a user facing option to control this would be convenient to have. The option (name) is the same as GCC's. --- clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td| 4 clang/lib/CodeGen/BackendUtil.cpp| 2 ++ clang/lib/Driver/ToolChains/Clang.cpp| 2 ++ clang/lib/Frontend/CompilerInvocation.cpp| 7 +++ clang/test/Driver/clang_f_opts.c | 7 +++ llvm/include/llvm/Passes/PassBuilder.h | 4 llvm/lib/Passes/PassBuilderPipelines.cpp | 9 +++-- 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 1ab8c7fb4d3c33c..22e6bf4aae6db50 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -319,6 +319,7 @@ CODEGENOPT(TimePassesPerRun , 1, 0) ///< Set when -ftime-report=per-pass-run is CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is enabled. VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity (in microseconds), ///< traced by time profiler +CODEGENOPT(InterchangeLoops , 1, 0) ///< Run loop-interchange. CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled. CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled. CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index df705104d9ea314..f49bba96bcd90c5 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4161,6 +4161,10 @@ def ftrap_function_EQ : Joined<["-"], "ftrap-function=">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Issue call to specified function rather than a trap instruction">, MarshallingInfoString>; +def floop_interchange : Flag<["-"], "floop-interchange">, Group, + HelpText<"Enable the loop interchange pass">, Visibility<[ClangOption, CC1Option]>; +def fno_loop_interchange: Flag<["-"], "fno-loop-interchange">, Group, + HelpText<"Disable the loop interchange pass">, Visibility<[ClangOption, CC1Option]>; def funroll_loops : Flag<["-"], "funroll-loops">, Group, HelpText<"Turn on loop unroller">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>; def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 3e65eeb3755d2ff..0f20fba09e44409 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -881,6 +881,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline( PipelineTuningOptions PTO; PTO.LoopUnrolling = CodeGenOpts.UnrollLoops; + PTO.LoopInterchange = CodeGenOpts.InterchangeLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. PTO.LoopInterleaving = CodeGenOpts.UnrollLoops; @@ -1305,6 +1306,7 @@ runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex, initTargetOptions(CI, Diags, Conf.Options); Conf.SampleProfile = std::move(SampleProfile); Conf.PTO.LoopUnrolling = CGOpts.UnrollLoops; + Conf.PTO.LoopInterchange = CGOpts.InterchangeLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 33f08cf28feca18..bb7ddb93e338c04 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7041,6 +7041,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings); Args.AddLastArg(CmdArgs, options::OPT_funroll_loops, options::OPT_fno_unroll_loops); + Args.AddLastArg(CmdArgs, options::OPT_floop_interchange, + options::OPT_fno_loop_interchange); Args.AddLastArg(CmdArgs, options::OPT_fstrict_flex_arrays_EQ); diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 3bf124e4827be96..cb030473908fa6c 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1665,6 +1665,11 @@ void CompilerI
[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)
brunodf-snps wrote: > I think we can continue to refine our implementation, yeah. [...] The > supertype-ish reasoning I laid out above seems like the right idea. Thanks. FWIW, I think this can be implemented as laid out in #126047. https://github.com/llvm/llvm-project/pull/122116 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][Driver] Add an option to control loop-interchange (PR #125830)
sjoerdmeijer wrote: > The other optimzation pass options (unrolll, vectorize, ...) are implemented > in `PipelineTuningOptions` and `CodeGenOptions.def`. Do it the same way? Thanks for the review and suggestion @Meinersbur, that's now implemented in the latest revision. https://github.com/llvm/llvm-project/pull/125830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Emit warnings about incorrect AVR interrupt/signal handlers (PR #125997)
@@ -351,8 +351,8 @@ def warn_arm_interrupt_vfp_clobber : Warning< def err_arm_interrupt_called : Error< "interrupt service routine cannot be called directly">; def warn_interrupt_attribute_invalid : Warning< benshi001 wrote: fixed. https://github.com/llvm/llvm-project/pull/125997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #125648)
https://github.com/ravurvi20 updated https://github.com/llvm/llvm-project/pull/125648 >From 189dd3cc2230ea5752969f02f119b6ee30e3df69 Mon Sep 17 00:00:00 2001 From: Urvi Rav Date: Tue, 4 Feb 2025 01:35:41 -0600 Subject: [PATCH 1/3] default clause replaced by otherwise clause for metadirective --- .../clang/Basic/DiagnosticParseKinds.td | 4 clang/lib/Parse/ParseOpenMP.cpp | 15 ++ clang/test/OpenMP/metadirective_ast_print.c | 20 +-- .../metadirective_device_arch_codegen.cpp | 2 +- .../metadirective_device_isa_codegen.cpp | 4 ++-- ...etadirective_device_isa_codegen_amdgcn.cpp | 4 ++-- .../metadirective_device_kind_codegen.c | 2 +- .../metadirective_device_kind_codegen.cpp | 2 +- clang/test/OpenMP/metadirective_empty.cpp | 4 ++-- .../metadirective_implementation_codegen.c| 12 +-- .../metadirective_implementation_codegen.cpp | 12 +-- clang/test/OpenMP/metadirective_messages.cpp | 12 +++ 12 files changed, 58 insertions(+), 35 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index c513dab810d1f53..4b8449e9ee9b629 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1657,6 +1657,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_missing_comma : Error< "missing ',' after %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_unknown_clause +: Error<"unknown clause '%0' in %1">; +def warn_omp_default_deprecated : Warning<"'default' clause for" + " 'metadirective' is deprecated; use 'otherwise' instead">, InGroup; def err_omp_requires_out_inout_depend_type : Error< "reserved locator 'omp_all_memory' requires 'out' or 'inout' " "dependency types">; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 89b83938f352dff..673806ef28b9fc6 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2743,6 +2743,15 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( OpenMPClauseKind CKind = Tok.isAnnotation() ? OMPC_unknown : getOpenMPClauseKind(PP.getSpelling(Tok)); + // Check if the clause is unrecognized. + if (CKind == OMPC_unknown) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; +return Directive; + } + if(CKind == OMPC_default) { +Diag(Tok, diag::warn_omp_default_deprecated); + } SourceLocation Loc = ConsumeToken(); // Parse '('. @@ -2769,6 +2778,12 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( return Directive; } } + if (CKind == OMPC_otherwise) { +// Check for 'otherwise' keyword. +if (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->getName() == "otherwise") { +ConsumeToken(); // Consume 'otherwise' +} + } // Skip Directive for now. We will parse directive in the second iteration int paren = 0; while (Tok.isNot(tok::r_paren) || paren != 0) { diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c index d9ff7e764521607..28efaac5949427b 100644 --- a/clang/test/OpenMP/metadirective_ast_print.c +++ b/clang/test/OpenMP/metadirective_ast_print.c @@ -15,18 +15,18 @@ void bar(void); #define N 10 void foo(void) { #pragma omp metadirective when(device = {kind(cpu)} \ - : parallel) default() + : parallel) otherwise() bar(); #pragma omp metadirective when(implementation = {vendor(score(0) \ : llvm)}, \ device = {kind(cpu)} \ - : parallel) default(target teams) + : parallel) otherwise(target teams) bar(); #pragma omp metadirective when(device = {kind(gpu)} \ : target teams) when(implementation = {vendor(llvm)} \ -: parallel) default() +: parallel) otherwise() bar(); -#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \ +#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \ : llvm)}, \ device = {kind(cpu, host)} \ : parallel) @@ -40,15 +40,15 @@ void foo(void) { for (int i = 0; i < 100; i++)
[clang] [llvm] [Clang][Driver] Add an option to control loop-interchange (PR #125830)
https://github.com/sjoerdmeijer updated https://github.com/llvm/llvm-project/pull/125830 >From da944d743f9fb97ddb1a40f58d43b0262f58205a Mon Sep 17 00:00:00 2001 From: Sjoerd Meijer Date: Thu, 6 Feb 2025 03:00:24 -0800 Subject: [PATCH] [Clang][Driver] Add an option to control loop-interchange This introduces options -floop-interchange and -fno-loop-interchange to enable/disable the loop-interchange pass. This is part of the work that tries to get that pass enabled by default (#124911), where it was remarked that a user facing option to control this would be convenient to have. The option (name) is the same as GCC's. --- clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td| 5 + clang/lib/CodeGen/BackendUtil.cpp| 2 ++ clang/lib/Driver/ToolChains/Clang.cpp| 2 ++ clang/lib/Frontend/CompilerInvocation.cpp| 7 +++ clang/test/Driver/clang_f_opts.c | 7 +++ llvm/include/llvm/Passes/PassBuilder.h | 4 llvm/lib/Passes/PassBuilderPipelines.cpp | 9 +++-- 8 files changed, 31 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 1ab8c7fb4d3c33c..22e6bf4aae6db50 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -319,6 +319,7 @@ CODEGENOPT(TimePassesPerRun , 1, 0) ///< Set when -ftime-report=per-pass-run is CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is enabled. VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity (in microseconds), ///< traced by time profiler +CODEGENOPT(InterchangeLoops , 1, 0) ///< Run loop-interchange. CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled. CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled. CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index df705104d9ea314..a0c13246acfedae 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4161,6 +4161,10 @@ def ftrap_function_EQ : Joined<["-"], "ftrap-function=">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Issue call to specified function rather than a trap instruction">, MarshallingInfoString>; +def floop_interchange : Flag<["-"], "floop-interchange">, Group, + HelpText<"Enable the loop interchange pass">, Visibility<[ClangOption, CC1Option]>; +def fno_loop_interchange: Flag<["-"], "fno-loop-interchange">, Group, + HelpText<"Disable the loop interchange pass">, Visibility<[ClangOption, CC1Option]>; def funroll_loops : Flag<["-"], "funroll-loops">, Group, HelpText<"Turn on loop unroller">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>; def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group, @@ -7498,6 +7502,7 @@ defm link_builtin_bitcode_postopt: BoolMOption<"link-builtin-bitcode-postopt", PosFlag, NegFlag>; + def vectorize_loops : Flag<["-"], "vectorize-loops">, HelpText<"Run the Loop vectorization passes">, MarshallingInfoFlag>; diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 3e65eeb3755d2ff..0f20fba09e44409 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -881,6 +881,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline( PipelineTuningOptions PTO; PTO.LoopUnrolling = CodeGenOpts.UnrollLoops; + PTO.LoopInterchange = CodeGenOpts.InterchangeLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. PTO.LoopInterleaving = CodeGenOpts.UnrollLoops; @@ -1305,6 +1306,7 @@ runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex, initTargetOptions(CI, Diags, Conf.Options); Conf.SampleProfile = std::move(SampleProfile); Conf.PTO.LoopUnrolling = CGOpts.UnrollLoops; + Conf.PTO.LoopInterchange = CGOpts.InterchangeLoops; // For historical reasons, loop interleaving is set to mirror setting for loop // unrolling. Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 33f08cf28feca18..bb7ddb93e338c04 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7041,6 +7041,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings); Args.AddLastArg(CmdArgs, options::OPT_funroll_loops, options::OPT_fno_unroll_loops); + Args.AddLastArg(CmdArgs, options::OPT_floop_interchange, + options::OPT_fno_loop_interchange); Args.AddLastArg(CmdArgs, options::OPT_fstrict_flex_arrays_EQ); diff --git a/clang/
[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)
https://github.com/brunodf-snps created https://github.com/llvm/llvm-project/pull/126047 Commit 77d3f8a avoids distinct tags for any pointers where the ultimate pointee type is `void`, to solve breakage in real-world code that uses (indirections to) `void*` for polymorphism over different pointer types. While this matches the TBAA implementation in GCC, this patch implements a refinement that distinguishes void pointers by pointer depth, as described in the "strict aliasing" documentation included in the aforementioned commit: > `void*` is permitted to alias any pointer type, `void**` is permitted > to alias any pointer to pointer type, and so on. For example, `void**` is no longer considered to alias `int*` in this refinement, but it remains possible to use `void**` for polymorphism over pointers to pointers. >From f516639a2bfe5cad76ac82684877f46ac6260077 Mon Sep 17 00:00:00 2001 From: Bruno De Fraine Date: Thu, 6 Feb 2025 11:50:44 +0100 Subject: [PATCH] [TBAA] Refine pointer-tbaa for void pointers by pointer depth Commit 77d3f8a avoids distinct tags for any pointers where the ultimate pointee type is `void`, to solve breakage in real-world code that uses (indirections to) `void*` for polymorphism over different pointer types. While this matches the TBAA implementation in GCC, this patch implements a refinement that distinguishes void pointers by pointer depth, as described in the "strict aliasing" documentation included in the aforementioned commit: > `void*` is permitted to alias any pointer type, `void**` is permitted > to alias any pointer to pointer type, and so on. For example, `void**` is no longer considered to alias `int*` in this refinement, but it remains possible to use `void**` for polymorphism over pointers to pointers. --- clang/lib/CodeGen/CodeGenTBAA.cpp | 30 -- clang/lib/CodeGen/CodeGenTBAA.h| 5 + clang/test/CXX/drs/cwg158.cpp | 3 ++- clang/test/CodeGen/tbaa-pointers.c | 22 ++ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index 3f1a24791ddd816..3a294fd5980472a 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -80,6 +80,25 @@ llvm::MDNode *CodeGenTBAA::getChar() { return Char; } +llvm::MDNode *CodeGenTBAA::getAnyPtr(unsigned PtrDepth) { + assert(PtrDepth >= 1 && "Pointer must have some depth"); + + if (AnyPtrs.size() < PtrDepth) { +AnyPtrs.reserve(PtrDepth); +auto Size = Module.getDataLayout().getPointerSize(); +// Populate first element. +if (AnyPtrs.empty()) + AnyPtrs.push_back(createScalarTypeNode("any pointer", getChar(), Size)); +// Populate further elements. +for (size_t Idx = AnyPtrs.size(); Idx < PtrDepth; ++Idx) { + auto Name = ("any p" + llvm::Twine(Idx + 1) + " pointer").str(); + AnyPtrs.push_back(createScalarTypeNode(Name, AnyPtrs[Idx - 1], Size)); +} + } + + return AnyPtrs[PtrDepth - 1]; +} + static bool TypeHasMayAlias(QualType QTy) { // Tagged types have declarations, and therefore may have attributes. if (auto *TD = QTy->getAsTagDecl()) @@ -202,9 +221,8 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // they involve a significant representation difference. We don't // currently do so, however. if (Ty->isPointerType() || Ty->isReferenceType()) { -llvm::MDNode *AnyPtr = createScalarTypeNode("any pointer", getChar(), Size); if (!CodeGenOpts.PointerTBAA) - return AnyPtr; + return getAnyPtr(); // C++ [basic.lval]p11 permits objects to accessed through an l-value of // similar type. Two types are similar under C++ [conv.qual]p2 if the // decomposition of the types into pointers, member pointers, and arrays has @@ -232,7 +250,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // common idioms and there is no good alternative to re-write the code // without strict-aliasing violations. if (Ty->isVoidType()) - return AnyPtr; + return getAnyPtr(PtrDepth); assert(!isa(Ty)); // When the underlying type is a builtin type, we compute the pointee type @@ -256,7 +274,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // similar-types rule. const auto *RT = Ty->getAs(); if (!RT) -return AnyPtr; +return getAnyPtr(); // For unnamed structs or unions C's compatible types rule applies. Two // compatible types in different compilation units can have different @@ -270,7 +288,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // compatibility rule, but it doesn't matter because you can never have a // pointer to an anonymous struct or union. if (!RT->getDecl()->getDeclName()) -return AnyPtr; +return getAnyPtr(); // For non-builtin types use the mangled name of the canonical typ
[clang] [clang][Sema] Emit warnings about incorrect AVR interrupt/signal handlers (PR #125997)
@@ -351,8 +351,8 @@ def warn_arm_interrupt_vfp_clobber : Warning< def err_arm_interrupt_called : Error< "interrupt service routine cannot be called directly">; def warn_interrupt_attribute_invalid : Warning< - "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to " - "functions that have %select{no parameters|a 'void' return type}1">, + "%select{MIPS|MSP430|RISC-V|AVR}0 '%1' attribute only applies to " benshi001 wrote: fixed. https://github.com/llvm/llvm-project/pull/125997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Bruno De Fraine (brunodf-snps) Changes Commit 77d3f8a avoids distinct tags for any pointers where the ultimate pointee type is `void`, to solve breakage in real-world code that uses (indirections to) `void*` for polymorphism over different pointer types. While this matches the TBAA implementation in GCC, this patch implements a refinement that distinguishes void pointers by pointer depth, as described in the "strict aliasing" documentation included in the aforementioned commit: > `void*` is permitted to alias any pointer type, `void**` is permitted > to alias any pointer to pointer type, and so on. For example, `void**` is no longer considered to alias `int*` in this refinement, but it remains possible to use `void**` for polymorphism over pointers to pointers. --- Full diff: https://github.com/llvm/llvm-project/pull/126047.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CodeGenTBAA.cpp (+24-6) - (modified) clang/lib/CodeGen/CodeGenTBAA.h (+5) - (modified) clang/test/CXX/drs/cwg158.cpp (+2-1) - (modified) clang/test/CodeGen/tbaa-pointers.c (+14-8) ``diff diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index 3f1a24791ddd816..3a294fd5980472a 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -80,6 +80,25 @@ llvm::MDNode *CodeGenTBAA::getChar() { return Char; } +llvm::MDNode *CodeGenTBAA::getAnyPtr(unsigned PtrDepth) { + assert(PtrDepth >= 1 && "Pointer must have some depth"); + + if (AnyPtrs.size() < PtrDepth) { +AnyPtrs.reserve(PtrDepth); +auto Size = Module.getDataLayout().getPointerSize(); +// Populate first element. +if (AnyPtrs.empty()) + AnyPtrs.push_back(createScalarTypeNode("any pointer", getChar(), Size)); +// Populate further elements. +for (size_t Idx = AnyPtrs.size(); Idx < PtrDepth; ++Idx) { + auto Name = ("any p" + llvm::Twine(Idx + 1) + " pointer").str(); + AnyPtrs.push_back(createScalarTypeNode(Name, AnyPtrs[Idx - 1], Size)); +} + } + + return AnyPtrs[PtrDepth - 1]; +} + static bool TypeHasMayAlias(QualType QTy) { // Tagged types have declarations, and therefore may have attributes. if (auto *TD = QTy->getAsTagDecl()) @@ -202,9 +221,8 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // they involve a significant representation difference. We don't // currently do so, however. if (Ty->isPointerType() || Ty->isReferenceType()) { -llvm::MDNode *AnyPtr = createScalarTypeNode("any pointer", getChar(), Size); if (!CodeGenOpts.PointerTBAA) - return AnyPtr; + return getAnyPtr(); // C++ [basic.lval]p11 permits objects to accessed through an l-value of // similar type. Two types are similar under C++ [conv.qual]p2 if the // decomposition of the types into pointers, member pointers, and arrays has @@ -232,7 +250,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // common idioms and there is no good alternative to re-write the code // without strict-aliasing violations. if (Ty->isVoidType()) - return AnyPtr; + return getAnyPtr(PtrDepth); assert(!isa(Ty)); // When the underlying type is a builtin type, we compute the pointee type @@ -256,7 +274,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // similar-types rule. const auto *RT = Ty->getAs(); if (!RT) -return AnyPtr; +return getAnyPtr(); // For unnamed structs or unions C's compatible types rule applies. Two // compatible types in different compilation units can have different @@ -270,7 +288,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // compatibility rule, but it doesn't matter because you can never have a // pointer to an anonymous struct or union. if (!RT->getDecl()->getDeclName()) -return AnyPtr; +return getAnyPtr(); // For non-builtin types use the mangled name of the canonical type. llvm::raw_svector_ostream TyOut(TyName); @@ -281,7 +299,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { OutName += std::to_string(PtrDepth); OutName += " "; OutName += TyName; -return createScalarTypeNode(OutName, AnyPtr, Size); +return createScalarTypeNode(OutName, getAnyPtr(PtrDepth), Size); } // Accesses to arrays are accesses to objects of their element types. diff --git a/clang/lib/CodeGen/CodeGenTBAA.h b/clang/lib/CodeGen/CodeGenTBAA.h index ab3b05df7713ba6..0aae171d168df2a 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.h +++ b/clang/lib/CodeGen/CodeGenTBAA.h @@ -139,6 +139,7 @@ class CodeGenTBAA { llvm::MDNode *Root; llvm::MDNode *Char; + llvm::SmallVector AnyPtrs; /// getRoot - This is the mdnode for the root of the metadata type graph /// for this translation unit. @@ -148,6
[clang] [llvm] [Clang][Driver] Add an option to control loop-interchange (PR #125830)
@@ -316,6 +312,7 @@ PipelineTuningOptions::PipelineTuningOptions() { LoopVectorization = true; SLPVectorization = false; LoopUnrolling = true; + LoopInterchange = false; Meinersbur wrote: The default of `LoopInterchange` could be initialized with `EnableLoopInterchange`, as done by `MergeFunctions = EnableMergeFunction`. Not important for me, but someone might want to keep `-mllvm -enable-loopinterchange` working, e.g. for non-Clang drivers. https://github.com/llvm/llvm-project/pull/125830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Enable IBT by default on OpenBSD/amd64 (PR #125395)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` running on `doug-worker-4` while building `clang` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/14184 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'Clang :: Analysis/live-stmts.cpp' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w -analyzer-checker=debug.DumpLiveExprs /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp 2>&1 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp + /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w -analyzer-checker=debug.DumpLiveExprs /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp + /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp [1m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp:239:16: [0m[0;1;31merror: [0m[1mCHECK-EMPTY: is not on the line after the previous match [0m// CHECK-EMPTY: [0;1;32m ^ [0m[1m:180:1: [0m[0;1;30mnote: [0m[1m'next' match was here [0m [0;1;32m^ [0m[1m:177:1: [0m[0;1;30mnote: [0m[1mprevious match ended here [0m [0;1;32m^ [0m[1m:178:1: [0m[0;1;30mnote: [0m[1mnon-matching line after previous match is here [0mImplicitCastExpr 0x136932f78 '_Bool' [0;1;32m^ [0m Input file: Check file: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp -dump-input=help explains the following input dump. Input was: << [1m[0m[0;1;30m 1: [0m[1m[0;1;46m [0m [0;1;30m 2: [0m[1m[0;1;46m[0m[ B0 (live expressions at block exit) ][0;1;46m [0m [0;1;32mcheck:21 ^~~ [0m[0;1;30m 3: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:22 ^ [0m[0;1;30m 4: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:23 ^ [0m[0;1;30m 5: [0m[1m[0;1;46m[0m[ B1 (live expressions at block exit) ][0;1;46m [0m [0;1;32mcheck:24 ^~~ [0m[0;1;30m 6: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:25 ^ [0m[0;1;30m 7: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:26 ^ [0m[0;1;30m 8: [0m[1m[0;1;46m[0m[ B2 (live expressions at block exit) ][0;1;46m [0m [0;1;32mcheck:27 ^~~ [0m[0;1;30m 9: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:28 ^ [0m[0;1;30m 10: [0m[1m[0;1;46m[0mDeclRefExpr 0x13692fce0 'int' lvalue ParmVar 0x136915870 'y' 'int'[0;1;46m [0m [0;1;32mnext:29 ^~ [0m[0;1;30m 11: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:30 ^ [0m[0;1;30m 12: [0m[1m[0;1;46m[0mDeclRefExpr 0x13692fd00 'int' lvalue ParmVar 0x1369158f0 'z' 'int'[0;1;46m [0m ... ``` https://github.com/llvm/llvm-project/pull/125395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
https://github.com/nightlark updated https://github.com/llvm/llvm-project/pull/125806 >From a4c09eda556104fbe5a8acdb830215b2a4ebd131 Mon Sep 17 00:00:00 2001 From: Ryan Mast Date: Tue, 4 Feb 2025 21:59:28 -0800 Subject: [PATCH] [libclang/python] Enable packaging libclang bindings --- .gitattributes | 2 ++ clang/bindings/python/.git_archival.txt | 3 +++ clang/bindings/python/.gitignore| 21 +++ clang/bindings/python/pyproject.toml| 36 + 4 files changed, 62 insertions(+) create mode 100644 clang/bindings/python/.git_archival.txt create mode 100644 clang/bindings/python/.gitignore create mode 100644 clang/bindings/python/pyproject.toml diff --git a/.gitattributes b/.gitattributes index 6b281f33f737db9..142d6689f108832 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ +clang/bindings/python/.git_archival.txt export-subst + libcxx/src/**/*.cpp merge=libcxx-reformat libcxx/include/**/*.h merge=libcxx-reformat diff --git a/clang/bindings/python/.git_archival.txt b/clang/bindings/python/.git_archival.txt new file mode 100644 index 000..7876d4af4c6206b --- /dev/null +++ b/clang/bindings/python/.git_archival.txt @@ -0,0 +1,3 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=llvmorg-*[0-9]*)$ diff --git a/clang/bindings/python/.gitignore b/clang/bindings/python/.gitignore new file mode 100644 index 000..1641a745fb6829f --- /dev/null +++ b/clang/bindings/python/.gitignore @@ -0,0 +1,21 @@ +# setuptools_scm auto-generated version file +_version.py + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Distribution / packaging +build/ +dist/ +*.egg-info/ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ diff --git a/clang/bindings/python/pyproject.toml b/clang/bindings/python/pyproject.toml new file mode 100644 index 000..8d020f6af0ac39e --- /dev/null +++ b/clang/bindings/python/pyproject.toml @@ -0,0 +1,36 @@ +[build-system] +requires = ["setuptools>=42", "setuptools_scm==8.1.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "clang" +description = "libclang python bindings" +readme = {file = "README.txt", content-type = "text/plain"} + +license = {text = "Apache-2.0 WITH LLVM-exception"} +authors = [ +{ name = "LLVM" } +] +keywords = ["llvm", "clang", "libclang"] +classifiers = [ +"Intended Audience :: Developers", +"Development Status :: 5 - Production/Stable", +"Topic :: Software Development :: Compilers", +"Operating System :: OS Independent", +"Programming Language :: Python :: 3", +] +dynamic = ["version"] + +[project.urls] +Homepage = "https://clang.llvm.org/"; +Download = "https://llvm.org/releases/download.html"; +Discussions = "https://discourse.llvm.org/"; +"Issue Tracker" = "https://github.com/llvm/llvm-project/issues"; +"Source Code" = "https://github.com/llvm/llvm-project/tree/main/clang/bindings/python"; + +[tool.setuptools_scm] +root = "../../.." +version_file = "clang/_version.py" +version_scheme = "no-guess-dev" +# Regex version capture group gets x.y.z with optional -rcN, -aN, -bN suffixes; -init is just consumed +tag_regex = "^llvmorg-(?P\\d+(?:\\.\\d+)*(?:-(?:rc|a|b)\\d+)?)(?:.*)$" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
@@ -0,0 +1,3 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ nightlark wrote: I didn't see an option for `git describe` to list out describes relative to all possible tags -- just listing all tags might be possible but that would also need to somehow dump enough info to calculate the distance like describe does; at that point it seems like the changes needed to setuptools_scm would be fairly extensive. I guess I should probably also pin the setuptools_scm version to something, to avoid surprises if any behavior changes in a future release. https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [libclang/python] Enable packaging libclang bindings (PR #125806)
https://github.com/nightlark edited https://github.com/llvm/llvm-project/pull/125806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #125648)
https://github.com/ravurvi20 updated https://github.com/llvm/llvm-project/pull/125648 >From 189dd3cc2230ea5752969f02f119b6ee30e3df69 Mon Sep 17 00:00:00 2001 From: Urvi Rav Date: Tue, 4 Feb 2025 01:35:41 -0600 Subject: [PATCH 1/3] default clause replaced by otherwise clause for metadirective --- .../clang/Basic/DiagnosticParseKinds.td | 4 clang/lib/Parse/ParseOpenMP.cpp | 15 ++ clang/test/OpenMP/metadirective_ast_print.c | 20 +-- .../metadirective_device_arch_codegen.cpp | 2 +- .../metadirective_device_isa_codegen.cpp | 4 ++-- ...etadirective_device_isa_codegen_amdgcn.cpp | 4 ++-- .../metadirective_device_kind_codegen.c | 2 +- .../metadirective_device_kind_codegen.cpp | 2 +- clang/test/OpenMP/metadirective_empty.cpp | 4 ++-- .../metadirective_implementation_codegen.c| 12 +-- .../metadirective_implementation_codegen.cpp | 12 +-- clang/test/OpenMP/metadirective_messages.cpp | 12 +++ 12 files changed, 58 insertions(+), 35 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index c513dab810d1f53..4b8449e9ee9b629 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1657,6 +1657,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_missing_comma : Error< "missing ',' after %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_unknown_clause +: Error<"unknown clause '%0' in %1">; +def warn_omp_default_deprecated : Warning<"'default' clause for" + " 'metadirective' is deprecated; use 'otherwise' instead">, InGroup; def err_omp_requires_out_inout_depend_type : Error< "reserved locator 'omp_all_memory' requires 'out' or 'inout' " "dependency types">; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 89b83938f352dff..673806ef28b9fc6 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2743,6 +2743,15 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( OpenMPClauseKind CKind = Tok.isAnnotation() ? OMPC_unknown : getOpenMPClauseKind(PP.getSpelling(Tok)); + // Check if the clause is unrecognized. + if (CKind == OMPC_unknown) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; +return Directive; + } + if(CKind == OMPC_default) { +Diag(Tok, diag::warn_omp_default_deprecated); + } SourceLocation Loc = ConsumeToken(); // Parse '('. @@ -2769,6 +2778,12 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( return Directive; } } + if (CKind == OMPC_otherwise) { +// Check for 'otherwise' keyword. +if (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->getName() == "otherwise") { +ConsumeToken(); // Consume 'otherwise' +} + } // Skip Directive for now. We will parse directive in the second iteration int paren = 0; while (Tok.isNot(tok::r_paren) || paren != 0) { diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c index d9ff7e764521607..28efaac5949427b 100644 --- a/clang/test/OpenMP/metadirective_ast_print.c +++ b/clang/test/OpenMP/metadirective_ast_print.c @@ -15,18 +15,18 @@ void bar(void); #define N 10 void foo(void) { #pragma omp metadirective when(device = {kind(cpu)} \ - : parallel) default() + : parallel) otherwise() bar(); #pragma omp metadirective when(implementation = {vendor(score(0) \ : llvm)}, \ device = {kind(cpu)} \ - : parallel) default(target teams) + : parallel) otherwise(target teams) bar(); #pragma omp metadirective when(device = {kind(gpu)} \ : target teams) when(implementation = {vendor(llvm)} \ -: parallel) default() +: parallel) otherwise() bar(); -#pragma omp metadirective default(target) when(implementation = {vendor(score(5) \ +#pragma omp metadirective otherwise(target) when(implementation = {vendor(score(5) \ : llvm)}, \ device = {kind(cpu, host)} \ : parallel) @@ -40,15 +40,15 @@ void foo(void) { for (int i = 0; i < 100; i++)
[clang] [clang][Sema] Emit warnings about incorrect AVR interrupt/signal handlers (PR #125997)
https://github.com/benshi001 updated https://github.com/llvm/llvm-project/pull/125997 >From 2c02723208bd48e82621e3bee5b778f6c8bcd2e5 Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Mon, 27 Jan 2025 13:04:45 +0800 Subject: [PATCH 1/2] [clang][Sema] Emit warnings about incorrect AVR interrupt/signal handlers 1. interrupt/signal handlers can not have parameters 2. interrupt/signal handlers must be 'void' type --- .../clang/Basic/DiagnosticSemaKinds.td| 4 ++-- clang/lib/Sema/SemaAVR.cpp| 24 +++ clang/lib/Sema/SemaMIPS.cpp | 4 ++-- clang/lib/Sema/SemaMSP430.cpp | 4 ++-- clang/lib/Sema/SemaRISCV.cpp | 4 ++-- clang/test/Sema/avr-interript-signal-attr.c | 22 + clang/test/Sema/avr-interrupt-attr.c | 8 --- clang/test/Sema/avr-signal-attr.c | 8 --- 8 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 clang/test/Sema/avr-interript-signal-attr.c delete mode 100644 clang/test/Sema/avr-interrupt-attr.c delete mode 100644 clang/test/Sema/avr-signal-attr.c diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 7b3b932c482baa2..3f732938d6b6b3a 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -351,8 +351,8 @@ def warn_arm_interrupt_vfp_clobber : Warning< def err_arm_interrupt_called : Error< "interrupt service routine cannot be called directly">; def warn_interrupt_attribute_invalid : Warning< - "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to " - "functions that have %select{no parameters|a 'void' return type}1">, + "%select{MIPS|MSP430|RISC-V|AVR}0 '%1' attribute only applies to " + "functions that have %select{no parameters|a 'void' return type}2">, InGroup; def warn_riscv_repeated_interrupt_attribute : Warning< "repeated RISC-V 'interrupt' attribute">, InGroup; diff --git a/clang/lib/Sema/SemaAVR.cpp b/clang/lib/Sema/SemaAVR.cpp index 47368780b620379..ff79fc89f827d16 100644 --- a/clang/lib/Sema/SemaAVR.cpp +++ b/clang/lib/Sema/SemaAVR.cpp @@ -30,6 +30,18 @@ void SemaAVR::handleInterruptAttr(Decl *D, const ParsedAttr &AL) { if (!AL.checkExactlyNumArgs(SemaRef, 0)) return; + // AVR interrupt handlers must have no parameter and be void type. + if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { +Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) +<< /*AVR*/ 3 << "interrupt" << 0; +return; + } + if (!getFunctionOrMethodResultType(D)->isVoidType()) { +Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) +<< /*AVR*/ 3 << "interrupt" << 1; +return; + } + handleSimpleAttribute(*this, D, AL); } @@ -43,6 +55,18 @@ void SemaAVR::handleSignalAttr(Decl *D, const ParsedAttr &AL) { if (!AL.checkExactlyNumArgs(SemaRef, 0)) return; + // AVR signal handlers must have no parameter and be void type. + if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { +Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) +<< /*AVR*/ 3 << "signal" << 0; +return; + } + if (!getFunctionOrMethodResultType(D)->isVoidType()) { +Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) +<< /*AVR*/ 3 << "signal" << 1; +return; + } + handleSimpleAttribute(*this, D, AL); } diff --git a/clang/lib/Sema/SemaMIPS.cpp b/clang/lib/Sema/SemaMIPS.cpp index 50d210e5b381405..2717c93e8c265c7 100644 --- a/clang/lib/Sema/SemaMIPS.cpp +++ b/clang/lib/Sema/SemaMIPS.cpp @@ -272,13 +272,13 @@ void SemaMIPS::handleInterruptAttr(Decl *D, const ParsedAttr &AL) { if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) -<< /*MIPS*/ 0 << 0; +<< /*MIPS*/ 0 << "interrupt" << 0; return; } if (!getFunctionOrMethodResultType(D)->isVoidType()) { Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) -<< /*MIPS*/ 0 << 1; +<< /*MIPS*/ 0 << "interrupt" << 1; return; } diff --git a/clang/lib/Sema/SemaMSP430.cpp b/clang/lib/Sema/SemaMSP430.cpp index 4038a1ff61d63ce..2b9e4769f06f0be 100644 --- a/clang/lib/Sema/SemaMSP430.cpp +++ b/clang/lib/Sema/SemaMSP430.cpp @@ -33,13 +33,13 @@ void SemaMSP430::handleInterruptAttr(Decl *D, const ParsedAttr &AL) { if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) -<< /*MSP430*/ 1 << 0; +<< /*MSP430*/ 1 << "interrupt" << 0; return; } if (!getFunctionOrMethodResultType(D)->isVoidType()) { Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) -<< /*MSP430*/ 1 << 1; +<< /*MSP430*/ 1 << "interrupt" << 1; return; } diff --git a/clang/lib/Sema/
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #125648)
ravurvi20 wrote: > Thank you for this patch. I wonder: was this spelling change introduced in > 5.2? If so, does the compiler after this patch still support the 5.1 spelling > when providing this as the OpenMP version (`-fopenmp-version=5.1`) Yes, otherwise clause was introduced in OpenMP 5.2 version ([Metadirective](https://www.openmp.org/spec-html/5.2/openmpse45.html)). I have added a condition where, for OpenMP 5.2 or later, the compiler generates a warning for the default clause, while for OpenMP 5.1 and earlier, the default clause is accepted without warnings. https://github.com/llvm/llvm-project/pull/125648 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Claiming "threadset clause" for implementation. (PR #126023)
https://github.com/SunilKuravinakop created https://github.com/llvm/llvm-project/pull/126023 threadset clause is part of free-agent threads. But, free-agent threads also involves runtime implementation. So, added an separate entry for threadset clause and claimed it for clang. >From cf86e7a2333c36b9cf98d48f51548c847a8c0705 Mon Sep 17 00:00:00 2001 From: Sunil Kuravinakop Date: Thu, 6 Feb 2025 02:18:30 -0600 Subject: [PATCH] Claiming "threadset clause" for implementation. --- clang/docs/OpenMPSupport.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 673c34bf08a4a40..8a7fc0f09708804 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,6 +363,8 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | ++=+===+===+==+ +| threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | +-+---+---+--+ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Claiming "threadset clause" for implementation. (PR #126023)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (SunilKuravinakop) Changes threadset clause is part of free-agent threads. But, free-agent threads also involves runtime implementation. So, added an separate entry for threadset clause and claimed it for clang. --- Full diff: https://github.com/llvm/llvm-project/pull/126023.diff 1 Files Affected: - (modified) clang/docs/OpenMPSupport.rst (+2) ``diff diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index 673c34bf08a4a4..8a7fc0f0970880 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -363,6 +363,8 @@ implementation. |Feature | C/C++ Status | Fortran Status | Reviews | +=+===+===+==+ | free-agent threads | :none:`unclaimed` | :none:`unclaimed` | | ++=+===+===+==+ +| threadset clause| :`worked on` | :none:`unclaimed` | | +-+---+---+--+ | Recording of task graphs| :none:`unclaimed` | :none:`unclaimed` | | +-+---+---+--+ `` https://github.com/llvm/llvm-project/pull/126023 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add -ftime-trace scopes for region-store bindings and removeDead (PR #125884)
@@ -1031,6 +1032,7 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out, const LocationContext *LC, const Stmt *DiagnosticStmt, ProgramPoint::Kind K) { + llvm::TimeTraceScope TimeScope("ExprEngine::removeDead"); necto wrote: @NagyDonat, are you speaking about grepping for the full `"ExprEngine::removeDead"` rather than just `removeDead`? This is what I meant by the third drawback, it is easier to find the explicit string literal. On the other hand, I don't know how different that is from, for example, grepping for just `removeDead` that would show up in the trace, which should also yield the desired function. Given that `removeDead` function name is still there right next to the `TimeScope` declaration, I consider it should be fine discoverability-wise https://github.com/llvm/llvm-project/pull/125884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 112490c - [analyzer] Use getFileName and do not use realpath names (#126039)
Author: Utkarsh Saxena Date: 2025-02-06T11:15:20+01:00 New Revision: 112490ce04edeb0b34ab2079b649e907c62fd47e URL: https://github.com/llvm/llvm-project/commit/112490ce04edeb0b34ab2079b649e907c62fd47e DIFF: https://github.com/llvm/llvm-project/commit/112490ce04edeb0b34ab2079b649e907c62fd47e.diff LOG: [analyzer] Use getFileName and do not use realpath names (#126039) The real paths resolves symlinks and makes the tests fail when the filesystem is a symlink tree over a content-addressable storage (our internal environment). Added: Modified: clang/lib/StaticAnalyzer/Core/BugReporter.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 4100812c4623e90..13677ed341d0c4c 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -299,7 +299,8 @@ std::string timeTraceName(const BugReportEquivClass &EQ) { return ("Flushing EQC " + BT.getDescription()).str(); } -llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) { +llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ, + const SourceManager &SM) { // Must be called only when constructing non-bogus TimeTraceScope assert(llvm::timeTraceProfilerEnabled()); @@ -309,9 +310,7 @@ llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) { const BugReport *R = BugReports.front().get(); const auto &BT = R->getBugType(); auto Loc = R->getLocation().asLocation(); - std::string File = ""; - if (const auto *Entry = Loc.getFileEntry()) -File = Entry->tryGetRealPathName().str(); + std::string File = SM.getFilename(Loc).str(); return {BT.getCheckerName().str(), std::move(File), static_cast(Loc.getLineNumber())}; } @@ -3150,8 +3149,9 @@ BugReport *PathSensitiveBugReporter::findReportInEquivalenceClass( } void BugReporter::FlushReport(BugReportEquivClass &EQ) { - llvm::TimeTraceScope TCS{timeTraceName(EQ), - [&EQ]() { return timeTraceMetadata(EQ); }}; + llvm::TimeTraceScope TCS{timeTraceName(EQ), [&]() { + return timeTraceMetadata(EQ, getSourceManager()); + }}; SmallVector bugReports; BugReport *report = findReportInEquivalenceClass(EQ, bugReports); if (!report) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Use getFileName and do not use realpath names (PR #126039)
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/126039 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Use getFileName and do not use realpath names (PR #126039)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/126039 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] When linking with the Fortran runtime also link with libexecinfo (PR #125998)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` running on `doug-worker-4` while building `clang,flang` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/14191 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'Clang :: Analysis/live-stmts.cpp' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w -analyzer-checker=debug.DumpLiveExprs /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp 2>&1 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp + /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w -analyzer-checker=debug.DumpLiveExprs /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp + /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp [1m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp:239:16: [0m[0;1;31merror: [0m[1mCHECK-EMPTY: is not on the line after the previous match [0m// CHECK-EMPTY: [0;1;32m ^ [0m[1m:180:1: [0m[0;1;30mnote: [0m[1m'next' match was here [0m [0;1;32m^ [0m[1m:177:1: [0m[0;1;30mnote: [0m[1mprevious match ended here [0m [0;1;32m^ [0m[1m:178:1: [0m[0;1;30mnote: [0m[1mnon-matching line after previous match is here [0mImplicitCastExpr 0x127017f78 '_Bool' [0;1;32m^ [0m Input file: Check file: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp -dump-input=help explains the following input dump. Input was: << [1m[0m[0;1;30m 1: [0m[1m[0;1;46m [0m [0;1;30m 2: [0m[1m[0;1;46m[0m[ B0 (live expressions at block exit) ][0;1;46m [0m [0;1;32mcheck:21 ^~~ [0m[0;1;30m 3: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:22 ^ [0m[0;1;30m 4: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:23 ^ [0m[0;1;30m 5: [0m[1m[0;1;46m[0m[ B1 (live expressions at block exit) ][0;1;46m [0m [0;1;32mcheck:24 ^~~ [0m[0;1;30m 6: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:25 ^ [0m[0;1;30m 7: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:26 ^ [0m[0;1;30m 8: [0m[1m[0;1;46m[0m[ B2 (live expressions at block exit) ][0;1;46m [0m [0;1;32mcheck:27 ^~~ [0m[0;1;30m 9: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:28 ^ [0m[0;1;30m 10: [0m[1m[0;1;46m[0mDeclRefExpr 0x1270152e0 'int' lvalue ParmVar 0x127877a70 'y' 'int'[0;1;46m [0m [0;1;32mnext:29 ^~ [0m[0;1;30m 11: [0m[1m[0;1;46m[0m [0m [0;1;32mempty:30 ^ [0m[0;1;30m 12: [0m[1m[0;1;46m[0mDeclRefExpr 0x127015300 'int' lvalue ParmVar 0x127877af0 'z' 'int'[0;1;46m [0m ... ``` https://github.com/llvm/llvm-project/pull/125998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add time-trace scopes for high-level analyzer steps (PR #125508)
steakhal wrote: FYI others had issue with this commit, fixed by #126039. https://github.com/llvm/llvm-project/pull/125508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][clang]: Implement a conditional lifetimebound_if builtin. (PR #125520)
ilya-biryukov wrote: > One question is whether the reflection proposal would address something like > this. If it does, it might make more sense to invest in that than a custom > solution. That seems like a great long-term direction, but the amount of investment between the two is also vastly different. I think we can either have something like an attribute now, or wait quite a long time for the reflection proposal to flesh out and be implemented. I think the reality is that this particular PR is **only** exploring a solution we can get relatively quickly and with relatively little effort. (Which also puts a burden on it to not cause too much maintenance cost in the long term, obviously, we don't want a quick hack that doesn't really scale or is too expensive in the long run). > ...cat is already out of the bag... Definitely agree, it's quite a nuanced topic. > I think even [[clang::diagnose_if(...)]] can cause template instantiations > that change program behavior. Unrelated, but I'd be curious to see those if you have any examples. I thought that maybe SFINAE could cause this, but at least [in simple examples](https://gcc.godbolt.org/z/5EeMhr4nW) `diagnose_if` does not affect overloading. > My reason is slightly different though: the moment we have another analysis > to add to the picture (something other than lifetimebound), we might run into > a case where we want one part of the spec for one analysis, and another for > the other... and I can't think of a decent way to do that. At the same time, > I'm not sure how likely that scenario is? I definitely have the same concerns, every single analysis makes things more and more chatty and I already feel we're close to a tipping point where annotating things becomes too hard. FWIW, it would be great to get something that "magically" works with a single attribute and does not need complicated compile-time computations. If we cannot get that, the approach with `clang::lifetimebound_like` seems like the second-best alternative. It's simple and show allow modelling functions forwarding to constructors in STL: `make_unique`, `emplace_back`, etc. Seems like a huge win, even if it's not modelling all the nuances that more sophisticated lifetime annotations could achieve. I believe @hokein was about to prepare a list of interesting code examples that we want to support. It would probably be great to that and see how many we can cover with various options, it should help us make a more informed decision. https://github.com/llvm/llvm-project/pull/125520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] Reland: [clang] fix P3310 overload resolution flag propagation (PR #125791)
hokein wrote: Heads-up: this patch triggers a MSAN failure in an lldb test (`lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py`), the stacktrace: ``` ==5633==WARNING: MemorySanitizer: use-of-uninitialized-value #0 in decltype(auto) clang::ASTNodeImporter::CallOverloadedCreateFun::operator()&, bool, clang::ClassTemplateSpecializationDecl*&>(clang::ASTContext&, clang::TagTypeKind&&, clang::DeclContext*&, clang::SourceLocation&, clang::SourceLocation&, clang::ClassTemplateDecl*&, llvm::SmallVector&, bool&&, clang::ClassTemplateSpecializationDecl*&) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:234:16 #1 in bool clang::ASTNodeImporter::GetImportedOrCreateSpecialDecl, clang::ClassTemplateSpecializationDecl, clang::ASTContext&, clang::TagTypeKind, clang::DeclContext*&, clang::SourceLocation&, clang::SourceLocation&, clang::ClassTemplateDecl*&, llvm::SmallVector&, bool, clang::ClassTemplateSpecializationDecl*&>(clang::ClassTemplateSpecializationDecl*&, clang::ASTNodeImporter::CallOverloadedCreateFun, clang::ClassTemplateSpecializationDecl*, clang::ASTContext&, clang::TagTypeKind&&, clang::DeclContext*&, clang::SourceLocation&, clang::SourceLocation&, clang::ClassTemplateDecl*&, llvm::SmallVector&, bool&&, clang::ClassTemplateSpecializationDecl*&) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:281:13 #2 in GetImportedOrCreateDecl &, bool, clang::ClassTemplateSpecializationDecl *&> llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:251:14 #3 in clang::ASTNodeImporter::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:6323:9 #4 in clang::declvisitor::Base>::Visit(clang::Decl*) llvm/llvm-project/clang/include/clang/AST/DeclNodes.inc #5 in clang::ASTImporter::ImportImpl(clang::Decl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9126:19 #6 in lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(clang::Decl*) llvm/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp:1134:23 #7 in clang::ASTImporter::Import(clang::Decl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9521:27 #8 in std::__msan::conditional, llvm::Expected, llvm::Expected>::type clang::ASTNodeImporter::import(clang::RecordDecl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:203:31 #9 in clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:1559:40 #10 in clang::TypeVisitor>::Visit(clang::Type const*) llvm/llvm-project/clang/include/clang/AST/TypeNodes.inc:76:1 #11 in clang::ASTImporter::Import(clang::Type const*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9157:36 #12 in clang::ASTImporter::Import(clang::QualType) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9171:31 #13 in import llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:217:23 #14 in llvm::Expected clang::ASTNodeImporter::import(clang::TemplateArgument const&) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:832:32 #15 in clang::ASTNodeImporter::ImportTemplateArguments(llvm::ArrayRef, llvm::SmallVectorImpl&) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:2453:24 #16 in clang::ASTNodeImporter::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:6219:11 #17 in clang::declvisitor::Base>::Visit(clang::Decl*) llvm/llvm-project/clang/include/clang/AST/DeclNodes.inc #18 in clang::ASTImporter::ImportImpl(clang::Decl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9126:19 #19 in lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(clang::Decl*) llvm/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp:1134:23 #20 in clang::ASTImporter::Import(clang::Decl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9521:27 #21 in std::__msan::conditional, llvm::Expected, llvm::Expected>::type clang::ASTNodeImporter::import(clang::RecordDecl*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:203:31 #22 in clang::ASTNodeImporter::VisitRecordType(clang::RecordType const*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:1559:40 #23 in clang::TypeVisitor>::Visit(clang::Type const*) llvm/llvm-project/clang/include/clang/AST/TypeNodes.inc:76:1 #24 in clang::ASTImporter::Import(clang::Type const*) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9157:36 #25 in clang::ASTImporter::Import(clang::QualType) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:9171:31 #26 in import llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:217:23 #27 in clang::QualType clang::ASTNodeImporter::importChecked(llvm::Error&, clang::QualType const&) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:692:30 #28 in clang::ASTNodeImporter::VisitTypedefNameDecl(clang::TypedefNameDecl*, bool) llvm/llvm-project/clang/lib/AST/ASTImporter.cpp:2823:27 #29 in VisitTyped
[clang] [clang-format] Add BreakBeforeTemplateCloser option (PR #118046)
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/118046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/126026 >From 04b5656b48bedf1250280c4145ee1c9b2a3f7cdf Mon Sep 17 00:00:00 2001 From: ergawy Date: Wed, 5 Feb 2025 23:31:15 -0600 Subject: [PATCH] [flang][OpenMP] Upstream first part of `do concurrent` mapping This PR starts the effort to upstream AMD's internal implementation of `do concurrent` to OpenMP mapping. This replaces #77285 since we extended this WIP quite a bit on our fork over the past year. An important part of this PR is a document that describes the current status downstream, the upstreaming status, and next steps to make this pass much more useful. In addition to this document, this PR also contains the skeleton of the pass (no useful transformations are done yet) and some testing for the added command line options. --- clang/include/clang/Driver/Options.td | 4 + clang/lib/Driver/ToolChains/Flang.cpp | 3 +- flang/docs/DoConcurrentConversionToOpenMP.md | 380 ++ flang/docs/index.md | 1 + .../include/flang/Frontend/CodeGenOptions.def | 2 + flang/include/flang/Frontend/CodeGenOptions.h | 5 + flang/include/flang/Optimizer/OpenMP/Passes.h | 2 + .../include/flang/Optimizer/OpenMP/Passes.td | 30 ++ flang/include/flang/Optimizer/OpenMP/Utils.h | 26 ++ .../flang/Optimizer/Passes/Pipelines.h| 11 +- flang/lib/Frontend/CompilerInvocation.cpp | 30 ++ flang/lib/Frontend/FrontendActions.cpp| 31 +- flang/lib/Optimizer/OpenMP/CMakeLists.txt | 1 + .../OpenMP/DoConcurrentConversion.cpp | 104 + flang/lib/Optimizer/Passes/Pipelines.cpp | 9 +- .../Transforms/DoConcurrent/basic_host.f90| 53 +++ .../DoConcurrent/command_line_options.f90 | 18 + flang/tools/bbc/bbc.cpp | 20 +- 18 files changed, 720 insertions(+), 10 deletions(-) create mode 100644 flang/docs/DoConcurrentConversionToOpenMP.md create mode 100644 flang/include/flang/Optimizer/OpenMP/Utils.h create mode 100644 flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp create mode 100644 flang/test/Transforms/DoConcurrent/basic_host.f90 create mode 100644 flang/test/Transforms/DoConcurrent/command_line_options.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 77ca2d2aac31be1..992e4066153829c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6910,6 +6910,10 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stri def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, Group, HelpText<"Emit hermetic module files (no nested USE association)">; + +def do_concurrent_parallel_EQ : Joined<["-"], "fdo-concurrent-parallel=">, + HelpText<"Try to map `do concurrent` loops to OpenMP [none|host|device]">, + Values<"none,host,device">; } // let Visibility = [FC1Option, FlangOption] def J : JoinedOrSeparate<["-"], "J">, diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index e4019c434968744..cf08ec1b900ad90 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -153,7 +153,8 @@ void Flang::addCodegenOptions(const ArgList &Args, CmdArgs.push_back("-fversion-loops-for-stride"); Args.addAllArgs(CmdArgs, - {options::OPT_flang_experimental_hlfir, + {options::OPT_do_concurrent_parallel_EQ, + options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_fno_ppc_native_vec_elem_order, options::OPT_fppc_native_vec_elem_order, diff --git a/flang/docs/DoConcurrentConversionToOpenMP.md b/flang/docs/DoConcurrentConversionToOpenMP.md new file mode 100644 index 000..6805061859556a1 --- /dev/null +++ b/flang/docs/DoConcurrentConversionToOpenMP.md @@ -0,0 +1,380 @@ + + +# `DO CONCURENT` mapping to OpenMP + +```{contents} +--- +local: +--- +``` + +This document seeks to describe the effort to parallelize `do concurrent` loops +by mapping them to OpenMP worksharing constructs. The goals of this document +are: +* Describing how to instruct `flang` to map `DO CONCURENT` loops to OpenMP + constructs. +* Tracking the current status of such mapping. +* Describing the limitations of the current implmenentation. +* Describing next steps. +* Tracking the current upstreaming status (from the AMD ROCm fork). + +## Usage + +In order to enable `do concurrent` to OpenMP mapping, `flang` adds a new +compiler flag: `-fdo-concurrent-parallel`. This flags has 3 possible values: +1. `host`: this maps `do concurent` loops to run in parallel on the host CPU. + This maps such loops to the equivalent of `omp parallel do`. +2. `device`: this maps `do concurent` loops to run in parallel on a device + (GPU). This maps such loops to the equivalent of `om
[clang] [clang] Parse warning-suppression-mapping after setting up diagengine (PR #125714)
https://github.com/kadircet closed https://github.com/llvm/llvm-project/pull/125714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)
https://github.com/ArtSin updated https://github.com/llvm/llvm-project/pull/123963 >From 3ebeb7bac943e447adecbefcebbd1f4f5b8d03aa Mon Sep 17 00:00:00 2001 From: Artem Sinkevich Date: Thu, 6 Feb 2025 13:56:56 +0400 Subject: [PATCH] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID Add support for expanding `%b` in `LLVM_PROFILE_FILE` to the binary ID (build ID). It can be used with `%m` to avoid its signature collisions. This is supported on all platforms where writing binary IDs into profiles is implemented, as the `__llvm_write_binary_ids` function is used. Fixes #51560. --- clang/docs/SourceBasedCodeCoverage.rst| 5 ++ clang/docs/UsersManual.rst| 13 - compiler-rt/lib/profile/InstrProfilingFile.c | 58 +-- .../test/profile/Linux/binary-id-path.c | 40 + 4 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 compiler-rt/test/profile/Linux/binary-id-path.c diff --git a/clang/docs/SourceBasedCodeCoverage.rst b/clang/docs/SourceBasedCodeCoverage.rst index 73910e134a58911..49bce3b72b45aa2 100644 --- a/clang/docs/SourceBasedCodeCoverage.rst +++ b/clang/docs/SourceBasedCodeCoverage.rst @@ -94,6 +94,11 @@ directory structure will be created. Additionally, the following special not specified (i.e the pattern is "%m"), it's assumed that ``N = 1``. The merge pool specifier can only occur once per filename pattern. +* "%b" expands out to the binary ID (build ID). It can be used with "%Nm" to + avoid binary signature collisions. To use it, the program should be compiled + with the build ID linker option (``--build-id`` for GNU ld or LLD). Linux, + Windows and AIX are supported. + * "%c" expands out to nothing, but enables a mode in which profile counter updates are continuously synced to a file. This means that if the instrumented program crashes, or is killed by a signal, perfect coverage diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 260e84910c6f783..71e3e5ffdaa3636 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -2880,7 +2880,8 @@ instrumentation: environment variable to specify an alternate file. If non-default file name is specified by both the environment variable and the command line option, the environment variable takes precedence. The file name pattern specified - can include different modifiers: ``%p``, ``%h``, ``%m``, ``%t``, and ``%c``. + can include different modifiers: ``%p``, ``%h``, ``%m``, ``%b``, ``%t``, and + ``%c``. Any instance of ``%p`` in that file name will be replaced by the process ID, so that you can easily distinguish the profile output from multiple @@ -2902,11 +2903,11 @@ instrumentation: ``%p`` is that the storage requirement for raw profile data files is greatly increased. To avoid issues like this, the ``%m`` specifier can used in the profile name. When this specifier is used, the profiler runtime will substitute ``%m`` - with a unique integer identifier associated with the instrumented binary. Additionally, + with an integer identifier associated with the instrumented binary. Additionally, multiple raw profiles dumped from different processes that share a file system (can be on different hosts) will be automatically merged by the profiler runtime during the dumping. If the program links in multiple instrumented shared libraries, each library - will dump the profile data into its own profile data file (with its unique integer + will dump the profile data into its own profile data file (with its integer id embedded in the profile name). Note that the merging enabled by ``%m`` is for raw profile data generated by profiler runtime. The resulting merged "raw" profile data file still needs to be converted to a different format expected by the compiler ( @@ -2916,6 +2917,12 @@ instrumentation: $ LLVM_PROFILE_FILE="code-%m.profraw" ./code + Although rare, binary signatures used by the ``%m`` specifier can have + collisions. In this case, the ``%b`` specifier, which expands to the binary + ID (build ID in ELF and COFF), can be added. To use it, the program should be + compiled with the build ID linker option (``--build-id`` for GNU ld or LLD). + Linux, Windows and AIX are supported. + See `this `_ section about the ``%t``, and ``%c`` modifiers. diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c index bad4cc71801ec40..343063fd6b754f1 100644 --- a/compiler-rt/lib/profile/InstrProfilingFile.c +++ b/compiler-rt/lib/profile/InstrProfilingFile.c @@ -77,6 +77,7 @@ typedef struct lprofFilename { char Hostname[COMPILER_RT_MAX_HOSTLEN]; unsigned NumPids; unsigned NumHosts; + unsigned NumBinaryIds; /* When in-process merging is enabled, this parameter specifies * the total number of profile data files shared by all the processes * spawn
[clang] [analyzer] Use getFileName and do not use realpath names (PR #126039)
https://github.com/ilya-biryukov approved this pull request. Could you add a description mentioning that real paths resolves symlinks and makes the tests fail when some forms of content-addressable filesystem is used (our internal environment)? Otherwise LG! https://github.com/llvm/llvm-project/pull/126039 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Add -ftime-trace scopes for region-store bindings and removeDead (PR #125884)
@@ -1031,6 +1032,7 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out, const LocationContext *LC, const Stmt *DiagnosticStmt, ProgramPoint::Kind K) { + llvm::TimeTraceScope TimeScope("ExprEngine::removeDead"); steakhal wrote: I think if it's unique, it's a good fit. I don't think we strictly need the namespace part or the function parameter types in the name. I think the shorter the better - assuming they still remain grep-able and unique. https://github.com/llvm/llvm-project/pull/125884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PGO] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)
https://github.com/w2yehia updated https://github.com/llvm/llvm-project/pull/124353 >From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001 From: Wael Yehia Date: Thu, 23 Jan 2025 00:03:15 + Subject: [PATCH 1/7] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode --- clang/docs/UsersManual.rst | 8 clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td| 5 +++ clang/lib/CodeGen/BackendUtil.cpp| 42 +++- clang/lib/Driver/ToolChains/Clang.cpp| 29 ++ clang/test/CodeGen/profile-continuous.c | 16 6 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 clang/test/CodeGen/profile-continuous.c diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 260e84910c6f783..1e5099067339977 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by frontend or the IR pass. overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported by the target, or ``single`` otherwise. +.. option:: -fprofile-continuous + + Enables continuous PGO mode where profile counter updates are continuously + synced to a file. This option sets any neccessary modifiers (currently ``%c``) + in the default profile filename and passes any necessary flags to the + middle-end to support this mode. Value profiling is not supported in + continuous mode. + .. option:: -ftemporal-profile Enables the temporal profiling extension for IRPGO to improve startup time by diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option spec AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified. CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic +CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode /// Choose profile instrumenation kind or no instrumentation. ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone) /// Choose profile kind for PGO use compilation. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], "fprofile-update=">, Values<"atomic,prefer-atomic,single">, MetaVarName<"">, HelpText<"Set update method of profile counters">, MarshallingInfoFlag>; +def fprofile_continuous : Flag<["-"], "fprofile-continuous">, +Group, Visibility<[ClangOption, CC1Option]>, +HelpText<"Enable Continuous PGO mode">, +MarshallingInfoFlag>; + defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling", CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse, PosFlag, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 3951ad01497ccac..afafa8af585c712 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() { : "default_%m.profraw"; } +// Path and name of file used for profile generation +std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) { + std::string FileName = CodeGenOpts.InstrProfileOutput.empty() + ? getDefaultProfileGenName() + : CodeGenOpts.InstrProfileOutput; + if (CodeGenOpts.ContinuousProfileSync) +FileName = "%c" + FileName; + return FileName; +} + class EmitAssemblyHelper { CompilerInstance &CI; DiagnosticsEngine &Diags; @@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts, return std::nullopt; InstrProfOptions Options; Options.NoRedZone = CodeGenOpts.DisableRedZone; - Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput; + Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync + ? ("%c" + CodeGenOpts.InstrProfileOutput) + : CodeGenOpts.InstrProfileOutput; Options.Atomic = CodeGenOpts.AtomicProfileUpdate; return Options; } @@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline( if (CodeGenOpts.hasProfileIRInstr()) // -fprofile-generate. -PGOOpt = PGOOptions( -CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName() - : CodeGenOpts.InstrProfileOutput, -"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr, -
[clang] [clang][DebugInfo] Set EnumKind based on enum_extensibility attribute (PR #126045)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/126045 >From 10d37ec7e406d3b6ff5034003087a4b6cbb76fe0 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 5 Feb 2025 12:02:50 + Subject: [PATCH] [clang][DebugInfo] Set EnumKind based on enum_extensibility attribute This is the 2nd part to https://github.com/llvm/llvm-project/pull/124752. Here we make sure to set the `DICompositeType` `EnumKind` if the enum was declared with `__attribute__((enum_extensibility(...)))`. In DWARF this will be rendered as `DW_AT_APPLE_enum_kind` and will be used by LLDB when creating `clang::EnumDecl`s from debug-info. --- clang/lib/CodeGen/CGDebugInfo.cpp | 6 ++- .../CodeGen/debug-info-enum-extensibility.c | 49 +++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/debug-info-enum-extensibility.c diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index db595796c067e98..d5b584ec0f2e95b 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3567,6 +3567,10 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { DBuilder.createEnumerator(Enum->getName(), Enum->getInitVal())); } + std::optional EnumKind; + if (auto *Attr = ED->getAttr()) +EnumKind = Attr->getExtensibility(); + // Return a CompositeType for the enum itself. llvm::DINodeArray EltArray = DBuilder.getOrCreateArray(Enumerators); @@ -3576,7 +3580,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit); return DBuilder.createEnumerationType( EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, ClassTy, - /*RunTimeLang=*/0, Identifier, ED->isScoped()); + /*RunTimeLang=*/0, Identifier, ED->isScoped(), EnumKind); } llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent, diff --git a/clang/test/CodeGen/debug-info-enum-extensibility.c b/clang/test/CodeGen/debug-info-enum-extensibility.c new file mode 100644 index 000..4f8a42bff3f0195 --- /dev/null +++ b/clang/test/CodeGen/debug-info-enum-extensibility.c @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s + +// CHECK-NOT: enumKind +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "ClosedEnum" +// CHECK-SAME: enumKind: DW_APPLE_ENUM_KIND_Closed) +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "OpenEnum" +// CHECK-SAME: enumKind: DW_APPLE_ENUM_KIND_Open) +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "ClosedFlagEnum" +// CHECK-SAME: enumKind: DW_APPLE_ENUM_KIND_Closed) +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "OpenFlagEnum" +// CHECK-SAME: enumKind: DW_APPLE_ENUM_KIND_Open) +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "MixedEnum" +// CHECK-SAME: enumKind: DW_APPLE_ENUM_KIND_Open) + +enum Enum { + E0, E1 +}; + +enum FlagEnum { + FE0 = 1 << 0, FE1 = 1 << 1 +}; + +enum __attribute__((enum_extensibility(closed))) ClosedEnum { + A0, A1 +}; + +enum __attribute__((enum_extensibility(open))) OpenEnum { + B0, B1 +}; + +enum __attribute__((enum_extensibility(closed),flag_enum)) ClosedFlagEnum { + C0 = 1 << 0, C1 = 1 << 1 +}; + +enum __attribute__((enum_extensibility(open),flag_enum)) OpenFlagEnum { + D0 = 1 << 0, D1 = 1 << 1 +}; + +enum __attribute__((enum_extensibility(open), enum_extensibility(closed))) MixedEnum { + M0, M1 +}; + +enum Enum e; +enum FlagEnum fe; +enum ClosedEnum ce; +enum OpenEnum oe; +enum ClosedFlagEnum cfe; +enum OpenFlagEnum ofe; +enum MixedEnum me; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add clang atomic control options and attribute (PR #114841)
https://github.com/yxsamliu edited https://github.com/llvm/llvm-project/pull/114841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Precommit end-to-end test for `--repository` option (PR #122565)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/122565 >From 7700273abae3318eb47bd508c0131220228b2624 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Sat, 11 Jan 2025 01:21:24 + Subject: [PATCH] [clang-doc] Precommit end-to-end test for `--repository` option We test the `--repository` output in the unit tests, but that option fails to change the HTML output in the end-to-end tests. Upcoming patches will address the incorrect behavior. --- clang-tools-extra/test/clang-doc/basic-project.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index 7c46c52bae687ce..b6b43bb82bb15db 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t/docs %t/build // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json > %t/build/compile_commands.json -// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json +// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json --repository=https://repository.com // RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefix=JSON-INDEX // RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Shape.html -check-prefix=HTML-SHAPE // RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Calculator.html -check-prefix=HTML-CALC @@ -286,4 +286,4 @@ // MD-ALL-FILES: ## [GlobalNamespace](GlobalNamespace{{[\/]}}index.md) // MD-INDEX: # C/C++ Reference -// MD-INDEX: * Namespace: [GlobalNamespace](GlobalNamespace) \ No newline at end of file +// MD-INDEX: * Namespace: [GlobalNamespace](GlobalNamespace) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add clang atomic control options and attribute (PR #114841)
https://github.com/yxsamliu edited https://github.com/llvm/llvm-project/pull/114841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Precommit end-to-end test for `--repository` option (PR #122565)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/122565 >From 872c3d010eaa746683fbc944fbd30a3d2b02a40b Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Sat, 11 Jan 2025 01:21:24 + Subject: [PATCH] [clang-doc] Precommit end-to-end test for `--repository` option We test the `--repository` output in the unit tests, but that option fails to change the HTML output in the end-to-end tests. Upcoming patches will address the incorrect behavior. --- clang-tools-extra/test/clang-doc/basic-project.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index 7c46c52bae687ce..b6b43bb82bb15db 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -1,6 +1,6 @@ // RUN: rm -rf %t && mkdir -p %t/docs %t/build // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json > %t/build/compile_commands.json -// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json +// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json --repository=https://repository.com // RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefix=JSON-INDEX // RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Shape.html -check-prefix=HTML-SHAPE // RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Calculator.html -check-prefix=HTML-CALC @@ -286,4 +286,4 @@ // MD-ALL-FILES: ## [GlobalNamespace](GlobalNamespace{{[\/]}}index.md) // MD-INDEX: # C/C++ Reference -// MD-INDEX: * Namespace: [GlobalNamespace](GlobalNamespace) \ No newline at end of file +// MD-INDEX: * Namespace: [GlobalNamespace](GlobalNamespace) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-linker-wrapper][lit] Fix SPIR-V OpenMP ELF test (PR #126098)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` running on `fuchsia-debian-64-us-central1-a-1` while building `clang` at step 4 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/12205 Here is the relevant piece of the build log for the reference ``` Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure) ... [826/1372] Building CXX object unittests/DebugInfo/LogicalView/CMakeFiles/DebugInfoLogicalViewTests.dir/__/DWARF/DwarfUtils.cpp.o [827/1372] Running the Clang regression tests llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using clang: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin/clang llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126: note: Did not find clang-repl in /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin/ld.lld llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin/lld-link llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin/ld64.lld llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin/wasm-ld -- Testing: 21880 tests, 60 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90 FAIL: Clang :: Tooling/clang-linker-wrapper-spirv-elf.cpp (20551 of 21880) TEST 'Clang :: Tooling/clang-linker-wrapper-spirv-elf.cpp' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 4: mkdir -p /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test/Tooling/Output/clang-linker-wrapper-spirv-elf.cpp.tmp_tmp + mkdir -p /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test/Tooling/Output/clang-linker-wrapper-spirv-elf.cpp.tmp_tmp RUN: at line 5: cd /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test/Tooling/Output/clang-linker-wrapper-spirv-elf.cpp.tmp_tmp + cd /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test/Tooling/Output/clang-linker-wrapper-spirv-elf.cpp.tmp_tmp RUN: at line 6: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin/clang --driver-mode=g++ -fopenmp -fopenmp-targets=spirv64-intel -nogpulib -c -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test/Tooling/Output/clang-linker-wrapper-spirv-elf.cpp.tmp_clang-linker-wrapper-spirv-elf.o /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/bin/clang --driver-mode=g++ -fopenmp -fopenmp-targets=spirv64-intel -nogpulib -c -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test/Tooling/Output/clang-linker-wrapper-spirv-elf.cpp.tmp_clang-linker-wrapper-spirv-elf.o /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp clang: error: unable to execute command: Executable "llvm-spirv" doesn't exist! clang: error: llvm-spirv command failed with exit code 1 (use -v to see invocation) -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Failed Tests (1): Clang :: Tooling/clang-linker-wrapper-spirv-elf.cpp Testing Time: 132.69s Total Discovered Tests: 46237 Skipped : 8 (0.02%) Unsupported : 824 (1.78%) Passed : 45376 (98.14%) Expectedly Failed:28 (0.06%) Failed : 1 (0.00%) [1370/1372] Linking CXX executable unittests/Transforms/Scalar/ScalarTests FAILED: tools/clang/test/CMakeFiles/check-clang /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test/CMakeFiles/check-clang cd /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test && /usr/bin/python3.10 /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/./bin/llvm-lit -sv --param USE_Z3_SOLVER=0 /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp/tools/clang/test ninja: build stopped: subcommand failed. ['ninja', '-C', '/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-7l906exp', 'check-llvm', 'check
[clang] [clang][Sema] Move computing enum bits into a separate function (PR #126096)
kuilpd wrote: > > This is just moving stuff around so that seems fine. Though, I wonder, > > could we just pass e.g. an `ArrayRef` to `computeEnumBits()`? The > > LLDB pr you linked seems to have an `SmallVector`, so > > that should be possible (I think it does require a `reinterpret_cast` from > > a `const Decl**` to a `const EnumConstantDecl**`, but we already do that in > > other places in Clang iirc). > > The reason I suggested the template initially was because in LLDB's case we > don't have the `EnumConstantDecl`s in a container. We only have an > `EnumDecl`. So the plan was to pass the `enumerators()` iterator into > `computeEnumBits`. But if you know of a good way to turn the range into a > container that we can pass as an `ArrayRef`, or some non-template way of > passing both an `iterator_range` and `ArrayRef` into `computeEnumBits`, > that'd be great! Yeah, `enumerator()` returns `llvm::iterator_range>`, and couldn't find a good way to convert this to an `ArrayRef`. I guess I could make a `SmallVector` and put the copy of pointers there at the point of their creation ([here](https://github.com/llvm/llvm-project/blob/b581ad411d6e178300732410dd8850cd34543ac3/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L2373)), since the function return a `EnumConstantDecl`, then discard it. https://github.com/llvm/llvm-project/pull/126096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PGO] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)
@@ -0,0 +1,21 @@ +// 1) test on platforms that (do or do not) require runtime relocation +// +// RUN: %clang -target x86_64-darwin -fprofile-generate -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=NO_RELOC +// NO_RELOC: "-cc1" {{.*}} "-fprofile-continuous" +// NO_RELOC-NOT: "-mllvm" "-runtime-counter-relocation" + +// RUN: %clang -target powerpc64-ibm-aix -fprofile-generate -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC w2yehia wrote: done https://github.com/llvm/llvm-project/pull/124353 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-linker-wrapper][lit] Temporarily disable OpenMP SPIR-V ELF test (PR #126104)
sarnex wrote: Merging this now to unbreak CI, will address any feedback in followup https://github.com/llvm/llvm-project/pull/126104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits