[llvm-branch-commits] [llvm] AsmPrinter: Avoid use of MachineFunction::getMMI (PR #99751)
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/99751 None >From 31d06e474c36bdba7169e7ad68e48b32cfd34202 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 20 Jul 2024 00:01:47 +0400 Subject: [PATCH] AsmPrinter: Avoid use of MachineFunction::getMMI --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 11 ++- llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b46a6d348413b..91b5703944f3d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1669,8 +1669,8 @@ void AsmPrinter::emitPCSections(const MachineFunction &MF) { } /// Returns true if function begin and end labels should be emitted. -static bool needFuncLabels(const MachineFunction &MF) { - MachineModuleInfo &MMI = MF.getMMI(); +static bool needFuncLabels(const MachineFunction &MF, + const MachineModuleInfo &MMI) { if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo() || MF.getFunction().hasMetadata(LLVMContext::MD_pcsections)) @@ -1944,7 +1944,7 @@ void AsmPrinter::emitFunctionBody() { // are automatically sized. bool EmitFunctionSize = MAI->hasDotTypeDotSizeDirective() && !TT.isWasm(); - if (needFuncLabels(*MF) || EmitFunctionSize) { + if (needFuncLabels(*MF, *MMI) || EmitFunctionSize) { // Create a symbol for the end of function. CurrentFnEnd = createTempSymbol("func_end"); OutStreamer->emitLabel(CurrentFnEnd); @@ -2587,8 +2587,9 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { bool NeedsLocalForSize = MAI->needsLocalForSize(); if (F.hasFnAttribute("patchable-function-entry") || F.hasFnAttribute("function-instrument") || - F.hasFnAttribute("xray-instruction-threshold") || needFuncLabels(MF) || - NeedsLocalForSize || MF.getTarget().Options.EmitStackSizeSection || + F.hasFnAttribute("xray-instruction-threshold") || + needFuncLabels(MF, *MMI) || NeedsLocalForSize || + MF.getTarget().Options.EmitStackSizeSection || MF.getTarget().Options.BBAddrMap || MF.hasBBLabels()) { CurrentFnBegin = createTempSymbol("func_begin"); if (NeedsLocalForSize) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 49f3fc1a1fa59..087ee02a7f2b3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -90,7 +90,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { shouldEmitLSDA = shouldEmitPersonality && LSDAEncoding != dwarf::DW_EH_PE_omit; - const MCAsmInfo &MAI = *MF->getMMI().getContext().getAsmInfo(); + const MCAsmInfo &MAI = *MF->getContext().getAsmInfo(); if (MAI.getExceptionHandlingType() != ExceptionHandling::None) shouldEmitCFI = MAI.usesCFIForEH() && (shouldEmitPersonality || shouldEmitMoves); ___ 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] AsmPrinter: Avoid use of MachineFunction::getMMI (PR #99751)
arsenm wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/99751?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#99751** https://app.graphite.dev/github/pr/llvm/llvm-project/99751?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> đŸ‘ˆ * **#99750** https://app.graphite.dev/github/pr/llvm/llvm-project/99750?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about stacking. Join @arsenm and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="11px" height="11px"/> Graphite https://github.com/llvm/llvm-project/pull/99751 ___ 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] AsmPrinter: Avoid use of MachineFunction::getMMI (PR #99751)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/99751 ___ 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] AsmPrinter: Avoid use of MachineFunction::getMMI (PR #99751)
llvmbot wrote: @llvm/pr-subscribers-debuginfo Author: Matt Arsenault (arsenm) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/99751.diff 2 Files Affected: - (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+6-5) - (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (+1-1) ``diff diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b46a6d348413b..91b5703944f3d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1669,8 +1669,8 @@ void AsmPrinter::emitPCSections(const MachineFunction &MF) { } /// Returns true if function begin and end labels should be emitted. -static bool needFuncLabels(const MachineFunction &MF) { - MachineModuleInfo &MMI = MF.getMMI(); +static bool needFuncLabels(const MachineFunction &MF, + const MachineModuleInfo &MMI) { if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo() || MF.getFunction().hasMetadata(LLVMContext::MD_pcsections)) @@ -1944,7 +1944,7 @@ void AsmPrinter::emitFunctionBody() { // are automatically sized. bool EmitFunctionSize = MAI->hasDotTypeDotSizeDirective() && !TT.isWasm(); - if (needFuncLabels(*MF) || EmitFunctionSize) { + if (needFuncLabels(*MF, *MMI) || EmitFunctionSize) { // Create a symbol for the end of function. CurrentFnEnd = createTempSymbol("func_end"); OutStreamer->emitLabel(CurrentFnEnd); @@ -2587,8 +2587,9 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { bool NeedsLocalForSize = MAI->needsLocalForSize(); if (F.hasFnAttribute("patchable-function-entry") || F.hasFnAttribute("function-instrument") || - F.hasFnAttribute("xray-instruction-threshold") || needFuncLabels(MF) || - NeedsLocalForSize || MF.getTarget().Options.EmitStackSizeSection || + F.hasFnAttribute("xray-instruction-threshold") || + needFuncLabels(MF, *MMI) || NeedsLocalForSize || + MF.getTarget().Options.EmitStackSizeSection || MF.getTarget().Options.BBAddrMap || MF.hasBBLabels()) { CurrentFnBegin = createTempSymbol("func_begin"); if (NeedsLocalForSize) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 49f3fc1a1fa59..087ee02a7f2b3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -90,7 +90,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { shouldEmitLSDA = shouldEmitPersonality && LSDAEncoding != dwarf::DW_EH_PE_omit; - const MCAsmInfo &MAI = *MF->getMMI().getContext().getAsmInfo(); + const MCAsmInfo &MAI = *MF->getContext().getAsmInfo(); if (MAI.getExceptionHandlingType() != ExceptionHandling::None) shouldEmitCFI = MAI.usesCFIForEH() && (shouldEmitPersonality || shouldEmitMoves); `` https://github.com/llvm/llvm-project/pull/99751 ___ 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] AsmPrinter: Avoid use of MachineFunction::getMMI (PR #99751)
https://github.com/s-barannikov approved this pull request. https://github.com/llvm/llvm-project/pull/99751 ___ 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++][spaceship] Marks P1614 as complete. (PR #99375)
@@ -1,5 +1,5 @@ "Number","Name","Status","First released version" mordante wrote: This page has been shipped in several libc++ releases. I strongly like to have it shipped in one release where P1614 is finished. I already have a TODO on my private list to remove it after branching LLVM 20. https://github.com/llvm/llvm-project/pull/99375 ___ 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] AsmPrinter: Avoid use of MachineFunction::getMMI (PR #99751)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/99751 >From c10130fca09ad69a523969af1a5e24a11505fd5f Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 20 Jul 2024 00:01:47 +0400 Subject: [PATCH] AsmPrinter: Avoid use of MachineFunction::getMMI --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 11 ++- llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b46a6d348413b..91b5703944f3d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1669,8 +1669,8 @@ void AsmPrinter::emitPCSections(const MachineFunction &MF) { } /// Returns true if function begin and end labels should be emitted. -static bool needFuncLabels(const MachineFunction &MF) { - MachineModuleInfo &MMI = MF.getMMI(); +static bool needFuncLabels(const MachineFunction &MF, + const MachineModuleInfo &MMI) { if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo() || MF.getFunction().hasMetadata(LLVMContext::MD_pcsections)) @@ -1944,7 +1944,7 @@ void AsmPrinter::emitFunctionBody() { // are automatically sized. bool EmitFunctionSize = MAI->hasDotTypeDotSizeDirective() && !TT.isWasm(); - if (needFuncLabels(*MF) || EmitFunctionSize) { + if (needFuncLabels(*MF, *MMI) || EmitFunctionSize) { // Create a symbol for the end of function. CurrentFnEnd = createTempSymbol("func_end"); OutStreamer->emitLabel(CurrentFnEnd); @@ -2587,8 +2587,9 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { bool NeedsLocalForSize = MAI->needsLocalForSize(); if (F.hasFnAttribute("patchable-function-entry") || F.hasFnAttribute("function-instrument") || - F.hasFnAttribute("xray-instruction-threshold") || needFuncLabels(MF) || - NeedsLocalForSize || MF.getTarget().Options.EmitStackSizeSection || + F.hasFnAttribute("xray-instruction-threshold") || + needFuncLabels(MF, *MMI) || NeedsLocalForSize || + MF.getTarget().Options.EmitStackSizeSection || MF.getTarget().Options.BBAddrMap || MF.hasBBLabels()) { CurrentFnBegin = createTempSymbol("func_begin"); if (NeedsLocalForSize) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 49f3fc1a1fa59..087ee02a7f2b3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -90,7 +90,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { shouldEmitLSDA = shouldEmitPersonality && LSDAEncoding != dwarf::DW_EH_PE_omit; - const MCAsmInfo &MAI = *MF->getMMI().getContext().getAsmInfo(); + const MCAsmInfo &MAI = *MF->getContext().getAsmInfo(); if (MAI.getExceptionHandlingType() != ExceptionHandling::None) shouldEmitCFI = MAI.usesCFIForEH() && (shouldEmitPersonality || shouldEmitMoves); ___ 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] [libc] 9130500 - Revert "Revert "[libc] implement cached process/thread identity" (#99559)"
Author: Schrodinger ZHU Yifan Date: 2024-07-20T08:04:24-07:00 New Revision: 9130500ce71f5ec38182ac8b397d8e6ab846782e URL: https://github.com/llvm/llvm-project/commit/9130500ce71f5ec38182ac8b397d8e6ab846782e DIFF: https://github.com/llvm/llvm-project/commit/9130500ce71f5ec38182ac8b397d8e6ab846782e.diff LOG: Revert "Revert "[libc] implement cached process/thread identity" (#99559)" This reverts commit 415ca24f8e392bca6f6295e667be2f02211fc303. Added: libc/src/__support/OSUtil/linux/pid.cpp libc/src/__support/OSUtil/pid.h libc/src/__support/threads/tid.h libc/src/unistd/gettid.cpp libc/src/unistd/gettid.h libc/test/src/unistd/gettid_test.cpp Modified: libc/config/config.json libc/config/linux/aarch64/entrypoints.txt libc/config/linux/riscv/entrypoints.txt libc/config/linux/x86_64/entrypoints.txt libc/docs/configure.rst libc/docs/dev/undefined_behavior.rst libc/spec/posix.td libc/src/__support/OSUtil/CMakeLists.txt libc/src/__support/OSUtil/linux/CMakeLists.txt libc/src/__support/threads/CMakeLists.txt libc/src/__support/threads/linux/CMakeLists.txt libc/src/__support/threads/linux/rwlock.h libc/src/__support/threads/linux/thread.cpp libc/src/__support/threads/thread.h libc/src/unistd/CMakeLists.txt libc/src/unistd/getpid.h libc/src/unistd/linux/CMakeLists.txt libc/src/unistd/linux/fork.cpp libc/src/unistd/linux/getpid.cpp libc/startup/linux/CMakeLists.txt libc/startup/linux/do_start.cpp libc/test/integration/src/unistd/CMakeLists.txt libc/test/integration/src/unistd/fork_test.cpp libc/test/src/unistd/CMakeLists.txt Removed: diff --git a/libc/config/config.json b/libc/config/config.json index 94bfed894c173..0fc88e2b8dbd5 100644 --- a/libc/config/config.json +++ b/libc/config/config.json @@ -75,6 +75,16 @@ "LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE": { "value": 1073741824, "doc": "Default size for the constinit freelist buffer used for the freelist malloc implementation (default 1o 1GB)." +}, + }, + "unistd": { +"LIBC_CONF_ENABLE_TID_CACHE": { + "value": true, + "doc": "Enable caching mechanism for gettid to avoid syscall (only effective in fullbuild mode, default to true). Please refer to Undefined Behavior documentation for implications." +}, +"LIBC_CONF_ENABLE_PID_CACHE": { + "value": true, + "doc": "Enable caching mechanism for getpid to avoid syscall (default to true). Please refer to Undefined Behavior documentation for implications." } }, "math": { diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index e2f6bd74bb694..8afd3fb67197e 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -297,6 +297,7 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.unistd.geteuid libc.src.unistd.getpid libc.src.unistd.getppid +libc.src.unistd.gettid libc.src.unistd.getuid libc.src.unistd.isatty libc.src.unistd.link diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 33dd8d06173b2..f61936b758bd9 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -296,6 +296,7 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.unistd.geteuid libc.src.unistd.getpid libc.src.unistd.getppid +libc.src.unistd.gettid libc.src.unistd.getuid libc.src.unistd.isatty libc.src.unistd.link diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 7309e95644c74..f2029da83ee71 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -315,6 +315,7 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.unistd.geteuid libc.src.unistd.getpid libc.src.unistd.getppid +libc.src.unistd.gettid libc.src.unistd.getuid libc.src.unistd.isatty libc.src.unistd.link diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst index dfb35f6a6611a..5c55e4ab0f181 100644 --- a/libc/docs/configure.rst +++ b/libc/docs/configure.rst @@ -52,3 +52,6 @@ to learn about the defaults for your platform and target. * **"string" options** - ``LIBC_CONF_MEMSET_X86_USE_SOFTWARE_PREFETCHING``: Inserts prefetch for write instructions (PREFETCHW) for memset on x86 to recover performance when hardware prefetcher is disabled. - ``LIBC_CONF_STRING_UNSAFE_WIDE_READ``: Read more than a byte at a time to perform byte-string operations like strlen. +* **"unistd" options** +- ``LIBC_CONF_ENABLE_PID_CACHE``: Enable caching mechanism for getpid to avoid syscall (default to true). Please refer to Undefined Behavior documentation for implications. +- ``LIBC_CONF_ENABLE_TID_CACHE``: Enable caching mechanism for gettid to avoid sysca
[llvm-branch-commits] [libc] 52ea296 - [libc] fix config syntax error
Author: Schrodinger ZHU Yifan Date: 2024-07-20T08:09:24-07:00 New Revision: 52ea2963b4ae0de27816e7f1b3be45f4f021999a URL: https://github.com/llvm/llvm-project/commit/52ea2963b4ae0de27816e7f1b3be45f4f021999a DIFF: https://github.com/llvm/llvm-project/commit/52ea2963b4ae0de27816e7f1b3be45f4f021999a.diff LOG: [libc] fix config syntax error Added: Modified: libc/config/config.json Removed: diff --git a/libc/config/config.json b/libc/config/config.json index 0fc88e2b8dbd5..92e1c956652ad 100644 --- a/libc/config/config.json +++ b/libc/config/config.json @@ -75,7 +75,7 @@ "LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE": { "value": 1073741824, "doc": "Default size for the constinit freelist buffer used for the freelist malloc implementation (default 1o 1GB)." -}, +} }, "unistd": { "LIBC_CONF_ENABLE_TID_CACHE": { @@ -99,4 +99,4 @@ "doc": "Configures sorting algorithm for qsort and qsort_r. Values accepted are LIBC_QSORT_QUICK_SORT, LIBC_QSORT_HEAP_SORT." } } -} +} \ No newline at end of file ___ 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] [libc] 4502f83 - [libc] fix config syntax error
Author: Schrodinger ZHU Yifan Date: 2024-07-20T08:11:31-07:00 New Revision: 4502f83ed026030e6886cdd3aac18e2f392d4877 URL: https://github.com/llvm/llvm-project/commit/4502f83ed026030e6886cdd3aac18e2f392d4877 DIFF: https://github.com/llvm/llvm-project/commit/4502f83ed026030e6886cdd3aac18e2f392d4877.diff LOG: [libc] fix config syntax error Added: Modified: libc/config/config.json Removed: diff --git a/libc/config/config.json b/libc/config/config.json index 0fc88e2b8dbd5..2005f4297bfc1 100644 --- a/libc/config/config.json +++ b/libc/config/config.json @@ -75,7 +75,7 @@ "LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE": { "value": 1073741824, "doc": "Default size for the constinit freelist buffer used for the freelist malloc implementation (default 1o 1GB)." -}, +} }, "unistd": { "LIBC_CONF_ENABLE_TID_CACHE": { ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
@@ -51,7 +78,9 @@ void ImplementationInNamespaceCheck::check( // instead. if (NS->getVisibility() != Visibility::HiddenVisibility) { diag(NS->getLocation(), "the '%0' macro should start with '%1'") -<< RequiredNamespaceDeclMacroName << RequiredNamespaceDeclStart; +<< RequiredNamespaceDeclMacroName << RequiredNamespaceDeclStart +<< FixItHint::CreateReplacement(NS->getLocation(), +RequiredNamespaceDeclMacroName); 5chmidti wrote: You probably would want to add an include in this case as well, given that you're adding the same macro as above. https://github.com/llvm/llvm-project/pull/99681 ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
https://github.com/5chmidti commented: (not familiar with libc development) One question may be if the outer namespace should be replaced with the libc macro, or if the libc macro should be added around the other namespace. But given that this check is for libc development, then the libc people would know best what is desired. https://github.com/llvm/llvm-project/pull/99681 ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
@@ -41,8 +50,26 @@ void ImplementationInNamespaceCheck::check( // Enforce that the namespace is the result of macro expansion if (Result.SourceManager->isMacroBodyExpansion(NS->getLocation()) == false) { -diag(NS->getLocation(), "the outermost namespace should be the '%0' macro") -<< RequiredNamespaceDeclMacroName; +auto DB = diag(NS->getLocation(), + "the outermost namespace should be the '%0' macro") + << RequiredNamespaceDeclMacroName; + +// TODO: Determine how to split inline namespaces correctly in the FixItHint +// +// We can't easily replace LIBC_NAMEPACE::inner::namespace { with +// +// namespace LIBC_NAMEPACE_DECL { +// namespace inner::namespace { 5chmidti wrote: I think this is doable, but the `MACRO` in `namespace MACRO::foo::bar` could be a nested namespace as well (`#define MACRO my::namespace`). You would likely have to go through the lexer and check if the next tokens are `::`, and take these locations (with offset 1) as the range to be removed/changed. Should the outer libc namespace be on its own like in this example, or is a replacement from `LIBC_NAMESPACE::inner::namespace` to `LIBC_NAMESPACE_DECL::inner::namespace` fine? FYI: `LIBC_NAMEPACE_DECL` -> `LIBC_NAMESPACE_DECL` (missing `S` twice) https://github.com/llvm/llvm-project/pull/99681 ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
https://github.com/5chmidti edited https://github.com/llvm/llvm-project/pull/99681 ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
@@ -1,4 +1,6 @@ -// RUN: %check_clang_tidy %s llvmlibc-implementation-in-namespace %t +// RUN: %check_clang_tidy %s llvmlibc-implementation-in-namespace %t -fix 5chmidti wrote: No need to specify `-fix`, fixes are done automatically, e.g., https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique.cpp https://github.com/llvm/llvm-project/pull/99681 ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
5chmidti wrote: Please add a test with an outer namespace that needs to be changed, but which already has the hidden visibility attribute. That way, we'll be sure that the replacement will replace the namespace name instead of breaking the attribute into pieces. https://github.com/llvm/llvm-project/pull/99681 ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
@@ -41,8 +50,26 @@ void ImplementationInNamespaceCheck::check( // Enforce that the namespace is the result of macro expansion if (Result.SourceManager->isMacroBodyExpansion(NS->getLocation()) == false) { -diag(NS->getLocation(), "the outermost namespace should be the '%0' macro") -<< RequiredNamespaceDeclMacroName; +auto DB = diag(NS->getLocation(), + "the outermost namespace should be the '%0' macro") + << RequiredNamespaceDeclMacroName; + +// TODO: Determine how to split inline namespaces correctly in the FixItHint +// +// We can't easily replace LIBC_NAMEPACE::inner::namespace { with +// +// namespace LIBC_NAMEPACE_DECL { +// namespace inner::namespace { +// +// For now, just update the simple case w/ LIBC_NAMEPACE_DECL +if (!NS->isInlineNamespace()) + DB << FixItHint::CreateReplacement(NS->getLocation(), + RequiredNamespaceDeclMacroName); + +DB << IncludeInserter.createIncludeInsertion( +Result.SourceManager->getFileID(NS->getBeginLoc()), +NamespaceMacroHeader); 5chmidti wrote: +-: It might be a bit weird to add an include without the macro https://github.com/llvm/llvm-project/pull/99681 ___ 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-tidy] Add FixIts for libc namespace macros (PR #99681)
@@ -41,8 +50,26 @@ void ImplementationInNamespaceCheck::check( // Enforce that the namespace is the result of macro expansion if (Result.SourceManager->isMacroBodyExpansion(NS->getLocation()) == false) { -diag(NS->getLocation(), "the outermost namespace should be the '%0' macro") -<< RequiredNamespaceDeclMacroName; +auto DB = diag(NS->getLocation(), + "the outermost namespace should be the '%0' macro") + << RequiredNamespaceDeclMacroName; + +// TODO: Determine how to split inline namespaces correctly in the FixItHint +// +// We can't easily replace LIBC_NAMEPACE::inner::namespace { with +// +// namespace LIBC_NAMEPACE_DECL { +// namespace inner::namespace { +// +// For now, just update the simple case w/ LIBC_NAMEPACE_DECL +if (!NS->isInlineNamespace()) 5chmidti wrote: These are nested namespaces, not inline namespaces. Please fix the comment, use `isNested`, and add true negative tests for nested namespaces. https://github.com/llvm/llvm-project/pull/99681 ___ 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] 1629eb6 - Revert "SelectionDAG: Avoid using MachineFunction::getMMI (#99696)"
Author: Vitaly Buka Date: 2024-07-20T12:19:14-07:00 New Revision: 1629eb6c05867047669f3b242f884182e4249d86 URL: https://github.com/llvm/llvm-project/commit/1629eb6c05867047669f3b242f884182e4249d86 DIFF: https://github.com/llvm/llvm-project/commit/1629eb6c05867047669f3b242f884182e4249d86.diff LOG: Revert "SelectionDAG: Avoid using MachineFunction::getMMI (#99696)" This reverts commit c2019a37bdb1375e9f72b2549361cc50ea7729db. Added: Modified: llvm/include/llvm/CodeGen/SelectionDAG.h llvm/include/llvm/CodeGen/SelectionDAGISel.h llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp Removed: diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index 24eab7b408675..16ec65f2e7daa 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -245,7 +245,6 @@ class SelectionDAG { ProfileSummaryInfo *PSI = nullptr; BlockFrequencyInfo *BFI = nullptr; - MachineModuleInfo *MMI = nullptr; /// List of non-single value types. FoldingSet VTListMap; @@ -460,15 +459,14 @@ class SelectionDAG { void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, -BlockFrequencyInfo *BFIin, MachineModuleInfo &MMI, -FunctionVarLocs const *FnVarLocs); +BlockFrequencyInfo *BFIin, FunctionVarLocs const *FnVarLocs); void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, MachineFunctionAnalysisManager &AM, const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, -MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs) { -init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, MMI, FnVarLocs); +FunctionVarLocs const *FnVarLocs) { +init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, FnVarLocs); MFAM = &AM; } @@ -502,7 +500,6 @@ class SelectionDAG { OptimizationRemarkEmitter &getORE() const { return *ORE; } ProfileSummaryInfo *getPSI() const { return PSI; } BlockFrequencyInfo *getBFI() const { return BFI; } - MachineModuleInfo *getMMI() const { return MMI; } FlagInserter *getFlagInserter() { return Inserter; } void setFlagInserter(FlagInserter *FI) { Inserter = FI; } diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h index fc0590b1a1b69..aa0efa5d9bf5d 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h @@ -48,7 +48,6 @@ class SelectionDAGISel { std::unique_ptr FuncInfo; SwiftErrorValueTracking *SwiftError; MachineFunction *MF; - MachineModuleInfo *MMI; MachineRegisterInfo *RegInfo; SelectionDAG *CurDAG; std::unique_ptr SDB; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index a1376aaaf12a9..02d44cd36ae53 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1333,7 +1333,7 @@ void SelectionDAG::init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, UniformityInfo *NewUA, ProfileSummaryInfo *PSIin, -BlockFrequencyInfo *BFIin, MachineModuleInfo &MMIin, +BlockFrequencyInfo *BFIin, FunctionVarLocs const *VarLocs) { MF = &NewMF; SDAGISelPass = PassPtr; @@ -1345,7 +1345,6 @@ void SelectionDAG::init(MachineFunction &NewMF, UA = NewUA; PSI = PSIin; BFI = BFIin; - MMI = &MMIin; FnVarLocs = VarLocs; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 02eb1305b24ae..98a795edb7a03 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6707,11 +6707,11 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, getValue(I.getArgOperand(0; return; case Intrinsic::eh_sjlj_callsite: { +MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI(); ConstantInt *CI = cast(I.getArgOperand(0)); -assert(DAG.getMMI()->getCurrentCallSite() == 0 && - "Overlapping call sites!"); +assert(MMI.getCurrentCallSite
[llvm-branch-commits] [llvm] 9185875 - Revert "Revert "SelectionDAG: Avoid using MachineFunction::getMMI" (#99777)"
Author: Vitaly Buka Date: 2024-07-20T12:20:56-07:00 New Revision: 918587576c66f2640161c1b54fb128b0eb103880 URL: https://github.com/llvm/llvm-project/commit/918587576c66f2640161c1b54fb128b0eb103880 DIFF: https://github.com/llvm/llvm-project/commit/918587576c66f2640161c1b54fb128b0eb103880.diff LOG: Revert "Revert "SelectionDAG: Avoid using MachineFunction::getMMI" (#99777)" This reverts commit 98c0e55d9d31ea0a7b8a1e5395257f10a6a27cc6. Added: Modified: llvm/include/llvm/CodeGen/SelectionDAG.h llvm/include/llvm/CodeGen/SelectionDAGISel.h llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp Removed: diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index 16ec65f2e7daa..24eab7b408675 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -245,6 +245,7 @@ class SelectionDAG { ProfileSummaryInfo *PSI = nullptr; BlockFrequencyInfo *BFI = nullptr; + MachineModuleInfo *MMI = nullptr; /// List of non-single value types. FoldingSet VTListMap; @@ -459,14 +460,15 @@ class SelectionDAG { void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, -BlockFrequencyInfo *BFIin, FunctionVarLocs const *FnVarLocs); +BlockFrequencyInfo *BFIin, MachineModuleInfo &MMI, +FunctionVarLocs const *FnVarLocs); void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, MachineFunctionAnalysisManager &AM, const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, -FunctionVarLocs const *FnVarLocs) { -init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, FnVarLocs); +MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs) { +init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, MMI, FnVarLocs); MFAM = &AM; } @@ -500,6 +502,7 @@ class SelectionDAG { OptimizationRemarkEmitter &getORE() const { return *ORE; } ProfileSummaryInfo *getPSI() const { return PSI; } BlockFrequencyInfo *getBFI() const { return BFI; } + MachineModuleInfo *getMMI() const { return MMI; } FlagInserter *getFlagInserter() { return Inserter; } void setFlagInserter(FlagInserter *FI) { Inserter = FI; } diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h index aa0efa5d9bf5d..fc0590b1a1b69 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h @@ -48,6 +48,7 @@ class SelectionDAGISel { std::unique_ptr FuncInfo; SwiftErrorValueTracking *SwiftError; MachineFunction *MF; + MachineModuleInfo *MMI; MachineRegisterInfo *RegInfo; SelectionDAG *CurDAG; std::unique_ptr SDB; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 02d44cd36ae53..a1376aaaf12a9 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1333,7 +1333,7 @@ void SelectionDAG::init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, UniformityInfo *NewUA, ProfileSummaryInfo *PSIin, -BlockFrequencyInfo *BFIin, +BlockFrequencyInfo *BFIin, MachineModuleInfo &MMIin, FunctionVarLocs const *VarLocs) { MF = &NewMF; SDAGISelPass = PassPtr; @@ -1345,6 +1345,7 @@ void SelectionDAG::init(MachineFunction &NewMF, UA = NewUA; PSI = PSIin; BFI = BFIin; + MMI = &MMIin; FnVarLocs = VarLocs; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 98a795edb7a03..02eb1305b24ae 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6707,11 +6707,11 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, getValue(I.getArgOperand(0; return; case Intrinsic::eh_sjlj_callsite: { -MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI(); ConstantInt *CI = cast(I.getArgOperand(0)); -assert(MMI.getCurrentCallSite() == 0 && "Overlapping call sites!"); +assert(DAG.getMMI()->getCurrentCallSite()
[llvm-branch-commits] [llvm] 3deacfb - Revert "[LoongArch] Remove spurious mask operations from andn->icmp on 16 and…"
Author: hev Date: 2024-07-21T09:30:48+08:00 New Revision: 3deacfb6a58ea3dcae27807209dffb227e9c786c URL: https://github.com/llvm/llvm-project/commit/3deacfb6a58ea3dcae27807209dffb227e9c786c DIFF: https://github.com/llvm/llvm-project/commit/3deacfb6a58ea3dcae27807209dffb227e9c786c.diff LOG: Revert "[LoongArch] Remove spurious mask operations from andn->icmp on 16 and…" This reverts commit c41fa0fdd7e14019fc48bece2a2b0b00c88c8518. Added: Modified: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp llvm/test/CodeGen/LoongArch/andn-icmp.ll Removed: diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp index 6072e5e244263..ba6be85c7f2e8 100644 --- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp +++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp @@ -335,7 +335,6 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM, setTargetDAGCombine(ISD::AND); setTargetDAGCombine(ISD::OR); setTargetDAGCombine(ISD::SRL); - setTargetDAGCombine(ISD::SETCC); // Set DAG combine for 'LSX' feature. @@ -2529,165 +2528,6 @@ static SDValue performORCombine(SDNode *N, SelectionDAG &DAG, return SDValue(); } -static bool checkValueWidth(SDValue V, ISD::LoadExtType &ExtType) { - ExtType = ISD::NON_EXTLOAD; - - switch (V.getNode()->getOpcode()) { - case ISD::LOAD: { -LoadSDNode *LoadNode = cast(V.getNode()); -if ((LoadNode->getMemoryVT() == MVT::i8) || -(LoadNode->getMemoryVT() == MVT::i16)) { - ExtType = LoadNode->getExtensionType(); - return true; -} -return false; - } - case ISD::AssertSext: { -VTSDNode *TypeNode = cast(V.getNode()->getOperand(1)); -if ((TypeNode->getVT() == MVT::i8) || (TypeNode->getVT() == MVT::i16)) { - ExtType = ISD::SEXTLOAD; - return true; -} -return false; - } - case ISD::AssertZext: { -VTSDNode *TypeNode = cast(V.getNode()->getOperand(1)); -if ((TypeNode->getVT() == MVT::i8) || (TypeNode->getVT() == MVT::i16)) { - ExtType = ISD::ZEXTLOAD; - return true; -} -return false; - } - default: -return false; - } - - return false; -} - -// Eliminate redundant truncation and zero-extension nodes. -// * Case 1: -// ++ ++ ++ -// | Input1 | | Input2 | | CC | -// ++ ++ ++ -// | | | -// V V ++ -// ++ ++ | -// | TRUNCATE | | TRUNCATE | | -// ++ ++ | -// | | | -// V V | -// ++ ++ | -// | ZERO_EXT | | ZERO_EXT | | -// ++ ++ | -// | | | -// | +-+ | -// V V | | -//++| | -//| AND || | -//++| | -//| | | -//+---+ | | -//| | | -//V V V -// +-+ -// | CMP | -// +-+ -// * Case 2: -// ++ ++ +-+ ++ ++ -// | Input1 | | Input2 | | Constant -1 | | Constant 0 | | CC | -// ++ ++ +-+ ++ ++ -// | | | | | -// V | | | | -// ++| | | | -// | XOR|<-+ | | -// ++| | | -// | | | | -// V V +---+ | -// ++ ++ | | -// | TRUNCATE | | TRUNCATE | | +-+ -// ++ ++ | | -// | | | | -// V V | | -// ++ ++ | | -// | ZERO_EXT | | ZERO_EXT | | | -// ++ ++ | | -// | | | | -// V V | | -//++