[llvm-branch-commits] [BOLT] Match functions with call graph (PR #98125)
https://github.com/shawbyoung created https://github.com/llvm/llvm-project/pull/98125 Test Plan: tbd ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [Flang][OpenMP] Add lowering support for DISTRIBUTE SIMD (PR #97819)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/97819 >From a61b3069a400f43eaa4f71e443b8a85c90aea0f0 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Fri, 5 Jul 2024 12:49:46 +0100 Subject: [PATCH] [Flang][OpenMP] Add lowering support for DISTRIBUTE SIMD This patch adds support for lowering 'DISTRIBUTE SIMD' constructs to MLIR. Translation of `omp.distribute` operations to LLVM IR is still not supported, so its composition with `omp.simd` isn't either. --- flang/lib/Lower/OpenMP/OpenMP.cpp | 38 +++- flang/test/Lower/OpenMP/distribute-simd.f90 | 59 ++ flang/test/Lower/OpenMP/if-clause.f90 | 218 +++- flang/test/Lower/OpenMP/loop-compound.f90 | 45 +++- 4 files changed, 351 insertions(+), 9 deletions(-) create mode 100644 flang/test/Lower/OpenMP/distribute-simd.f90 diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index b1bb4c11f86dd..dffdb834d4e66 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -1976,7 +1976,43 @@ static void genCompositeDistributeSimd( semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval, mlir::Location loc, const ConstructQueue &queue, ConstructQueue::iterator item, DataSharingProcessor &dsp) { - TODO(loc, "Composite DISTRIBUTE SIMD"); + lower::StatementContext stmtCtx; + + // Clause processing. + mlir::omp::DistributeClauseOps distributeClauseOps; + genDistributeClauses(converter, semaCtx, stmtCtx, item->clauses, loc, + distributeClauseOps); + + mlir::omp::SimdClauseOps simdClauseOps; + genSimdClauses(converter, semaCtx, item->clauses, loc, simdClauseOps); + + mlir::omp::LoopNestClauseOps loopNestClauseOps; + llvm::SmallVector iv; + genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc, + loopNestClauseOps, iv); + + // Operation creation. + // TODO: Populate entry block arguments with private variables. + auto distributeOp = genWrapperOp( + converter, loc, distributeClauseOps, /*blockArgTypes=*/{}); + + // TODO: Populate entry block arguments with reduction and private variables. + auto simdOp = genWrapperOp(converter, loc, simdClauseOps, +/*blockArgTypes=*/{}); + + // Construct wrapper entry block list and associated symbols. It is important + // that the symbol order and the block argument order match, so that the + // symbol-value bindings created are correct. + // TODO: Add omp.distribute private and omp.simd private and reduction args. + auto wrapperArgs = llvm::to_vector( + llvm::concat(distributeOp.getRegion().getArguments(), +simdOp.getRegion().getArguments())); + + assert(wrapperArgs.empty() && + "Block args for omp.simd and omp.distribute currently not expected"); + genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item, +loopNestClauseOps, iv, /*wrapperSyms=*/{}, wrapperArgs, +llvm::omp::Directive::OMPD_distribute_simd, dsp); } static void genCompositeDoSimd(lower::AbstractConverter &converter, diff --git a/flang/test/Lower/OpenMP/distribute-simd.f90 b/flang/test/Lower/OpenMP/distribute-simd.f90 new file mode 100644 index 0..545037b7791b8 --- /dev/null +++ b/flang/test/Lower/OpenMP/distribute-simd.f90 @@ -0,0 +1,59 @@ +! This test checks lowering of OpenMP DISTRIBUTE SIMD composite constructs. + +! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s +! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s + +! CHECK-LABEL: func.func @_QPdistribute_simd_aligned( +subroutine distribute_simd_aligned(A) + use iso_c_binding + type(c_ptr) :: A + + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: aligned({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: aligned({{.*}}) + !$omp distribute simd aligned(A) + do index_ = 1, 10 +call c_test_call(A) + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_aligned + +! CHECK-LABEL: func.func @_QPdistribute_simd_safelen( +subroutine distribute_simd_safelen() + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: safelen({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: safelen({{.*}}) + !$omp distribute simd safelen(4) + do index_ = 1, 10 + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_safelen + +! CHECK-LABEL: func.func @_QPdistribute_simd_simdlen( +subroutine distribute_simd_simdlen() + !$omp teams + + ! CHECK: omp.distribute + ! CHECK-NOT: simdlen({{.*}}) + ! CHECK-SAME: { + ! CHECK-NEXT: omp.simd + ! CHECK-SAME: simdlen({{.*}}) + !$omp distribute simd simdlen(4) + do index_ = 1, 10 + end do + !$omp end distribute simd + + !$omp end teams +end subroutine distribute_simd_simdlen diff --git a/flang/test/Lower/OpenMP/if-clause.f90 b/flang/tes
[llvm-branch-commits] [llvm] [BOLT] Added more details on heatmap docs. (PR #98162)
https://github.com/paschalis-mpeis created https://github.com/llvm/llvm-project/pull/98162 Suggesting a few more details for Heatmaps.md >From f209cca87cf7c53242a353a505e3bfe34688a1b2 Mon Sep 17 00:00:00 2001 From: Paschalis Mpeis Date: Tue, 9 Jul 2024 08:52:51 +0100 Subject: [PATCH] [BOLT] Added more details on heatmap docs. --- bolt/docs/Heatmaps.md | 53 +++ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/bolt/docs/Heatmaps.md b/bolt/docs/Heatmaps.md index e1b59d49ad102..c1a01839d6682 100644 --- a/bolt/docs/Heatmaps.md +++ b/bolt/docs/Heatmaps.md @@ -1,9 +1,9 @@ # Code Heatmaps BOLT has gained the ability to print code heatmaps based on -sampling-based LBR profiles generated by `perf`. The output is produced -in colored ASCII to be displayed in a color-capable terminal. It looks -something like this: +sampling-based profiles generated by `perf`, either with `LBR` data or not. +The output is produced in colored ASCII to be displayed in a color-capable +terminal. It looks something like this:  @@ -32,17 +32,7 @@ $ llvm-bolt-heatmap -p perf.data ``` By default the heatmap will be dumped to *stdout*. You can change it -with `-o ` option. Each character/block in the heatmap -shows the execution data accumulated for corresponding 64 bytes of -code. You can change this granularity with a `-block-size` option. -E.g. set it to 4096 to see code usage grouped by 4K pages. -Other useful options are: - -```bash --line-size= - number of entries per line (default 256) --max-address= - maximum address considered valid for heatmap (default 4GB) --print-mappings= - print mappings in legend, between characters/blocks and text sections (default false) -``` +with `-o ` option. If you prefer to look at the data in a browser (or would like to share it that way), then you can use an HTML conversion tool. E.g.: @@ -50,3 +40,38 @@ it that way), then you can use an HTML conversion tool. E.g.: ```bash $ aha -b -f > .html ``` + +--- + +## Background on heatmaps: +A heatmap is effectively a histogram that is rendered into a grid for better +visualization. +In theory we can generate a heatmap using any binary and a perf profile. + +Each block/character in the heatmap shows the execution data accumulated for +corresponding 64 bytes of code. You can change this granularity with a +`-block-size` option. +E.g. set it to 4096 to see code usage grouped by 4K pages. + + +When a block is shown as a dot, it means that no samples were found for that address. +When it is shown as a letter, it indicates a captured sample on a particular text section of the binary. To show a mapping between letters and text sections in the legend, use `-print-mappings`. When a sampled address does not belong to any of the TextSegments, the characters 'o' or 'O' will be shown. + +The legend shows by default the ranges in the heatmap according to the number +of samples per block. +A color is assigned per range, except the first two ranges that distinguished by +lower and upper case letters. + +Each consecutive line in the heatmap advances by the same amount, +with the binary size covered by a line being dependent on the block size and the +line size. +An empty new line is inserted for bigger gaps between samples. + + +Some useful options are: + +``` +-line-size= - number of entries per line (default 256) +-max-address= - maximum address considered valid for heatmap (default 4GB) +-print-mappings - print mappings in the legend, between characters/blocks and text sections (default false) +``` ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Added more details on heatmap docs. (PR #98162)
llvmbot wrote: @llvm/pr-subscribers-bolt Author: Paschalis Mpeis (paschalis-mpeis) Changes Suggesting a few more details for Heatmaps.md --- Full diff: https://github.com/llvm/llvm-project/pull/98162.diff 1 Files Affected: - (modified) bolt/docs/Heatmaps.md (+39-14) ``diff diff --git a/bolt/docs/Heatmaps.md b/bolt/docs/Heatmaps.md index e1b59d49ad102..c1a01839d6682 100644 --- a/bolt/docs/Heatmaps.md +++ b/bolt/docs/Heatmaps.md @@ -1,9 +1,9 @@ # Code Heatmaps BOLT has gained the ability to print code heatmaps based on -sampling-based LBR profiles generated by `perf`. The output is produced -in colored ASCII to be displayed in a color-capable terminal. It looks -something like this: +sampling-based profiles generated by `perf`, either with `LBR` data or not. +The output is produced in colored ASCII to be displayed in a color-capable +terminal. It looks something like this:  @@ -32,17 +32,7 @@ $ llvm-bolt-heatmap -p perf.data ``` By default the heatmap will be dumped to *stdout*. You can change it -with `-o ` option. Each character/block in the heatmap -shows the execution data accumulated for corresponding 64 bytes of -code. You can change this granularity with a `-block-size` option. -E.g. set it to 4096 to see code usage grouped by 4K pages. -Other useful options are: - -```bash --line-size= - number of entries per line (default 256) --max-address= - maximum address considered valid for heatmap (default 4GB) --print-mappings= - print mappings in legend, between characters/blocks and text sections (default false) -``` +with `-o ` option. If you prefer to look at the data in a browser (or would like to share it that way), then you can use an HTML conversion tool. E.g.: @@ -50,3 +40,38 @@ it that way), then you can use an HTML conversion tool. E.g.: ```bash $ aha -b -f > .html ``` + +--- + +## Background on heatmaps: +A heatmap is effectively a histogram that is rendered into a grid for better +visualization. +In theory we can generate a heatmap using any binary and a perf profile. + +Each block/character in the heatmap shows the execution data accumulated for +corresponding 64 bytes of code. You can change this granularity with a +`-block-size` option. +E.g. set it to 4096 to see code usage grouped by 4K pages. + + +When a block is shown as a dot, it means that no samples were found for that address. +When it is shown as a letter, it indicates a captured sample on a particular text section of the binary. To show a mapping between letters and text sections in the legend, use `-print-mappings`. When a sampled address does not belong to any of the TextSegments, the characters 'o' or 'O' will be shown. + +The legend shows by default the ranges in the heatmap according to the number +of samples per block. +A color is assigned per range, except the first two ranges that distinguished by +lower and upper case letters. + +Each consecutive line in the heatmap advances by the same amount, +with the binary size covered by a line being dependent on the block size and the +line size. +An empty new line is inserted for bigger gaps between samples. + + +Some useful options are: + +``` +-line-size= - number of entries per line (default 256) +-max-address= - maximum address considered valid for heatmap (default 4GB) +-print-mappings - print mappings in the legend, between characters/blocks and text sections (default false) +``` `` https://github.com/llvm/llvm-project/pull/98162 ___ 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++][TZDB] Finishes zoned_time constructors. (PR #95010)
https://github.com/ldionne milestoned https://github.com/llvm/llvm-project/pull/95010 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
https://github.com/ldionne edited https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
@@ -0,0 +1,136 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-experimental-tzdb +// XFAIL: availability-tzdb-missing + +// + +// template +// class zoned_time; +// +// zoned_time& operator=(const sys_time& st); + +#include +#include +#include +#include + +namespace cr = std::chrono; + +int main(int, char**) { + { +using duration = cr::nanoseconds; +using time_point = cr::sys_time; +using zoned_time = cr::zoned_time; +zoned_time zt{time_point{duration{42}}}; + +assert(zt.get_time_zone() == cr::locate_zone("UTC")); +assert(zt.get_sys_time() == time_point{duration{42}}); + +[[maybe_unused]] std::same_as decltype(auto) _ = zt = time_point{duration{99}}; ldionne wrote: Same comment here! https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
@@ -0,0 +1,135 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-experimental-tzdb +// XFAIL: availability-tzdb-missing + +// + +// template +// class zoned_time; +// +// explicit operator local_time() const; + +#include +#include + +#include "../test_offset_time_zone.h" + +namespace cr = std::chrono; + +static void test_const_member() { + { +using duration = cr::nanoseconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +static_assert(!std::is_convertible_v>); +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; ldionne wrote: Same comment. https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
https://github.com/ldionne approved this pull request. LGTM with a few suggestions! https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
@@ -0,0 +1,243 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-experimental-tzdb +// XFAIL: availability-tzdb-missing + +// + +// template +// class zoned_time; +// +// zoned_time& operator=(const local_time& st); + +// TODO TZDB Investigate the issues in this test, this seems like +// a design issue of the class. +// +// [time.zone.zonedtime.members]/3 +// Effects: After assignment, get_local_time() == lt. +// This assignment has no effect on the return value of get_time_zone(). +// +// The test cases describe the issues. + +#include +#include +#include +#include + +#include "test_macros.h" + +namespace cr = std::chrono; + +// Tests unique conversions. To make sure the test is does not depend on changes +// in the database it uses a time zone with a fixed offset. +static void test_unique() { + // common_type_t -> duration + { +using duration = cr::nanoseconds; +using sys_time_point = cr::sys_time; +using local_time_point = cr::local_time; +using zoned_time = cr::zoned_time; +zoned_time zt{"Etc/GMT+1", sys_time_point{duration{42}}}; + +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{42}}); +assert(zt.get_local_time() == local_time_point{duration{42} - cr::hours{1}}); + +[[maybe_unused]] std::same_as decltype(auto) _ = zt = local_time_point{duration{99}}; ldionne wrote: ```suggestion std::same_as decltype(auto) result = zt = local_time_point{duration{99}}; assert(&result == &zt); ``` Kinda pedantic but necessary! https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
@@ -0,0 +1,133 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-experimental-tzdb +// XFAIL: availability-tzdb-missing + +// + +// template +// class zoned_time; +// +// local_time get_local_time() const; + +#include +#include + +#include "../test_offset_time_zone.h" + +namespace cr = std::chrono; + +static void test_const_member() { + { +using duration = cr::nanoseconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; ldionne wrote: This test seems out of place, since the function name suggests that we're only testing const-qualification in it. https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
@@ -0,0 +1,243 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-experimental-tzdb +// XFAIL: availability-tzdb-missing + +// + +// template +// class zoned_time; +// +// zoned_time& operator=(const local_time& st); + +// TODO TZDB Investigate the issues in this test, this seems like +// a design issue of the class. +// +// [time.zone.zonedtime.members]/3 +// Effects: After assignment, get_local_time() == lt. +// This assignment has no effect on the return value of get_time_zone(). +// +// The test cases describe the issues. + +#include +#include +#include +#include + +#include "test_macros.h" + +namespace cr = std::chrono; + +// Tests unique conversions. To make sure the test is does not depend on changes +// in the database it uses a time zone with a fixed offset. +static void test_unique() { + // common_type_t -> duration + { +using duration = cr::nanoseconds; +using sys_time_point = cr::sys_time; +using local_time_point = cr::local_time; +using zoned_time = cr::zoned_time; +zoned_time zt{"Etc/GMT+1", sys_time_point{duration{42}}}; + +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{42}}); +assert(zt.get_local_time() == local_time_point{duration{42} - cr::hours{1}}); + +[[maybe_unused]] std::same_as decltype(auto) _ = zt = local_time_point{duration{99}}; +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{99} + cr::hours{1}}); +assert(zt.get_local_time() == local_time_point{duration{99}}); + } + { +using duration = cr::microseconds; +using sys_time_point = cr::sys_time; +using local_time_point = cr::local_time; +using zoned_time = cr::zoned_time; +zoned_time zt{"Etc/GMT+1", sys_time_point{duration{42}}}; + +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{42}}); +assert(zt.get_local_time() == local_time_point{duration{42} - cr::hours{1}}); + +[[maybe_unused]] std::same_as decltype(auto) _ = zt = local_time_point{duration{99}}; +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{99} + cr::hours{1}}); +assert(zt.get_local_time() == local_time_point{duration{99}}); + } + { +using duration = cr::milliseconds; +using sys_time_point = cr::sys_time; +using local_time_point = cr::local_time; +using zoned_time = cr::zoned_time; +zoned_time zt{"Etc/GMT+1", sys_time_point{duration{42}}}; + +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{42}}); +assert(zt.get_local_time() == local_time_point{duration{42} - cr::hours{1}}); + +[[maybe_unused]] std::same_as decltype(auto) _ = zt = local_time_point{duration{99}}; +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{99} + cr::hours{1}}); +assert(zt.get_local_time() == local_time_point{duration{99}}); + } + // common_type_t -> seconds + { +using duration = cr::seconds; +using sys_time_point = cr::sys_time; +using local_time_point = cr::local_time; +using zoned_time = cr::zoned_time; +zoned_time zt{"Etc/GMT+1", sys_time_point{duration{42}}}; + +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{42}}); +assert(zt.get_local_time() == local_time_point{duration{42} - cr::hours{1}}); + +[[maybe_unused]] std::same_as decltype(auto) _ = zt = local_time_point{duration{99}}; +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == sys_time_point{duration{99} + cr::hours{1}}); +assert(zt.get_local_time() == local_time_point{duration{99}}); + } + // common_type_t -> seconds + { +using duration = cr::days; +using sys_time_point = cr::sys_time; +using local_time_point = cr::local_time; +using zoned_time = cr::zoned_time; +zoned_time zt{"Etc/GMT+1", sys_time_point{duration{42}}}; + +assert(zt.get_time_zone() == cr::locate_zone("Etc/GMT+1")); +assert(zt.get_sys_time() == cr::sys_seconds{duration{42}}); +assert(zt.get_local_time() == cr::local_seconds{duration{42} - cr::hours{1}}); + +[[maybe_unused]] std::same_as decltyp
[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)
@@ -0,0 +1,135 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: no-filesystem, no-localization, no-tzdb + +// XFAIL: libcpp-has-no-experimental-tzdb +// XFAIL: availability-tzdb-missing + +// + +// template +// class zoned_time; +// +// explicit operator local_time() const; + +#include +#include + +#include "../test_offset_time_zone.h" + +namespace cr = std::chrono; + +static void test_const_member() { + { +using duration = cr::nanoseconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +static_assert(!std::is_convertible_v>); +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + { +using duration = cr::nanoseconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +static_assert(!std::is_convertible_v>); +const cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } +} + +static void test_duration_conversion() { + // common_type_t -> duration + { +using duration = cr::nanoseconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + { +using duration = cr::microseconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + { +using duration = cr::milliseconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + // common_type_t -> seconds + { +using duration = cr::seconds; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + // common_type_t -> seconds + { +using duration = cr::days; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + { +using duration = cr::weeks; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + { +using duration = cr::months; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; + +std::same_as decltype(auto) time = static_cast(zt); +assert(time == local_time_point{duration{42} - cr::hours{1}}); + } + { +using duration = cr::years; +using time_point = cr::sys_time; +using local_time_point = cr::local_time; +cr::zoned_time zt{"Etc/GMT+1", time_point{duration{42}}}; ldionne wrote: Note that you could make all of those `zt`'s `const` since the method is `const`. https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Finishes zoned_time member functions. (PR #95026)
@@ -147,8 +148,29 @@ class zoned_time { } && is_convertible_v, sys_time<_Duration>>) : zoned_time{__traits::locate_zone(__name), __zt, __c} {} + _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) { +__tp_ = __tp; +return *this; + } + + _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& __tp) { +// TODO TZDB This seems wrong. +// Assigning a non-existant or abiguous time will throw and not satisfy ldionne wrote: ```suggestion // Assigning a non-existent or ambiguous time will throw and not satisfy ``` Can you file a LWG issue about this? https://github.com/llvm/llvm-project/pull/95026 ___ 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++][TZDB] Adds zoned_time deduction guides. (PR #95139)
https://github.com/ldionne milestoned https://github.com/llvm/llvm-project/pull/95139 ___ 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++][TZDB] Adds zoned_time deduction guides. (PR #95139)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/95139 ___ 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++][TZDB] Implements zoned_time's operator==. (PR #95140)
https://github.com/ldionne milestoned https://github.com/llvm/llvm-project/pull/95140 ___ 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++][TZDB] Implements zoned_time's operator==. (PR #95140)
@@ -0,0 +1,71 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// REQUIRES: has-unix-headers +// REQUIRES: libcpp-hardening-mode={{extensive|debug}} +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing ldionne wrote: This looks like a leftover? https://github.com/llvm/llvm-project/pull/95140 ___ 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++][TZDB] Implements zoned_time's operator==. (PR #95140)
https://github.com/ldionne edited https://github.com/llvm/llvm-project/pull/95140 ___ 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++][TZDB] Implements zoned_time's operator==. (PR #95140)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/95140 ___ 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++][TZDB] Implements zoned_seconds typedef. (PR #95141)
https://github.com/ldionne milestoned https://github.com/llvm/llvm-project/pull/95141 ___ 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++][TZDB] Implements zoned_seconds typedef. (PR #95141)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/95141 ___ 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] b685845 - Revert "[lit] Implement builtin umask (#94621)"
Author: Jay Foad Date: 2024-07-09T17:17:57+01:00 New Revision: b68584571de3370ba7655b62047908b28a81d56c URL: https://github.com/llvm/llvm-project/commit/b68584571de3370ba7655b62047908b28a81d56c DIFF: https://github.com/llvm/llvm-project/commit/b68584571de3370ba7655b62047908b28a81d56c.diff LOG: Revert "[lit] Implement builtin umask (#94621)" This reverts commit 9f6dd1f761a5121e9a69e5d1f67c2438c065b499. Added: Modified: llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test llvm/test/tools/llvm-objcopy/ELF/respect-umask.test llvm/utils/lit/lit/TestRunner.py Removed: llvm/utils/lit/tests/Inputs/shtest-umask/lit.cfg llvm/utils/lit/tests/Inputs/shtest-umask/umask-bad-arg.txt llvm/utils/lit/tests/Inputs/shtest-umask/umask-ok.txt llvm/utils/lit/tests/Inputs/shtest-umask/umask-too-many-args.txt llvm/utils/lit/tests/shtest-umask.py diff --git a/llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test b/llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test index fdcba4dcd666b..a95d1c0aafa21 100644 --- a/llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test +++ b/llvm/test/tools/llvm-dwarfutil/ELF/X86/mirror-permissions-unix.test @@ -3,6 +3,7 @@ ## Setting the umask to 0 ensures deterministic permissions across ## test environments. # UNSUPPORTED: system-windows +# REQUIRES: shell # RUN: touch %t # RUN: chmod 0777 %t diff --git a/llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test b/llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test index 66a481a2230d1..8f4993f4f3d29 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test +++ b/llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test @@ -6,6 +6,7 @@ ## Setting the umask to 0 ensures deterministic permissions across ## test environments. # UNSUPPORTED: system-windows +# REQUIRES: shell # RUN: touch %t # RUN: chmod 0777 %t diff --git a/llvm/test/tools/llvm-objcopy/ELF/respect-umask.test b/llvm/test/tools/llvm-objcopy/ELF/respect-umask.test index 02e9b93f5376f..376e33a217819 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/respect-umask.test +++ b/llvm/test/tools/llvm-objcopy/ELF/respect-umask.test @@ -1,8 +1,10 @@ ## This tests that the umask is respected when ## assigning permissions of output files. -## Windows has no umask so this test makes no sense. +## Windows has no umask so this test makes no sense, nor would +## it work because there is no umask(1) in a Windows environment # UNSUPPORTED: system-windows +# REQUIRES: shell # RUN: rm -f %t # RUN: touch %t diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index 865376e0e711e..da7fa86fd3917 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -87,10 +87,9 @@ class ShellEnvironment(object): we maintain a dir stack for pushd/popd. """ -def __init__(self, cwd, env, umask=-1): +def __init__(self, cwd, env): self.cwd = cwd self.env = dict(env) -self.umask = umask self.dirStack = [] def change_dir(self, newdir): @@ -566,20 +565,6 @@ class SHFILEOPSTRUCTW(Structure): return ShellCommandResult(cmd, "", stderr.getvalue(), exitCode, False) -def executeBuiltinUmask(cmd, shenv): -"""executeBuiltinUmask - Change the current umask.""" -if os.name != "posix": -raise InternalShellError(cmd, "'umask' not supported on this system") -if len(cmd.args) != 2: -raise InternalShellError(cmd, "'umask' supports only one argument") -try: -# Update the umask in the parent environment. -shenv.umask = int(cmd.args[1], 8) -except ValueError as err: -raise InternalShellError(cmd, "Error: 'umask': %s" % str(err)) -return ShellCommandResult(cmd, "", "", 0, False) - - def executeBuiltinColon(cmd, cmd_shenv): """executeBuiltinColon - Discard arguments and exit with status 0.""" return ShellCommandResult(cmd, "", "", 0, False) @@ -734,7 +719,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper): "popd": executeBuiltinPopd, "pushd": executeBuiltinPushd, "rm": executeBuiltinRm, -"umask": executeBuiltinUmask, ":": executeBuiltinColon, } # To avoid deadlock, we use a single stderr stream for piped @@ -756,7 +740,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper): # env FOO=1 llc < %s | env BAR=2 llvm-mc | FileCheck %s # env FOO=1 %{another_env_plus_cmd} | FileCheck %s if cmd_shenv is shenv: -cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env, shenv.umask) +cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env) args = updateEnv(cmd_shenv, args)
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/96596 >From 05d59574d6260b98a469921eb2fccf5398bfafb6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 24 Jun 2024 23:00:59 -0700 Subject: [PATCH 01/16] Added call to matchWithCallsAsAnchors Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index aafffac3d4b1c..1a0e5d239d252 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -479,6 +479,9 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + uint64_t MatchedWithCallsAsAnchors = 0; + matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 77ef0008f4f5987719555e6cc3e32da812ae0f31 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 24 Jun 2024 23:11:43 -0700 Subject: [PATCH 02/16] Changed CallHashToBF representation Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 1a0e5d239d252..91b01a99c7485 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -29,6 +29,10 @@ static llvm::cl::opt cl::desc("ignore hash while reading function profile"), cl::Hidden, cl::cat(BoltOptCategory)); +llvm::cl::opt MatchWithCallsAsAnchors("match-with-calls-as-anchors", + cl::desc("Matches with calls as anchors"), + cl::Hidden, cl::cat(BoltOptCategory)); + llvm::cl::opt ProfileUseDFS("profile-use-dfs", cl::desc("use DFS order for YAML profile"), cl::Hidden, cl::cat(BoltOptCategory)); @@ -353,7 +357,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( llvm_unreachable("Unhandled HashFunction"); }; - std::unordered_map CallHashToBF; + std::unordered_map CallHashToBF; for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { if (ProfiledFunctions.count(BF)) @@ -375,12 +379,12 @@ void YAMLProfileReader::matchWithCallsAsAnchors( for (const std::string &FunctionName : FunctionNames) HashString.append(FunctionName); } -CallHashToBF.emplace(ComputeCallHash(HashString), BF); +CallHashToBF[ComputeCallHash(HashString)] = BF; } std::unordered_map ProfiledFunctionIdToName; - for (const yaml::bolt::BinaryFunctionProfile YamlBF : YamlBP.Functions) + for (const yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) ProfiledFunctionIdToName[YamlBF.Id] = YamlBF.Name; for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) { @@ -401,7 +405,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( auto It = CallHashToBF.find(Hash); if (It == CallHashToBF.end()) continue; -matchProfileToFunction(YamlBF, It->second); +matchProfileToFunction(YamlBF, *It->second); ++MatchedWithCallsAsAnchors; } } @@ -480,7 +484,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { matchProfileToFunction(YamlBF, *BF); uint64_t MatchedWithCallsAsAnchors = 0; - matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); + if (opts::MatchWithCallsAsAnchors) +matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) >From ea7cb68ab9e8e158412c2e752986968968a60d93 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 25 Jun 2024 09:28:39 -0700 Subject: [PATCH 03/16] Changed BF called FunctionNames to multiset Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 91b01a99c7485..3b3d73f7af023 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -365,7 +365,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( std::string HashString; for (const auto &BB : BF->blocks()) { - std::set FunctionNames; + std::multiset FunctionNames; for (const MCInst &Instr : BB) { // Skip non-call instructions. if (!BC.MIB->isCall(Instr)) @@ -397,9 +397,8 @@ void YAMLProfileReader::matchWithCallsAsAnchors( std::string &FunctionName = ProfiledFunctionIdToName[CallSite.DestId]; FunctionNames.insert(FunctionName);
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/96596 >From 05d59574d6260b98a469921eb2fccf5398bfafb6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 24 Jun 2024 23:00:59 -0700 Subject: [PATCH 01/16] Added call to matchWithCallsAsAnchors Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index aafffac3d4b1c..1a0e5d239d252 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -479,6 +479,9 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + uint64_t MatchedWithCallsAsAnchors = 0; + matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 77ef0008f4f5987719555e6cc3e32da812ae0f31 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 24 Jun 2024 23:11:43 -0700 Subject: [PATCH 02/16] Changed CallHashToBF representation Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 1a0e5d239d252..91b01a99c7485 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -29,6 +29,10 @@ static llvm::cl::opt cl::desc("ignore hash while reading function profile"), cl::Hidden, cl::cat(BoltOptCategory)); +llvm::cl::opt MatchWithCallsAsAnchors("match-with-calls-as-anchors", + cl::desc("Matches with calls as anchors"), + cl::Hidden, cl::cat(BoltOptCategory)); + llvm::cl::opt ProfileUseDFS("profile-use-dfs", cl::desc("use DFS order for YAML profile"), cl::Hidden, cl::cat(BoltOptCategory)); @@ -353,7 +357,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( llvm_unreachable("Unhandled HashFunction"); }; - std::unordered_map CallHashToBF; + std::unordered_map CallHashToBF; for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { if (ProfiledFunctions.count(BF)) @@ -375,12 +379,12 @@ void YAMLProfileReader::matchWithCallsAsAnchors( for (const std::string &FunctionName : FunctionNames) HashString.append(FunctionName); } -CallHashToBF.emplace(ComputeCallHash(HashString), BF); +CallHashToBF[ComputeCallHash(HashString)] = BF; } std::unordered_map ProfiledFunctionIdToName; - for (const yaml::bolt::BinaryFunctionProfile YamlBF : YamlBP.Functions) + for (const yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) ProfiledFunctionIdToName[YamlBF.Id] = YamlBF.Name; for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) { @@ -401,7 +405,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( auto It = CallHashToBF.find(Hash); if (It == CallHashToBF.end()) continue; -matchProfileToFunction(YamlBF, It->second); +matchProfileToFunction(YamlBF, *It->second); ++MatchedWithCallsAsAnchors; } } @@ -480,7 +484,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { matchProfileToFunction(YamlBF, *BF); uint64_t MatchedWithCallsAsAnchors = 0; - matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); + if (opts::MatchWithCallsAsAnchors) +matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) >From ea7cb68ab9e8e158412c2e752986968968a60d93 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 25 Jun 2024 09:28:39 -0700 Subject: [PATCH 03/16] Changed BF called FunctionNames to multiset Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 91b01a99c7485..3b3d73f7af023 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -365,7 +365,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( std::string HashString; for (const auto &BB : BF->blocks()) { - std::set FunctionNames; + std::multiset FunctionNames; for (const MCInst &Instr : BB) { // Skip non-call instructions. if (!BC.MIB->isCall(Instr)) @@ -397,9 +397,8 @@ void YAMLProfileReader::matchWithCallsAsAnchors( std::string &FunctionName = ProfiledFunctionIdToName[CallSite.DestId]; FunctionNames.insert(FunctionName);
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/96596 >From 05d59574d6260b98a469921eb2fccf5398bfafb6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 24 Jun 2024 23:00:59 -0700 Subject: [PATCH 01/17] Added call to matchWithCallsAsAnchors Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index aafffac3d4b1c..1a0e5d239d252 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -479,6 +479,9 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + uint64_t MatchedWithCallsAsAnchors = 0; + matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 77ef0008f4f5987719555e6cc3e32da812ae0f31 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 24 Jun 2024 23:11:43 -0700 Subject: [PATCH 02/17] Changed CallHashToBF representation Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 1a0e5d239d252..91b01a99c7485 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -29,6 +29,10 @@ static llvm::cl::opt cl::desc("ignore hash while reading function profile"), cl::Hidden, cl::cat(BoltOptCategory)); +llvm::cl::opt MatchWithCallsAsAnchors("match-with-calls-as-anchors", + cl::desc("Matches with calls as anchors"), + cl::Hidden, cl::cat(BoltOptCategory)); + llvm::cl::opt ProfileUseDFS("profile-use-dfs", cl::desc("use DFS order for YAML profile"), cl::Hidden, cl::cat(BoltOptCategory)); @@ -353,7 +357,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( llvm_unreachable("Unhandled HashFunction"); }; - std::unordered_map CallHashToBF; + std::unordered_map CallHashToBF; for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { if (ProfiledFunctions.count(BF)) @@ -375,12 +379,12 @@ void YAMLProfileReader::matchWithCallsAsAnchors( for (const std::string &FunctionName : FunctionNames) HashString.append(FunctionName); } -CallHashToBF.emplace(ComputeCallHash(HashString), BF); +CallHashToBF[ComputeCallHash(HashString)] = BF; } std::unordered_map ProfiledFunctionIdToName; - for (const yaml::bolt::BinaryFunctionProfile YamlBF : YamlBP.Functions) + for (const yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) ProfiledFunctionIdToName[YamlBF.Id] = YamlBF.Name; for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) { @@ -401,7 +405,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( auto It = CallHashToBF.find(Hash); if (It == CallHashToBF.end()) continue; -matchProfileToFunction(YamlBF, It->second); +matchProfileToFunction(YamlBF, *It->second); ++MatchedWithCallsAsAnchors; } } @@ -480,7 +484,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { matchProfileToFunction(YamlBF, *BF); uint64_t MatchedWithCallsAsAnchors = 0; - matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); + if (opts::MatchWithCallsAsAnchors) +matchWithCallsAsAnchors(BC, MatchedWithCallsAsAnchors); for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) >From ea7cb68ab9e8e158412c2e752986968968a60d93 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 25 Jun 2024 09:28:39 -0700 Subject: [PATCH 03/17] Changed BF called FunctionNames to multiset Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 91b01a99c7485..3b3d73f7af023 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -365,7 +365,7 @@ void YAMLProfileReader::matchWithCallsAsAnchors( std::string HashString; for (const auto &BB : BF->blocks()) { - std::set FunctionNames; + std::multiset FunctionNames; for (const MCInst &Instr : BB) { // Skip non-call instructions. if (!BC.MIB->isCall(Instr)) @@ -397,9 +397,8 @@ void YAMLProfileReader::matchWithCallsAsAnchors( std::string &FunctionName = ProfiledFunctionIdToName[CallSite.DestId]; FunctionNames.insert(FunctionName);
[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/98125 >From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 9 Jul 2024 10:04:25 -0700 Subject: [PATCH] Comments Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 69ea0899c5f2c..6753337c24ea7 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { // Maps binary functions to adjacent functions in the FCG. for (const BinaryFunction *CallerBF : BFs) { -// Add all call targets to the hash map. for (const BinaryBasicBlock &BB : CallerBF->blocks()) { for (const MCInst &Inst : BB) { if (!BC.MIB->isCall(Instr)) @@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { } } - // Create mapping from neighbor hash to BFs. + // Using the constructed adjacent function mapping, creates mapping from + // neighbor hash to BFs. std::unordered_map> NeighborHashToBFs; for (const BinaryFunction *BF : BFs) { @@ -552,12 +552,12 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { .push_back(BF); } - // TODO: change call anchor PR to have this representation - we need it here + // TODO: note, this will be introduced in the matching functions with calls + // as anchors pr DenseMap IdToYAMLBF; - // TODO: change call anchor PR to have this representation - we need it here - // Maps hashes to profiled functions. + // Maps YAML functions to adjacent functions in the profile FCG. std::unordered_map YamlBFToHashes(BFs.size()); @@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { } } - // Matching YAMLBF with neighbor hashes. + // Matches YAMLBF to BFs with neighbor hashes. for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
shawbyoung wrote: @maksfb Just addressed your comments, let me know if everything looks good. https://github.com/llvm/llvm-project/pull/96596 ___ 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] [mlir] [MLIR][LLVM] Use CyclicReplacerCache for recursive DIType import (PR #98203)
https://github.com/zyx-billy created https://github.com/llvm/llvm-project/pull/98203 Use the new CyclicReplacerCache from https://github.com/llvm/llvm-project/pull/98202 to support importing of recursive DITypes in LLVM dialect's DebugImporter. This helps simplify the implementation, allows for separate testing of the cache infra itself, and as a result we even got more efficient translations. --- Stacked PRs: - https://github.com/llvm/llvm-project/pull/98202 >From 288234b7494eae0cd5f1e74db99edaf76290d1fd Mon Sep 17 00:00:00 2001 From: Billy Zhu Date: Tue, 9 Jul 2024 10:28:21 -0700 Subject: [PATCH] use cyclic cache in importer and update tests --- mlir/lib/Target/LLVMIR/DebugImporter.cpp | 142 --- mlir/lib/Target/LLVMIR/DebugImporter.h | 101 ++--- mlir/test/Target/LLVMIR/Import/debug-info.ll | 34 +++-- 3 files changed, 50 insertions(+), 227 deletions(-) diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp index 15737aa681c59..2bbaa485a07a7 100644 --- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp +++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp @@ -28,7 +28,7 @@ using namespace mlir::LLVM::detail; DebugImporter::DebugImporter(ModuleOp mlirModule, bool dropDICompositeTypeElements) -: recursionPruner(mlirModule.getContext()), +: cache([&](llvm::DINode *node) { return createRecSelf(node); }), context(mlirModule.getContext()), mlirModule(mlirModule), dropDICompositeTypeElements(dropDICompositeTypeElements) {} @@ -287,16 +287,9 @@ DINodeAttr DebugImporter::translate(llvm::DINode *node) { return nullptr; // Check for a cached instance. - if (DINodeAttr attr = nodeToAttr.lookup(node)) -return attr; - - // Register with the recursive translator. If it can be handled without - // recursing into it, return the result immediately. - if (DINodeAttr attr = recursionPruner.pruneOrPushTranslationStack(node)) -return attr; - - auto guard = llvm::make_scope_exit( - [&]() { recursionPruner.popTranslationStack(node); }); + auto cacheEntry = cache.lookupOrInit(node); + if (std::optional result = cacheEntry.get()) +return *result; // Convert the debug metadata if possible. auto translateNode = [this](llvm::DINode *node) -> DINodeAttr { @@ -335,20 +328,19 @@ DINodeAttr DebugImporter::translate(llvm::DINode *node) { return nullptr; }; if (DINodeAttr attr = translateNode(node)) { -auto [result, isSelfContained] = -recursionPruner.finalizeTranslation(node, attr); -// Only cache fully self-contained nodes. -if (isSelfContained) - nodeToAttr.try_emplace(node, result); -return result; +// If this node is given a recursive ID, set the recId onto the result. +if (cacheEntry.wasRepeated()) { + DistinctAttr recId = nodeToRecId.lookup(node); + auto recType = cast(attr); + attr = cast(recType.withRecId(recId)); +} +cacheEntry.resolve(attr); +return attr; } + cacheEntry.resolve(nullptr); return nullptr; } -//===--===// -// RecursionPruner -//===--===// - /// Get the `getRecSelf` constructor for the translated type of `node` if its /// translated DITypeAttr supports recursion. Otherwise, returns nullptr. static function_ref @@ -361,104 +353,20 @@ getRecSelfConstructor(llvm::DINode *node) { .Default(CtorType()); } -DINodeAttr DebugImporter::RecursionPruner::pruneOrPushTranslationStack( -llvm::DINode *node) { - // If the node type is capable of being recursive, check if it's seen - // before. +std::optional DebugImporter::createRecSelf(llvm::DINode *node) { auto recSelfCtor = getRecSelfConstructor(node); - if (recSelfCtor) { -// If a cyclic dependency is detected since the same node is being -// traversed twice, emit a recursive self type, and mark the duplicate -// node on the translationStack so it can emit a recursive decl type. -auto [iter, inserted] = translationStack.try_emplace(node); -if (!inserted) { - // The original node may have already been assigned a recursive ID from - // a different self-reference. Use that if possible. - DIRecursiveTypeAttrInterface recSelf = iter->second.recSelf; - if (!recSelf) { -DistinctAttr recId = nodeToRecId.lookup(node); -if (!recId) { - recId = DistinctAttr::create(UnitAttr::get(context)); - nodeToRecId[node] = recId; -} -recSelf = recSelfCtor(recId); -iter->second.recSelf = recSelf; - } - // Inject the self-ref into the previous layer. - translationStack.back().second.unboundSelfRefs.insert(recSelf); - return cast(recSelf); -} + if (!recSelfCtor) +return std::nullopt; + + // The original node may have already been assigned a recursive ID from + //
[llvm-branch-commits] [mlir] [MLIR] Cyclic AttrType Replacer (PR #98206)
https://github.com/zyx-billy created https://github.com/llvm/llvm-project/pull/98206 The current `AttrTypeReplacer` does not allow for custom handling of replacer functions that may cause self-recursion. For example, the replacement of one attr/type may depend on the replacement of another attr/type (by calling into the replacer manually again), which in turn may depend on the replacement of the original attr/type. To enable this functionality, this PR broke out the original AttrTypeReplacer into two parts: - An uncached base version (`detail::AttrTypeReplacerBase`) that allows registering replacer functions and has logic for invoking it on attr/types & their sub-elements - A cached version (`AttrTypeReplacer`) that provides the same caching as the original one. This is still the one used everywhere and behavior is unchanged. On top of the uncached base version, a `CyclicAttrTypeReplacer` is introduced that provides caching & cycle-handling for replacer logic that is cyclic. Cycle-breaking & caching is provided by the `CyclicReplacerCache` from https://github.com/llvm/llvm-project/pull/98202. Both concrete implementations of the uncached base version use CRTP to avoid dynamic dispatch. The base class merely provides replacer registration & invocation, and is not meant to be used, or otherwise extended elsewhere. --- Stacked PRs: - https://github.com/llvm/llvm-project/pull/98202 >From 0d38de6f61b4dcb6d0d3ba5ddc75a64819f64c0a Mon Sep 17 00:00:00 2001 From: Billy Zhu Date: Tue, 9 Jul 2024 10:27:13 -0700 Subject: [PATCH] refactor attrtype replacers & add tests --- mlir/include/mlir/IR/AttrTypeSubElements.h | 142 +++-- mlir/lib/IR/AttrTypeSubElements.cpp| 146 ++--- mlir/unittests/IR/AttrTypeReplacerTest.cpp | 231 + mlir/unittests/IR/CMakeLists.txt | 1 + 4 files changed, 469 insertions(+), 51 deletions(-) create mode 100644 mlir/unittests/IR/AttrTypeReplacerTest.cpp diff --git a/mlir/include/mlir/IR/AttrTypeSubElements.h b/mlir/include/mlir/IR/AttrTypeSubElements.h index 3105040b87631..2e953d490f92a 100644 --- a/mlir/include/mlir/IR/AttrTypeSubElements.h +++ b/mlir/include/mlir/IR/AttrTypeSubElements.h @@ -16,6 +16,7 @@ #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Visitors.h" +#include "mlir/Support/CyclicReplacerCache.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include @@ -116,9 +117,21 @@ class AttrTypeWalker { /// AttrTypeReplacer //===--===// -/// This class provides a utility for replacing attributes/types, and their sub -/// elements. Multiple replacement functions may be registered. -class AttrTypeReplacer { +namespace detail { + +/// This class provides a base utility for replacing attributes/types, and their +/// sub elements. Multiple replacement functions may be registered. +/// +/// This base utility is uncached. Users can choose between two cached versions +/// of this replacer: +/// * For non-cyclic replacer logic, use `AttrTypeReplacer`. +/// * For cyclic replacer logic, use `CyclicAttrTypeReplacer`. +/// +/// Concrete implementations implement the following `replace` entry functions: +/// * Attribute replace(Attribute attr); +/// * Type replace(Type type); +template +class AttrTypeReplacerBase { public: //======// // Application @@ -139,12 +152,6 @@ class AttrTypeReplacer { bool replaceLocs = false, bool replaceTypes = false); - /// Replace the given attribute/type, and recursively replace any sub - /// elements. Returns either the new attribute/type, or nullptr in the case of - /// failure. - Attribute replace(Attribute attr); - Type replace(Type type); - //======// // Registration //======// @@ -206,29 +213,122 @@ class AttrTypeReplacer { }); } -private: - /// Internal implementation of the `replace` methods above. - template - T replaceImpl(T element, ReplaceFns &replaceFns); - - /// Replace the sub elements of the given interface. - template - T replaceSubElements(T interface); +protected: + /// Invokes the registered replacement functions from most recently registered + /// to least recently registered until a successful replacement is returned. + /// Unless skipping is requested, invokes `replace` on sub-elements of the + /// current attr/type. + Attribute replaceBase(Attribute attr); + Type replaceBase(Type type); +private: /// The set of replacement functions that map sub elements. std::vector> attrReplacementFns; std::vector> typeReplacementFns; +}; + +} // namespace detail + +/// This is an attribute/type replacer that is naively cached. It is best
[llvm-branch-commits] [mlir] [MLIR][LLVM] Use CyclicReplacerCache for recursive DIType import (PR #98203)
https://github.com/zyx-billy edited https://github.com/llvm/llvm-project/pull/98203 ___ 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] [mlir] [MLIR] Cyclic AttrType Replacer (PR #98206)
https://github.com/zyx-billy edited https://github.com/llvm/llvm-project/pull/98206 ___ 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] [mlir] [MLIR] Cyclic AttrType Replacer (PR #98206)
https://github.com/zyx-billy updated https://github.com/llvm/llvm-project/pull/98206 >From 8d1dd886c4a80507c8a97dda15e91acbfa7c3619 Mon Sep 17 00:00:00 2001 From: Billy Zhu Date: Tue, 9 Jul 2024 10:27:13 -0700 Subject: [PATCH] refactor attrtype replacers & add tests --- mlir/include/mlir/IR/AttrTypeSubElements.h | 138 ++-- mlir/lib/IR/AttrTypeSubElements.cpp| 146 ++--- mlir/unittests/IR/AttrTypeReplacerTest.cpp | 231 + mlir/unittests/IR/CMakeLists.txt | 1 + 4 files changed, 467 insertions(+), 49 deletions(-) create mode 100644 mlir/unittests/IR/AttrTypeReplacerTest.cpp diff --git a/mlir/include/mlir/IR/AttrTypeSubElements.h b/mlir/include/mlir/IR/AttrTypeSubElements.h index 3105040b87631..234767deea00a 100644 --- a/mlir/include/mlir/IR/AttrTypeSubElements.h +++ b/mlir/include/mlir/IR/AttrTypeSubElements.h @@ -16,6 +16,7 @@ #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Visitors.h" +#include "mlir/Support/CyclicReplacerCache.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include @@ -116,9 +117,21 @@ class AttrTypeWalker { /// AttrTypeReplacer //===--===// -/// This class provides a utility for replacing attributes/types, and their sub -/// elements. Multiple replacement functions may be registered. -class AttrTypeReplacer { +namespace detail { + +/// This class provides a base utility for replacing attributes/types, and their +/// sub elements. Multiple replacement functions may be registered. +/// +/// This base utility is uncached. Users can choose between two cached versions +/// of this replacer: +/// * For non-cyclic replacer logic, use `AttrTypeReplacer`. +/// * For cyclic replacer logic, use `CyclicAttrTypeReplacer`. +/// +/// Concrete implementations implement the following `replace` entry functions: +/// * Attribute replace(Attribute attr); +/// * Type replace(Type type); +template +class AttrTypeReplacerBase { public: //======// // Application @@ -139,12 +152,6 @@ class AttrTypeReplacer { bool replaceLocs = false, bool replaceTypes = false); - /// Replace the given attribute/type, and recursively replace any sub - /// elements. Returns either the new attribute/type, or nullptr in the case of - /// failure. - Attribute replace(Attribute attr); - Type replace(Type type); - //======// // Registration //======// @@ -206,21 +213,114 @@ class AttrTypeReplacer { }); } -private: - /// Internal implementation of the `replace` methods above. - template - T replaceImpl(T element, ReplaceFns &replaceFns); - - /// Replace the sub elements of the given interface. - template - T replaceSubElements(T interface); +protected: + /// Invokes the registered replacement functions from most recently registered + /// to least recently registered until a successful replacement is returned. + /// Unless skipping is requested, invokes `replace` on sub-elements of the + /// current attr/type. + Attribute replaceBase(Attribute attr); + Type replaceBase(Type type); +private: /// The set of replacement functions that map sub elements. std::vector> attrReplacementFns; std::vector> typeReplacementFns; +}; + +} // namespace detail + +/// This is an attribute/type replacer that is naively cached. It is best used +/// when the replacer logic is guaranteed to not contain cycles. Otherwise, any +/// re-occurrence of an in-progress element will be skipped. +class AttrTypeReplacer : public detail::AttrTypeReplacerBase { +public: + Attribute replace(Attribute attr); + Type replace(Type type); + +private: + /// Shared concrete implementation of the public `replace` functions. Invokes + /// `replaceBase` with caching. + template + T cachedReplaceImpl(T element); + + // Stores the opaque pointer of an attribute or type. + DenseMap cache; +}; + +/// This is an attribute/type replacer that supports custom handling of cycles +/// in the replacer logic. In addition to registering replacer functions, it +/// allows registering cycle-breaking functions in the same style. +class CyclicAttrTypeReplacer +: public detail::AttrTypeReplacerBase { +public: + CyclicAttrTypeReplacer(); - /// The set of cached mappings for attributes/types. - DenseMap attrTypeMap; + //======// + // Application + //======// + + Attribute replace(Attribute attr); + Type replace(Type type); + + //======// + // Registration + //===-
[llvm-branch-commits] [mlir] [MLIR][LLVM] Use CyclicReplacerCache for recursive DIType import (PR #98203)
https://github.com/zyx-billy updated https://github.com/llvm/llvm-project/pull/98203 >From a0b59b246a1b8860fad16f1f74537c38b5abf2cf Mon Sep 17 00:00:00 2001 From: Billy Zhu Date: Tue, 9 Jul 2024 10:28:21 -0700 Subject: [PATCH] use cyclic cache in importer and update tests --- mlir/lib/Target/LLVMIR/DebugImporter.cpp | 143 --- mlir/lib/Target/LLVMIR/DebugImporter.h | 101 ++--- mlir/test/Target/LLVMIR/Import/debug-info.ll | 34 +++-- 3 files changed, 51 insertions(+), 227 deletions(-) diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp index 15737aa681c59..f104b72209c39 100644 --- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp +++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp @@ -28,7 +28,7 @@ using namespace mlir::LLVM::detail; DebugImporter::DebugImporter(ModuleOp mlirModule, bool dropDICompositeTypeElements) -: recursionPruner(mlirModule.getContext()), +: cache([&](llvm::DINode *node) { return createRecSelf(node); }), context(mlirModule.getContext()), mlirModule(mlirModule), dropDICompositeTypeElements(dropDICompositeTypeElements) {} @@ -287,16 +287,9 @@ DINodeAttr DebugImporter::translate(llvm::DINode *node) { return nullptr; // Check for a cached instance. - if (DINodeAttr attr = nodeToAttr.lookup(node)) -return attr; - - // Register with the recursive translator. If it can be handled without - // recursing into it, return the result immediately. - if (DINodeAttr attr = recursionPruner.pruneOrPushTranslationStack(node)) -return attr; - - auto guard = llvm::make_scope_exit( - [&]() { recursionPruner.popTranslationStack(node); }); + auto cacheEntry = cache.lookupOrInit(node); + if (std::optional result = cacheEntry.get()) +return *result; // Convert the debug metadata if possible. auto translateNode = [this](llvm::DINode *node) -> DINodeAttr { @@ -335,20 +328,20 @@ DINodeAttr DebugImporter::translate(llvm::DINode *node) { return nullptr; }; if (DINodeAttr attr = translateNode(node)) { -auto [result, isSelfContained] = -recursionPruner.finalizeTranslation(node, attr); -// Only cache fully self-contained nodes. -if (isSelfContained) - nodeToAttr.try_emplace(node, result); -return result; +// If this node was repeated, lookup its recursive ID and assign it to the +// base result. +if (cacheEntry.wasRepeated()) { + DistinctAttr recId = nodeToRecId.lookup(node); + auto recType = cast(attr); + attr = cast(recType.withRecId(recId)); +} +cacheEntry.resolve(attr); +return attr; } + cacheEntry.resolve(nullptr); return nullptr; } -//===--===// -// RecursionPruner -//===--===// - /// Get the `getRecSelf` constructor for the translated type of `node` if its /// translated DITypeAttr supports recursion. Otherwise, returns nullptr. static function_ref @@ -361,104 +354,20 @@ getRecSelfConstructor(llvm::DINode *node) { .Default(CtorType()); } -DINodeAttr DebugImporter::RecursionPruner::pruneOrPushTranslationStack( -llvm::DINode *node) { - // If the node type is capable of being recursive, check if it's seen - // before. +std::optional DebugImporter::createRecSelf(llvm::DINode *node) { auto recSelfCtor = getRecSelfConstructor(node); - if (recSelfCtor) { -// If a cyclic dependency is detected since the same node is being -// traversed twice, emit a recursive self type, and mark the duplicate -// node on the translationStack so it can emit a recursive decl type. -auto [iter, inserted] = translationStack.try_emplace(node); -if (!inserted) { - // The original node may have already been assigned a recursive ID from - // a different self-reference. Use that if possible. - DIRecursiveTypeAttrInterface recSelf = iter->second.recSelf; - if (!recSelf) { -DistinctAttr recId = nodeToRecId.lookup(node); -if (!recId) { - recId = DistinctAttr::create(UnitAttr::get(context)); - nodeToRecId[node] = recId; -} -recSelf = recSelfCtor(recId); -iter->second.recSelf = recSelf; - } - // Inject the self-ref into the previous layer. - translationStack.back().second.unboundSelfRefs.insert(recSelf); - return cast(recSelf); -} + if (!recSelfCtor) +return std::nullopt; + + // The original node may have already been assigned a recursive ID from + // a different self-reference. Use that if possible. + DistinctAttr recId = nodeToRecId.lookup(node); + if (!recId) { +recId = DistinctAttr::create(UnitAttr::get(context)); +nodeToRecId[node] = recId; } - - return lookup(node); -} - -std::pair -DebugImporter::RecursionPruner::finalizeTranslation(llvm::DINode *node, -
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -40,6 +40,8 @@ class YAMLProfileReader : public ProfileReaderBase { /// Check if the file contains YAML. static bool isYAML(StringRef Filename); + using FunctionMap = DenseMap; aaupov wrote: ```suggestion using ProfileLookupMap = DenseMap; ``` https://github.com/llvm/llvm-project/pull/96596 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
@@ -181,20 +182,19 @@ std::string hashBlockCalls(BinaryContext &BC, const BinaryBasicBlock &BB) { /// The same as the $hashBlockCalls function, but for profiled functions. std::string -hashBlockCalls(const DenseMap &IdToFunctionName, +hashBlockCalls(const DenseMap + &IdToYamlFunction, const yaml::bolt::BinaryBasicBlockProfile &YamlBB) { - std::multiset FunctionNames; + std::vector FunctionNames; for (const yaml::bolt::CallSiteInfo &CallSiteInfo : YamlBB.CallSites) { -auto It = IdToFunctionName.find(CallSiteInfo.DestId); -if (It == IdToFunctionName.end()) +auto It = IdToYamlFunction.find(CallSiteInfo.DestId); +if (It == IdToYamlFunction.end()) continue; -StringRef Name = It->second; -const size_t Pos = Name.find("(*"); -if (Pos != StringRef::npos) - Name = Name.substr(0, Pos); -FunctionNames.insert(std::string(Name)); +StringRef Name = +NameResolver::removeSuffix(It->second->Name, StringRef("(*")); aaupov wrote: I think the intent of Maksim's comment was to hide an implementation detail (using `(*N)` suffix) in relevant component (NameResolver). https://github.com/llvm/llvm-project/pull/96596 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/98125 >From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 9 Jul 2024 10:04:25 -0700 Subject: [PATCH 1/2] Comments Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 69ea0899c5f2c..6753337c24ea7 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { // Maps binary functions to adjacent functions in the FCG. for (const BinaryFunction *CallerBF : BFs) { -// Add all call targets to the hash map. for (const BinaryBasicBlock &BB : CallerBF->blocks()) { for (const MCInst &Inst : BB) { if (!BC.MIB->isCall(Instr)) @@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { } } - // Create mapping from neighbor hash to BFs. + // Using the constructed adjacent function mapping, creates mapping from + // neighbor hash to BFs. std::unordered_map> NeighborHashToBFs; for (const BinaryFunction *BF : BFs) { @@ -552,12 +552,12 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { .push_back(BF); } - // TODO: change call anchor PR to have this representation - we need it here + // TODO: note, this will be introduced in the matching functions with calls + // as anchors pr DenseMap IdToYAMLBF; - // TODO: change call anchor PR to have this representation - we need it here - // Maps hashes to profiled functions. + // Maps YAML functions to adjacent functions in the profile FCG. std::unordered_map YamlBFToHashes(BFs.size()); @@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { } } - // Matching YAMLBF with neighbor hashes. + // Matches YAMLBF to BFs with neighbor hashes. for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; >From ee9049fc4bd3d4203c19c9c0982a78ab3b47666f Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 9 Jul 2024 13:52:05 -0700 Subject: [PATCH 2/2] Moved blended hash definition Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 69 ++- bolt/lib/Profile/StaleProfileMatching.cpp | 65 --- bolt/lib/Profile/YAMLProfileReader.cpp| 110 -- 3 files changed, 119 insertions(+), 125 deletions(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 36e8f8739eee1..e8a34ecad9a08 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -16,6 +16,73 @@ namespace llvm { namespace bolt { +/// An object wrapping several components of a basic block hash. The combined +/// (blended) hash is represented and stored as one uint64_t, while individual +/// components are of smaller size (e.g., uint16_t or uint8_t). +struct BlendedBlockHash { +private: + using ValueOffset = Bitfield::Element; + using ValueOpcode = Bitfield::Element; + using ValueInstr = Bitfield::Element; + using ValuePred = Bitfield::Element; + using ValueSucc = Bitfield::Element; + +public: + explicit BlendedBlockHash() {} + + explicit BlendedBlockHash(uint64_t Hash) { +Offset = Bitfield::get(Hash); +OpcodeHash = Bitfield::get(Hash); +InstrHash = Bitfield::get(Hash); +PredHash = Bitfield::get(Hash); +SuccHash = Bitfield::get(Hash); + } + + /// Combine the blended hash into uint64_t. + uint64_t combine() const { +uint64_t Hash = 0; +Bitfield::set(Hash, Offset); +Bitfield::set(Hash, OpcodeHash); +Bitfield::set(Hash, InstrHash); +Bitfield::set(Hash, PredHash); +Bitfield::set(Hash, SuccHash); +return Hash; + } + + /// Compute a distance between two given blended hashes. The smaller the + /// distance, the more similar two blocks are. For identical basic blocks, + /// the distance is zero. + uint64_t distance(const BlendedBlockHash &BBH) const { +assert(OpcodeHash == BBH.OpcodeHash && + "incorrect blended hash distance computation"); +uint64_t Dist = 0; +// Account for NeighborHash +Dist += SuccHash == BBH.SuccHash ? 0 : 1; +Dist += PredHash == BBH.PredHash ? 0 : 1; +Dist <<= 16; +// Account for InstrHash +Dist += InstrHash == BBH.InstrHash ? 0 : 1; +Dist <<= 16; +// Account for Offset +Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset); +return Dist; + } + + /// The offset of the basic block from the function start. + uint16_t Offset{0}; + /// (Loose) Hash of the basic block instructions, excluding operands. + uint16_t OpcodeHash{0}; + /// (Strong)
[llvm-branch-commits] [mlir] [MLIR][LLVM] Use CyclicReplacerCache for recursive DIType import (PR #98203)
https://github.com/zyx-billy ready_for_review https://github.com/llvm/llvm-project/pull/98203 ___ 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] [mlir] [MLIR] Cyclic AttrType Replacer (PR #98206)
https://github.com/zyx-billy ready_for_review https://github.com/llvm/llvm-project/pull/98206 ___ 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] [mlir] [MLIR][LLVM] Use CyclicReplacerCache for recursive DIType import (PR #98203)
llvmbot wrote: @llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-mlir Author: Billy Zhu (zyx-billy) Changes Use the new CyclicReplacerCache from https://github.com/llvm/llvm-project/pull/98202 to support importing of recursive DITypes in LLVM dialect's DebugImporter. This helps simplify the implementation, allows for separate testing of the cache infra itself, and as a result we even got more efficient translations. --- Stacked PRs: - https://github.com/llvm/llvm-project/pull/98202 - ➡️ https://github.com/llvm/llvm-project/pull/98203 --- Full diff: https://github.com/llvm/llvm-project/pull/98203.diff 3 Files Affected: - (modified) mlir/lib/Target/LLVMIR/DebugImporter.cpp (+26-117) - (modified) mlir/lib/Target/LLVMIR/DebugImporter.h (+9-92) - (modified) mlir/test/Target/LLVMIR/Import/debug-info.ll (+16-18) ``diff diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp index 15737aa681c59..f104b72209c39 100644 --- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp +++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp @@ -28,7 +28,7 @@ using namespace mlir::LLVM::detail; DebugImporter::DebugImporter(ModuleOp mlirModule, bool dropDICompositeTypeElements) -: recursionPruner(mlirModule.getContext()), +: cache([&](llvm::DINode *node) { return createRecSelf(node); }), context(mlirModule.getContext()), mlirModule(mlirModule), dropDICompositeTypeElements(dropDICompositeTypeElements) {} @@ -287,16 +287,9 @@ DINodeAttr DebugImporter::translate(llvm::DINode *node) { return nullptr; // Check for a cached instance. - if (DINodeAttr attr = nodeToAttr.lookup(node)) -return attr; - - // Register with the recursive translator. If it can be handled without - // recursing into it, return the result immediately. - if (DINodeAttr attr = recursionPruner.pruneOrPushTranslationStack(node)) -return attr; - - auto guard = llvm::make_scope_exit( - [&]() { recursionPruner.popTranslationStack(node); }); + auto cacheEntry = cache.lookupOrInit(node); + if (std::optional result = cacheEntry.get()) +return *result; // Convert the debug metadata if possible. auto translateNode = [this](llvm::DINode *node) -> DINodeAttr { @@ -335,20 +328,20 @@ DINodeAttr DebugImporter::translate(llvm::DINode *node) { return nullptr; }; if (DINodeAttr attr = translateNode(node)) { -auto [result, isSelfContained] = -recursionPruner.finalizeTranslation(node, attr); -// Only cache fully self-contained nodes. -if (isSelfContained) - nodeToAttr.try_emplace(node, result); -return result; +// If this node was repeated, lookup its recursive ID and assign it to the +// base result. +if (cacheEntry.wasRepeated()) { + DistinctAttr recId = nodeToRecId.lookup(node); + auto recType = cast(attr); + attr = cast(recType.withRecId(recId)); +} +cacheEntry.resolve(attr); +return attr; } + cacheEntry.resolve(nullptr); return nullptr; } -//===--===// -// RecursionPruner -//===--===// - /// Get the `getRecSelf` constructor for the translated type of `node` if its /// translated DITypeAttr supports recursion. Otherwise, returns nullptr. static function_ref @@ -361,104 +354,20 @@ getRecSelfConstructor(llvm::DINode *node) { .Default(CtorType()); } -DINodeAttr DebugImporter::RecursionPruner::pruneOrPushTranslationStack( -llvm::DINode *node) { - // If the node type is capable of being recursive, check if it's seen - // before. +std::optional DebugImporter::createRecSelf(llvm::DINode *node) { auto recSelfCtor = getRecSelfConstructor(node); - if (recSelfCtor) { -// If a cyclic dependency is detected since the same node is being -// traversed twice, emit a recursive self type, and mark the duplicate -// node on the translationStack so it can emit a recursive decl type. -auto [iter, inserted] = translationStack.try_emplace(node); -if (!inserted) { - // The original node may have already been assigned a recursive ID from - // a different self-reference. Use that if possible. - DIRecursiveTypeAttrInterface recSelf = iter->second.recSelf; - if (!recSelf) { -DistinctAttr recId = nodeToRecId.lookup(node); -if (!recId) { - recId = DistinctAttr::create(UnitAttr::get(context)); - nodeToRecId[node] = recId; -} -recSelf = recSelfCtor(recId); -iter->second.recSelf = recSelf; - } - // Inject the self-ref into the previous layer. - translationStack.back().second.unboundSelfRefs.insert(recSelf); - return cast(recSelf); -} + if (!recSelfCtor) +return std::nullopt; + + // The original node may have already been assigned a recursive ID from + // a different self-reference. Use that
[llvm-branch-commits] [mlir] [MLIR] Cyclic AttrType Replacer (PR #98206)
llvmbot wrote: @llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-core Author: Billy Zhu (zyx-billy) Changes The current `AttrTypeReplacer` does not allow for custom handling of replacer functions that may cause self-recursion. For example, the replacement of one attr/type may depend on the replacement of another attr/type (by calling into the replacer manually again), which in turn may depend on the replacement of the original attr/type. To enable this functionality, this PR broke out the original AttrTypeReplacer into two parts: - An uncached base version (`detail::AttrTypeReplacerBase`) that allows registering replacer functions and has logic for invoking it on attr/types & their sub-elements - A cached version (`AttrTypeReplacer`) that provides the same caching as the original one. This is still the one used everywhere and behavior is unchanged. On top of the uncached base version, a `CyclicAttrTypeReplacer` is introduced that provides caching & cycle-handling for replacer logic that is cyclic. Cycle-breaking & caching is provided by the `CyclicReplacerCache` from https://github.com/llvm/llvm-project/pull/98202. Both concrete implementations of the uncached base version use CRTP to avoid dynamic dispatch. The base class merely provides replacer registration & invocation, and is not meant to be used, or otherwise extended elsewhere. --- Stacked PRs: - https://github.com/llvm/llvm-project/pull/98202 - ➡️ https://github.com/llvm/llvm-project/pull/98206 --- Patch is 24.36 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/98206.diff 4 Files Affected: - (modified) mlir/include/mlir/IR/AttrTypeSubElements.h (+119-19) - (modified) mlir/lib/IR/AttrTypeSubElements.cpp (+116-30) - (added) mlir/unittests/IR/AttrTypeReplacerTest.cpp (+231) - (modified) mlir/unittests/IR/CMakeLists.txt (+1) ``diff diff --git a/mlir/include/mlir/IR/AttrTypeSubElements.h b/mlir/include/mlir/IR/AttrTypeSubElements.h index 3105040b87631..234767deea00a 100644 --- a/mlir/include/mlir/IR/AttrTypeSubElements.h +++ b/mlir/include/mlir/IR/AttrTypeSubElements.h @@ -16,6 +16,7 @@ #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Visitors.h" +#include "mlir/Support/CyclicReplacerCache.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include @@ -116,9 +117,21 @@ class AttrTypeWalker { /// AttrTypeReplacer //===--===// -/// This class provides a utility for replacing attributes/types, and their sub -/// elements. Multiple replacement functions may be registered. -class AttrTypeReplacer { +namespace detail { + +/// This class provides a base utility for replacing attributes/types, and their +/// sub elements. Multiple replacement functions may be registered. +/// +/// This base utility is uncached. Users can choose between two cached versions +/// of this replacer: +/// * For non-cyclic replacer logic, use `AttrTypeReplacer`. +/// * For cyclic replacer logic, use `CyclicAttrTypeReplacer`. +/// +/// Concrete implementations implement the following `replace` entry functions: +/// * Attribute replace(Attribute attr); +/// * Type replace(Type type); +template +class AttrTypeReplacerBase { public: //======// // Application @@ -139,12 +152,6 @@ class AttrTypeReplacer { bool replaceLocs = false, bool replaceTypes = false); - /// Replace the given attribute/type, and recursively replace any sub - /// elements. Returns either the new attribute/type, or nullptr in the case of - /// failure. - Attribute replace(Attribute attr); - Type replace(Type type); - //======// // Registration //======// @@ -206,21 +213,114 @@ class AttrTypeReplacer { }); } -private: - /// Internal implementation of the `replace` methods above. - template - T replaceImpl(T element, ReplaceFns &replaceFns); - - /// Replace the sub elements of the given interface. - template - T replaceSubElements(T interface); +protected: + /// Invokes the registered replacement functions from most recently registered + /// to least recently registered until a successful replacement is returned. + /// Unless skipping is requested, invokes `replace` on sub-elements of the + /// current attr/type. + Attribute replaceBase(Attribute attr); + Type replaceBase(Type type); +private: /// The set of replacement functions that map sub elements. std::vector> attrReplacementFns; std::vector> typeReplacementFns; +}; + +} // namespace detail + +/// This is an attribute/type replacer that is naively cached. It is best used +/// when the replacer logic is guaranteed to not contain cycles. O
[llvm-branch-commits] Improve tests, change API (PR #98235)
https://github.com/pcc created https://github.com/llvm/llvm-project/pull/98235 None ___ 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] Improve tests, change API (PR #98235)
llvmbot wrote: @llvm/pr-subscribers-llvm-binary-utilities Author: None (pcc) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/98235.diff 3 Files Affected: - (modified) llvm/include/llvm/Object/ArchiveWriter.h (+6-2) - (modified) llvm/lib/Object/ArchiveWriter.cpp (+22-14) - (modified) llvm/test/Object/archive-malformed-object.test (+14-1) ``diff diff --git a/llvm/include/llvm/Object/ArchiveWriter.h b/llvm/include/llvm/Object/ArchiveWriter.h index a19f8fcc79d74..f965a12c45267 100644 --- a/llvm/include/llvm/Object/ArchiveWriter.h +++ b/llvm/include/llvm/Object/ArchiveWriter.h @@ -48,18 +48,22 @@ enum class SymtabWritingMode { BigArchive64 // Only write the 64-bit symbol table. }; +void warnToStderr(Error Err); + Error writeArchive(StringRef ArcName, ArrayRef NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr OldArchiveBuf = nullptr, - std::optional IsEC = std::nullopt); + std::optional IsEC = std::nullopt, + function_ref Warn = warnToStderr); // writeArchiveToBuffer is similar to writeArchive but returns the Archive in a // buffer instead of writing it out to a file. Expected> writeArchiveToBuffer(ArrayRef NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, - bool Deterministic, bool Thin); + bool Deterministic, bool Thin, + function_ref Warn = warnToStderr); } #endif diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index c6d443ff9d15a..1c75268322257 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -483,7 +483,7 @@ static uint64_t computeHeadersSize(object::Archive::Kind Kind, static Expected> getSymbolicFile(MemoryBufferRef Buf, LLVMContext &Context, -object::Archive::Kind Kind) { +object::Archive::Kind Kind, function_ref Warn) { const file_magic Type = identify_magic(Buf.getBuffer()); // Don't attempt to read non-symbolic file types. if (!object::SymbolicFile::isSymbolicFile(Type, &Context)) @@ -512,9 +512,7 @@ getSymbolicFile(MemoryBufferRef Buf, LLVMContext &Context, case object::Archive::K_BSD: case object::Archive::K_GNU: case object::Archive::K_GNU64: -llvm::logAllUnhandledErrors(ObjOrErr.takeError(), llvm::errs(), -"warning: " + Buf.getBufferIdentifier() + -": "); +Warn(ObjOrErr.takeError()); return nullptr; case object::Archive::K_AIXBIG: case object::Archive::K_COFF: @@ -782,7 +780,7 @@ computeMemberData(raw_ostream &StringTable, raw_ostream &SymNames, object::Archive::Kind Kind, bool Thin, bool Deterministic, SymtabWritingMode NeedSymbols, SymMap *SymMap, LLVMContext &Context, ArrayRef NewMembers, - std::optional IsEC) { + std::optional IsEC, function_ref Warn) { static char PaddingData[8] = {'\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n'}; uint64_t MemHeadPadSize = 0; uint64_t Pos = @@ -850,8 +848,10 @@ computeMemberData(raw_ostream &StringTable, raw_ostream &SymNames, if (NeedSymbols != SymtabWritingMode::NoSymtab || isAIXBigArchive(Kind)) { for (const NewArchiveMember &M : NewMembers) { - Expected> SymFileOrErr = - getSymbolicFile(M.Buf->getMemBufferRef(), Context, Kind); + Expected> SymFileOrErr = getSymbolicFile( + M.Buf->getMemBufferRef(), Context, Kind, [&](Error Err) { +Warn(createFileError(M.MemberName, std::move(Err))); + }); if (!SymFileOrErr) return createFileError(M.MemberName, SymFileOrErr.takeError()); SymFiles.push_back(std::move(*SymFileOrErr)); @@ -1031,7 +1031,8 @@ Expected computeArchiveRelativePath(StringRef From, StringRef To) { static Error writeArchiveToStream(raw_ostream &Out, ArrayRef NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, - bool Deterministic, bool Thin, std::optional IsEC) { + bool Deterministic, bool Thin, std::optional IsEC, + function_ref Warn) { assert((!Thin || !isBSDLike(Kind)) && "Only the gnu format has a thin mode"); SmallString<0> SymNamesBuf; @@ -1053,7 +1054,7 @@ writeArchiveToStream(raw_ostream &Out, ArrayRef NewMembers, Expected> DataOrErr = computeMemberData( StringTable, SymNames, Kind, Thin, Deterministic, WriteSymtab, - isCOFFArchive(Kind) ? &SymMap : nullptr, Context, NewMembers, IsEC); + isCOFFArchive(Kind) ? &SymMap : nullptr, Context, NewMembers, IsEC, Warn); if (Error E = DataOrErr.takeError()) return E; std::vector &Da
[llvm-branch-commits] Improve tests, change API (PR #98235)
https://github.com/pcc closed https://github.com/llvm/llvm-project/pull/98235 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/98125 >From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 9 Jul 2024 10:04:25 -0700 Subject: [PATCH 1/3] Comments Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 69ea0899c5f2c..6753337c24ea7 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { // Maps binary functions to adjacent functions in the FCG. for (const BinaryFunction *CallerBF : BFs) { -// Add all call targets to the hash map. for (const BinaryBasicBlock &BB : CallerBF->blocks()) { for (const MCInst &Inst : BB) { if (!BC.MIB->isCall(Instr)) @@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { } } - // Create mapping from neighbor hash to BFs. + // Using the constructed adjacent function mapping, creates mapping from + // neighbor hash to BFs. std::unordered_map> NeighborHashToBFs; for (const BinaryFunction *BF : BFs) { @@ -552,12 +552,12 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { .push_back(BF); } - // TODO: change call anchor PR to have this representation - we need it here + // TODO: note, this will be introduced in the matching functions with calls + // as anchors pr DenseMap IdToYAMLBF; - // TODO: change call anchor PR to have this representation - we need it here - // Maps hashes to profiled functions. + // Maps YAML functions to adjacent functions in the profile FCG. std::unordered_map YamlBFToHashes(BFs.size()); @@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { } } - // Matching YAMLBF with neighbor hashes. + // Matches YAMLBF to BFs with neighbor hashes. for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; >From ee9049fc4bd3d4203c19c9c0982a78ab3b47666f Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Tue, 9 Jul 2024 13:52:05 -0700 Subject: [PATCH 2/3] Moved blended hash definition Created using spr 1.3.4 --- bolt/include/bolt/Profile/YAMLProfileReader.h | 69 ++- bolt/lib/Profile/StaleProfileMatching.cpp | 65 --- bolt/lib/Profile/YAMLProfileReader.cpp| 110 -- 3 files changed, 119 insertions(+), 125 deletions(-) diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h index 36e8f8739eee1..e8a34ecad9a08 100644 --- a/bolt/include/bolt/Profile/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -16,6 +16,73 @@ namespace llvm { namespace bolt { +/// An object wrapping several components of a basic block hash. The combined +/// (blended) hash is represented and stored as one uint64_t, while individual +/// components are of smaller size (e.g., uint16_t or uint8_t). +struct BlendedBlockHash { +private: + using ValueOffset = Bitfield::Element; + using ValueOpcode = Bitfield::Element; + using ValueInstr = Bitfield::Element; + using ValuePred = Bitfield::Element; + using ValueSucc = Bitfield::Element; + +public: + explicit BlendedBlockHash() {} + + explicit BlendedBlockHash(uint64_t Hash) { +Offset = Bitfield::get(Hash); +OpcodeHash = Bitfield::get(Hash); +InstrHash = Bitfield::get(Hash); +PredHash = Bitfield::get(Hash); +SuccHash = Bitfield::get(Hash); + } + + /// Combine the blended hash into uint64_t. + uint64_t combine() const { +uint64_t Hash = 0; +Bitfield::set(Hash, Offset); +Bitfield::set(Hash, OpcodeHash); +Bitfield::set(Hash, InstrHash); +Bitfield::set(Hash, PredHash); +Bitfield::set(Hash, SuccHash); +return Hash; + } + + /// Compute a distance between two given blended hashes. The smaller the + /// distance, the more similar two blocks are. For identical basic blocks, + /// the distance is zero. + uint64_t distance(const BlendedBlockHash &BBH) const { +assert(OpcodeHash == BBH.OpcodeHash && + "incorrect blended hash distance computation"); +uint64_t Dist = 0; +// Account for NeighborHash +Dist += SuccHash == BBH.SuccHash ? 0 : 1; +Dist += PredHash == BBH.PredHash ? 0 : 1; +Dist <<= 16; +// Account for InstrHash +Dist += InstrHash == BBH.InstrHash ? 0 : 1; +Dist <<= 16; +// Account for Offset +Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset); +return Dist; + } + + /// The offset of the basic block from the function start. + uint16_t Offset{0}; + /// (Loose) Hash of the basic block instructions, excluding operands. + uint16_t OpcodeHash{0}; + /// (Strong)
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/dcci approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/96596 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
dcci wrote: (assuming Amir is happy) https://github.com/llvm/llvm-project/pull/96596 ___ 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] b7fa6ce - Revert "[libc] Move off_t and stdio macros to proxy hdrs (#98215)"
Author: Michael Jones Date: 2024-07-09T16:22:13-07:00 New Revision: b7fa6cee242086ae030a74cc3894c22ecc79b6c4 URL: https://github.com/llvm/llvm-project/commit/b7fa6cee242086ae030a74cc3894c22ecc79b6c4 DIFF: https://github.com/llvm/llvm-project/commit/b7fa6cee242086ae030a74cc3894c22ecc79b6c4.diff LOG: Revert "[libc] Move off_t and stdio macros to proxy hdrs (#98215)" This reverts commit 240ec5a37517f55a64cd0c69fd4fa1613ab30f97. Added: Modified: libc/config/gpu/api.td libc/config/linux/api.td libc/hdr/CMakeLists.txt libc/hdr/types/CMakeLists.txt libc/include/llvm-libc-macros/stdio-macros.h libc/newhdrgen/yaml/stdio.yaml libc/src/__support/File/CMakeLists.txt libc/src/__support/File/file.cpp libc/src/__support/File/file.h libc/src/__support/File/linux/CMakeLists.txt libc/src/__support/File/linux/file.cpp libc/src/__support/File/linux/file.h libc/src/__support/File/linux/lseekImpl.h libc/src/__support/OSUtil/linux/CMakeLists.txt libc/src/__support/OSUtil/linux/fcntl.cpp libc/src/stdio/CMakeLists.txt libc/src/stdio/fopencookie.cpp libc/src/stdio/setbuf.cpp utils/bazel/llvm-project-overlay/libc/BUILD.bazel Removed: libc/hdr/stdio_macros.h libc/hdr/types/off_t.h diff --git a/libc/config/gpu/api.td b/libc/config/gpu/api.td index 21ddbb95b70c9..523ad49ffa3fd 100644 --- a/libc/config/gpu/api.td +++ b/libc/config/gpu/api.td @@ -59,6 +59,11 @@ def FenvAPI: PublicAPI<"fenv.h"> { } def StdIOAPI : PublicAPI<"stdio.h"> { + let Macros = [ +SimpleMacroDef<"_IOFBF", "0">, +SimpleMacroDef<"_IOLBF", "1">, +SimpleMacroDef<"_IONBF", "2">, + ]; let Types = [ "FILE", "off_t", diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td index 60e9b70f0d8a4..eb0090c80b0da 100644 --- a/libc/config/linux/api.td +++ b/libc/config/linux/api.td @@ -76,6 +76,9 @@ def StdIOAPI : PublicAPI<"stdio.h"> { SimpleMacroDef<"stderr", "stderr">, SimpleMacroDef<"stdin", "stdin">, SimpleMacroDef<"stdout", "stdout">, +SimpleMacroDef<"_IOFBF", "0">, +SimpleMacroDef<"_IOLBF", "1">, +SimpleMacroDef<"_IONBF", "2">, ]; let Types = [ "FILE", diff --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt index da640e8c0f70c..1303280c2c5ef 100644 --- a/libc/hdr/CMakeLists.txt +++ b/libc/hdr/CMakeLists.txt @@ -69,16 +69,6 @@ add_proxy_header_library( libc.include.signal ) -add_proxy_header_library( - stdio_macros - HDRS -stdio_macros.h - FULL_BUILD_DEPENDS -libc.include.stdio -libc.include.llvm-libc-macros.stdio_macros -libc.include.llvm-libc-macros.file_seek_macros -) - add_proxy_header_library( sys_epoll_macros HDRS diff --git a/libc/hdr/stdio_macros.h b/libc/hdr/stdio_macros.h deleted file mode 100644 index a212846dd8f41..0 --- a/libc/hdr/stdio_macros.h +++ /dev/null @@ -1,23 +0,0 @@ -//===-- Definition of macros from stdio.h ===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#ifndef LLVM_LIBC_HDR_STDIO_MACROS_H -#define LLVM_LIBC_HDR_STDIO_MACROS_H - -#ifdef LIBC_FULL_BUILD - -#include "include/llvm-libc-macros/file-seek-macros.h" -#include "include/llvm-libc-macros/stdio-macros.h" - -#else // Overlay mode - -#include - -#endif // LLVM_LIBC_FULL_BUILD - -#endif // LLVM_LIBC_HDR_STDIO_MACROS_H diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt index f66f2cf5dda9f..1cab1d3b812cf 100644 --- a/libc/hdr/types/CMakeLists.txt +++ b/libc/hdr/types/CMakeLists.txt @@ -135,12 +135,3 @@ add_proxy_header_library( libc.include.llvm-libc-types.struct_sigaction libc.include.signal ) - -add_proxy_header_library( - off_t - HDRS -off_t.h - FULL_BUILD_DEPENDS -libc.include.llvm-libc-types.off_t -libc.include.stdio -) diff --git a/libc/hdr/types/off_t.h b/libc/hdr/types/off_t.h deleted file mode 100644 index abc3aa659365f..0 --- a/libc/hdr/types/off_t.h +++ /dev/null @@ -1,22 +0,0 @@ -//===-- Proxy for off_t ---===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#ifndef LLVM_LIBC_HDR_TYPES_OFF_T_H -#define LLVM_LIBC_HDR_TYPES_OFF_T_H - -#ifdef LIBC_FULL_BUILD - -#include "include/llvm-libc-types/off_t.h" - -#else // Overlay mode - -#include - -#endif // LLVM_LIBC_FULL_BUILD - -#endif // LLVM_LIBC_HDR_TYPES_OFF_T_H diff --git a/libc
[llvm-branch-commits] [compiler-rt] Cleanup use of COMPILER_RT_INCLUDE_TESTS (PR #98246)
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/98246 1. Move checks into parent test/CMakeLists.txt 2. COMPILER_RT_INCLUDE_TESTS disable both lit and gtests. Before it was very inconsistent between sanitizers. ___ 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] Cleanup use of COMPILER_RT_INCLUDE_TESTS (PR #98246)
llvmbot wrote: @llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) Changes 1. Move checks into parent test/CMakeLists.txt 2. COMPILER_RT_INCLUDE_TESTS disable both lit and gtests. Before it was very inconsistent between sanitizers. --- Full diff: https://github.com/llvm/llvm-project/pull/98246.diff 14 Files Affected: - (modified) compiler-rt/cmake/base-config-ix.cmake (+2-2) - (modified) compiler-rt/test/CMakeLists.txt (+1-1) - (modified) compiler-rt/test/asan/CMakeLists.txt (+27-29) - (modified) compiler-rt/test/ctx_profile/CMakeLists.txt (+9-11) - (modified) compiler-rt/test/fuzzer/CMakeLists.txt (+7-11) - (modified) compiler-rt/test/gwp_asan/CMakeLists.txt (+2-2) - (modified) compiler-rt/test/interception/CMakeLists.txt (+1-1) - (modified) compiler-rt/test/memprof/CMakeLists.txt (+9-11) - (modified) compiler-rt/test/msan/CMakeLists.txt (+1-3) - (modified) compiler-rt/test/nsan/CMakeLists.txt (+1-3) - (modified) compiler-rt/test/rtsan/CMakeLists.txt (+10-12) - (modified) compiler-rt/test/sanitizer_common/CMakeLists.txt (+7-9) - (modified) compiler-rt/test/scudo/standalone/CMakeLists.txt (+16-18) - (modified) compiler-rt/test/tsan/CMakeLists.txt (+10-12) ``diff diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake index 87137b3d111b6..5b52a30a94aaf 100644 --- a/compiler-rt/cmake/base-config-ix.cmake +++ b/compiler-rt/cmake/base-config-ix.cmake @@ -43,7 +43,7 @@ if (LLVM_TREE_AVAILABLE) get_clang_resource_dir(COMPILER_RT_OUTPUT_DIR PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/..) set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) get_clang_resource_dir(COMPILER_RT_INSTALL_PATH) - option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." + option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt tests." ${LLVM_INCLUDE_TESTS}) option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" ${LLVM_ENABLE_WERROR}) @@ -70,7 +70,7 @@ else() "Path where built compiler-rt executables should be stored.") set(COMPILER_RT_INSTALL_PATH "" CACHE PATH "Prefix for directories where built compiler-rt artifacts should be installed.") - option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." OFF) + option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt tests." OFF) option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" OFF) # Use a host compiler to compile/link tests. set(COMPILER_RT_TEST_COMPILER ${CMAKE_C_COMPILER} CACHE PATH "Compiler to use for testing") diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt index 5982260c2d854..3d52bb552ccda 100644 --- a/compiler-rt/test/CMakeLists.txt +++ b/compiler-rt/test/CMakeLists.txt @@ -48,7 +48,7 @@ umbrella_lit_testsuite_begin(check-compiler-rt) function(compiler_rt_test_runtime runtime) string(TOUPPER ${runtime} runtime_uppercase) - if(COMPILER_RT_HAS_${runtime_uppercase}) + if(COMPILER_RT_HAS_${runtime_uppercase} AND COMPILER_RT_INCLUDE_TESTS) if (${runtime} STREQUAL scudo_standalone) add_subdirectory(scudo/standalone) else() diff --git a/compiler-rt/test/asan/CMakeLists.txt b/compiler-rt/test/asan/CMakeLists.txt index 2d683e61d6954..fb9e81bbe8082 100644 --- a/compiler-rt/test/asan/CMakeLists.txt +++ b/compiler-rt/test/asan/CMakeLists.txt @@ -130,39 +130,37 @@ if(APPLE) endif() # Add unit tests. -if(COMPILER_RT_INCLUDE_TESTS) - foreach(arch ${ASAN_TEST_ARCH}) -string(TOUPPER ${arch} ARCH_UPPER_CASE) -set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) -set(CONFIG_NAME_DYNAMIC ${ARCH_UPPER_CASE}${OS_NAME}DynamicConfig) +foreach(arch ${ASAN_TEST_ARCH}) + string(TOUPPER ${arch} ARCH_UPPER_CASE) + set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) + set(CONFIG_NAME_DYNAMIC ${ARCH_UPPER_CASE}${OS_NAME}DynamicConfig) -if(NOT MINGW) - # MinGW environments don't provide a statically linked CRT, so only the - # dynamic asan test configuration can be expected to work. - set(ASAN_TEST_DYNAMIC False) - configure_lit_site_cfg( -${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in -${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py) + if(NOT MINGW) +# MinGW environments don't provide a statically linked CRT, so only the +# dynamic asan test configuration can be expected to work. +set(ASAN_TEST_DYNAMIC False) +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py) + endif() + if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME) +set(ASAN_TEST_DYNAMIC True) +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME_DYNAMIC}/lit.site.cfg.py) + endif() + # FIXME: support unit test in the android test runner + if (NOT ANDR
[llvm-branch-commits] [compiler-rt] Cleanup use of COMPILER_RT_INCLUDE_TESTS (PR #98246)
https://github.com/MaskRay approved this pull request. I am not familiar with how the tests cmake work, but this patch indeed improves consistency. For example, `foreach(arch ${MEMPROF_TEST_ARCH})` is at the toplevel while its unittest `foreach` is guarded by `COMPILER_RT_INCLUDE_TESTS`. Removing `COMPILER_RT_INCLUDE_TESTS` is great. https://github.com/llvm/llvm-project/pull/98246 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Added more details on heatmap docs. (PR #98162)
https://github.com/paschalis-mpeis ready_for_review https://github.com/llvm/llvm-project/pull/98162 ___ 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] [EarlyIfCvt] Take branch probablities into consideration (PR #97808)
@@ -913,6 +913,10 @@ class TargetInstrInfo : public MCInstrInfo { return false; } + /// Return true if the target will always try to convert predictable branches + /// to selects. + virtual bool shouldConvertPredictableBranches() const { return true; } + mgudim wrote: The default should be `false` https://github.com/llvm/llvm-project/pull/97808 ___ 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] [EarlyIfCvt] Take branch probablities into consideration (PR #97808)
mgudim wrote: > [EarlyIfCvt] Take branch probablities into consideration It looks like this MR is only adding a target hook, so this title doesn't make sense to me https://github.com/llvm/llvm-project/pull/97808 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits