[llvm-branch-commits] [compiler-rt] release/18.x: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) (PR #81402)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/81402 Backport 0a255fcf4a90f9e864ae9321b28e4956f7c865fb Requested by: @devnexen >From 9d41797f95e2bf60d335015eb749a65484e09995 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 10 Feb 2024 19:14:28 + Subject: [PATCH] [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) close #79708 (cherry picked from commit 0a255fcf4a90f9e864ae9321b28e4956f7c865fb) --- compiler-rt/lib/profile/InstrProfilingFile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c index 867ae73f0d3b27..f3b457d786e6bd 100644 --- a/compiler-rt/lib/profile/InstrProfilingFile.c +++ b/compiler-rt/lib/profile/InstrProfilingFile.c @@ -677,6 +677,7 @@ static void initializeProfileForContinuousMode(void) { PROF_ERR("Continuous counter sync mode is enabled, but raw profile is not" "page-aligned. CurrentFileOffset = %" PRIu64 ", pagesz = %u.\n", (uint64_t)CurrentFileOffset, PageSize); + fclose(File); return; } if (writeProfileWithFileObject(Filename, File) != 0) { @@ -692,6 +693,8 @@ static void initializeProfileForContinuousMode(void) { if (doMerging()) { lprofUnlockFileHandle(File); + } + if (File != NULL) { fclose(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] [compiler-rt] release/18.x: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) (PR #81402)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/81402 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] release/18.x: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) (PR #81402)
llvmbot wrote: @petrhosek What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/81402 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] release/18.x: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) (PR #81402)
llvmbot wrote: @llvm/pr-subscribers-pgo Author: None (llvmbot) Changes Backport 0a255fcf4a90f9e864ae9321b28e4956f7c865fb Requested by: @devnexen --- Full diff: https://github.com/llvm/llvm-project/pull/81402.diff 1 Files Affected: - (modified) compiler-rt/lib/profile/InstrProfilingFile.c (+3) ``diff diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c index 867ae73f0d3b27..f3b457d786e6bd 100644 --- a/compiler-rt/lib/profile/InstrProfilingFile.c +++ b/compiler-rt/lib/profile/InstrProfilingFile.c @@ -677,6 +677,7 @@ static void initializeProfileForContinuousMode(void) { PROF_ERR("Continuous counter sync mode is enabled, but raw profile is not" "page-aligned. CurrentFileOffset = %" PRIu64 ", pagesz = %u.\n", (uint64_t)CurrentFileOffset, PageSize); + fclose(File); return; } if (writeProfileWithFileObject(Filename, File) != 0) { @@ -692,6 +693,8 @@ static void initializeProfileForContinuousMode(void) { if (doMerging()) { lprofUnlockFileHandle(File); + } + if (File != NULL) { fclose(File); } } `` https://github.com/llvm/llvm-project/pull/81402 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] release/18.x: [SPARC] Support reserving arbitrary general purpose registers (#74927) (PR #81397)
koachan wrote: > @koachan What do you think about merging this PR to the release branch? Eh yeah should be okay I think... https://github.com/llvm/llvm-project/pull/81397 ___ 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] release/18.x: [libc++][print] Moves is_terminal to the dylib. (#80464) (PR #81410)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/81410 ___ 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] release/18.x: [libc++][print] Moves is_terminal to the dylib. (#80464) (PR #81410)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/81410 Backport 4fb7b3301bfbd439eb3d30d6a36c7cdb26941a0d Requested by: @mordante >From 460dc4de03e6310285d63e33fbd8c7d02d8af2ff Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sat, 10 Feb 2024 17:09:53 +0100 Subject: [PATCH] [libc++][print] Moves is_terminal to the dylib. (#80464) Having the test in the header requires including unistd.h on POSIX platforms. This header has other declarations which may conflict with code that uses named declarations provided by this header. For example code using "int pipe;" would conflict with the function pipe in this header. Moving the code to the dylib means std::print would not be available on Apple backdeployment targets. On POSIX platforms there is no transcoding required so a not Standard conforming implementation is still a useful and the observable differences are minimal. This behaviour has been done for print before https://github.com/llvm/llvm-project/pull/76293. Note questions have been raised in LWG4044 "Confusing requirements for std::print on POSIX platforms", whether or not the isatty check on POSIX platforms is required. When this LWG issue is resolved the backdeployment targets could become Standard compliant. This patch is intended to be backported to the LLVM-18 branch. Fixes: https://github.com/llvm/llvm-project/issues/79782 (cherry picked from commit 4fb7b3301bfbd439eb3d30d6a36c7cdb26941a0d) --- libcxx/include/print | 14 +-- libcxx/lib/abi/CHANGELOG.TXT | 8 ++ ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...bcxxabi.v1.stable.exceptions.nonew.abilist | 1 + ...xxabi.v1.stable.noexceptions.nonew.abilist | 1 + libcxx/src/print.cpp | 25 --- 12 files changed, 40 insertions(+), 16 deletions(-) diff --git a/libcxx/include/print b/libcxx/include/print index 7f2b5bac3dcf61..543a540ee4f27d 100644 --- a/libcxx/include/print +++ b/libcxx/include/print @@ -32,6 +32,7 @@ namespace std { */ #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__concepts/same_as.h> #include <__config> #include <__system_error/system_error.h> @@ -43,10 +44,6 @@ namespace std { #include #include -#if __has_include() -# include -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif @@ -68,7 +65,8 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream); // Note the function is only implemented on the Windows platform. _LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view); # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS - +#elif __has_include() +_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream); #endif // _LIBCPP_WIN32API #if _LIBCPP_STD_VER >= 23 @@ -195,15 +193,17 @@ inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTE inline constexpr bool __use_unicode_execution_charset = true; # endif -_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal(FILE* __stream) { +_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) { // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change // the behavior in the test. This is not part of the public API. # ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream); +# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 + return false; # elif defined(_LIBCPP_WIN32API) return std::__is_windows_terminal(__stream); # elif __has_include() - return isatty(fileno(__stream)); + return std::__is_posix_terminal(__stream); # else #error "Provide a way to determine whether a FILE* is a terminal" # endif diff --git a/libcxx/lib/abi/CHANGELOG.TXT b/libcxx/lib/abi/CHANGELOG.TXT index 1179c253f18c8f..7ff604959f4d5c 100644 --- a/libcxx/lib/abi/CHANGELOG.TXT +++ b/libcxx/lib/abi/CHANGELOG.TXT @@ -16,6 +16,14 @@ New entries should be added directly below the "Version" header. Version 18.0 +* [libc++] Moves is_terminal to the dylib + + The patch moves the POSIX implementation of is_terminal to the dylib. This is + needed to avoid using in public headers. + + All platforms + Symbol added: _ZNSt6__ndk119__is_posix_terminalEP7__sFILE + * [libc++abi] Implement __cxa_init_primary_exception and use it to optimize std::make_exception_ptr (#65534) This patch implements __cxa_init_primary_exception, an extension to the Itanium C++ ABI. diff --git a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b
[llvm-branch-commits] [libcxx] release/18.x: [libc++][print] Moves is_terminal to the dylib. (#80464) (PR #81410)
llvmbot wrote: @ldionne What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/81410 ___ 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] release/18.x: [libc++][print] Moves is_terminal to the dylib. (#80464) (PR #81410)
llvmbot wrote: @llvm/pr-subscribers-libcxx Author: None (llvmbot) Changes Backport 4fb7b3301bfbd439eb3d30d6a36c7cdb26941a0d Requested by: @mordante --- Full diff: https://github.com/llvm/llvm-project/pull/81410.diff 12 Files Affected: - (modified) libcxx/include/print (+7-7) - (modified) libcxx/lib/abi/CHANGELOG.TXT (+8) - (modified) libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/i686-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/x86_64-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist (+1) - (modified) libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist (+1) - (modified) libcxx/src/print.cpp (+16-9) ``diff diff --git a/libcxx/include/print b/libcxx/include/print index 7f2b5bac3dcf61..543a540ee4f27d 100644 --- a/libcxx/include/print +++ b/libcxx/include/print @@ -32,6 +32,7 @@ namespace std { */ #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__concepts/same_as.h> #include <__config> #include <__system_error/system_error.h> @@ -43,10 +44,6 @@ namespace std { #include #include -#if __has_include() -# include -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif @@ -68,7 +65,8 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream); // Note the function is only implemented on the Windows platform. _LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view); # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS - +#elif __has_include() +_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream); #endif // _LIBCPP_WIN32API #if _LIBCPP_STD_VER >= 23 @@ -195,15 +193,17 @@ inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTE inline constexpr bool __use_unicode_execution_charset = true; # endif -_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal(FILE* __stream) { +_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) { // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change // the behavior in the test. This is not part of the public API. # ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream); +# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 + return false; # elif defined(_LIBCPP_WIN32API) return std::__is_windows_terminal(__stream); # elif __has_include() - return isatty(fileno(__stream)); + return std::__is_posix_terminal(__stream); # else #error "Provide a way to determine whether a FILE* is a terminal" # endif diff --git a/libcxx/lib/abi/CHANGELOG.TXT b/libcxx/lib/abi/CHANGELOG.TXT index 1179c253f18c8f..7ff604959f4d5c 100644 --- a/libcxx/lib/abi/CHANGELOG.TXT +++ b/libcxx/lib/abi/CHANGELOG.TXT @@ -16,6 +16,14 @@ New entries should be added directly below the "Version" header. Version 18.0 +* [libc++] Moves is_terminal to the dylib + + The patch moves the POSIX implementation of is_terminal to the dylib. This is + needed to avoid using in public headers. + + All platforms + Symbol added: _ZNSt6__ndk119__is_posix_terminalEP7__sFILE + * [libc++abi] Implement __cxa_init_primary_exception and use it to optimize std::make_exception_ptr (#65534) This patch implements __cxa_init_primary_exception, an extension to the Itanium C++ ABI. diff --git a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist index c2fea4d8adb420..2064f45bf8c084 100644 --- a/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist +++ b/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist @@ -1495,6 +1495,7 @@ {'is_defined': True, 'name': '__ZNSt3__118shared_timed_mutex8try_lockEv', 'type': 'FUNC'} {'is_defined': True, 'name': '__ZNSt3__118shared_timed_mutexC1Ev', 'type': 'FUNC'} {'is_defined': True, 'name': '__ZNSt3__118shared_timed_mutexC2Ev', 'type': 'FUNC'} +{'is_defined': True, 'name': '__ZNSt3__119__is_posix_terminalEP7__sFILE', 'type': 'FUNC'} {'is_defined': True, 'name': '__ZNSt3__119__shared_mutex_base11lock_sharedEv', 'type': 'FUNC'} {'is_defined': True, 'name': '__ZNSt3__119__shared_mutex_base13unlock_sharedEv', 'type': 'FUNC'} {'is_defin
[llvm-branch-commits] [clang] [llvm] release/18.x: [SPARC] Support reserving arbitrary general purpose registers (#74927) (PR #81397)
https://github.com/koachan approved this pull request. https://github.com/llvm/llvm-project/pull/81397 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] [LLD] [docs] Add a release note for the SOURCE_DATE_EPOCH support (PR #81388)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/81388 ___ 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] [TypeProf][IndirectCallPromotion]Implement vtable-based transformation (PR #81442)
https://github.com/minglotus-6 edited https://github.com/llvm/llvm-project/pull/81442 ___ 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] [TypeProf][IndirectCallPromotion]Implement vtable-based transformation (PR #81442)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff d033799050b7bda70d80a933d5d99b7088a72a95 29d9cd2f128da0adde011a0a8362ec252104c901 -- compiler-rt/include/profile/InstrProfData.inc compiler-rt/lib/profile/InstrProfiling.h compiler-rt/lib/profile/InstrProfilingBuffer.c compiler-rt/lib/profile/InstrProfilingInternal.h compiler-rt/lib/profile/InstrProfilingMerge.c compiler-rt/lib/profile/InstrProfilingPlatformLinux.c compiler-rt/lib/profile/InstrProfilingWriter.c llvm/include/llvm/Analysis/IndirectCallPromotionAnalysis.h llvm/include/llvm/Analysis/IndirectCallVisitor.h llvm/include/llvm/ProfileData/InstrProf.h llvm/include/llvm/ProfileData/InstrProfData.inc llvm/include/llvm/ProfileData/InstrProfReader.h llvm/include/llvm/ProfileData/InstrProfWriter.h llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp llvm/lib/Analysis/ModuleSummaryAnalysis.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/ProfileData/InstrProf.cpp llvm/lib/ProfileData/InstrProfReader.cpp llvm/lib/ProfileData/InstrProfWriter.cpp llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp llvm/lib/Transforms/Instrumentation/ValueProfilePlugins.inc llvm/lib/Transforms/Utils/CallPromotionUtils.cpp llvm/tools/llvm-profdata/llvm-profdata.cpp llvm/unittests/ProfileData/InstrProfTest.cpp llvm/unittests/Transforms/Utils/CallPromotionUtilsTest.cpp `` View the diff from clang-format here. ``diff diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc index f0bc2d960c..f9c26b1f33 100644 --- a/compiler-rt/include/profile/InstrProfData.inc +++ b/compiler-rt/include/profile/InstrProfData.inc @@ -184,55 +184,73 @@ INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last) #endif VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \ INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(void *, Data, PointerType::getUnqual(Ctx)) INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) + VALUE_PROF_FUNC_PARAM(void *, Data, +PointerType::getUnqual(Ctx)) + INSTR_PROF_COMMA + VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, +Type::getInt32Ty(Ctx)) #undef VALUE_PROF_FUNC_PARAM #undef INSTR_PROF_COMMA -/* VALUE_PROF_FUNC_PARAM end */ + /* VALUE_PROF_FUNC_PARAM end */ -/* VALUE_PROF_KIND start */ + /* VALUE_PROF_KIND start */ #ifndef VALUE_PROF_KIND #define VALUE_PROF_KIND(Enumerator, Value, Descr) #else #define INSTR_PROF_DATA_DEFINED #endif -/* For indirect function call value profiling, the addresses of the target - * functions are profiled by the instrumented code. The target addresses are - * written in the raw profile data and converted to target function name's MD5 - * hash by the profile reader during deserialization. Typically, this happens - * when the raw profile data is read during profile merging. - * - * For this remapping the ProfData is used. ProfData contains both the function - * name hash and the function address. - */ -VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0, "indirect call target") -/* For memory intrinsic functions size profiling. */ -VALUE_PROF_KIND(IPVK_MemOPSize, 1, "memory intrinsic functions size") -/* For virtual table address profiling, the addresses of the virtual table - * (i.e., the address contained in objects pointing to a virtual table) are - * profiled. Note this may not be the address of the per C++ class virtual table - * object (i.e., there is an offset). - * - * The profiled addresses are stored in raw profile, together with the following - * two types of information. - * 1. The (beginning and ending) addresses of per C++ class virtual table objects. - * 2. The (compressed) virtual table object names. - * RawInstrProfReader converts profiled virtual table addresses to virtual table - * objects' MD5 hash. - */ -VALUE_PROF_KIND(IPVK_VTableTarget, 2, "The address of the compatible vtable (i.e., " - "there is an offset from this address to per C++ " - "class virtual table global variable.)") -/* These two kinds must be the last to be - * declared. This is to make sure the string - * array created with the template can be - * indexed with the kind value. - */ -VALUE_PROF_KIND(IPVK_First, IPVK_IndirectCallTarget, "first") -VALUE_PROF_KIND(IPVK_Last, IPVK_VTableTarget, "last") + /* For indirect function call value profiling, the