[llvm-branch-commits] [clang] 95fa0be - [clang-format] Correctly identify token-pasted record names (#106484)
Author: Owen Pan Date: 2024-09-01T10:43:34Z New Revision: 95fa0bee9314a878b3a58d748998c3b3ef42bd75 URL: https://github.com/llvm/llvm-project/commit/95fa0bee9314a878b3a58d748998c3b3ef42bd75 DIFF: https://github.com/llvm/llvm-project/commit/95fa0bee9314a878b3a58d748998c3b3ef42bd75.diff LOG: [clang-format] Correctly identify token-pasted record names (#106484) See https://github.com/llvm/llvm-project/pull/89706#issuecomment-2315549955. (cherry picked from commit 7579787e05966f21684dd4b4a15b9deac13d09e1) Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 53ddb710d2143b..7f5d157ae95891 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -4016,6 +4016,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } break; case tok::coloncolon: +case tok::hashhash: break; default: if (!JSPastExtendsOrImplements && !ClassName && diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 81e2628f28e583..f0533c92f6538c 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -3208,6 +3208,16 @@ TEST_F(TokenAnnotatorTest, BraceKind) { ASSERT_EQ(Tokens.size(), 11u) << Tokens; EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_ClassLBrace); EXPECT_BRACE_KIND(Tokens[7], BK_Block); + EXPECT_TOKEN(Tokens[8], tok::r_brace, TT_ClassRBrace); + EXPECT_BRACE_KIND(Tokens[8], BK_Block); + + Tokens = annotate("#define FOO(X) \\\n" +" struct X##_tag_ {};"); + ASSERT_EQ(Tokens.size(), 14u) << Tokens; + EXPECT_TOKEN(Tokens[10], tok::l_brace, TT_StructLBrace); + EXPECT_BRACE_KIND(Tokens[10], BK_Block); + EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace); + EXPECT_BRACE_KIND(Tokens[11], BK_Block); } TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { ___ 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/19.x: [clang-format] Correctly identify token-pasted record names (#106484) (PR #106900)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/106900 ___ 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/19.x: Win release packaging: Don't try to use rpmalloc for 32-bit x86 (#106969) (PR #106985)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/106985 >From d9cb501ec0012de5d4e1c6310df55f4e8af011a9 Mon Sep 17 00:00:00 2001 From: Hans Date: Mon, 2 Sep 2024 15:04:13 +0200 Subject: [PATCH] Win release packaging: Don't try to use rpmalloc for 32-bit x86 (#106969) because that doesn't work (results in `LINK : error LNK2001: unresolved external symbol malloc`). Based on the title of #91862 it was only intended for use in 64-bit builds. (cherry picked from commit ef26afcb88dcb5f2de79bfc3cf88a8ea10f230ec) --- llvm/utils/release/build_llvm_release.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/utils/release/build_llvm_release.bat b/llvm/utils/release/build_llvm_release.bat index 64ae2d41ab2b02..3508748c1d5404 100755 --- a/llvm/utils/release/build_llvm_release.bat +++ b/llvm/utils/release/build_llvm_release.bat @@ -193,6 +193,7 @@ REM Stage0 binaries directory; used in stage1. set "stage0_bin_dir=%build_dir%/build32_stage0/bin" set cmake_flags=^ %common_cmake_flags% ^ + -DLLVM_ENABLE_RPMALLOC=OFF ^ -DLLDB_TEST_COMPILER=%stage0_bin_dir%/clang.exe ^ -DPYTHON_HOME=%PYTHONHOME% ^ -DPython3_ROOT_DIR=%PYTHONHOME% ^ ___ 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/19.x: [clang-format] Correctly identify token-pasted record names (#106484) (PR #106900)
github-actions[bot] wrote: @owenca (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/106900 ___ 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] d9cb501 - Win release packaging: Don't try to use rpmalloc for 32-bit x86 (#106969)
Author: Hans Date: 2024-09-03T09:02:01+02:00 New Revision: d9cb501ec0012de5d4e1c6310df55f4e8af011a9 URL: https://github.com/llvm/llvm-project/commit/d9cb501ec0012de5d4e1c6310df55f4e8af011a9 DIFF: https://github.com/llvm/llvm-project/commit/d9cb501ec0012de5d4e1c6310df55f4e8af011a9.diff LOG: Win release packaging: Don't try to use rpmalloc for 32-bit x86 (#106969) because that doesn't work (results in `LINK : error LNK2001: unresolved external symbol malloc`). Based on the title of #91862 it was only intended for use in 64-bit builds. (cherry picked from commit ef26afcb88dcb5f2de79bfc3cf88a8ea10f230ec) Added: Modified: llvm/utils/release/build_llvm_release.bat Removed: diff --git a/llvm/utils/release/build_llvm_release.bat b/llvm/utils/release/build_llvm_release.bat index 64ae2d41ab2b02..3508748c1d5404 100755 --- a/llvm/utils/release/build_llvm_release.bat +++ b/llvm/utils/release/build_llvm_release.bat @@ -193,6 +193,7 @@ REM Stage0 binaries directory; used in stage1. set "stage0_bin_dir=%build_dir%/build32_stage0/bin" set cmake_flags=^ %common_cmake_flags% ^ + -DLLVM_ENABLE_RPMALLOC=OFF ^ -DLLDB_TEST_COMPILER=%stage0_bin_dir%/clang.exe ^ -DPYTHON_HOME=%PYTHONHOME% ^ -DPython3_ROOT_DIR=%PYTHONHOME% ^ ___ 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/19.x: Win release packaging: Don't try to use rpmalloc for 32-bit x86 (#106969) (PR #106985)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/106985 ___ 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/19.x: Win release packaging: Don't try to use rpmalloc for 32-bit x86 (#106969) (PR #106985)
github-actions[bot] wrote: @zmodem (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/106985 ___ 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-tools-extra] release/19.x: [clangd] Update TidyFastChecks for release/19.x (#106354) (PR #106989)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/106989 >From 9b6180ed2ecbbb54f26caa78082e7b955a634117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kadir=20=C3=A7etinkaya?= Date: Mon, 2 Sep 2024 15:25:26 +0200 Subject: [PATCH] [clangd] Update TidyFastChecks for release/19.x (#106354) Run for clang-tidy checks available in release/19.x branch. Some notable findings: - altera-id-dependent-backward-branch, stays slow with 13%. - misc-const-correctness become faster, going from 261% to 67%, but still above 8% threshold. - misc-header-include-cycle is a new SLOW check with 10% runtime implications - readability-container-size-empty went from 16% to 13%, still SLOW. (cherry picked from commit b47d7ce8121b1cb1923e879d58eaa1d63aeaaae2) --- clang-tools-extra/clangd/TidyFastChecks.inc | 669 +++- 1 file changed, 367 insertions(+), 302 deletions(-) diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc index 9050ce16127ff4..de1a025602fa9c 100644 --- a/clang-tools-extra/clangd/TidyFastChecks.inc +++ b/clang-tools-extra/clangd/TidyFastChecks.inc @@ -7,370 +7,435 @@ #define SLOW(CHECK, DELTA) #endif -FAST(abseil-cleanup-ctad, -1.0) +FAST(abseil-cleanup-ctad, -2.0) FAST(abseil-duration-addition, 0.0) -FAST(abseil-duration-comparison, 1.0) -FAST(abseil-duration-conversion-cast, 3.0) -FAST(abseil-duration-division, -0.0) -FAST(abseil-duration-factory-float, 1.0) -FAST(abseil-duration-factory-scale, -0.0) -FAST(abseil-duration-subtraction, 1.0) -FAST(abseil-duration-unnecessary-conversion, 4.0) -FAST(abseil-faster-strsplit-delimiter, 2.0) -FAST(abseil-no-internal-dependencies, -1.0) -FAST(abseil-no-namespace, -1.0) -FAST(abseil-redundant-strcat-calls, 2.0) -FAST(abseil-str-cat-append, 1.0) -FAST(abseil-string-find-startswith, 1.0) -FAST(abseil-string-find-str-contains, 1.0) -FAST(abseil-time-comparison, -0.0) -FAST(abseil-time-subtraction, 0.0) +FAST(abseil-duration-comparison, -1.0) +FAST(abseil-duration-conversion-cast, -1.0) +FAST(abseil-duration-division, 0.0) +FAST(abseil-duration-factory-float, 2.0) +FAST(abseil-duration-factory-scale, 1.0) +FAST(abseil-duration-subtraction, -1.0) +FAST(abseil-duration-unnecessary-conversion, -0.0) +FAST(abseil-faster-strsplit-delimiter, 3.0) +FAST(abseil-no-internal-dependencies, 1.0) +FAST(abseil-no-namespace, -0.0) +FAST(abseil-redundant-strcat-calls, 1.0) +FAST(abseil-str-cat-append, -0.0) +FAST(abseil-string-find-startswith, -1.0) +FAST(abseil-string-find-str-contains, 4.0) +FAST(abseil-time-comparison, -1.0) +FAST(abseil-time-subtraction, 1.0) FAST(abseil-upgrade-duration-conversions, 2.0) SLOW(altera-id-dependent-backward-branch, 13.0) -FAST(altera-kernel-name-restriction, -1.0) -FAST(altera-single-work-item-barrier, -1.0) -FAST(altera-struct-pack-align, -1.0) +FAST(altera-kernel-name-restriction, 4.0) +FAST(altera-single-work-item-barrier, 1.0) +FAST(altera-struct-pack-align, -0.0) FAST(altera-unroll-loops, 2.0) -FAST(android-cloexec-accept, -1.0) -FAST(android-cloexec-accept4, 3.0) -FAST(android-cloexec-creat, 0.0) -FAST(android-cloexec-dup, 3.0) -FAST(android-cloexec-epoll-create, -2.0) -FAST(android-cloexec-epoll-create1, -1.0) -FAST(android-cloexec-fopen, -0.0) -FAST(android-cloexec-inotify-init, 1.0) -FAST(android-cloexec-inotify-init1, 2.0) -FAST(android-cloexec-memfd-create, 2.0) -FAST(android-cloexec-open, -1.0) -FAST(android-cloexec-pipe, -1.0) +FAST(android-cloexec-accept, 0.0) +FAST(android-cloexec-accept4, 1.0) +FAST(android-cloexec-creat, 1.0) +FAST(android-cloexec-dup, 0.0) +FAST(android-cloexec-epoll-create, 2.0) +FAST(android-cloexec-epoll-create1, 0.0) +FAST(android-cloexec-fopen, -1.0) +FAST(android-cloexec-inotify-init, 2.0) +FAST(android-cloexec-inotify-init1, -0.0) +FAST(android-cloexec-memfd-create, -1.0) +FAST(android-cloexec-open, 1.0) +FAST(android-cloexec-pipe, -0.0) FAST(android-cloexec-pipe2, 0.0) FAST(android-cloexec-socket, 1.0) -FAST(android-comparison-in-temp-failure-retry, 0.0) -FAST(boost-use-to-string, 1.0) -FAST(bugprone-argument-comment, 2.0) +FAST(android-comparison-in-temp-failure-retry, 1.0) +FAST(boost-use-ranges, 2.0) +FAST(boost-use-to-string, 2.0) +FAST(bugprone-argument-comment, 4.0) FAST(bugprone-assert-side-effect, 1.0) -FAST(bugprone-assignment-in-if-condition, -0.0) -FAST(bugprone-bad-signal-to-kill-thread, -1.0) +FAST(bugprone-assignment-in-if-condition, 2.0) +FAST(bugprone-bad-signal-to-kill-thread, 1.0) FAST(bugprone-bool-pointer-implicit-conversion, 0.0) -FAST(bugprone-branch-clone, -0.0) +FAST(bugprone-branch-clone, 1.0) +FAST(bugprone-casting-through-void, 1.0) +FAST(bugprone-chained-comparison, 1.0) +FAST(bugprone-compare-pointer-to-member-virtual-function, -0.0) FAST(bugprone-copy-constructor-init, 1.0) -FAST(bugprone-dangling-handle, 0.0) -FAST(bugprone-dynamic-static-initializers, 1.0) +FAST(bugprone-crtp-constructor-accessibility, 0.0) +FAST(bugprone-dangling-handle, -0.0) +FAST(bugprone-dynamic-static-initializ
[llvm-branch-commits] [clang-tools-extra] release/19.x: [clangd] Update TidyFastChecks for release/19.x (#106354) (PR #106989)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/106989 ___ 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-tools-extra] 9b6180e - [clangd] Update TidyFastChecks for release/19.x (#106354)
Author: kadir çetinkaya Date: 2024-09-03T09:03:13+02:00 New Revision: 9b6180ed2ecbbb54f26caa78082e7b955a634117 URL: https://github.com/llvm/llvm-project/commit/9b6180ed2ecbbb54f26caa78082e7b955a634117 DIFF: https://github.com/llvm/llvm-project/commit/9b6180ed2ecbbb54f26caa78082e7b955a634117.diff LOG: [clangd] Update TidyFastChecks for release/19.x (#106354) Run for clang-tidy checks available in release/19.x branch. Some notable findings: - altera-id-dependent-backward-branch, stays slow with 13%. - misc-const-correctness become faster, going from 261% to 67%, but still above 8% threshold. - misc-header-include-cycle is a new SLOW check with 10% runtime implications - readability-container-size-empty went from 16% to 13%, still SLOW. (cherry picked from commit b47d7ce8121b1cb1923e879d58eaa1d63aeaaae2) Added: Modified: clang-tools-extra/clangd/TidyFastChecks.inc Removed: diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc index 9050ce16127ff4..de1a025602fa9c 100644 --- a/clang-tools-extra/clangd/TidyFastChecks.inc +++ b/clang-tools-extra/clangd/TidyFastChecks.inc @@ -7,370 +7,435 @@ #define SLOW(CHECK, DELTA) #endif -FAST(abseil-cleanup-ctad, -1.0) +FAST(abseil-cleanup-ctad, -2.0) FAST(abseil-duration-addition, 0.0) -FAST(abseil-duration-comparison, 1.0) -FAST(abseil-duration-conversion-cast, 3.0) -FAST(abseil-duration-division, -0.0) -FAST(abseil-duration-factory-float, 1.0) -FAST(abseil-duration-factory-scale, -0.0) -FAST(abseil-duration-subtraction, 1.0) -FAST(abseil-duration-unnecessary-conversion, 4.0) -FAST(abseil-faster-strsplit-delimiter, 2.0) -FAST(abseil-no-internal-dependencies, -1.0) -FAST(abseil-no-namespace, -1.0) -FAST(abseil-redundant-strcat-calls, 2.0) -FAST(abseil-str-cat-append, 1.0) -FAST(abseil-string-find-startswith, 1.0) -FAST(abseil-string-find-str-contains, 1.0) -FAST(abseil-time-comparison, -0.0) -FAST(abseil-time-subtraction, 0.0) +FAST(abseil-duration-comparison, -1.0) +FAST(abseil-duration-conversion-cast, -1.0) +FAST(abseil-duration-division, 0.0) +FAST(abseil-duration-factory-float, 2.0) +FAST(abseil-duration-factory-scale, 1.0) +FAST(abseil-duration-subtraction, -1.0) +FAST(abseil-duration-unnecessary-conversion, -0.0) +FAST(abseil-faster-strsplit-delimiter, 3.0) +FAST(abseil-no-internal-dependencies, 1.0) +FAST(abseil-no-namespace, -0.0) +FAST(abseil-redundant-strcat-calls, 1.0) +FAST(abseil-str-cat-append, -0.0) +FAST(abseil-string-find-startswith, -1.0) +FAST(abseil-string-find-str-contains, 4.0) +FAST(abseil-time-comparison, -1.0) +FAST(abseil-time-subtraction, 1.0) FAST(abseil-upgrade-duration-conversions, 2.0) SLOW(altera-id-dependent-backward-branch, 13.0) -FAST(altera-kernel-name-restriction, -1.0) -FAST(altera-single-work-item-barrier, -1.0) -FAST(altera-struct-pack-align, -1.0) +FAST(altera-kernel-name-restriction, 4.0) +FAST(altera-single-work-item-barrier, 1.0) +FAST(altera-struct-pack-align, -0.0) FAST(altera-unroll-loops, 2.0) -FAST(android-cloexec-accept, -1.0) -FAST(android-cloexec-accept4, 3.0) -FAST(android-cloexec-creat, 0.0) -FAST(android-cloexec-dup, 3.0) -FAST(android-cloexec-epoll-create, -2.0) -FAST(android-cloexec-epoll-create1, -1.0) -FAST(android-cloexec-fopen, -0.0) -FAST(android-cloexec-inotify-init, 1.0) -FAST(android-cloexec-inotify-init1, 2.0) -FAST(android-cloexec-memfd-create, 2.0) -FAST(android-cloexec-open, -1.0) -FAST(android-cloexec-pipe, -1.0) +FAST(android-cloexec-accept, 0.0) +FAST(android-cloexec-accept4, 1.0) +FAST(android-cloexec-creat, 1.0) +FAST(android-cloexec-dup, 0.0) +FAST(android-cloexec-epoll-create, 2.0) +FAST(android-cloexec-epoll-create1, 0.0) +FAST(android-cloexec-fopen, -1.0) +FAST(android-cloexec-inotify-init, 2.0) +FAST(android-cloexec-inotify-init1, -0.0) +FAST(android-cloexec-memfd-create, -1.0) +FAST(android-cloexec-open, 1.0) +FAST(android-cloexec-pipe, -0.0) FAST(android-cloexec-pipe2, 0.0) FAST(android-cloexec-socket, 1.0) -FAST(android-comparison-in-temp-failure-retry, 0.0) -FAST(boost-use-to-string, 1.0) -FAST(bugprone-argument-comment, 2.0) +FAST(android-comparison-in-temp-failure-retry, 1.0) +FAST(boost-use-ranges, 2.0) +FAST(boost-use-to-string, 2.0) +FAST(bugprone-argument-comment, 4.0) FAST(bugprone-assert-side-effect, 1.0) -FAST(bugprone-assignment-in-if-condition, -0.0) -FAST(bugprone-bad-signal-to-kill-thread, -1.0) +FAST(bugprone-assignment-in-if-condition, 2.0) +FAST(bugprone-bad-signal-to-kill-thread, 1.0) FAST(bugprone-bool-pointer-implicit-conversion, 0.0) -FAST(bugprone-branch-clone, -0.0) +FAST(bugprone-branch-clone, 1.0) +FAST(bugprone-casting-through-void, 1.0) +FAST(bugprone-chained-comparison, 1.0) +FAST(bugprone-compare-pointer-to-member-virtual-function, -0.0) FAST(bugprone-copy-constructor-init, 1.0) -FAST(bugprone-dangling-handle, 0.0) -FAST(bugprone-dynamic-static-initializers, 1.0) +FAST(bugprone-crtp-construc
[llvm-branch-commits] [clang-tools-extra] release/19.x: [clangd] Update TidyFastChecks for release/19.x (#106354) (PR #106989)
github-actions[bot] wrote: @kadircet (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/106989 ___ 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] release/19.x: [compiler-rt] Support building runtimes for Windows on arm32 (#101462) (PR #106518)
mstorsjo wrote: In case @vitalybuka doesn't have time to reply here, can @petrhosek ack the backport? https://github.com/llvm/llvm-project/pull/106518 ___ 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] release/19.x: [compiler-rt] Support building runtimes for Windows on arm32 (#101462) (PR #106518)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/106518 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/107058 Backport 0fa78b6c7bd43c2498700a98c47a02cf4fd06388 Requested by: @owenca >From adf3a8b70608648cab831f80f346c6f101f6f034 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Mon, 2 Sep 2024 01:40:13 -0700 Subject: [PATCH] [clang-format] Correctly annotate braces in macro definition (#106662) Fixes #106418. (cherry picked from commit 0fa78b6c7bd43c2498700a98c47a02cf4fd06388) --- clang/lib/Format/UnwrappedLineParser.cpp | 3 +-- clang/unittests/Format/TokenAnnotatorTest.cpp | 5 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7f5d157ae95891..60e65aaa83e9c1 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -609,9 +609,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { ProbablyBracedList = NextTok->isNot(tok::l_square); } - // Cpp macro definition body that is a nonempty braced list or block: + // Cpp macro definition body containing nonempty braced list or block: if (IsCpp && Line->InMacroBody && PrevTok != FormatTok && - !FormatTok->Previous && NextTok->is(tok::eof) && // A statement can end with only `;` (simple statement), a block // closing brace (compound statement), or `:` (label statement). // If PrevTok is a block opening brace, Tok ends an empty block. diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index f0533c92f6538c..db580d70058811 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -3218,6 +3218,11 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[10], BK_Block); EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace); EXPECT_BRACE_KIND(Tokens[11], BK_Block); + + Tokens = annotate("#define MEMBER(NAME) NAME{\"\"}"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit); + EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit); } TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/107058 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
llvmbot wrote: @HazardyKnusperkeks What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/107058 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: None (llvmbot) Changes Backport 0fa78b6c7bd43c2498700a98c47a02cf4fd06388 Requested by: @owenca --- Full diff: https://github.com/llvm/llvm-project/pull/107058.diff 2 Files Affected: - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+1-2) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+5) ``diff diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7f5d157ae95891..60e65aaa83e9c1 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -609,9 +609,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { ProbablyBracedList = NextTok->isNot(tok::l_square); } - // Cpp macro definition body that is a nonempty braced list or block: + // Cpp macro definition body containing nonempty braced list or block: if (IsCpp && Line->InMacroBody && PrevTok != FormatTok && - !FormatTok->Previous && NextTok->is(tok::eof) && // A statement can end with only `;` (simple statement), a block // closing brace (compound statement), or `:` (label statement). // If PrevTok is a block opening brace, Tok ends an empty block. diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index f0533c92f6538c..db580d70058811 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -3218,6 +3218,11 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[10], BK_Block); EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace); EXPECT_BRACE_KIND(Tokens[11], BK_Block); + + Tokens = annotate("#define MEMBER(NAME) NAME{\"\"}"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit); + EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit); } TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { `` https://github.com/llvm/llvm-project/pull/107058 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/107058 ___ 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/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/107060 ___ 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/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/107060 Backport 25f87f2d703178bb4bc13a62cb3df001b186cba2 Requested by: @jmorse >From e832641a6370eebfd0d57ed4c4224dc1842bb0c8 Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Mon, 2 Sep 2024 11:56:40 +0100 Subject: [PATCH] [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When serialising to textual IR, there can be constant Values referred to by DbgRecords that don't appear anywhere else, and have types hidden even deeper in side them. Enumerate these when enumerating all types. Test by Mikael Holmén. (cherry picked from commit 25f87f2d703178bb4bc13a62cb3df001b186cba2) --- llvm/lib/IR/DebugProgramInstruction.cpp | 5 +- llvm/lib/IR/TypeFinder.cpp| 14 + .../DebugInfo/type-finder-w-dbg-records.ll| 51 +++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 llvm/test/DebugInfo/type-finder-w-dbg-records.ll diff --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp index 362d467beeb11b..5d2189b54204fb 100644 --- a/llvm/lib/IR/DebugProgramInstruction.cpp +++ b/llvm/lib/IR/DebugProgramInstruction.cpp @@ -473,11 +473,12 @@ DbgLabelRecord::createDebugIntrinsic(Module *M, Value *DbgVariableRecord::getAddress() const { auto *MD = getRawAddress(); - if (auto *V = dyn_cast(MD)) + if (auto *V = dyn_cast_or_null(MD)) return V->getValue(); // When the value goes to null, it gets replaced by an empty MDNode. - assert(!cast(MD)->getNumOperands() && "Expected an empty MDNode"); + assert(!MD || + !cast(MD)->getNumOperands() && "Expected an empty MDNode"); return nullptr; } diff --git a/llvm/lib/IR/TypeFinder.cpp b/llvm/lib/IR/TypeFinder.cpp index 003155a4af4877..963f4b4806e1f9 100644 --- a/llvm/lib/IR/TypeFinder.cpp +++ b/llvm/lib/IR/TypeFinder.cpp @@ -88,6 +88,20 @@ void TypeFinder::run(const Module &M, bool onlyNamed) { for (const auto &MD : MDForInst) incorporateMDNode(MD.second); MDForInst.clear(); + +// Incorporate types hiding in variable-location information. +for (const auto &Dbg : I.getDbgRecordRange()) { + // Pick out records that have Values. + if (const DbgVariableRecord *DVI = + dyn_cast(&Dbg)) { +for (Value *V : DVI->location_ops()) + incorporateValue(V); +if (DVI->isDbgAssign()) { + if (Value *Addr = DVI->getAddress()) +incorporateValue(Addr); +} + } +} } } diff --git a/llvm/test/DebugInfo/type-finder-w-dbg-records.ll b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll new file mode 100644 index 00..8259b4a9f1c3a5 --- /dev/null +++ b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll @@ -0,0 +1,51 @@ +; RUN: opt --passes=verify %s -o - -S | FileCheck %s + +;; Test that the type definitions are discovered when serialising to LLVM-IR, +;; even if they're only present inside a DbgRecord, and thus not normally +;; visible. + +; CHECK: %union.anon = type { %struct.a } +; CHECK: %struct.a = type { i32 } +; CHECK: %union.anon2 = type { %struct.a2 } +; CHECK: %struct.a2 = type { i32 } + +; ModuleID = 'bbi-98372.ll' +source_filename = "bbi-98372.ll" + +%union.anon = type { %struct.a } +%struct.a = type { i32 } +%union.anon2 = type { %struct.a2 } +%struct.a2 = type { i32 } + +@d = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 +@e = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 + +define void @f() { +entry: +#dbg_value(ptr getelementptr inbounds ([1 x %union.anon], ptr @d, i32 0, i32 3), !7, !DIExpression(), !14) +#dbg_assign(ptr null, !7, !DIExpression(), !16, ptr getelementptr inbounds ([1 x %union.anon2], ptr @e, i32 0, i32 3), !17, !14) + ret void, !dbg !15 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "foo.c", directory: "/bar") +!2 = !{i32 7, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = !{i32 1, !"wchar_size", i32 1} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"clang"} +!7 = !DILocalVariable(name: "f", scope: !8, file: !1, line: 8, type: !12) +!8 = distinct !DISubprogram(name: "e", scope: !1, file: !1, line: 8, type: !9, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) +!9 = !DISubroutineType(types: !10) +!10 = !{null} +!11 = !{!7} +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 16) +!13 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_
[llvm-branch-commits] [llvm] release/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
llvmbot wrote: @OCHyams What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/107060 ___ 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/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
llvmbot wrote: @llvm/pr-subscribers-llvm-ir Author: None (llvmbot) Changes Backport 25f87f2d703178bb4bc13a62cb3df001b186cba2 Requested by: @jmorse --- Full diff: https://github.com/llvm/llvm-project/pull/107060.diff 3 Files Affected: - (modified) llvm/lib/IR/DebugProgramInstruction.cpp (+3-2) - (modified) llvm/lib/IR/TypeFinder.cpp (+14) - (added) llvm/test/DebugInfo/type-finder-w-dbg-records.ll (+51) ``diff diff --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp index 362d467beeb11b..5d2189b54204fb 100644 --- a/llvm/lib/IR/DebugProgramInstruction.cpp +++ b/llvm/lib/IR/DebugProgramInstruction.cpp @@ -473,11 +473,12 @@ DbgLabelRecord::createDebugIntrinsic(Module *M, Value *DbgVariableRecord::getAddress() const { auto *MD = getRawAddress(); - if (auto *V = dyn_cast(MD)) + if (auto *V = dyn_cast_or_null(MD)) return V->getValue(); // When the value goes to null, it gets replaced by an empty MDNode. - assert(!cast(MD)->getNumOperands() && "Expected an empty MDNode"); + assert(!MD || + !cast(MD)->getNumOperands() && "Expected an empty MDNode"); return nullptr; } diff --git a/llvm/lib/IR/TypeFinder.cpp b/llvm/lib/IR/TypeFinder.cpp index 003155a4af4877..963f4b4806e1f9 100644 --- a/llvm/lib/IR/TypeFinder.cpp +++ b/llvm/lib/IR/TypeFinder.cpp @@ -88,6 +88,20 @@ void TypeFinder::run(const Module &M, bool onlyNamed) { for (const auto &MD : MDForInst) incorporateMDNode(MD.second); MDForInst.clear(); + +// Incorporate types hiding in variable-location information. +for (const auto &Dbg : I.getDbgRecordRange()) { + // Pick out records that have Values. + if (const DbgVariableRecord *DVI = + dyn_cast(&Dbg)) { +for (Value *V : DVI->location_ops()) + incorporateValue(V); +if (DVI->isDbgAssign()) { + if (Value *Addr = DVI->getAddress()) +incorporateValue(Addr); +} + } +} } } diff --git a/llvm/test/DebugInfo/type-finder-w-dbg-records.ll b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll new file mode 100644 index 00..8259b4a9f1c3a5 --- /dev/null +++ b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll @@ -0,0 +1,51 @@ +; RUN: opt --passes=verify %s -o - -S | FileCheck %s + +;; Test that the type definitions are discovered when serialising to LLVM-IR, +;; even if they're only present inside a DbgRecord, and thus not normally +;; visible. + +; CHECK: %union.anon = type { %struct.a } +; CHECK: %struct.a = type { i32 } +; CHECK: %union.anon2 = type { %struct.a2 } +; CHECK: %struct.a2 = type { i32 } + +; ModuleID = 'bbi-98372.ll' +source_filename = "bbi-98372.ll" + +%union.anon = type { %struct.a } +%struct.a = type { i32 } +%union.anon2 = type { %struct.a2 } +%struct.a2 = type { i32 } + +@d = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 +@e = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 + +define void @f() { +entry: +#dbg_value(ptr getelementptr inbounds ([1 x %union.anon], ptr @d, i32 0, i32 3), !7, !DIExpression(), !14) +#dbg_assign(ptr null, !7, !DIExpression(), !16, ptr getelementptr inbounds ([1 x %union.anon2], ptr @e, i32 0, i32 3), !17, !14) + ret void, !dbg !15 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "foo.c", directory: "/bar") +!2 = !{i32 7, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = !{i32 1, !"wchar_size", i32 1} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"clang"} +!7 = !DILocalVariable(name: "f", scope: !8, file: !1, line: 8, type: !12) +!8 = distinct !DISubprogram(name: "e", scope: !1, file: !1, line: 8, type: !9, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) +!9 = !DISubroutineType(types: !10) +!10 = !{null} +!11 = !{!7} +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 16) +!13 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed) +!14 = !DILocation(line: 0, scope: !8) +!15 = !DILocation(line: 8, column: 28, scope: !8) +!16 = distinct !DIAssignID() +!17 = !DIExpression() `` https://github.com/llvm/llvm-project/pull/107060 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)
Patryk27 wrote: Ah, I've just checked and I can't set miilestones, though :-// https://github.com/llvm/llvm-project/pull/106729 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)
tru wrote: > Ah, I've just checked and I can't set miilestones, though :-// I can do it for you - what's the issue or PR? https://github.com/llvm/llvm-project/pull/106729 ___ 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] [X86] Avoid generating nested CALLSEQ for TLS pointer function arguments (PR #106965)
@@ -0,0 +1,17 @@ +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" ritter-x2a wrote: Should I also autogenerate check labels for the test or just pipe the generated code to FileCheck? My intention with the test is only to validate that the MachineVerifier does not fail. https://github.com/llvm/llvm-project/pull/106965 ___ 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/19.x: [SLP]Fix PR104422: Wrong value truncation (PR #104747)
nikic wrote: @alexey-bataev Do you think this should be backported? https://github.com/llvm/llvm-project/pull/104747 ___ 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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671, #106723) (PR #106952)
https://github.com/jmorse approved this pull request. As with the previous rev, LGTM as a fix for an edge case. This situation has taken many months to expose, so I don't think it urgently needs to go into the imminent release, a point release should be fine. https://github.com/llvm/llvm-project/pull/106952 ___ 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/19.x: [SLP]Fix PR104422: Wrong value truncation (PR #104747)
alexey-bataev wrote: Yes, if possible https://github.com/llvm/llvm-project/pull/104747 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)
Patryk27 wrote: Thanks! We need both https://github.com/llvm/llvm-project/commit/86a60e7f1e8f361f84ccb6e656e848dd4fbaa713 and https://github.com/llvm/llvm-project/pull/106739/commits/af15b6dff67e7aa1997ae0294e0bc01a3fe5a438; the original issue was https://github.com/llvm/llvm-project/pull/102936. https://github.com/llvm/llvm-project/pull/106729 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)
aykevl wrote: Made a new issue, let's see whether this one works: https://github.com/llvm/llvm-project/issues/107081 https://github.com/llvm/llvm-project/pull/106729 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)
https://github.com/aykevl closed https://github.com/llvm/llvm-project/pull/106729 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)
aykevl wrote: And closing this one, because this one doesn't include the followup fix. https://github.com/llvm/llvm-project/pull/106729 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/107082 ___ 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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/107082 Backport 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713 Requested by: @aykevl >From 415672314bf3b8e3d293609fce0335e79bbe862c Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec Date: Fri, 30 Aug 2024 15:25:54 +0200 Subject: [PATCH] [AVR] Fix parsing & emitting relative jumps (#106722) Ever since 6859685a87ad093d60c8bed60b116143c0a684c7 (or, precisely, 84428dafc0941e3a31303fa1b286835ab2b8e234) relative jumps emitted by the AVR codegen are off by two bytes - this pull request fixes it. ## Abstract As compared to absolute jumps, relative jumps - such as rjmp, rcall or brsh - have an implied `pc+2` behavior; that is, `jmp 100` is `pc = 100`, but `rjmp 100` gets understood as `pc = pc + 100 + 2`. This is not reflected in the AVR codegen: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L89 ... which always emits relative jumps that are two bytes too far - or rather it _would_ emit such jumps if not for this check: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L517 ... which causes most of the relative jumps to be actually resolved late, by the linker, which applies the offsetting logic on its own, hiding the issue within LLVM. [Some time ago](https://github.com/llvm/llvm-project/commit/697a162fa63df328ec9ca334636c5e85390b2bf0) we've had a similar "jumps are off" problem that got solved by touching `shouldForceRelocation()`, but I think that has worked only by accident. It's exploited the fact that absolute vs relative jumps in the parsed assembly can be distinguished through a "side channel" check relying on the existence of labels (i.e. absolute jumps happen to named labels, but relative jumps are anonymous, so to say). This was an alright idea back then, but it got broken by 6859685a87ad093d60c8bed60b116143c0a684c7. I propose a different approach: - when emitting relative jumps, offset them by `-2` (well, `-1`, strictly speaking, because those instructions rely on right-shifted offset), - when parsing relative jumps, treat `.` as `+2` and read `rjmp .+1234` as `rjmp (1234 + 2)`. This approach seems to be sound and now we generate the same assembly as avr-gcc, which can be confirmed with: ```cpp // avr-gcc test.c -O3 && avr-objdump -d a.out int main() { asm( " foo:\n\t" "rjmp .+2\n\t" "rjmp .-2\n\t" "rjmp foo\n\t" "rjmp .+8\n\t" "rjmp end\n\t" "rjmp .+0\n\t" " end:\n\t" "rjmp .-4\n\t" "rjmp .-6\n\t" " x:\n\t" "rjmp x\n\t" ".short 0xc00f\n\t" ); } ``` avr-gcc is also how I got the opcodes for all new tests like `inst-brbc.s`, so we should be good. (cherry picked from commit 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713) --- .../lib/Target/AVR/AsmParser/AVRAsmParser.cpp | 15 +- .../Target/AVR/MCTargetDesc/AVRAsmBackend.cpp | 12 +- llvm/test/CodeGen/AVR/jmp.ll | 25 ++ llvm/test/MC/AVR/inst-brbc.s | 23 +- llvm/test/MC/AVR/inst-brbs.s | 22 +- llvm/test/MC/AVR/inst-brcc.s | 28 ++ llvm/test/MC/AVR/inst-brcs.s | 28 ++ llvm/test/MC/AVR/inst-breq.s | 28 ++ llvm/test/MC/AVR/inst-brge.s | 24 ++ llvm/test/MC/AVR/inst-brhc.s | 24 ++ llvm/test/MC/AVR/inst-brhs.s | 24 ++ llvm/test/MC/AVR/inst-brid.s | 24 ++ llvm/test/MC/AVR/inst-brie.s | 24 ++ llvm/test/MC/AVR/inst-brlo.s | 24 ++ llvm/test/MC/AVR/inst-brlt.s | 24 ++ llvm/test/MC/AVR/inst-brmi.s | 24 ++ llvm/test/MC/AVR/inst-brne.s | 28 ++ llvm/test/MC/AVR/inst-brpl.s | 24 ++ llvm/test/MC/AVR/inst-brsh.s | 24 ++ llvm/test/MC/AVR/inst-brtc.s | 24 ++ llvm/test/MC/AVR/inst-brts.s | 24 ++ llvm/test/MC/AVR/inst-brvc.s | 24 ++ llvm/test/MC/AVR/inst-brvs.s | 24 ++ llvm/test/MC/AVR/inst-family-cond-branch.s| 321 -- llvm/test/MC/AVR/inst-rcall.s | 33 +- llvm/test/MC/AVR/inst-rjmp.s | 69 ++-- 26 files changed, 567 insertions(+), 401 deletions(-) create mode 100644 llvm/test/CodeGen/AVR/jmp.ll create mode 100644 llvm/test/MC/AVR/inst-brcc.s create mode 100644 llvm/test/MC/AVR/inst-brcs.s create mode 100644 llvm/test/MC/AVR/inst-breq.s create mode 100644 llvm/test/MC/AVR/inst-brge.s create mode 100644 llvm/test/MC/AVR/inst-brhc.s create mode 100644 llvm/test/MC/AVR/inst-brhs.s create mode 100644 llvm/test/MC/AVR/inst-brid.s create mode 100644 llvm/test/MC/AVR/inst-brie.s create mode 100644 llvm/test/MC/AVR/inst-brlo.s create mode 100644 llvm/test/MC/AVR/inst-br
[llvm-branch-commits] [llvm] release/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
llvmbot wrote: @llvm/pr-subscribers-mc Author: None (llvmbot) Changes Backport 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713 Requested by: @aykevl --- Patch is 46.04 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/107082.diff 26 Files Affected: - (modified) llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp (+11-4) - (modified) llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp (+5-7) - (added) llvm/test/CodeGen/AVR/jmp.ll (+25) - (modified) llvm/test/MC/AVR/inst-brbc.s (+12-11) - (modified) llvm/test/MC/AVR/inst-brbs.s (+11-11) - (added) llvm/test/MC/AVR/inst-brcc.s (+28) - (added) llvm/test/MC/AVR/inst-brcs.s (+28) - (added) llvm/test/MC/AVR/inst-breq.s (+28) - (added) llvm/test/MC/AVR/inst-brge.s (+24) - (added) llvm/test/MC/AVR/inst-brhc.s (+24) - (added) llvm/test/MC/AVR/inst-brhs.s (+24) - (added) llvm/test/MC/AVR/inst-brid.s (+24) - (added) llvm/test/MC/AVR/inst-brie.s (+24) - (added) llvm/test/MC/AVR/inst-brlo.s (+24) - (added) llvm/test/MC/AVR/inst-brlt.s (+24) - (added) llvm/test/MC/AVR/inst-brmi.s (+24) - (added) llvm/test/MC/AVR/inst-brne.s (+28) - (added) llvm/test/MC/AVR/inst-brpl.s (+24) - (added) llvm/test/MC/AVR/inst-brsh.s (+24) - (added) llvm/test/MC/AVR/inst-brtc.s (+24) - (added) llvm/test/MC/AVR/inst-brts.s (+24) - (added) llvm/test/MC/AVR/inst-brvc.s (+24) - (added) llvm/test/MC/AVR/inst-brvs.s (+24) - (removed) llvm/test/MC/AVR/inst-family-cond-branch.s (-321) - (modified) llvm/test/MC/AVR/inst-rcall.s (+17-16) - (modified) llvm/test/MC/AVR/inst-rjmp.s (+38-31) ``diff diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp index 383dfcc31117c1..c016b2dd91dc67 100644 --- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -72,7 +72,7 @@ class AVRAsmParser : public MCTargetAsmParser { int parseRegisterName(); int parseRegister(bool RestoreOnFailure = false); bool tryParseRegisterOperand(OperandVector &Operands); - bool tryParseExpression(OperandVector &Operands); + bool tryParseExpression(OperandVector &Operands, int64_t offset); bool tryParseRelocExpression(OperandVector &Operands); void eatComma(); @@ -418,7 +418,7 @@ bool AVRAsmParser::tryParseRegisterOperand(OperandVector &Operands) { return false; } -bool AVRAsmParser::tryParseExpression(OperandVector &Operands) { +bool AVRAsmParser::tryParseExpression(OperandVector &Operands, int64_t offset) { SMLoc S = Parser.getTok().getLoc(); if (!tryParseRelocExpression(Operands)) @@ -437,6 +437,11 @@ bool AVRAsmParser::tryParseExpression(OperandVector &Operands) { if (getParser().parseExpression(Expression)) return true; + if (offset) { +Expression = MCBinaryExpr::createAdd( +Expression, MCConstantExpr::create(offset, getContext()), getContext()); + } + SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1); Operands.push_back(AVROperand::CreateImm(Expression, S, E)); return false; @@ -529,8 +534,9 @@ bool AVRAsmParser::parseOperand(OperandVector &Operands, bool maybeReg) { [[fallthrough]]; case AsmToken::LParen: case AsmToken::Integer: +return tryParseExpression(Operands, 0); case AsmToken::Dot: -return tryParseExpression(Operands); +return tryParseExpression(Operands, 2); case AsmToken::Plus: case AsmToken::Minus: { // If the sign preceeds a number, parse the number, @@ -540,7 +546,7 @@ bool AVRAsmParser::parseOperand(OperandVector &Operands, bool maybeReg) { case AsmToken::BigNum: case AsmToken::Identifier: case AsmToken::Real: - if (!tryParseExpression(Operands)) + if (!tryParseExpression(Operands, 0)) return false; break; default: @@ -643,6 +649,7 @@ bool AVRAsmParser::ParseInstruction(ParseInstructionInfo &Info, // These specific operands should be treated as addresses/symbols/labels, // other than registers. bool maybeReg = true; + if (OperandNum == 1) { std::array Insts = {"lds", "adiw", "sbiw", "ldi"}; for (auto Inst : Insts) { diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp index 0d29912bee2646..388d58a82214d1 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp @@ -94,6 +94,9 @@ static void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup, // Rightshifts the value by one. AVR::fixups::adjustBranchTarget(Value); + + // Jumps are relative to the current instruction. + Value -= 1; } /// 22-bit absolute fixup. @@ -513,15 +516,10 @@ bool AVRAsmBackend::shouldForceRelocation(const MCAssembler &Asm, switch ((unsigned)Fixup.getKind()) { default: return Fixup.getKind() >= FirstLiteralRelocationKind; - // Fixups which should always be recorded as relocations. case AVR::f
[llvm-branch-commits] [llvm] release/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
https://github.com/OCHyams approved this pull request. > @OCHyams What do you think about merging this PR to the release branch? LGTM, this fixes a bug where valid IR gets rejected by the parser, so getting it backported sounds good. For peace of mind: we don't need a null check in the `DVI->location_ops()` loop because `location_ops()` returns an empty range rather than a single-nullptr-location, and multiple locations (through DIArgList) should never be nullptr. https://github.com/llvm/llvm-project/pull/107060 ___ 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] release/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/107082 >From 8607f62de309c11f443af6055477cbfbdf38ec0d Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec Date: Fri, 30 Aug 2024 15:25:54 +0200 Subject: [PATCH 1/2] [AVR] Fix parsing & emitting relative jumps (#106722) Ever since 6859685a87ad093d60c8bed60b116143c0a684c7 (or, precisely, 84428dafc0941e3a31303fa1b286835ab2b8e234) relative jumps emitted by the AVR codegen are off by two bytes - this pull request fixes it. ## Abstract As compared to absolute jumps, relative jumps - such as rjmp, rcall or brsh - have an implied `pc+2` behavior; that is, `jmp 100` is `pc = 100`, but `rjmp 100` gets understood as `pc = pc + 100 + 2`. This is not reflected in the AVR codegen: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L89 ... which always emits relative jumps that are two bytes too far - or rather it _would_ emit such jumps if not for this check: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L517 ... which causes most of the relative jumps to be actually resolved late, by the linker, which applies the offsetting logic on its own, hiding the issue within LLVM. [Some time ago](https://github.com/llvm/llvm-project/commit/697a162fa63df328ec9ca334636c5e85390b2bf0) we've had a similar "jumps are off" problem that got solved by touching `shouldForceRelocation()`, but I think that has worked only by accident. It's exploited the fact that absolute vs relative jumps in the parsed assembly can be distinguished through a "side channel" check relying on the existence of labels (i.e. absolute jumps happen to named labels, but relative jumps are anonymous, so to say). This was an alright idea back then, but it got broken by 6859685a87ad093d60c8bed60b116143c0a684c7. I propose a different approach: - when emitting relative jumps, offset them by `-2` (well, `-1`, strictly speaking, because those instructions rely on right-shifted offset), - when parsing relative jumps, treat `.` as `+2` and read `rjmp .+1234` as `rjmp (1234 + 2)`. This approach seems to be sound and now we generate the same assembly as avr-gcc, which can be confirmed with: ```cpp // avr-gcc test.c -O3 && avr-objdump -d a.out int main() { asm( " foo:\n\t" "rjmp .+2\n\t" "rjmp .-2\n\t" "rjmp foo\n\t" "rjmp .+8\n\t" "rjmp end\n\t" "rjmp .+0\n\t" " end:\n\t" "rjmp .-4\n\t" "rjmp .-6\n\t" " x:\n\t" "rjmp x\n\t" ".short 0xc00f\n\t" ); } ``` avr-gcc is also how I got the opcodes for all new tests like `inst-brbc.s`, so we should be good. (cherry picked from commit 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713) --- .../lib/Target/AVR/AsmParser/AVRAsmParser.cpp | 15 +- .../Target/AVR/MCTargetDesc/AVRAsmBackend.cpp | 12 +- llvm/test/CodeGen/AVR/jmp.ll | 25 ++ llvm/test/MC/AVR/inst-brbc.s | 23 +- llvm/test/MC/AVR/inst-brbs.s | 22 +- llvm/test/MC/AVR/inst-brcc.s | 28 ++ llvm/test/MC/AVR/inst-brcs.s | 28 ++ llvm/test/MC/AVR/inst-breq.s | 28 ++ llvm/test/MC/AVR/inst-brge.s | 24 ++ llvm/test/MC/AVR/inst-brhc.s | 24 ++ llvm/test/MC/AVR/inst-brhs.s | 24 ++ llvm/test/MC/AVR/inst-brid.s | 24 ++ llvm/test/MC/AVR/inst-brie.s | 24 ++ llvm/test/MC/AVR/inst-brlo.s | 24 ++ llvm/test/MC/AVR/inst-brlt.s | 24 ++ llvm/test/MC/AVR/inst-brmi.s | 24 ++ llvm/test/MC/AVR/inst-brne.s | 28 ++ llvm/test/MC/AVR/inst-brpl.s | 24 ++ llvm/test/MC/AVR/inst-brsh.s | 24 ++ llvm/test/MC/AVR/inst-brtc.s | 24 ++ llvm/test/MC/AVR/inst-brts.s | 24 ++ llvm/test/MC/AVR/inst-brvc.s | 24 ++ llvm/test/MC/AVR/inst-brvs.s | 24 ++ llvm/test/MC/AVR/inst-family-cond-branch.s| 321 -- llvm/test/MC/AVR/inst-rcall.s | 33 +- llvm/test/MC/AVR/inst-rjmp.s | 69 ++-- 26 files changed, 567 insertions(+), 401 deletions(-) create mode 100644 llvm/test/CodeGen/AVR/jmp.ll create mode 100644 llvm/test/MC/AVR/inst-brcc.s create mode 100644 llvm/test/MC/AVR/inst-brcs.s create mode 100644 llvm/test/MC/AVR/inst-breq.s create mode 100644 llvm/test/MC/AVR/inst-brge.s create mode 100644 llvm/test/MC/AVR/inst-brhc.s create mode 100644 llvm/test/MC/AVR/inst-brhs.s create mode 100644 llvm/test/MC/AVR/inst-brid.s create mode 100644 llvm/test/MC/AVR/inst-brie.s create mode 100644 llvm/test/MC/AVR/inst-brlo.s create mode 100644 llvm/test/MC/AVR/inst-brlt.s create mode 100644 llvm/test/MC/AVR/inst-brmi.s create mode 100
[llvm-branch-commits] [llvm] 5c836eb - Revert "[Utils][SPIR-V] Adding spirv-sim to LLVM (#104020)"
Author: Nathan Gauër Date: 2024-09-03T13:04:15+02:00 New Revision: 5c836eb36d13eb7c2f8ce8445283da3c78f7fe4f URL: https://github.com/llvm/llvm-project/commit/5c836eb36d13eb7c2f8ce8445283da3c78f7fe4f DIFF: https://github.com/llvm/llvm-project/commit/5c836eb36d13eb7c2f8ce8445283da3c78f7fe4f.diff LOG: Revert "[Utils][SPIR-V] Adding spirv-sim to LLVM (#104020)" This reverts commit c3d8124617a0f7916123174001547eb3b4968644. Added: Modified: llvm/test/lit.cfg.py Removed: llvm/test/Other/spirv-sim/branch.spv llvm/test/Other/spirv-sim/call.spv llvm/test/Other/spirv-sim/constant.spv llvm/test/Other/spirv-sim/lit.local.cfg llvm/test/Other/spirv-sim/loop.spv llvm/test/Other/spirv-sim/simple-bad-result.spv llvm/test/Other/spirv-sim/simple.spv llvm/test/Other/spirv-sim/simulator-args.spv llvm/test/Other/spirv-sim/switch.spv llvm/test/Other/spirv-sim/wave-get-lane-index.spv llvm/test/Other/spirv-sim/wave-read-lane-first.spv llvm/utils/spirv-sim/instructions.py llvm/utils/spirv-sim/spirv-sim.py diff --git a/llvm/test/Other/spirv-sim/branch.spv b/llvm/test/Other/spirv-sim/branch.spv deleted file mode 100644 index 7ee0ebcad249dd..00 --- a/llvm/test/Other/spirv-sim/branch.spv +++ /dev/null @@ -1,42 +0,0 @@ -; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %} -; RUN: spirv-sim --function=simple --wave=3 --expects=5,6,6 -i %s - OpCapability Shader - OpCapability GroupNonUniform - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %main "main" %WaveIndex - OpExecutionMode %main LocalSize 1 1 1 - OpSource HLSL 670 - OpName %simple "simple" - OpName %main "main" -OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId -%int = OpTypeInt 32 1 - %uint = OpTypeInt 32 0 - %bool = OpTypeBool - %int_2 = OpConstant %int 2 - %int_5 = OpConstant %int 5 - %int_6 = OpConstant %int 6 - %uint_0 = OpConstant %uint 0 - %void = OpTypeVoid - %main_type = OpTypeFunction %void -%simple_type = OpTypeFunction %int - %uint_iptr = OpTypePointer Input %uint - %WaveIndex = OpVariable %uint_iptr Input - %main = OpFunction %void None %main_type - %entry = OpLabel - OpReturn - OpFunctionEnd - %simple = OpFunction %int None %simple_type - %1 = OpLabel - %2 = OpLoad %uint %WaveIndex - %3 = OpIEqual %bool %uint_0 %2 - OpSelectionMerge %merge None - OpBranchConditional %3 %true %false - %true = OpLabel - OpBranch %merge - %false = OpLabel - OpBranch %merge - %merge = OpLabel - %4 = OpPhi %int %int_5 %true %int_6 %false - OpReturnValue %4 - OpFunctionEnd - diff --git a/llvm/test/Other/spirv-sim/call.spv b/llvm/test/Other/spirv-sim/call.spv deleted file mode 100644 index 320b048f95296c..00 --- a/llvm/test/Other/spirv-sim/call.spv +++ /dev/null @@ -1,36 +0,0 @@ -; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %} -; RUN: spirv-sim --function=simple --wave=1 --expects=2 -i %s - OpCapability Shader - OpCapability GroupNonUniform - OpMemoryModel Logical GLSL450 - OpEntryPoint GLCompute %main "main" %WaveIndex - OpExecutionMode %main LocalSize 1 1 1 - OpSource HLSL 670 - OpName %simple "simple" - OpName %main "main" -OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId -%int = OpTypeInt 32 1 - %uint = OpTypeInt 32 0 - %uint_2 = OpConstant %uint 2 - %void = OpTypeVoid - %main_type = OpTypeFunction %void -%simple_type = OpTypeFunction %int - %sub_type = OpTypeFunction %uint - %uint_iptr = OpTypePointer Input %uint - %WaveIndex = OpVariable %uint_iptr Input - %main = OpFunction %void None %main_type - %entry = OpLabel - OpReturn - OpFunctionEnd -%sub = OpFunction %uint None %sub_type - %a = OpLabel - OpReturnValue %uint_2 - OpFunctionEnd - %simple = OpFunction %int None %simple_type - %1 = OpLabel - %2 = OpFunctionCall %uint %sub - %3 = OpBitcast %int %2 - OpReturnValue %3 - OpFunctionEnd - - diff --git a/llvm/test/Other/spirv-sim/constant.spv b/llvm/test/Other/spirv-sim/constant.spv deleted file mode 100644 index 1002427943a8d2..00 --- a/llvm/test/Other/spirv-sim/constant.spv +++ /dev/null @@ -1,36 +0,0 @@ -; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %} -; RUN: spirv-sim --function=a --wave=1 --expects=2 -i %s -; RUN: spirv-sim --function=b --wave=1 --expects=1 -i %s - OpCapability Sh
[llvm-branch-commits] [llvm] release/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
https://github.com/OCHyams edited https://github.com/llvm/llvm-project/pull/107060 ___ 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] release/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
aykevl wrote: Oh wow, it seems to have actually worked this time! https://github.com/llvm/llvm-project/pull/107082 ___ 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/19.x: Fix codegen of consteval functions returning an empty class, and related issues (#93115) (PR #102070)
AaronBallman wrote: I'd really appreciate a review from @rjmccall -- the changes are extensive and risky enough that I worry about landing them this late in the cycle, but this does fix a miscompile and that's a pretty important thing for us to land. I didn't spot any concerns with the changes, but @rjmccall is definitely stronger in codegen-fu than I am. If we don't hear from John today (Sept 3), I'd say let's go ahead and land (I'm not accepting the review yet just in case that sends mixed messages to other reviewers). https://github.com/llvm/llvm-project/pull/102070 ___ 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/19.x: [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size. (PR #107098)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/107098 ___ 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/19.x: [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size. (PR #107098)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/107098 Backport f381cd069965dabfeb277f30a4e532d7fd498f6e Requested by: @DianQK >From bfe50bcefb56727a4b0a7a2a9ff0f641201fd53e Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 3 Sep 2024 04:52:47 -0700 Subject: [PATCH] [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size. Only some instructions should be considered as potentially reducing the size of the operands types, not all instructions should be considered. Fixes https://github.com/llvm/llvm-project/issues/107036 (cherry picked from commit f381cd069965dabfeb277f30a4e532d7fd498f6e) --- .../Transforms/Vectorize/SLPVectorizer.cpp| 5 +++ .../X86/minbw-user-non-sizable.ll | 31 +++ 2 files changed, 36 insertions(+) create mode 100644 llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index cca9eeebaa53f0..2f3d6b27378aee 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -15539,6 +15539,11 @@ void BoUpSLP::computeMinimumValueSizes() { const TreeEntry *UserTE = E.UserTreeIndices.back().UserTE; if (TE == UserTE || !TE) return false; +if (!isa(U) || +!isa(UserTE->getMainOp())) + return true; unsigned UserTESz = DL->getTypeSizeInBits( UserTE->Scalars.front()->getType()); auto It = MinBWs.find(TE); diff --git a/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll b/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll new file mode 100644 index 00..7e7d4352e27733 --- /dev/null +++ b/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll @@ -0,0 +1,31 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-100 | FileCheck %s + +define void @test(ptr %i) { +; CHECK-LABEL: define void @test( +; CHECK-SAME: ptr [[I:%.*]]) { +; CHECK-NEXT: [[BB:.*]]: +; CHECK-NEXT:br label %[[BB2:.*]] +; CHECK: [[BB2]]: +; CHECK-NEXT:[[TMP0:%.*]] = phi <2 x i32> [ [[TMP3:%.*]], %[[BB2]] ], [ zeroinitializer, %[[BB]] ] +; CHECK-NEXT:store <2 x i32> [[TMP0]], ptr [[I]], align 4 +; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <2 x i32> [[TMP0]], <2 x i32> , <2 x i32> +; CHECK-NEXT:[[TMP2:%.*]] = trunc <2 x i32> [[TMP1]] to <2 x i1> +; CHECK-NEXT:[[TMP3]] = select <2 x i1> [[TMP2]], <2 x i32> zeroinitializer, <2 x i32> zeroinitializer +; CHECK-NEXT:br label %[[BB2]] +; +bb: + %i1 = getelementptr i8, ptr %i, i64 4 + br label %bb2 + +bb2: + %i3 = phi i32 [ %i6, %bb2 ], [ 0, %bb ] + %i4 = phi i32 [ %i8, %bb2 ], [ 0, %bb ] + store i32 %i3, ptr %i + store i32 %i4, ptr %i1 + %i5 = trunc i32 0 to i1 + %i6 = select i1 %i5, i32 0, i32 0 + %i7 = trunc i32 %i4 to i1 + %i8 = select i1 %i7, i32 0, i32 0 + br label %bb2 +} ___ 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/19.x: [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size. (PR #107098)
llvmbot wrote: @llvm/pr-subscribers-llvm-transforms Author: None (llvmbot) Changes Backport f381cd069965dabfeb277f30a4e532d7fd498f6e Requested by: @DianQK --- Full diff: https://github.com/llvm/llvm-project/pull/107098.diff 2 Files Affected: - (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+5) - (added) llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll (+31) ``diff diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index cca9eeebaa53f0..2f3d6b27378aee 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -15539,6 +15539,11 @@ void BoUpSLP::computeMinimumValueSizes() { const TreeEntry *UserTE = E.UserTreeIndices.back().UserTE; if (TE == UserTE || !TE) return false; +if (!isa(U) || +!isa(UserTE->getMainOp())) + return true; unsigned UserTESz = DL->getTypeSizeInBits( UserTE->Scalars.front()->getType()); auto It = MinBWs.find(TE); diff --git a/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll b/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll new file mode 100644 index 00..7e7d4352e27733 --- /dev/null +++ b/llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll @@ -0,0 +1,31 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-100 | FileCheck %s + +define void @test(ptr %i) { +; CHECK-LABEL: define void @test( +; CHECK-SAME: ptr [[I:%.*]]) { +; CHECK-NEXT: [[BB:.*]]: +; CHECK-NEXT:br label %[[BB2:.*]] +; CHECK: [[BB2]]: +; CHECK-NEXT:[[TMP0:%.*]] = phi <2 x i32> [ [[TMP3:%.*]], %[[BB2]] ], [ zeroinitializer, %[[BB]] ] +; CHECK-NEXT:store <2 x i32> [[TMP0]], ptr [[I]], align 4 +; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <2 x i32> [[TMP0]], <2 x i32> , <2 x i32> +; CHECK-NEXT:[[TMP2:%.*]] = trunc <2 x i32> [[TMP1]] to <2 x i1> +; CHECK-NEXT:[[TMP3]] = select <2 x i1> [[TMP2]], <2 x i32> zeroinitializer, <2 x i32> zeroinitializer +; CHECK-NEXT:br label %[[BB2]] +; +bb: + %i1 = getelementptr i8, ptr %i, i64 4 + br label %bb2 + +bb2: + %i3 = phi i32 [ %i6, %bb2 ], [ 0, %bb ] + %i4 = phi i32 [ %i8, %bb2 ], [ 0, %bb ] + store i32 %i3, ptr %i + store i32 %i4, ptr %i1 + %i5 = trunc i32 0 to i1 + %i6 = select i1 %i5, i32 0, i32 0 + %i7 = trunc i32 %i4 to i1 + %i8 = select i1 %i7, i32 0, i32 0 + br label %bb2 +} `` https://github.com/llvm/llvm-project/pull/107098 ___ 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/19.x: [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size. (PR #107098)
https://github.com/alexey-bataev approved this pull request. https://github.com/llvm/llvm-project/pull/107098 ___ 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/19.x: [IndVars] Check if WideInc available before trying to use it (PR #106892)
https://github.com/AaronBallman approved this pull request. I think you may have intended to tag someone other than Shafik and I for this one, but the changes LGTM nonetheless. https://github.com/llvm/llvm-project/pull/106892 ___ 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/19.x: [IndVars] Check if WideInc available before trying to use it (PR #106892)
https://github.com/fhahn approved this pull request. LGTM looks like a safe cherry-pick https://github.com/llvm/llvm-project/pull/106892 ___ 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] [flang] [llvm] [mlir] [OpenMP]Update use_device_clause lowering (PR #101707)
@@ -2193,80 +2197,137 @@ llvm::Value *getSizeInBytes(DataLayout &dl, const mlir::Type &type, return builder.getInt64(dl.getTypeSizeInBits(type) / 8); } -void collectMapDataFromMapVars(MapInfoData &mapData, - llvm::SmallVectorImpl &mapVars, - LLVM::ModuleTranslation &moduleTranslation, - DataLayout &dl, llvm::IRBuilderBase &builder) { - for (mlir::Value mapValue : mapVars) { -if (auto mapOp = mlir::dyn_cast_if_present( -mapValue.getDefiningOp())) { - mlir::Value offloadPtr = +static void collectMapDataFromMapOperands( +MapInfoData &mapData, SmallVectorImpl &mapVars, +LLVM::ModuleTranslation &moduleTranslation, DataLayout &dl, +llvm::IRBuilderBase &builder, const ArrayRef &useDevPtrOperands = {}, +const ArrayRef &useDevAddrOperands = {}) { + // Process MapOperands + for (Value mapValue : mapVars) { +auto mapOp = cast(mapValue.getDefiningOp()); +Value offloadPtr = +mapOp.getVarPtrPtr() ? mapOp.getVarPtrPtr() : mapOp.getVarPtr(); +mapData.OriginalValue.push_back(moduleTranslation.lookupValue(offloadPtr)); +mapData.Pointers.push_back(mapData.OriginalValue.back()); + +if (llvm::Value *refPtr = +getRefPtrIfDeclareTarget(offloadPtr, + moduleTranslation)) { // declare target + mapData.IsDeclareTarget.push_back(true); + mapData.BasePointers.push_back(refPtr); +} else { // regular mapped variable + mapData.IsDeclareTarget.push_back(false); + mapData.BasePointers.push_back(mapData.OriginalValue.back()); +} + +mapData.BaseType.push_back( +moduleTranslation.convertType(mapOp.getVarType())); +mapData.Sizes.push_back( +getSizeInBytes(dl, mapOp.getVarType(), mapOp, mapData.Pointers.back(), + mapData.BaseType.back(), builder, moduleTranslation)); +mapData.MapClause.push_back(mapOp.getOperation()); +mapData.Types.push_back( +llvm::omp::OpenMPOffloadMappingFlags(mapOp.getMapType().value())); +mapData.Names.push_back(LLVM::createMappingInformation( +mapOp.getLoc(), *moduleTranslation.getOpenMPBuilder())); + mapData.DevicePointers.push_back(llvm::OpenMPIRBuilder::DeviceInfoTy::None); +mapData.IsAMapping.push_back(true); + +// Check if this is a member mapping and correctly assign that it is, if +// it is a member of a larger object. +// TODO: Need better handling of members, and distinguishing of members +// that are implicitly allocated on device vs explicitly passed in as +// arguments. +// TODO: May require some further additions to support nested record +// types, i.e. member maps that can have member maps. +mapData.IsAMember.push_back(false); +for (Value mapValue : mapVars) { + auto map = cast(mapValue.getDefiningOp()); TIFitis wrote: I've moved the logic to a lambda, hopefully that helps readability along with code divergence. I don't think we need to check for member mapOp being same as parent as that would be a peculiar scenario we aren't expecting. https://github.com/llvm/llvm-project/pull/101707 ___ 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] [mlir] [OpenMP]Update use_device_clause lowering (PR #101707)
https://github.com/TIFitis updated https://github.com/llvm/llvm-project/pull/101707 >From 10f575c3457719e2b21f9633c890c34ae671548e Mon Sep 17 00:00:00 2001 From: Akash Banerjee Date: Fri, 2 Aug 2024 17:11:21 +0100 Subject: [PATCH] [OpenMP]Update use_device_clause lowering This patch updates the use_device_ptr and use_device_addr clauses to use the mapInfoOps for lowering. This allows all the types that are handle by the map clauses such as derived types to also be supported by the use_device_clauses. This is patch 2/2 in a series of patches. --- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 2 +- .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 354 +- mlir/test/Target/LLVMIR/omptarget-llvm.mlir | 16 +- .../openmp-target-use-device-nested.mlir | 39 ++ 4 files changed, 228 insertions(+), 183 deletions(-) create mode 100644 mlir/test/Target/LLVMIR/openmp-target-use-device-nested.mlir diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 532313a31fc132..497fecbf6ea199 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -6369,6 +6369,7 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTargetData( if (!updateToLocation(Loc)) return InsertPointTy(); + Builder.restoreIP(CodeGenIP); // Disable TargetData CodeGen on Device pass. if (Config.IsTargetDevice.value_or(false)) { if (BodyGenCB) @@ -6376,7 +6377,6 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTargetData( return Builder.saveIP(); } - Builder.restoreIP(CodeGenIP); bool IsStandAlone = !BodyGenCB; MapInfosTy *MapInfo; // Generate the code for the opening of the data environment. Capture all the diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp index 6a32aeb4441406..d597bbfee2fe19 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp @@ -2260,6 +2260,7 @@ getRefPtrIfDeclareTarget(mlir::Value value, return nullptr; } +namespace { // A small helper structure to contain data gathered // for map lowering and coalese it into one area and // avoiding extra computations such as searches in the @@ -2269,6 +2270,8 @@ getRefPtrIfDeclareTarget(mlir::Value value, struct MapInfoData : llvm::OpenMPIRBuilder::MapInfosTy { llvm::SmallVector IsDeclareTarget; llvm::SmallVector IsAMember; + // Identify if mapping was added by mapClause or use_device clauses. + llvm::SmallVector IsAMapping; llvm::SmallVector MapClause; llvm::SmallVector OriginalValue; // Stripped off array/pointer to get the underlying @@ -2286,6 +2289,7 @@ struct MapInfoData : llvm::OpenMPIRBuilder::MapInfosTy { llvm::OpenMPIRBuilder::MapInfosTy::append(CurInfo); } }; +} // namespace uint64_t getArrayElementSizeInBits(LLVM::LLVMArrayType arrTy, DataLayout &dl) { if (auto nestedArrTy = llvm::dyn_cast_if_present( @@ -2352,80 +2356,126 @@ llvm::Value *getSizeInBytes(DataLayout &dl, const mlir::Type &type, return builder.getInt64(dl.getTypeSizeInBits(type) / 8); } -void collectMapDataFromMapVars(MapInfoData &mapData, - llvm::SmallVectorImpl &mapVars, - LLVM::ModuleTranslation &moduleTranslation, - DataLayout &dl, llvm::IRBuilderBase &builder) { - for (mlir::Value mapValue : mapVars) { -if (auto mapOp = mlir::dyn_cast_if_present( -mapValue.getDefiningOp())) { - mlir::Value offloadPtr = +static void collectMapDataFromMapOperands( +MapInfoData &mapData, SmallVectorImpl &mapVars, +LLVM::ModuleTranslation &moduleTranslation, DataLayout &dl, +llvm::IRBuilderBase &builder, const ArrayRef &useDevPtrOperands = {}, +const ArrayRef &useDevAddrOperands = {}) { + auto checkIsAMember = [](const auto &mapVars, auto mapOp) { +// Check if this is a member mapping and correctly assign that it is, if +// it is a member of a larger object. +// TODO: Need better handling of members, and distinguishing of members +// that are implicitly allocated on device vs explicitly passed in as +// arguments. +// TODO: May require some further additions to support nested record +// types, i.e. member maps that can have member maps. +for (Value mapValue : mapVars) { + auto map = cast(mapValue.getDefiningOp()); + for (auto member : map.getMembers()) +if (member == mapOp) + return true; +} +return false; + }; + + // Process MapOperands + for (Value mapValue : mapVars) { +auto mapOp = cast(mapValue.getDefiningOp()); +Value offloadPtr = +mapOp.getVarPtrPtr() ? mapOp.getVarPtrPtr() : mapOp.getVarPtr(); +mapData.OriginalValue.push_back(moduleTranslation.lookupValue(offloadPtr)); +mapD
[llvm-branch-commits] [compiler-rt] release/19.x: [builtins] Fix divtc3.c etc. compilation on Solaris/SPARC with gcc (#101662) (PR #101847)
perry-ca wrote: I have concerns about this change just thinking about this from the Solaris point of view. A couple questions: - from what I've learnt from Rainer, the Sparc 32-bit mode doesn't support long double. In that case they should change the CMakefile file so none of the TF functions are compiled. - why are you compiling the multc3 function and not the divtc3? I would expect that if the compiler can generate one, it would be able to generate the other. > It's difficult: on one hand it fixes a Solaris/SPARC build failure. On the > other, it's said to cause problems for an out-of-tree z/OS port. > Unfortunately, the developers refuse to publish their code, so it's almost > impossible to reason about that code. I take exception to the statement "the developers refuse to publish". The z/OS code is in the process of being published. No one has refused to publish code and we have worked with other contributors to compiler-rt to ensure the code builds on all platforms while we get the z/OS changes upstreamed. This change will need to be undone and a proper fix applied for Sparc when we enable the z/OS buildbots. I have asked @rorth to review #82789 and provide any changes required for Sparc. I haven't heard back yet. For z/OS, I am ok with this change in the 19.x release since we only depend on trunk and 18.x. We do need to find a proper solution for Sparc in trunk. https://github.com/llvm/llvm-project/pull/101847 ___ 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] release/19.x: [compiler-rt] Support building runtimes for Windows on arm32 (#101462) (PR #106518)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/106518 >From e3abd19242dd908e6186639d091f6ecc219963f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 8 Aug 2024 13:51:07 +0300 Subject: [PATCH] [compiler-rt] Support building runtimes for Windows on arm32 (#101462) In these environments, the architecture name is armv7; recognize that and enable the relevant runtimes. Fix building the sanitizer_common library for this target, by using the right registers for the architecture - this is similar to what 0c391133c9201ef29273554a1505ef855ce17668 did for aarch64. (Still, address sanitizer doesn't support hooking functions at runtime on armv7 or aarch64 - but other runtimes such as ubsan do work.) (cherry picked from commit 5ea9dd8c7076270695a1d90b9c73718e7d95e0bf) --- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake | 4 compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp | 7 +++ compiler-rt/lib/sanitizer_common/sanitizer_win.cpp| 5 + 3 files changed, 16 insertions(+) diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake index 29e5beb6182ba3..37ad48bef818a2 100644 --- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake +++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake @@ -24,6 +24,10 @@ if(APPLE) set(X86_64 x86_64 x86_64h) endif() +if(WIN32) + set(ARM32 ${ARM32} armv7) +endif() + set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} ${RISCV64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON} ${LOONGARCH64}) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp index afcd01dae0b7a4..6fc18396ca63b0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp @@ -70,10 +70,17 @@ void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) { stack_frame.AddrStack.Offset = ctx.Rsp; # endif #else +# if SANITIZER_ARM + int machine_type = IMAGE_FILE_MACHINE_ARM; + stack_frame.AddrPC.Offset = ctx.Pc; + stack_frame.AddrFrame.Offset = ctx.R11; + stack_frame.AddrStack.Offset = ctx.Sp; +# else int machine_type = IMAGE_FILE_MACHINE_I386; stack_frame.AddrPC.Offset = ctx.Eip; stack_frame.AddrFrame.Offset = ctx.Ebp; stack_frame.AddrStack.Offset = ctx.Esp; +# endif #endif stack_frame.AddrPC.Mode = AddrModeFlat; stack_frame.AddrFrame.Mode = AddrModeFlat; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp index 995f00eddc38ae..8a80d54751364e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp @@ -992,8 +992,13 @@ void SignalContext::InitPcSpBp() { sp = (uptr)context_record->Rsp; #endif # else +#if SANITIZER_ARM + bp = (uptr)context_record->R11; + sp = (uptr)context_record->Sp; +#else bp = (uptr)context_record->Ebp; sp = (uptr)context_record->Esp; +#endif # endif } ___ 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] e3abd19 - [compiler-rt] Support building runtimes for Windows on arm32 (#101462)
Author: Martin Storsjö Date: 2024-09-03T16:04:12+02:00 New Revision: e3abd19242dd908e6186639d091f6ecc219963f0 URL: https://github.com/llvm/llvm-project/commit/e3abd19242dd908e6186639d091f6ecc219963f0 DIFF: https://github.com/llvm/llvm-project/commit/e3abd19242dd908e6186639d091f6ecc219963f0.diff LOG: [compiler-rt] Support building runtimes for Windows on arm32 (#101462) In these environments, the architecture name is armv7; recognize that and enable the relevant runtimes. Fix building the sanitizer_common library for this target, by using the right registers for the architecture - this is similar to what 0c391133c9201ef29273554a1505ef855ce17668 did for aarch64. (Still, address sanitizer doesn't support hooking functions at runtime on armv7 or aarch64 - but other runtimes such as ubsan do work.) (cherry picked from commit 5ea9dd8c7076270695a1d90b9c73718e7d95e0bf) Added: Modified: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp compiler-rt/lib/sanitizer_common/sanitizer_win.cpp Removed: diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake index 29e5beb6182ba3..37ad48bef818a2 100644 --- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake +++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake @@ -24,6 +24,10 @@ if(APPLE) set(X86_64 x86_64 x86_64h) endif() +if(WIN32) + set(ARM32 ${ARM32} armv7) +endif() + set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} ${RISCV64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON} ${LOONGARCH64}) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp index afcd01dae0b7a4..6fc18396ca63b0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp @@ -70,10 +70,17 @@ void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) { stack_frame.AddrStack.Offset = ctx.Rsp; # endif #else +# if SANITIZER_ARM + int machine_type = IMAGE_FILE_MACHINE_ARM; + stack_frame.AddrPC.Offset = ctx.Pc; + stack_frame.AddrFrame.Offset = ctx.R11; + stack_frame.AddrStack.Offset = ctx.Sp; +# else int machine_type = IMAGE_FILE_MACHINE_I386; stack_frame.AddrPC.Offset = ctx.Eip; stack_frame.AddrFrame.Offset = ctx.Ebp; stack_frame.AddrStack.Offset = ctx.Esp; +# endif #endif stack_frame.AddrPC.Mode = AddrModeFlat; stack_frame.AddrFrame.Mode = AddrModeFlat; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp index 995f00eddc38ae..8a80d54751364e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp @@ -992,8 +992,13 @@ void SignalContext::InitPcSpBp() { sp = (uptr)context_record->Rsp; #endif # else +#if SANITIZER_ARM + bp = (uptr)context_record->R11; + sp = (uptr)context_record->Sp; +#else bp = (uptr)context_record->Ebp; sp = (uptr)context_record->Esp; +#endif # endif } ___ 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] release/19.x: [compiler-rt] Support building runtimes for Windows on arm32 (#101462) (PR #106518)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/106518 ___ 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] e594b28 - [IndVars] Check if WideInc available before trying to use it
Author: Nikita Popov Date: 2024-09-03T16:04:37+02:00 New Revision: e594b284810c73b09da9436fdc6f1cbbfb4a7924 URL: https://github.com/llvm/llvm-project/commit/e594b284810c73b09da9436fdc6f1cbbfb4a7924 DIFF: https://github.com/llvm/llvm-project/commit/e594b284810c73b09da9436fdc6f1cbbfb4a7924.diff LOG: [IndVars] Check if WideInc available before trying to use it WideInc/WideIncExpr can be null. Previously this worked out because the comparison with WideIncExpr would fail. Now we have accesses to WideInc prior to that. Avoid the issue with an explicit check. Fixes https://github.com/llvm/llvm-project/issues/106239. (cherry picked from commit c9a5e1b665dbba898e9981fd7d48881947e6560e) Added: llvm/test/Transforms/IndVarSimplify/pr106239.ll Modified: llvm/lib/Transforms/Utils/SimplifyIndVar.cpp Removed: diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index 5bda7c50c62c66..0b4a75e0bc52de 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -1928,18 +1928,24 @@ Instruction *WidenIV::widenIVUse(WidenIV::NarrowIVDefUse DU, if (!WideAddRec.first) return nullptr; -// Reuse the IV increment that SCEVExpander created. Recompute flags, unless -// the flags for both increments agree and it is safe to use the ones from -// the original inc. In that case, the new use of the wide increment won't -// be more poisonous. -bool NeedToRecomputeFlags = -!SCEVExpander::canReuseFlagsFromOriginalIVInc(OrigPhi, WidePhi, - DU.NarrowUse, WideInc) || -DU.NarrowUse->hasNoUnsignedWrap() != WideInc->hasNoUnsignedWrap() || -DU.NarrowUse->hasNoSignedWrap() != WideInc->hasNoSignedWrap(); +auto CanUseWideInc = [&]() { + if (!WideInc) +return false; + // Reuse the IV increment that SCEVExpander created. Recompute flags, + // unless the flags for both increments agree and it is safe to use the + // ones from the original inc. In that case, the new use of the wide + // increment won't be more poisonous. + bool NeedToRecomputeFlags = + !SCEVExpander::canReuseFlagsFromOriginalIVInc( + OrigPhi, WidePhi, DU.NarrowUse, WideInc) || + DU.NarrowUse->hasNoUnsignedWrap() != WideInc->hasNoUnsignedWrap() || + DU.NarrowUse->hasNoSignedWrap() != WideInc->hasNoSignedWrap(); + return WideAddRec.first == WideIncExpr && + Rewriter.hoistIVInc(WideInc, DU.NarrowUse, NeedToRecomputeFlags); +}; + Instruction *WideUse = nullptr; -if (WideAddRec.first == WideIncExpr && -Rewriter.hoistIVInc(WideInc, DU.NarrowUse, NeedToRecomputeFlags)) +if (CanUseWideInc()) WideUse = WideInc; else { WideUse = cloneIVUser(DU, WideAddRec.first); diff --git a/llvm/test/Transforms/IndVarSimplify/pr106239.ll b/llvm/test/Transforms/IndVarSimplify/pr106239.ll new file mode 100644 index 00..8d5aa99539a5a7 --- /dev/null +++ b/llvm/test/Transforms/IndVarSimplify/pr106239.ll @@ -0,0 +1,36 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S -passes=indvars < %s | FileCheck %s + +target datalayout = "n8:16:32:64" + +; Make sure it does not crash. + +define i32 @m() { +; CHECK-LABEL: define i32 @m() { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT:br label %[[FOR_BODY_I6:.*]] +; CHECK: [[FOR_BODY_I6]]: +; CHECK-NEXT:br i1 true, label %[[I_EXIT:.*]], label %[[IF_END_I:.*]] +; CHECK: [[IF_END_I]]: +; CHECK-NEXT:store i64 0, ptr null, align 8 +; CHECK-NEXT:br label %[[FOR_BODY_I6]] +; CHECK: [[I_EXIT]]: +; CHECK-NEXT:ret i32 0 +; +entry: + %div.i4 = sdiv i32 1, 0 + br label %for.body.i6 + +for.body.i6: ; preds = %if.end.i, %entry + %add57.i = phi i32 [ %add.i7, %if.end.i ], [ 0, %entry ] + br i1 true, label %i.exit, label %if.end.i + +if.end.i: ; preds = %for.body.i6 + %add.i7 = add i32 %add57.i, %div.i4 + %conv.i = zext i32 %add57.i to i64 + store i64 %conv.i, ptr null, align 8 + br label %for.body.i6 + +i.exit: ; preds = %for.body.i6 + ret i32 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] release/19.x: [IndVars] Check if WideInc available before trying to use it (PR #106892)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/106892 >From e594b284810c73b09da9436fdc6f1cbbfb4a7924 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 28 Aug 2024 12:54:14 +0200 Subject: [PATCH] [IndVars] Check if WideInc available before trying to use it WideInc/WideIncExpr can be null. Previously this worked out because the comparison with WideIncExpr would fail. Now we have accesses to WideInc prior to that. Avoid the issue with an explicit check. Fixes https://github.com/llvm/llvm-project/issues/106239. (cherry picked from commit c9a5e1b665dbba898e9981fd7d48881947e6560e) --- llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 28 +-- .../Transforms/IndVarSimplify/pr106239.ll | 36 +++ 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 llvm/test/Transforms/IndVarSimplify/pr106239.ll diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index 5bda7c50c62c66..0b4a75e0bc52de 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -1928,18 +1928,24 @@ Instruction *WidenIV::widenIVUse(WidenIV::NarrowIVDefUse DU, if (!WideAddRec.first) return nullptr; -// Reuse the IV increment that SCEVExpander created. Recompute flags, unless -// the flags for both increments agree and it is safe to use the ones from -// the original inc. In that case, the new use of the wide increment won't -// be more poisonous. -bool NeedToRecomputeFlags = -!SCEVExpander::canReuseFlagsFromOriginalIVInc(OrigPhi, WidePhi, - DU.NarrowUse, WideInc) || -DU.NarrowUse->hasNoUnsignedWrap() != WideInc->hasNoUnsignedWrap() || -DU.NarrowUse->hasNoSignedWrap() != WideInc->hasNoSignedWrap(); +auto CanUseWideInc = [&]() { + if (!WideInc) +return false; + // Reuse the IV increment that SCEVExpander created. Recompute flags, + // unless the flags for both increments agree and it is safe to use the + // ones from the original inc. In that case, the new use of the wide + // increment won't be more poisonous. + bool NeedToRecomputeFlags = + !SCEVExpander::canReuseFlagsFromOriginalIVInc( + OrigPhi, WidePhi, DU.NarrowUse, WideInc) || + DU.NarrowUse->hasNoUnsignedWrap() != WideInc->hasNoUnsignedWrap() || + DU.NarrowUse->hasNoSignedWrap() != WideInc->hasNoSignedWrap(); + return WideAddRec.first == WideIncExpr && + Rewriter.hoistIVInc(WideInc, DU.NarrowUse, NeedToRecomputeFlags); +}; + Instruction *WideUse = nullptr; -if (WideAddRec.first == WideIncExpr && -Rewriter.hoistIVInc(WideInc, DU.NarrowUse, NeedToRecomputeFlags)) +if (CanUseWideInc()) WideUse = WideInc; else { WideUse = cloneIVUser(DU, WideAddRec.first); diff --git a/llvm/test/Transforms/IndVarSimplify/pr106239.ll b/llvm/test/Transforms/IndVarSimplify/pr106239.ll new file mode 100644 index 00..8d5aa99539a5a7 --- /dev/null +++ b/llvm/test/Transforms/IndVarSimplify/pr106239.ll @@ -0,0 +1,36 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S -passes=indvars < %s | FileCheck %s + +target datalayout = "n8:16:32:64" + +; Make sure it does not crash. + +define i32 @m() { +; CHECK-LABEL: define i32 @m() { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT:br label %[[FOR_BODY_I6:.*]] +; CHECK: [[FOR_BODY_I6]]: +; CHECK-NEXT:br i1 true, label %[[I_EXIT:.*]], label %[[IF_END_I:.*]] +; CHECK: [[IF_END_I]]: +; CHECK-NEXT:store i64 0, ptr null, align 8 +; CHECK-NEXT:br label %[[FOR_BODY_I6]] +; CHECK: [[I_EXIT]]: +; CHECK-NEXT:ret i32 0 +; +entry: + %div.i4 = sdiv i32 1, 0 + br label %for.body.i6 + +for.body.i6: ; preds = %if.end.i, %entry + %add57.i = phi i32 [ %add.i7, %if.end.i ], [ 0, %entry ] + br i1 true, label %i.exit, label %if.end.i + +if.end.i: ; preds = %for.body.i6 + %add.i7 = add i32 %add57.i, %div.i4 + %conv.i = zext i32 %add57.i to i64 + store i64 %conv.i, ptr null, align 8 + br label %for.body.i6 + +i.exit: ; preds = %for.body.i6 + ret i32 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] [compiler-rt] release/19.x: [compiler-rt] Support building runtimes for Windows on arm32 (#101462) (PR #106518)
github-actions[bot] wrote: @mstorsjo (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/106518 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/107058 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
github-actions[bot] wrote: @owenca (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/107058 ___ 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/19.x: [IndVars] Check if WideInc available before trying to use it (PR #106892)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/106892 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/107058 >From 2d90e8f7402b0a8114978b6f014cfe76c96c94a1 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Mon, 2 Sep 2024 01:40:13 -0700 Subject: [PATCH] [clang-format] Correctly annotate braces in macro definition (#106662) Fixes #106418. (cherry picked from commit 0fa78b6c7bd43c2498700a98c47a02cf4fd06388) --- clang/lib/Format/UnwrappedLineParser.cpp | 3 +-- clang/unittests/Format/TokenAnnotatorTest.cpp | 5 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7f5d157ae95891..60e65aaa83e9c1 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -609,9 +609,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { ProbablyBracedList = NextTok->isNot(tok::l_square); } - // Cpp macro definition body that is a nonempty braced list or block: + // Cpp macro definition body containing nonempty braced list or block: if (IsCpp && Line->InMacroBody && PrevTok != FormatTok && - !FormatTok->Previous && NextTok->is(tok::eof) && // A statement can end with only `;` (simple statement), a block // closing brace (compound statement), or `:` (label statement). // If PrevTok is a block opening brace, Tok ends an empty block. diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index f0533c92f6538c..db580d70058811 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -3218,6 +3218,11 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[10], BK_Block); EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace); EXPECT_BRACE_KIND(Tokens[11], BK_Block); + + Tokens = annotate("#define MEMBER(NAME) NAME{\"\"}"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit); + EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit); } TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { ___ 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] 2d90e8f - [clang-format] Correctly annotate braces in macro definition (#106662)
Author: Owen Pan Date: 2024-09-03T16:04:58+02:00 New Revision: 2d90e8f7402b0a8114978b6f014cfe76c96c94a1 URL: https://github.com/llvm/llvm-project/commit/2d90e8f7402b0a8114978b6f014cfe76c96c94a1 DIFF: https://github.com/llvm/llvm-project/commit/2d90e8f7402b0a8114978b6f014cfe76c96c94a1.diff LOG: [clang-format] Correctly annotate braces in macro definition (#106662) Fixes #106418. (cherry picked from commit 0fa78b6c7bd43c2498700a98c47a02cf4fd06388) Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7f5d157ae95891..60e65aaa83e9c1 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -609,9 +609,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { ProbablyBracedList = NextTok->isNot(tok::l_square); } - // Cpp macro definition body that is a nonempty braced list or block: + // Cpp macro definition body containing nonempty braced list or block: if (IsCpp && Line->InMacroBody && PrevTok != FormatTok && - !FormatTok->Previous && NextTok->is(tok::eof) && // A statement can end with only `;` (simple statement), a block // closing brace (compound statement), or `:` (label statement). // If PrevTok is a block opening brace, Tok ends an empty block. diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index f0533c92f6538c..db580d70058811 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -3218,6 +3218,11 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[10], BK_Block); EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace); EXPECT_BRACE_KIND(Tokens[11], BK_Block); + + Tokens = annotate("#define MEMBER(NAME) NAME{\"\"}"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit); + EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit); } TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { ___ 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/19.x: [IndVars] Check if WideInc available before trying to use it (PR #106892)
github-actions[bot] wrote: @nikic (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/106892 ___ 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/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/107060 >From f3da9af3fd2696fbbe437dea599eda088fcb5592 Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Mon, 2 Sep 2024 11:56:40 +0100 Subject: [PATCH] [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When serialising to textual IR, there can be constant Values referred to by DbgRecords that don't appear anywhere else, and have types hidden even deeper in side them. Enumerate these when enumerating all types. Test by Mikael Holmén. (cherry picked from commit 25f87f2d703178bb4bc13a62cb3df001b186cba2) --- llvm/lib/IR/DebugProgramInstruction.cpp | 5 +- llvm/lib/IR/TypeFinder.cpp| 14 + .../DebugInfo/type-finder-w-dbg-records.ll| 51 +++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 llvm/test/DebugInfo/type-finder-w-dbg-records.ll diff --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp index 362d467beeb11b..5d2189b54204fb 100644 --- a/llvm/lib/IR/DebugProgramInstruction.cpp +++ b/llvm/lib/IR/DebugProgramInstruction.cpp @@ -473,11 +473,12 @@ DbgLabelRecord::createDebugIntrinsic(Module *M, Value *DbgVariableRecord::getAddress() const { auto *MD = getRawAddress(); - if (auto *V = dyn_cast(MD)) + if (auto *V = dyn_cast_or_null(MD)) return V->getValue(); // When the value goes to null, it gets replaced by an empty MDNode. - assert(!cast(MD)->getNumOperands() && "Expected an empty MDNode"); + assert(!MD || + !cast(MD)->getNumOperands() && "Expected an empty MDNode"); return nullptr; } diff --git a/llvm/lib/IR/TypeFinder.cpp b/llvm/lib/IR/TypeFinder.cpp index 003155a4af4877..963f4b4806e1f9 100644 --- a/llvm/lib/IR/TypeFinder.cpp +++ b/llvm/lib/IR/TypeFinder.cpp @@ -88,6 +88,20 @@ void TypeFinder::run(const Module &M, bool onlyNamed) { for (const auto &MD : MDForInst) incorporateMDNode(MD.second); MDForInst.clear(); + +// Incorporate types hiding in variable-location information. +for (const auto &Dbg : I.getDbgRecordRange()) { + // Pick out records that have Values. + if (const DbgVariableRecord *DVI = + dyn_cast(&Dbg)) { +for (Value *V : DVI->location_ops()) + incorporateValue(V); +if (DVI->isDbgAssign()) { + if (Value *Addr = DVI->getAddress()) +incorporateValue(Addr); +} + } +} } } diff --git a/llvm/test/DebugInfo/type-finder-w-dbg-records.ll b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll new file mode 100644 index 00..8259b4a9f1c3a5 --- /dev/null +++ b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll @@ -0,0 +1,51 @@ +; RUN: opt --passes=verify %s -o - -S | FileCheck %s + +;; Test that the type definitions are discovered when serialising to LLVM-IR, +;; even if they're only present inside a DbgRecord, and thus not normally +;; visible. + +; CHECK: %union.anon = type { %struct.a } +; CHECK: %struct.a = type { i32 } +; CHECK: %union.anon2 = type { %struct.a2 } +; CHECK: %struct.a2 = type { i32 } + +; ModuleID = 'bbi-98372.ll' +source_filename = "bbi-98372.ll" + +%union.anon = type { %struct.a } +%struct.a = type { i32 } +%union.anon2 = type { %struct.a2 } +%struct.a2 = type { i32 } + +@d = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 +@e = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 + +define void @f() { +entry: +#dbg_value(ptr getelementptr inbounds ([1 x %union.anon], ptr @d, i32 0, i32 3), !7, !DIExpression(), !14) +#dbg_assign(ptr null, !7, !DIExpression(), !16, ptr getelementptr inbounds ([1 x %union.anon2], ptr @e, i32 0, i32 3), !17, !14) + ret void, !dbg !15 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "foo.c", directory: "/bar") +!2 = !{i32 7, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = !{i32 1, !"wchar_size", i32 1} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"clang"} +!7 = !DILocalVariable(name: "f", scope: !8, file: !1, line: 8, type: !12) +!8 = distinct !DISubprogram(name: "e", scope: !1, file: !1, line: 8, type: !9, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) +!9 = !DISubroutineType(types: !10) +!10 = !{null} +!11 = !{!7} +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 16) +!13 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed) +!14 = !DILocation(line: 0, scope: !8) +!15 = !DILocation(line: 8, colu
[llvm-branch-commits] [llvm] f3da9af - [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547)
Author: Jeremy Morse Date: 2024-09-03T16:05:46+02:00 New Revision: f3da9af3fd2696fbbe437dea599eda088fcb5592 URL: https://github.com/llvm/llvm-project/commit/f3da9af3fd2696fbbe437dea599eda088fcb5592 DIFF: https://github.com/llvm/llvm-project/commit/f3da9af3fd2696fbbe437dea599eda088fcb5592.diff LOG: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) When serialising to textual IR, there can be constant Values referred to by DbgRecords that don't appear anywhere else, and have types hidden even deeper in side them. Enumerate these when enumerating all types. Test by Mikael Holmén. (cherry picked from commit 25f87f2d703178bb4bc13a62cb3df001b186cba2) Added: llvm/test/DebugInfo/type-finder-w-dbg-records.ll Modified: llvm/lib/IR/DebugProgramInstruction.cpp llvm/lib/IR/TypeFinder.cpp Removed: diff --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp index 362d467beeb11b..5d2189b54204fb 100644 --- a/llvm/lib/IR/DebugProgramInstruction.cpp +++ b/llvm/lib/IR/DebugProgramInstruction.cpp @@ -473,11 +473,12 @@ DbgLabelRecord::createDebugIntrinsic(Module *M, Value *DbgVariableRecord::getAddress() const { auto *MD = getRawAddress(); - if (auto *V = dyn_cast(MD)) + if (auto *V = dyn_cast_or_null(MD)) return V->getValue(); // When the value goes to null, it gets replaced by an empty MDNode. - assert(!cast(MD)->getNumOperands() && "Expected an empty MDNode"); + assert(!MD || + !cast(MD)->getNumOperands() && "Expected an empty MDNode"); return nullptr; } diff --git a/llvm/lib/IR/TypeFinder.cpp b/llvm/lib/IR/TypeFinder.cpp index 003155a4af4877..963f4b4806e1f9 100644 --- a/llvm/lib/IR/TypeFinder.cpp +++ b/llvm/lib/IR/TypeFinder.cpp @@ -88,6 +88,20 @@ void TypeFinder::run(const Module &M, bool onlyNamed) { for (const auto &MD : MDForInst) incorporateMDNode(MD.second); MDForInst.clear(); + +// Incorporate types hiding in variable-location information. +for (const auto &Dbg : I.getDbgRecordRange()) { + // Pick out records that have Values. + if (const DbgVariableRecord *DVI = + dyn_cast(&Dbg)) { +for (Value *V : DVI->location_ops()) + incorporateValue(V); +if (DVI->isDbgAssign()) { + if (Value *Addr = DVI->getAddress()) +incorporateValue(Addr); +} + } +} } } diff --git a/llvm/test/DebugInfo/type-finder-w-dbg-records.ll b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll new file mode 100644 index 00..8259b4a9f1c3a5 --- /dev/null +++ b/llvm/test/DebugInfo/type-finder-w-dbg-records.ll @@ -0,0 +1,51 @@ +; RUN: opt --passes=verify %s -o - -S | FileCheck %s + +;; Test that the type definitions are discovered when serialising to LLVM-IR, +;; even if they're only present inside a DbgRecord, and thus not normally +;; visible. + +; CHECK: %union.anon = type { %struct.a } +; CHECK: %struct.a = type { i32 } +; CHECK: %union.anon2 = type { %struct.a2 } +; CHECK: %struct.a2 = type { i32 } + +; ModuleID = 'bbi-98372.ll' +source_filename = "bbi-98372.ll" + +%union.anon = type { %struct.a } +%struct.a = type { i32 } +%union.anon2 = type { %struct.a2 } +%struct.a2 = type { i32 } + +@d = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 +@e = global [1 x { i16, i16 }] [{ i16, i16 } { i16 0, i16 undef }], align 1 + +define void @f() { +entry: +#dbg_value(ptr getelementptr inbounds ([1 x %union.anon], ptr @d, i32 0, i32 3), !7, !DIExpression(), !14) +#dbg_assign(ptr null, !7, !DIExpression(), !16, ptr getelementptr inbounds ([1 x %union.anon2], ptr @e, i32 0, i32 3), !17, !14) + ret void, !dbg !15 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2, !3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "foo.c", directory: "/bar") +!2 = !{i32 7, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = !{i32 1, !"wchar_size", i32 1} +!5 = !{i32 7, !"frame-pointer", i32 2} +!6 = !{!"clang"} +!7 = !DILocalVariable(name: "f", scope: !8, file: !1, line: 8, type: !12) +!8 = distinct !DISubprogram(name: "e", scope: !1, file: !1, line: 8, type: !9, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) +!9 = !DISubroutineType(types: !10) +!10 = !{null} +!11 = !{!7} +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 16) +!13 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed) +!14 = !DILocation(line: 0, scope: !8) +!15 = !DILocation(line: 8, column: 28, scope: !8) +!16 = distinct !DIAssignID() +!17 = !DIExpression()
[llvm-branch-commits] [lld] [llvm] release/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/107082 >From 830b7ebac09ebef91671f0863986aee1a1d60e5e Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec Date: Fri, 30 Aug 2024 15:25:54 +0200 Subject: [PATCH 1/2] [AVR] Fix parsing & emitting relative jumps (#106722) Ever since 6859685a87ad093d60c8bed60b116143c0a684c7 (or, precisely, 84428dafc0941e3a31303fa1b286835ab2b8e234) relative jumps emitted by the AVR codegen are off by two bytes - this pull request fixes it. ## Abstract As compared to absolute jumps, relative jumps - such as rjmp, rcall or brsh - have an implied `pc+2` behavior; that is, `jmp 100` is `pc = 100`, but `rjmp 100` gets understood as `pc = pc + 100 + 2`. This is not reflected in the AVR codegen: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L89 ... which always emits relative jumps that are two bytes too far - or rather it _would_ emit such jumps if not for this check: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L517 ... which causes most of the relative jumps to be actually resolved late, by the linker, which applies the offsetting logic on its own, hiding the issue within LLVM. [Some time ago](https://github.com/llvm/llvm-project/commit/697a162fa63df328ec9ca334636c5e85390b2bf0) we've had a similar "jumps are off" problem that got solved by touching `shouldForceRelocation()`, but I think that has worked only by accident. It's exploited the fact that absolute vs relative jumps in the parsed assembly can be distinguished through a "side channel" check relying on the existence of labels (i.e. absolute jumps happen to named labels, but relative jumps are anonymous, so to say). This was an alright idea back then, but it got broken by 6859685a87ad093d60c8bed60b116143c0a684c7. I propose a different approach: - when emitting relative jumps, offset them by `-2` (well, `-1`, strictly speaking, because those instructions rely on right-shifted offset), - when parsing relative jumps, treat `.` as `+2` and read `rjmp .+1234` as `rjmp (1234 + 2)`. This approach seems to be sound and now we generate the same assembly as avr-gcc, which can be confirmed with: ```cpp // avr-gcc test.c -O3 && avr-objdump -d a.out int main() { asm( " foo:\n\t" "rjmp .+2\n\t" "rjmp .-2\n\t" "rjmp foo\n\t" "rjmp .+8\n\t" "rjmp end\n\t" "rjmp .+0\n\t" " end:\n\t" "rjmp .-4\n\t" "rjmp .-6\n\t" " x:\n\t" "rjmp x\n\t" ".short 0xc00f\n\t" ); } ``` avr-gcc is also how I got the opcodes for all new tests like `inst-brbc.s`, so we should be good. (cherry picked from commit 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713) --- .../lib/Target/AVR/AsmParser/AVRAsmParser.cpp | 15 +- .../Target/AVR/MCTargetDesc/AVRAsmBackend.cpp | 12 +- llvm/test/CodeGen/AVR/jmp.ll | 25 ++ llvm/test/MC/AVR/inst-brbc.s | 23 +- llvm/test/MC/AVR/inst-brbs.s | 22 +- llvm/test/MC/AVR/inst-brcc.s | 28 ++ llvm/test/MC/AVR/inst-brcs.s | 28 ++ llvm/test/MC/AVR/inst-breq.s | 28 ++ llvm/test/MC/AVR/inst-brge.s | 24 ++ llvm/test/MC/AVR/inst-brhc.s | 24 ++ llvm/test/MC/AVR/inst-brhs.s | 24 ++ llvm/test/MC/AVR/inst-brid.s | 24 ++ llvm/test/MC/AVR/inst-brie.s | 24 ++ llvm/test/MC/AVR/inst-brlo.s | 24 ++ llvm/test/MC/AVR/inst-brlt.s | 24 ++ llvm/test/MC/AVR/inst-brmi.s | 24 ++ llvm/test/MC/AVR/inst-brne.s | 28 ++ llvm/test/MC/AVR/inst-brpl.s | 24 ++ llvm/test/MC/AVR/inst-brsh.s | 24 ++ llvm/test/MC/AVR/inst-brtc.s | 24 ++ llvm/test/MC/AVR/inst-brts.s | 24 ++ llvm/test/MC/AVR/inst-brvc.s | 24 ++ llvm/test/MC/AVR/inst-brvs.s | 24 ++ llvm/test/MC/AVR/inst-family-cond-branch.s| 321 -- llvm/test/MC/AVR/inst-rcall.s | 33 +- llvm/test/MC/AVR/inst-rjmp.s | 69 ++-- 26 files changed, 567 insertions(+), 401 deletions(-) create mode 100644 llvm/test/CodeGen/AVR/jmp.ll create mode 100644 llvm/test/MC/AVR/inst-brcc.s create mode 100644 llvm/test/MC/AVR/inst-brcs.s create mode 100644 llvm/test/MC/AVR/inst-breq.s create mode 100644 llvm/test/MC/AVR/inst-brge.s create mode 100644 llvm/test/MC/AVR/inst-brhc.s create mode 100644 llvm/test/MC/AVR/inst-brhs.s create mode 100644 llvm/test/MC/AVR/inst-brid.s create mode 100644 llvm/test/MC/AVR/inst-brie.s create mode 100644 llvm/test/MC/AVR/inst-brlo.s create mode 100644 llvm/test/MC/AVR/inst-brlt.s create mode 100644 llvm/test/MC/AVR/inst-brmi.s create mode 100644 l
[llvm-branch-commits] [llvm] release/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
github-actions[bot] wrote: @jmorse (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/107060 ___ 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] release/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
github-actions[bot] wrote: @aykevl (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/107082 ___ 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/19.x: [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547) (PR #107060)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/107060 ___ 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] a01d631 - [AVR] Fix LLD test (#106739)
Author: Patryk Wychowaniec Date: 2024-09-03T16:07:37+02:00 New Revision: a01d631a1c2c3902b383b6491f27b72d63f6257b URL: https://github.com/llvm/llvm-project/commit/a01d631a1c2c3902b383b6491f27b72d63f6257b DIFF: https://github.com/llvm/llvm-project/commit/a01d631a1c2c3902b383b6491f27b72d63f6257b.diff LOG: [AVR] Fix LLD test (#106739) Since we don't generate relocations for those, it doesn't make sense to assert them here; fallout of https://github.com/llvm/llvm-project/pull/106722. (cherry picked from commit a3816b5a573dbf57ba3082a919ca2de6b47257e9) Added: Modified: lld/test/ELF/avr-reloc.s Removed: diff --git a/lld/test/ELF/avr-reloc.s b/lld/test/ELF/avr-reloc.s index ec088eaa149d01..41c32580f63a1c 100644 --- a/lld/test/ELF/avr-reloc.s +++ b/lld/test/ELF/avr-reloc.s @@ -76,32 +76,6 @@ adiw r24, b ; R_AVR_6_ADIW inr20, b ; R_AVR_PORT6 sbic b, 1; R_AVR_PORT5 -.section .PCREL,"ax",@progbits -; CHECK-LABEL: section .PCREL -; CHECK: rjmp .+30 -; CHECK-NEXT: rjmp .-36 -; CHECK-NEXT: breq .+26 -; CHECK-NEXT: breq .-40 -; CHECK-NEXT: rjmp .-4096 -; CHECK-NEXT: rjmp .+4094 -; CHECK-NEXT: rjmp .+4094 -; CHECK-NEXT: rjmp .-4096 -; CHECK-NEXT: breq .-128 -; CHECK-NEXT: breq .+126 -; HEX-LABEL: section .PCREL: -; HEX-NEXT:0fc0eecf 69f061f3 -foo: -rjmp foo + 32 ; R_AVR_13_PCREL -rjmp foo - 32 ; R_AVR_13_PCREL -breq foo + 32 ; R_AVR_7_PCREL -breq foo - 32 ; R_AVR_7_PCREL -rjmp 1f - 4096 $ 1: ; R_AVR_13_PCREL -rjmp 1f + 4094 $ 1: ; R_AVR_13_PCREL -rjmp 1f - 4098 $ 1: ; R_AVR_13_PCREL (overflow) -rjmp 1f + 4096 $ 1: ; R_AVR_13_PCREL (overflow) -breq 1f - 128 $ 1: ; R_AVR_7_PCREL -breq 1f + 126 $ 1: ; R_AVR_7_PCREL - .section .LDSSTS,"ax",@progbits ; CHECK-LABEL: section .LDSSTS: ; CHECK: lds r20, 0x1e ___ 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] 830b7eb - [AVR] Fix parsing & emitting relative jumps (#106722)
Author: Patryk Wychowaniec Date: 2024-09-03T16:07:37+02:00 New Revision: 830b7ebac09ebef91671f0863986aee1a1d60e5e URL: https://github.com/llvm/llvm-project/commit/830b7ebac09ebef91671f0863986aee1a1d60e5e DIFF: https://github.com/llvm/llvm-project/commit/830b7ebac09ebef91671f0863986aee1a1d60e5e.diff LOG: [AVR] Fix parsing & emitting relative jumps (#106722) Ever since 6859685a87ad093d60c8bed60b116143c0a684c7 (or, precisely, 84428dafc0941e3a31303fa1b286835ab2b8e234) relative jumps emitted by the AVR codegen are off by two bytes - this pull request fixes it. ## Abstract As compared to absolute jumps, relative jumps - such as rjmp, rcall or brsh - have an implied `pc+2` behavior; that is, `jmp 100` is `pc = 100`, but `rjmp 100` gets understood as `pc = pc + 100 + 2`. This is not reflected in the AVR codegen: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L89 ... which always emits relative jumps that are two bytes too far - or rather it _would_ emit such jumps if not for this check: https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L517 ... which causes most of the relative jumps to be actually resolved late, by the linker, which applies the offsetting logic on its own, hiding the issue within LLVM. [Some time ago](https://github.com/llvm/llvm-project/commit/697a162fa63df328ec9ca334636c5e85390b2bf0) we've had a similar "jumps are off" problem that got solved by touching `shouldForceRelocation()`, but I think that has worked only by accident. It's exploited the fact that absolute vs relative jumps in the parsed assembly can be distinguished through a "side channel" check relying on the existence of labels (i.e. absolute jumps happen to named labels, but relative jumps are anonymous, so to say). This was an alright idea back then, but it got broken by 6859685a87ad093d60c8bed60b116143c0a684c7. I propose a different approach: - when emitting relative jumps, offset them by `-2` (well, `-1`, strictly speaking, because those instructions rely on right-shifted offset), - when parsing relative jumps, treat `.` as `+2` and read `rjmp .+1234` as `rjmp (1234 + 2)`. This approach seems to be sound and now we generate the same assembly as avr-gcc, which can be confirmed with: ```cpp // avr-gcc test.c -O3 && avr-objdump -d a.out int main() { asm( " foo:\n\t" "rjmp .+2\n\t" "rjmp .-2\n\t" "rjmp foo\n\t" "rjmp .+8\n\t" "rjmp end\n\t" "rjmp .+0\n\t" " end:\n\t" "rjmp .-4\n\t" "rjmp .-6\n\t" " x:\n\t" "rjmp x\n\t" ".short 0xc00f\n\t" ); } ``` avr-gcc is also how I got the opcodes for all new tests like `inst-brbc.s`, so we should be good. (cherry picked from commit 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713) Added: llvm/test/CodeGen/AVR/jmp.ll llvm/test/MC/AVR/inst-brcc.s llvm/test/MC/AVR/inst-brcs.s llvm/test/MC/AVR/inst-breq.s llvm/test/MC/AVR/inst-brge.s llvm/test/MC/AVR/inst-brhc.s llvm/test/MC/AVR/inst-brhs.s llvm/test/MC/AVR/inst-brid.s llvm/test/MC/AVR/inst-brie.s llvm/test/MC/AVR/inst-brlo.s llvm/test/MC/AVR/inst-brlt.s llvm/test/MC/AVR/inst-brmi.s llvm/test/MC/AVR/inst-brne.s llvm/test/MC/AVR/inst-brpl.s llvm/test/MC/AVR/inst-brsh.s llvm/test/MC/AVR/inst-brtc.s llvm/test/MC/AVR/inst-brts.s llvm/test/MC/AVR/inst-brvc.s llvm/test/MC/AVR/inst-brvs.s Modified: llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp llvm/test/MC/AVR/inst-brbc.s llvm/test/MC/AVR/inst-brbs.s llvm/test/MC/AVR/inst-rcall.s llvm/test/MC/AVR/inst-rjmp.s Removed: llvm/test/MC/AVR/inst-family-cond-branch.s diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp index 383dfcc31117c1..c016b2dd91dc67 100644 --- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -72,7 +72,7 @@ class AVRAsmParser : public MCTargetAsmParser { int parseRegisterName(); int parseRegister(bool RestoreOnFailure = false); bool tryParseRegisterOperand(OperandVector &Operands); - bool tryParseExpression(OperandVector &Operands); + bool tryParseExpression(OperandVector &Operands, int64_t offset); bool tryParseRelocExpression(OperandVector &Operands); void eatComma(); @@ -418,7 +418,7 @@ bool AVRAsmParser::tryParseRegisterOperand(OperandVector &Operands) { return false; } -bool AVRAsmParser::tryParseExpression(OperandVector &Operands) { +bool AVRAsmParser::tryParseExpression(OperandVector &Operands, int64_t offset) { SMLoc S = Parser.getTok().getLoc(); if (!tryParseRelocExpression(Operands)) @@ -437,6 +437,11 @@ bool AVR
[llvm-branch-commits] [lld] [llvm] release/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #107082)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/107082 ___ 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/19.x: [MIPS] Optimize sortRelocs for o32 (PR #106008)
alexrp wrote: Definitely agree it's not a regression, but I think I would quibble a bit with the idea that taking ~1h6min to compile something that normally takes ~3min is not a bug in some sense. :slightly_smiling_face: But ok, philosophical debates aside: Would it be reasonable to at least consider it a [critical performance issue for the purposes of a bug fix release](https://github.com/llvm/llvm-project/blob/main/llvm/docs/HowToReleaseLLVM.rst#release-patch-rules)? I acknowledge that there'd still need to be an assessment as to whether the patch is safe, but it *seems* like it should at least fit one of the criteria on its face. In regards to safety, perhaps confidence in the patch would increase in the time between 19.1.0-final and the subsequent bug fix releases? https://github.com/llvm/llvm-project/pull/106008 ___ 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] [X86] Avoid generating nested CALLSEQ for TLS pointer function arguments (PR #106965)
@@ -0,0 +1,17 @@ +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" phoebewang wrote: Yes, we need to check the functional correctness. https://github.com/llvm/llvm-project/pull/106965 ___ 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] [X86] Avoid generating nested CALLSEQ for TLS pointer function arguments (PR #106965)
https://github.com/ritter-x2a updated https://github.com/llvm/llvm-project/pull/106965 >From dadca8c997bad9fc1d655230997985afe64b8430 Mon Sep 17 00:00:00 2001 From: Fabian Ritter Date: Mon, 2 Sep 2024 05:37:33 -0400 Subject: [PATCH] [X86] Avoid generating nested CALLSEQ for TLS pointer function arguments When a pointer to thread-local storage is passed in a function call, ISel first lowers the call and wraps the resulting code in CALLSEQ markers. Afterwards, to compute the pointer to TLS, a call to retrieve the TLS base address is generated and then wrapped in a set of CALLSEQ markers. If the latter call is inserted into the call sequence of the former call, this leads to nested call frames, which are illegal and lead to errors in the machine verifier. This patch avoids surrounding the call to compute the TLS base address in CALLSEQ markers if it is already surrounded by such markers. It relies on zero-sized call frames being represented in the call frame size info stored in the MachineBBs. Fixes #45574 and #98042. --- llvm/lib/Target/X86/X86ISelLowering.cpp | 7 + .../test/CodeGen/X86/tls-function-argument.ll | 30 +++ 2 files changed, 37 insertions(+) create mode 100644 llvm/test/CodeGen/X86/tls-function-argument.ll diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index bbee0af109c74b..bf9777888df831 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -35593,6 +35593,13 @@ X86TargetLowering::EmitLoweredTLSAddr(MachineInstr &MI, // inside MC, therefore without the two markers shrink-wrapping // may push the prologue/epilogue pass them. const TargetInstrInfo &TII = *Subtarget.getInstrInfo(); + + // Do not introduce CALLSEQ markers if we are already in a call sequence. + // Nested call sequences are not allowed and cause errors in the machine + // verifier. + if (TII.getCallFrameSizeAt(MI).has_value()) +return BB; + const MIMetadata MIMD(MI); MachineFunction &MF = *BB->getParent(); diff --git a/llvm/test/CodeGen/X86/tls-function-argument.ll b/llvm/test/CodeGen/X86/tls-function-argument.ll new file mode 100644 index 00..77af1f051a1e40 --- /dev/null +++ b/llvm/test/CodeGen/X86/tls-function-argument.ll @@ -0,0 +1,30 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -mtriple=x86_64 -verify-machineinstrs < %s -relocation-model=pic | FileCheck %s + +; Passing a pointer to thread-local storage to a function can be problematic +; since computing such addresses requires a function call that is introduced +; very late in instruction selection. We need to ensure that we don't introduce +; nested call sequence markers if this function call happens in a call sequence. + +@TLS = internal thread_local global i64 zeroinitializer, align 8 +declare void @bar(ptr) + define internal void @foo() { +; CHECK-LABEL: foo: +; CHECK: # %bb.0: +; CHECK-NEXT:pushq %rbx +; CHECK-NEXT:.cfi_def_cfa_offset 16 +; CHECK-NEXT:.cfi_offset %rbx, -16 +; CHECK-NEXT:leaq TLS@TLSLD(%rip), %rdi +; CHECK-NEXT:callq __tls_get_addr@PLT +; CHECK-NEXT:leaq TLS@DTPOFF(%rax), %rbx +; CHECK-NEXT:movq %rbx, %rdi +; CHECK-NEXT:callq bar@PLT +; CHECK-NEXT:movq %rbx, %rdi +; CHECK-NEXT:callq bar@PLT +; CHECK-NEXT:popq %rbx +; CHECK-NEXT:.cfi_def_cfa_offset 8 +; CHECK-NEXT:retq + call void @bar(ptr @TLS) + call void @bar(ptr @TLS) + ret void +} ___ 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] [X86] Avoid generating nested CALLSEQ for TLS pointer function arguments (PR #106965)
@@ -0,0 +1,17 @@ +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" ritter-x2a wrote: Done in the updated commit. https://github.com/llvm/llvm-project/pull/106965 ___ 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/19.x: [clang-format] Correctly annotate braces in macro definition (#106662) (PR #107058)
prj- wrote: Are you sure about this fix? `20240831100704%2B8aa8c0590c09-1~exp1~20240831220720.2307` is clean, 19 RC4 is clean, but `20240902101259+0ba006daf5d9-1~exp1~20240902221440.2311` is not, see https://github.com/llvm/llvm-project/issues/107096. https://github.com/llvm/llvm-project/pull/107058 ___ 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] [libc++][format][5/7] Improve std::format_to_n (PR #101831)
@@ -56,6 +57,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace __format { +// A helper to limit the total size of code units written. +class _LIBCPP_HIDE_FROM_ABI __max_output_size { +public: + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __max_output_size(size_t __max_size) : __max_size_{__max_size} {} + + // This function adjusts the size of a (bulk) write operations. It ensures the + // number of code units written by a __output_buffer never exceed ldionne wrote: ```suggestion // number of code units written by a __output_buffer never exceeds ``` https://github.com/llvm/llvm-project/pull/101831 ___ 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] [libc++][format][5/7] Improve std::format_to_n (PR #101831)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/101831 ___ 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] [libc++][format][6/7] Optimizes formatted_size. (PR #101835)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/101835 ___ 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] [BOLT][NFC] Rename profile-use-pseudo-probes (PR #106364)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/106364 ___ 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/19.x: [MIPS] Optimize sortRelocs for o32 (PR #106008)
wzssyqa wrote: > Definitely agree it's not a regression, but I think I would quibble a bit > with the idea that taking ~1h6min to compile something that normally takes > ~3min is not a bug in some sense. 🙂 > If so, then I think that it is a real bug ;) > But ok, philosophical debates aside: Would it be reasonable to at least > consider it a [critical performance issue for the purposes of a bug fix > release](https://github.com/llvm/llvm-project/blob/main/llvm/docs/HowToReleaseLLVM.rst#release-patch-rules)? > I acknowledge that there'd still need to be an assessment as to whether the > patch is safe, but it _seems_ like it should at least fit one of the criteria > on its face. In regards to safety, perhaps confidence in the patch would > increase in the time between 19.1.0-final and the subsequent bug fix releases? https://github.com/llvm/llvm-project/pull/106008 ___ 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] [AMDGPU] Fix sign confusion in performMulLoHiCombine (PR #106977)
https://github.com/rampitec approved this pull request. https://github.com/llvm/llvm-project/pull/106977 ___ 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/19.x: workflows: Fix tag name for release sources job (#100752) (PR #107132)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/107132 Backport 3c2ce706a22ab8dc0e9488600c43644b5102 Requested by: @tstellar >From a279ea01c6403874b29b79bbed7274a6 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 26 Jul 2024 07:38:53 -0700 Subject: [PATCH] workflows: Fix tag name for release sources job (#100752) (cherry picked from commit 3c2ce706a22ab8dc0e9488600c43644b5102) --- .github/workflows/release-sources.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-sources.yml b/.github/workflows/release-sources.yml index edb0449ef7e2c2..a6c86823f99df5 100644 --- a/.github/workflows/release-sources.yml +++ b/.github/workflows/release-sources.yml @@ -51,7 +51,7 @@ jobs: steps: - id: inputs run: | - ref=${{ inputs.release-version || github.sha }} + ref=${{ (inputs.release-version && format('llvmorg-{0}', inputs.release-version)) || github.sha }} if [ -n "${{ inputs.release-version }}" ]; then export_args="-release ${{ inputs.release-version }} -final" else ___ 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/19.x: workflows: Fix tag name for release sources job (#100752) (PR #107132)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/107132 ___ 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/19.x: workflows: Fix tag name for release sources job (#100752) (PR #107132)
llvmbot wrote: @tru What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/107132 ___ 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/19.x: workflows: Fix tag name for release sources job (#100752) (PR #107132)
llvmbot wrote: @llvm/pr-subscribers-github-workflow Author: None (llvmbot) Changes Backport 3c2ce706a22ab8dc0e9488600c43644b5102 Requested by: @tstellar --- Full diff: https://github.com/llvm/llvm-project/pull/107132.diff 1 Files Affected: - (modified) .github/workflows/release-sources.yml (+1-1) ``diff diff --git a/.github/workflows/release-sources.yml b/.github/workflows/release-sources.yml index edb0449ef7e2c2..a6c86823f99df5 100644 --- a/.github/workflows/release-sources.yml +++ b/.github/workflows/release-sources.yml @@ -51,7 +51,7 @@ jobs: steps: - id: inputs run: | - ref=${{ inputs.release-version || github.sha }} + ref=${{ (inputs.release-version && format('llvmorg-{0}', inputs.release-version)) || github.sha }} if [ -n "${{ inputs.release-version }}" ]; then export_args="-release ${{ inputs.release-version }} -final" else `` https://github.com/llvm/llvm-project/pull/107132 ___ 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/19.x: workflows: Fix tag name for release sources job (#100752) (PR #107132)
https://github.com/tru approved this pull request. https://github.com/llvm/llvm-project/pull/107132 ___ 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] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/107137 To be used for pseudo probe function matching (#100446). ___ 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] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)
llvmbot wrote: @llvm/pr-subscribers-bolt Author: Amir Ayupov (aaupov) Changes To be used for pseudo probe function matching (#100446). --- Full diff: https://github.com/llvm/llvm-project/pull/107137.diff 3 Files Affected: - (modified) bolt/include/bolt/Profile/ProfileYAMLMapping.h (+38-11) - (modified) bolt/lib/Profile/DataAggregator.cpp (+46-7) - (modified) bolt/lib/Profile/YAMLProfileWriter.cpp (+49-10) ``diff diff --git a/bolt/include/bolt/Profile/ProfileYAMLMapping.h b/bolt/include/bolt/Profile/ProfileYAMLMapping.h index 2a0514d7d9304b..f0cc116ebc6cb0 100644 --- a/bolt/include/bolt/Profile/ProfileYAMLMapping.h +++ b/bolt/include/bolt/Profile/ProfileYAMLMapping.h @@ -95,24 +95,28 @@ template <> struct MappingTraits { namespace bolt { struct PseudoProbeInfo { - llvm::yaml::Hex64 GUID; uint64_t Index; + uint32_t InlineTreeIndex; + llvm::yaml::Hex32 Offset{0}; uint8_t Type; bool operator==(const PseudoProbeInfo &Other) const { -return GUID == Other.GUID && Index == Other.Index; +return InlineTreeIndex == Other.InlineTreeIndex && Index == Other.Index; } - bool operator!=(const PseudoProbeInfo &Other) const { -return !(*this == Other); + bool operator<(const PseudoProbeInfo &Other) const { +if (InlineTreeIndex == Other.InlineTreeIndex) + return Index < Other.Index; +return InlineTreeIndex < Other.InlineTreeIndex; } }; } // end namespace bolt template <> struct MappingTraits { static void mapping(IO &YamlIO, bolt::PseudoProbeInfo &PI) { -YamlIO.mapRequired("guid", PI.GUID); YamlIO.mapRequired("id", PI.Index); YamlIO.mapRequired("type", PI.Type); +YamlIO.mapOptional("inline_tree_id", PI.InlineTreeIndex, (uint32_t)0); +YamlIO.mapOptional("offset", PI.Offset, (uint32_t)0); } static const bool flow = true; @@ -122,7 +126,7 @@ template <> struct MappingTraits { LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::bolt::CallSiteInfo) LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::bolt::SuccessorInfo) -LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::bolt::PseudoProbeInfo) +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::bolt::PseudoProbeInfo) namespace llvm { namespace yaml { @@ -163,10 +167,35 @@ template <> struct MappingTraits { } }; +namespace bolt { +struct InlineTreeInfo { + uint32_t Index; + uint32_t ParentIndex; + uint32_t CallSiteProbe; + llvm::yaml::Hex64 GUID; + llvm::yaml::Hex64 Hash; + bool operator==(const InlineTreeInfo &Other) const { +return Index == Other.Index; + } +}; +} // end namespace bolt + +template <> struct MappingTraits { + static void mapping(IO &YamlIO, bolt::InlineTreeInfo &ITI) { +YamlIO.mapRequired("guid", ITI.GUID); +YamlIO.mapRequired("hash", ITI.Hash); +YamlIO.mapRequired("id", ITI.Index); +YamlIO.mapOptional("parent", ITI.ParentIndex, (uint32_t)0); +YamlIO.mapOptional("callsite", ITI.CallSiteProbe, 0); + } + + static const bool flow = true; +}; } // end namespace yaml } // end namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::bolt::BinaryBasicBlockProfile) +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::bolt::InlineTreeInfo) namespace llvm { namespace yaml { @@ -179,8 +208,7 @@ struct BinaryFunctionProfile { llvm::yaml::Hex64 Hash{0}; uint64_t ExecCount{0}; std::vector Blocks; - llvm::yaml::Hex64 GUID{0}; - llvm::yaml::Hex64 PseudoProbeDescHash{0}; + std::vector InlineTree; bool Used{false}; }; } // end namespace bolt @@ -194,9 +222,8 @@ template <> struct MappingTraits { YamlIO.mapRequired("nblocks", BFP.NumBasicBlocks); YamlIO.mapOptional("blocks", BFP.Blocks, std::vector()); -YamlIO.mapOptional("guid", BFP.GUID, (uint64_t)0); -YamlIO.mapOptional("pseudo_probe_desc_hash", BFP.PseudoProbeDescHash, - (uint64_t)0); +YamlIO.mapOptional("inline_tree", BFP.InlineTree, + std::vector()); } }; diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 10d745cc69824b..803cc4725b5702 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include #include #include @@ -2402,12 +2403,43 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC, const unsigned BlockIndex = BlockMap.getBBIndex(BI.To.Offset); YamlBF.Blocks[BlockIndex].ExecCount += BI.Branches; } - if (PseudoProbeDecoder) { -if ((YamlBF.GUID = BF->getGUID())) { - const MCPseudoProbeFuncDesc *FuncDesc = - PseudoProbeDecoder->getFuncDescForGUID(YamlBF.GUID); - YamlBF.PseudoProbeDescHash = FuncDesc->FuncHash; + DenseMap + InlineTreeNodeId; + if (PseudoProbeDecoder && BF->getGUID()) { +std::queue ITWorklist; +// FIXME: faster inline tree lookup by top-level GUID +if (const MCDecodedPseudoPro
[llvm-branch-commits] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/107137 ___ 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] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/107137 >From 50c021b09950cf7d6a8f25b1ac0dec246f2325f5 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 3 Sep 2024 11:38:04 -0700 Subject: [PATCH] update pseudoprobe-decoding-inline.test Created using spr 1.3.4 --- .../test/X86/pseudoprobe-decoding-inline.test | 31 --- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/bolt/test/X86/pseudoprobe-decoding-inline.test b/bolt/test/X86/pseudoprobe-decoding-inline.test index 1fdd00c7ef6c4b..629dd84ab8e1dc 100644 --- a/bolt/test/X86/pseudoprobe-decoding-inline.test +++ b/bolt/test/X86/pseudoprobe-decoding-inline.test @@ -14,29 +14,38 @@ # RUN: FileCheck --input-file %t.yaml2 %s --check-prefix CHECK-YAML # CHECK-YAML: name: bar # CHECK-YAML: - bid: 0 -# CHECK-YAML: pseudo_probes: [ { guid: 0xE413754A191DB537, id: 1, type: 0 }, { guid: 0xE413754A191DB537, id: 4, type: 0 } ] -# CHECK-YAML: guid: 0xE413754A191DB537 -# CHECK-YAML: pseudo_probe_desc_hash: 0x10E852DA94 +# CHECK-YAML: pseudo_probes: +# CHECK-YAML-NEXT: - { id: 1, type: 0 +# CHECK-YAML-NEXT: - { id: 4, type: 0 +# CHECK-YAML: inline_tree: +# CHECK-YAML-NEXT: - { guid: 0xE413754A191DB537, hash: 0x10E852DA94, id: 0 } # # CHECK-YAML: name: foo # CHECK-YAML: - bid: 0 -# CHECK-YAML: pseudo_probes: [ { guid: 0x5CF8C24CDB18BDAC, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 2, type: 0 } ] -# CHECK-YAML: guid: 0x5CF8C24CDB18BDAC -# CHECK-YAML: pseudo_probe_desc_hash: 0x200205A19C5B4 +# CHECK-YAML: pseudo_probes: +# CHECK-YAML-NEXT: - { id: 1, type: 0 } +# CHECK-YAML-NEXT: - { id: 2, type: 0 } +# CHECK-YAML: inline_tree: +# CHECK-YAML-NEXT: - { guid: 0x5CF8C24CDB18BDAC, hash: 0x200205A19C5B4, id: 0 } +# CHECK-YAML-NEXT: - { guid: 0xE413754A191DB537, hash: 0x10E852DA94, id: 1, callsite: 8 } # # CHECK-YAML: name: main # CHECK-YAML: - bid: 0 -# CHECK-YAML: pseudo_probes: [ { guid: 0xDB956436E78DD5FA, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 1, type: 0 }, { guid: 0x5CF8C24CDB18BDAC, id: 2, type: 0 } ] -# CHECK-YAML: guid: 0xDB956436E78DD5FA -# CHECK-YAML: pseudo_probe_desc_hash: 0x1 +# CHECK-YAML: pseudo_probes: +# CHECK-YAML-NEXT: - { id: 1, type: 0 } +# CHECK-YAML-NEXT: - { id: 1, type: 0, inline_tree_id: 1 } +# CHECK-YAML-NEXT: - { id: 2, type: 0, inline_tree_id: 1 } +# CHECK-YAML: inline_tree: +# CHECK-YAML-NEXT: - { guid: 0xDB956436E78DD5FA, hash: 0x1, id: 0 } +# CHECK-YAML-NEXT: - { guid: 0x5CF8C24CDB18BDAC, hash: 0x200205A19C5B4, id: 1, callsite: 2 } +# CHECK-YAML-NEXT: - { guid: 0xE413754A191DB537, hash: 0x10E852DA94, id: 2, parent: 1, callsite: 8 } # ## Check that without --profile-write-pseudo-probes option, no pseudo probes are ## generated # RUN: perf2bolt %S/../../../llvm/test/tools/llvm-profgen/Inputs/inline-cs-pseudoprobe.perfbin -p %t.preagg --pa -w %t.yaml -o %t.fdata # RUN: FileCheck --input-file %t.yaml %s --check-prefix CHECK-NO-OPT # CHECK-NO-OPT-NOT: pseudo_probes -# CHECK-NO-OPT-NOT: guid -# CHECK-NO-OPT-NOT: pseudo_probe_desc_hash +# CHECK-NO-OPT-NOT: inline_tree CHECK: Report of decoding input pseudo probe binaries ___ 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] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/107137 ___ 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] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/107137 ___ 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/19.x: [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) (PR #107146)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/107146 Backport fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10 Requested by: @mstorsjo >From 2859d33f4b5820a203848916086f7dc3990eea1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 3 Sep 2024 22:45:54 +0300 Subject: [PATCH] [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) This fixes a regression from f58330cbe44598eb2de0cca3b812f67fea0a71ca. That commit changed the clang-cl options /Zi and /Z7 to be implemented as aliases of -g rather than having separate handling. This had the unintended effect, that when assembling .s files with clang-cl, the /Z7 option (which implies using CodeView debug info) was treated as a -g option, which causes `ClangAs::ConstructJob` to pick up the option as part of `Args.getLastArg(options::OPT_g_Group)`, which sets the `WantDebug` variable. Within `Clang::ConstructJob`, we check for whether explicit `-gdwarf` or `-gcodeview` options have been set, and if not, we pick the default debug format for the current toolchain. However, in `ClangAs`, if debug info has been enabled, it always adds DWARF debug info. Add similar logic in `ClangAs` - check if the user has explicitly requested either DWARF or CodeView, otherwise look up the toolchain default. If we (either implicitly or explicitly) should be producing CodeView, don't enable the default `ClangAs` DWARF generation. This fixes the issue, where assembling a single `.s` file with clang-cl, with the /Z7 option, causes the file to contain some DWARF sections. This causes the output executable to contain DWARF, in addition to the separate intended main PDB file. By having the output executable contain DWARF sections, LLDB only looks at the (very little) DWARF info in the executable, rather than looking for a separate standalone PDB file. This caused an issue with LLDB's tests, https://github.com/llvm/llvm-project/issues/101710. (cherry picked from commit fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10) --- clang/lib/Driver/ToolChains/Clang.cpp | 26 ++ clang/test/Driver/debug-options-as.c | 17 - 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 366b147a052bf2..8858c318aba7a1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8561,6 +8561,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, WantDebug = !A->getOption().matches(options::OPT_g0) && !A->getOption().matches(options::OPT_ggdb0); + // If a -gdwarf argument appeared, remember it. + bool EmitDwarf = false; + if (const Arg *A = getDwarfNArg(Args)) +EmitDwarf = checkDebugInfoOption(A, Args, D, getToolChain()); + + bool EmitCodeView = false; + if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) +EmitCodeView = checkDebugInfoOption(A, Args, D, getToolChain()); + + // If the user asked for debug info but did not explicitly specify -gcodeview + // or -gdwarf, ask the toolchain for the default format. + if (!EmitCodeView && !EmitDwarf && WantDebug) { +switch (getToolChain().getDefaultDebugFormat()) { +case llvm::codegenoptions::DIF_CodeView: + EmitCodeView = true; + break; +case llvm::codegenoptions::DIF_DWARF: + EmitDwarf = true; + break; +} + } + + // If the arguments don't imply DWARF, don't emit any debug info here. + if (!EmitDwarf) +WantDebug = false; + llvm::codegenoptions::DebugInfoKind DebugInfoKind = llvm::codegenoptions::NoDebugInfo; diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c index c83c0cb90431d3..3e1ae109711003 100644 --- a/clang/test/Driver/debug-options-as.c +++ b/clang/test/Driver/debug-options-as.c @@ -19,12 +19,27 @@ // GGDB0-NOT: -debug-info-kind= // Check to make sure clang with -g on a .s file gets passed. -// RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ +// This requires a target that defaults to DWARF. +// RUN: %clang -### --target=x86_64-linux-gnu -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck %s // // CHECK: "-cc1as" // CHECK: "-debug-info-kind=constructor" +// Check that a plain -g, without any -gdwarf, for a MSVC target, doesn't +// trigger producing DWARF output. +// RUN: %clang -### --target=x86_64-windows-msvc -c -integrated-as -g -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s +// +// MSVC: "-cc1as" +// MSVC-NOT: "-debug-info-kind=constructor" + +// Check that clang-cl with the -Z7 option works the same, not triggering +// any DWARF output. +// +// RUN: %clang_cl -### -c -Z7 -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s + // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer. // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ // RUN:
[llvm-branch-commits] [clang] release/19.x: [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) (PR #107146)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/107146 ___ 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/19.x: [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) (PR #107146)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (llvmbot) Changes Backport fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10 Requested by: @mstorsjo --- Full diff: https://github.com/llvm/llvm-project/pull/107146.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+26) - (modified) clang/test/Driver/debug-options-as.c (+16-1) ``diff diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 366b147a052bf2..8858c318aba7a1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8561,6 +8561,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, WantDebug = !A->getOption().matches(options::OPT_g0) && !A->getOption().matches(options::OPT_ggdb0); + // If a -gdwarf argument appeared, remember it. + bool EmitDwarf = false; + if (const Arg *A = getDwarfNArg(Args)) +EmitDwarf = checkDebugInfoOption(A, Args, D, getToolChain()); + + bool EmitCodeView = false; + if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) +EmitCodeView = checkDebugInfoOption(A, Args, D, getToolChain()); + + // If the user asked for debug info but did not explicitly specify -gcodeview + // or -gdwarf, ask the toolchain for the default format. + if (!EmitCodeView && !EmitDwarf && WantDebug) { +switch (getToolChain().getDefaultDebugFormat()) { +case llvm::codegenoptions::DIF_CodeView: + EmitCodeView = true; + break; +case llvm::codegenoptions::DIF_DWARF: + EmitDwarf = true; + break; +} + } + + // If the arguments don't imply DWARF, don't emit any debug info here. + if (!EmitDwarf) +WantDebug = false; + llvm::codegenoptions::DebugInfoKind DebugInfoKind = llvm::codegenoptions::NoDebugInfo; diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c index c83c0cb90431d3..3e1ae109711003 100644 --- a/clang/test/Driver/debug-options-as.c +++ b/clang/test/Driver/debug-options-as.c @@ -19,12 +19,27 @@ // GGDB0-NOT: -debug-info-kind= // Check to make sure clang with -g on a .s file gets passed. -// RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ +// This requires a target that defaults to DWARF. +// RUN: %clang -### --target=x86_64-linux-gnu -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck %s // // CHECK: "-cc1as" // CHECK: "-debug-info-kind=constructor" +// Check that a plain -g, without any -gdwarf, for a MSVC target, doesn't +// trigger producing DWARF output. +// RUN: %clang -### --target=x86_64-windows-msvc -c -integrated-as -g -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s +// +// MSVC: "-cc1as" +// MSVC-NOT: "-debug-info-kind=constructor" + +// Check that clang-cl with the -Z7 option works the same, not triggering +// any DWARF output. +// +// RUN: %clang_cl -### -c -Z7 -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s + // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer. // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck -check-prefix=P %s `` https://github.com/llvm/llvm-project/pull/107146 ___ 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/19.x: [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) (PR #107146)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: None (llvmbot) Changes Backport fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10 Requested by: @mstorsjo --- Full diff: https://github.com/llvm/llvm-project/pull/107146.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+26) - (modified) clang/test/Driver/debug-options-as.c (+16-1) ``diff diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 366b147a052bf2..8858c318aba7a1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8561,6 +8561,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, WantDebug = !A->getOption().matches(options::OPT_g0) && !A->getOption().matches(options::OPT_ggdb0); + // If a -gdwarf argument appeared, remember it. + bool EmitDwarf = false; + if (const Arg *A = getDwarfNArg(Args)) +EmitDwarf = checkDebugInfoOption(A, Args, D, getToolChain()); + + bool EmitCodeView = false; + if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) +EmitCodeView = checkDebugInfoOption(A, Args, D, getToolChain()); + + // If the user asked for debug info but did not explicitly specify -gcodeview + // or -gdwarf, ask the toolchain for the default format. + if (!EmitCodeView && !EmitDwarf && WantDebug) { +switch (getToolChain().getDefaultDebugFormat()) { +case llvm::codegenoptions::DIF_CodeView: + EmitCodeView = true; + break; +case llvm::codegenoptions::DIF_DWARF: + EmitDwarf = true; + break; +} + } + + // If the arguments don't imply DWARF, don't emit any debug info here. + if (!EmitDwarf) +WantDebug = false; + llvm::codegenoptions::DebugInfoKind DebugInfoKind = llvm::codegenoptions::NoDebugInfo; diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c index c83c0cb90431d3..3e1ae109711003 100644 --- a/clang/test/Driver/debug-options-as.c +++ b/clang/test/Driver/debug-options-as.c @@ -19,12 +19,27 @@ // GGDB0-NOT: -debug-info-kind= // Check to make sure clang with -g on a .s file gets passed. -// RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ +// This requires a target that defaults to DWARF. +// RUN: %clang -### --target=x86_64-linux-gnu -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck %s // // CHECK: "-cc1as" // CHECK: "-debug-info-kind=constructor" +// Check that a plain -g, without any -gdwarf, for a MSVC target, doesn't +// trigger producing DWARF output. +// RUN: %clang -### --target=x86_64-windows-msvc -c -integrated-as -g -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s +// +// MSVC: "-cc1as" +// MSVC-NOT: "-debug-info-kind=constructor" + +// Check that clang-cl with the -Z7 option works the same, not triggering +// any DWARF output. +// +// RUN: %clang_cl -### -c -Z7 -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s + // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer. // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck -check-prefix=P %s `` https://github.com/llvm/llvm-project/pull/107146 ___ 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/19.x: [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) (PR #107146)
Martin =?utf-8?q?Storsjö?= Message-ID: In-Reply-To: https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/107146 >From 413f7b7b9200bd989c1d584ea43ec3b9cae48265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 3 Sep 2024 22:45:54 +0300 Subject: [PATCH 1/2] [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) This fixes a regression from f58330cbe44598eb2de0cca3b812f67fea0a71ca. That commit changed the clang-cl options /Zi and /Z7 to be implemented as aliases of -g rather than having separate handling. This had the unintended effect, that when assembling .s files with clang-cl, the /Z7 option (which implies using CodeView debug info) was treated as a -g option, which causes `ClangAs::ConstructJob` to pick up the option as part of `Args.getLastArg(options::OPT_g_Group)`, which sets the `WantDebug` variable. Within `Clang::ConstructJob`, we check for whether explicit `-gdwarf` or `-gcodeview` options have been set, and if not, we pick the default debug format for the current toolchain. However, in `ClangAs`, if debug info has been enabled, it always adds DWARF debug info. Add similar logic in `ClangAs` - check if the user has explicitly requested either DWARF or CodeView, otherwise look up the toolchain default. If we (either implicitly or explicitly) should be producing CodeView, don't enable the default `ClangAs` DWARF generation. This fixes the issue, where assembling a single `.s` file with clang-cl, with the /Z7 option, causes the file to contain some DWARF sections. This causes the output executable to contain DWARF, in addition to the separate intended main PDB file. By having the output executable contain DWARF sections, LLDB only looks at the (very little) DWARF info in the executable, rather than looking for a separate standalone PDB file. This caused an issue with LLDB's tests, https://github.com/llvm/llvm-project/issues/101710. (cherry picked from commit fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10) --- clang/lib/Driver/ToolChains/Clang.cpp | 26 ++ clang/test/Driver/debug-options-as.c | 17 - 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 366b147a052bf2..8858c318aba7a1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8561,6 +8561,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, WantDebug = !A->getOption().matches(options::OPT_g0) && !A->getOption().matches(options::OPT_ggdb0); + // If a -gdwarf argument appeared, remember it. + bool EmitDwarf = false; + if (const Arg *A = getDwarfNArg(Args)) +EmitDwarf = checkDebugInfoOption(A, Args, D, getToolChain()); + + bool EmitCodeView = false; + if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) +EmitCodeView = checkDebugInfoOption(A, Args, D, getToolChain()); + + // If the user asked for debug info but did not explicitly specify -gcodeview + // or -gdwarf, ask the toolchain for the default format. + if (!EmitCodeView && !EmitDwarf && WantDebug) { +switch (getToolChain().getDefaultDebugFormat()) { +case llvm::codegenoptions::DIF_CodeView: + EmitCodeView = true; + break; +case llvm::codegenoptions::DIF_DWARF: + EmitDwarf = true; + break; +} + } + + // If the arguments don't imply DWARF, don't emit any debug info here. + if (!EmitDwarf) +WantDebug = false; + llvm::codegenoptions::DebugInfoKind DebugInfoKind = llvm::codegenoptions::NoDebugInfo; diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c index c83c0cb90431d3..3e1ae109711003 100644 --- a/clang/test/Driver/debug-options-as.c +++ b/clang/test/Driver/debug-options-as.c @@ -19,12 +19,27 @@ // GGDB0-NOT: -debug-info-kind= // Check to make sure clang with -g on a .s file gets passed. -// RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ +// This requires a target that defaults to DWARF. +// RUN: %clang -### --target=x86_64-linux-gnu -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck %s // // CHECK: "-cc1as" // CHECK: "-debug-info-kind=constructor" +// Check that a plain -g, without any -gdwarf, for a MSVC target, doesn't +// trigger producing DWARF output. +// RUN: %clang -### --target=x86_64-windows-msvc -c -integrated-as -g -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s +// +// MSVC: "-cc1as" +// MSVC-NOT: "-debug-info-kind=constructor" + +// Check that clang-cl with the -Z7 option works the same, not triggering +// any DWARF output. +// +// RUN: %clang_cl -### -c -Z7 -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s + // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer. // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck -c
[llvm-branch-commits] [clang] release/19.x: [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) (PR #107146)
mstorsjo wrote: It seems like llvmbot didn't CC anyone to ack to backport this time (or yet), so I'll do it manually: @bogner and @zmodem, what do you think about backporting this to the 19.x release? Also sorry for filing the backport before sorting out buildbot breakage caused by the patch... @tru - this isn't a very urgent fix wrt the release (for me, I guess it could be for someone else though?), so if you want to keep 19.1.0 extra safe and minimal, feel free to hold off of it for a while. But it's a fix for a clear regression, so I guess it qualifies for 19.x at some point at least. The main impact that I know of, is that one of LLDB's tests on Windows fails, in MSVC configurations, until this issue is fixed. https://github.com/llvm/llvm-project/pull/107146 ___ 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/19.x: [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) (PR #107146)
Martin =?utf-8?q?Storsjö?= , Martin =?utf-8?q?Storsjö?= Message-ID: In-Reply-To: https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/107146 >From 416125130acdec945b91f2db08a80459eca58fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 3 Sep 2024 22:45:54 +0300 Subject: [PATCH 1/3] [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 (#106686) This fixes a regression from f58330cbe44598eb2de0cca3b812f67fea0a71ca. That commit changed the clang-cl options /Zi and /Z7 to be implemented as aliases of -g rather than having separate handling. This had the unintended effect, that when assembling .s files with clang-cl, the /Z7 option (which implies using CodeView debug info) was treated as a -g option, which causes `ClangAs::ConstructJob` to pick up the option as part of `Args.getLastArg(options::OPT_g_Group)`, which sets the `WantDebug` variable. Within `Clang::ConstructJob`, we check for whether explicit `-gdwarf` or `-gcodeview` options have been set, and if not, we pick the default debug format for the current toolchain. However, in `ClangAs`, if debug info has been enabled, it always adds DWARF debug info. Add similar logic in `ClangAs` - check if the user has explicitly requested either DWARF or CodeView, otherwise look up the toolchain default. If we (either implicitly or explicitly) should be producing CodeView, don't enable the default `ClangAs` DWARF generation. This fixes the issue, where assembling a single `.s` file with clang-cl, with the /Z7 option, causes the file to contain some DWARF sections. This causes the output executable to contain DWARF, in addition to the separate intended main PDB file. By having the output executable contain DWARF sections, LLDB only looks at the (very little) DWARF info in the executable, rather than looking for a separate standalone PDB file. This caused an issue with LLDB's tests, https://github.com/llvm/llvm-project/issues/101710. (cherry picked from commit fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10) --- clang/lib/Driver/ToolChains/Clang.cpp | 26 ++ clang/test/Driver/debug-options-as.c | 17 - 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 366b147a052bf2..8858c318aba7a1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8561,6 +8561,32 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, WantDebug = !A->getOption().matches(options::OPT_g0) && !A->getOption().matches(options::OPT_ggdb0); + // If a -gdwarf argument appeared, remember it. + bool EmitDwarf = false; + if (const Arg *A = getDwarfNArg(Args)) +EmitDwarf = checkDebugInfoOption(A, Args, D, getToolChain()); + + bool EmitCodeView = false; + if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) +EmitCodeView = checkDebugInfoOption(A, Args, D, getToolChain()); + + // If the user asked for debug info but did not explicitly specify -gcodeview + // or -gdwarf, ask the toolchain for the default format. + if (!EmitCodeView && !EmitDwarf && WantDebug) { +switch (getToolChain().getDefaultDebugFormat()) { +case llvm::codegenoptions::DIF_CodeView: + EmitCodeView = true; + break; +case llvm::codegenoptions::DIF_DWARF: + EmitDwarf = true; + break; +} + } + + // If the arguments don't imply DWARF, don't emit any debug info here. + if (!EmitDwarf) +WantDebug = false; + llvm::codegenoptions::DebugInfoKind DebugInfoKind = llvm::codegenoptions::NoDebugInfo; diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c index c83c0cb90431d3..3e1ae109711003 100644 --- a/clang/test/Driver/debug-options-as.c +++ b/clang/test/Driver/debug-options-as.c @@ -19,12 +19,27 @@ // GGDB0-NOT: -debug-info-kind= // Check to make sure clang with -g on a .s file gets passed. -// RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \ +// This requires a target that defaults to DWARF. +// RUN: %clang -### --target=x86_64-linux-gnu -c -integrated-as -g -x assembler %s 2>&1 \ // RUN: | FileCheck %s // // CHECK: "-cc1as" // CHECK: "-debug-info-kind=constructor" +// Check that a plain -g, without any -gdwarf, for a MSVC target, doesn't +// trigger producing DWARF output. +// RUN: %clang -### --target=x86_64-windows-msvc -c -integrated-as -g -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s +// +// MSVC: "-cc1as" +// MSVC-NOT: "-debug-info-kind=constructor" + +// Check that clang-cl with the -Z7 option works the same, not triggering +// any DWARF output. +// +// RUN: %clang_cl -### -c -Z7 -x assembler %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MSVC %s + // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer. // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&