[llvm-branch-commits] [Hashing] Use a non-deterministic seed (PR #96282)
https://github.com/nikic commented: I like the idea, but I'm not sure this should be always enabled. This sounds like a lot of debugging fun when a seed-dependent case is not caught in testing. Can we have this part of LLVM_REVERSE_ITERATION instead, which is used to detect similar hash iteration stability issues? We have a build bot for it. https://github.com/llvm/llvm-project/pull/96282 ___ 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] [Hashing] Use a non-deterministic seed (PR #96282)
MaskRay wrote: > I like the idea, but I'm not sure this should be always enabled. This sounds > like a lot of debugging fun when a seed-dependent case is not caught in > testing. > > Can we have this part of LLVM_REVERSE_ITERATION instead, which is used to > detect similar hash iteration stability issues? We have a build bot for it. I have fixed a lot of non-determinism bugs in the past few years. In my experience, non-determinism caused by `DenseMap` is a more frequent issue than overuse of `DenseMap`. `DenseMap` non-determinism issues could have a low failure rate with certain malloc implementations, especially when the bucket count is small. Potential non-determinism concerns are outweighed by the benefits. The argument in https://github.com/abseil/abseil-cpp/issues/339 might be useful: > Part of Abseil's philosophy is engineering at scale. In addition to making it > harder to execute a hash flooding attack, another reason we randomize > iteration order is that is makes it easier for use to change the underlying > implementation if we need to. When we wanted to change our hash function (for > example), we found thousands of unit tests that depended on iteration order. > We could not just break these tests and say "sorry, you are violating Hyrum's > Law" since we would have thousands of angry Google developers. So instead, we > fixed the tests and implemented randomization so that next time we wanted to > change something in the implementation, this would not be an issue. The need > for iteration order determinism is relatively rare compared to the potential > wins we get by being free to change the implementation (maybe to make the > hash table faster, which could save millions of cycles at scale, for > example). By giving users a knob to disable the randomness, we'd be in the > same situation all over again. While -DLLVM_ENABLE_REVERSE_ITERATION=on helps, it adds complexity for bot maintainers and configurations. This PR allows easier detection of `DenseMap` overuse by all contributors. Eventually, perhaps we can extend this to all `DenseMap` for LLVM_ENABLE_ASSERTIONS=on. https://github.com/llvm/llvm-project/pull/96282 ___ 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] [OpenMP][MLIR] Descriptor explicit member map lowering changes (PR #96265)
Dinistro wrote: Please reduce this test to the absolute minimum that still tests your change. The IR does not need to compute anything useful, but the test should fail when you would revert only your C++ changes. Additionally, try to reduce the `CHECK`s to a minimum to not make the test exceptionally sensitive to all kinds of changes. https://github.com/llvm/llvm-project/pull/96265 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU] Codegen support for constrained multi-dword sloads (PR #96163)
https://github.com/arsenm commented: In a separate patch, we should add a verifier check that you used the correct tied version depending on whether xnack is enabled or not https://github.com/llvm/llvm-project/pull/96163 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU] Codegen support for constrained multi-dword sloads (PR #96163)
@@ -867,13 +867,104 @@ def SMRDBufferImm : ComplexPattern; def SMRDBufferImm32 : ComplexPattern; def SMRDBufferSgprImm : ComplexPattern; +class SMRDAlignedLoadPat : PatFrag <(ops node:$ptr), (Op node:$ptr), [{ + // Returns true if it is a naturally aligned multi-dword load. + LoadSDNode *Ld = cast(N); + unsigned Size = Ld->getMemoryVT().getStoreSize(); + return (Size <= 4) || (Ld->getAlign().value() >= PowerOf2Ceil(Size)); arsenm wrote: Shouldn't need the PowerOf2Ceil? https://github.com/llvm/llvm-project/pull/96163 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU] Codegen support for constrained multi-dword sloads (PR #96163)
@@ -867,13 +867,104 @@ def SMRDBufferImm : ComplexPattern; def SMRDBufferImm32 : ComplexPattern; def SMRDBufferSgprImm : ComplexPattern; +class SMRDAlignedLoadPat : PatFrag <(ops node:$ptr), (Op node:$ptr), [{ + // Returns true if it is a naturally aligned multi-dword load. + LoadSDNode *Ld = cast(N); + unsigned Size = Ld->getMemoryVT().getStoreSize(); + return (Size <= 4) || (Ld->getAlign().value() >= PowerOf2Ceil(Size)); cdevadas wrote: For the DWORDX3 case. Even though the size is 12 Bytes, its natural alignment is 16 Bytes. https://github.com/llvm/llvm-project/pull/96163 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU] Codegen support for constrained multi-dword sloads (PR #96163)
@@ -886,26 +977,17 @@ multiclass SMRD_Pattern { def : GCNPat < (smrd_load (SMRDSgpr i64:$sbase, i32:$soffset)), (vt (!cast(Instr#"_SGPR") $sbase, $soffset, 0))> { -let OtherPredicates = [isNotGFX9Plus]; - } - def : GCNPat < -(smrd_load (SMRDSgpr i64:$sbase, i32:$soffset)), -(vt (!cast(Instr#"_SGPR_IMM") $sbase, $soffset, 0, 0))> { -let OtherPredicates = [isGFX9Plus]; +let OtherPredicates = [isGFX6GFX7]; } - // 4. SGPR+IMM offset + // 4. No offset def : GCNPat < -(smrd_load (SMRDSgprImm i64:$sbase, i32:$soffset, i32:$offset)), -(vt (!cast(Instr#"_SGPR_IMM") $sbase, $soffset, $offset, 0))> { -let OtherPredicates = [isGFX9Plus]; +(vt (smrd_load (i64 SReg_64:$sbase))), +(vt (!cast(Instr#"_IMM") i64:$sbase, 0, 0))> { +let OtherPredicates = [isGFX6GFX7]; } - // 5. No offset - def : GCNPat < -(vt (smrd_load (i64 SReg_64:$sbase))), -(vt (!cast(Instr#"_IMM") i64:$sbase, 0, 0)) - >; + defm : SMRD_Align_Pattern; cdevadas wrote: I was using the predicate for gfx8+ which has the xnack replay support enabled. I should instead check if the xnack is on. Will change it. https://github.com/llvm/llvm-project/pull/96163 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU] Codegen support for constrained multi-dword sloads (PR #96163)
@@ -867,13 +867,104 @@ def SMRDBufferImm : ComplexPattern; def SMRDBufferImm32 : ComplexPattern; def SMRDBufferSgprImm : ComplexPattern; +class SMRDAlignedLoadPat : PatFrag <(ops node:$ptr), (Op node:$ptr), [{ + // Returns true if it is a naturally aligned multi-dword load. + LoadSDNode *Ld = cast(N); + unsigned Size = Ld->getMemoryVT().getStoreSize(); + return (Size <= 4) || (Ld->getAlign().value() >= PowerOf2Ceil(Size)); jayfoad wrote: Right but the PowerOf2Ceil makes no difference. Either you test 16>=12 or 16>=16, the result it the same. Also you don't need most of the parens on this line. https://github.com/llvm/llvm-project/pull/96163 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU] Codegen support for constrained multi-dword sloads (PR #96163)
https://github.com/arsenm commented: Another strategy that might simplify the patterns is to always select the _ec versions, and then later swap to the non-ec versions if xnack is disabled https://github.com/llvm/llvm-project/pull/96163 ___ 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][linalg] Add transform operator for Winograd Conv2D algorithm (PR #96182)
@@ -3480,6 +3480,31 @@ DiagnosedSilenceableFailure transform::MapCopyToThreadsOp::applyToOne( return DiagnosedSilenceableFailure::success(); } +//===--===// +// WinogradConv2DOp +//===--===// + +DiagnosedSilenceableFailure transform::WinogradConv2DOp::applyToOne( +transform::TransformRewriter &rewriter, linalg::LinalgOp target, +transform::ApplyToEachResultList &results, +transform::TransformState &state) { + rewriter.setInsertionPoint(target); + auto maybeTransformed = + TypeSwitch>(target) + .Case([&](linalg::Conv2DNhwcFhwcOp op) { +return winogradConv2D(rewriter, op, getM(), getR()); + }) + .Default([&](Operation *op) { +return rewriter.notifyMatchFailure(op, "not supported"); ftynse wrote: Let's rather `emitSilenceableFailure()` with this message to the user. The rewriter messages are not printed AFAIK. https://github.com/llvm/llvm-project/pull/96182 ___ 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][linalg] Add transform operator for Winograd Conv2D algorithm (PR #96182)
@@ -2587,4 +2587,55 @@ def MapCopyToThreadsOp : }]; } +//===--===// +// Winograd Conv2D +//===--===// + +def WinogradConv2DOp : Op { + let description = [{ +Winograd Conv2D algorithm will convert linalg Conv2D operator into batched ftynse wrote: ```suggestion Winograd Conv2D algorithm will convert linalg Conv2D operation into batched ``` Nit: these are called operations, not operators, in MLIR. https://github.com/llvm/llvm-project/pull/96182 ___ 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][linalg] Add transform operator for Winograd Conv2D algorithm (PR #96182)
@@ -0,0 +1,88 @@ +// RUN: mlir-opt %s -transform-interpreter -canonicalize --split-input-file | FileCheck %s + +func.func @conv2d(%arg0: tensor<2x10x10x5xf32>, %arg1: tensor<2x3x3x5xf32>, %arg2: tensor<1xf32>) -> tensor<2x8x8x2xf32> { + %0 = tensor.empty() : tensor<2x8x8x2xf32> + %1 = linalg.generic {indexing_maps = [affine_map<(d0, d1, d2, d3) -> (0)>, affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%arg2 : tensor<1xf32>) outs(%0 : tensor<2x8x8x2xf32>) { + ^bb0(%in: f32, %out: f32): +linalg.yield %in : f32 + } -> tensor<2x8x8x2xf32> + %2 = linalg.conv_2d_nhwc_fhwc {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} ins(%arg0, %arg1 : tensor<2x10x10x5xf32>, tensor<2x3x3x5xf32>) outs(%1 : tensor<2x8x8x2xf32>) -> tensor<2x8x8x2xf32> + return %2 : tensor<2x8x8x2xf32> +} + +module attributes {transform.with_named_sequence} { + transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { +%0 = transform.structured.match ops{["linalg.conv_2d_nhwc_fhwc"]} in %arg1 : (!transform.any_op) -> !transform.any_op +%1 = transform.structured.winograd_conv2d %0 { m = 4, r = 3 } : (!transform.any_op) -> (!transform.any_op) +transform.yield + } +} + +// CHECK: #[[$MAP0:.+]] = affine_map<(d0, d1, d2, d3) -> (0)> +// CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)> +// CHECK-LABEL: func.func @conv2d +// CHECK-SAME: (%[[ARG0:.*]]: tensor<2x10x10x5xf32>, %[[ARG1:.*]]: tensor<2x3x3x5xf32>, %[[ARG2:.*]]: tensor<1xf32>) -> tensor<2x8x8x2xf32> { +// CHECK:%[[S0:.*]] = tensor.empty() : tensor<2x8x8x2xf32> +// CHECK-NEXT: %[[S1:.*]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]]], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%[[ARG2]] : tensor<1xf32>) outs(%[[S0]] : tensor<2x8x8x2xf32>) { +// CHECK-NEXT: ^bb0(%[[IN:.*]]: f32, %[[OUT:.*]]: f32): +// CHECK-NEXT: linalg.yield %[[IN]] : f32 +// CHECK-NEXT: } -> tensor<2x8x8x2xf32> +// CHECK-NEXT: %[[S2:.*]] = tensor.empty() : tensor<2x2x6x6x5x2xf32> +// CHECK-NEXT: %[[S3:.*]] = linalg.winograd_filter_transform m(4) r(3) ins(%[[ARG1]] : tensor<2x3x3x5xf32>) outs(%[[S2]] : tensor<2x2x6x6x5x2xf32>) -> tensor<2x2x6x6x5x2xf32> +// CHECK-NEXT: %[[S4:.*]] = tensor.empty() : tensor<2x2x6x6x2x5xf32> +// CHECK-NEXT: %[[S5:.*]] = linalg.winograd_input_transform m(4) r(3) ins(%[[ARG0]] : tensor<2x10x10x5xf32>) outs(%[[S4]] : tensor<2x2x6x6x2x5xf32>) -> tensor<2x2x6x6x2x5xf32> +// CHECK-NEXT: %[[COLLAPSED:.*]] = tensor.collapse_shape %[[S3]] {{\[}}[0, 1, 2, 3], [4], [5]] : tensor<2x2x6x6x5x2xf32> into tensor<144x5x2xf32> +// CHECK-NEXT: %[[COLLAPSED_0:.*]] = tensor.collapse_shape %[[S5]] {{\[}}[0, 1, 2, 3], [4], [5]] : tensor<2x2x6x6x2x5xf32> into tensor<144x2x5xf32> +// CHECK-NEXT: %[[S6:.*]] = tensor.empty() : tensor<144x2x2xf32> +// CHECK-NEXT: %[[S7:.*]] = linalg.batch_matmul ins(%[[COLLAPSED_0]], %[[COLLAPSED]] : tensor<144x2x5xf32>, tensor<144x5x2xf32>) outs(%[[S6]] : tensor<144x2x2xf32>) -> tensor<144x2x2xf32> +// CHECK-NEXT: %[[EXPANDED:.*]] = tensor.expand_shape %[[S7]] {{\[}}[0, 1, 2, 3], [4], [5]] output_shape [2, 2, 6, 6, 2, 2] : tensor<144x2x2xf32> into tensor<2x2x6x6x2x2xf32> +// CHECK-NEXT: %[[S8:.*]] = linalg.winograd_output_transform m(4) r(3) ins(%[[EXPANDED]] : tensor<2x2x6x6x2x2xf32>) outs(%[[S1]] : tensor<2x8x8x2xf32>) -> tensor<2x8x8x2xf32> +// CHECK-NEXT: return %[[S8]] : tensor<2x8x8x2xf32> +// CHECK-NEXT: } ftynse wrote: Since we are already testing the op production logic elsewhere, we don't need to re-test it here. It is sufficient to check that it worked at the high level, e.g.: ``` CHECK: winograd_filter_transform m(4) r(3) CHECK: winograd_input_transform CHECK: match_matmul CHECK: winograd_output_transform ``` https://github.com/llvm/llvm-project/pull/96182 ___ 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][linalg] Add transform operator for Winograd Conv2D algorithm (PR #96182)
@@ -2587,4 +2587,55 @@ def MapCopyToThreadsOp : }]; } +//===--===// +// Winograd Conv2D +//===--===// + +def WinogradConv2DOp : Op { + let description = [{ +Winograd Conv2D algorithm will convert linalg Conv2D operator into batched +matrix multiply. Before the matrix multiply, it will convert filter and +input into a format suitable for batched matrix multiply. After the matrix +multiply, it will convert output to the final result tensor. + +The algorithm F(m x m, r x r) is + +Y = A^T x [(G x g x G^T) @ (B^T x d x B)] x A + +The size of output Y is m x m. The size of filter g is r x r. The size of +input d is (m + r - 1) x (m + r - 1). A^T, A, G^T, G, B^T, and B are +transformation matrices. + + Return modes: + +This operation fails if `target` is unsupported. Otherwise, the operation ftynse wrote: ```suggestion This operation produces a silenceable failure if `target` is unsupported. Otherwise, the operation ``` https://github.com/llvm/llvm-project/pull/96182 ___ 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][linalg] Add transform operator for Winograd Conv2D algorithm (PR #96182)
@@ -0,0 +1,88 @@ +// RUN: mlir-opt %s -transform-interpreter -canonicalize --split-input-file | FileCheck %s + +func.func @conv2d(%arg0: tensor<2x10x10x5xf32>, %arg1: tensor<2x3x3x5xf32>, %arg2: tensor<1xf32>) -> tensor<2x8x8x2xf32> { + %0 = tensor.empty() : tensor<2x8x8x2xf32> + %1 = linalg.generic {indexing_maps = [affine_map<(d0, d1, d2, d3) -> (0)>, affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%arg2 : tensor<1xf32>) outs(%0 : tensor<2x8x8x2xf32>) { + ^bb0(%in: f32, %out: f32): +linalg.yield %in : f32 + } -> tensor<2x8x8x2xf32> + %2 = linalg.conv_2d_nhwc_fhwc {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} ins(%arg0, %arg1 : tensor<2x10x10x5xf32>, tensor<2x3x3x5xf32>) outs(%1 : tensor<2x8x8x2xf32>) -> tensor<2x8x8x2xf32> + return %2 : tensor<2x8x8x2xf32> +} + +module attributes {transform.with_named_sequence} { + transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { +%0 = transform.structured.match ops{["linalg.conv_2d_nhwc_fhwc"]} in %arg1 : (!transform.any_op) -> !transform.any_op +%1 = transform.structured.winograd_conv2d %0 { m = 4, r = 3 } : (!transform.any_op) -> (!transform.any_op) +transform.yield + } +} + +// CHECK: #[[$MAP0:.+]] = affine_map<(d0, d1, d2, d3) -> (0)> +// CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)> +// CHECK-LABEL: func.func @conv2d +// CHECK-SAME: (%[[ARG0:.*]]: tensor<2x10x10x5xf32>, %[[ARG1:.*]]: tensor<2x3x3x5xf32>, %[[ARG2:.*]]: tensor<1xf32>) -> tensor<2x8x8x2xf32> { +// CHECK:%[[S0:.*]] = tensor.empty() : tensor<2x8x8x2xf32> +// CHECK-NEXT: %[[S1:.*]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]]], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%[[ARG2]] : tensor<1xf32>) outs(%[[S0]] : tensor<2x8x8x2xf32>) { +// CHECK-NEXT: ^bb0(%[[IN:.*]]: f32, %[[OUT:.*]]: f32): +// CHECK-NEXT: linalg.yield %[[IN]] : f32 +// CHECK-NEXT: } -> tensor<2x8x8x2xf32> +// CHECK-NEXT: %[[S2:.*]] = tensor.empty() : tensor<2x2x6x6x5x2xf32> +// CHECK-NEXT: %[[S3:.*]] = linalg.winograd_filter_transform m(4) r(3) ins(%[[ARG1]] : tensor<2x3x3x5xf32>) outs(%[[S2]] : tensor<2x2x6x6x5x2xf32>) -> tensor<2x2x6x6x5x2xf32> +// CHECK-NEXT: %[[S4:.*]] = tensor.empty() : tensor<2x2x6x6x2x5xf32> +// CHECK-NEXT: %[[S5:.*]] = linalg.winograd_input_transform m(4) r(3) ins(%[[ARG0]] : tensor<2x10x10x5xf32>) outs(%[[S4]] : tensor<2x2x6x6x2x5xf32>) -> tensor<2x2x6x6x2x5xf32> +// CHECK-NEXT: %[[COLLAPSED:.*]] = tensor.collapse_shape %[[S3]] {{\[}}[0, 1, 2, 3], [4], [5]] : tensor<2x2x6x6x5x2xf32> into tensor<144x5x2xf32> +// CHECK-NEXT: %[[COLLAPSED_0:.*]] = tensor.collapse_shape %[[S5]] {{\[}}[0, 1, 2, 3], [4], [5]] : tensor<2x2x6x6x2x5xf32> into tensor<144x2x5xf32> +// CHECK-NEXT: %[[S6:.*]] = tensor.empty() : tensor<144x2x2xf32> +// CHECK-NEXT: %[[S7:.*]] = linalg.batch_matmul ins(%[[COLLAPSED_0]], %[[COLLAPSED]] : tensor<144x2x5xf32>, tensor<144x5x2xf32>) outs(%[[S6]] : tensor<144x2x2xf32>) -> tensor<144x2x2xf32> +// CHECK-NEXT: %[[EXPANDED:.*]] = tensor.expand_shape %[[S7]] {{\[}}[0, 1, 2, 3], [4], [5]] output_shape [2, 2, 6, 6, 2, 2] : tensor<144x2x2xf32> into tensor<2x2x6x6x2x2xf32> +// CHECK-NEXT: %[[S8:.*]] = linalg.winograd_output_transform m(4) r(3) ins(%[[EXPANDED]] : tensor<2x2x6x6x2x2xf32>) outs(%[[S1]] : tensor<2x8x8x2xf32>) -> tensor<2x8x8x2xf32> +// CHECK-NEXT: return %[[S8]] : tensor<2x8x8x2xf32> +// CHECK-NEXT: } + +// - + +func.func @conv2d_unaligned(%arg0: tensor<2x11x11x5xf32>, %arg1: tensor<2x3x3x5xf32>, %arg2: tensor<1xf32>) -> tensor<2x9x9x2xf32> { + %0 = tensor.empty() : tensor<2x9x9x2xf32> + %1 = linalg.generic {indexing_maps = [affine_map<(d0, d1, d2, d3) -> (0)>, affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%arg2 : tensor<1xf32>) outs(%0 : tensor<2x9x9x2xf32>) { + ^bb0(%in: f32, %out: f32): +linalg.yield %in : f32 + } -> tensor<2x9x9x2xf32> + %2 = linalg.conv_2d_nhwc_fhwc {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} ins(%arg0, %arg1 : tensor<2x11x11x5xf32>, tensor<2x3x3x5xf32>) outs(%1 : tensor<2x9x9x2xf32>) -> tensor<2x9x9x2xf32> + return %2 : tensor<2x9x9x2xf32> +} + +module attributes {transform.with_named_sequence} { + transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { +%0 = transform.structured.match ops{["linalg.conv_2d_nhwc_fhwc"]} in %arg1 : (!transform.any_op) -> !transform.any_op +%1 = transform.structured.winograd_conv2d %0 { m = 4, r = 3 } : (!transform.any_op) -> (!transform.any_op) +transform.yield + } +} + +// CHECK: #[[$MAP0:.+]] = affine_map<(d0, d1, d2, d3) -> (0)> +// CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)> +// CHECK-LABEL: func.func @conv2d_unaligned
[llvm-branch-commits] [mlir] [mlir][linalg] Add transform operator for Winograd Conv2D algorithm (PR #96182)
@@ -3480,6 +3480,31 @@ DiagnosedSilenceableFailure transform::MapCopyToThreadsOp::applyToOne( return DiagnosedSilenceableFailure::success(); } +//===--===// +// WinogradConv2DOp +//===--===// + +DiagnosedSilenceableFailure transform::WinogradConv2DOp::applyToOne( +transform::TransformRewriter &rewriter, linalg::LinalgOp target, +transform::ApplyToEachResultList &results, +transform::TransformState &state) { + rewriter.setInsertionPoint(target); + auto maybeTransformed = + TypeSwitch>(target) + .Case([&](linalg::Conv2DNhwcFhwcOp op) { +return winogradConv2D(rewriter, op, getM(), getR()); + }) + .Default([&](Operation *op) { +return rewriter.notifyMatchFailure(op, "not supported"); + }); + + if (failed(maybeTransformed)) +return emitDefaultSilenceableFailure(target); ftynse wrote: It would be nice if `windogradConv2D` was returning some error code or was taking a callback to print error messages to instead of giving a default message here. Non-blocking. https://github.com/llvm/llvm-project/pull/96182 ___ 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] [OpenMP][MLIR] Descriptor explicit member map lowering changes (PR #96265)
agozillon wrote: Hi, I believe in this case it is at the point of being minimal, I could reduce it to 1 of the 4 test cases if you wish keeping the most complicated or if you have any other suggestions on how to reduce it I would be more than happy to adjust the test. The test is checking the correct information is accessed and inserted into the OpenMP map information construct so it unfortunately requires a number of CHECK's, most of the code gen is handled via OpenMPToLLVMIRTranslation.cpp and the OMPIRBuilder.cpp (although it is of course susceptible to modifications in the MLIR -> LLVM-IR lowering and LLVM changes like most other tests). The MLIR itself requires a number of omp.map.info operations to test it, with a somewhat sane approximation of what it would expect as an argument (in this case accesses into a larger structure). The bounds aren't entirely necessary for the example though (mainly just checking the array offsets work in conjunction with everything still), so I could remove them if you wish which might lower the number of constants as well? https://github.com/llvm/llvm-project/pull/96265 ___ 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] [SPARC][IAS] Rework ASI tag matching in prep for `ParseForAllFeatures` (PR #96020)
@@ -1085,13 +1085,24 @@ ParseStatus SparcAsmParser::parseASITag(OperandVector &Operands) { SMLoc E = Parser.getTok().getEndLoc(); int64_t ASIVal = 0; - if (is64Bit() && (getLexer().getKind() == AsmToken::Hash)) { + switch (getLexer().getKind()) { + case AsmToken::LParen: + case AsmToken::Integer: + case AsmToken::Identifier: + case AsmToken::Plus: + case AsmToken::Minus: + case AsmToken::Tilde: koachan wrote: > Also, optionally, add a parseExpression method that returns NoMatch if the > first token can't start an expression and Success/Failure if it can and > expression parsing succeeded/failed. Hmm, not sure how would I use this in the ASI/Prefetch tag parsing... I'm thinking about calling `parseExpression` then checking if the return value is a `Success` before further checking if the returned value is in range for each tag type, but apparently comparing `ParseStatus`es is an error? ``` [clang] (typecheck_invalid_operands) Invalid operands to binary expression ('ParseStatus' and 'const StatusTy') ``` https://github.com/llvm/llvm-project/pull/96020 ___ 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] [SPARC][IAS] Rework ASI tag matching in prep for `ParseForAllFeatures` (PR #96020)
@@ -1085,13 +1085,24 @@ ParseStatus SparcAsmParser::parseASITag(OperandVector &Operands) { SMLoc E = Parser.getTok().getEndLoc(); int64_t ASIVal = 0; - if (is64Bit() && (getLexer().getKind() == AsmToken::Hash)) { + switch (getLexer().getKind()) { + case AsmToken::LParen: + case AsmToken::Integer: + case AsmToken::Identifier: + case AsmToken::Plus: + case AsmToken::Minus: + case AsmToken::Tilde: s-barannikov wrote: It should be examined using its public methods (isSuccess(), isFailure() or isNoMatch()). https://github.com/llvm/llvm-project/pull/96020 ___ 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] Name similarity function matching (PR #95884)
https://github.com/aaupov commented: Can you please also note the runtime of the namespace-filtered pairwise checks? This would guide us in whether to add a BB count filtering. https://github.com/llvm/llvm-project/pull/95884 ___ 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] Name similarity function matching (PR #95884)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/95884 ___ 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] Name similarity function matching (PR #95884)
@@ -415,6 +422,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + // Uses name similarity to match functions that were not matched by name. + uint64_t MatchedWithDemangledName = 0; + + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { + int Status = 0; + char *DemangledName = abi::__cxa_demangle(String, +nullptr, nullptr, &Status); + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); +} + +for (auto YamlBF : YamlBP.Functions) { + if (YamlBF.Used) +continue; + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) +continue; + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +continue; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); aaupov wrote: ```suggestion std::string *BFDemangledName = BF->getDemangledName(); ``` https://github.com/llvm/llvm-project/pull/95884 ___ 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] Name similarity function matching (PR #95884)
@@ -415,6 +422,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + // Uses name similarity to match functions that were not matched by name. + uint64_t MatchedWithDemangledName = 0; + + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { + int Status = 0; + char *DemangledName = abi::__cxa_demangle(String, aaupov wrote: Let's use LLVM's `demangle` (llvm/Demangle/Demangle.h) https://github.com/llvm/llvm-project/pull/95884 ___ 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] Name similarity function matching (PR #95884)
@@ -415,6 +422,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + // Uses name similarity to match functions that were not matched by name. + uint64_t MatchedWithDemangledName = 0; + + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { + int Status = 0; + char *DemangledName = abi::__cxa_demangle(String, +nullptr, nullptr, &Status); + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { aaupov wrote: Would be cool to use `getFunctionDeclContextName` from ItaniumPartialDemangler https://github.com/llvm/llvm-project/pull/95884 ___ 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][Transforms][NFC] Dialect Conversion: Move argument materialization logic (PR #96329)
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/96329 This commit moves the argument materialization logic from `legalizeConvertedArgumentTypes` to `legalizeUnresolvedMaterializations`. Before this change: - Argument materializations were created in `legalizeConvertedArgumentTypes` (which used to call `materializeLiveConversions`). After this change: - `legalizeConvertedArgumentTypes` creates a "placeholder" `unrealized_conversion_cast`. - The placeholder `unrealized_conversion_cast` is replaced with an argument materialization (using the type converter) in `legalizeUnresolvedMaterializations`. - All argument and target materializations now take place in the same location (`legalizeUnresolvedMaterializations`). This commit brings us closer towards creating all source/target/argument materializations in one central step, which can then be made optional (and delegated to the user) in the future. (There is one more source materialization step that has not been moved yet.) This commit also consolidates all `build*UnresolvedMaterialization` functions into a single `buildUnresolvedMaterialization` function. >From d2b0b9ef97c626fc48b0c00ce2ec8e5573599f2b Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Thu, 20 Jun 2024 17:40:07 +0200 Subject: [PATCH] remove materializeLiveConversions --- .../Transforms/Utils/DialectConversion.cpp| 133 +++--- 1 file changed, 52 insertions(+), 81 deletions(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 07ebd687ee2b3..47e03383304af 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -53,6 +53,16 @@ static void logFailure(llvm::ScopedPrinter &os, StringRef fmt, Args &&...args) { }); } +/// Helper function that computes an insertion point where the given value is +/// defined and can be used without a dominance violation. +static OpBuilder::InsertPoint computeInsertPoint(Value value) { + Block *insertBlock = value.getParentBlock(); + Block::iterator insertPt = insertBlock->begin(); + if (OpResult inputRes = dyn_cast(value)) +insertPt = ++inputRes.getOwner()->getIterator(); + return OpBuilder::InsertPoint(insertBlock, insertPt); +} + //===--===// // ConversionValueMapping //===--===// @@ -445,11 +455,9 @@ class BlockTypeConversionRewrite : public BlockRewrite { return rewrite->getKind() == Kind::BlockTypeConversion; } - /// Materialize any necessary conversions for converted arguments that have - /// live users, using the provided `findLiveUser` to search for a user that - /// survives the conversion process. - LogicalResult - materializeLiveConversions(function_ref findLiveUser); + Block *getOrigBlock() const { return origBlock; } + + const TypeConverter *getConverter() const { return converter; } void commit(RewriterBase &rewriter) override; @@ -841,14 +849,10 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener { /// Build an unresolved materialization operation given an output type and set /// of input operands. Value buildUnresolvedMaterialization(MaterializationKind kind, - Block *insertBlock, - Block::iterator insertPt, Location loc, + OpBuilder::InsertPoint ip, Location loc, ValueRange inputs, Type outputType, Type origOutputType, const TypeConverter *converter); - Value buildUnresolvedTargetMaterialization(Location loc, Value input, - Type outputType, - const TypeConverter *converter); //======// // Rewriter Notification Hooks @@ -981,49 +985,6 @@ void BlockTypeConversionRewrite::rollback() { block->replaceAllUsesWith(origBlock); } -LogicalResult BlockTypeConversionRewrite::materializeLiveConversions( -function_ref findLiveUser) { - // Process the remapping for each of the original arguments. - for (auto it : llvm::enumerate(origBlock->getArguments())) { -BlockArgument origArg = it.value(); -// Note: `block` may be detached, so OpBuilder::atBlockBegin cannot be used. -OpBuilder builder(it.value().getContext(), /*listener=*/&rewriterImpl); -builder.setInsertionPointToStart(block); - -// If the type of this argument changed and the argument is still live, we -// need to materialize a conversion. -if (rewriterImpl.mapping.lookupOrNull(origArg, origArg.getType())) - continue; -Operation *liveUser = findLiveUser(
[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Dialect Conversion: Move argument materialization logic (PR #96329)
llvmbot wrote: @llvm/pr-subscribers-mlir Author: Matthias Springer (matthias-springer) Changes This commit moves the argument materialization logic from `legalizeConvertedArgumentTypes` to `legalizeUnresolvedMaterializations`. Before this change: - Argument materializations were created in `legalizeConvertedArgumentTypes` (which used to call `materializeLiveConversions`). After this change: - `legalizeConvertedArgumentTypes` creates a "placeholder" `unrealized_conversion_cast`. - The placeholder `unrealized_conversion_cast` is replaced with an argument materialization (using the type converter) in `legalizeUnresolvedMaterializations`. - All argument and target materializations now take place in the same location (`legalizeUnresolvedMaterializations`). This commit brings us closer towards creating all source/target/argument materializations in one central step, which can then be made optional (and delegated to the user) in the future. (There is one more source materialization step that has not been moved yet.) This commit also consolidates all `build*UnresolvedMaterialization` functions into a single `buildUnresolvedMaterialization` function. --- Full diff: https://github.com/llvm/llvm-project/pull/96329.diff 1 Files Affected: - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+52-81) ``diff diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 07ebd687ee2b3..47e03383304af 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -53,6 +53,16 @@ static void logFailure(llvm::ScopedPrinter &os, StringRef fmt, Args &&...args) { }); } +/// Helper function that computes an insertion point where the given value is +/// defined and can be used without a dominance violation. +static OpBuilder::InsertPoint computeInsertPoint(Value value) { + Block *insertBlock = value.getParentBlock(); + Block::iterator insertPt = insertBlock->begin(); + if (OpResult inputRes = dyn_cast(value)) +insertPt = ++inputRes.getOwner()->getIterator(); + return OpBuilder::InsertPoint(insertBlock, insertPt); +} + //===--===// // ConversionValueMapping //===--===// @@ -445,11 +455,9 @@ class BlockTypeConversionRewrite : public BlockRewrite { return rewrite->getKind() == Kind::BlockTypeConversion; } - /// Materialize any necessary conversions for converted arguments that have - /// live users, using the provided `findLiveUser` to search for a user that - /// survives the conversion process. - LogicalResult - materializeLiveConversions(function_ref findLiveUser); + Block *getOrigBlock() const { return origBlock; } + + const TypeConverter *getConverter() const { return converter; } void commit(RewriterBase &rewriter) override; @@ -841,14 +849,10 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener { /// Build an unresolved materialization operation given an output type and set /// of input operands. Value buildUnresolvedMaterialization(MaterializationKind kind, - Block *insertBlock, - Block::iterator insertPt, Location loc, + OpBuilder::InsertPoint ip, Location loc, ValueRange inputs, Type outputType, Type origOutputType, const TypeConverter *converter); - Value buildUnresolvedTargetMaterialization(Location loc, Value input, - Type outputType, - const TypeConverter *converter); //======// // Rewriter Notification Hooks @@ -981,49 +985,6 @@ void BlockTypeConversionRewrite::rollback() { block->replaceAllUsesWith(origBlock); } -LogicalResult BlockTypeConversionRewrite::materializeLiveConversions( -function_ref findLiveUser) { - // Process the remapping for each of the original arguments. - for (auto it : llvm::enumerate(origBlock->getArguments())) { -BlockArgument origArg = it.value(); -// Note: `block` may be detached, so OpBuilder::atBlockBegin cannot be used. -OpBuilder builder(it.value().getContext(), /*listener=*/&rewriterImpl); -builder.setInsertionPointToStart(block); - -// If the type of this argument changed and the argument is still live, we -// need to materialize a conversion. -if (rewriterImpl.mapping.lookupOrNull(origArg, origArg.getType())) - continue; -Operation *liveUser = findLiveUser(origArg); -if (!liveUser) - continue; - -Value replacementValue = rewriterImpl.mapping.lookupOrNull(origArg); -as
[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Dialect Conversion: Move argument materialization logic (PR #96329)
llvmbot wrote: @llvm/pr-subscribers-mlir-core Author: Matthias Springer (matthias-springer) Changes This commit moves the argument materialization logic from `legalizeConvertedArgumentTypes` to `legalizeUnresolvedMaterializations`. Before this change: - Argument materializations were created in `legalizeConvertedArgumentTypes` (which used to call `materializeLiveConversions`). After this change: - `legalizeConvertedArgumentTypes` creates a "placeholder" `unrealized_conversion_cast`. - The placeholder `unrealized_conversion_cast` is replaced with an argument materialization (using the type converter) in `legalizeUnresolvedMaterializations`. - All argument and target materializations now take place in the same location (`legalizeUnresolvedMaterializations`). This commit brings us closer towards creating all source/target/argument materializations in one central step, which can then be made optional (and delegated to the user) in the future. (There is one more source materialization step that has not been moved yet.) This commit also consolidates all `build*UnresolvedMaterialization` functions into a single `buildUnresolvedMaterialization` function. --- Full diff: https://github.com/llvm/llvm-project/pull/96329.diff 1 Files Affected: - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+52-81) ``diff diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 07ebd687ee2b3..47e03383304af 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -53,6 +53,16 @@ static void logFailure(llvm::ScopedPrinter &os, StringRef fmt, Args &&...args) { }); } +/// Helper function that computes an insertion point where the given value is +/// defined and can be used without a dominance violation. +static OpBuilder::InsertPoint computeInsertPoint(Value value) { + Block *insertBlock = value.getParentBlock(); + Block::iterator insertPt = insertBlock->begin(); + if (OpResult inputRes = dyn_cast(value)) +insertPt = ++inputRes.getOwner()->getIterator(); + return OpBuilder::InsertPoint(insertBlock, insertPt); +} + //===--===// // ConversionValueMapping //===--===// @@ -445,11 +455,9 @@ class BlockTypeConversionRewrite : public BlockRewrite { return rewrite->getKind() == Kind::BlockTypeConversion; } - /// Materialize any necessary conversions for converted arguments that have - /// live users, using the provided `findLiveUser` to search for a user that - /// survives the conversion process. - LogicalResult - materializeLiveConversions(function_ref findLiveUser); + Block *getOrigBlock() const { return origBlock; } + + const TypeConverter *getConverter() const { return converter; } void commit(RewriterBase &rewriter) override; @@ -841,14 +849,10 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener { /// Build an unresolved materialization operation given an output type and set /// of input operands. Value buildUnresolvedMaterialization(MaterializationKind kind, - Block *insertBlock, - Block::iterator insertPt, Location loc, + OpBuilder::InsertPoint ip, Location loc, ValueRange inputs, Type outputType, Type origOutputType, const TypeConverter *converter); - Value buildUnresolvedTargetMaterialization(Location loc, Value input, - Type outputType, - const TypeConverter *converter); //======// // Rewriter Notification Hooks @@ -981,49 +985,6 @@ void BlockTypeConversionRewrite::rollback() { block->replaceAllUsesWith(origBlock); } -LogicalResult BlockTypeConversionRewrite::materializeLiveConversions( -function_ref findLiveUser) { - // Process the remapping for each of the original arguments. - for (auto it : llvm::enumerate(origBlock->getArguments())) { -BlockArgument origArg = it.value(); -// Note: `block` may be detached, so OpBuilder::atBlockBegin cannot be used. -OpBuilder builder(it.value().getContext(), /*listener=*/&rewriterImpl); -builder.setInsertionPointToStart(block); - -// If the type of this argument changed and the argument is still live, we -// need to materialize a conversion. -if (rewriterImpl.mapping.lookupOrNull(origArg, origArg.getType())) - continue; -Operation *liveUser = findLiveUser(origArg); -if (!liveUser) - continue; - -Value replacementValue = rewriterImpl.mapping.lookupOrNull(origArg); -
[llvm-branch-commits] [clang] [compiler-rt] [llvm] [PAC][AArch64] Support init/fini array signing (PR #95203)
https://github.com/ahatanak closed https://github.com/llvm/llvm-project/pull/95203 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)
https://github.com/ahatanak closed https://github.com/llvm/llvm-project/pull/94056 ___ 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] Name similarity function matching (PR #95884)
@@ -415,6 +422,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + // Uses name similarity to match functions that were not matched by name. + uint64_t MatchedWithDemangledName = 0; + + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { + int Status = 0; + char *DemangledName = abi::__cxa_demangle(String, +nullptr, nullptr, &Status); + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); +} + +for (auto YamlBF : YamlBP.Functions) { + if (YamlBF.Used) +continue; + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) +continue; + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +continue; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); shawbyoung wrote: For the sake of matching - is not a good idea to apply the same function name transformation to both the YamlBF and BF function names? https://github.com/llvm/llvm-project/pull/95884 ___ 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] Name similarity function matching (PR #95884)
https://github.com/shawbyoung deleted https://github.com/llvm/llvm-project/pull/95884 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)
https://github.com/ahmedbougacha reopened https://github.com/llvm/llvm-project/pull/94056 ___ 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] Name similarity function matching (PR #95884)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95884 >From 34652b2eebc62218c50a23509ce99937385c30e6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:42:00 -0700 Subject: [PATCH 1/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 73 -- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 66cabc236f4b2..c9f6d88f0b13a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -424,36 +424,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses name similarity to match functions that were not matched by name. uint64_t MatchedWithDemangledName = 0; - if (opts::NameSimilarityFunctionMatchingThreshold > 0) { - -std::unordered_map NameToBinaryFunction; -NameToBinaryFunction.reserve(BC.getBinaryFunctions().size()); -for (auto &[_, BF] : BC.getBinaryFunctions()) { + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { int Status = 0; - char *DemangledName = abi::__cxa_demangle(BF.getOneName().str().c_str(), + char *DemangledName = abi::__cxa_demangle(String, nullptr, nullptr, &Status); - if (Status == 0) -NameToBinaryFunction[std::string(DemangledName)] = &BF; + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); } for (auto YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; - int Status = 0; - char *DemangledName = - abi::__cxa_demangle(YamlBF.Name.c_str(), nullptr, nullptr, &Status); - if (Status != 0) + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) continue; - auto It = NameToBinaryFunction.find(DemangledName); - if (It == NameToBinaryFunction.end()) + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) continue; - BinaryFunction *BF = It->second; - matchProfileToFunction(YamlBF, *BF); - ++MatchedWithDemangledName; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); +if (!BFDemangledName) + continue; +unsigned BFEditDistance = StringRef(*BFDemangledName).edit_distance(*YamlBFDemangledName); +if (BFEditDistance < MinEditDistance) { + MinEditDistance = BFEditDistance; + ClosestNameBF = BF; +} + } + + if (ClosestNameBF && +MinEditDistance < opts::NameSimilarityFunctionMatchingThreshold) { +matchProfileToFunction(YamlBF, *ClosestNameBF); +++MatchedWithDemangledName; + } } } + outs() << MatchedWithDemangledName << ": functions matched by name similarity\n"; + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 2d23bbd6b9ce4f0786ae8ceb39b1b008b4ca9c4d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:45:27 -0700 Subject: [PATCH 2/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index c9f6d88f0b13a..cf4a5393df8f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -491,8 +491,6 @@ Error YAMLProfileReader::read
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -128,6 +128,11 @@ cl::opt cl::desc("instrument code to generate accurate profile data"), cl::cat(BoltOptCategory)); +cl::opt +MatchingFunctionsWithHash("stale-matching-matching-functions-with-hash", + cl::desc("Matching functions using hash"), aaupov wrote: Technically it's independent of stale matching: ```suggestion MatchProfileWithFunctionHash("match-profile-with-function-hash", cl::desc("Match profile with function hash"), ``` https://github.com/llvm/llvm-project/pull/95821 ___ 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] Hash-based function matching (PR #95821)
@@ -2982,6 +2983,9 @@ void RewriteInstance::selectFunctionsToProcess() { if (mustSkip(Function)) return false; +if (opts::MatchingFunctionsWithHash) + return true; aaupov wrote: Since we're forcing the processing of all functions here to construct CFG and compute hashes, let's also mark functions without profile as ignored in Lite mode. This should happen after we assign profile, at the end of YAMLProfileReader::readProfile. Under the new option, go over all functions and check if the function has profile, if not, mark it ignored. https://github.com/llvm/llvm-project/pull/95821 ___ 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] Hash-based function matching (PR #95821)
@@ -363,9 +364,27 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { return Profile.Hash == static_cast(BF.getHash()); }; - // We have to do 2 passes since LTO introduces an ambiguity in function - // names. The first pass assigns profiles that match 100% by name and - // by hash. The second pass allows name ambiguity for LTO private functions. + uint64_t MatchedWithExactName = 0; + uint64_t MatchedWithHash = 0; + uint64_t MatchedWithLTOCommonName = 0; + + // Computes hash for binary functions. + if (opts::MatchingFunctionsWithHash) { +for (auto &[_, BF] : BC.getBinaryFunctions()) + BF.computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction); + } else { +for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs)) { + if (!BF) +continue; + BinaryFunction &Function = *BF; + + if (!opts::IgnoreHash) +Function.computeHash(YamlBP.Header.IsDFSOrder, + YamlBP.Header.HashFunction); +} + } aaupov wrote: ```suggestion if (opts::MatchingFunctionsWithHash) for (auto &[_, BF] : BC.getBinaryFunctions()) BF.computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction); else if (!opts::IgnoreHash) for (BinaryFunction *BF : ProfileBFs) BF->computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction); ``` https://github.com/llvm/llvm-project/pull/95821 ___ 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] Hash-based function matching (PR #95821)
@@ -1161,4 +1165,4 @@ - `--print-options` - Print non-default options after command line parsing aaupov wrote: nit: please avoid unrelated changes https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] d907514 - Revert "[clang-doc] Add --asset option to clang-doc (#94717)"
Author: Paul Kirth Date: 2024-06-21T13:17:41-07:00 New Revision: d9075144100406eed753f1b7ca3df933a596bb3a URL: https://github.com/llvm/llvm-project/commit/d9075144100406eed753f1b7ca3df933a596bb3a DIFF: https://github.com/llvm/llvm-project/commit/d9075144100406eed753f1b7ca3df933a596bb3a.diff LOG: Revert "[clang-doc] Add --asset option to clang-doc (#94717)" This reverts commit 724d903e03aaf7ee7d4bcdf3cd9fe1e1bda33f9a. Added: Modified: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp Removed: clang-tools-extra/test/clang-doc/single-source-html.cpp diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 5a43c70a5ebc3..5517522d7967d 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -81,12 +81,6 @@ static llvm::cl::list UserStylesheets( llvm::cl::desc("CSS stylesheets to extend the default styles."), llvm::cl::cat(ClangDocCategory)); -static llvm::cl::opt UserAssetPath( -"asset", -llvm::cl::desc("User supplied asset path to " - "override the default css and js files for html output"), -llvm::cl::cat(ClangDocCategory)); - static llvm::cl::opt SourceRoot("source-root", llvm::cl::desc(R"( Directory where processed files are stored. Links to definition locations will only be @@ -133,86 +127,16 @@ std::string getFormatString() { // GetMainExecutable (since some platforms don't support taking the // address of main, and some platforms can't implement GetMainExecutable // without being given the address of a function in the main executable). -std::string getExecutablePath(const char *Argv0, void *MainAddr) { +std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } -llvm::Error getAssetFiles(clang::doc::ClangDocContext &CDCtx) { - using DirIt = llvm::sys::fs::directory_iterator; - std::error_code FileErr; - llvm::SmallString<128> FilePath(UserAssetPath); - for (DirIt DirStart = DirIt(UserAssetPath, FileErr), - DirEnd; - !FileErr && DirStart != DirEnd; DirStart.increment(FileErr)) { -FilePath = DirStart->path(); -if (llvm::sys::fs::is_regular_file(FilePath)) { - if (llvm::sys::path::extension(FilePath) == ".css") -CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(FilePath)); - else if (llvm::sys::path::extension(FilePath) == ".js") -CDCtx.FilesToCopy.emplace_back(FilePath.str()); -} - } - if (FileErr) -return llvm::createFileError(FilePath, FileErr); - return llvm::Error::success(); -} - -llvm::Error getDefaultAssetFiles(const char *Argv0, - clang::doc::ClangDocContext &CDCtx) { - void *MainAddr = (void *)(intptr_t)getExecutablePath; - std::string ClangDocPath = getExecutablePath(Argv0, MainAddr); - llvm::SmallString<128> NativeClangDocPath; - llvm::sys::path::native(ClangDocPath, NativeClangDocPath); - - llvm::SmallString<128> AssetsPath; - AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); - llvm::sys::path::append(AssetsPath, "..", "share", "clang"); - llvm::SmallString<128> DefaultStylesheet; - llvm::sys::path::native(AssetsPath, DefaultStylesheet); - llvm::sys::path::append(DefaultStylesheet, - "clang-doc-default-stylesheet.css"); - llvm::SmallString<128> IndexJS; - llvm::sys::path::native(AssetsPath, IndexJS); - llvm::sys::path::append(IndexJS, "index.js"); - - llvm::outs() << "Using default asset: " << AssetsPath << "\n"; - - if (!llvm::sys::fs::is_regular_file(IndexJS)) -return llvm::createStringError(llvm::inconvertibleErrorCode(), - "default index.js file missing at " + - IndexJS + "\n"); - - if (!llvm::sys::fs::is_regular_file(DefaultStylesheet)) -return llvm::createStringError( -llvm::inconvertibleErrorCode(), -"default clang-doc-default-stylesheet.css file missing at " + -DefaultStylesheet + "\n"); - - CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet)); - CDCtx.FilesToCopy.emplace_back(IndexJS.str()); - - return llvm::Error::success(); -} - -llvm::Error getHtmlAssetFiles(const char *Argv0, - clang::doc::ClangDocContext &CDCtx) { - if (!UserAssetPath.empty() && - !llvm::sys::fs::is_directory(std::string(UserAssetPath))) -llvm::outs() << "Asset path supply is not a directory: " << UserAssetPath - << " falling back to default\n"; - if (llvm::sys::fs::is_directory(std::string(UserAssetPath))) -return getAssetFiles(CDCtx); - return getDefaultAssetFiles(Argv0, CDCtx); -} - int main(int argc,
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +393,34 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // the profile. Function.setExecutionCount(BinaryFunction::COUNT_NO_PROFILE); -// Recompute hash once per function. -if (!opts::IgnoreHash) - Function.computeHash(YamlBP.Header.IsDFSOrder, - YamlBP.Header.HashFunction); - -if (profileMatches(YamlBF, Function)) +if (profileMatches(YamlBF, Function)) { matchProfileToFunction(YamlBF, Function); + ++MatchedWithExactName; +} } + // Uses the strict hash of profiled and binary functions to match functions + // that are not matched by name or common name. + if (opts::MatchingFunctionsWithHash) { WenleiHe wrote: What is captured in strict hash? For reference, function hash for compiler PGO isn't very strict, and it's not strong enough for small functions. So we use comprehensive graph matching in addition to hash matching to recover renamed function/profile pair. Change in https://github.com/llvm/llvm-project/pull/95135 cc @wlei-llvm https://github.com/llvm/llvm-project/pull/95821 ___ 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] Hash-based function matching (PR #95821)
@@ -374,15 +393,34 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // the profile. Function.setExecutionCount(BinaryFunction::COUNT_NO_PROFILE); -// Recompute hash once per function. -if (!opts::IgnoreHash) - Function.computeHash(YamlBP.Header.IsDFSOrder, - YamlBP.Header.HashFunction); - -if (profileMatches(YamlBF, Function)) +if (profileMatches(YamlBF, Function)) { matchProfileToFunction(YamlBF, Function); + ++MatchedWithExactName; +} } + // Uses the strict hash of profiled and binary functions to match functions + // that are not matched by name or common name. + if (opts::MatchingFunctionsWithHash) { shawbyoung wrote: In BOLT, a strict hash captures a binary function's block order as well as each blocks' instructions & opcodes. So, the goal of this PR is to recover block-identical functions that have been simply been renamed. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [libcxx] [clang] Finish implementation of P0522 (PR #96023)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/96023 >From e5df11098caf4500b6cb3e2de8f9c927b609955a Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 17 Jun 2024 21:39:08 -0300 Subject: [PATCH] [clang] Finish implementation of P0522 This finishes the clang implementation of P0522, getting rid of the fallback to the old, pre-P0522 rules. Before this patch, when partial ordering template template parameters, we would perform, in order: * If the old rules would match, we would accept it. Otherwise, don't generate diagnostics yet. * If the new rules would match, just accept it. Otherwise, don't generate any diagnostics yet again. * Apply the old rules again, this time with diagnostics. This situation was far from ideal, as we would sometimes: * Accept some things we shouldn't. * Reject some things we shouldn't. * Only diagnose rejection in terms of the old rules. With this patch, we apply the P0522 rules throughout. This needed to extend template argument deduction in order to accept the historial rule for TTP matching pack parameter to non-pack arguments. This change also makes us accept some combinations of historical and P0522 allowances we wouldn't before. It also fixes a bunch of bugs that were documented in the test suite, which I am not sure there are issues already created for them. This causes a lot of changes to the way these failures are diagnosed, with related test suite churn. The problem here is that the old rules were very simple and non-recursive, making it easy to provide customized diagnostics, and to keep them consistent with each other. The new rules are a lot more complex and rely on template argument deduction, substitutions, and they are recursive. The approach taken here is to mostly rely on existing diagnostics, and create a new instantiation context that keeps track of this context. So for example when a substitution failure occurs, we use the error produced there unmodified, and just attach notes to it explaining that it occurred in the context of partial ordering this template argument against that template parameter. This diverges from the old diagnostics, which would lead with an error pointing to the template argument, explain the problem in subsequent notes, and produce a final note pointing to the parameter. --- clang/docs/ReleaseNotes.rst | 9 +- .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Sema/Sema.h | 14 +- clang/lib/Frontend/FrontendActions.cpp| 2 + clang/lib/Sema/SemaTemplate.cpp | 94 ++--- clang/lib/Sema/SemaTemplateDeduction.cpp | 339 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 15 + .../temp/temp.arg/temp.arg.template/p3-0x.cpp | 31 +- clang/test/CXX/temp/temp.param/p12.cpp| 21 +- clang/test/Modules/cxx-templates.cpp | 15 +- clang/test/SemaCXX/make_integer_seq.cpp | 5 +- clang/test/SemaTemplate/cwg2398.cpp | 27 +- clang/test/SemaTemplate/temp_arg_nontype.cpp | 45 ++- clang/test/SemaTemplate/temp_arg_template.cpp | 38 +- .../SemaTemplate/temp_arg_template_p0522.cpp | 70 ++-- .../Templight/templight-empty-entries-fix.cpp | 12 + .../templight-prior-template-arg.cpp | 33 +- .../type_traits/is_specialization.verify.cpp | 8 +- 18 files changed, 504 insertions(+), 281 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 7112d1f889fef..abe535f55fb2a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -176,6 +176,8 @@ C++17 Feature Support the values produced by GCC, so these macros should not be used from header files because they may not be stable across multiple TUs (the values may vary based on compiler version as well as CPU tuning). #GH60174 +- The implementation of the relaxed template template argument matching rules is + more complete and reliable, and should provide more accurate diagnostics. C++14 Feature Support ^ @@ -589,6 +591,10 @@ Improvements to Clang's diagnostics - Clang no longer emits a "declared here" note for a builtin function that has no declaration in source. Fixes #GH93369. +- Clang now properly explains the reason a template template argument failed to + match a template template parameter, in terms of the C++17 relaxed matching rules + instead of the old ones. + Improvements to Clang's time-trace -- @@ -887,7 +893,8 @@ Bug Fixes to C++ Support between the addresses of two labels (a GNU extension) to a pointer within a constant expression. (#GH95366). - Fix immediate escalation bugs in the presence of dependent call arguments. (#GH94935) - Clang now diagnoses explicit specializations with storage class specifiers in all contexts. - +- Fixes to several issues in partial ordering of template template parameters, which + were documented in the test suite
[llvm-branch-commits] [llvm] [BOLT] Name similarity function matching (PR #95884)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95884 >From 34652b2eebc62218c50a23509ce99937385c30e6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:42:00 -0700 Subject: [PATCH 1/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 73 -- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 66cabc236f4b2..c9f6d88f0b13a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -424,36 +424,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses name similarity to match functions that were not matched by name. uint64_t MatchedWithDemangledName = 0; - if (opts::NameSimilarityFunctionMatchingThreshold > 0) { - -std::unordered_map NameToBinaryFunction; -NameToBinaryFunction.reserve(BC.getBinaryFunctions().size()); -for (auto &[_, BF] : BC.getBinaryFunctions()) { + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { int Status = 0; - char *DemangledName = abi::__cxa_demangle(BF.getOneName().str().c_str(), + char *DemangledName = abi::__cxa_demangle(String, nullptr, nullptr, &Status); - if (Status == 0) -NameToBinaryFunction[std::string(DemangledName)] = &BF; + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); } for (auto YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; - int Status = 0; - char *DemangledName = - abi::__cxa_demangle(YamlBF.Name.c_str(), nullptr, nullptr, &Status); - if (Status != 0) + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) continue; - auto It = NameToBinaryFunction.find(DemangledName); - if (It == NameToBinaryFunction.end()) + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) continue; - BinaryFunction *BF = It->second; - matchProfileToFunction(YamlBF, *BF); - ++MatchedWithDemangledName; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); +if (!BFDemangledName) + continue; +unsigned BFEditDistance = StringRef(*BFDemangledName).edit_distance(*YamlBFDemangledName); +if (BFEditDistance < MinEditDistance) { + MinEditDistance = BFEditDistance; + ClosestNameBF = BF; +} + } + + if (ClosestNameBF && +MinEditDistance < opts::NameSimilarityFunctionMatchingThreshold) { +matchProfileToFunction(YamlBF, *ClosestNameBF); +++MatchedWithDemangledName; + } } } + outs() << MatchedWithDemangledName << ": functions matched by name similarity\n"; + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 2d23bbd6b9ce4f0786ae8ceb39b1b008b4ca9c4d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:45:27 -0700 Subject: [PATCH 2/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index c9f6d88f0b13a..cf4a5393df8f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -491,8 +491,6 @@ Error YAMLProfileReader::read
[llvm-branch-commits] [clang] [libcxx] [clang] Finish implementation of P0522 (PR #96023)
mizvekov wrote: @ldionne I had to adjust the libcxx expectation change. The simple regex won't work, as the error diagnostic is now produced in different source locations. I have changed it so it uses a preprocessor conditional, but that new solution will still break if libcxx-CI is using an outdated trunk clang. Let me know if you have a better idea. https://github.com/llvm/llvm-project/pull/96023 ___ 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] Name similarity function matching (PR #95884)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95884 >From 34652b2eebc62218c50a23509ce99937385c30e6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:42:00 -0700 Subject: [PATCH 1/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 73 -- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 66cabc236f4b2..c9f6d88f0b13a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -424,36 +424,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses name similarity to match functions that were not matched by name. uint64_t MatchedWithDemangledName = 0; - if (opts::NameSimilarityFunctionMatchingThreshold > 0) { - -std::unordered_map NameToBinaryFunction; -NameToBinaryFunction.reserve(BC.getBinaryFunctions().size()); -for (auto &[_, BF] : BC.getBinaryFunctions()) { + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { int Status = 0; - char *DemangledName = abi::__cxa_demangle(BF.getOneName().str().c_str(), + char *DemangledName = abi::__cxa_demangle(String, nullptr, nullptr, &Status); - if (Status == 0) -NameToBinaryFunction[std::string(DemangledName)] = &BF; + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); } for (auto YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; - int Status = 0; - char *DemangledName = - abi::__cxa_demangle(YamlBF.Name.c_str(), nullptr, nullptr, &Status); - if (Status != 0) + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) continue; - auto It = NameToBinaryFunction.find(DemangledName); - if (It == NameToBinaryFunction.end()) + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) continue; - BinaryFunction *BF = It->second; - matchProfileToFunction(YamlBF, *BF); - ++MatchedWithDemangledName; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); +if (!BFDemangledName) + continue; +unsigned BFEditDistance = StringRef(*BFDemangledName).edit_distance(*YamlBFDemangledName); +if (BFEditDistance < MinEditDistance) { + MinEditDistance = BFEditDistance; + ClosestNameBF = BF; +} + } + + if (ClosestNameBF && +MinEditDistance < opts::NameSimilarityFunctionMatchingThreshold) { +matchProfileToFunction(YamlBF, *ClosestNameBF); +++MatchedWithDemangledName; + } } } + outs() << MatchedWithDemangledName << ": functions matched by name similarity\n"; + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 2d23bbd6b9ce4f0786ae8ceb39b1b008b4ca9c4d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:45:27 -0700 Subject: [PATCH 2/3] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index c9f6d88f0b13a..cf4a5393df8f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -491,8 +491,6 @@ Error YAMLProfileReader::read
[llvm-branch-commits] [llvm] [BOLT] Name similarity function matching (PR #95884)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95884 >From 34652b2eebc62218c50a23509ce99937385c30e6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:42:00 -0700 Subject: [PATCH 1/4] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 73 -- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 66cabc236f4b2..c9f6d88f0b13a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -424,36 +424,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses name similarity to match functions that were not matched by name. uint64_t MatchedWithDemangledName = 0; - if (opts::NameSimilarityFunctionMatchingThreshold > 0) { - -std::unordered_map NameToBinaryFunction; -NameToBinaryFunction.reserve(BC.getBinaryFunctions().size()); -for (auto &[_, BF] : BC.getBinaryFunctions()) { + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { int Status = 0; - char *DemangledName = abi::__cxa_demangle(BF.getOneName().str().c_str(), + char *DemangledName = abi::__cxa_demangle(String, nullptr, nullptr, &Status); - if (Status == 0) -NameToBinaryFunction[std::string(DemangledName)] = &BF; + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); } for (auto YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; - int Status = 0; - char *DemangledName = - abi::__cxa_demangle(YamlBF.Name.c_str(), nullptr, nullptr, &Status); - if (Status != 0) + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) continue; - auto It = NameToBinaryFunction.find(DemangledName); - if (It == NameToBinaryFunction.end()) + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) continue; - BinaryFunction *BF = It->second; - matchProfileToFunction(YamlBF, *BF); - ++MatchedWithDemangledName; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); +if (!BFDemangledName) + continue; +unsigned BFEditDistance = StringRef(*BFDemangledName).edit_distance(*YamlBFDemangledName); +if (BFEditDistance < MinEditDistance) { + MinEditDistance = BFEditDistance; + ClosestNameBF = BF; +} + } + + if (ClosestNameBF && +MinEditDistance < opts::NameSimilarityFunctionMatchingThreshold) { +matchProfileToFunction(YamlBF, *ClosestNameBF); +++MatchedWithDemangledName; + } } } + outs() << MatchedWithDemangledName << ": functions matched by name similarity\n"; + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 2d23bbd6b9ce4f0786ae8ceb39b1b008b4ca9c4d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:45:27 -0700 Subject: [PATCH 2/4] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index c9f6d88f0b13a..cf4a5393df8f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -491,8 +491,6 @@ Error YAMLProfileReader::read
[llvm-branch-commits] [llvm] [BOLT] Name similarity function matching (PR #95884)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95884 >From 34652b2eebc62218c50a23509ce99937385c30e6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:42:00 -0700 Subject: [PATCH 1/5] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 73 -- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 66cabc236f4b2..c9f6d88f0b13a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -424,36 +424,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses name similarity to match functions that were not matched by name. uint64_t MatchedWithDemangledName = 0; - if (opts::NameSimilarityFunctionMatchingThreshold > 0) { - -std::unordered_map NameToBinaryFunction; -NameToBinaryFunction.reserve(BC.getBinaryFunctions().size()); -for (auto &[_, BF] : BC.getBinaryFunctions()) { + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { int Status = 0; - char *DemangledName = abi::__cxa_demangle(BF.getOneName().str().c_str(), + char *DemangledName = abi::__cxa_demangle(String, nullptr, nullptr, &Status); - if (Status == 0) -NameToBinaryFunction[std::string(DemangledName)] = &BF; + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); } for (auto YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; - int Status = 0; - char *DemangledName = - abi::__cxa_demangle(YamlBF.Name.c_str(), nullptr, nullptr, &Status); - if (Status != 0) + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) continue; - auto It = NameToBinaryFunction.find(DemangledName); - if (It == NameToBinaryFunction.end()) + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) continue; - BinaryFunction *BF = It->second; - matchProfileToFunction(YamlBF, *BF); - ++MatchedWithDemangledName; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); +if (!BFDemangledName) + continue; +unsigned BFEditDistance = StringRef(*BFDemangledName).edit_distance(*YamlBFDemangledName); +if (BFEditDistance < MinEditDistance) { + MinEditDistance = BFEditDistance; + ClosestNameBF = BF; +} + } + + if (ClosestNameBF && +MinEditDistance < opts::NameSimilarityFunctionMatchingThreshold) { +matchProfileToFunction(YamlBF, *ClosestNameBF); +++MatchedWithDemangledName; + } } } + outs() << MatchedWithDemangledName << ": functions matched by name similarity\n"; + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 2d23bbd6b9ce4f0786ae8ceb39b1b008b4ca9c4d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:45:27 -0700 Subject: [PATCH 2/5] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index c9f6d88f0b13a..cf4a5393df8f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -491,8 +491,6 @@ Error YAMLProfileReader::read
[llvm-branch-commits] [Hashing] Use a non-deterministic seed (PR #96282)
efriedma-quic wrote: We restricted reverse-iteration when we added it just to save time when we were enabling it: we wanted to prioritize issues that were actually likely to cause non-determinism (as opposed to relying on the hash algorithm, which is annoying but not actually non-deterministic). If you're willing to fix all the resulting breakage, it should be fine to apply it more widely. - I'm a little concerned that doing this in release builds is going to lead to weird bug reports. Especially given the current approach for getting randomness: ASLR isn't really that random, particularly on Windows, so the probability of getting a particular seed isn't uniform. https://github.com/llvm/llvm-project/pull/96282 ___ 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] Name similarity function matching (PR #95884)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95884 >From 34652b2eebc62218c50a23509ce99937385c30e6 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:42:00 -0700 Subject: [PATCH 1/6] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 73 -- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 66cabc236f4b2..c9f6d88f0b13a 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -424,36 +424,75 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses name similarity to match functions that were not matched by name. uint64_t MatchedWithDemangledName = 0; - if (opts::NameSimilarityFunctionMatchingThreshold > 0) { - -std::unordered_map NameToBinaryFunction; -NameToBinaryFunction.reserve(BC.getBinaryFunctions().size()); -for (auto &[_, BF] : BC.getBinaryFunctions()) { + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { +auto DemangleName = [&](const char* String) { int Status = 0; - char *DemangledName = abi::__cxa_demangle(BF.getOneName().str().c_str(), + char *DemangledName = abi::__cxa_demangle(String, nullptr, nullptr, &Status); - if (Status == 0) -NameToBinaryFunction[std::string(DemangledName)] = &BF; + return Status == 0 ? new std::string(DemangledName) : nullptr; +}; + +auto DeriveNameSpace = [&](std::string DemangledName) { + size_t LParen = std::string(DemangledName).find("("); + std::string FunctionName = std::string(DemangledName).substr(0, LParen); + size_t ScopeResolutionOperator = std::string(FunctionName).rfind("::"); + return ScopeResolutionOperator == std::string::npos ? std::string("") : std::string(DemangledName).substr(0, ScopeResolutionOperator); +}; + +std::unordered_map> NamespaceToBFs; +NamespaceToBFs.reserve(BC.getBinaryFunctions().size()); + +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) { + std::string* DemangledName = DemangleName(BF->getOneName().str().c_str()); + if (!DemangledName) +continue; + std::string Namespace = DeriveNameSpace(*DemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) +NamespaceToBFs[Namespace] = {BF}; + else +It->second.push_back(BF); } for (auto YamlBF : YamlBP.Functions) { if (YamlBF.Used) continue; - int Status = 0; - char *DemangledName = - abi::__cxa_demangle(YamlBF.Name.c_str(), nullptr, nullptr, &Status); - if (Status != 0) + std::string* YamlBFDemangledName = DemangleName(YamlBF.Name.c_str()); + if (!YamlBFDemangledName) continue; - auto It = NameToBinaryFunction.find(DemangledName); - if (It == NameToBinaryFunction.end()) + std::string Namespace = DeriveNameSpace(*YamlBFDemangledName); + auto It = NamespaceToBFs.find(Namespace); + if (It == NamespaceToBFs.end()) continue; - BinaryFunction *BF = It->second; - matchProfileToFunction(YamlBF, *BF); - ++MatchedWithDemangledName; + std::vector BFs = It->second; + + unsigned MinEditDistance = UINT_MAX; + BinaryFunction *ClosestNameBF = nullptr; + + for (BinaryFunction *BF : BFs) { +if (ProfiledFunctions.count(BF)) + continue; +std::string *BFDemangledName = DemangleName(BF->getOneName().str().c_str()); +if (!BFDemangledName) + continue; +unsigned BFEditDistance = StringRef(*BFDemangledName).edit_distance(*YamlBFDemangledName); +if (BFEditDistance < MinEditDistance) { + MinEditDistance = BFEditDistance; + ClosestNameBF = BF; +} + } + + if (ClosestNameBF && +MinEditDistance < opts::NameSimilarityFunctionMatchingThreshold) { +matchProfileToFunction(YamlBF, *ClosestNameBF); +++MatchedWithDemangledName; + } } } + outs() << MatchedWithDemangledName << ": functions matched by name similarity\n"; + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) if (!YamlBF.Used && opts::Verbosity >= 1) errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name >From 2d23bbd6b9ce4f0786ae8ceb39b1b008b4ca9c4d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Thu, 20 Jun 2024 23:45:27 -0700 Subject: [PATCH 2/6] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index c9f6d88f0b13a..cf4a5393df8f4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -491,8 +491,6 @@ Error YAMLProfileReader::read
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -1161,4 +1165,4 @@ - `--print-options` - Print non-default options after command line parsing shawbyoung wrote: Didn't touch this line - diff return nothing when applied to "added" and "deleted" line - maybe it's some git corner case? https://github.com/llvm/llvm-project/pull/95821 ___ 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] Hash-based function matching (PR #95821)
https://github.com/shawbyoung edited https://github.com/llvm/llvm-project/pull/95821 ___ 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] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/15] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index f0fcb1c130002..2bca83c9d11ec 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,6 +421,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count(&BF)) + continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/15] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 2bca83c9d11ec..56474a67307ed 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -417,10 +417,10 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { for (auto YamlBF : YamlBP.Functions) { auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); -if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { +if (It != StrictBinaryFunctionHashes.end() && +!ProfiledFunctions.count(It->second)) { auto *BF = It->second; matchProfileToFunction(YamlBF, *BF); } >From 8e7b2229a69c3795e723404c56e0d4298eef412a Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/15] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- bolt/test/X86/profile-passthrough-block.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 56474a67307ed..779d60bce3b66 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,7 +421,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count(&BF)) +if (ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } diff --git a/bolt/test/X86/profile-passthrough-block.test b/bolt/test/X86/profile-passthrough-block.test index 1b875885260dc..ed2a8117ddfc4 100644 --- a/bolt/test/X86/profile-passthrough-block.test +++ b/bolt/test/X86/profile-passthrough-block.test @@ -57,7 +57,7 @@ header: functions: - name:main fid: 0 -hash:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/15] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 779d60bce3b66..e3d30bfdb74e4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -427,6 +427,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { } for (auto YamlBF : YamlBP.Functions) { +if (YamlBF.Used) + continue; auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { >From 41ce2897a445e47dfe685da66b4af080824e78ed Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/15] spr amend Created using spr 1.3.4 --- bolt/test/X86/profile-passthrough-block.test | 2 +- 1 file changed, 1 insertion(+), 1 deleti
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/16] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index f0fcb1c130002..2bca83c9d11ec 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,6 +421,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count(&BF)) + continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/16] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 2bca83c9d11ec..56474a67307ed 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -417,10 +417,10 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { for (auto YamlBF : YamlBP.Functions) { auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); -if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { +if (It != StrictBinaryFunctionHashes.end() && +!ProfiledFunctions.count(It->second)) { auto *BF = It->second; matchProfileToFunction(YamlBF, *BF); } >From 8e7b2229a69c3795e723404c56e0d4298eef412a Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/16] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- bolt/test/X86/profile-passthrough-block.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 56474a67307ed..779d60bce3b66 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,7 +421,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count(&BF)) +if (ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } diff --git a/bolt/test/X86/profile-passthrough-block.test b/bolt/test/X86/profile-passthrough-block.test index 1b875885260dc..ed2a8117ddfc4 100644 --- a/bolt/test/X86/profile-passthrough-block.test +++ b/bolt/test/X86/profile-passthrough-block.test @@ -57,7 +57,7 @@ header: functions: - name:main fid: 0 -hash:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/16] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 779d60bce3b66..e3d30bfdb74e4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -427,6 +427,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { } for (auto YamlBF : YamlBP.Functions) { +if (YamlBF.Used) + continue; auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { >From 41ce2897a445e47dfe685da66b4af080824e78ed Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/16] spr amend Created using spr 1.3.4 --- bolt/test/X86/profile-passthrough-block.test | 2 +- 1 file changed, 1 insertion(+), 1 deleti
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/17] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index f0fcb1c130002..2bca83c9d11ec 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,6 +421,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count(&BF)) + continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/17] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 2bca83c9d11ec..56474a67307ed 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -417,10 +417,10 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { for (auto YamlBF : YamlBP.Functions) { auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); -if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { +if (It != StrictBinaryFunctionHashes.end() && +!ProfiledFunctions.count(It->second)) { auto *BF = It->second; matchProfileToFunction(YamlBF, *BF); } >From 8e7b2229a69c3795e723404c56e0d4298eef412a Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/17] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- bolt/test/X86/profile-passthrough-block.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 56474a67307ed..779d60bce3b66 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,7 +421,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count(&BF)) +if (ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } diff --git a/bolt/test/X86/profile-passthrough-block.test b/bolt/test/X86/profile-passthrough-block.test index 1b875885260dc..ed2a8117ddfc4 100644 --- a/bolt/test/X86/profile-passthrough-block.test +++ b/bolt/test/X86/profile-passthrough-block.test @@ -57,7 +57,7 @@ header: functions: - name:main fid: 0 -hash:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/17] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 779d60bce3b66..e3d30bfdb74e4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -427,6 +427,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { } for (auto YamlBF : YamlBP.Functions) { +if (YamlBF.Used) + continue; auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { >From 41ce2897a445e47dfe685da66b4af080824e78ed Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/17] spr amend Created using spr 1.3.4 --- bolt/test/X86/profile-passthrough-block.test | 2 +- 1 file changed, 1 insertion(+), 1 deleti
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/18] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index f0fcb1c130002..2bca83c9d11ec 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,6 +421,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count(&BF)) + continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/18] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 2bca83c9d11ec..56474a67307ed 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -417,10 +417,10 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { for (auto YamlBF : YamlBP.Functions) { auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); -if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { +if (It != StrictBinaryFunctionHashes.end() && +!ProfiledFunctions.count(It->second)) { auto *BF = It->second; matchProfileToFunction(YamlBF, *BF); } >From 8e7b2229a69c3795e723404c56e0d4298eef412a Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/18] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 +- bolt/test/X86/profile-passthrough-block.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 56474a67307ed..779d60bce3b66 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -421,7 +421,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count(&BF)) +if (ProfiledFunctions.count(&BF)) continue; StrictBinaryFunctionHashes[BF.getHash()] = &BF; } diff --git a/bolt/test/X86/profile-passthrough-block.test b/bolt/test/X86/profile-passthrough-block.test index 1b875885260dc..ed2a8117ddfc4 100644 --- a/bolt/test/X86/profile-passthrough-block.test +++ b/bolt/test/X86/profile-passthrough-block.test @@ -57,7 +57,7 @@ header: functions: - name:main fid: 0 -hash:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/18] spr amend Created using spr 1.3.4 --- bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp index 779d60bce3b66..e3d30bfdb74e4 100644 --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -427,6 +427,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { } for (auto YamlBF : YamlBP.Functions) { +if (YamlBF.Used) + continue; auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { >From 41ce2897a445e47dfe685da66b4af080824e78ed Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/18] spr amend Created using spr 1.3.4 --- bolt/test/X86/profile-passthrough-block.test | 2 +- 1 file changed, 1 insertion(+), 1 deleti
[llvm-branch-commits] [flang] 2a4add4 - Revert "[flang] Fix execute_command_line cmdstat is not set when error occurs…"
Author: Kiran Chandramohan Date: 2024-06-21T23:45:46+01:00 New Revision: 2a4add4de4d882fbf3e9d75b2a6a7609687a7890 URL: https://github.com/llvm/llvm-project/commit/2a4add4de4d882fbf3e9d75b2a6a7609687a7890 DIFF: https://github.com/llvm/llvm-project/commit/2a4add4de4d882fbf3e9d75b2a6a7609687a7890.diff LOG: Revert "[flang] Fix execute_command_line cmdstat is not set when error occurs…" This reverts commit 4232dd586b65c9301304cab2fb166d8df97c591a. Added: Modified: flang/docs/Intrinsics.md flang/runtime/execute.cpp flang/unittests/Runtime/CommandTest.cpp Removed: diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md index d1f7cd8372e24..8853d4d9e1c79 100644 --- a/flang/docs/Intrinsics.md +++ b/flang/docs/Intrinsics.md @@ -893,17 +893,16 @@ used in constant expressions have currently no folding support at all. # `CMDSTAT`: - Synchronous execution: - - -2: `ASYNC_NO_SUPPORT_ERR` - No error condition occurs, but `WAIT` is present with the value `false`, and the processor does not support asynchronous execution. - - -1: `NO_SUPPORT_ERR` - The processor does not support command line execution. (system returns -1 with errno `ENOENT`) - - 0: `CMD_EXECUTED` - Command executed with no error. + - -2: No error condition occurs, but `WAIT` is present with the value `false`, and the processor does not support asynchronous execution. + - -1: The processor does not support command line execution. - \+ (positive value): An error condition occurs. -- 1: `FORK_ERR` - Fork Error (occurs only on POSIX-compatible systems). -- 2: `EXECL_ERR` - Execution Error (system returns -1 with other errno). -- 3: `COMMAND_EXECUTION_ERR` - Invalid Command Error (exit code 1). -- 4: `COMMAND_CANNOT_EXECUTE_ERR` - Command Cannot Execute Error (Linux exit code 126). -- 5: `COMMAND_NOT_FOUND_ERR` - Command Not Found Error (Linux exit code 127). -- 6: `INVALID_CL_ERR` - Invalid Command Line Error (covers all other non-zero exit codes). -- 7: `SIGNAL_ERR` - Signal error (either stopped or killed by signal, occurs only on POSIX-compatible systems). +- 1: Fork Error (occurs only on POSIX-compatible systems). +- 2: Execution Error (command exits with status -1). +- 3: Invalid Command Error (determined by the exit code depending on the system). + - On Windows: exit code is 1. + - On POSIX-compatible systems: exit code is 127 or 126. +- 4: Signal error (either stopped or killed by signal, occurs only on POSIX-compatible systems). + - 0: Otherwise. - Asynchronous execution: - 0 will always be assigned. diff --git a/flang/runtime/execute.cpp b/flang/runtime/execute.cpp index c7f8f386d81f4..0f5bc5059e21d 100644 --- a/flang/runtime/execute.cpp +++ b/flang/runtime/execute.cpp @@ -13,10 +13,8 @@ #include "tools.h" #include "flang/Runtime/descriptor.h" #include -#include #include #include - #ifdef _WIN32 #include "flang/Common/windows-include.h" #else @@ -34,16 +32,13 @@ namespace Fortran::runtime { // and the processor does not support asynchronous execution. Otherwise it is // assigned the value 0 enum CMD_STAT { - ASYNC_NO_SUPPORT_ERR = -2, // system returns -1 with ENOENT - NO_SUPPORT_ERR = -1, // Linux setsid() returns -1 - CMD_EXECUTED = 0, // command executed with no error - FORK_ERR = 1, // Linux fork() returns < 0 - EXECL_ERR = 2, // system returns -1 with other errno - COMMAND_EXECUTION_ERR = 3, // exit code 1 - COMMAND_CANNOT_EXECUTE_ERR = 4, // Linux exit code 126 - COMMAND_NOT_FOUND_ERR = 5, // Linux exit code 127 - INVALID_CL_ERR = 6, // cover all other non-zero exit code - SIGNAL_ERR = 7 + ASYNC_NO_SUPPORT_ERR = -2, + NO_SUPPORT_ERR = -1, + CMD_EXECUTED = 0, + FORK_ERR = 1, + EXECL_ERR = 2, + INVALID_CL_ERR = 3, + SIGNAL_ERR = 4 }; // Override CopyCharsToDescriptor in tools.h, pass string directly @@ -67,86 +62,24 @@ void CheckAndStoreIntToDescriptor( // If a condition occurs that would assign a nonzero value to CMDSTAT but // the CMDSTAT variable is not present, error termination is initiated. -std::int64_t TerminationCheck(std::int64_t status, const Descriptor *cmdstat, +int TerminationCheck(int status, const Descriptor *cmdstat, const Descriptor *cmdmsg, Terminator &terminator) { - // On both Windows and Linux, errno is set when system returns -1. if (status == -1) { -// On Windows, ENOENT means the command interpreter can't be found. -// On Linux, system calls execl with filepath "/bin/sh", ENOENT means the -// file pathname does not exist. -if (errno == ENOENT) { - if (!cmdstat) { -terminator.Crash("Command line execution is not supported, system " - "returns -1 with errno ENOENT."); - } else { -StoreIntToDescriptor(cmdstat, NO_SUPPORT_ERR, terminator); -CheckAndCopyCharsToDescriptor(cmdmsg, -"C
[llvm-branch-commits] [Hashing] Use a non-deterministic seed (PR #96282)
MaskRay wrote: Due to ASLR and malloc non-determinism, `DenseMap` already introduces a lot of non-determinism to release builds. `DenseMap` issues are less pronounced compared with `DenseMap`. > I'm a little concerned that doing this in release builds is going to lead to > weird bug reports I understand the concern. If we receive 10 weird bug reports root caused to `DenseMap`, the number of `DenseMap` bug reports might just be 1. --- The next step is to make integer type keys (e.g. `DenseMap`) non-deterministic. IIRC the recent uint64_t getHashKey changes does not require any test update. The number of `DenseMap` bug reports might be small. As my previous comment says: > we could consider restrict the nondeterminism to LLVM_ENABLE_ASSERTIONS=on. but I haven't found it necessary. https://github.com/llvm/llvm-project/pull/96282 ___ 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] [SPARC][IAS] Rework ASI tag matching in prep for `ParseForAllFeatures` (PR #96020)
https://github.com/koachan updated https://github.com/llvm/llvm-project/pull/96020 ___ 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] [SPARC][IAS] Rework ASI tag matching in prep for `ParseForAllFeatures` (PR #96020)
https://github.com/koachan updated https://github.com/llvm/llvm-project/pull/96020 ___ 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] [AArch64][PAC] Reduce the size of synchronous CFI (PR #96377)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/96377 For synchronous unwind tables, the call frame information can be slightly reduced by bundling the `.cfi_negate_ra_state` instruction with other CFI instructions in the prolog, saving 1 byte per function used for `DW_CFA_advance_loc`. This was suggested in [D156428](https://reviews.llvm.org/D156428#4554317). >From 4880bc9fca58a185f70acf00a8c31891184272cd Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 20 Jun 2024 18:53:45 -0700 Subject: [PATCH] [AArch64][PAC] Reduce the size of synchronous CFI For synchronous unwind tables, the call frame information can be slightly reduced by bundling the `.cfi_negate_ra_state` instruction with other CFI instructions in the prolog, saving 1 byte per function used for `DW_CFA_advance_loc`. This was suggested in [D156428](https://reviews.llvm.org/D156428#4554317). --- .../lib/Target/AArch64/AArch64PointerAuth.cpp | 13 + .../machine-outliner-retaddr-sign-cfi.ll | 3 +- ...tliner-retaddr-sign-diff-scope-same-key.ll | 6 ++-- .../machine-outliner-retaddr-sign-non-leaf.ll | 9 -- .../machine-outliner-retaddr-sign-regsave.mir | 3 +- ...tliner-retaddr-sign-same-scope-diff-key.ll | 9 -- ...machine-outliner-retaddr-sign-subtarget.ll | 9 -- .../machine-outliner-retaddr-sign-thunk.ll| 12 +--- .../AArch64/pacbti-llvm-generated-funcs-2.ll | 9 -- ...sign-return-address-cfi-negate-ra-state.ll | 13 + .../AArch64/sign-return-address-pauth-lr.ll | 28 +-- .../CodeGen/AArch64/sign-return-address.ll| 18 ++-- 12 files changed, 84 insertions(+), 48 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp index e900f6881620f..eb0ff73200407 100644 --- a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp +++ b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp @@ -100,6 +100,7 @@ void AArch64PointerAuth::signLR(MachineFunction &MF, auto &MFnI = *MF.getInfo(); bool UseBKey = MFnI.shouldSignWithBKey(); bool EmitCFI = MFnI.needsDwarfUnwindInfo(MF); + bool EmitAsyncCFI = MFnI.needsAsyncDwarfUnwindInfo(MF); bool NeedsWinCFI = MF.hasWinCFI(); MachineBasicBlock &MBB = *MBBI->getParent(); @@ -137,6 +138,18 @@ void AArch64PointerAuth::signLR(MachineFunction &MF, } if (EmitCFI) { +if (!EmitAsyncCFI) { + // Reduce the size of the generated call frame information for synchronous + // CFI by bundling the new CFI instruction with others in the prolog, so + // that no additional DW_CFA_advance_loc is needed. + for (auto I = MBBI; I != MBB.end(); ++I) { +if (I->getOpcode() == TargetOpcode::CFI_INSTRUCTION && +I->getFlag(MachineInstr::FrameSetup)) { + MBBI = I; + break; +} + } +} unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createNegateRAState(nullptr)); BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll index 4bbbe40176313..c64b3842aa5ba 100644 --- a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll +++ b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll @@ -11,7 +11,8 @@ define void @a() "sign-return-address"="all" "sign-return-address-key"="b_key" { ; CHECK-NEXT: .cfi_b_key_frame ; V8A-NEXT:hint #27 ; V83A-NEXT: pacibsp -; CHECK-NEXT: .cfi_negate_ra_state +; CHECK: .cfi_negate_ra_state +; CHECK-NEXT: .cfi_def_cfa_offset %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll index f4e9c0a4c2204..3221815da33c5 100644 --- a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll +++ b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll @@ -7,7 +7,8 @@ define void @a() "sign-return-address"="all" { ; CHECK-LABEL: a: // @a ; V8A: hint #25 ; V83A: paciasp -; CHECK-NEXT: .cfi_negate_ra_state +; CHECK:.cfi_negate_ra_state +; CHECK-NEXT: .cfi_def_cfa_offset %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 @@ -54,7 +55,8 @@ define void @c() "sign-return-address"="all" { ; CHECK-LABEL: c: // @c ; V8A: hint #25 ; V83A:paciasp -; CHECK-NEXT: .cfi_negate_ra_state +; CHECK: .cfi_negate_ra_state +; CHECK-NEXT: .cfi_def_cfa_offset %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 diff --git a/llvm/test/CodeGe
[llvm-branch-commits] [llvm] [AArch64][PAC] Reduce the size of synchronous CFI (PR #96377)
llvmbot wrote: @llvm/pr-subscribers-backend-aarch64 Author: Igor Kudrin (igorkudrin) Changes For synchronous unwind tables, the call frame information can be slightly reduced by bundling the `.cfi_negate_ra_state` instruction with other CFI instructions in the prolog, saving 1 byte per function used for `DW_CFA_advance_loc`. This was suggested in [D156428](https://reviews.llvm.org/D156428#4554317). --- Patch is 24.95 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96377.diff 12 Files Affected: - (modified) llvm/lib/Target/AArch64/AArch64PointerAuth.cpp (+13) - (modified) llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll (+2-1) - (modified) llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll (+4-2) - (modified) llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-non-leaf.ll (+6-3) - (modified) llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-regsave.mir (+2-1) - (modified) llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-same-scope-diff-key.ll (+6-3) - (modified) llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-subtarget.ll (+6-3) - (modified) llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-thunk.ll (+8-4) - (modified) llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll (+6-3) - (modified) llvm/test/CodeGen/AArch64/sign-return-address-cfi-negate-ra-state.ll (+8-5) - (modified) llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll (+14-14) - (modified) llvm/test/CodeGen/AArch64/sign-return-address.ll (+9-9) ``diff diff --git a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp index e900f6881620f..eb0ff73200407 100644 --- a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp +++ b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp @@ -100,6 +100,7 @@ void AArch64PointerAuth::signLR(MachineFunction &MF, auto &MFnI = *MF.getInfo(); bool UseBKey = MFnI.shouldSignWithBKey(); bool EmitCFI = MFnI.needsDwarfUnwindInfo(MF); + bool EmitAsyncCFI = MFnI.needsAsyncDwarfUnwindInfo(MF); bool NeedsWinCFI = MF.hasWinCFI(); MachineBasicBlock &MBB = *MBBI->getParent(); @@ -137,6 +138,18 @@ void AArch64PointerAuth::signLR(MachineFunction &MF, } if (EmitCFI) { +if (!EmitAsyncCFI) { + // Reduce the size of the generated call frame information for synchronous + // CFI by bundling the new CFI instruction with others in the prolog, so + // that no additional DW_CFA_advance_loc is needed. + for (auto I = MBBI; I != MBB.end(); ++I) { +if (I->getOpcode() == TargetOpcode::CFI_INSTRUCTION && +I->getFlag(MachineInstr::FrameSetup)) { + MBBI = I; + break; +} + } +} unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createNegateRAState(nullptr)); BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll index 4bbbe40176313..c64b3842aa5ba 100644 --- a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll +++ b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll @@ -11,7 +11,8 @@ define void @a() "sign-return-address"="all" "sign-return-address-key"="b_key" { ; CHECK-NEXT: .cfi_b_key_frame ; V8A-NEXT:hint #27 ; V83A-NEXT: pacibsp -; CHECK-NEXT: .cfi_negate_ra_state +; CHECK: .cfi_negate_ra_state +; CHECK-NEXT: .cfi_def_cfa_offset %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll index f4e9c0a4c2204..3221815da33c5 100644 --- a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll +++ b/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll @@ -7,7 +7,8 @@ define void @a() "sign-return-address"="all" { ; CHECK-LABEL: a: // @a ; V8A: hint #25 ; V83A: paciasp -; CHECK-NEXT: .cfi_negate_ra_state +; CHECK:.cfi_negate_ra_state +; CHECK-NEXT: .cfi_def_cfa_offset %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 @@ -54,7 +55,8 @@ define void @c() "sign-return-address"="all" { ; CHECK-LABEL: c: // @c ; V8A: hint #25 ; V83A:paciasp -; CHECK-NEXT: .cfi_negate_ra_state +; CHECK: .cfi_negate_ra_state +; CHECK-NEXT: .cfi_def_cfa_offset %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-non-leaf.ll b/llvm/test/CodeGen/AArch6