[Lldb-commits] [lldb] [lldb] Add Populate Methods for ELFLinuxPrPsInfo and ELFLinuxPrStatus (PR #104109)
ilovepi wrote: We're seeing a failure in our CI after this patch, would you mind taking a look and reverting if its going to take a while to fix? Error: ``` FAILED: tools/lldb/unittests/Process/elf-core/CMakeFiles/ProcessElfCoreTests.dir/ThreadElfCoreTest.cpp.o /b/s/w/ir/x/w/rc/cxx-rbe47grlile/reclient-cxx-wrapper.sh /b/s/w/ir/x/w/cipd/bin/clang++ --sysroot=/b/s/w/ir/x/w/cipd/linux -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLIBXML_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/s/w/ir/x/w/llvm_build/tools/lldb/unittests/Process/elf-core -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests/Process/elf-core -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/include -I/b/s/w/ir/x/w/llvm_build/tools/lldb/include -I/b/s/w/ir/x/w/rc/tensorflow-venv/store/python_venv-u3hh0hkn7c13sepmcfocq14vq0/contents/lib/python3.8/site-packages/tensorflow/include -I/b/s/w/ir/x/w/llvm_build/include -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/include -I/b/s/w/ir/x/w/lldb_install/python3/include/python3.11 -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/../clang/include -I/b/s/w/ir/x/w/llvm_build/tools/lldb/../clang/include -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/source -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests -I/b/s/w/ir/x/w/llvm-llvm-project/third-party/unittest/googletest/include -I/b/s/w/ir/x/w/llvm-llvm-project/third-party/unittest/googlemock/include -isystem /b/s/w/ir/x/w/libxml2_install_target/include/libxml2 -isystem /b/s/w/ir/x/w/zlib_install_target/include -isystem /b/s/w/ir/x/w/zstd_install/include -isystem /b/s/w/ir/x/w/libedit_install/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -ffat-lto-objects -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build=../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -std=c++17 -fvisibility=default -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/lldb/unittests/Process/elf-core/CMakeFiles/ProcessElfCoreTests.dir/ThreadElfCoreTest.cpp.o -MF tools/lldb/unittests/Process/elf-core/CMakeFiles/ProcessElfCoreTests.dir/ThreadElfCoreTest.cpp.o.d -o tools/lldb/unittests/Process/elf-core/CMakeFiles/ProcessElfCoreTests.dir/ThreadElfCoreTest.cpp.o -c /b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp /b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp:94:56: error: use of undeclared identifier 'gettid' 94 | std::make_shared(*process_sp.get(), gettid()); |^ /b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp:170:57: error: use of undeclared identifier 'gettid' 170 | ASSERT_EQ(prstatus_opt->pr_pid, static_cast(gettid())); | ^ /b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp:173:64: error: use of undeclared identifier 'gettid' 173 | ASSERT_EQ(prstatus_opt->pr_sid, static_cast(getsid(gettid(; |^ 3 errors generated. ``` Bot: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8739431848195463889/overview Logs: https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8739431848195463889/+/u/lldb/test/stdout https://github.com/llvm/llvm-project/pull/104109 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add Populate Methods for ELFLinuxPrPsInfo and ELFLinuxPrStatus (PR #104109)
ilovepi wrote: I think the need to add _GNU_SOURCE depends on your libc, it it’s probably reasonable to add it based on the platform. I’d think you’d want to use an ifdef here to define _GNU_SOURCE if needed. I based on the target platform. You could also probably do something similar in CMAKE but you may want to limit that in scope to only this test, since I’m not completely sure of the impact, though IIRC it’s safe. Regardless, I’d appreciate it if this was reverted until a fixed version ready, since is been breaking our CI since it landed. https://github.com/llvm/llvm-project/pull/104109 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add Populate Methods for ELFLinuxPrPsInfo and ELFLinuxPrStatus (PR #104109)
ilovepi wrote: > Update: I see that what we are really compiling for is fuchsia! Interesting. > I will investigate further! No, this is targeting linux for x86_64: The command line doesn't list a different target, and we don't try to test LLDB on Fuchsia targets to my knowledge. We do run the tests for the host platform though. This is a normal linux build, with no downstream packages. Looking at that command, `-D_GNU_SOURCE` is already defined for that TU, so maybe there is a different reason. Our bots and sysroot are based on the oldest supported versions of Debian, based on the project's stated minimum requirements. We do this purposefully to make sure we're not out of sync w/ what is intended to be supported by LLVM. So perhaps there is an issue in that regard? ``` /b/s/w/ir/x/w/rc/cxx-rbe47grlile/reclient-cxx-wrapper.sh /b/s/w/ir/x/w/cipd/bin/clang++ --sysroot=/b/s/w/ir/x/w/cipd/linux -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLIBXML_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/s/w/ir/x/w/llvm_build/tools/lldb/unittests/Process/elf-core -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests/Process/elf-core -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/include -I/b/s/w/ir/x/w/llvm_build/tools/lldb/include -I/b/s/w/ir/x/w/rc/tensorflow-venv/store/python_venv-u3hh0hkn7c13sepmcfocq14vq0/contents/lib/python3.8/site-packages/tensorflow/include -I/b/s/w/ir/x/w/llvm_build/include -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/include -I/b/s/w/ir/x/w/lldb_install/python3/include/python3.11 -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/../clang/include -I/b/s/w/ir/x/w/llvm_build/tools/lldb/../clang/include -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/source -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests -I/b/s/w/ir/x/w/llvm-llvm-project/third-party/unittest/googletest/include -I/b/s/w/ir/x/w/llvm-llvm-project/third-party/unittest/googlemock/include -isystem /b/s/w/ir/x/w/libxml2_install_target/include/libxml2 -isystem /b/s/w/ir/x/w/zlib_install_target/include -isystem /b/s/w/ir/x/w/zstd_install/include -isystem /b/s/w/ir/x/w/libedit_install/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -ffat-lto-objects -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build=../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -std=c++17 -fvisibility=default -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/lldb/unittests/Process/elf-core/CMakeFiles/ProcessElfCoreTests.dir/ThreadElfCoreTest.cpp.o -MF tools/lldb/unittests/Process/elf-core/CMakeFiles/ProcessElfCoreTests.dir/ThreadElfCoreTest.cpp.o.d -o tools/lldb/unittests/Process/elf-core/CMakeFiles/ProcessElfCoreTests.dir/ThreadElfCoreTest.cpp.o -c /b/s/w/ir/x/w/llvm-llvm-project/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp ``` https://github.com/llvm/llvm-project/pull/104109 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)
https://github.com/ilovepi closed https://github.com/llvm/llvm-project/pull/104878 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)
ilovepi wrote: @hawkinsw I think you're fine to land this. From what I can tell you've addressed @petrhosek's comments. I work on the same team as him, so we'd like to see our CI go green ASAP. https://github.com/llvm/llvm-project/pull/104831 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [flang] [mlir] [lldb] [compiler-rt] [llvm] [Profile] Add binary profile correlation for code coverage. (PR #69493)
ilovepi wrote: I think our Linux CI is seeing failures related to this patch: https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8761705440671462977/overview Profile-aarch64 :: instrprof-binary-correlate.c is failing on that bot for both x86_64 and arm64. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [flang] [mlir] [lldb] [compiler-rt] [llvm] [Profile] Add binary profile correlation for code coverage. (PR #69493)
ilovepi wrote: Test output: ``` TEST 'Profile-aarch64 :: instrprof-binary-correlate.c' FAILED Exit Code: 1 Command Output (stdout): -- Binary files /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata and /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata differ -- Command Output (stderr): -- RUN: at line 3: /b/s/w/ir/x/w/llvm_build/./bin/clang-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -ldl -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal -fprofile-instr-generate -fcoverage-mapping /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-main.cpp /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-foo.cpp + /b/s/w/ir/x/w/llvm_build/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -ldl -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal -fprofile-instr-generate -fcoverage-mapping /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-main.cpp /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-foo.cpp RUN: at line 4: env LLVM_PROFILE_FILE=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal + env LLVM_PROFILE_FILE=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal RUN: at line 5: llvm-profdata merge -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw + llvm-profdata merge -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw RUN: at line 6: llvm-cov report --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal > /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.report + llvm-cov report --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal RUN: at line 7: llvm-cov show --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal > /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.show + llvm-cov show --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal RUN: at line 10: /b/s/w/ir/x/w/llvm_bui
[Lldb-commits] [clang] [clang-tools-extra] [flang] [mlir] [lldb] [compiler-rt] [llvm] [Profile] Add binary profile correlation for code coverage. (PR #69493)
ilovepi wrote: Seems like a mismatch on the diff, so maybe the check is too stringent. If this will take a while to fix, would you mind reverting until it can be addressed? https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [mlir] [clang-tools-extra] [clang] [flang] [llvm] [compiler-rt] [Profile] Add binary profile correlation for code coverage. (PR #69493)
ilovepi wrote: Our next cI run should finish in about 25 minutes, so we'll find out soon. https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8761696932167687409/overview https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [mlir] [clang-tools-extra] [lldb] [llvm] [flang] [clang] [compiler-rt] [Profile] Add binary profile correlation for code coverage. (PR #69493)
ilovepi wrote: Well, seems like someone broke ToT w/ a compiler error. I'll let you know if the forward fix fails to address the issue. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [flang] [clang-tools-extra] [mlir] [compiler-rt] [lldb] [clang] [Profile] Add binary profile correlation for code coverage. (PR #69493)
ilovepi wrote: Indeed. Thank you! https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [libcxxabi] [lld] [flang] [llvm] [libc] [libcxx] [compiler-rt] [clang-tools-extra] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/66915 >From ce9772dd519a62025cf545ded306bf40c75f2924 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Tue, 19 Sep 2023 20:53:54 + Subject: [PATCH 01/15] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend This patch adds basic TLSDESC support for the global dynamic case in the RISC-V backend by adding new relocation types for TLSDESC, as prescribed in https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373. We also add a new pseudo instruction to simplify code generation. Possible improvements for the local dynamic case will be addressed in separate patches. The current implementation is only enabled when passing the -riscv-enable-tlsdesc flag. --- .../llvm/BinaryFormat/ELFRelocs/RISCV.def | 4 + .../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 97 +-- .../RISCV/MCTargetDesc/RISCVAsmBackend.cpp| 9 ++ .../Target/RISCV/MCTargetDesc/RISCVBaseInfo.h | 6 +- .../MCTargetDesc/RISCVELFObjectWriter.cpp | 15 +++ .../RISCV/MCTargetDesc/RISCVFixupKinds.h | 12 +++ .../RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp | 46 + .../Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp | 18 .../Target/RISCV/MCTargetDesc/RISCVMCExpr.h | 4 + llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 12 +++ .../Target/RISCV/RISCVExpandPseudoInsts.cpp | 53 ++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 23 - llvm/lib/Target/RISCV/RISCVISelLowering.h | 3 + llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 6 +- llvm/lib/Target/RISCV/RISCVInstrInfo.td | 36 +++ llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 4 + llvm/test/CodeGen/RISCV/tls-models.ll | 96 ++ 17 files changed, 432 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def b/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def index 9a126df0153119..94420395fa0fad 100644 --- a/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def +++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def @@ -55,3 +55,7 @@ ELF_RELOC(R_RISCV_SET32, 56) ELF_RELOC(R_RISCV_32_PCREL, 57) ELF_RELOC(R_RISCV_IRELATIVE, 58) ELF_RELOC(R_RISCV_PLT32, 59) +ELF_RELOC(R_RISCV_TLSDESC_HI20, 62) +ELF_RELOC(R_RISCV_TLSDESC_LOAD_LO12, 63) +ELF_RELOC(R_RISCV_TLSDESC_ADD_LO12, 64) +ELF_RELOC(R_RISCV_TLSDESC_CALL, 65) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 7d8d82e381313b..1303f5e85aeeb6 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -152,6 +152,7 @@ class RISCVAsmParser : public MCTargetAsmParser { // Helper to emit pseudo instruction "la.tls.gd" used in global-dynamic TLS // addressing. void emitLoadTLSGDAddress(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out); + void emitLoadTLSDescAddress(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out); // Helper to emit pseudo load/store instruction with a symbol. void emitLoadStoreSymbol(MCInst &Inst, unsigned Opcode, SMLoc IDLoc, @@ -170,6 +171,12 @@ class RISCVAsmParser : public MCTargetAsmParser { // 'add' is an overloaded mnemonic. bool checkPseudoAddTPRel(MCInst &Inst, OperandVector &Operands); + // Checks that a PseudoTLSDESCCall is using x5/t0 in its output operand. + // Enforcing this using a restricted register class for the output + // operand of PseudoTLSDESCCall results in a poor diagnostic due to the fact + // 'jalr' is an overloaded mnemonic. + bool checkPseudoTLSDESCCall(MCInst &Inst, OperandVector &Operands); + // Check instruction constraints. bool validateInstruction(MCInst &Inst, OperandVector &Operands); @@ -533,6 +540,16 @@ struct RISCVOperand final : public MCParsedAsmOperand { VK == RISCVMCExpr::VK_RISCV_TPREL_ADD; } + bool isTLSDESCCallSymbol() const { +int64_t Imm; +RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None; +// Must be of 'immediate' type but not a constant. +if (!isImm() || evaluateConstantImm(getImm(), Imm, VK)) + return false; +return RISCVAsmParser::classifySymbolRef(getImm(), VK) && + VK == RISCVMCExpr::VK_RISCV_TLSDESC_CALL; + } + bool isCSRSystemRegister() const { return isSystemRegister(); } bool isVTypeImm(unsigned N) const { @@ -584,7 +601,10 @@ struct RISCVOperand final : public MCParsedAsmOperand { if (!isImm()) return false; bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK); -if (VK == RISCVMCExpr::VK_RISCV_LO || VK == RISCVMCExpr::VK_RISCV_PCREL_LO) +if (VK == RISCVMCExpr::VK_RISCV_LO || +VK == RISCVMCExpr::VK_RISCV_PCREL_LO || +VK == RISCVMCExpr::VK_RISCV_TLSDESC_LOAD_LO || +VK == RISCVMCExpr::VK_RISCV_TLSDESC_ADD_LO) return true; // Given only Imm, ensuring that the actually specified constant is either // a sign
[Lldb-commits] [clang] [lldb] [libcxxabi] [lld] [flang] [llvm] [libc] [libcxx] [compiler-rt] [clang-tools-extra] [RISC-V][LLD] Add Support for RISC-V TLSDESC Relocations (PR #66916)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/66916 >From ce9772dd519a62025cf545ded306bf40c75f2924 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Tue, 19 Sep 2023 20:53:54 + Subject: [PATCH 01/17] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend This patch adds basic TLSDESC support for the global dynamic case in the RISC-V backend by adding new relocation types for TLSDESC, as prescribed in https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373. We also add a new pseudo instruction to simplify code generation. Possible improvements for the local dynamic case will be addressed in separate patches. The current implementation is only enabled when passing the -riscv-enable-tlsdesc flag. --- .../llvm/BinaryFormat/ELFRelocs/RISCV.def | 4 + .../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 97 +-- .../RISCV/MCTargetDesc/RISCVAsmBackend.cpp| 9 ++ .../Target/RISCV/MCTargetDesc/RISCVBaseInfo.h | 6 +- .../MCTargetDesc/RISCVELFObjectWriter.cpp | 15 +++ .../RISCV/MCTargetDesc/RISCVFixupKinds.h | 12 +++ .../RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp | 46 + .../Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp | 18 .../Target/RISCV/MCTargetDesc/RISCVMCExpr.h | 4 + llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 12 +++ .../Target/RISCV/RISCVExpandPseudoInsts.cpp | 53 ++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 23 - llvm/lib/Target/RISCV/RISCVISelLowering.h | 3 + llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 6 +- llvm/lib/Target/RISCV/RISCVInstrInfo.td | 36 +++ llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 4 + llvm/test/CodeGen/RISCV/tls-models.ll | 96 ++ 17 files changed, 432 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def b/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def index 9a126df0153119..94420395fa0fad 100644 --- a/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def +++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def @@ -55,3 +55,7 @@ ELF_RELOC(R_RISCV_SET32, 56) ELF_RELOC(R_RISCV_32_PCREL, 57) ELF_RELOC(R_RISCV_IRELATIVE, 58) ELF_RELOC(R_RISCV_PLT32, 59) +ELF_RELOC(R_RISCV_TLSDESC_HI20, 62) +ELF_RELOC(R_RISCV_TLSDESC_LOAD_LO12, 63) +ELF_RELOC(R_RISCV_TLSDESC_ADD_LO12, 64) +ELF_RELOC(R_RISCV_TLSDESC_CALL, 65) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 7d8d82e381313b..1303f5e85aeeb6 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -152,6 +152,7 @@ class RISCVAsmParser : public MCTargetAsmParser { // Helper to emit pseudo instruction "la.tls.gd" used in global-dynamic TLS // addressing. void emitLoadTLSGDAddress(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out); + void emitLoadTLSDescAddress(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out); // Helper to emit pseudo load/store instruction with a symbol. void emitLoadStoreSymbol(MCInst &Inst, unsigned Opcode, SMLoc IDLoc, @@ -170,6 +171,12 @@ class RISCVAsmParser : public MCTargetAsmParser { // 'add' is an overloaded mnemonic. bool checkPseudoAddTPRel(MCInst &Inst, OperandVector &Operands); + // Checks that a PseudoTLSDESCCall is using x5/t0 in its output operand. + // Enforcing this using a restricted register class for the output + // operand of PseudoTLSDESCCall results in a poor diagnostic due to the fact + // 'jalr' is an overloaded mnemonic. + bool checkPseudoTLSDESCCall(MCInst &Inst, OperandVector &Operands); + // Check instruction constraints. bool validateInstruction(MCInst &Inst, OperandVector &Operands); @@ -533,6 +540,16 @@ struct RISCVOperand final : public MCParsedAsmOperand { VK == RISCVMCExpr::VK_RISCV_TPREL_ADD; } + bool isTLSDESCCallSymbol() const { +int64_t Imm; +RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None; +// Must be of 'immediate' type but not a constant. +if (!isImm() || evaluateConstantImm(getImm(), Imm, VK)) + return false; +return RISCVAsmParser::classifySymbolRef(getImm(), VK) && + VK == RISCVMCExpr::VK_RISCV_TLSDESC_CALL; + } + bool isCSRSystemRegister() const { return isSystemRegister(); } bool isVTypeImm(unsigned N) const { @@ -584,7 +601,10 @@ struct RISCVOperand final : public MCParsedAsmOperand { if (!isImm()) return false; bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK); -if (VK == RISCVMCExpr::VK_RISCV_LO || VK == RISCVMCExpr::VK_RISCV_PCREL_LO) +if (VK == RISCVMCExpr::VK_RISCV_LO || +VK == RISCVMCExpr::VK_RISCV_PCREL_LO || +VK == RISCVMCExpr::VK_RISCV_TLSDESC_LOAD_LO || +VK == RISCVMCExpr::VK_RISCV_TLSDESC_ADD_LO) return true; // Given only Imm, ensuring that the actually specified constant is either // a sign
[Lldb-commits] [libcxxabi] [flang] [libc] [clang] [lldb] [compiler-rt] [clang-tools-extra] [llvm] [libcxx] [lld] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)
@@ -3,8 +3,8 @@ # Out of range immediates ## simm12 -flh ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047] -fsh ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047] +flh ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo/%tlsdesc_load_lo modifier or an integer in the range [-2048, 2047] ilovepi wrote: done. https://github.com/llvm/llvm-project/pull/66915 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [libc] [compiler-rt] [clang] [flang] [lld] [libcxxabi] [clang-tools-extra] [lldb] [llvm] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)
@@ -0,0 +1,44 @@ +# RUN: llvm-mc -filetype=obj -triple riscv32 < %s --defsym RV32=1 | llvm-objdump -d -M no-aliases - | FileCheck %s --check-prefixes=INST,RV32 +# RUN: llvm-mc -filetype=obj -triple riscv64 < %s | llvm-objdump -d -M no-aliases - | FileCheck %s --check-prefixes=INST,RV64 + +# RUN: not llvm-mc -triple riscv32 < %s --defsym RV32=1 --defsym ERR=1 2>&1 | FileCheck %s --check-prefixes=ERR +# RUN: not llvm-mc -triple riscv64 < %s --defsym ERR=1 2>&1 | FileCheck %s --check-prefixes=ERR + +start: # @start +# %bb.0:# %entry +.Ltlsdesc_hi0: + auipc a0, %tlsdesc_hi(a-4) + # INST: auipc a0, 0x0 + auipc a0, %tlsdesc_hi(unspecified) + # INST: auipc a0, 0x0 +.ifdef RV32 + lw a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0) + # RV32: lw a1, 0x0(a0) +.else + ld a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0) + #RV64: ld a1, 0x0(a0) +.endif + addia0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi0) + # INST: addi a0, a0, 0x0 + jalrt0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi0) + # INST: jalr t0, 0x0(a1) + add a0, a0, tp + # INST: add a0, a0, tp + ret + +## Check invalid usage +.ifdef ERR + auipc x1, %tlsdesc_call(foo) # ERR: :[[@LINE]]:12: error: operand must be a symbol with a %pcrel_hi/%got_pcrel_hi/%tls_ie_pcrel_hi/%tls_gd_pcrel_hi/%tlsdesc_hi modifier or an integer in the range ilovepi wrote: Thanks. done. https://github.com/llvm/llvm-project/pull/66915 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [libc] [flang] [libcxxabi] [libcxx] [lld] [clang] [clang-tools-extra] [compiler-rt] [lldb] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)
@@ -71,6 +71,18 @@ enum Fixups { // Used to generate an R_RISCV_ALIGN relocation, which indicates the linker // should fixup the alignment after linker relaxation. fixup_riscv_align, + // 20-bit fixup corresponding to %tlsdesc_hi(foo) for instructions like + // auipc + fixup_riscv_tlsdesc_hi20, ilovepi wrote: I've adjusted the comments per your suggestion, but could you elaborate more on what you're thinking w.r.t. `MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_TLSDESC_CALL)`? https://github.com/llvm/llvm-project/pull/66915 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxxabi] [lld] [libcxx] [clang-tools-extra] [libc] [flang] [compiler-rt] [lldb] [clang] [llvm] [RISC-V][LLD] Add Support for RISC-V TLSDESC Relocations (PR #66916)
ilovepi wrote: > The base branch can be edited if you click "Edit" near the title, which will > help reveal the lld side changes... hmm, I was hoping that would work, but the base branch is in my fork. I think to make it work correctly I'd have to be using the "user" branches in the main repository. Maybe its better to re-open both of them using `spr`? That still seems bad, but it will probably make everyone a bit happier. I'll look into this a bit more, because I agree, its very hard to understand what is intended to be reviewed here vs what's been included from the base patch. https://github.com/llvm/llvm-project/pull/66916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [libc] [clang] [lldb] [llvm] [libcxxabi] [clang-tools-extra] [compiler-rt] [flang] [lld] [RISC-V][LLD] Add Support for RISC-V TLSDESC Relocations (PR #66916)
ilovepi wrote: @MaskRay , do you think this is worth abandoning in favor of https://github.com/llvm/llvm-project/pull/77516? If so, I guess I'd also need to abandon https://github.com/llvm/llvm-project/pull/66915, which is unfortunate. https://github.com/llvm/llvm-project/pull/66916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [libc] [lldb] [lld] [llvm] [libcxxabi] [clang-tools-extra] [compiler-rt] [flang] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)
ilovepi wrote: @topperc @MaskRay , do either of you have strong feelings about abandoning this in favor of https://github.com/llvm/llvm-project/pull/77515? That PR was made w/ `spr` and should be a bit easier to understand/review (since it won't have merge or fixup commits) and will make the LLD side changes easier to stack. https://github.com/llvm/llvm-project/pull/66915 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [libc] [compiler-rt] [lld] [llvm] [libcxxabi] [lldb] [clang] [libcxx] [clang-tools-extra] [RISC-V][LLD] Add Support for RISC-V TLSDESC Relocations (PR #66916)
ilovepi wrote: sounds good. I'll go ahead and close this in favor of https://github.com/llvm/llvm-project/pull/77516 then, and leave the LLVM PR alone. https://github.com/llvm/llvm-project/pull/66916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [libcxxabi] [clang] [clang-tools-extra] [lld] [libcxx] [compiler-rt] [libc] [flang] [RISC-V][LLD] Add Support for RISC-V TLSDESC Relocations (PR #66916)
https://github.com/ilovepi closed https://github.com/llvm/llvm-project/pull/66916 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [libcxxabi] [clang] [clang-tools-extra] [lld] [libcxx] [compiler-rt] [libc] [flang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)
ilovepi wrote: As @MaskRay pointed out in #66916, there's a bit too much context in this review, so please just ignore my earlier question about moving to a stacked PR. https://github.com/llvm/llvm-project/pull/66915 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Report exit status message in lldb-dap, same as lldb cli (PR #89405)
ilovepi wrote: Hi, I think we're seeing some breakage in our CI after this patch. We see the lldb-api :: tools/lldb-dap/console/TestDAP_console.py test failing. https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8749666263730294449/overview ``` TEST 'lldb-api :: tools/lldb-dap/console/TestDAP_console.py' FAILED Script: -- /b/s/w/ir/x/w/lldb_install/python3/bin/python3 /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env ARCHIVER=/b/s/w/ir/x/w/cipd/bin/llvm-ar --env OBJCOPY=/b/s/w/ir/x/w/cipd/bin/llvm-objcopy --env LLVM_LIBS_DIR=/b/s/w/ir/x/w/llvm_build/./lib --env LLVM_INCLUDE_DIR=/b/s/w/ir/x/w/llvm_build/include --env LLVM_TOOLS_DIR=/b/s/w/ir/x/w/llvm_build/./bin --libcxx-include-dir /b/s/w/ir/x/w/llvm_build/include/c++/v1 --libcxx-include-target-dir /b/s/w/ir/x/w/llvm_build/include/aarch64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /b/s/w/ir/x/w/llvm_build/./lib/aarch64-unknown-linux-gnu --arch aarch64 --build-dir /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex --lldb-module-cache-dir /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /b/s/w/ir/x/w/llvm_build/./bin/lldb --compiler /b/s/w/ir/x/w/llvm_build/./bin/clang --dsymutil /b/s/w/ir/x/w/llvm_build/./bin/dsymutil --llvm-tools-dir /b/s/w/ir/x/w/llvm_build/./bin --lldb-libs-dir /b/s/w/ir/x/w/llvm_build/./lib --skip-category=pexpect /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/tools/lldb-dap/console -p TestDAP_console.py -- Exit Code: 1 Command Output (stdout): -- lldb version 19.0.0git (https://llvm.googlesource.com/a/llvm-project revision 5fb59e744783cf686e6a355c8331eeab90678c00) clang revision 5fb59e744783cf686e6a355c8331eeab90678c00 llvm revision 5fb59e744783cf686e6a355c8331eeab90678c00 Skipping the following test categories: ['pexpect', 'dsym', 'gmodules', 'debugserver', 'objc'] -- Command Output (stderr): -- Traceback (most recent call last): File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/dotest.py", line 8, in lldbsuite.test.run_suite() File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", line 1039, in run_suite visit("Test", dirpath, filenames) File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", line 700, in visit visit_file(dir, name) File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", line 643, in visit_file module = __import__(base) File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py", line 7, in import psutil ModuleNotFoundError: No module named 'psutil' -- ``` would you mind taking a look. CC: @mysterymath since he's the most familiar w/ our lldb build https://github.com/llvm/llvm-project/pull/89405 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libunwind] [lldb] [libc] [lld] [clang-tools-extra] [compiler-rt] [llvm] [clang] [libclc] [flang] [libcxxabi] [libcxx] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #
@@ -80,6 +80,11 @@ static cl::opt EnableRISCVDeadRegisterElimination( " them with stores to x0"), cl::init(true)); +// TODO: This should be controlled by -mtls-dialect= +cl::opt EnableRISCVTLSDESC("riscv-enable-tlsdesc", ilovepi wrote: That's a good suggestion. I was thinking of doing something like that as a follow up for the Clang driver patches, but I agree, its probably better to do it in this patch. https://github.com/llvm/llvm-project/pull/66915 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [libunwind] [compiler-rt] [lld] [flang] [libc] [llvm] [libclc] [libcxxabi] [libcxx] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #
ilovepi wrote: @topperc Is there anything else you think needs to be done for the code generation? https://github.com/llvm/llvm-project/pull/66915 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libunwind] [llvm] [libc] [flang] [clang-tools-extra] [clang] [libcxx] [lld] [compiler-rt] [lldb] [ELF] Implement R_RISCV_TLSDESC for RISC-V (PR #79239)
https://github.com/ilovepi approved this pull request. LGTM on my end. Thanks for all the help on this. https://github.com/llvm/llvm-project/pull/79239 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [compiler-rt] [clang-tools-extra] [clang] [libc] [libunwind] [lld] [libcxx] [flang] [mlir] [llvm] [ELF] Implement R_RISCV_TLSDESC for RISC-V (PR #79239)
@@ -513,29 +547,125 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { break; case R_RISCV_RELAX: -return; // Ignored (for now) - +return; + case R_RISCV_TLSDESC: +// The addend is stored in the second word. +if (config->is64) + write64le(loc + 8, val); +else + write32le(loc + 4, val); +break; default: llvm_unreachable("unknown relocation"); } } +static void tlsdescToIe(uint8_t *loc, const Relocation &rel, uint64_t val) { + switch (rel.type) { + case R_RISCV_TLSDESC_HI20: + case R_RISCV_TLSDESC_LOAD_LO12: +write32le(loc, 0x0013); // nop +break; + case R_RISCV_TLSDESC_ADD_LO12: +write32le(loc, utype(AUIPC, X_A0, hi20(val))); // auipc a0, +break; + case R_RISCV_TLSDESC_CALL: +if (config->is64) + write32le(loc, itype(LD, X_A0, X_A0, lo12(val))); // ld a0,(a0) +else + write32le(loc, itype(LW, X_A0, X_A0, lo12(val))); // lw a0,(a0) +break; + default: +llvm_unreachable("unsupported relocation for TLSDESC to IE"); + } +} + +static void tlsdescToLe(uint8_t *loc, const Relocation &rel, uint64_t val) { + switch (rel.type) { + case R_RISCV_TLSDESC_HI20: + case R_RISCV_TLSDESC_LOAD_LO12: +write32le(loc, 0x0013); // nop +return; + case R_RISCV_TLSDESC_ADD_LO12: +if (isInt<12>(val)) + write32le(loc, 0x0013); // nop +else + write32le(loc, utype(LUI, X_A0, hi20(val))); // lui a0, +return; + case R_RISCV_TLSDESC_CALL: +if (isInt<12>(val)) + write32le(loc, itype(ADDI, X_A0, 0, val)); // addi a0,zero, +else + write32le(loc, itype(ADDI, X_A0, X_A0, lo12(val))); // addi a0,a0, +return; + default: +llvm_unreachable("unsupported relocation for TLSDESC to LE"); + } +} + void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const { uint64_t secAddr = sec.getOutputSection()->addr; if (auto *s = dyn_cast(&sec)) secAddr += s->outSecOff; else if (auto *ehIn = dyn_cast(&sec)) secAddr += ehIn->getParent()->outSecOff; - for (size_t i = 0, size = sec.relocs().size(); i != size; ++i) { -const Relocation &rel = sec.relocs()[i]; + uint64_t tlsdescVal = 0; + bool isToLe = false; + const ArrayRef relocs = sec.relocs(); + for (size_t i = 0, size = relocs.size(); i != size; ++i) { +const Relocation &rel = relocs[i]; uint8_t *loc = buf + rel.offset; -const uint64_t val = +uint64_t val = sec.getRelocTargetVA(sec.file, rel.type, rel.addend, secAddr + rel.offset, *rel.sym, rel.expr); switch (rel.expr) { case R_RELAX_HINT: + continue; +case R_TLSDESC_PC: + // For R_RISCV_TLSDESC_HI20, store &got(sym)-PC to be used by the + // following two instructions L[DW] and ADDI. + if (rel.type == R_RISCV_TLSDESC_HI20) +tlsdescVal = val; + else +val = tlsdescVal; break; +case R_RELAX_TLS_GD_TO_IE: + // Only R_RISCV_TLSDESC_HI20 reaches here. tlsdescVal will be finalized + // after we see R_RISCV_TLSDESC_ADD_LO12 in the R_RELAX_TLS_GD_TO_LE case. + // The net effect is that tlsdescVal will be smaller than `val` to take + // into account of NOP instructions (in the absence of R_RISCV_RELAX) + // before AUIPC. + tlsdescVal = val + rel.offset; + isToLe = false; + if (!(i + 1 != relocs.size() && relocs[i + 1].type == R_RISCV_RELAX)) +tlsdescToIe(loc, rel, val); + continue; +case R_RELAX_TLS_GD_TO_LE: + // See the comment in handleTlsRelocation. For TLSDESC=>IE, + // R_RISCV_TLSDESC_{LOAD_LO12,ADD_LO12,CALL} also reach here. If isToIe is + // true, this is actually TLSDESC=>IE optimization. + if (rel.type == R_RISCV_TLSDESC_HI20) { +tlsdescVal = val; +isToLe = true; + } else { +if (!isToLe && rel.type == R_RISCV_TLSDESC_ADD_LO12) + tlsdescVal -= rel.offset; +val = tlsdescVal; + } + // When NOP conversion is eligible and R_RISCV_RELAX is present, don't + // write a NOP in case an unrelated instruction follows the current + // instruction. + if ((rel.type == R_RISCV_TLSDESC_HI20 || + rel.type == R_RISCV_TLSDESC_LOAD_LO12 || + (rel.type == R_RISCV_TLSDESC_ADD_LO12 && isToLe && !hi20(val))) && + i + 1 != relocs.size() && relocs[i + 1].type == R_RISCV_RELAX) ilovepi wrote: This is a pretty complicated condition ... I know its a one off, but do you think it makes sense to use a helper, just for the readability aspect? Maybe `canReplaceTlLSDESCWithNop()` or `isTLSDESCRelocElegibleForNop()`? It may make sense to at least use a helper for `!(i + 1 != relocs.size() && relocs[i + 1].type == R_RISCV_RELAX` since its used another time. I'm fine either way, since this is a style choice(and is really a nit), but I think it would be easier to understand of some of the complexity was abstracted
[Lldb-commits] [clang] [lldb] [libunwind] [libcxx] [compiler-rt] [libc] [flang] [lld] [llvm] [clang-tools-extra] [mlir] [ELF] Implement R_RISCV_TLSDESC for RISC-V (PR #79239)
@@ -513,29 +547,125 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { break; case R_RISCV_RELAX: -return; // Ignored (for now) - +return; + case R_RISCV_TLSDESC: +// The addend is stored in the second word. +if (config->is64) + write64le(loc + 8, val); +else + write32le(loc + 4, val); +break; default: llvm_unreachable("unknown relocation"); } } +static void tlsdescToIe(uint8_t *loc, const Relocation &rel, uint64_t val) { + switch (rel.type) { + case R_RISCV_TLSDESC_HI20: + case R_RISCV_TLSDESC_LOAD_LO12: +write32le(loc, 0x0013); // nop +break; + case R_RISCV_TLSDESC_ADD_LO12: +write32le(loc, utype(AUIPC, X_A0, hi20(val))); // auipc a0, +break; + case R_RISCV_TLSDESC_CALL: +if (config->is64) + write32le(loc, itype(LD, X_A0, X_A0, lo12(val))); // ld a0,(a0) +else + write32le(loc, itype(LW, X_A0, X_A0, lo12(val))); // lw a0,(a0) +break; + default: +llvm_unreachable("unsupported relocation for TLSDESC to IE"); + } +} + +static void tlsdescToLe(uint8_t *loc, const Relocation &rel, uint64_t val) { + switch (rel.type) { + case R_RISCV_TLSDESC_HI20: + case R_RISCV_TLSDESC_LOAD_LO12: +write32le(loc, 0x0013); // nop +return; + case R_RISCV_TLSDESC_ADD_LO12: +if (isInt<12>(val)) + write32le(loc, 0x0013); // nop +else + write32le(loc, utype(LUI, X_A0, hi20(val))); // lui a0, +return; + case R_RISCV_TLSDESC_CALL: +if (isInt<12>(val)) + write32le(loc, itype(ADDI, X_A0, 0, val)); // addi a0,zero, +else + write32le(loc, itype(ADDI, X_A0, X_A0, lo12(val))); // addi a0,a0, +return; + default: +llvm_unreachable("unsupported relocation for TLSDESC to LE"); + } +} + void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const { uint64_t secAddr = sec.getOutputSection()->addr; if (auto *s = dyn_cast(&sec)) secAddr += s->outSecOff; else if (auto *ehIn = dyn_cast(&sec)) secAddr += ehIn->getParent()->outSecOff; - for (size_t i = 0, size = sec.relocs().size(); i != size; ++i) { -const Relocation &rel = sec.relocs()[i]; + uint64_t tlsdescVal = 0; + bool isToLe = false; + const ArrayRef relocs = sec.relocs(); + for (size_t i = 0, size = relocs.size(); i != size; ++i) { +const Relocation &rel = relocs[i]; uint8_t *loc = buf + rel.offset; -const uint64_t val = +uint64_t val = sec.getRelocTargetVA(sec.file, rel.type, rel.addend, secAddr + rel.offset, *rel.sym, rel.expr); switch (rel.expr) { case R_RELAX_HINT: + continue; +case R_TLSDESC_PC: + // For R_RISCV_TLSDESC_HI20, store &got(sym)-PC to be used by the + // following two instructions L[DW] and ADDI. + if (rel.type == R_RISCV_TLSDESC_HI20) +tlsdescVal = val; + else +val = tlsdescVal; break; +case R_RELAX_TLS_GD_TO_IE: + // Only R_RISCV_TLSDESC_HI20 reaches here. tlsdescVal will be finalized + // after we see R_RISCV_TLSDESC_ADD_LO12 in the R_RELAX_TLS_GD_TO_LE case. + // The net effect is that tlsdescVal will be smaller than `val` to take + // into account of NOP instructions (in the absence of R_RISCV_RELAX) + // before AUIPC. + tlsdescVal = val + rel.offset; + isToLe = false; + if (!(i + 1 != relocs.size() && relocs[i + 1].type == R_RISCV_RELAX)) +tlsdescToIe(loc, rel, val); + continue; +case R_RELAX_TLS_GD_TO_LE: + // See the comment in handleTlsRelocation. For TLSDESC=>IE, + // R_RISCV_TLSDESC_{LOAD_LO12,ADD_LO12,CALL} also reach here. If isToIe is + // true, this is actually TLSDESC=>IE optimization. + if (rel.type == R_RISCV_TLSDESC_HI20) { +tlsdescVal = val; +isToLe = true; + } else { +if (!isToLe && rel.type == R_RISCV_TLSDESC_ADD_LO12) + tlsdescVal -= rel.offset; +val = tlsdescVal; + } + // When NOP conversion is eligible and R_RISCV_RELAX is present, don't + // write a NOP in case an unrelated instruction follows the current + // instruction. + if ((rel.type == R_RISCV_TLSDESC_HI20 || + rel.type == R_RISCV_TLSDESC_LOAD_LO12 || + (rel.type == R_RISCV_TLSDESC_ADD_LO12 && isToLe && !hi20(val))) && + i + 1 != relocs.size() && relocs[i + 1].type == R_RISCV_RELAX) ilovepi wrote: > I am thinking of a simplification where I only check whether > R_RISCV_TLSDESC_HI20 has an associated R_RISCV_RELAX. If yes, apply > relaxation whether or not the following 3 instructions has an associated > R_RISCV_RELAX. > > Then, I just use another variable to hold "whether there is R_RISCV_RELAX" > and arguably the straight line code will be more readable than introducing a > function call. > That sounds like a nice approach. > On the LLVM side, relaxation can be enabled by adding R_RISCV_RELAX to just > th
[Lldb-commits] [libunwind] [clang] [lld] [libcxx] [flang] [mlir] [compiler-rt] [libc] [clang-tools-extra] [llvm] [lldb] [Driver, CodeGen] Support -mtls-dialect= (PR #79256)
https://github.com/ilovepi approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/79256 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [lld] [libc] [libcxx] [llvm] [clang] [lldb] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/80480 >From 2793f30243a0b93d8a1f52343ab974bf9eef4e03 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Tue, 22 Aug 2023 15:24:03 + Subject: [PATCH] [CMAKE] Enable FatLTO as a build option for LLVM --- clang/cmake/caches/Fuchsia-stage2.cmake| 1 + llvm/cmake/modules/AddLLVM.cmake | 11 +-- llvm/cmake/modules/HandleLLVMOptions.cmake | 6 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index eee37c5e7901f..d5a1662cbf4aa 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -11,6 +11,7 @@ set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING " set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "") +set(LLVM_ENABLE_FATLTO ON CACHE BOOL "") set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "") set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "") set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 5e98961855282..26ba092a82948 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1621,8 +1621,15 @@ function(add_unittest test_suite test_name) # The runtime benefits of LTO don't outweight the compile time costs for tests. if(LLVM_ENABLE_LTO) if((UNIX OR MINGW) AND LINKER_IS_LLD) - set_property(TARGET ${test_name} APPEND_STRING PROPERTY -LINK_FLAGS " -Wl,--lto-O0") + if(LLVM_ENABLE_FATLTO) +# When using FatLTO, just use relocatable linking. +set_property(TARGET ${test_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--no-fat-lto-objects") +set_property(TARGET ${test_name} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-lto") + else() +set_property(TARGET ${test_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--lto-O0") + endif() elseif(LINKER_IS_LLD_LINK) set_property(TARGET ${test_name} APPEND_STRING PROPERTY LINK_FLAGS " /opt:lldlto=0") diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 0699a8586fcc7..05bbe98ef96f8 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -32,6 +32,8 @@ endif() set(LLVM_ENABLE_LTO OFF CACHE STRING "Build LLVM with LTO. May be specified as Thin or Full to use a particular kind of LTO") string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) +option(LLVM_ENABLE_FATLTO "Build LLVM with -ffat-lto-objects." OFF) + # Ninja Job Pool support # The following only works with the Ninja generator in CMake >= 3.0. set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING @@ -1251,6 +1253,10 @@ elseif(LLVM_ENABLE_LTO) endif() endif() +if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX)) +append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) +endif() + # Set an AIX default for LLVM_EXPORT_SYMBOLS_FOR_PLUGINS based on whether we are # doing dynamic linking (see below). set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_AIX_default OFF) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [lld] [lldb] [clang] [libcxx] [llvm] [libc] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)
https://github.com/ilovepi ready_for_review https://github.com/llvm/llvm-project/pull/80480 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [lld] [libc] [clang] [libcxx] [flang] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)
ilovepi wrote: This speeds up a 2 stage build by about 3 minutes, tests time are still much closer than expected. Locally I saw a bout a 5-8% speedup to build clang unit tests, but maybe the unit tests are too small in the overall test regime to make a difference. I'll try to collect more performance numbers locally w.r.t. the test times. https://github.com/llvm/llvm-project/pull/80480 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [lld] [libc] [clang] [libcxx] [flang] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)
@@ -1251,6 +1253,10 @@ elseif(LLVM_ENABLE_LTO) endif() endif() +if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX)) +append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) ilovepi wrote: Dang, I thought I had done that. That's probably why I'm seeing an odd result. Thank you. https://github.com/llvm/llvm-project/pull/80480 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [lld] [libc] [clang] [libcxx] [flang] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/80480 >From 2793f30243a0b93d8a1f52343ab974bf9eef4e03 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Tue, 22 Aug 2023 15:24:03 + Subject: [PATCH 1/2] [CMAKE] Enable FatLTO as a build option for LLVM --- clang/cmake/caches/Fuchsia-stage2.cmake| 1 + llvm/cmake/modules/AddLLVM.cmake | 11 +-- llvm/cmake/modules/HandleLLVMOptions.cmake | 6 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index eee37c5e7901f..d5a1662cbf4aa 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -11,6 +11,7 @@ set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING " set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "") +set(LLVM_ENABLE_FATLTO ON CACHE BOOL "") set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "") set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "") set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 5e98961855282..26ba092a82948 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1621,8 +1621,15 @@ function(add_unittest test_suite test_name) # The runtime benefits of LTO don't outweight the compile time costs for tests. if(LLVM_ENABLE_LTO) if((UNIX OR MINGW) AND LINKER_IS_LLD) - set_property(TARGET ${test_name} APPEND_STRING PROPERTY -LINK_FLAGS " -Wl,--lto-O0") + if(LLVM_ENABLE_FATLTO) +# When using FatLTO, just use relocatable linking. +set_property(TARGET ${test_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--no-fat-lto-objects") +set_property(TARGET ${test_name} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-lto") + else() +set_property(TARGET ${test_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--lto-O0") + endif() elseif(LINKER_IS_LLD_LINK) set_property(TARGET ${test_name} APPEND_STRING PROPERTY LINK_FLAGS " /opt:lldlto=0") diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 0699a8586fcc7..05bbe98ef96f8 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -32,6 +32,8 @@ endif() set(LLVM_ENABLE_LTO OFF CACHE STRING "Build LLVM with LTO. May be specified as Thin or Full to use a particular kind of LTO") string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) +option(LLVM_ENABLE_FATLTO "Build LLVM with -ffat-lto-objects." OFF) + # Ninja Job Pool support # The following only works with the Ninja generator in CMake >= 3.0. set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING @@ -1251,6 +1253,10 @@ elseif(LLVM_ENABLE_LTO) endif() endif() +if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX)) +append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) +endif() + # Set an AIX default for LLVM_EXPORT_SYMBOLS_FOR_PLUGINS based on whether we are # doing dynamic linking (see below). set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_AIX_default OFF) >From 9ee6e49745ec16578c8160fd109b175f7a217edf Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Fri, 2 Feb 2024 13:09:18 -0800 Subject: [PATCH 2/2] Add -ffat-lto-objects to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS --- llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 05bbe98ef96f8..6abdddf5421fa 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -1254,7 +1254,7 @@ elseif(LLVM_ENABLE_LTO) endif() if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX)) -append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) + append("-ffat-lto-objects" CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) endif() # Set an AIX default for LLVM_EXPORT_SYMBOLS_FOR_PLUGINS based on whether we are ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [lld] [mlir] [libc] [clang-tools-extra] [clang] [libcxx] [flang] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/80480 >From 2793f30243a0b93d8a1f52343ab974bf9eef4e03 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Tue, 22 Aug 2023 15:24:03 + Subject: [PATCH 1/2] [CMAKE] Enable FatLTO as a build option for LLVM --- clang/cmake/caches/Fuchsia-stage2.cmake| 1 + llvm/cmake/modules/AddLLVM.cmake | 11 +-- llvm/cmake/modules/HandleLLVMOptions.cmake | 6 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index eee37c5e7901f..d5a1662cbf4aa 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -11,6 +11,7 @@ set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING " set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "") +set(LLVM_ENABLE_FATLTO ON CACHE BOOL "") set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "") set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "") set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 5e98961855282..26ba092a82948 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1621,8 +1621,15 @@ function(add_unittest test_suite test_name) # The runtime benefits of LTO don't outweight the compile time costs for tests. if(LLVM_ENABLE_LTO) if((UNIX OR MINGW) AND LINKER_IS_LLD) - set_property(TARGET ${test_name} APPEND_STRING PROPERTY -LINK_FLAGS " -Wl,--lto-O0") + if(LLVM_ENABLE_FATLTO) +# When using FatLTO, just use relocatable linking. +set_property(TARGET ${test_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--no-fat-lto-objects") +set_property(TARGET ${test_name} APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-lto") + else() +set_property(TARGET ${test_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--lto-O0") + endif() elseif(LINKER_IS_LLD_LINK) set_property(TARGET ${test_name} APPEND_STRING PROPERTY LINK_FLAGS " /opt:lldlto=0") diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 0699a8586fcc7..05bbe98ef96f8 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -32,6 +32,8 @@ endif() set(LLVM_ENABLE_LTO OFF CACHE STRING "Build LLVM with LTO. May be specified as Thin or Full to use a particular kind of LTO") string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) +option(LLVM_ENABLE_FATLTO "Build LLVM with -ffat-lto-objects." OFF) + # Ninja Job Pool support # The following only works with the Ninja generator in CMake >= 3.0. set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING @@ -1251,6 +1253,10 @@ elseif(LLVM_ENABLE_LTO) endif() endif() +if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX)) +append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) +endif() + # Set an AIX default for LLVM_EXPORT_SYMBOLS_FOR_PLUGINS based on whether we are # doing dynamic linking (see below). set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_AIX_default OFF) >From 9ee6e49745ec16578c8160fd109b175f7a217edf Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Fri, 2 Feb 2024 13:09:18 -0800 Subject: [PATCH 2/2] Add -ffat-lto-objects to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS --- llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 05bbe98ef96f8..6abdddf5421fa 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -1254,7 +1254,7 @@ elseif(LLVM_ENABLE_LTO) endif() if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX)) -append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) + append("-ffat-lto-objects" CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) endif() # Set an AIX default for LLVM_EXPORT_SYMBOLS_FOR_PLUGINS based on whether we are ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
ilovepi wrote: Hi, we're seeing some breakages, similar to the above in our debugger tests with this patch. A failing bot can be found here: https://luci-milo.appspot.com/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.x64-debug/b8764552260903625809/overview You can find a fuller discussion in our bugtracker: https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=136182. The problem in our test is that the `DW_AT_const_value`, no longer seems to be in the expected place, similar to @dyung's issue above. Is there an ETA on when your fix will land? If it won't be soon, would you mind reverting until you can address this issue? https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
ilovepi wrote: Fantastic! https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
ilovepi wrote: I'm unclear on the specifics of the check, but it's probably something we can adjust if that is the long-term solution. CC @petrhosek Since he was interested in getting this resolved soon. https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)
ilovepi wrote: The test output isn't appropriate for the commit body, so please remove that. I also see many files were changed in this PR that aren't related. Many of them seem to be changes to the line endings in files. Please double check your editor and git settings to be sure they follow the project rules https://github.com/llvm/llvm-project/blob/main/llvm/docs/GettingStarted.rst#id24 details git settings https://llvm.org/docs/DeveloperPolicy.html And https://llvm.org/docs/ProgrammersManual.html have details related to project norms and best practices. I'll take a deeper look at your PR once it only has clang-doc related changes. https://github.com/llvm/llvm-project/pull/132360 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)
@@ -0,0 +1,32 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s +// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass + +#define DECLARE_METHODS \ +/** + * @brief Declare a method to calculate the sum of two numbers + */ \ +int Add(int a, int b) \ +{ \ +return a + b; \ +} + +// MD-MyClass: ### Add ilovepi wrote: ```suggestion // MD-MYCLASS: ### Add ``` Use all caps for check prefixes https://github.com/llvm/llvm-project/pull/132360 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)
@@ -0,0 +1,32 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s +// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass + +#define DECLARE_METHODS \ +/** + * @brief Declare a method to calculate the sum of two numbers + */ \ +int Add(int a, int b) \ +{ \ +return a + b; \ +} + +// MD-MyClass: ### Add +// MD-MyClass: *public int Add(int a, int b)* +// MD-MyClass: **brief** Declare a method to calculate the sum of two numbers + +// HTML-MyClass: public int Add(int a, int b) +// HTML-MyClass: brief +// HTML-MyClass: Declare a method to calculate the sum of two numbers + + +class MyClass { ilovepi wrote: What is this class testing? It's not clear what property you're trying to exercise. I see you expect the macro to expand in the class, but I don't think you're testing what you think you are. https://github.com/llvm/llvm-project/pull/132360 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] [clang-doc] Add regression test for test comments in macros (PR #132360)
@@ -0,0 +1,32 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s +// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass + +#define DECLARE_METHODS \ +/** + * @brief Declare a method to calculate the sum of two numbers ilovepi wrote: > I also rarely see this kind comment in comments, whether in books or in real > projects. But this issue display like this. Maybe I understood this wrongly. ah, no, I've confused this with a different issue. Apologies. I should take my own advice not to review code first thing in the morning XD. Lets just make it syntactically correct using trailing `\`. If the markdown comes out w/ an extra `\`, we can file a bug for that and handle that separately. You can confirm what's going on by dumping the AST from clang, or by using some of the debug output from clang-doc. https://github.com/llvm/llvm-project/pull/132360 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)
ilovepi wrote: Also, please change the PR title to ``` [clang-doc] Add regression test for test comments in macros ``` The body should contain `Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test.` https://github.com/llvm/llvm-project/pull/132360 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)
@@ -0,0 +1,32 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s +// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass + +#define DECLARE_METHODS \ +/** + * @brief Declare a method to calculate the sum of two numbers ilovepi wrote: I don't think this comment is in the macro, did you intend it to be? Also as I understand it the bug wasn't filed about comments within macros, which I seldom see. But about comments attached to macros. I'd also suggest a simpler macro that doesn't define a full function (which also doesn't appear to actually be part of the macro.). Maybe the macro could be something like ```c++ /// Your doc comments #define ADD(a, b) a+b ``` https://github.com/llvm/llvm-project/pull/132360 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)
@@ -0,0 +1,32 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s +// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s ilovepi wrote: Lets move this down w/ the HTML FileCheck lines so they're grouped together. I'd also suggest renaming the test file to DR-59819.cpp, which is a common way to indicate that its a regression test (DR stands for Defect Report, and the number is the issue number. I'm fine to leave it with a more readable name, but in that case I'd prefer `comments-in-macros.cpp` and a comment at the top of the file describing the purpose and properties you're testing for. https://github.com/llvm/llvm-project/pull/132360 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix SBTarget::ReadInstruction with flavor (PR #134626)
ilovepi wrote: I think we're seeing this persist on x86_64 mac bots https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/lldb-mac-x64/b8717871333718166241/infra I'm not sure what the right spelling is to opt out.. I think @DavidSpickett's original suggestion may work better if we need to opt out more than just windows. https://github.com/llvm/llvm-project/pull/134626 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix SBTarget::ReadInstruction with flavor (PR #134626)
ilovepi wrote: @da-viper Ah, shoot. Sorry for the noise, I think it may have been https://github.com/llvm/llvm-project/commit/2fd860c1f559c0b0be66cc000e38270a04d0a1a3, which was just reverted. thanks for taking a look. :) https://github.com/llvm/llvm-project/pull/134626 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits