[llvm-branch-commits] [llvm] Bump version to 18.1.7 (PR #93723)
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/93723 None >From 828c6f81112b194cd322cc38ac50b0f2e3404587 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 29 May 2024 12:37:48 -0700 Subject: [PATCH] Bump version to 18.1.7 --- llvm/CMakeLists.txt| 2 +- llvm/utils/lit/lit/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 26b7b01bb1f8d..51278943847aa 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -22,7 +22,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR) set(LLVM_VERSION_MINOR 1) endif() if(NOT DEFINED LLVM_VERSION_PATCH) - set(LLVM_VERSION_PATCH 6) + set(LLVM_VERSION_PATCH 7) endif() if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX) diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py index d8b0e3bd1c69e..5003d78ce5218 100644 --- a/llvm/utils/lit/lit/__init__.py +++ b/llvm/utils/lit/lit/__init__.py @@ -2,7 +2,7 @@ __author__ = "Daniel Dunbar" __email__ = "dan...@minormatter.com" -__versioninfo__ = (18, 1, 6) +__versioninfo__ = (18, 1, 7) __version__ = ".".join(str(v) for v in __versioninfo__) + "dev" __all__ = [] ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Bump version to 18.1.7 (PR #93723)
https://github.com/tstellar milestoned https://github.com/llvm/llvm-project/pull/93723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Bump version to 18.1.7 (PR #93723)
https://github.com/tstellar edited https://github.com/llvm/llvm-project/pull/93723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Bump version to 18.1.7 (PR #93723)
tstellar wrote: @whentojump Yes, but I'm only going to accept critical fixes or regressions for this one. https://github.com/llvm/llvm-project/pull/93723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Bump version to 18.1.7 (PR #93723)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/93723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [PPCMergeStringPool] Only replace constant once (#92996) (PR #93442)
tstellar wrote: What release note should we use for this change? https://github.com/llvm/llvm-project/pull/93442 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [PPCMergeStringPool] Only replace constant once (#92996) (PR #93442)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/93442 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Don't always break before << between str… (PR #94091)
tstellar wrote: @owenca I'm only going to take regression fixes for 18.1.7. https://github.com/llvm/llvm-project/pull/94091 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a bug in formatting goto labels in macros (#92494) (PR #93494)
tstellar wrote: @owenca I'm only going to take regression fixes for 18.1.7. https://github.com/llvm/llvm-project/pull/93494 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a bug in formatting goto labels in macros (#92494) (PR #93494)
tstellar wrote: @owenca OK, can you give me more details: 1) How risky is this fix? 2) When was the last known working version of clang-format? https://github.com/llvm/llvm-project/pull/93494 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Don't always break before << between str… (PR #94091)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/94091 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a bug in formatting goto labels in macros (#92494) (PR #93494)
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/93494 >From 768118d1ad38bf13c545828f67bd6b474d61fc55 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 21 May 2024 01:35:31 -0700 Subject: [PATCH] [clang-format] Fix a bug in formatting goto labels in macros (#92494) Fixes #92300. (cherry picked from commit d89f20058b45e3836527e816af7ed7372e1d554d) --- clang/lib/Format/UnwrappedLineParser.cpp | 9 ++--- clang/unittests/Format/FormatTest.cpp | 8 clang/unittests/Format/TokenAnnotatorTest.cpp | 13 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index f70affb732a0d..179d77bf00491 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1185,12 +1185,6 @@ void UnwrappedLineParser::parsePPDefine() { return; } - if (FormatTok->is(tok::identifier) && - Tokens->peekNextToken()->is(tok::colon)) { -nextToken(); -nextToken(); - } - // Errors during a preprocessor directive can only affect the layout of the // preprocessor directive, and thus we ignore them. An alternative approach // would be to use the same approach we use on the file level (no @@ -1671,7 +1665,8 @@ void UnwrappedLineParser::parseStructuralElement( if (!Style.isJavaScript() && !Style.isVerilog() && !Style.isTableGen() && Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) { nextToken(); - Line->Tokens.begin()->Tok->MustBreakBefore = true; + if (!Line->InMacroBody || CurrentLines->size() > 1) +Line->Tokens.begin()->Tok->MustBreakBefore = true; FormatTok->setFinalizedType(TT_GotoLabelColon); parseLabel(!Style.IndentGotoLabels); if (HasLabel) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d69632f7f0f8c..11ae41bc78ace 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3118,6 +3118,7 @@ TEST_F(FormatTest, FormatsLabels) { "g();\n" " }\n" "}"); + FormatStyle Style = getLLVMStyle(); Style.IndentGotoLabels = false; verifyFormat("void f() {\n" @@ -3157,6 +3158,13 @@ TEST_F(FormatTest, FormatsLabels) { " }\n" "}", Style); + + Style.ColumnLimit = 15; + verifyFormat("#define FOO \\\n" + "label:\\\n" + " break;", + Style); + // The opening brace may either be on the same unwrapped line as the colon or // on a separate one. The formatter should recognize both. Style = getLLVMStyle(); diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 44ebad9d5a872..dfa9c22430f36 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2353,15 +2353,28 @@ TEST_F(TokenAnnotatorTest, UnderstandsLabels) { auto Tokens = annotate("{ x: break; }"); ASSERT_EQ(Tokens.size(), 7u) << Tokens; EXPECT_TOKEN(Tokens[2], tok::colon, TT_GotoLabelColon); + Tokens = annotate("{ case x: break; }"); ASSERT_EQ(Tokens.size(), 8u) << Tokens; EXPECT_TOKEN(Tokens[3], tok::colon, TT_CaseLabelColon); + Tokens = annotate("{ x: { break; } }"); ASSERT_EQ(Tokens.size(), 9u) << Tokens; EXPECT_TOKEN(Tokens[2], tok::colon, TT_GotoLabelColon); + Tokens = annotate("{ case x: { break; } }"); ASSERT_EQ(Tokens.size(), 10u) << Tokens; EXPECT_TOKEN(Tokens[3], tok::colon, TT_CaseLabelColon); + + Tokens = annotate("#define FOO label:"); + ASSERT_EQ(Tokens.size(), 6u) << Tokens; + EXPECT_TOKEN(Tokens[4], tok::colon, TT_GotoLabelColon); + + Tokens = annotate("#define FOO \\\n" +"label: \\\n" +" break;"); + ASSERT_EQ(Tokens.size(), 8u) << Tokens; + EXPECT_TOKEN(Tokens[4], tok::colon, TT_GotoLabelColon); } TEST_F(TokenAnnotatorTest, UnderstandsNestedBlocks) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a bug in formatting goto labels in macros (#92494) (PR #93494)
tstellar wrote: @owenca Do you have a release note we can put in the release announcement? https://github.com/llvm/llvm-project/pull/93494 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Don't always break before << between str… (PR #94091)
tstellar wrote: @owenca Do you have a release note we can put in the release announcement? https://github.com/llvm/llvm-project/pull/94091 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 768118d - [clang-format] Fix a bug in formatting goto labels in macros (#92494)
Author: Owen Pan Date: 2024-06-05T14:56:32-07:00 New Revision: 768118d1ad38bf13c545828f67bd6b474d61fc55 URL: https://github.com/llvm/llvm-project/commit/768118d1ad38bf13c545828f67bd6b474d61fc55 DIFF: https://github.com/llvm/llvm-project/commit/768118d1ad38bf13c545828f67bd6b474d61fc55.diff LOG: [clang-format] Fix a bug in formatting goto labels in macros (#92494) Fixes #92300. (cherry picked from commit d89f20058b45e3836527e816af7ed7372e1d554d) Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index f70affb732a0d..179d77bf00491 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1185,12 +1185,6 @@ void UnwrappedLineParser::parsePPDefine() { return; } - if (FormatTok->is(tok::identifier) && - Tokens->peekNextToken()->is(tok::colon)) { -nextToken(); -nextToken(); - } - // Errors during a preprocessor directive can only affect the layout of the // preprocessor directive, and thus we ignore them. An alternative approach // would be to use the same approach we use on the file level (no @@ -1671,7 +1665,8 @@ void UnwrappedLineParser::parseStructuralElement( if (!Style.isJavaScript() && !Style.isVerilog() && !Style.isTableGen() && Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) { nextToken(); - Line->Tokens.begin()->Tok->MustBreakBefore = true; + if (!Line->InMacroBody || CurrentLines->size() > 1) +Line->Tokens.begin()->Tok->MustBreakBefore = true; FormatTok->setFinalizedType(TT_GotoLabelColon); parseLabel(!Style.IndentGotoLabels); if (HasLabel) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d69632f7f0f8c..11ae41bc78ace 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3118,6 +3118,7 @@ TEST_F(FormatTest, FormatsLabels) { "g();\n" " }\n" "}"); + FormatStyle Style = getLLVMStyle(); Style.IndentGotoLabels = false; verifyFormat("void f() {\n" @@ -3157,6 +3158,13 @@ TEST_F(FormatTest, FormatsLabels) { " }\n" "}", Style); + + Style.ColumnLimit = 15; + verifyFormat("#define FOO \\\n" + "label:\\\n" + " break;", + Style); + // The opening brace may either be on the same unwrapped line as the colon or // on a separate one. The formatter should recognize both. Style = getLLVMStyle(); diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 44ebad9d5a872..dfa9c22430f36 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2353,15 +2353,28 @@ TEST_F(TokenAnnotatorTest, UnderstandsLabels) { auto Tokens = annotate("{ x: break; }"); ASSERT_EQ(Tokens.size(), 7u) << Tokens; EXPECT_TOKEN(Tokens[2], tok::colon, TT_GotoLabelColon); + Tokens = annotate("{ case x: break; }"); ASSERT_EQ(Tokens.size(), 8u) << Tokens; EXPECT_TOKEN(Tokens[3], tok::colon, TT_CaseLabelColon); + Tokens = annotate("{ x: { break; } }"); ASSERT_EQ(Tokens.size(), 9u) << Tokens; EXPECT_TOKEN(Tokens[2], tok::colon, TT_GotoLabelColon); + Tokens = annotate("{ case x: { break; } }"); ASSERT_EQ(Tokens.size(), 10u) << Tokens; EXPECT_TOKEN(Tokens[3], tok::colon, TT_CaseLabelColon); + + Tokens = annotate("#define FOO label:"); + ASSERT_EQ(Tokens.size(), 6u) << Tokens; + EXPECT_TOKEN(Tokens[4], tok::colon, TT_GotoLabelColon); + + Tokens = annotate("#define FOO \\\n" +"label: \\\n" +" break;"); + ASSERT_EQ(Tokens.size(), 8u) << Tokens; + EXPECT_TOKEN(Tokens[4], tok::colon, TT_GotoLabelColon); } TEST_F(TokenAnnotatorTest, UnderstandsNestedBlocks) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a bug in formatting goto labels in macros (#92494) (PR #93494)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/93494 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Bump version to 18.1.8 (PR #95458)
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/95458 None >From 2edf6218b7e74cc76035e4e1efa8166b1c22312d Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 13 Jun 2024 12:33:39 -0700 Subject: [PATCH] Bump version to 18.1.8 --- llvm/CMakeLists.txt| 2 +- llvm/utils/lit/lit/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 51278943847aa..909a965cd86c8 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -22,7 +22,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR) set(LLVM_VERSION_MINOR 1) endif() if(NOT DEFINED LLVM_VERSION_PATCH) - set(LLVM_VERSION_PATCH 7) + set(LLVM_VERSION_PATCH 8) endif() if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX) diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py index 5003d78ce5218..800d59492d8ff 100644 --- a/llvm/utils/lit/lit/__init__.py +++ b/llvm/utils/lit/lit/__init__.py @@ -2,7 +2,7 @@ __author__ = "Daniel Dunbar" __email__ = "dan...@minormatter.com" -__versioninfo__ = (18, 1, 7) +__versioninfo__ = (18, 1, 8) __version__ = ".".join(str(v) for v in __versioninfo__) + "dev" __all__ = [] ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] Bump version to 18.1.8 (PR #95458)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/95458 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [SystemZ] Bugfix in getDemandedSrcElements(). (#88623) (PR #95463)
tstellar wrote: Is this a critical bug? I'm trying to decide if we should add this to 18.1.8. https://github.com/llvm/llvm-project/pull/95463 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Add release note for #95264 (PR #96116)
tstellar wrote: We don't have a great way to add release notes after the final release. I added this to the release announcement do you think that is enough? https://github.com/llvm/llvm-project/pull/96116 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] workflows: Fix libclc-tests (PR #101496)
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/101496 The old out-of-tree build configuration stopped working and in tree builds are supported now, so we should use the in tree configuration. The only downside is we can't run the tests any more, but at least we will be able to test the build again. >From 3ec814d1bcb7064b907526937ae83f23657394af Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 1 Aug 2024 07:58:35 -0700 Subject: [PATCH] workflows: Fix libclc-tests The old out-of-tree build configuration stopped working and in tree builds are supported now, so we should use the in tree configuration. The only downside is we can't run the tests any more, but at least we will be able to test the build again. --- .github/workflows/llvm-project-tests.yml | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index 0a228c41f354e..17a54be16badc 100644 --- a/.github/workflows/llvm-project-tests.yml +++ b/.github/workflows/llvm-project-tests.yml @@ -131,6 +131,7 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLDB_INCLUDE_TESTS=OFF \ + -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ $extra_cmake_args \ @@ -142,8 +143,6 @@ jobs: env: LLVM_BUILDDIR: ${{ steps.build-llvm.outputs.llvm-builddir }} run: | - # Make sure all of LLVM libraries that llvm-config needs are built. + # The libclc tests don't have a generated check target so all we can + # do is build it. ninja -C "$LLVM_BUILDDIR" - cmake -G Ninja -S libclc -B libclc-build -DLLVM_DIR="$LLVM_BUILDDIR"/lib/cmake/llvm -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" - ninja -C libclc-build - ninja -C libclc-build test ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] workflows: Fix libclc-tests (PR #101496)
tstellar wrote: This PR is for testing. The change will need to land in main first. https://github.com/llvm/llvm-project/pull/101496 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] workflows: Fix libclc-tests (PR #101496)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/101496 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] workflows: Fix libclc-tests (PR #101496)
tstellar wrote: Closing in favor of #101539 https://github.com/llvm/llvm-project/pull/101496 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/101554 The old version in the llvm/actions repo stopped working after the version variables were moved out of llvm/CMakeLists.txt. Composite actions are more simple and don't require javascript, which is why I reimplemented it as a composite action. >From 904aab8a345b781c27e5aaa75a8ba64fdef15658 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 1 Aug 2024 13:09:52 -0700 Subject: [PATCH] workflows: Re-implement the get-llvm-version action as a composite The old version in the llvm/actions repo stopped working after the version variables were moved out of llvm/CMakeLists.txt. Composite actions are more simple and don't require javascript, which is why I reimplemented it as a composite action. --- .github/workflows/get-llvm-version/action.yml | 26 +++ .github/workflows/libclang-abi-tests.yml | 16 ++-- .github/workflows/llvm-tests.yml | 14 +- 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/get-llvm-version/action.yml diff --git a/.github/workflows/get-llvm-version/action.yml b/.github/workflows/get-llvm-version/action.yml new file mode 100644 index 0..b33efa67d416b --- /dev/null +++ b/.github/workflows/get-llvm-version/action.yml @@ -0,0 +1,26 @@ +name: Get LLVM Version +description: >- + Get the LLVM version from the llvm-project source tree. This action assumes + the llvm-project sources have already been checked out into GITHUB_WORKSPACE. + +outputs: + major: +description: LLVM major version +value: ${{ steps.version.outputs.major }} + minor: +description: LLVM minor version +value: ${{ steps.version.outputs.minor }} + patch: +description: LLVM patch version +value: ${{ steps.version.outputs.patch }} + +runs: + using: "composite" + steps: +- name: Get Version + shell: bash + id: version + run: | +for v in major minor patch; do + echo echo "$v=`llvm/utils/release/get-llvm-version.sh -$v`" >> $GITHUB_OUTPUT +done diff --git a/.github/workflows/libclang-abi-tests.yml b/.github/workflows/libclang-abi-tests.yml index 972d21c3bcedf..9e839ff49e283 100644 --- a/.github/workflows/libclang-abi-tests.yml +++ b/.github/workflows/libclang-abi-tests.yml @@ -33,9 +33,9 @@ jobs: ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }} ABI_LIBS: ${{ steps.vars.outputs.ABI_LIBS }} BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }} - LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }} - LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }} + LLVM_VERSION_MAJOR: ${{ steps.version.outputs.major }} + LLVM_VERSION_MINOR: ${{ steps.version.outputs.minor }} + LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }} steps: - name: Checkout source uses: actions/checkout@v4 @@ -44,14 +44,14 @@ jobs: - name: Get LLVM version id: version -uses: llvm/actions/get-llvm-version@main +uses: ./.github/workflows/get-llvm-version - name: Setup Variables id: vars run: | remote_repo='https://github.com/llvm/llvm-project' - if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then -major_version=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1)) + if [ ${{ steps.version.outputs.patch }} -eq 0 ]; then +major_version=$(( ${{ steps.version.outputs.major }} - 1)) baseline_ref="llvmorg-$major_version.1.0" # If there is a minor release, we want to use that as the base line. @@ -73,8 +73,8 @@ jobs: } >> "$GITHUB_OUTPUT" else { - echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}" - echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.1.0" + echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.major }}" + echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.major }}.1.0" echo "ABI_HEADERS=." echo "ABI_LIBS=libclang.so libclang-cpp.so" } >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/llvm-tests.yml b/.github/workflows/llvm-tests.yml index 64d60bc3da45e..26e644229aaa2 100644 --- a/.github/workflows/llvm-tests.yml +++ b/.github/workflows/llvm-tests.yml @@ -43,9 +43,9 @@ jobs: ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }} BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }} BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }} - LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }} - LLVM_VERSION_
[llvm-branch-commits] [llvm] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)
tstellar wrote: This PR is for testing purpose, it will need to be committed to main first and then cherry-picked. https://github.com/llvm/llvm-project/pull/101554 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/101554 >From 904aab8a345b781c27e5aaa75a8ba64fdef15658 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 1 Aug 2024 13:09:52 -0700 Subject: [PATCH 1/2] workflows: Re-implement the get-llvm-version action as a composite The old version in the llvm/actions repo stopped working after the version variables were moved out of llvm/CMakeLists.txt. Composite actions are more simple and don't require javascript, which is why I reimplemented it as a composite action. --- .github/workflows/get-llvm-version/action.yml | 26 +++ .github/workflows/libclang-abi-tests.yml | 16 ++-- .github/workflows/llvm-tests.yml | 14 +- 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/get-llvm-version/action.yml diff --git a/.github/workflows/get-llvm-version/action.yml b/.github/workflows/get-llvm-version/action.yml new file mode 100644 index 0..b33efa67d416b --- /dev/null +++ b/.github/workflows/get-llvm-version/action.yml @@ -0,0 +1,26 @@ +name: Get LLVM Version +description: >- + Get the LLVM version from the llvm-project source tree. This action assumes + the llvm-project sources have already been checked out into GITHUB_WORKSPACE. + +outputs: + major: +description: LLVM major version +value: ${{ steps.version.outputs.major }} + minor: +description: LLVM minor version +value: ${{ steps.version.outputs.minor }} + patch: +description: LLVM patch version +value: ${{ steps.version.outputs.patch }} + +runs: + using: "composite" + steps: +- name: Get Version + shell: bash + id: version + run: | +for v in major minor patch; do + echo echo "$v=`llvm/utils/release/get-llvm-version.sh -$v`" >> $GITHUB_OUTPUT +done diff --git a/.github/workflows/libclang-abi-tests.yml b/.github/workflows/libclang-abi-tests.yml index 972d21c3bcedf..9e839ff49e283 100644 --- a/.github/workflows/libclang-abi-tests.yml +++ b/.github/workflows/libclang-abi-tests.yml @@ -33,9 +33,9 @@ jobs: ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }} ABI_LIBS: ${{ steps.vars.outputs.ABI_LIBS }} BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }} - LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }} - LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }} + LLVM_VERSION_MAJOR: ${{ steps.version.outputs.major }} + LLVM_VERSION_MINOR: ${{ steps.version.outputs.minor }} + LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }} steps: - name: Checkout source uses: actions/checkout@v4 @@ -44,14 +44,14 @@ jobs: - name: Get LLVM version id: version -uses: llvm/actions/get-llvm-version@main +uses: ./.github/workflows/get-llvm-version - name: Setup Variables id: vars run: | remote_repo='https://github.com/llvm/llvm-project' - if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then -major_version=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1)) + if [ ${{ steps.version.outputs.patch }} -eq 0 ]; then +major_version=$(( ${{ steps.version.outputs.major }} - 1)) baseline_ref="llvmorg-$major_version.1.0" # If there is a minor release, we want to use that as the base line. @@ -73,8 +73,8 @@ jobs: } >> "$GITHUB_OUTPUT" else { - echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}" - echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.1.0" + echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.major }}" + echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.major }}.1.0" echo "ABI_HEADERS=." echo "ABI_LIBS=libclang.so libclang-cpp.so" } >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/llvm-tests.yml b/.github/workflows/llvm-tests.yml index 64d60bc3da45e..26e644229aaa2 100644 --- a/.github/workflows/llvm-tests.yml +++ b/.github/workflows/llvm-tests.yml @@ -43,9 +43,9 @@ jobs: ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }} BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }} BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }} - LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }} - LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }} + LLVM_VERSION_MAJOR: ${{ steps.version.outputs.major }} + LLVM_VERSION_MINOR: ${{ steps.version.outputs.minor }} + LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }}
[llvm-branch-commits] [llvm] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)
@@ -0,0 +1,86 @@ +#!/usr/bin/env bash +#===-- get-llvm-version.sh - Test the LLVM release candidates --===# tstellar wrote: Fixed here: PR#101569. I'll merge #101569 and then backport the change to the release branch. https://github.com/llvm/llvm-project/pull/101554 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] release/19.x: Workflow fixes for building release binaries (PR #101791)
https://github.com/tstellar milestoned https://github.com/llvm/llvm-project/pull/101791 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] release/19.x: Workflow fixes for building release binaries (PR #101791)
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/101791 This is a collection of fixes needed for building the release binaries. >From 3ec814d1bcb7064b907526937ae83f23657394af Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 1 Aug 2024 07:58:35 -0700 Subject: [PATCH 1/6] workflows: Fix libclc-tests The old out-of-tree build configuration stopped working and in tree builds are supported now, so we should use the in tree configuration. The only downside is we can't run the tests any more, but at least we will be able to test the build again. --- .github/workflows/llvm-project-tests.yml | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index 0a228c41f354e..17a54be16badc 100644 --- a/.github/workflows/llvm-project-tests.yml +++ b/.github/workflows/llvm-project-tests.yml @@ -131,6 +131,7 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLDB_INCLUDE_TESTS=OFF \ + -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ $extra_cmake_args \ @@ -142,8 +143,6 @@ jobs: env: LLVM_BUILDDIR: ${{ steps.build-llvm.outputs.llvm-builddir }} run: | - # Make sure all of LLVM libraries that llvm-config needs are built. + # The libclc tests don't have a generated check target so all we can + # do is build it. ninja -C "$LLVM_BUILDDIR" - cmake -G Ninja -S libclc -B libclc-build -DLLVM_DIR="$LLVM_BUILDDIR"/lib/cmake/llvm -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" - ninja -C libclc-build - ninja -C libclc-build test >From fdd961d5dbd68ca05e64b726e73a149ae67e680d Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 26 Jul 2024 11:26:34 -0700 Subject: [PATCH 2/6] Build release binaries for multiple targets (#98431) This adds release binary builds for the 4 platforms currently supported by the free GitHub Action runners: * Linux x86_64 * Windows x86_64 * Mac x86_64 * Mac AArch64 The test stages for these are known to fail, but the creating and upoading of the release binaries should pass. (cherry picked from commit 247251aee0d4314385a3fea86e31484d3d792ffb) --- .github/workflows/release-binaries-all.yml| 94 .../release-binaries-save-stage/action.yml| 38 ++ .../release-binaries-setup-stage/action.yml | 59 +++ .github/workflows/release-binaries.yml| 474 -- .github/workflows/release-tasks.yml | 10 + clang/cmake/caches/Release.cmake | 6 +- 6 files changed, 520 insertions(+), 161 deletions(-) create mode 100644 .github/workflows/release-binaries-all.yml create mode 100644 .github/workflows/release-binaries-save-stage/action.yml create mode 100644 .github/workflows/release-binaries-setup-stage/action.yml diff --git a/.github/workflows/release-binaries-all.yml b/.github/workflows/release-binaries-all.yml new file mode 100644 index 0..73c9d96946e33 --- /dev/null +++ b/.github/workflows/release-binaries-all.yml @@ -0,0 +1,94 @@ +name: Release Binaries All + +permissions: + contents: read # Default everything to read-only + +on: + workflow_dispatch: +inputs: + release-version: +description: 'Release Version' +required: true +type: string + upload: +description: 'Upload binaries to the release page' +required: true +default: false +type: boolean + + workflow_call: +inputs: + release-version: +description: 'Release Version' +required: true +type: string + upload: +description: 'Upload binaries to the release page' +required: true +default: false +type: boolean + + pull_request: +types: + - opened + - synchronize + - reopened + # When a PR is closed, we still start this workflow, but then skip + # all the jobs, which makes it effectively a no-op. The reason to + # do this is that it allows us to take advantage of concurrency groups + # to cancel in progress CI jobs whenever the PR is closed. + - closed +paths: + - '.github/workflows/release-binaries-all.yml' + - '.github/workflows/release-binaries.yml' + - '.github/workflows/release-binaries-setup-stage/*' + - '.github/workflows/release-binaries-save-stage/*' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || 'dispatch' }} + cancel-in-progress: True + +jobs: + setup-variables: +if: >- + (github.event_name != 'pull_request' || github.event.action != 'closed') +
[llvm-branch-commits] [clang] [llvm] release/19.x: Workflow fixes for building release binaries (PR #101791)
https://github.com/tstellar edited https://github.com/llvm/llvm-project/pull/101791 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] release/19.x: Workflow fixes for building release binaries (PR #101791)
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/101791 >From 3ec814d1bcb7064b907526937ae83f23657394af Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 1 Aug 2024 07:58:35 -0700 Subject: [PATCH 1/7] workflows: Fix libclc-tests The old out-of-tree build configuration stopped working and in tree builds are supported now, so we should use the in tree configuration. The only downside is we can't run the tests any more, but at least we will be able to test the build again. --- .github/workflows/llvm-project-tests.yml | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index 0a228c41f354e..17a54be16badc 100644 --- a/.github/workflows/llvm-project-tests.yml +++ b/.github/workflows/llvm-project-tests.yml @@ -131,6 +131,7 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLDB_INCLUDE_TESTS=OFF \ + -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ $extra_cmake_args \ @@ -142,8 +143,6 @@ jobs: env: LLVM_BUILDDIR: ${{ steps.build-llvm.outputs.llvm-builddir }} run: | - # Make sure all of LLVM libraries that llvm-config needs are built. + # The libclc tests don't have a generated check target so all we can + # do is build it. ninja -C "$LLVM_BUILDDIR" - cmake -G Ninja -S libclc -B libclc-build -DLLVM_DIR="$LLVM_BUILDDIR"/lib/cmake/llvm -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" - ninja -C libclc-build - ninja -C libclc-build test >From fdd961d5dbd68ca05e64b726e73a149ae67e680d Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 26 Jul 2024 11:26:34 -0700 Subject: [PATCH 2/7] Build release binaries for multiple targets (#98431) This adds release binary builds for the 4 platforms currently supported by the free GitHub Action runners: * Linux x86_64 * Windows x86_64 * Mac x86_64 * Mac AArch64 The test stages for these are known to fail, but the creating and upoading of the release binaries should pass. (cherry picked from commit 247251aee0d4314385a3fea86e31484d3d792ffb) --- .github/workflows/release-binaries-all.yml| 94 .../release-binaries-save-stage/action.yml| 38 ++ .../release-binaries-setup-stage/action.yml | 59 +++ .github/workflows/release-binaries.yml| 474 -- .github/workflows/release-tasks.yml | 10 + clang/cmake/caches/Release.cmake | 6 +- 6 files changed, 520 insertions(+), 161 deletions(-) create mode 100644 .github/workflows/release-binaries-all.yml create mode 100644 .github/workflows/release-binaries-save-stage/action.yml create mode 100644 .github/workflows/release-binaries-setup-stage/action.yml diff --git a/.github/workflows/release-binaries-all.yml b/.github/workflows/release-binaries-all.yml new file mode 100644 index 0..73c9d96946e33 --- /dev/null +++ b/.github/workflows/release-binaries-all.yml @@ -0,0 +1,94 @@ +name: Release Binaries All + +permissions: + contents: read # Default everything to read-only + +on: + workflow_dispatch: +inputs: + release-version: +description: 'Release Version' +required: true +type: string + upload: +description: 'Upload binaries to the release page' +required: true +default: false +type: boolean + + workflow_call: +inputs: + release-version: +description: 'Release Version' +required: true +type: string + upload: +description: 'Upload binaries to the release page' +required: true +default: false +type: boolean + + pull_request: +types: + - opened + - synchronize + - reopened + # When a PR is closed, we still start this workflow, but then skip + # all the jobs, which makes it effectively a no-op. The reason to + # do this is that it allows us to take advantage of concurrency groups + # to cancel in progress CI jobs whenever the PR is closed. + - closed +paths: + - '.github/workflows/release-binaries-all.yml' + - '.github/workflows/release-binaries.yml' + - '.github/workflows/release-binaries-setup-stage/*' + - '.github/workflows/release-binaries-save-stage/*' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || 'dispatch' }} + cancel-in-progress: True + +jobs: + setup-variables: +if: >- + (github.event_name != 'pull_request' || github.event.action != 'closed') +runs-on: ubuntu-22.04 +outputs: + release-version: ${{ steps.var
[llvm-branch-commits] [llvm] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/101554 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)
tstellar wrote: Closed in favor of #101793 https://github.com/llvm/llvm-project/pull/101554 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] PR for llvm/llvm-project#79155 (PR #80484)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80484 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] PR for llvm/llvm-project#80441 (PR #80444)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80444 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] d9f8cd8 - [Clang][AArch64] Add missing SME macros (#80293)
Author: Sander de Smalen Date: 2024-02-03T10:17:11-08:00 New Revision: d9f8cd8028db85204724f4efc1eec9b567dac05c URL: https://github.com/llvm/llvm-project/commit/d9f8cd8028db85204724f4efc1eec9b567dac05c DIFF: https://github.com/llvm/llvm-project/commit/d9f8cd8028db85204724f4efc1eec9b567dac05c.diff LOG: [Clang][AArch64] Add missing SME macros (#80293) __ARM_STATE_ZA and __ARM_STATE_ZT0 are set when the compiler can parse the "za" and "zt0" strings in the SME attributes. __ARM_FEATURE_SME and __ARM_FEATURE_SME2 are set when the compiler can generate code for attributes with "za" and "zt0" state, respectively. __ARM_FEATURE_LOCALLY_STREAMING is set when the compiler supports the __arm_locally_streaming attribute. (cherry picked from commit 9e649518e6038a5b9ea38cfa424468657d3be59e) Added: Modified: clang/lib/Basic/Targets/AArch64.cpp clang/lib/Basic/Targets/AArch64.h clang/test/Preprocessor/aarch64-target-features.c clang/test/Preprocessor/init-aarch64.c Removed: diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index d47181bfca4fc..336b7a5e3d727 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -387,6 +387,11 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4"); + // These macros are set when Clang can parse declarations with these + // attributes. + Builder.defineMacro("__ARM_STATE_ZA", "1"); + Builder.defineMacro("__ARM_STATE_ZT0", "1"); + // 0xe implies support for half, single and double precision operations. if (FPU & FPUMode) Builder.defineMacro("__ARM_FP", "0xE"); @@ -431,6 +436,17 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts, if (HasSVE2 && HasSVE2SM4) Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1"); + if (HasSME) { +Builder.defineMacro("__ARM_FEATURE_SME"); +Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1"); + } + + if (HasSME2) { +Builder.defineMacro("__ARM_FEATURE_SME"); +Builder.defineMacro("__ARM_FEATURE_SME2"); +Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1"); + } + if (HasCRC) Builder.defineMacro("__ARM_FEATURE_CRC32", "1"); @@ -686,6 +702,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const { .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3) .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4) .Case("sme", HasSME) + .Case("sme2", HasSME2) .Case("sme-f64f64", HasSMEF64F64) .Case("sme-i16i64", HasSMEI16I64) .Case("sme-fa64", HasSMEFA64) @@ -806,6 +823,12 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features, HasBFloat16 = true; HasFullFP16 = true; } +if (Feature == "+sme2") { + HasSME = true; + HasSME2 = true; + HasBFloat16 = true; + HasFullFP16 = true; +} if (Feature == "+sme-f64f64") { HasSME = true; HasSMEF64F64 = true; diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index f0e0782e7abe9..9699222b0bf77 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { bool HasCCDP = false; bool HasFRInt3264 = false; bool HasSME = false; + bool HasSME2 = false; bool HasSMEF64F64 = false; bool HasSMEI16I64 = false; bool HasSB = false; diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c index 15879da04fcf0..9914775097e57 100644 --- a/clang/test/Preprocessor/aarch64-target-features.c +++ b/clang/test/Preprocessor/aarch64-target-features.c @@ -60,6 +60,10 @@ // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048 +// CHECK: __ARM_STATE_ZA 1 +// CHECK: __ARM_STATE_ZT0 1 +// CHECK-NOT: __ARM_FEATURE_SME +// CHECK-NOT: __ARM_FEATURE_SME2 // RUN: %clang -target aarch64-none-elf -march=armv8-r -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-R-PROFILE // RUN: %clang -target arm64-none-linux-gnu -march=armv8-r -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-R-PROFILE @@ -634,3 +638,12 @@ // RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc3 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-RCPC3 %s // CHECK-RCPC3: __ARM_FEATURE_RCPC 3 + +// RUN: %clang --target=aarch64 -march=armv9-a+sme -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SME %s +// CHECK-SME: __ARM_FEATURE_LOCALLY_STREAMING 1 +// CHECK-SME: __ARM_FEATURE_SME 1 +// +// RUN: %clang --target=aarch64 -march=armv9-a+sme2 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SME2 %s +// CHECK-SME2: __ARM_FEATURE_LOCALLY_STREAMING 1 +// CHECK-SME2: __ARM_FEATURE_SME 1 +// CHECK-SME2: __ARM_FEATURE_
[llvm-branch-commits] [llvm] b7dd1e0 - [PhaseOrdering] Add additional test for #79161 (NFC)
Author: Nikita Popov Date: 2024-02-03T10:22:03-08:00 New Revision: b7dd1e099f2c3335ba2636cd1d4cfcc4db7a243d URL: https://github.com/llvm/llvm-project/commit/b7dd1e099f2c3335ba2636cd1d4cfcc4db7a243d DIFF: https://github.com/llvm/llvm-project/commit/b7dd1e099f2c3335ba2636cd1d4cfcc4db7a243d.diff LOG: [PhaseOrdering] Add additional test for #79161 (NFC) (cherry picked from commit 543cf08636f3a3bb55dddba2e8cad787601647ba) Added: llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll Modified: Removed: diff --git a/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll b/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll new file mode 100644 index 0..846787f721ba7 --- /dev/null +++ b/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll @@ -0,0 +1,147 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -S -O3 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s + +define internal void @acc(ptr noalias noundef %val, ptr noalias noundef %prev) { +entry: + %0 = load i8, ptr %prev, align 1 + %conv = zext i8 %0 to i32 + %1 = load i8, ptr %val, align 1 + %conv1 = zext i8 %1 to i32 + %add = add nsw i32 %conv1, %conv + %conv2 = trunc i32 %add to i8 + store i8 %conv2, ptr %val, align 1 + ret void +} + +; This loop should not get vectorized. +; FIXME: This is a miscompile. +define void @accsum(ptr noundef %vals, i64 noundef %num) #0 { +; CHECK-LABEL: define void @accsum( +; CHECK-SAME: ptr nocapture noundef [[VALS:%.*]], i64 noundef [[NUM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[CMP1:%.*]] = icmp ugt i64 [[NUM]], 1 +; CHECK-NEXT:br i1 [[CMP1]], label [[ITER_CHECK:%.*]], label [[FOR_END:%.*]] +; CHECK: iter.check: +; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[NUM]], -1 +; CHECK-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[NUM]], 9 +; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK]], label [[FOR_BODY_PREHEADER:%.*]], label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]] +; CHECK: vector.main.loop.iter.check: +; CHECK-NEXT:[[MIN_ITERS_CHECK3:%.*]] = icmp ult i64 [[NUM]], 33 +; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK3]], label [[VEC_EPILOG_PH:%.*]], label [[VECTOR_PH:%.*]] +; CHECK: vector.ph: +; CHECK-NEXT:[[N_VEC:%.*]] = and i64 [[TMP0]], -32 +; CHECK-NEXT:br label [[VECTOR_BODY:%.*]] +; CHECK: vector.body: +; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] +; CHECK-NEXT:[[OFFSET_IDX:%.*]] = or disjoint i64 [[INDEX]], 1 +; CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds i8, ptr [[VALS]], i64 [[OFFSET_IDX]] +; CHECK-NEXT:[[TMP2:%.*]] = getelementptr i8, ptr [[TMP1]], i64 -1 +; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl(metadata [[META0:![0-9]+]]) +; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl(metadata [[META3:![0-9]+]]) +; CHECK-NEXT:[[TMP3:%.*]] = getelementptr i8, ptr [[TMP1]], i64 15 +; CHECK-NEXT:[[WIDE_LOAD:%.*]] = load <16 x i8>, ptr [[TMP2]], align 1, !alias.scope [[META3]], !noalias [[META0]] +; CHECK-NEXT:[[WIDE_LOAD4:%.*]] = load <16 x i8>, ptr [[TMP3]], align 1, !alias.scope [[META3]], !noalias [[META0]] +; CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 16 +; CHECK-NEXT:[[WIDE_LOAD5:%.*]] = load <16 x i8>, ptr [[TMP1]], align 1, !alias.scope [[META0]], !noalias [[META3]] +; CHECK-NEXT:[[WIDE_LOAD6:%.*]] = load <16 x i8>, ptr [[TMP4]], align 1, !alias.scope [[META0]], !noalias [[META3]] +; CHECK-NEXT:[[TMP5:%.*]] = add <16 x i8> [[WIDE_LOAD5]], [[WIDE_LOAD]] +; CHECK-NEXT:[[TMP6:%.*]] = add <16 x i8> [[WIDE_LOAD6]], [[WIDE_LOAD4]] +; CHECK-NEXT:store <16 x i8> [[TMP5]], ptr [[TMP1]], align 1, !alias.scope [[META0]], !noalias [[META3]] +; CHECK-NEXT:store <16 x i8> [[TMP6]], ptr [[TMP4]], align 1, !alias.scope [[META0]], !noalias [[META3]] +; CHECK-NEXT:[[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32 +; CHECK-NEXT:[[TMP7:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]] +; CHECK-NEXT:br i1 [[TMP7]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]] +; CHECK: middle.block: +; CHECK-NEXT:[[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]] +; CHECK-NEXT:br i1 [[CMP_N]], label [[FOR_END]], label [[VEC_EPILOG_ITER_CHECK:%.*]] +; CHECK: vec.epilog.iter.check: +; CHECK-NEXT:[[IND_END9:%.*]] = or disjoint i64 [[N_VEC]], 1 +; CHECK-NEXT:[[N_VEC_REMAINING:%.*]] = and i64 [[TMP0]], 24 +; CHECK-NEXT:[[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp eq i64 [[N_VEC_REMAINING]], 0 +; CHECK-NEXT:br i1 [[MIN_EPILOG_ITERS_CHECK]], label [[FOR_BODY_PREHEADER]], label [[VEC_EPILOG_PH]] +; CHECK: vec.epilog.ph: +; CHECK-NEXT:[[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]]
[llvm-branch-commits] [llvm] 42b7061 - [LAA] Drop alias scope metadata that is not valid across iterations (#79161)
Author: Nikita Popov Date: 2024-02-03T10:22:03-08:00 New Revision: 42b7061f1f0a2c52c8302a25ec656f990236b933 URL: https://github.com/llvm/llvm-project/commit/42b7061f1f0a2c52c8302a25ec656f990236b933 DIFF: https://github.com/llvm/llvm-project/commit/42b7061f1f0a2c52c8302a25ec656f990236b933.diff LOG: [LAA] Drop alias scope metadata that is not valid across iterations (#79161) LAA currently adds memory locations with their original AATags to AST. However, scoped alias AATags may be valid only within one loop iteration, while LAA reasons across iterations. Fix this by determining which alias scopes are defined inside the loop, and drop AATags that reference these scopes. Fixes https://github.com/llvm/llvm-project/issues/79137. (cherry picked from commit cd7ea4ea657ea41b42fcbd0e6b33faa46608d18e) Added: Modified: llvm/lib/Analysis/LoopAccessAnalysis.cpp llvm/test/Analysis/LoopAccessAnalysis/noalias-scope-decl.ll llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll Removed: diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 7e67c90152829..dd6b88fee415a 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -657,16 +657,18 @@ class AccessAnalysis { AccessAnalysis(Loop *TheLoop, AAResults *AA, LoopInfo *LI, MemoryDepChecker::DepCandidates &DA, - PredicatedScalarEvolution &PSE) - : TheLoop(TheLoop), BAA(*AA), AST(BAA), LI(LI), DepCands(DA), PSE(PSE) { + PredicatedScalarEvolution &PSE, + SmallPtrSetImpl &LoopAliasScopes) + : TheLoop(TheLoop), BAA(*AA), AST(BAA), LI(LI), DepCands(DA), PSE(PSE), +LoopAliasScopes(LoopAliasScopes) { // We're analyzing dependences across loop iterations. BAA.enableCrossIterationMode(); } /// Register a load and whether it is only read from. void addLoad(MemoryLocation &Loc, Type *AccessTy, bool IsReadOnly) { -Value *Ptr = const_cast(Loc.Ptr); -AST.add(Loc.getWithNewSize(LocationSize::beforeOrAfterPointer())); +Value *Ptr = const_cast(Loc.Ptr); +AST.add(adjustLoc(Loc)); Accesses[MemAccessInfo(Ptr, false)].insert(AccessTy); if (IsReadOnly) ReadOnlyPtr.insert(Ptr); @@ -674,8 +676,8 @@ class AccessAnalysis { /// Register a store. void addStore(MemoryLocation &Loc, Type *AccessTy) { -Value *Ptr = const_cast(Loc.Ptr); -AST.add(Loc.getWithNewSize(LocationSize::beforeOrAfterPointer())); +Value *Ptr = const_cast(Loc.Ptr); +AST.add(adjustLoc(Loc)); Accesses[MemAccessInfo(Ptr, true)].insert(AccessTy); } @@ -731,6 +733,32 @@ class AccessAnalysis { private: typedef MapVector> PtrAccessMap; + /// Adjust the MemoryLocation so that it represents accesses to this + /// location across all iterations, rather than a single one. + MemoryLocation adjustLoc(MemoryLocation Loc) const { +// The accessed location varies within the loop, but remains within the +// underlying object. +Loc.Size = LocationSize::beforeOrAfterPointer(); +Loc.AATags.Scope = adjustAliasScopeList(Loc.AATags.Scope); +Loc.AATags.NoAlias = adjustAliasScopeList(Loc.AATags.NoAlias); +return Loc; + } + + /// Drop alias scopes that are only valid within a single loop iteration. + MDNode *adjustAliasScopeList(MDNode *ScopeList) const { +if (!ScopeList) + return nullptr; + +// For the sake of simplicity, drop the whole scope list if any scope is +// iteration-local. +if (any_of(ScopeList->operands(), [&](Metadata *Scope) { + return LoopAliasScopes.contains(cast(Scope)); +})) + return nullptr; + +return ScopeList; + } + /// Go over all memory access and check whether runtime pointer checks /// are needed and build sets of dependency check candidates. void processMemAccesses(); @@ -775,6 +803,10 @@ class AccessAnalysis { PredicatedScalarEvolution &PSE; DenseMap> UnderlyingObjects; + + /// Alias scopes that are declared inside the loop, and as such not valid + /// across iterations. + SmallPtrSetImpl &LoopAliasScopes; }; } // end anonymous namespace @@ -2283,6 +2315,7 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI, // Holds the Load and Store instructions. SmallVector Loads; SmallVector Stores; + SmallPtrSet LoopAliasScopes; // Holds all the diff erent accesses in the loop. unsigned NumReads = 0; @@ -2326,6 +2359,11 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI, if (HasComplexMemInst) continue; + // Record alias scopes defined inside the loop. + if (auto *Decl = dyn_cast(&I)) +for (Metadata *Op : Decl->getScopeList()->operands()) + LoopAliasScopes.insert(cast(Op)); + // Many math library functions read the rounding mode. We will onl
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79137 (PR #79561)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/79561 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [libcxx] [clang] [openmp] [lld] [clang-tools-extra] Backport '[clang] static operators should evaluate object argument (reland)' to release/18.x (PR #80109)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80109 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] 278f80c - [ELF] Fix compareSections assertion failure when OutputDescs in sectionCommands are non-contiguous
Author: Fangrui Song Date: 2024-02-03T10:37:52-08:00 New Revision: 278f80ce95401f7920845d1281aa99804a139b6c URL: https://github.com/llvm/llvm-project/commit/278f80ce95401f7920845d1281aa99804a139b6c DIFF: https://github.com/llvm/llvm-project/commit/278f80ce95401f7920845d1281aa99804a139b6c.diff LOG: [ELF] Fix compareSections assertion failure when OutputDescs in sectionCommands are non-contiguous In a `--defsym y0=0 -T a.lds` link where a.lds contains only INSERT commands, the `script->sectionCommands` layout may be: ``` orphan sections SymbolAssignment due to --defsym sections created by INSERT commands ``` The `OutputDesc` objects are not contiguous in sortInputSections, and `compareSections` will be called with a SymbolAssignment argument, leading to an assertion failure. (cherry picked from commit dee8786f70a3d62b639113343fa36ef55bdbad63) Added: Modified: lld/ELF/Writer.cpp lld/test/ELF/linkerscript/insert-before.test Removed: diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 6f66f3615fa4a..501c10f358497 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1518,12 +1518,12 @@ template void Writer::sortSections() { if (auto *osd = dyn_cast(cmd)) osd->osec.sortRank = getSectionRank(osd->osec); if (!script->hasSectionsCommand) { -// We know that all the OutputSections are contiguous in this case. -auto isSection = [](SectionCommand *cmd) { return isa(cmd); }; -std::stable_sort( -llvm::find_if(script->sectionCommands, isSection), -llvm::find_if(llvm::reverse(script->sectionCommands), isSection).base(), -compareSections); +// OutputDescs are mostly contiguous, but may be interleaved with +// SymbolAssignments in the presence of INSERT commands. +auto mid = std::stable_partition( +script->sectionCommands.begin(), script->sectionCommands.end(), +[](SectionCommand *cmd) { return isa(cmd); }); +std::stable_sort(script->sectionCommands.begin(), mid, compareSections); } // Process INSERT commands and update output section attributes. From this diff --git a/lld/test/ELF/linkerscript/insert-before.test b/lld/test/ELF/linkerscript/insert-before.test index e6ed413639827..a72834988007c 100644 --- a/lld/test/ELF/linkerscript/insert-before.test +++ b/lld/test/ELF/linkerscript/insert-before.test @@ -24,8 +24,9 @@ ## without making more layout changes. Address/offset assignments are diff erent ## with a main linker script. -# RUN: ld.lld --script %s %t1.o -o %t2 -# RUN: llvm-readelf -S -l %t2 | FileCheck --check-prefix=CHECK2 %s +## Test non-contiguous OutputDescs in script->sectionCommands. +# RUN: ld.lld --defsym y0=1 %s --defsym y1=1 %t1.o -o %t2 +# RUN: llvm-readelf -S -l -sX %t2 | FileCheck --check-prefix=CHECK2 %s # CHECK2: Name Type AddressOff Size ES Flg # CHECK2-NEXT: NULL # CHECK2-NEXT: .foo.text PROGBITS 0020{{.*}} [[#%x,]] 08 00 AX @@ -40,9 +41,13 @@ # CHECK2-NEXT: LOAD {{.*}} RW 0x1000 # CHECK2-NEXT: GNU_STACK {{.*}} RW 0 +# CHECK2: NOTYPE GLOBAL DEFAULT ABS y0 +# CHECK2: NOTYPE GLOBAL DEFAULT [[#]] (.foo.text) x0 +# CHECK2: NOTYPE GLOBAL DEFAULT ABS y1 + SECTIONS { .byte : { BYTE(0) } } INSERT BEFORE .data; SECTIONS { .foo.data : { *(.foo.data) } } INSERT BEFORE .data; ## The input section .foo.text is an orphan. It will be placed in .foo.text -SECTIONS { .foo.text : {} } INSERT BEFORE .text; +SECTIONS { .foo.text : { x0 = .; } } INSERT BEFORE .text; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] PR for llvm/llvm-project#80390 (PR #80391)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80391 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] [llvm] ReleaseNotes: add lld/ELF notes (PR #80393)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80393 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] ae04671 - [clang] Represent array refs as `TemplateArgument::Declaration` (#80050)
Author: Andrey Ali Khan Bolshakov Date: 2024-02-03T21:09:06-08:00 New Revision: ae04671e43c44f64ed8627d856a3c67e25ce01a6 URL: https://github.com/llvm/llvm-project/commit/ae04671e43c44f64ed8627d856a3c67e25ce01a6 DIFF: https://github.com/llvm/llvm-project/commit/ae04671e43c44f64ed8627d856a3c67e25ce01a6.diff LOG: [clang] Represent array refs as `TemplateArgument::Declaration` (#80050) This returns (probably temporarily) array-referring NTTP behavior to which was prior to #78041 because ~~I'm fed up~~ have no time to fix regressions. (cherry picked from commit 9bf4e54ef42d907ae7550f36fa518f14fa97af6f) Added: Modified: clang/lib/Sema/SemaTemplate.cpp clang/test/CoverageMapping/templates.cpp Removed: diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 9bfa71dc8bcf1..a381d876a54c6 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7412,9 +7412,9 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, if (ArgResult.isInvalid()) return ExprError(); -// Prior to C++20, enforce restrictions on possible template argument -// values. -if (!getLangOpts().CPlusPlus20 && Value.isLValue()) { +if (Value.isLValue()) { + APValue::LValueBase Base = Value.getLValueBase(); + auto *VD = const_cast(Base.dyn_cast()); // For a non-type template-parameter of pointer or reference type, // the value of the constant expression shall not refer to assert(ParamType->isPointerType() || ParamType->isReferenceType() || @@ -7423,8 +7423,6 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // -- a string literal // -- the result of a typeid expression, or // -- a predefined __func__ variable - APValue::LValueBase Base = Value.getLValueBase(); - auto *VD = const_cast(Base.dyn_cast()); if (Base && (!VD || isa(VD))) { @@ -7432,24 +7430,30 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, << Arg->getSourceRange(); return ExprError(); } - // -- a subobject [until C++20] - if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 && - VD && VD->getType()->isArrayType() && + + if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 && VD && + VD->getType()->isArrayType() && Value.getLValuePath()[0].getAsArrayIndex() == 0 && !Value.isLValueOnePastTheEnd() && ParamType->isPointerType()) { -// Per defect report (no number yet): -// ... other than a pointer to the first element of a complete array -// object. - } else if (!Value.hasLValuePath() || Value.getLValuePath().size() || - Value.isLValueOnePastTheEnd()) { -Diag(StartLoc, diag::err_non_type_template_arg_subobject) - << Value.getAsString(Context, ParamType); -return ExprError(); +SugaredConverted = TemplateArgument(VD, ParamType); +CanonicalConverted = TemplateArgument( +cast(VD->getCanonicalDecl()), CanonParamType); +return ArgResult.get(); + } + + // -- a subobject [until C++20] + if (!getLangOpts().CPlusPlus20) { +if (!Value.hasLValuePath() || Value.getLValuePath().size() || +Value.isLValueOnePastTheEnd()) { + Diag(StartLoc, diag::err_non_type_template_arg_subobject) + << Value.getAsString(Context, ParamType); + return ExprError(); +} +assert((VD || !ParamType->isReferenceType()) && + "null reference should not be a constant expression"); +assert((!VD || !ParamType->isNullPtrType()) && + "non-null value of type nullptr_t?"); } - assert((VD || !ParamType->isReferenceType()) && - "null reference should not be a constant expression"); - assert((!VD || !ParamType->isNullPtrType()) && - "non-null value of type nullptr_t?"); } if (Value.isAddrLabelDiff()) diff --git a/clang/test/CoverageMapping/templates.cpp b/clang/test/CoverageMapping/templates.cpp index 7010edbc32c34..143e566a33cb8 100644 --- a/clang/test/CoverageMapping/templates.cpp +++ b/clang/test/CoverageMapping/templates.cpp @@ -19,3 +19,16 @@ int main() { func(true); return 0; } + +namespace structural_value_crash { + template + void tpl_fn() { +(void)p; + } + + int arr[] = {1, 2, 3}; + + void test() { +tpl_fn(); + } +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] PR for llvm/llvm-project#80150 (PR #80151)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80151 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 900e7cb - [LoongArch] Fixing the incorrect return value of LoongArchTTIImpl::getRegisterBitWidth (#79441)
Author: wanglei Date: 2024-02-03T21:28:38-08:00 New Revision: 900e7cbfdee09c94d022e4dae923b3c7827f95e3 URL: https://github.com/llvm/llvm-project/commit/900e7cbfdee09c94d022e4dae923b3c7827f95e3 DIFF: https://github.com/llvm/llvm-project/commit/900e7cbfdee09c94d022e4dae923b3c7827f95e3.diff LOG: [LoongArch] Fixing the incorrect return value of LoongArchTTIImpl::getRegisterBitWidth (#79441) When we do not enable vector features, we should return the default value (`TargetTransformInfoImplBase::getRegisterBitWidth`) instead of zero. This should fix the LoongArch [buildbot breakage](https://lab.llvm.org/staging/#/builders/5/builds/486) from #78943. (cherry picked from commit 1e9924c1f248bbddcb95d82a59708d617297dad3) Added: Modified: llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp Removed: diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp index 04349aa52b540..d47dded9ea6ec 100644 --- a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp +++ b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp @@ -21,17 +21,20 @@ using namespace llvm; TypeSize LoongArchTTIImpl::getRegisterBitWidth( TargetTransformInfo::RegisterKind K) const { + TypeSize DefSize = TargetTransformInfoImplBase::getRegisterBitWidth(K); switch (K) { case TargetTransformInfo::RGK_Scalar: return TypeSize::getFixed(ST->is64Bit() ? 64 : 32); case TargetTransformInfo::RGK_FixedWidthVector: -if (ST->hasExtLASX() && ST->hasExpAutoVec()) +if (!ST->hasExpAutoVec()) + return DefSize; +if (ST->hasExtLASX()) return TypeSize::getFixed(256); -if (ST->hasExtLSX() && ST->hasExpAutoVec()) +if (ST->hasExtLSX()) return TypeSize::getFixed(128); -return TypeSize::getFixed(0); +[[fallthrough]]; case TargetTransformInfo::RGK_ScalableVector: -return TypeSize::getScalable(0); +return DefSize; } llvm_unreachable("Unsupported register kind"); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80577 (PR #80578)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80578 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80348 (PR #80585)
tstellar wrote: /cherry-pick 4b34558f43121df9b863ff2492f74fb2e65a5af1. https://github.com/llvm/llvm-project/pull/80585 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 1a791e8 - [Clang][AArch64] Emit 'unimplemented' diagnostic for SME (#80295)
Author: Sander de Smalen Date: 2024-02-05T11:20:35-08:00 New Revision: 1a791e84d9e6ef0e6be1a15e64b78a8fcc18467a URL: https://github.com/llvm/llvm-project/commit/1a791e84d9e6ef0e6be1a15e64b78a8fcc18467a DIFF: https://github.com/llvm/llvm-project/commit/1a791e84d9e6ef0e6be1a15e64b78a8fcc18467a.diff LOG: [Clang][AArch64] Emit 'unimplemented' diagnostic for SME (#80295) When a function F has ZA and ZT0 state, calls another function G that only shares ZT0 state with its caller, F will have to save ZA before the call to G, and restore it afterwards (rather than setting up a lazy-sve). This is not yet implemented in LLVM and does not result in a compile-time error either. So instead of silently generating incorrect code, it's better to emit an error saying this is not yet implemented. (cherry picked from commit 319f4c03ba2909c7240ac157cc46216bf1518c10) Added: Modified: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaChecking.cpp clang/test/Sema/aarch64-sme-func-attrs.c Removed: diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a1c32abb4dcd8..ef8c111b1d8cc 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3711,6 +3711,12 @@ def err_sme_za_call_no_za_state : Error< "call to a shared ZA function requires the caller to have ZA state">; def err_sme_zt0_call_no_zt0_state : Error< "call to a shared ZT0 function requires the caller to have ZT0 state">; +def err_sme_unimplemented_za_save_restore : Error< + "call to a function that shares state other than 'za' from a " + "function that has live 'za' state requires a spill/fill of ZA, which is not yet " + "implemented">; +def note_sme_use_preserves_za : Note< + "add '__arm_preserves(\"za\")' to the callee if it preserves ZA">; def err_sme_definition_using_sm_in_non_sme_target : Error< "function executed in streaming-SVE mode requires 'sme'">; def err_sme_definition_using_za_in_non_sme_target : Error< diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 25e9af1ea3f36..09b7e1c62fbd7 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -7545,47 +7545,43 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, } } -// If the callee uses AArch64 SME ZA state but the caller doesn't define -// any, then this is an error. -FunctionType::ArmStateValue ArmZAState = +FunctionType::ArmStateValue CalleeArmZAState = FunctionType::getArmZAState(ExtInfo.AArch64SMEAttributes); -if (ArmZAState != FunctionType::ARM_None) { +FunctionType::ArmStateValue CalleeArmZT0State = +FunctionType::getArmZT0State(ExtInfo.AArch64SMEAttributes); +if (CalleeArmZAState != FunctionType::ARM_None || +CalleeArmZT0State != FunctionType::ARM_None) { bool CallerHasZAState = false; + bool CallerHasZT0State = false; if (const auto *CallerFD = dyn_cast(CurContext)) { auto *Attr = CallerFD->getAttr(); if (Attr && Attr->isNewZA()) CallerHasZAState = true; -else if (const auto *FPT = - CallerFD->getType()->getAs()) - CallerHasZAState = FunctionType::getArmZAState( - FPT->getExtProtoInfo().AArch64SMEAttributes) != - FunctionType::ARM_None; - } - - if (!CallerHasZAState) -Diag(Loc, diag::err_sme_za_call_no_za_state); -} - -// If the callee uses AArch64 SME ZT0 state but the caller doesn't define -// any, then this is an error. -FunctionType::ArmStateValue ArmZT0State = -FunctionType::getArmZT0State(ExtInfo.AArch64SMEAttributes); -if (ArmZT0State != FunctionType::ARM_None) { - bool CallerHasZT0State = false; - if (const auto *CallerFD = dyn_cast(CurContext)) { -auto *Attr = CallerFD->getAttr(); if (Attr && Attr->isNewZT0()) CallerHasZT0State = true; -else if (const auto *FPT = - CallerFD->getType()->getAs()) - CallerHasZT0State = +if (const auto *FPT = CallerFD->getType()->getAs()) { + CallerHasZAState |= + FunctionType::getArmZAState( + FPT->getExtProtoInfo().AArch64SMEAttributes) != + FunctionType::ARM_None; + CallerHasZT0State |= FunctionType::getArmZT0State( FPT->getExtProtoInfo().AArch64SMEAttributes) != FunctionType::ARM_None; +} } - if (!CallerHasZT0State) + if (CalleeArmZAState != FunctionType::ARM_None && !CallerHasZAState) +Diag(Loc, diag::err_sme_za_call_no_za_state); + + if (CalleeArmZT0State != FunctionType::ARM_None && !CallerHasZT0State) Dia
[llvm-branch-commits] [clang] PR for llvm/llvm-project#80432 (PR #80433)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80433 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 43db795 - [MSSAUpdater] Handle simplified accesses when updating phis (#78272)
Author: Nikita Popov Date: 2024-02-05T11:23:33-08:00 New Revision: 43db795259d91ddb3b12596e8aec3dddbd1fb583 URL: https://github.com/llvm/llvm-project/commit/43db795259d91ddb3b12596e8aec3dddbd1fb583 DIFF: https://github.com/llvm/llvm-project/commit/43db795259d91ddb3b12596e8aec3dddbd1fb583.diff LOG: [MSSAUpdater] Handle simplified accesses when updating phis (#78272) This is a followup to #76819. After those changes, we can still run into an assertion failure for a slight variation of the test case: When fixing up MemoryPhis, we map the incoming access to the access of the cloned instruction -- which may now no longer exist. Fix this by reusing the getNewDefiningAccessForClone() helper, which will look upwards for a new defining access in that case. (cherry picked from commit a7a1b8b17e264fb0f2d2b4165cf9a7f5094b08b3) Added: Modified: llvm/lib/Analysis/MemorySSAUpdater.cpp llvm/test/Transforms/SimpleLoopUnswitch/memssa-readnone-access.ll Removed: diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index e87ae7d71fffe..aa550f0b6a7bf 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -692,25 +692,9 @@ void MemorySSAUpdater::updateForClonedLoop(const LoopBlocksRPO &LoopBlocks, continue; // Determine incoming value and add it as incoming from IncBB. - if (MemoryUseOrDef *IncMUD = dyn_cast(IncomingAccess)) { -if (!MSSA->isLiveOnEntryDef(IncMUD)) { - Instruction *IncI = IncMUD->getMemoryInst(); - assert(IncI && "Found MemoryUseOrDef with no Instruction."); - if (Instruction *NewIncI = - cast_or_null(VMap.lookup(IncI))) { -IncMUD = MSSA->getMemoryAccess(NewIncI); -assert(IncMUD && - "MemoryUseOrDef cannot be null, all preds processed."); - } -} -NewPhi->addIncoming(IncMUD, IncBB); - } else { -MemoryPhi *IncPhi = cast(IncomingAccess); -if (MemoryAccess *NewDefPhi = MPhiMap.lookup(IncPhi)) - NewPhi->addIncoming(NewDefPhi, IncBB); -else - NewPhi->addIncoming(IncPhi, IncBB); - } + NewPhi->addIncoming( + getNewDefiningAccessForClone(IncomingAccess, VMap, MPhiMap, MSSA), + IncBB); } if (auto *SingleAccess = onlySingleValue(NewPhi)) { MPhiMap[Phi] = SingleAccess; diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/memssa-readnone-access.ll b/llvm/test/Transforms/SimpleLoopUnswitch/memssa-readnone-access.ll index 2aaf777683e11..c6e6608d4be38 100644 --- a/llvm/test/Transforms/SimpleLoopUnswitch/memssa-readnone-access.ll +++ b/llvm/test/Transforms/SimpleLoopUnswitch/memssa-readnone-access.ll @@ -115,3 +115,107 @@ split: exit: ret void } + +; Variants of the above test with swapped branch destinations. + +define void @test1_swapped(i1 %c) { +; CHECK-LABEL: define void @test1_swapped( +; CHECK-SAME: i1 [[C:%.*]]) { +; CHECK-NEXT: start: +; CHECK-NEXT:[[C_FR:%.*]] = freeze i1 [[C]] +; CHECK-NEXT:br i1 [[C_FR]], label [[START_SPLIT_US:%.*]], label [[START_SPLIT:%.*]] +; CHECK: start.split.us: +; CHECK-NEXT:br label [[LOOP_US:%.*]] +; CHECK: loop.us: +; CHECK-NEXT:call void @foo() +; CHECK-NEXT:br label [[LOOP_US]] +; CHECK: start.split: +; CHECK-NEXT:br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT:call void @foo() +; CHECK-NEXT:br label [[EXIT:%.*]] +; CHECK: exit: +; CHECK-NEXT:ret void +; +start: + br label %loop + +loop: + %fn = load ptr, ptr @vtable, align 8 + call void %fn() + br i1 %c, label %loop, label %exit + +exit: + ret void +} + +define void @test2_swapped(i1 %c, ptr %p) { +; CHECK-LABEL: define void @test2_swapped( +; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) { +; CHECK-NEXT:[[C_FR:%.*]] = freeze i1 [[C]] +; CHECK-NEXT:br i1 [[C_FR]], label [[DOTSPLIT_US:%.*]], label [[DOTSPLIT:%.*]] +; CHECK: .split.us: +; CHECK-NEXT:br label [[LOOP_US:%.*]] +; CHECK: loop.us: +; CHECK-NEXT:call void @foo() +; CHECK-NEXT:call void @bar() +; CHECK-NEXT:br label [[LOOP_US]] +; CHECK: .split: +; CHECK-NEXT:br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT:call void @foo() +; CHECK-NEXT:call void @bar() +; CHECK-NEXT:br label [[EXIT:%.*]] +; CHECK: exit: +; CHECK-NEXT:ret void +; + br label %loop + +loop: + %fn = load ptr, ptr @vtable, align 8 + call void %fn() + call void @bar() + br i1 %c, label %loop, label %exit + +exit: + ret void +} + +define void @test3_swapped(i1 %c, ptr %p) { +; CHECK-LABEL: define void @test3_swapped( +; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) { +; CHECK-NEXT:[[C_FR:%.*]] = freeze i1 [[C]] +; CHECK-NEXT:br i1 [[C_FR]], label [[DOTSPLIT_US:%.*]], label [[DOTSPLIT:%.*]] +; CHECK: .split.us: +; CHEC
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79571 (PR #79572)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/79572 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] a6817b7 - CoverageMappingWriter: Emit `Decision` before `Expansion` (#78966)
Author: NAKAMURA Takumi Date: 2024-02-05T11:32:50-08:00 New Revision: a6817b7315af5da94cfbe69767c8e8f827fecbca URL: https://github.com/llvm/llvm-project/commit/a6817b7315af5da94cfbe69767c8e8f827fecbca DIFF: https://github.com/llvm/llvm-project/commit/a6817b7315af5da94cfbe69767c8e8f827fecbca.diff LOG: CoverageMappingWriter: Emit `Decision` before `Expansion` (#78966) To relax scanning record, tweak order by `Decision < Expansion`, or `Expansion` could not be distinguished whether it belonged to `Decision` or not. Relevant to #77871 (cherry picked from commit 438fe1db09b0c20708ea1020519d8073c37feae8) Added: Modified: llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp llvm/unittests/ProfileData/CoverageMappingTest.cpp Removed: diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp index 1c7d8a8909c48..27727f216b051 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp @@ -167,7 +167,15 @@ void CoverageMappingWriter::write(raw_ostream &OS) { return LHS.FileID < RHS.FileID; if (LHS.startLoc() != RHS.startLoc()) return LHS.startLoc() < RHS.startLoc(); -return LHS.Kind < RHS.Kind; + +// Put `Decision` before `Expansion`. +auto getKindKey = [](CounterMappingRegion::RegionKind Kind) { + return (Kind == CounterMappingRegion::MCDCDecisionRegion + ? 2 * CounterMappingRegion::ExpansionRegion - 1 + : 2 * Kind); +}; + +return getKindKey(LHS.Kind) < getKindKey(RHS.Kind); }); // Write out the fileid -> filename mapping. diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp index 23f66a0232ddb..2849781a9dc43 100644 --- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp +++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp @@ -890,6 +890,42 @@ TEST_P(CoverageMappingTest, non_code_region_bitmask) { ASSERT_EQ(1U, Names.size()); } +// Test the order of MCDCDecision before Expansion +TEST_P(CoverageMappingTest, decision_before_expansion) { + startFunction("foo", 0x1234); + addCMR(Counter::getCounter(0), "foo", 3, 23, 5, 2); + + // This(4:11) was put after Expansion(4:11) before the fix + addMCDCDecisionCMR(0, 2, "foo", 4, 11, 4, 20); + + addExpansionCMR("foo", "A", 4, 11, 4, 12); + addExpansionCMR("foo", "B", 4, 19, 4, 20); + addCMR(Counter::getCounter(0), "A", 1, 14, 1, 17); + addCMR(Counter::getCounter(0), "A", 1, 14, 1, 17); + addMCDCBranchCMR(Counter::getCounter(0), Counter::getCounter(1), 1, 2, 0, "A", + 1, 14, 1, 17); + addCMR(Counter::getCounter(1), "B", 1, 14, 1, 17); + addMCDCBranchCMR(Counter::getCounter(1), Counter::getCounter(2), 2, 0, 0, "B", + 1, 14, 1, 17); + + // InputFunctionCoverageData::Regions is rewritten after the write. + auto InputRegions = InputFunctions.back().Regions; + + writeAndReadCoverageRegions(); + + const auto &OutputRegions = OutputFunctions.back().Regions; + + size_t N = ArrayRef(InputRegions).size(); + ASSERT_EQ(N, OutputRegions.size()); + for (size_t I = 0; I < N; ++I) { +ASSERT_EQ(InputRegions[I].Kind, OutputRegions[I].Kind); +ASSERT_EQ(InputRegions[I].FileID, OutputRegions[I].FileID); +ASSERT_EQ(InputRegions[I].ExpandedFileID, OutputRegions[I].ExpandedFileID); +ASSERT_EQ(InputRegions[I].startLoc(), OutputRegions[I].startLoc()); +ASSERT_EQ(InputRegions[I].endLoc(), OutputRegions[I].endLoc()); + } +} + TEST_P(CoverageMappingTest, strip_filename_prefix) { ProfileWriter.addRecord({"file1:func", 0x1234, {0}}, Err); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] b50a84e - [Coverage] Let `Decision` take account of expansions (#78969)
Author: NAKAMURA Takumi Date: 2024-02-05T11:32:51-08:00 New Revision: b50a84e303378df35996d7330aa80aa4ea1f497a URL: https://github.com/llvm/llvm-project/commit/b50a84e303378df35996d7330aa80aa4ea1f497a DIFF: https://github.com/llvm/llvm-project/commit/b50a84e303378df35996d7330aa80aa4ea1f497a.diff LOG: [Coverage] Let `Decision` take account of expansions (#78969) The current implementation (D138849) assumes `Branch`(es) would follow after the corresponding `Decision`. It is not true if `Branch`(es) are forwarded to expanded file ID. As a result, consecutive `Decision`(s) would be confused with insufficient number of `Branch`(es). `Expansion` will point `Branch`(es) in other file IDs if `Expansion` is included in the range of `Decision`. Fixes #77871 - Co-authored-by: Alan Phipps (cherry picked from commit d912f1f0cb49465b08f82fae89ece222404e5640) Added: llvm/test/tools/llvm-cov/Inputs/mcdc-macro.c llvm/test/tools/llvm-cov/Inputs/mcdc-macro.o llvm/test/tools/llvm-cov/Inputs/mcdc-macro.proftext llvm/test/tools/llvm-cov/mcdc-macro.test Modified: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp Removed: diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index da8e1d87319dd..a357b4cb49211 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -14,6 +14,7 @@ #include "llvm/ProfileData/Coverage/CoverageMapping.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" @@ -583,6 +584,160 @@ static unsigned getMaxBitmapSize(const CounterMappingContext &Ctx, return MaxBitmapID + (SizeInBits / CHAR_BIT); } +namespace { + +/// Collect Decisions, Branchs, and Expansions and associate them. +class MCDCDecisionRecorder { +private: + /// This holds the DecisionRegion and MCDCBranches under it. + /// Also traverses Expansion(s). + /// The Decision has the number of MCDCBranches and will complete + /// when it is filled with unique ConditionID of MCDCBranches. + struct DecisionRecord { +const CounterMappingRegion *DecisionRegion; + +/// They are reflected from DecisionRegion for convenience. +LineColPair DecisionStartLoc; +LineColPair DecisionEndLoc; + +/// This is passed to `MCDCRecordProcessor`, so this should be compatible +/// to`ArrayRef`. +SmallVector MCDCBranches; + +/// IDs that are stored in MCDCBranches +/// Complete when all IDs (1 to NumConditions) are met. +DenseSet ConditionIDs; + +/// Set of IDs of Expansion(s) that are relevant to DecisionRegion +/// and its children (via expansions). +/// FileID pointed by ExpandedFileID is dedicated to the expansion, so +/// the location in the expansion doesn't matter. +DenseSet ExpandedFileIDs; + +DecisionRecord(const CounterMappingRegion &Decision) +: DecisionRegion(&Decision), DecisionStartLoc(Decision.startLoc()), + DecisionEndLoc(Decision.endLoc()) { + assert(Decision.Kind == CounterMappingRegion::MCDCDecisionRegion); +} + +/// Determine whether DecisionRecord dominates `R`. +bool dominates(const CounterMappingRegion &R) const { + // Determine whether `R` is included in `DecisionRegion`. + if (R.FileID == DecisionRegion->FileID && + R.startLoc() >= DecisionStartLoc && R.endLoc() <= DecisionEndLoc) +return true; + + // Determine whether `R` is pointed by any of Expansions. + return ExpandedFileIDs.contains(R.FileID); +} + +enum Result { + NotProcessed = 0, /// Irrelevant to this Decision + Processed,/// Added to this Decision + Completed,/// Added and filled this Decision +}; + +/// Add Branch into the Decision +/// \param Branch expects MCDCBranchRegion +/// \returns NotProcessed/Processed/Completed +Result addBranch(const CounterMappingRegion &Branch) { + assert(Branch.Kind == CounterMappingRegion::MCDCBranchRegion); + + auto ConditionID = Branch.MCDCParams.ID; + assert(ConditionID > 0 && "ConditionID should begin with 1"); + + if (ConditionIDs.contains(ConditionID) || + ConditionID > DecisionRegion->MCDCParams.NumConditions) +return NotProcessed; + + if (!this->dominates(Branch)) +return NotProcessed; + + assert(MCDCBranches.size() < DecisionRegion->MCDCParams.NumConditions); + + // Put `ID=1` in front of `MCDCBranches` for convenience + // even if `MCDCBranches` is not topological. + if (ConditionID == 1) +MCDCBranches.insert(MCDCBranches.begin(), &Branch); + else +MCDCBranches.push_back(&Branch); + + // Mark `ID` as `assigned`. + ConditionIDs.insert(Con
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#77871 (PR #80513)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80513 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] 7a5cba8 - [compiler-rt] Remove duplicate MS names for chkstk symbols (#80450)
Author: Martin Storsjö Date: 2024-02-05T11:39:38-08:00 New Revision: 7a5cba8bea8f774d48db1b0426bcc102edd2b69f URL: https://github.com/llvm/llvm-project/commit/7a5cba8bea8f774d48db1b0426bcc102edd2b69f DIFF: https://github.com/llvm/llvm-project/commit/7a5cba8bea8f774d48db1b0426bcc102edd2b69f.diff LOG: [compiler-rt] Remove duplicate MS names for chkstk symbols (#80450) Prior to 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2, the builtins library contained two chkstk implementations for each of i386 and x86_64, one that was used in mingw environments, and one unused (with a symbol name not matching anything that is used anywhere). Some of the functions additionally had other, also unused, aliases. After cleaning this up in 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2, the unused symbol names were removed. At the same time, symbol aliases were added for the names as they are used by MSVC; the functions are functionally equivalent, but have different names between mingw and MSVC style environments. By adding a symbol alias (so that one object file contains two different symbols for the same function), users can run into problems with duplicate definitions, if they themselves define one of the symbols (for various reasons), but need to link in the other one. This happens for Wine, which provides their own definition of "__chkstk", but when built in mingw mode does need compiler-rt to provide the mingw specific symbol names; see https://github.com/mstorsjo/llvm-mingw/issues/397. To avoid the issue, remove the extra MS style names. They weren't entirely usable as such for MSVC style environments anyway, as compiler-rt builtins don't build these object files at all, when built in MSVC mode; thus, the effort to provide them for MSVC style environments in 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2 was a half-hearted step towards that. If we really do want to provide those functions (as an alternative to the ones provided by MSVC itself), we should do it in a separate object file (even if the function implementation is the same), so that users who have a definition of one of them but need a definition of the other, won't have conflicts. Additionally, if we do want to provide them for MSVC, those files actually should be built when building the builtins in MSVC mode as well (see compiler-rt/lib/builtins/CMakeLists.txt). If we do that, there's a risk that an MSVC style build ends up linking in and preferring our implementation over the one provided by MSVC, which would be suboptimal. Our implementation always probes the requested amount of stack, while the MSVC one checks the amount of allocated stack and only probes as much as really is needed. In short - this reverts the situation to what it was in the 17.x release series (except for unused functions that have been removed). (cherry picked from commit 248aeac1ad2cf4f583490dd1312a5b448d2bb8cc) Added: Modified: compiler-rt/lib/builtins/i386/chkstk.S compiler-rt/lib/builtins/x86_64/chkstk.S Removed: diff --git a/compiler-rt/lib/builtins/i386/chkstk.S b/compiler-rt/lib/builtins/i386/chkstk.S index a84bb0ee30070..cdd9a4c2a5752 100644 --- a/compiler-rt/lib/builtins/i386/chkstk.S +++ b/compiler-rt/lib/builtins/i386/chkstk.S @@ -14,7 +14,6 @@ .text .balign 4 DEFINE_COMPILERRT_FUNCTION(_alloca) // _chkstk and _alloca are the same function -DEFINE_COMPILERRT_FUNCTION(_chkstk) push %ecx cmp$0x1000,%eax lea8(%esp),%ecx // esp before calling this routine -> ecx @@ -35,7 +34,6 @@ DEFINE_COMPILERRT_FUNCTION(_chkstk) push (%eax) // push return address onto the stack sub%esp,%eax// restore the original value in eax ret -END_COMPILERRT_FUNCTION(_chkstk) END_COMPILERRT_FUNCTION(_alloca) #endif // __i386__ diff --git a/compiler-rt/lib/builtins/x86_64/chkstk.S b/compiler-rt/lib/builtins/x86_64/chkstk.S index 494ee261193bc..ad7953a116ac7 100644 --- a/compiler-rt/lib/builtins/x86_64/chkstk.S +++ b/compiler-rt/lib/builtins/x86_64/chkstk.S @@ -18,7 +18,6 @@ .text .balign 4 DEFINE_COMPILERRT_FUNCTION(___chkstk_ms) -DEFINE_COMPILERRT_FUNCTION(__chkstk) push %rcx push %rax cmp$0x1000,%rax @@ -36,7 +35,6 @@ DEFINE_COMPILERRT_FUNCTION(__chkstk) pop%rax pop%rcx ret -END_COMPILERRT_FUNCTION(__chkstk) END_COMPILERRT_FUNCTION(___chkstk_ms) #endif // __x86_64__ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80543 (PR #80544)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80544 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] aa69808 - [Loads] Use BatchAAResults for available value APIs (NFCI)
Author: Nikita Popov Date: 2024-02-05T11:41:54-08:00 New Revision: aa6980841e587eba9c98bf54c51f5414f8a15871 URL: https://github.com/llvm/llvm-project/commit/aa6980841e587eba9c98bf54c51f5414f8a15871 DIFF: https://github.com/llvm/llvm-project/commit/aa6980841e587eba9c98bf54c51f5414f8a15871.diff LOG: [Loads] Use BatchAAResults for available value APIs (NFCI) This allows caching AA queries both within and across the calls, and enables us to use a custom AAQI configuration. (cherry picked from commit 89dae798cc77789a43e9a60173f647dae03a65fe) Added: Modified: llvm/include/llvm/Analysis/Loads.h llvm/lib/Analysis/Lint.cpp llvm/lib/Analysis/Loads.cpp llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp llvm/lib/Transforms/Scalar/JumpThreading.cpp Removed: diff --git a/llvm/include/llvm/Analysis/Loads.h b/llvm/include/llvm/Analysis/Loads.h index 2880ed33a34cb..0926093bba99d 100644 --- a/llvm/include/llvm/Analysis/Loads.h +++ b/llvm/include/llvm/Analysis/Loads.h @@ -18,7 +18,7 @@ namespace llvm { -class AAResults; +class BatchAAResults; class AssumptionCache; class DataLayout; class DominatorTree; @@ -129,11 +129,10 @@ extern cl::opt DefMaxInstsToScan; /// location in memory, as opposed to the value operand of a store. /// /// \returns The found value, or nullptr if no value is found. -Value *FindAvailableLoadedValue(LoadInst *Load, -BasicBlock *ScanBB, +Value *FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan = DefMaxInstsToScan, -AAResults *AA = nullptr, +BatchAAResults *AA = nullptr, bool *IsLoadCSE = nullptr, unsigned *NumScanedInst = nullptr); @@ -141,7 +140,8 @@ Value *FindAvailableLoadedValue(LoadInst *Load, /// FindAvailableLoadedValue() for the case where we are not interested in /// finding the closest clobbering instruction if no available load is found. /// This overload cannot be used to scan across multiple blocks. -Value *FindAvailableLoadedValue(LoadInst *Load, AAResults &AA, bool *IsLoadCSE, +Value *FindAvailableLoadedValue(LoadInst *Load, BatchAAResults &AA, +bool *IsLoadCSE, unsigned MaxInstsToScan = DefMaxInstsToScan); /// Scan backwards to see if we have the value of the given pointer available @@ -170,7 +170,7 @@ Value *FindAvailableLoadedValue(LoadInst *Load, AAResults &AA, bool *IsLoadCSE, Value *findAvailablePtrLoadStore(const MemoryLocation &Loc, Type *AccessTy, bool AtLeastAtomic, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, - unsigned MaxInstsToScan, AAResults *AA, + unsigned MaxInstsToScan, BatchAAResults *AA, bool *IsLoadCSE, unsigned *NumScanedInst); /// Returns true if a pointer value \p A can be replace with another pointer diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp index 1ebc593016bc0..16635097d20af 100644 --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -657,11 +657,12 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk, BasicBlock::iterator BBI = L->getIterator(); BasicBlock *BB = L->getParent(); SmallPtrSet VisitedBlocks; +BatchAAResults BatchAA(*AA); for (;;) { if (!VisitedBlocks.insert(BB).second) break; if (Value *U = - FindAvailableLoadedValue(L, BB, BBI, DefMaxInstsToScan, AA)) + FindAvailableLoadedValue(L, BB, BBI, DefMaxInstsToScan, &BatchAA)) return findValueImpl(U, OffsetOk, Visited); if (BBI != BB->begin()) break; diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index 97d21db86abf2..6bf0d2f56eb4e 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -450,11 +450,10 @@ llvm::DefMaxInstsToScan("available-load-scan-limit", cl::init(6), cl::Hidden, "to scan backward from a given instruction, when searching for " "available loaded value")); -Value *llvm::FindAvailableLoadedValue(LoadInst *Load, - BasicBlock *ScanBB, +Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan, - AAResults *AA, bool *IsLoad, + BatchAAResults *AA, bool *IsLoad, unsigned *NumScanedInst) { // Don't C
[llvm-branch-commits] [llvm] 28879ab - [AA][JumpThreading] Don't use DomTree for AA in JumpThreading (#79294)
Author: Nikita Popov Date: 2024-02-05T11:41:55-08:00 New Revision: 28879ab8276e7237bfc86f4c7d7890fd4311d334 URL: https://github.com/llvm/llvm-project/commit/28879ab8276e7237bfc86f4c7d7890fd4311d334 DIFF: https://github.com/llvm/llvm-project/commit/28879ab8276e7237bfc86f4c7d7890fd4311d334.diff LOG: [AA][JumpThreading] Don't use DomTree for AA in JumpThreading (#79294) JumpThreading may perform AA queries while the dominator tree is not up to date, which may result in miscompilations. Fix this by adding a new AAQI option to disable the use of the dominator tree in BasicAA. Fixes https://github.com/llvm/llvm-project/issues/79175. (cherry picked from commit 4f32f5d5720fbef06672714a62376f236a36aef5) Added: Modified: llvm/include/llvm/Analysis/AliasAnalysis.h llvm/include/llvm/Analysis/BasicAliasAnalysis.h llvm/lib/Analysis/BasicAliasAnalysis.cpp llvm/lib/Transforms/Scalar/JumpThreading.cpp llvm/test/Transforms/JumpThreading/pr79175.ll Removed: diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h index d6f732d35fd4c..e8e4f491be5a3 100644 --- a/llvm/include/llvm/Analysis/AliasAnalysis.h +++ b/llvm/include/llvm/Analysis/AliasAnalysis.h @@ -287,6 +287,10 @@ class AAQueryInfo { /// store %l, ... bool MayBeCrossIteration = false; + /// Whether alias analysis is allowed to use the dominator tree, for use by + /// passes that lazily update the DT while performing AA queries. + bool UseDominatorTree = true; + AAQueryInfo(AAResults &AAR, CaptureInfo *CI) : AAR(AAR), CI(CI) {} }; @@ -668,6 +672,9 @@ class BatchAAResults { void enableCrossIterationMode() { AAQI.MayBeCrossIteration = true; } + + /// Disable the use of the dominator tree during alias analysis queries. + void disableDominatorTree() { AAQI.UseDominatorTree = false; } }; /// Temporary typedef for legacy code that uses a generic \c AliasAnalysis diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h index afc1811239f28..7eca82729430d 100644 --- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h +++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h @@ -43,20 +43,26 @@ class BasicAAResult : public AAResultBase { const Function &F; const TargetLibraryInfo &TLI; AssumptionCache &AC; - DominatorTree *DT; + /// Use getDT() instead of accessing this member directly, in order to + /// respect the AAQI.UseDominatorTree option. + DominatorTree *DT_; + + DominatorTree *getDT(const AAQueryInfo &AAQI) const { +return AAQI.UseDominatorTree ? DT_ : nullptr; + } public: BasicAAResult(const DataLayout &DL, const Function &F, const TargetLibraryInfo &TLI, AssumptionCache &AC, DominatorTree *DT = nullptr) - : DL(DL), F(F), TLI(TLI), AC(AC), DT(DT) {} + : DL(DL), F(F), TLI(TLI), AC(AC), DT_(DT) {} BasicAAResult(const BasicAAResult &Arg) : AAResultBase(Arg), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI), AC(Arg.AC), -DT(Arg.DT) {} +DT_(Arg.DT_) {} BasicAAResult(BasicAAResult &&Arg) : AAResultBase(std::move(Arg)), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI), -AC(Arg.AC), DT(Arg.DT) {} +AC(Arg.AC), DT_(Arg.DT_) {} /// Handle invalidation events in the new pass manager. bool invalidate(Function &Fn, const PreservedAnalyses &PA, diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 3178e2d278167..1028b52a79123 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -89,7 +89,7 @@ bool BasicAAResult::invalidate(Function &Fn, const PreservedAnalyses &PA, // may be created without handles to some analyses and in that case don't // depend on them. if (Inv.invalidate(Fn, PA) || - (DT && Inv.invalidate(Fn, PA))) + (DT_ && Inv.invalidate(Fn, PA))) return true; // Otherwise this analysis result remains valid. @@ -1063,6 +1063,7 @@ AliasResult BasicAAResult::aliasGEP( : AliasResult::MayAlias; } + DominatorTree *DT = getDT(AAQI); DecomposedGEP DecompGEP1 = DecomposeGEPExpression(GEP1, DL, &AC, DT); DecomposedGEP DecompGEP2 = DecomposeGEPExpression(V2, DL, &AC, DT); @@ -1556,6 +1557,7 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size, const Value *HintO1 = getUnderlyingObject(Hint1); const Value *HintO2 = getUnderlyingObject(Hint2); +DominatorTree *DT = getDT(AAQI); auto ValidAssumeForPtrContext = [&](const Value *Ptr) { if (const Instruction *PtrI = dyn_cast(Ptr)) { return isValidAssumeForContext(Assume, PtrI, DT, @@ -1735,7 +1737,7 @@ bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V, if (!Inst || Inst->getParent()->isEntryBlo
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79175 (PR #80274)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80274 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] a581690 - [JumpThreading] Add test for #79175 (NFC)
Author: Nikita Popov Date: 2024-02-05T11:41:55-08:00 New Revision: a581690c57d153f329ded71004a8616b93cb88ca URL: https://github.com/llvm/llvm-project/commit/a581690c57d153f329ded71004a8616b93cb88ca DIFF: https://github.com/llvm/llvm-project/commit/a581690c57d153f329ded71004a8616b93cb88ca.diff LOG: [JumpThreading] Add test for #79175 (NFC) (cherry picked from commit 7143b451d71fe314730f7610d7908e3b9611815c) Added: llvm/test/Transforms/JumpThreading/pr79175.ll Modified: Removed: diff --git a/llvm/test/Transforms/JumpThreading/pr79175.ll b/llvm/test/Transforms/JumpThreading/pr79175.ll new file mode 100644 index 0..6815aabb26dfc --- /dev/null +++ b/llvm/test/Transforms/JumpThreading/pr79175.ll @@ -0,0 +1,64 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -S -passes=jump-threading < %s | FileCheck %s + +@f = external global i32 + +; Make sure the value of @f is reloaded prior to the final comparison. +; FIXME: This is a miscompile. +define i32 @test(i64 %idx, i32 %val) { +; CHECK-LABEL: define i32 @test( +; CHECK-SAME: i64 [[IDX:%.*]], i32 [[VAL:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[CMP:%.*]] = icmp slt i64 [[IDX]], 1 +; CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[RETURN:%.*]] +; CHECK: for.body: +; CHECK-NEXT:[[F:%.*]] = load i32, ptr @f, align 4 +; CHECK-NEXT:[[CMP1:%.*]] = icmp eq i32 [[F]], 0 +; CHECK-NEXT:br i1 [[CMP1]], label [[COND_END_THREAD:%.*]], label [[COND_END:%.*]] +; CHECK: cond.end: +; CHECK-NEXT:[[CMP_I:%.*]] = icmp sgt i32 [[VAL]], 0 +; CHECK-NEXT:[[COND_FR:%.*]] = freeze i1 [[CMP_I]] +; CHECK-NEXT:br i1 [[COND_FR]], label [[COND_END_THREAD]], label [[TMP0:%.*]] +; CHECK: cond.end.thread: +; CHECK-NEXT:[[F_RELOAD_PR:%.*]] = load i32, ptr @f, align 4 +; CHECK-NEXT:br label [[TMP0]] +; CHECK: 0: +; CHECK-NEXT:[[F_RELOAD:%.*]] = phi i32 [ [[F]], [[COND_END]] ], [ [[F_RELOAD_PR]], [[COND_END_THREAD]] ] +; CHECK-NEXT:[[TMP1:%.*]] = phi i32 [ 0, [[COND_END_THREAD]] ], [ [[VAL]], [[COND_END]] ] +; CHECK-NEXT:[[F_IDX:%.*]] = getelementptr inbounds i32, ptr @f, i64 [[IDX]] +; CHECK-NEXT:store i32 [[TMP1]], ptr [[F_IDX]], align 4 +; CHECK-NEXT:[[CMP3:%.*]] = icmp slt i32 [[F_RELOAD]], 1 +; CHECK-NEXT:br i1 [[CMP3]], label [[RETURN2:%.*]], label [[RETURN]] +; CHECK: return: +; CHECK-NEXT:ret i32 0 +; CHECK: return2: +; CHECK-NEXT:ret i32 1 +; +entry: + %cmp = icmp slt i64 %idx, 1 + br i1 %cmp, label %for.body, label %return + +for.body: + %f = load i32, ptr @f, align 4 + %cmp1 = icmp eq i32 %f, 0 + br i1 %cmp1, label %cond.end, label %cond.false + +cond.false: + br label %cond.end + +cond.end: + %phi = phi i32 [ %val, %cond.false ], [ 1, %for.body ] + %cmp.i = icmp sgt i32 %phi, 0 + %sel = select i1 %cmp.i, i32 0, i32 %phi + %f.idx = getelementptr inbounds i32, ptr @f, i64 %idx + store i32 %sel, ptr %f.idx, align 4 + %f.reload = load i32, ptr @f, align 4 + %cmp3 = icmp slt i32 %f.reload, 1 + br i1 %cmp3, label %return2, label %return + +return: + ret i32 0 + +return2: + ret i32 1 +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] f7d0a0e - [clang] Add GCC-compatible code model names for sparc64
Author: Koakuma Date: 2024-02-05T11:46:24-08:00 New Revision: f7d0a0e7aec97eb7f0719f0f3cfcf94ad823fedd URL: https://github.com/llvm/llvm-project/commit/f7d0a0e7aec97eb7f0719f0f3cfcf94ad823fedd DIFF: https://github.com/llvm/llvm-project/commit/f7d0a0e7aec97eb7f0719f0f3cfcf94ad823fedd.diff LOG: [clang] Add GCC-compatible code model names for sparc64 This adds GCC-compatible names for code model selection on 64-bit SPARC with absolute code. Testing with a 2-stage build then running codegen tests works okay under all of the supported code models. (32-bit target does not have selectable code models) Reviewed By: @brad0, @MaskRay (cherry picked from commit b0f0babff22e9c0af74535b05e2c6424392bb24a) Added: clang/test/Driver/sparc64-codemodel.c Modified: clang/lib/Driver/ToolChains/Clang.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 8092fc050b0ee..54de8edd9a039 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5779,6 +5779,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // NVPTX/AMDGPU does not care about the code model and will accept // whatever works for the host. Ok = true; +} else if (Triple.isSPARC64()) { + if (CM == "medlow") +CM = "small"; + else if (CM == "medmid") +CM = "medium"; + else if (CM == "medany") +CM = "large"; + Ok = CM == "small" || CM == "medium" || CM == "large"; } if (Ok) { CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM)); diff --git a/clang/test/Driver/sparc64-codemodel.c b/clang/test/Driver/sparc64-codemodel.c new file mode 100644 index 0..e4b01fd61b6fa --- /dev/null +++ b/clang/test/Driver/sparc64-codemodel.c @@ -0,0 +1,6 @@ +// RUN: %clang --target=sparc64 -mcmodel=medlow %s -### 2>&1 | FileCheck -check-prefix=MEDLOW %s +// RUN: %clang --target=sparc64 -mcmodel=medmid %s -### 2>&1 | FileCheck -check-prefix=MEDMID %s +// RUN: %clang --target=sparc64 -mcmodel=medany %s -### 2>&1 | FileCheck -check-prefix=MEDANY %s +// MEDLOW: "-mcmodel=small" +// MEDMID: "-mcmodel=medium" +// MEDANY: "-mcmodel=large" ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] PR for llvm/llvm-project#80599 (PR #80600)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80600 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 47fbb64 - [AMDGPU][PromoteAlloca] Support memsets to ptr allocas (#80678)
Author: Pierre van Houtryve Date: 2024-02-05T11:48:14-08:00 New Revision: 47fbb649e12f7016ee60a5918bda26c01f2ea543 URL: https://github.com/llvm/llvm-project/commit/47fbb649e12f7016ee60a5918bda26c01f2ea543 DIFF: https://github.com/llvm/llvm-project/commit/47fbb649e12f7016ee60a5918bda26c01f2ea543.diff LOG: [AMDGPU][PromoteAlloca] Support memsets to ptr allocas (#80678) Fixes #80366 (cherry picked from commit 4e958abf2f44d08129eafd5b6a4ee2bd3584ed22) Added: Modified: llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp llvm/test/CodeGen/AMDGPU/promote-alloca-memset.ll Removed: diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp index 5e73411cae9b7..c1b244f50d93f 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -521,10 +521,18 @@ static Value *promoteAllocaUserToVector( // For memset, we don't need to know the previous value because we // currently only allow memsets that cover the whole alloca. Value *Elt = MSI->getOperand(1); - if (DL.getTypeStoreSize(VecEltTy) > 1) { -Value *EltBytes = -Builder.CreateVectorSplat(DL.getTypeStoreSize(VecEltTy), Elt); -Elt = Builder.CreateBitCast(EltBytes, VecEltTy); + const unsigned BytesPerElt = DL.getTypeStoreSize(VecEltTy); + if (BytesPerElt > 1) { +Value *EltBytes = Builder.CreateVectorSplat(BytesPerElt, Elt); + +// If the element type of the vector is a pointer, we need to first cast +// to an integer, then use a PtrCast. +if (VecEltTy->isPointerTy()) { + Type *PtrInt = Builder.getIntNTy(BytesPerElt * 8); + Elt = Builder.CreateBitCast(EltBytes, PtrInt); + Elt = Builder.CreateIntToPtr(Elt, VecEltTy); +} else + Elt = Builder.CreateBitCast(EltBytes, VecEltTy); } return Builder.CreateVectorSplat(VectorTy->getElementCount(), Elt); diff --git a/llvm/test/CodeGen/AMDGPU/promote-alloca-memset.ll b/llvm/test/CodeGen/AMDGPU/promote-alloca-memset.ll index 15af1f17e230e..f1e2737b370ef 100644 --- a/llvm/test/CodeGen/AMDGPU/promote-alloca-memset.ll +++ b/llvm/test/CodeGen/AMDGPU/promote-alloca-memset.ll @@ -84,4 +84,58 @@ entry: ret void } +define amdgpu_kernel void @memset_array_ptr_alloca(ptr %out) { +; CHECK-LABEL: @memset_array_ptr_alloca( +; CHECK-NEXT:store i64 0, ptr [[OUT:%.*]], align 8 +; CHECK-NEXT:ret void +; + %alloca = alloca [6 x ptr], align 16, addrspace(5) + call void @llvm.memset.p5.i64(ptr addrspace(5) %alloca, i8 0, i64 48, i1 false) + %load = load i64, ptr addrspace(5) %alloca + store i64 %load, ptr %out + ret void +} + +define amdgpu_kernel void @memset_vector_ptr_alloca(ptr %out) { +; CHECK-LABEL: @memset_vector_ptr_alloca( +; CHECK-NEXT:store i64 0, ptr [[OUT:%.*]], align 8 +; CHECK-NEXT:ret void +; + %alloca = alloca <6 x ptr>, align 16, addrspace(5) + call void @llvm.memset.p5.i64(ptr addrspace(5) %alloca, i8 0, i64 48, i1 false) + %load = load i64, ptr addrspace(5) %alloca + store i64 %load, ptr %out + ret void +} + +define amdgpu_kernel void @memset_array_of_array_ptr_alloca(ptr %out) { +; CHECK-LABEL: @memset_array_of_array_ptr_alloca( +; CHECK-NEXT:[[ALLOCA:%.*]] = alloca [2 x [3 x ptr]], align 16, addrspace(5) +; CHECK-NEXT:call void @llvm.memset.p5.i64(ptr addrspace(5) [[ALLOCA]], i8 0, i64 48, i1 false) +; CHECK-NEXT:[[LOAD:%.*]] = load i64, ptr addrspace(5) [[ALLOCA]], align 8 +; CHECK-NEXT:store i64 [[LOAD]], ptr [[OUT:%.*]], align 8 +; CHECK-NEXT:ret void +; + %alloca = alloca [2 x [3 x ptr]], align 16, addrspace(5) + call void @llvm.memset.p5.i64(ptr addrspace(5) %alloca, i8 0, i64 48, i1 false) + %load = load i64, ptr addrspace(5) %alloca + store i64 %load, ptr %out + ret void +} + +define amdgpu_kernel void @memset_array_of_vec_ptr_alloca(ptr %out) { +; CHECK-LABEL: @memset_array_of_vec_ptr_alloca( +; CHECK-NEXT:[[ALLOCA:%.*]] = alloca [2 x <3 x ptr>], align 16, addrspace(5) +; CHECK-NEXT:call void @llvm.memset.p5.i64(ptr addrspace(5) [[ALLOCA]], i8 0, i64 48, i1 false) +; CHECK-NEXT:[[LOAD:%.*]] = load i64, ptr addrspace(5) [[ALLOCA]], align 8 +; CHECK-NEXT:store i64 [[LOAD]], ptr [[OUT:%.*]], align 8 +; CHECK-NEXT:ret void +; + %alloca = alloca [2 x <3 x ptr>], align 16, addrspace(5) + call void @llvm.memset.p5.i64(ptr addrspace(5) %alloca, i8 0, i64 48, i1 false) + %load = load i64, ptr addrspace(5) %alloca + store i64 %load, ptr %out + ret void +} + declare void @llvm.memset.p5.i64(ptr addrspace(5) nocapture writeonly, i8, i64, i1 immarg) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80694 (PR #80695)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80695 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] 7253396 - [libc++] Add missing conditionals for feature-test macros (#80168)
Author: Louis Dionne Date: 2024-02-05T11:49:51-08:00 New Revision: 72533964036dca3ce806044e92a1e70584e3aca9 URL: https://github.com/llvm/llvm-project/commit/72533964036dca3ce806044e92a1e70584e3aca9 DIFF: https://github.com/llvm/llvm-project/commit/72533964036dca3ce806044e92a1e70584e3aca9.diff LOG: [libc++] Add missing conditionals for feature-test macros (#80168) We noticed that some feature-test macros were not conditional on configuration flags like _LIBCPP_HAS_NO_FILESYSTEM. As a result, code attempting to use FTMs would not work as intended. This patch adds conditionals for a few feature-test macros, but more issues may exist. rdar://122020466 (cherry picked from commit f2c84211d2834c73ff874389c6bb47b1c76d391a) Added: Modified: libcxx/include/version libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/fstream.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/iomanip.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/mutex.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Removed: diff --git a/libcxx/include/version b/libcxx/include/version index 9e26da8c1b242..d356976d6454a 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -266,7 +266,9 @@ __cpp_lib_within_lifetime 202306L # define __cpp_lib_make_reverse_iterator201402L # define __cpp_lib_make_unique 201304L # define __cpp_lib_null_iterators 201304L -# define __cpp_lib_quoted_string_io 201304L +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# define __cpp_lib_quoted_string_io 201304L +# endif # define __cpp_lib_result_of_sfinae 201210L # define __cpp_lib_robust_nonmodifying_seq_ops 201304L # if !defined(_LIBCPP_HAS_NO_THREADS) @@ -294,7 +296,7 @@ __cpp_lib_within_lifetime 202306L # define __cpp_lib_clamp201603L # define __cpp_lib_enable_shared_from_this 201603L // # define __cpp_lib_execution201603L -# if _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY +# if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY # define __cpp_lib_filesystem 201703L # endif # define __cpp_lib_gcd_lcm 201606L @@ -323,7 +325,9 @@ __cpp_lib_within_lifetime 202306L // # define __cpp_lib_parallel_algorithm 201603L # define __cpp_lib_raw_memory_algorithms201606L # define __cpp_lib_sample 201603L -# define __cpp_lib_scoped_lock 201703L +# if !defined(_LIBCPP_HAS_NO_THREADS) +# define __cpp_lib_scoped_lock201703L +# endif # if !defined(_LIBCPP_HAS_NO_THREADS) # define __cpp_lib_shared_mutex 201505L # endif @@ -496,7 +500,9 @@ __cpp_lib_within_lifetime 202306L // # define __cpp_lib_freestanding_optional202311L // # define __cpp_lib_freestanding_string_view 202311L // # define __cpp_lib_freestanding_variant 202311L -# define __cpp_lib_fstream_native_handle202306L +# if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# define __cpp_lib_fstream_native_handle 202306L +# endif // # define __cpp_lib_function_ref 202306L // # define __cpp_lib_hazard_pointer 202306L // # define __cpp_lib_linalg 202311L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.compile.pass.cpp index 46ccde800c179..3f03e8be9aeab 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.compile.pass.cpp @@ -51,7 +51,7 @@ # error "__cpp_lib_char8_t should not be defined before c++20" # endif -# if !defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY +# if !defined(_LIBCPP_VERSION) || (!defined(_LIBCPP_HAS_NO_FILESYSTEM) && _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY) # ifndef __cpp_lib_filesystem # error "__cpp_lib_fil
[llvm-branch-commits] [libcxx] PR for llvm/llvm-project#80168 (PR #80702)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80702 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] 984fe40 - [libc++] Rename __bit_reference template parameter to avoid conflict (#80661)
Author: Dimitry Andric Date: 2024-02-05T13:21:41-08:00 New Revision: 984fe4054a4e67ed3a781e15a4269a2a89b5f424 URL: https://github.com/llvm/llvm-project/commit/984fe4054a4e67ed3a781e15a4269a2a89b5f424 DIFF: https://github.com/llvm/llvm-project/commit/984fe4054a4e67ed3a781e15a4269a2a89b5f424.diff LOG: [libc++] Rename __bit_reference template parameter to avoid conflict (#80661) As of 4d20cfcf4eb08217ed37c4d4c38dc395d7a66d26, `__bit_reference` contains a template `__fill_n` with a bool `_FillValue` parameter. Unfortunately there is a relatively widely used piece of scientific software called NetCDF, which exposes a (C) macro `_FillValue` in its public headers. When building the NetCDF C++ bindings, this quickly leads to compilation errors when the macro interferes with the template in `__bit_reference`. Rename the parameter to `_FillVal` to avoid the conflict. (cherry picked from commit 1ec252298925de50b27930c557ba9de3cc397afe) Added: Modified: libcxx/include/__bit_reference Removed: diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference index 9032b8f018093..3a5339b72ddc3 100644 --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -173,7 +173,7 @@ private: // fill_n -template +template _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { using _It= __bit_iterator<_Cp, false>; @@ -185,7 +185,7 @@ __fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); __storage_type __dn= std::min(__clz_f, __n); __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); -if (_FillValue) +if (_FillVal) *__first.__seg_ |= __m; else *__first.__seg_ &= ~__m; @@ -194,13 +194,13 @@ __fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { } // do middle whole words __storage_type __nw = __n / __bits_per_word; - std::fill_n(std::__to_address(__first.__seg_), __nw, _FillValue ? static_cast<__storage_type>(-1) : 0); + std::fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) { __first.__seg_ += __nw; __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); -if (_FillValue) +if (_FillVal) *__first.__seg_ |= __m; else *__first.__seg_ &= ~__m; @@ -1007,7 +1007,7 @@ private: friend class __bit_iterator<_Cp, true>; template friend struct __bit_array; - template + template _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void __fill_n(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); template ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] PR for llvm/llvm-project#80718 (PR #80720)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80720 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [18.x][Docs] Add release note about Clang-defined target OS macros (PR #80044)
tstellar wrote: Looks like this patch caused the documentation build to fail. https://github.com/llvm/llvm-project/pull/80044 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80715 (PR #80716)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80716 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [workflows] Fix version-check.yml to work with the new minor release bump (PR #79495)
tstellar wrote: Merged: 6abd792a67471975596cda7db4fe5762b3e5511f https://github.com/llvm/llvm-project/pull/79495 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [workflows] Fix version-check.yml to work with the new minor release bump (PR #79495)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/79495 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] CI fixes for release/18.x (PR #80772)
https://github.com/tstellar milestoned https://github.com/llvm/llvm-project/pull/80772 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] CI fixes for release/18.x (PR #80772)
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/80772 None >From e54eaf5a5136628ae8f2bc00c6d769b33dd2c0f0 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sat, 3 Feb 2024 21:37:46 -0800 Subject: [PATCH 1/3] [workflows] Stop using the build-test-llvm-project action (#80580) This action is really just a wrapper around cmake and ninja. It doesn't add any value to the builds, and I don't think we need it now that there are reusable workflows. (cherry picked from commit d25022bb689b9bf48a24c0ae6c29c1d3c2f32823) --- .github/workflows/llvm-project-tests.yml | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index 91d0b258394ef..79a382bfa4f9a 100644 --- a/.github/workflows/llvm-project-tests.yml +++ b/.github/workflows/llvm-project-tests.yml @@ -98,14 +98,23 @@ jobs: key: ${{ matrix.os }} variant: sccache - name: Build and Test -uses: llvm/actions/build-test-llvm-project@main env: # Workaround for https://github.com/actions/virtual-environments/issues/5900. # This should be a no-op for non-mac OSes PKG_CONFIG_PATH: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12 -with: - cmake_args: '-GNinja -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLDB_INCLUDE_TESTS=OFF -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ inputs.extra_cmake_args }}' - build_target: '${{ inputs.build_target }}' +shell: bash +run: | + cmake -G Ninja \ +-B build \ +-S llvm \ +-DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" \ +-DCMAKE_BUILD_TYPE=Release \ +-DLLVM_ENABLE_ASSERTIONS=ON \ +-DLLDB_INCLUDE_TESTS=OFF \ +-DCMAKE_C_COMPILER_LAUNCHER=sccache \ +-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ +${{ inputs.extra_cmake_args }} + ninja -C build '${{ inputs.build_target }}' - name: Build and Test libclc if: "!startsWith(matrix.os, 'windows') && contains(inputs.projects, 'libclc')" >From ff2405a632eeb0d9356108c5fd0d86afdbe4d163 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 5 Feb 2024 16:44:11 -0800 Subject: [PATCH 2/3] [workflows] Fix lldb-tests and libclc-tests (#80751) This was broken by d25022bb689b9bf48a24c0ae6c29c1d3c2f32823, which caused the workflow to pass an empty string to ninja as the target. The 'all' target is probably not the right target for these tests, but this is what the behavior was before d25022bb689b9bf48a24c0ae6c29c1d3c2f32823. (cherry picked from commit 792d928e15aa30c8b686eff465598ceea0b03891) --- .github/workflows/libclc-tests.yml | 1 - .github/workflows/lldb-tests.yml | 1 - .github/workflows/llvm-project-tests.yml | 3 ++- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/libclc-tests.yml b/.github/workflows/libclc-tests.yml index 29d050db2f12c..23192f776a985 100644 --- a/.github/workflows/libclc-tests.yml +++ b/.github/workflows/libclc-tests.yml @@ -36,5 +36,4 @@ jobs: name: Test libclc uses: ./.github/workflows/llvm-project-tests.yml with: - build_target: '' projects: clang;libclc diff --git a/.github/workflows/lldb-tests.yml b/.github/workflows/lldb-tests.yml index ef5d7c7d581b7..6bb9721956258 100644 --- a/.github/workflows/lldb-tests.yml +++ b/.github/workflows/lldb-tests.yml @@ -36,5 +36,4 @@ jobs: name: Build lldb uses: ./.github/workflows/llvm-project-tests.yml with: - build_target: '' projects: clang;lldb diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index 79a382bfa4f9a..0e361bfb77fe4 100644 --- a/.github/workflows/llvm-project-tests.yml +++ b/.github/workflows/llvm-project-tests.yml @@ -22,8 +22,9 @@ on: workflow_call: inputs: build_target: -required: true +required: false type: string +default: "all" projects: required: true >From 4929f87c3f9e320cb89af2ce2f5dbe27f69851ac Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 5 Feb 2024 09:46:19 -0800 Subject: [PATCH 3/3] [workflows] Use /mnt as the build directory on Linux (#80583) There is more space available on /mnt (~56G) than on / (~30G), and we are starting to see some of the CI jobs run out of disk space on Linux. (cherry picked from commit 1a6426067fb33a8a789978f6e229108787a041be) --- .github/workflows/llvm-project-tests.yml | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index 0e361bfb77fe4..3bc7bd4957fa6 100644 --- a/.github/workflows/llvm-project-tests.y
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80580 (PR #80584)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80584 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80580 (PR #80584)
tstellar wrote: Dropping this in favor of #80772. https://github.com/llvm/llvm-project/pull/80584 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80348 (PR #80585)
tstellar wrote: /cherry-pick 2193c95e2459887e7e6e4f9f4aacf9252e99858f 4b34558f43121df9b863ff2492f74fb2e65a5af1 https://github.com/llvm/llvm-project/pull/80585 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] ad0fb41 - [CMake][PGO] Add option for using an external project to generate profile data (#78879)
Author: Tom Stellard Date: 2024-02-06T11:49:07-08:00 New Revision: ad0fb418badbb695b5db9335985e67c67e69c554 URL: https://github.com/llvm/llvm-project/commit/ad0fb418badbb695b5db9335985e67c67e69c554 DIFF: https://github.com/llvm/llvm-project/commit/ad0fb418badbb695b5db9335985e67c67e69c554.diff LOG: [CMake][PGO] Add option for using an external project to generate profile data (#78879) The new CLANG_PGO_TRAINING_DATA_SOURCE_DIR allows users to specify a CMake project to use for generating the profile data. For example, to use the llvm-test-suite to generate profile data you would do: $ cmake -G Ninja -B build -S llvm -C /clang/cmake/caches/PGO.cmake \ -DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR= \ -DBOOTSTRAP_CLANG_PGO_TRAINING_DEPS=runtimes Note that the CLANG_PERF_TRAINING_DEPS has been renamed to CLANG_PGO_TRAINING_DEPS. - Co-authored-by: Petr Hosek (cherry picked from commit dd0356d741aefa25ece973d6cc4b55dcb73b84b4) Added: Modified: clang/utils/perf-training/CMakeLists.txt clang/utils/perf-training/perf-helper.py llvm/docs/AdvancedBuilds.rst Removed: diff --git a/clang/utils/perf-training/CMakeLists.txt b/clang/utils/perf-training/CMakeLists.txt index c6d51863fb1b5c..93744f46060236 100644 --- a/clang/utils/perf-training/CMakeLists.txt +++ b/clang/utils/perf-training/CMakeLists.txt @@ -1,6 +1,10 @@ +include(LLVMExternalProjectUtils) + set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "The path to a lit testsuite containing samples for PGO and order file generation" ) +set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source directory containing cmake project with source files to use for generating pgo data") +set(CLANG_PGO_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to build the PGO training data.") if(LLVM_BUILD_INSTRUMENTED) configure_lit_site_cfg( @@ -11,11 +15,11 @@ if(LLVM_BUILD_INSTRUMENTED) add_lit_testsuite(generate-profraw "Generating clang PGO data" ${CMAKE_CURRENT_BINARY_DIR}/pgo-data/ EXCLUDE_FROM_CHECK_ALL -DEPENDS clang clear-profraw ${CLANG_PERF_TRAINING_DEPS} +DEPENDS clang clear-profraw ${CLANG_PGO_TRAINING_DEPS} ) add_custom_target(clear-profraw -COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} profraw +COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ profraw COMMENT "Clearing old profraw data") if(NOT LLVM_PROFDATA) @@ -26,9 +30,14 @@ if(LLVM_BUILD_INSTRUMENTED) message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to llvm-profdata") else() add_custom_target(generate-profdata - COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} + COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ COMMENT "Merging profdata" DEPENDS generate-profraw) +if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR) + llvm_ExternalProject_Add(generate-profraw-external ${CLANG_PGO_TRAINING_DATA_SOURCE_DIR} + USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS generate-profraw) + add_dependencies(generate-profdata generate-profraw-external) +endif() endif() endif() diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py index 99d6ab6ef0..3e92cd38a71451 100644 --- a/clang/utils/perf-training/perf-helper.py +++ b/clang/utils/perf-training/perf-helper.py @@ -30,26 +30,28 @@ def findFilesWithExtension(path, extension): def clean(args): -if len(args) != 2: +if len(args) < 2: print( -"Usage: %s clean \n" % __file__ +"Usage: %s clean \n" % __file__ + "\tRemoves all files with extension from ." ) return 1 -for filename in findFilesWithExtension(args[0], args[1]): -os.remove(filename) +for path in args[1:-1]: +for filename in findFilesWithExtension(path, args[-1]): +os.remove(filename) return 0 def merge(args): -if len(args) != 3: +if len(args) < 3: print( -"Usage: %s merge \n" % __file__ +"Usage: %s merge \n" % __file__ + "\tMerges all profraw files from path into output." ) return 1 cmd = [args[0], "merge", "-o", args[1]] -cmd.extend(findFilesWithExtension(args[2], "profraw")) +for path in args[2:]: +cmd.extend(findFilesWithExtension(path, "profraw")) subprocess.check_call(cmd) return 0 diff --git a/llvm/d
[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#80565 (PR #80566)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80566 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 8835ba8 - [BPI] Transfer value-handles when assign/move constructing BPI (#77774)
Author: Jeremy Morse Date: 2024-02-06T15:38:30-08:00 New Revision: 8835ba873031a412595de2ce90e46fb65e93d214 URL: https://github.com/llvm/llvm-project/commit/8835ba873031a412595de2ce90e46fb65e93d214 DIFF: https://github.com/llvm/llvm-project/commit/8835ba873031a412595de2ce90e46fb65e93d214.diff LOG: [BPI] Transfer value-handles when assign/move constructing BPI (#4) Background: BPI stores a collection of edge branch-probabilities, and also a set of Callback value-handles for the blocks in the edge-collection. When a block is deleted, BPI's eraseBlock method is called to clear the edge-collection of references to that block, to avoid dangling pointers. However, when move-constructing or assigning a BPI object, the edge-collection gets moved, but the value-handles are discarded. This can lead to to stale entries in the edge-collection when blocks are deleted without the callback -- not normally a problem, but if a new block is allocated with the same address as an old block, spurious branch probabilities will be recorded about it. The fix is to transfer the handles from the source BPI object. This was exposed by an unrelated debug-info change, it probably just shifted around allocation orders to expose this. Detected as nondeterminism and reduced by Zequan Wu: https://github.com/llvm/llvm-project/commit/f1b0a544514f3d343f32a41de9d6fb0b6cbb6021#commitcomment-136737090 (No test because IMHO testing for a behaviour that varies with memory allocators is likely futile; I can add the reproducer with a CHECK for the relevant branch weights if it's desired though) (cherry picked from commit 604a6c409e8473b212952b8633d92bbdb22a45c9) Added: Modified: llvm/include/llvm/Analysis/BranchProbabilityInfo.h Removed: diff --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h index 6b9d178182011..91e1872e9bd6f 100644 --- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h +++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h @@ -122,16 +122,23 @@ class BranchProbabilityInfo { } BranchProbabilityInfo(BranchProbabilityInfo &&Arg) - : Probs(std::move(Arg.Probs)), LastF(Arg.LastF), -EstimatedBlockWeight(std::move(Arg.EstimatedBlockWeight)) {} + : Handles(std::move(Arg.Handles)), Probs(std::move(Arg.Probs)), +LastF(Arg.LastF), +EstimatedBlockWeight(std::move(Arg.EstimatedBlockWeight)) { +for (auto &Handle : Handles) + Handle.setBPI(this); + } BranchProbabilityInfo(const BranchProbabilityInfo &) = delete; BranchProbabilityInfo &operator=(const BranchProbabilityInfo &) = delete; BranchProbabilityInfo &operator=(BranchProbabilityInfo &&RHS) { releaseMemory(); +Handles = std::move(RHS.Handles); Probs = std::move(RHS.Probs); EstimatedBlockWeight = std::move(RHS.EstimatedBlockWeight); +for (auto &Handle : Handles) + Handle.setBPI(this); return *this; } @@ -279,6 +286,8 @@ class BranchProbabilityInfo { } public: +void setBPI(BranchProbabilityInfo *BPI) { this->BPI = BPI; } + BasicBlockCallbackVH(const Value *V, BranchProbabilityInfo *BPI = nullptr) : CallbackVH(const_cast(V)), BPI(BPI) {} }; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80699 (PR #80729)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80729 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 7a9e418 - [InstCombine] Fix assertion failure in issue80597 (#80614)
Author: Yingwei Zheng Date: 2024-02-06T15:40:40-08:00 New Revision: 7a9e4184fbb17d31265253f69b3bf5217c0d967c URL: https://github.com/llvm/llvm-project/commit/7a9e4184fbb17d31265253f69b3bf5217c0d967c DIFF: https://github.com/llvm/llvm-project/commit/7a9e4184fbb17d31265253f69b3bf5217c0d967c.diff LOG: [InstCombine] Fix assertion failure in issue80597 (#80614) The assertion in #80597 failed when we were trying to compute known bits of a value in an unreachable BB. https://github.com/llvm/llvm-project/blob/859b09da08c2a47026ba0a7d2f21b7dca705864d/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L749-L810 In this case, `SignBits` is 30 (deduced from instr info), but `Known` is `110101011101000101000?0?` (deduced from dom cond). Setting high bits of `lshr Known, 1` will lead to conflict. This patch masks out high bits of `Known.Zero` to address this problem. Fixes #80597. (cherry picked from commit cb8d83a77c25e529f58eba17bb1ec76069a04e90) Added: llvm/test/Transforms/InstCombine/pr80597.ll Modified: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Removed: diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index a8a5f9831e15e3..79873a9b4cbb4c 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -802,6 +802,9 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, return InsertNewInstWith(LShr, I->getIterator()); } else if (Known.One[BitWidth-ShiftAmt-1]) { // New bits are known one. Known.One |= HighBits; +// SignBits may be out-of-sync with Known.countMinSignBits(). Mask out +// high bits of Known.Zero to avoid conflicts. +Known.Zero &= ~HighBits; } } else { computeKnownBits(I, Known, Depth, CxtI); diff --git a/llvm/test/Transforms/InstCombine/pr80597.ll b/llvm/test/Transforms/InstCombine/pr80597.ll new file mode 100644 index 00..5feae4a06c45c0 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pr80597.ll @@ -0,0 +1,33 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -S -passes=instcombine < %s | FileCheck %s + +define i64 @pr80597(i1 %cond) { +; CHECK-LABEL: define i64 @pr80597( +; CHECK-SAME: i1 [[COND:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[ADD:%.*]] = select i1 [[COND]], i64 0, i64 -12884901888 +; CHECK-NEXT:[[SEXT1:%.*]] = add nsw i64 [[ADD]], 8836839514384105472 +; CHECK-NEXT:[[CMP:%.*]] = icmp ult i64 [[SEXT1]], -34359738368 +; CHECK-NEXT:br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]] +; CHECK: if.else: +; CHECK-NEXT:[[SEXT2:%.*]] = ashr exact i64 [[ADD]], 1 +; CHECK-NEXT:[[ASHR:%.*]] = or i64 [[SEXT2]], 4418419761487020032 +; CHECK-NEXT:ret i64 [[ASHR]] +; CHECK: if.then: +; CHECK-NEXT:ret i64 0 +; +entry: + %add = select i1 %cond, i64 0, i64 4294967293 + %add8 = shl i64 %add, 32 + %sext1 = add i64 %add8, 8836839514384105472 + %cmp = icmp ult i64 %sext1, -34359738368 + br i1 %cmp, label %if.then, label %if.else + +if.else: + %sext2 = or i64 %add8, 8836839522974040064 + %ashr = ashr i64 %sext2, 1 + ret i64 %ashr + +if.then: + ret i64 0 +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80597 (PR #80731)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80731 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80585 (PR #80776)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80776 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] PR for llvm/llvm-project#80789 (PR #80790)
tstellar wrote: This has a failing CI test that needs to be fixed. https://github.com/llvm/llvm-project/pull/80790 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] c92b81d - [Profile][Windows] Drop extern for __buildid. (#80700)
Author: Zequan Wu Date: 2024-02-06T15:45:32-08:00 New Revision: c92b81dde8a3068d90f5c4e7c012ffa34ede7da5 URL: https://github.com/llvm/llvm-project/commit/c92b81dde8a3068d90f5c4e7c012ffa34ede7da5 DIFF: https://github.com/llvm/llvm-project/commit/c92b81dde8a3068d90f5c4e7c012ffa34ede7da5.diff LOG: [Profile][Windows] Drop extern for __buildid. (#80700) (cherry picked from commit dd22140e21f2ef51cf031354966a3d41c191c6e7) Added: Modified: compiler-rt/lib/profile/InstrProfilingPlatformWindows.c Removed: diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c index c976776ae59e9c..0751b28f81d0ac 100644 --- a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c +++ b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c @@ -77,7 +77,7 @@ ValueProfNode *EndVNode = &VNodesEnd; /* lld-link provides __buildid symbol which ponits to the 16 bytes build id when * using /build-id flag. https://lld.llvm.org/windows_support.html#lld-flags */ #define BUILD_ID_LEN 16 -COMPILER_RT_WEAK extern uint8_t __buildid[BUILD_ID_LEN]; +COMPILER_RT_WEAK uint8_t __buildid[BUILD_ID_LEN]; COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) { if (*__buildid) { if (Writer && ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80811 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] ecd1cee - [CLANG] Fix INF/NAN warning. (#80290)
Author: Zahira Ammarguellat Date: 2024-02-06T15:46:29-08:00 New Revision: ecd1cee3e0d7e8bbe7ce98ca81c9c96e1804709c URL: https://github.com/llvm/llvm-project/commit/ecd1cee3e0d7e8bbe7ce98ca81c9c96e1804709c DIFF: https://github.com/llvm/llvm-project/commit/ecd1cee3e0d7e8bbe7ce98ca81c9c96e1804709c.diff LOG: [CLANG] Fix INF/NAN warning. (#80290) In https://github.com/llvm/llvm-project/pull/76873 a warning was added when the macros INFINITY and NAN are used in binary expressions when -menable-no-nans or -menable-no-infs are used. If the user uses an option that nullifies these two options, the warning will still be generated. This patch adds an additional information to the warning comment to let the user know about this. It also suppresses the warning when #ifdef INFINITY, #ifdef NAN, #ifdef NAN or #ifndef NAN are used in the code. (cherry picked from commit 62c352e13c145b5606ace88ecbe9164ff011b5cf) Added: Modified: clang/include/clang/Basic/DiagnosticCommonKinds.td clang/include/clang/Basic/DiagnosticDocs.td clang/include/clang/Lex/Preprocessor.h clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPExpressions.cpp clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp clang/test/Sema/warn-infinity-nan-disabled-win.cpp Removed: diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index b1bada65cb6b28..08bb1d81ba29f1 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -73,7 +73,7 @@ def warn_pragma_debug_unexpected_argument : Warning< def warn_fp_nan_inf_when_disabled : Warning< "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior " "due to the currently enabled floating-point options">, - InGroup>; + InGroup>; } // Parse && Sema diff --git a/clang/include/clang/Basic/DiagnosticDocs.td b/clang/include/clang/Basic/DiagnosticDocs.td index e9862422b4997e..8c024b5cad740a 100644 --- a/clang/include/clang/Basic/DiagnosticDocs.td +++ b/clang/include/clang/Basic/DiagnosticDocs.td @@ -87,3 +87,12 @@ program by treating all string literals as having type ``const char *`` instead of ``char *``. This can cause unexpected behaviors with type-sensitive constructs like ``_Generic``. }]; + +defvar NanInfDisabledDocs = [{ +This warning is enabled when source code using the macros ``INFINITY`` or ``NAN`` +is compiled with floating-point options preventing these two values. This can +lead to undefined behavior. Check the order of command line arguments that modify +this behavior, such as ``-ffast-math``, ``-fhonor-infinities``, and +``-fhonor-nans`` (etc), as well as ``#pragma`` directives if this diagnostic is +generated unexpectedly. +}]; diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 2d9c53cdf5bde8..b0a8ec0fec5e94 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -2828,7 +2828,8 @@ class Preprocessor { return AnnotationInfos.find(II)->second; } - void emitMacroExpansionWarnings(const Token &Identifier) const { + void emitMacroExpansionWarnings(const Token &Identifier, + bool IsIfnDef = false) const { IdentifierInfo *Info = Identifier.getIdentifierInfo(); if (Info->isDeprecatedMacro()) emitMacroDeprecationWarning(Identifier); @@ -2837,12 +2838,12 @@ class Preprocessor { !SourceMgr.isInMainFile(Identifier.getLocation())) emitRestrictExpansionWarning(Identifier); -if (Info->getName() == "INFINITY") - if (getLangOpts().NoHonorInfs) +if (!IsIfnDef) { + if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs) emitRestrictInfNaNWarning(Identifier, 0); -if (Info->getName() == "NAN") - if (getLangOpts().NoHonorNaNs) + if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs) emitRestrictInfNaNWarning(Identifier, 1); +} } static void processPathForFileMacro(SmallVectorImpl &Path, diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 9f82a6d073e3ba..a980f4bcbae124 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, return; } - emitMacroExpansionWarnings(MacroNameTok); + emitMacroExpansionWarnings(MacroNameTok, /*IsIfnDef=*/true); // Check to see if this is the last token on the #if[n]def line. CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef"); diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp index 1feb0eb18d71e6..8f25c67ec9dfbe 100644 --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/lib/Lex/PPExpressions.cpp @@ -133,7 +133,9 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTra
[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80845 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 36cecd9 - [MIPS] Use generic isBlockOnlyReachableByFallthrough (#80799)
Author: Fangrui Song Date: 2024-02-06T15:49:23-08:00 New Revision: 36cecd98cfd006e2b3b044e1433a8914916c98b9 URL: https://github.com/llvm/llvm-project/commit/36cecd98cfd006e2b3b044e1433a8914916c98b9 DIFF: https://github.com/llvm/llvm-project/commit/36cecd98cfd006e2b3b044e1433a8914916c98b9.diff LOG: [MIPS] Use generic isBlockOnlyReachableByFallthrough (#80799) FastISel may create a redundant BGTZ terminal which fallthroughes. ``` BGTZ %2:gpr32, %bb.1, implicit-def $at bb.1.bb1: ; predecessors: %bb.0 ``` The `!I->isBarrier()` check in MipsAsmPrinter::isBlockOnlyReachableByFallthrough will incorrectly not print a label, leading to a `Undefined temporary symbol ` error when we try assembling the output assembly file. See the updated `Fast-ISel/pr40325.ll` and https://github.com/rust-lang/rust/issues/108835 In addition, the `SwitchInst` condition is too conservative and prints many unneeded labels (see the updated tests). Just use the generic isBlockOnlyReachableByFallthrough, updated by commit 1995b9fead62f2f6c0ad217bd00ce3184f741fdb for SPARC, which also handles MIPS. (cherry picked from commit 6b2fd7aed66d592738f26c76caa8fff95e168598) Added: Modified: llvm/lib/Target/Mips/MipsAsmPrinter.cpp llvm/lib/Target/Mips/MipsAsmPrinter.h llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll llvm/test/CodeGen/Mips/compactbranches/unsafe-in-forbidden-slot.ll llvm/test/CodeGen/Mips/indirect-jump-hazard/jumptables.ll llvm/test/CodeGen/Mips/jump-table-mul.ll llvm/test/CodeGen/Mips/pseudo-jump-fill.ll Removed: diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index 718844bc36ff93..66b2b0de8d52a3 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -471,45 +471,6 @@ void MipsAsmPrinter::emitBasicBlockEnd(const MachineBasicBlock &MBB) { TS.emitDirectiveInsn(); } -/// isBlockOnlyReachableByFallthough - Return true if the basic block has -/// exactly one predecessor and the control transfer mechanism between -/// the predecessor and this block is a fall-through. -bool MipsAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock* - MBB) const { - // The predecessor has to be immediately before this block. - const MachineBasicBlock *Pred = *MBB->pred_begin(); - - // If the predecessor is a switch statement, assume a jump table - // implementation, so it is not a fall through. - if (const BasicBlock *bb = Pred->getBasicBlock()) -if (isa(bb->getTerminator())) - return false; - - // If this is a landing pad, it isn't a fall through. If it has no preds, - // then nothing falls through to it. - if (MBB->isEHPad() || MBB->pred_empty()) -return false; - - // If there isn't exactly one predecessor, it can't be a fall through. - if (MBB->pred_size() != 1) -return false; - - // The predecessor has to be immediately before this block. - if (!Pred->isLayoutSuccessor(MBB)) -return false; - - // If the block is completely empty, then it definitely does fall through. - if (Pred->empty()) -return true; - - // Otherwise, check the last instruction. - // Check if the last terminator is an unconditional branch. - MachineBasicBlock::const_iterator I = Pred->end(); - while (I != Pred->begin() && !(--I)->isTerminator()) ; - - return !I->isBarrier(); -} - // Print out an operand for an inline asm expression. bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, const char *ExtraCode, raw_ostream &O) { diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.h b/llvm/lib/Target/Mips/MipsAsmPrinter.h index 64424b181504a7..0b55089385d79d 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.h +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.h @@ -142,8 +142,6 @@ class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter { void emitFunctionBodyStart() override; void emitFunctionBodyEnd() override; void emitBasicBlockEnd(const MachineBasicBlock &MBB) override; - bool isBlockOnlyReachableByFallthrough( - const MachineBasicBlock* MBB) const override; bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override; bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, diff --git a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll index 9e64d7b2fa039b..c276515920d52a 100644 --- a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll +++ b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll @@ -11,7 +11,7 @@ define void @test(i32 %x, ptr %p) nounwind { ; CHECK-NEXT:andi $1, $4, 1 ; CHECK-NEXT:bgtz $1, $BB0_1 ; CHECK-NEXT:nop -; CHECK-
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80878 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] ae6cfa2 - [AArch64][TargetParser] Add mcpu alias for Microsoft Azure Cobalt 100. (#79614)
Author: Alexandros Lamprineas Date: 2024-02-06T15:51:16-08:00 New Revision: ae6cfa24d6f4a04a74734e75f23905041b6c276f URL: https://github.com/llvm/llvm-project/commit/ae6cfa24d6f4a04a74734e75f23905041b6c276f DIFF: https://github.com/llvm/llvm-project/commit/ae6cfa24d6f4a04a74734e75f23905041b6c276f.diff LOG: [AArch64][TargetParser] Add mcpu alias for Microsoft Azure Cobalt 100. (#79614) With a690e86 we added -mcpu/mtune=native support to handle the Microsoft Azure Cobalt 100 CPU as a Neoverse N2. This patch adds a CPU alias in TargetParser to maintain compatibility with GCC. (cherry picked from commit ae8005ffb6cd18900de8ed5a86f60a4a16975471) Added: Modified: clang/test/Driver/aarch64-mcpu.c clang/test/Misc/target-invalid-cpu-note.c llvm/include/llvm/TargetParser/AArch64TargetParser.h llvm/unittests/TargetParser/TargetParserTest.cpp Removed: diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c index 511482a420da26..3e07f3597f3408 100644 --- a/clang/test/Driver/aarch64-mcpu.c +++ b/clang/test/Driver/aarch64-mcpu.c @@ -72,6 +72,9 @@ // RUN: %clang --target=aarch64 -mcpu=cortex-r82 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEXR82 %s // CORTEXR82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-r82" +// RUN: %clang --target=aarch64 -mcpu=cobalt-100 -### -c %s 2>&1 | FileCheck -check-prefix=COBALT-100 %s +// COBALT-100: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-n2" + // RUN: %clang --target=aarch64 -mcpu=grace -### -c %s 2>&1 | FileCheck -check-prefix=GRACE %s // GRACE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-v2" diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c index 84aed5c9c36fe4..2f10bfb1fd82fe 100644 --- a/clang/test/Misc/target-invalid-cpu-note.c +++ b/clang/test/Misc/target-invalid-cpu-note.c @@ -5,11 +5,11 @@ // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 // AARCH64: error: unknown target CPU 'not-a-cpu' -// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}} +// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, cobalt-100, grace{{$}} // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu' -// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}} +// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510,
[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#79614 (PR #79870)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/79870 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 4251261 - [ConstraintElim] Add tests for #78621.
Author: Florian Hahn Date: 2024-02-06T16:05:15-08:00 New Revision: 42512617acf38425909676a190ed1b0ce9335616 URL: https://github.com/llvm/llvm-project/commit/42512617acf38425909676a190ed1b0ce9335616 DIFF: https://github.com/llvm/llvm-project/commit/42512617acf38425909676a190ed1b0ce9335616.diff LOG: [ConstraintElim] Add tests for #78621. Tests with umin where the result may be poison for https://github.com/llvm/llvm-project/issues/78621. (cherry picked from commit c83180c1248615cf6ea8842eb4e0cebebba4ab57) Added: llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll Modified: Removed: diff --git a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll new file mode 100644 index 00..35ac72e54d1894 --- /dev/null +++ b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll @@ -0,0 +1,60 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -p constraint-elimination -S %s | FileCheck %s + +; Tests for https://github.com/llvm/llvm-project/issues/78621. + +define i1 @umin_not_used(i32 %arg) { +; CHECK-LABEL: define i1 @umin_not_used( +; CHECK-SAME: i32 [[ARG:%.*]]) { +; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3 +; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80) +; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3 +; CHECK-NEXT:ret i1 false +; + %icmp = icmp slt i32 %arg, 0 + %shl = shl nuw nsw i32 %arg, 3 + call i32 @llvm.umin.i32(i32 %shl, i32 80) + %cmp2 = shl nuw nsw i32 %arg, 3 + ret i1 %icmp +} + +define i1 @umin_poison_is_UB_via_call(i32 %arg) { +; CHECK-LABEL: define i1 @umin_poison_is_UB_via_call( +; CHECK-SAME: i32 [[ARG:%.*]]) { +; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3 +; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80) +; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]]) +; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3 +; CHECK-NEXT:ret i1 false +; + %icmp = icmp slt i32 %arg, 0 + %shl = shl nuw nsw i32 %arg, 3 + %min = call i32 @llvm.umin.i32(i32 %shl, i32 80) + call void @noundef(i32 noundef %min) + %cmp2 = shl nuw nsw i32 %arg, 3 + ret i1 %icmp +} + +define i1 @umin_poison_call_before_UB(i32 %arg) { +; CHECK-LABEL: define i1 @umin_poison_call_before_UB( +; CHECK-SAME: i32 [[ARG:%.*]]) { +; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3 +; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80) +; CHECK-NEXT:call void @fn() +; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]]) +; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3 +; CHECK-NEXT:ret i1 false +; + %icmp = icmp slt i32 %arg, 0 + %shl = shl nuw nsw i32 %arg, 3 + %min = call i32 @llvm.umin.i32(i32 %shl, i32 80) + call void @fn() + call void @noundef(i32 noundef %min) + %cmp2 = shl nuw nsw i32 %arg, 3 + ret i1 %icmp +} + +declare i32 @llvm.umin.i32(i32, i32) #0 + +declare void @noundef(i32 noundef) +declare void @fn() ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 56c50a4 - [ConstraintElim] Make sure min/max intrinsic results are not poison.
Author: Florian Hahn Date: 2024-02-06T16:05:16-08:00 New Revision: 56c50a4e0b50fb59ae1f1b322b31a5546522a928 URL: https://github.com/llvm/llvm-project/commit/56c50a4e0b50fb59ae1f1b322b31a5546522a928 DIFF: https://github.com/llvm/llvm-project/commit/56c50a4e0b50fb59ae1f1b322b31a5546522a928.diff LOG: [ConstraintElim] Make sure min/max intrinsic results are not poison. The result of umin may be poison and in that case the added constraints are not be valid in contexts where poison doesn't cause UB. Only queue facts for min/max intrinsics if the result is guaranteed to not be poison. This could be improved in the future, by only adding the fact when solving conditions using the result value. Fixes https://github.com/llvm/llvm-project/issues/78621. (cherry picked from commit 3d91d9613e294b242d853039209b40a0cb7853f2) Added: Modified: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp llvm/test/Transforms/ConstraintElimination/minmax.ll llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll Removed: diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp index 8f09569d0d9cc..7b672e89b67aa 100644 --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -1061,11 +1061,16 @@ void State::addInfoFor(BasicBlock &BB) { FactOrCheck::getCheck(DT.getNode(&BB), cast(&I))); break; // Enqueue the intrinsics to add extra info. -case Intrinsic::abs: case Intrinsic::umin: case Intrinsic::umax: case Intrinsic::smin: case Intrinsic::smax: + // TODO: Check if it is possible to instead only added the min/max facts + // when simplifying uses of the min/max intrinsics. + if (!isGuaranteedNotToBePoison(&I)) +break; + [[fallthrough]]; +case Intrinsic::abs: WorkList.push_back(FactOrCheck::getInstFact(DT.getNode(&BB), &I)); break; } diff --git a/llvm/test/Transforms/ConstraintElimination/minmax.ll b/llvm/test/Transforms/ConstraintElimination/minmax.ll index a31cf6845ad67..82b932f14c4ff 100644 --- a/llvm/test/Transforms/ConstraintElimination/minmax.ll +++ b/llvm/test/Transforms/ConstraintElimination/minmax.ll @@ -306,7 +306,9 @@ define i1 @smin_branchless(i32 %x, i32 %y) { ; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[X]], i32 [[Y]]) -; CHECK-NEXT:[[RET:%.*]] = xor i1 true, false +; CHECK-NEXT:[[CMP1:%.*]] = icmp sle i32 [[MIN]], [[X]] +; CHECK-NEXT:[[CMP2:%.*]] = icmp sgt i32 [[MIN]], [[X]] +; CHECK-NEXT:[[RET:%.*]] = xor i1 [[CMP1]], [[CMP2]] ; CHECK-NEXT:ret i1 [[RET]] ; entry: diff --git a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll index 35ac72e54d189..6d1d95ec4fdba 100644 --- a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll +++ b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll @@ -6,10 +6,11 @@ define i1 @umin_not_used(i32 %arg) { ; CHECK-LABEL: define i1 @umin_not_used( ; CHECK-SAME: i32 [[ARG:%.*]]) { +; CHECK-NEXT:[[ICMP:%.*]] = icmp slt i32 [[ARG]], 0 ; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3 ; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80) ; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3 -; CHECK-NEXT:ret i1 false +; CHECK-NEXT:ret i1 [[ICMP]] ; %icmp = icmp slt i32 %arg, 0 %shl = shl nuw nsw i32 %arg, 3 @@ -38,12 +39,13 @@ define i1 @umin_poison_is_UB_via_call(i32 %arg) { define i1 @umin_poison_call_before_UB(i32 %arg) { ; CHECK-LABEL: define i1 @umin_poison_call_before_UB( ; CHECK-SAME: i32 [[ARG:%.*]]) { +; CHECK-NEXT:[[ICMP:%.*]] = icmp slt i32 [[ARG]], 0 ; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3 ; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80) ; CHECK-NEXT:call void @fn() ; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]]) ; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3 -; CHECK-NEXT:ret i1 false +; CHECK-NEXT:ret i1 [[ICMP]] ; %icmp = icmp slt i32 %arg, 0 %shl = shl nuw nsw i32 %arg, 3 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78621 (PR #80260)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80260 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 024f45e - [clang-format] Simplify the AfterPlacementOperator option (#79796)
Author: Owen Pan Date: 2024-02-06T16:07:18-08:00 New Revision: 024f45e9ed23da66802c49847b82151dfdb70766 URL: https://github.com/llvm/llvm-project/commit/024f45e9ed23da66802c49847b82151dfdb70766 DIFF: https://github.com/llvm/llvm-project/commit/024f45e9ed23da66802c49847b82151dfdb70766.diff LOG: [clang-format] Simplify the AfterPlacementOperator option (#79796) Change AfterPlacementOperator to a boolean and deprecate SBPO_Never, which meant never inserting a space except when after new/delete. Fixes #78892. (cherry picked from commit 908fd09a13b2e89a52282478544f7f70cf0a887f) Added: Modified: clang/docs/ClangFormatStyleOptions.rst clang/include/clang/Format/Format.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 4dc0de3a90f26..0b887288fe2cb 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -5277,15 +5277,9 @@ the configuration (without a prefix: ``Auto``). Possible values: * ``SBPO_Never`` (in configuration: ``Never``) -Never put a space before opening parentheses. - -.. code-block:: c++ - - void f() { - if(true) { - f(); - } - } +This is **deprecated** and replaced by ``Custom`` below, with all +``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to +``false``. * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``) Put a space before opening parentheses only after control statement @@ -5425,32 +5419,14 @@ the configuration (without a prefix: ``Auto``). void operator++ (int a);vs.void operator++(int a); object.operator++ (10);object.operator++(10); - * ``AfterPlacementOperatorStyle AfterPlacementOperator`` :versionbadge:`clang-format 18` - -Defines in which cases to put a space between ``new/delete`` operators -and opening parentheses. - -Possible values: - -* ``APO_Never`` (in configuration: ``Never``) - Remove space after ``new/delete`` operators and before ``(``. - - .. code-block:: c++ - - new(buf) T; - delete(buf) T; - -* ``APO_Always`` (in configuration: ``Always``) - Always add space after ``new/delete`` operators and before ``(``. + * ``bool AfterPlacementOperator`` If ``true``, put a space between operator ``new``/``delete`` and opening +parenthesis. - .. code-block:: c++ - - new (buf) T; - delete (buf) T; - -* ``APO_Leave`` (in configuration: ``Leave``) - Leave placement ``new/delete`` expressions as they are. +.. code-block:: c++ + true: false: + new (buf) T;vs.new(buf) T; + delete (buf) T;delete(buf) T; * ``bool AfterRequiresInClause`` If ``true``, put space between requires keyword in a requires clause and opening parentheses, if there is one. diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index bc9eecd42f9eb..efcb4e1d87ea4 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -4157,14 +4157,9 @@ struct FormatStyle { /// Different ways to put a space before opening parentheses. enum SpaceBeforeParensStyle : int8_t { -/// Never put a space before opening parentheses. -/// \code -///void f() { -/// if(true) { -///f(); -/// } -///} -/// \endcode +/// This is **deprecated** and replaced by ``Custom`` below, with all +/// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to +/// ``false``. SBPO_Never, /// Put a space before opening parentheses only after control statement /// keywords (``for/if/while...``). @@ -4273,28 +4268,14 @@ struct FormatStyle { ///object.operator++ (10);object.operator++(10); /// \endcode bool AfterOverloadedOperator; -/// Styles for adding spacing between ``new/delete`` operators and opening -/// parentheses. -enum AfterPlacementOperatorStyle : int8_t { - /// Remove space after ``new/delete`` operators and before ``(``. - /// \code - ///new(buf) T; - ///delete(buf) T; - /// \endcode - APO_Never, - /// Always add space after ``new/delete`` operators and before ``(``. - /// \code - ///new (buf) T; - ///delete (buf) T; - /// \endcode - APO_Always, - /// Leave placement ``new/delete`` expressions as they are. - APO_Leave, -}; -/// Defines in which cases to put a space between ``new/delete`` operators -/// and opening par
[llvm-branch-commits] [clang] PR for llvm/llvm-project#78892 (PR #80259)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/80259 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits