[llvm-branch-commits] [flang] [flang][OpenMP] Extend `do concurrent` mapping to device (PR #155987)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/155987 >From 959c75f8f0af9ae0d1ac4598d8200f888f33f352 Mon Sep 17 00:00:00 2001 From: ergawy Date: Fri, 29 Aug 2025 02:04:49 -0500 Subject: [PATCH] [flang][OpenMP] Extend `do concurrent` mapping to device Upstreams further parts of `do concurrent` to OpenMP conversion pass from AMD's fork. This PR extends the pass by adding support for mapping to the device. --- flang/lib/Optimizer/OpenMP/CMakeLists.txt | 1 + .../OpenMP/DoConcurrentConversion.cpp | 401 +- .../Transforms/DoConcurrent/basic_device.f90 | 83 .../Transforms/DoConcurrent/basic_device.mlir | 10 +- 4 files changed, 477 insertions(+), 18 deletions(-) create mode 100644 flang/test/Transforms/DoConcurrent/basic_device.f90 diff --git a/flang/lib/Optimizer/OpenMP/CMakeLists.txt b/flang/lib/Optimizer/OpenMP/CMakeLists.txt index e0aebd0714c8f..b85ee7e861a4f 100644 --- a/flang/lib/Optimizer/OpenMP/CMakeLists.txt +++ b/flang/lib/Optimizer/OpenMP/CMakeLists.txt @@ -26,6 +26,7 @@ add_flang_library(FlangOpenMPTransforms FIRSupport FortranSupport HLFIRDialect + FortranUtils MLIR_DEPS ${dialect_libs} diff --git a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp index de3b8d730072f..44be055e555e1 100644 --- a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp +++ b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp @@ -6,17 +6,22 @@ // //===--===// +#include "flang/Optimizer/Builder/DirectivesCommon.h" #include "flang/Optimizer/Builder/FIRBuilder.h" +#include "flang/Optimizer/Builder/HLFIRTools.h" #include "flang/Optimizer/Builder/Todo.h" #include "flang/Optimizer/Dialect/FIROps.h" +#include "flang/Optimizer/HLFIR/HLFIROps.h" #include "flang/Optimizer/OpenMP/Passes.h" #include "flang/Optimizer/OpenMP/Utils.h" #include "flang/Support/OpenMP-utils.h" +#include "flang/Utils/OpenMP.h" #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "mlir/IR/IRMapping.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/RegionUtils.h" +#include "llvm/Frontend/OpenMP/OMPConstants.h" namespace flangomp { #define GEN_PASS_DEF_DOCONCURRENTCONVERSIONPASS @@ -107,6 +112,33 @@ struct InductionVariableInfo { using InductionVariableInfos = llvm::SmallVector; +/// Collect the list of values used inside the loop but defined outside of it. +void collectLoopLiveIns(fir::DoConcurrentLoopOp loop, +llvm::SmallVectorImpl &liveIns) { + llvm::SmallDenseSet seenValues; + llvm::SmallDenseSet seenOps; + + for (auto [lb, ub, st] : llvm::zip_equal( + loop.getLowerBound(), loop.getUpperBound(), loop.getStep())) { +liveIns.push_back(lb); +liveIns.push_back(ub); +liveIns.push_back(st); + } + + mlir::visitUsedValuesDefinedAbove( + loop.getRegion(), [&](mlir::OpOperand *operand) { +if (!seenValues.insert(operand->get()).second) + return; + +mlir::Operation *definingOp = operand->get().getDefiningOp(); +// We want to collect ops corresponding to live-ins only once. +if (definingOp && !seenOps.insert(definingOp).second) + return; + +liveIns.push_back(operand->get()); + }); +} + /// Collects values that are local to a loop: "loop-local values". A loop-local /// value is one that is used exclusively inside the loop but allocated outside /// of it. This usually corresponds to temporary values that are used inside the @@ -182,10 +214,6 @@ class DoConcurrentConversion mlir::LogicalResult matchAndRewrite(fir::DoConcurrentOp doLoop, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { -if (mapToDevice) - return doLoop.emitError( - "not yet implemented: Mapping `do concurrent` loops to device"); - looputils::InductionVariableInfos ivInfos; auto loop = mlir::cast( doLoop.getRegion().back().getTerminator()); @@ -196,20 +224,72 @@ class DoConcurrentConversion for (mlir::Value indVar : *indVars) ivInfos.emplace_back(loop, indVar); +llvm::SmallVector loopNestLiveIns; +looputils::collectLoopLiveIns(loop, loopNestLiveIns); +assert(!loopNestLiveIns.empty()); + llvm::SetVector locals; looputils::collectLoopLocalValues(loop, locals); +// We do not want to map "loop-local" values to the device through +// `omp.map.info` ops. Therefore, we remove them from the list of live-ins. +loopNestLiveIns.erase(llvm::remove_if(loopNestLiveIns, + [&](mlir::Value liveIn) { +return locals.contains(liveIn); + }), + loopNestLiveIns.end()); + +mlir::omp::TargetOp targetOp;
[llvm-branch-commits] [llvm] [flang][do concurent] Add saxpy offload tests for OpenMP mapping (PR #155993)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/155993 >From d592609334934d668abeb75673048cc9c89d931f Mon Sep 17 00:00:00 2001 From: ergawy Date: Fri, 29 Aug 2025 04:04:07 -0500 Subject: [PATCH] [flang][do concurent] Add saxpy offload tests for OpenMP mapping Adds end-to-end tests for `do concurrent` offloading to the device. --- .../fortran/do-concurrent-to-omp-saxpy-2d.f90 | 53 +++ .../fortran/do-concurrent-to-omp-saxpy.f90| 53 +++ 2 files changed, 106 insertions(+) create mode 100644 offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 create mode 100644 offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 diff --git a/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 new file mode 100644 index 0..c6f576acb90b6 --- /dev/null +++ b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 @@ -0,0 +1,53 @@ +! REQUIRES: flang, amdgpu + +! RUN: %libomptarget-compile-fortran-generic -fdo-concurrent-to-openmp=device +! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic +module saxpymod + use iso_fortran_env + public :: saxpy +contains + +subroutine saxpy(a, x, y, n, m) + use iso_fortran_env + implicit none + integer,intent(in) :: n, m + real(kind=real32),intent(in) :: a + real(kind=real32), dimension(:,:),intent(in) :: x + real(kind=real32), dimension(:,:),intent(inout) :: y + integer :: i, j + + do concurrent(i=1:n, j=1:m) + y(i,j) = a * x(i,j) + y(i,j) + end do + + write(*,*) "plausibility check:" + write(*,'("y(1,1) ",f8.6)') y(1,1) + write(*,'("y(n,m) ",f8.6)') y(n,m) +end subroutine saxpy + +end module saxpymod + +program main + use iso_fortran_env + use saxpymod, ONLY:saxpy + implicit none + + integer,parameter :: n = 1000, m=1 + real(kind=real32), allocatable, dimension(:,:) :: x, y + real(kind=real32) :: a + integer :: i + + allocate(x(1:n,1:m), y(1:n,1:m)) + a = 2.0_real32 + x(:,:) = 1.0_real32 + y(:,:) = 2.0_real32 + + call saxpy(a, x, y, n, m) + + deallocate(x,y) +end program main + +! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}} +! CHECK: plausibility check: +! CHECK: y(1,1) 4.0 +! CHECK: y(n,m) 4.0 diff --git a/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 new file mode 100644 index 0..e094a1d7459ef --- /dev/null +++ b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 @@ -0,0 +1,53 @@ +! REQUIRES: flang, amdgpu + +! RUN: %libomptarget-compile-fortran-generic -fdo-concurrent-to-openmp=device +! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic +module saxpymod + use iso_fortran_env + public :: saxpy +contains + +subroutine saxpy(a, x, y, n) + use iso_fortran_env + implicit none + integer,intent(in) :: n + real(kind=real32),intent(in) :: a + real(kind=real32), dimension(:),intent(in) :: x + real(kind=real32), dimension(:),intent(inout) :: y + integer :: i + + do concurrent(i=1:n) + y(i) = a * x(i) + y(i) + end do + + write(*,*) "plausibility check:" + write(*,'("y(1) ",f8.6)') y(1) + write(*,'("y(n) ",f8.6)') y(n) +end subroutine saxpy + +end module saxpymod + +program main + use iso_fortran_env + use saxpymod, ONLY:saxpy + implicit none + + integer,parameter :: n = 1000 + real(kind=real32), allocatable, dimension(:) :: x, y + real(kind=real32) :: a + integer :: i + + allocate(x(1:n), y(1:n)) + a = 2.0_real32 + x(:) = 1.0_real32 + y(:) = 2.0_real32 + + call saxpy(a, x, y, n) + + deallocate(x,y) +end program main + +! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}} +! CHECK: plausibility check: +! CHECK: y(1) 4.0 +! CHECK: y(n) 4.0 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang][OpenMP] `do concurrent` to device mapping lit tests (PR #155992)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/155992 >From f19a301531f99c65b666969bb9e174698d315d0d Mon Sep 17 00:00:00 2001 From: ergawy Date: Fri, 29 Aug 2025 03:53:51 -0500 Subject: [PATCH] [flang][OpenMP] `do concurrent` to device mapping lit tests Adds more lit tests for `do concurrent` device mapping. --- .../Transforms/DoConcurrent/allocatable.f90 | 29 + .../Transforms/DoConcurrent/host_eval.f90 | 63 +++ .../DoConcurrent/locally_destroyed_temp.f90 | 43 --- .../DoConcurrent/map_shape_info.f90 | 104 + .../multiple_iteration_ranges.f90 | 106 +++--- .../DoConcurrent/non_reference_to_device.f90 | 34 ++ .../DoConcurrent/not_perfectly_nested.f90 | 66 +++ .../DoConcurrent/runtime_sized_array.f90 | 42 +++ .../DoConcurrent/skip_all_nested_loops.f90| 68 +++ 9 files changed, 478 insertions(+), 77 deletions(-) create mode 100644 flang/test/Transforms/DoConcurrent/allocatable.f90 create mode 100644 flang/test/Transforms/DoConcurrent/host_eval.f90 create mode 100644 flang/test/Transforms/DoConcurrent/map_shape_info.f90 create mode 100644 flang/test/Transforms/DoConcurrent/non_reference_to_device.f90 create mode 100644 flang/test/Transforms/DoConcurrent/runtime_sized_array.f90 create mode 100644 flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90 diff --git a/flang/test/Transforms/DoConcurrent/allocatable.f90 b/flang/test/Transforms/DoConcurrent/allocatable.f90 new file mode 100644 index 0..03962f150eb95 --- /dev/null +++ b/flang/test/Transforms/DoConcurrent/allocatable.f90 @@ -0,0 +1,29 @@ +! Verifies that proper `omp.map.bounds` ops are emitted when an allocatable is +! implicitly mapped by a `do concurrent` loop. + +! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=device %s -o - \ +! RUN: | FileCheck %s +program main + implicit none + + integer,parameter :: n = 100 + real, allocatable, dimension(:) :: y + integer :: i + + allocate(y(1:n)) + + do concurrent(i=1:n) + y(i) = 42 + end do + + deallocate(y) +end program main + +! CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEy"} +! CHECK: %[[Y_VAL:.*]] = fir.load %[[Y_DECL]]#0 +! CHECK: %[[Y_DIM0:.*]]:3 = fir.box_dims %[[Y_VAL]], %{{c0_.*}} +! CHECK: %[[Y_LB:.*]] = arith.constant 0 : index +! CHECK: %[[Y_UB:.*]] = arith.subi %[[Y_DIM0]]#1, %{{c1_.*}} : index +! CHECK: %[[Y_BOUNDS:.*]] = omp.map.bounds lower_bound(%[[Y_LB]] : index) upper_bound(%[[Y_UB]] : index) extent(%[[Y_DIM0]]#1 : index) +! CHECK: %[[MEM_MAP:.*]] = omp.map.info {{.*}} bounds(%[[Y_BOUNDS]]) +! CHECK: omp.map.info var_ptr(%[[Y_DECL]]#1 : {{.*}}) {{.*}} members(%[[MEM_MAP]] : {{.*}}) diff --git a/flang/test/Transforms/DoConcurrent/host_eval.f90 b/flang/test/Transforms/DoConcurrent/host_eval.f90 new file mode 100644 index 0..7d16a91ae6941 --- /dev/null +++ b/flang/test/Transforms/DoConcurrent/host_eval.f90 @@ -0,0 +1,63 @@ +! Tests `host_eval` clause code-gen and loop nest bounds on host vs. device. + +! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \ +! RUN: -fdo-concurrent-to-openmp=device %s -o - \ +! RUN: | FileCheck %s --check-prefix=HOST -vv + +! RUN: %flang_fc1 -triple amdgcn-amd-amdhsa -emit-hlfir -fopenmp\ +! RUN: -fopenmp-is-target-device -fdo-concurrent-to-openmp=device %s -o - \ +! RUN: | FileCheck %s --check-prefix=DEVICE + +program do_concurrent_host_eval +implicit none +integer :: i, j + +do concurrent (i=1:10, j=1:20) +end do +end program do_concurrent_host_eval + +! HOST: omp.target host_eval( +! HOST-SAME:%{{[^[:space:]]+}} -> %[[I_LB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[I_UB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[I_ST:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[J_LB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[J_UB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[J_ST:[^,]+]] : {{.*}}) map_entries + +! HOST: omp.loop_nest ({{.*}}, {{.*}}) : index = (%[[I_LB]], %[[J_LB]]) to +! HOST-SAME:(%[[I_UB]], %[[J_UB]]) inclusive step +! HOST-SAME:(%[[I_ST]], %[[J_ST]]) + +! DEVICE: omp.target map_entries( +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_LB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_UB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_ST_MAP:[^,]+]], + +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_LB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_UB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_ST_MAP:[^,]+]], + +! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}}, +! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}} : {{.*}}) + +! DEVICE: %[[I_LB_DECL:.*]]:2 = hlfir.declare %[[I_LB_MAP]] +! DEVICE: %[[I_LB:.*]] = fir.load %[[I_LB_DECL]]#1 : !fir.ref + +! DEVICE: %[[I_UB_DECL:.*]]:2 = hlfir.declare %[[I_UB_MAP]
[llvm-branch-commits] [llvm] [mlir] [flang][OpenMP] Support multi-block reduction combiner regions on the GPU (PR #156837)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/156837 >From 3c3f326ea3dd77c4b5a75f3928c9856ffadf599c Mon Sep 17 00:00:00 2001 From: ergawy Date: Thu, 4 Sep 2025 01:06:21 -0500 Subject: [PATCH] [flang][OpenMP] Support multi-block reduction combiner regions on the GPU Fixes a bug related to insertion points when inlining multi-block combiner reduction regions. The IP at the end of the inlined region was not used resulting in emitting BBs with multiple terminators. --- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 3 + .../omptarget-multi-block-reduction.mlir | 85 +++ 2 files changed, 88 insertions(+) create mode 100644 mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 3d5e487c8990f..fe00a2a5696dc 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -3506,6 +3506,8 @@ Expected OpenMPIRBuilder::createReductionFunction( return AfterIP.takeError(); if (!Builder.GetInsertBlock()) return ReductionFunc; + + Builder.SetInsertPoint(AfterIP->getBlock(), AfterIP->getPoint()); Builder.CreateStore(Reduced, LHSPtr); } } @@ -3750,6 +3752,7 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createReductionsGPU( RI.ReductionGen(Builder.saveIP(), RHSValue, LHSValue, Reduced); if (!AfterIP) return AfterIP.takeError(); + Builder.SetInsertPoint(AfterIP->getBlock(), AfterIP->getPoint()); Builder.CreateStore(Reduced, LHS, false); } } diff --git a/mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir b/mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir new file mode 100644 index 0..aaf06d2d0e0c2 --- /dev/null +++ b/mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir @@ -0,0 +1,85 @@ +// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s + +// Verifies that the IR builder can handle reductions with multi-block combiner +// regions on the GPU. + +module attributes {dlti.dl_spec = #dlti.dl_spec<"dlti.alloca_memory_space" = 5 : ui64, "dlti.global_memory_space" = 1 : ui64>, llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, omp.is_target_device = true} { + llvm.func @bar() {} + llvm.func @baz() {} + + omp.declare_reduction @add_reduction_byref_box_5xf32 : !llvm.ptr alloc { +%0 = llvm.mlir.constant(1 : i64) : i64 +%1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> : (i64) -> !llvm.ptr<5> +%2 = llvm.addrspacecast %1 : !llvm.ptr<5> to !llvm.ptr +omp.yield(%2 : !llvm.ptr) + } init { + ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): +omp.yield(%arg1 : !llvm.ptr) + } combiner { + ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): +llvm.call @bar() : () -> () +llvm.br ^bb3 + + ^bb3: // pred: ^bb1 +llvm.call @baz() : () -> () +omp.yield(%arg0 : !llvm.ptr) + } + llvm.func @foo_() { +%c1 = llvm.mlir.constant(1 : i64) : i64 +%10 = llvm.alloca %c1 x !llvm.array<5 x f32> {bindc_name = "x"} : (i64) -> !llvm.ptr<5> +%11 = llvm.addrspacecast %10 : !llvm.ptr<5> to !llvm.ptr +%74 = omp.map.info var_ptr(%11 : !llvm.ptr, !llvm.array<5 x f32>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "x"} +omp.target map_entries(%74 -> %arg0 : !llvm.ptr) { + %c1_2 = llvm.mlir.constant(1 : i32) : i32 + %c10 = llvm.mlir.constant(10 : i32) : i32 + omp.teams reduction(byref @add_reduction_byref_box_5xf32 %arg0 -> %arg2 : !llvm.ptr) { +omp.parallel { + omp.distribute { +omp.wsloop { + omp.loop_nest (%arg5) : i32 = (%c1_2) to (%c10) inclusive step (%c1_2) { +omp.yield + } +} {omp.composite} + } {omp.composite} + omp.terminator +} {omp.composite} +omp.terminator + } + omp.terminator +} +llvm.return + } +} + +// CHECK: call void @__kmpc_parallel_51({{.*}}, i32 1, i32 -1, i32 -1, +// CHECK-SAME: ptr @[[PAR_OUTLINED:.*]], ptr null, ptr %2, i64 1) + +// CHECK: define internal void @[[PAR_OUTLINED]]{{.*}} { +// CHECK: .omp.reduction.then: +// CHECK: br label %omp.reduction.nonatomic.body + +// CHECK: omp.reduction.nonatomic.body: +// CHECK: call void @bar() +// CHECK: br label %[[BODY_2ND_BB:.*]] + +// CHECK: [[BODY_2ND_BB]]: +// CHECK: call void @baz() +// CHECK: br label %[[CONT_BB:.*]] + +// CHECK: [[CONT_BB]]: +// CHECK: br label %.omp.reduction.done +// CHECK: } + +// CHECK: define internal void @"{{.*}}$reduction$reduction_func"(ptr noundef %0, ptr noundef %1) #0 { +// CHECK: br label %omp.reduction.nonatomic.body + +// CHECK: [[BODY_2ND_BB:.*]]: +// CHECK: call void @baz() +// CHECK: br label %omp.region.cont + + +// CHECK: omp.reduction.nonatomic.body: +// CHECK: call void @bar()
[llvm-branch-commits] [flang] [flang][OpenMP] `do concurrent`: support `reduce` on device (PR #156610)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/156610 >From 9a7ae05aac85c4573a27f48b361220f72c435ef3 Mon Sep 17 00:00:00 2001 From: ergawy Date: Tue, 2 Sep 2025 08:36:34 -0500 Subject: [PATCH] [flang][OpenMP] `do concurrent`: support `reduce` on device Extends `do concurrent` to OpenMP device mapping by adding support for mapping `reduce` specifiers to omp `reduction` clauses. The changes attach 2 `reduction` clauses to the mapped OpenMP construct: one on the `teams` part of the construct and one on the `wloop` part. --- .../OpenMP/DoConcurrentConversion.cpp | 117 ++ .../DoConcurrent/reduce_device.mlir | 53 2 files changed, 121 insertions(+), 49 deletions(-) create mode 100644 flang/test/Transforms/DoConcurrent/reduce_device.mlir diff --git a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp index 1add508ec153b..442a838340104 100644 --- a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp +++ b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp @@ -140,6 +140,9 @@ void collectLoopLiveIns(fir::DoConcurrentLoopOp loop, for (mlir::Value local : loop.getLocalVars()) liveIns.push_back(local); + + for (mlir::Value reduce : loop.getReduceVars()) +liveIns.push_back(reduce); } /// Collects values that are local to a loop: "loop-local values". A loop-local @@ -272,7 +275,7 @@ class DoConcurrentConversion targetOp = genTargetOp(doLoop.getLoc(), rewriter, mapper, loopNestLiveIns, targetClauseOps, loopNestClauseOps, liveInShapeInfoMap); - genTeamsOp(doLoop.getLoc(), rewriter); + genTeamsOp(rewriter, loop, mapper); } mlir::omp::ParallelOp parallelOp = @@ -488,46 +491,7 @@ class DoConcurrentConversion if (!mapToDevice) genPrivatizers(rewriter, mapper, loop, wsloopClauseOps); -if (!loop.getReduceVars().empty()) { - for (auto [op, byRef, sym, arg] : llvm::zip_equal( - loop.getReduceVars(), loop.getReduceByrefAttr().asArrayRef(), - loop.getReduceSymsAttr().getAsRange(), - loop.getRegionReduceArgs())) { -auto firReducer = moduleSymbolTable.lookup( -sym.getLeafReference()); - -mlir::OpBuilder::InsertionGuard guard(rewriter); -rewriter.setInsertionPointAfter(firReducer); -std::string ompReducerName = sym.getLeafReference().str() + ".omp"; - -auto ompReducer = -moduleSymbolTable.lookup( -rewriter.getStringAttr(ompReducerName)); - -if (!ompReducer) { - ompReducer = mlir::omp::DeclareReductionOp::create( - rewriter, firReducer.getLoc(), ompReducerName, - firReducer.getTypeAttr().getValue()); - - cloneFIRRegionToOMP(rewriter, firReducer.getAllocRegion(), - ompReducer.getAllocRegion()); - cloneFIRRegionToOMP(rewriter, firReducer.getInitializerRegion(), - ompReducer.getInitializerRegion()); - cloneFIRRegionToOMP(rewriter, firReducer.getReductionRegion(), - ompReducer.getReductionRegion()); - cloneFIRRegionToOMP(rewriter, firReducer.getAtomicReductionRegion(), - ompReducer.getAtomicReductionRegion()); - cloneFIRRegionToOMP(rewriter, firReducer.getCleanupRegion(), - ompReducer.getCleanupRegion()); - moduleSymbolTable.insert(ompReducer); -} - -wsloopClauseOps.reductionVars.push_back(op); -wsloopClauseOps.reductionByref.push_back(byRef); -wsloopClauseOps.reductionSyms.push_back( -mlir::SymbolRefAttr::get(ompReducer)); - } -} +genReductions(rewriter, mapper, loop, wsloopClauseOps); auto wsloopOp = mlir::omp::WsloopOp::create(rewriter, loop.getLoc(), wsloopClauseOps); @@ -549,8 +513,6 @@ class DoConcurrentConversion rewriter.setInsertionPointToEnd(&loopNestOp.getRegion().back()); mlir::omp::YieldOp::create(rewriter, loop->getLoc()); -loop->getParentOfType().print( -llvm::errs(), mlir::OpPrintingFlags().assumeVerified()); return {loopNestOp, wsloopOp}; } @@ -771,15 +733,26 @@ class DoConcurrentConversion liveInName, shape); } - mlir::omp::TeamsOp - genTeamsOp(mlir::Location loc, - mlir::ConversionPatternRewriter &rewriter) const { -auto teamsOp = rewriter.create( -loc, /*clauses=*/mlir::omp::TeamsOperands{}); + mlir::omp::TeamsOp genTeamsOp(mlir::ConversionPatternRewriter &rewriter, +fir::DoConcurrentLoopOp loop, +mlir::IRMapping &mapper) const { +mlir::omp::TeamsOperands teamsOps; +genReductions(rewriter, mapper, loop, teamsOps); + +mlir::Location loc = loop.getLoc(); +aut
[llvm-branch-commits] [llvm] [flang][do concurent] Add saxpy offload tests for OpenMP mapping (PR #155993)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/155993 >From 315f52184fce3a107917f684f6929bd56004142b Mon Sep 17 00:00:00 2001 From: ergawy Date: Fri, 29 Aug 2025 04:04:07 -0500 Subject: [PATCH] [flang][do concurent] Add saxpy offload tests for OpenMP mapping Adds end-to-end tests for `do concurrent` offloading to the device. --- .../fortran/do-concurrent-to-omp-saxpy-2d.f90 | 53 +++ .../fortran/do-concurrent-to-omp-saxpy.f90| 53 +++ 2 files changed, 106 insertions(+) create mode 100644 offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 create mode 100644 offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 diff --git a/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 new file mode 100644 index 0..c6f576acb90b6 --- /dev/null +++ b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy-2d.f90 @@ -0,0 +1,53 @@ +! REQUIRES: flang, amdgpu + +! RUN: %libomptarget-compile-fortran-generic -fdo-concurrent-to-openmp=device +! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic +module saxpymod + use iso_fortran_env + public :: saxpy +contains + +subroutine saxpy(a, x, y, n, m) + use iso_fortran_env + implicit none + integer,intent(in) :: n, m + real(kind=real32),intent(in) :: a + real(kind=real32), dimension(:,:),intent(in) :: x + real(kind=real32), dimension(:,:),intent(inout) :: y + integer :: i, j + + do concurrent(i=1:n, j=1:m) + y(i,j) = a * x(i,j) + y(i,j) + end do + + write(*,*) "plausibility check:" + write(*,'("y(1,1) ",f8.6)') y(1,1) + write(*,'("y(n,m) ",f8.6)') y(n,m) +end subroutine saxpy + +end module saxpymod + +program main + use iso_fortran_env + use saxpymod, ONLY:saxpy + implicit none + + integer,parameter :: n = 1000, m=1 + real(kind=real32), allocatable, dimension(:,:) :: x, y + real(kind=real32) :: a + integer :: i + + allocate(x(1:n,1:m), y(1:n,1:m)) + a = 2.0_real32 + x(:,:) = 1.0_real32 + y(:,:) = 2.0_real32 + + call saxpy(a, x, y, n, m) + + deallocate(x,y) +end program main + +! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}} +! CHECK: plausibility check: +! CHECK: y(1,1) 4.0 +! CHECK: y(n,m) 4.0 diff --git a/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 new file mode 100644 index 0..e094a1d7459ef --- /dev/null +++ b/offload/test/offloading/fortran/do-concurrent-to-omp-saxpy.f90 @@ -0,0 +1,53 @@ +! REQUIRES: flang, amdgpu + +! RUN: %libomptarget-compile-fortran-generic -fdo-concurrent-to-openmp=device +! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic +module saxpymod + use iso_fortran_env + public :: saxpy +contains + +subroutine saxpy(a, x, y, n) + use iso_fortran_env + implicit none + integer,intent(in) :: n + real(kind=real32),intent(in) :: a + real(kind=real32), dimension(:),intent(in) :: x + real(kind=real32), dimension(:),intent(inout) :: y + integer :: i + + do concurrent(i=1:n) + y(i) = a * x(i) + y(i) + end do + + write(*,*) "plausibility check:" + write(*,'("y(1) ",f8.6)') y(1) + write(*,'("y(n) ",f8.6)') y(n) +end subroutine saxpy + +end module saxpymod + +program main + use iso_fortran_env + use saxpymod, ONLY:saxpy + implicit none + + integer,parameter :: n = 1000 + real(kind=real32), allocatable, dimension(:) :: x, y + real(kind=real32) :: a + integer :: i + + allocate(x(1:n), y(1:n)) + a = 2.0_real32 + x(:) = 1.0_real32 + y(:) = 2.0_real32 + + call saxpy(a, x, y, n) + + deallocate(x,y) +end program main + +! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}} +! CHECK: plausibility check: +! CHECK: y(1) 4.0 +! CHECK: y(n) 4.0 ___ 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] [clang-tools-extra] [compiler-rt] [libcxx] [libcxxabi] [libunwind] [lldb] [llvm] [mlir] [openmp] release/21.x: [CMake][AIX] quote the string AIX `if` conditions (PR #1565
https://github.com/hubert-reinterpretcast approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/156505 ___ 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] [MC] Rewrite stdin.s to use python (PR #157232)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157232 >From d749f30964e57caa797b3df87ae88ffc3d4a2f54 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sun, 7 Sep 2025 17:39:19 + Subject: [PATCH 1/3] feedback Created using spr 1.3.6 --- llvm/test/MC/COFF/stdin.py | 17 + llvm/test/MC/COFF/stdin.s | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 llvm/test/MC/COFF/stdin.py delete mode 100644 llvm/test/MC/COFF/stdin.s diff --git a/llvm/test/MC/COFF/stdin.py b/llvm/test/MC/COFF/stdin.py new file mode 100644 index 0..8b7b6ae1fba13 --- /dev/null +++ b/llvm/test/MC/COFF/stdin.py @@ -0,0 +1,17 @@ +# RUN: echo "// comment" > %t.input +# RUN: which llvm-mc | %python %s %t + +import subprocess +import sys + +llvm_mc_binary = sys.stdin.readlines()[0].strip() +temp_file = sys.argv[1] +input_file = temp_file + ".input" + +with open(temp_file, "w") as mc_stdout: +mc_stdout.seek(4) +subprocess.run( +[llvm_mc_binary, "-filetype=obj", "-triple", "i686-pc-win32", input_file], +stdout=mc_stdout, +check=True, +) diff --git a/llvm/test/MC/COFF/stdin.s b/llvm/test/MC/COFF/stdin.s deleted file mode 100644 index 8ceae7fdef501..0 --- a/llvm/test/MC/COFF/stdin.s +++ /dev/null @@ -1 +0,0 @@ -// RUN: bash -c '(echo "test"; llvm-mc -filetype=obj -triple i686-pc-win32 %s ) > %t' >From 0bfe954d4cd5edf4312e924c278c59e57644d5f1 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Mon, 8 Sep 2025 17:28:59 + Subject: [PATCH 2/3] feedback Created using spr 1.3.6 --- llvm/test/MC/COFF/stdin.py | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/test/MC/COFF/stdin.py b/llvm/test/MC/COFF/stdin.py index 8b7b6ae1fba13..1d9b50c022523 100644 --- a/llvm/test/MC/COFF/stdin.py +++ b/llvm/test/MC/COFF/stdin.py @@ -1,14 +1,22 @@ # RUN: echo "// comment" > %t.input # RUN: which llvm-mc | %python %s %t +import argparse import subprocess import sys +parser = argparse.ArgumentParser() +parser.add_argument("temp_file") +arguments = parser.parse_args() + llvm_mc_binary = sys.stdin.readlines()[0].strip() -temp_file = sys.argv[1] +temp_file = arguments.temp_file input_file = temp_file + ".input" with open(temp_file, "w") as mc_stdout: +## We need to test that starting on an input stream with a non-zero offset +## does not trigger an assertion in WinCOFFObjectWriter.cpp, so we seek +## past zero for STDOUT. mc_stdout.seek(4) subprocess.run( [llvm_mc_binary, "-filetype=obj", "-triple", "i686-pc-win32", input_file], >From 2ae17e4f18a95c52b53ad5ad45a19c4bf29e5025 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Mon, 8 Sep 2025 17:43:39 + Subject: [PATCH 3/3] feedback Created using spr 1.3.6 --- llvm/test/MC/COFF/stdin.py | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/llvm/test/MC/COFF/stdin.py b/llvm/test/MC/COFF/stdin.py index 1d9b50c022523..0da1b4895142b 100644 --- a/llvm/test/MC/COFF/stdin.py +++ b/llvm/test/MC/COFF/stdin.py @@ -1,25 +1,30 @@ # RUN: echo "// comment" > %t.input -# RUN: which llvm-mc | %python %s %t +# RUN: which llvm-mc | %python %s %t.input %t import argparse import subprocess import sys parser = argparse.ArgumentParser() +parser.add_argument("input_file") parser.add_argument("temp_file") arguments = parser.parse_args() llvm_mc_binary = sys.stdin.readlines()[0].strip() -temp_file = arguments.temp_file -input_file = temp_file + ".input" -with open(temp_file, "w") as mc_stdout: +with open(arguments.temp_file, "w") as mc_stdout: ## We need to test that starting on an input stream with a non-zero offset ## does not trigger an assertion in WinCOFFObjectWriter.cpp, so we seek ## past zero for STDOUT. mc_stdout.seek(4) subprocess.run( -[llvm_mc_binary, "-filetype=obj", "-triple", "i686-pc-win32", input_file], +[ +llvm_mc_binary, +"-filetype=obj", +"-triple", +"i686-pc-win32", +arguments.input_file, +], stdout=mc_stdout, check=True, ) ___ 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] [CGData] Rewrite tests to not use subshells (PR #157234)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157234 ___ 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] Use lit internal shell by default (PR #157237)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157237 ___ 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] [MC] Rewrite stdin.s to use python (PR #157232)
@@ -0,0 +1,25 @@ +# RUN: echo "// comment" > %t.input +# RUN: which llvm-mc | %python %s %t boomanaiden154 wrote: Done. https://github.com/llvm/llvm-project/pull/157232 ___ 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] [not] Update disable-symbolization.test to work with internal shell (PR #157236)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157236 ___ 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] [CGData] Rewrite tests to not use subshells (PR #157234)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157234 ___ 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] [not] Update disable-symbolization.test to work with internal shell (PR #157236)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157236 ___ 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] [MC] Rewrite stdin.s to use python (PR #157232)
https://github.com/ilovepi edited https://github.com/llvm/llvm-project/pull/157232 ___ 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] [MC] Rewrite stdin.s to use python (PR #157232)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/157232 ___ 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] release/21.x: [RISCV] Cost casts with illegal types that can't be legalized (#153030) (PR #153118)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/153118 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [lldb] release/21.x: [libc++] Ensure that we restore invariants in basic_filebuf::overflow (#147389) (PR #155712)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/155712 >From b7c18c1e7ac029cd8305bcdb1745bb25a931c209 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 15 Jul 2025 10:40:54 -0400 Subject: [PATCH 1/3] [libc++] Ensure that we restore invariants in basic_filebuf::overflow (#147389) In rare circumstances, the invariants could fail to be restored. (cherry picked from commit 6291b63a9a104fe93f8e4e279ef2237dc081304f) --- libcxx/include/fstream| 35 ++--- .../overflow.writefail.pass.cpp | 72 +++ 2 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp diff --git a/libcxx/include/fstream b/libcxx/include/fstream index c86f709bedb80..dc5c47304f014 100644 --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -821,6 +821,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> template typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::overflow(int_type __c) { + auto __failed = [this]() { +if (this->pptr() == this->epptr() + 1) { + this->pbump(-1); // lose the character we overflowed above -- we don't really have a + // choice since we couldn't commit the contents of the put area +} +return traits_type::eof(); + }; + if (__file_ == nullptr) return traits_type::eof(); __write_mode(); @@ -841,8 +849,9 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> if (__always_noconv_) { size_t __n = static_cast(this->pptr() - this->pbase()); -if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) { + return __failed(); +} } else { if (!__cv_) std::__throw_bad_cast(); @@ -854,34 +863,38 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> char* __extbuf_end = __extbuf_; do { codecvt_base::result __r = __cv_->out(__st_, __b, __p, __end, __extbuf_, __extbuf_ + __ebs_, __extbuf_end); - if (__end == __b) -return traits_type::eof(); + if (__end == __b) { +return __failed(); + } // No conversion needed: output characters directly to the file, done. if (__r == codecvt_base::noconv) { size_t __n = static_cast(__p - __b); -if (std::fwrite(__b, 1, __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(__b, 1, __n, __file_) != __n) { + return __failed(); +} break; // Conversion successful: output the converted characters to the file, done. } else if (__r == codecvt_base::ok) { size_t __n = static_cast(__extbuf_end - __extbuf_); -if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { + return __failed(); +} break; // Conversion partially successful: output converted characters to the file and repeat with the // remaining characters. } else if (__r == codecvt_base::partial) { size_t __n = static_cast(__extbuf_end - __extbuf_); -if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { + return __failed(); +} __b = const_cast(__end); continue; } else { -return traits_type::eof(); +return __failed(); } } while (true); } diff --git a/libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp new file mode 100644 index 0..27e06982d749b --- /dev/null +++ b/libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp @@ -0,0 +1,72 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: no-filesystem + +// setrlimit(RLIMIT_FSIZE) seems to only work as intended on Apple platforms +// REQUIRES: target={{.+}}-apple-{{.+}} + +// + +// Make sure that we properly handle the case where we try to write content to a file +// but we fail to do so because std::fwrite fails. + +#include +#include +#include +#include +#include + +#include "platform_support.h" +#include "test_mac
[llvm-branch-commits] [compiler-rt] release/21.x: [compiler-rt] Avoid depending on the libnvmm header for NetBSD (#153534) (PR #155717)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/155717 >From f8a0ecfc6108fc51f2ff518307b5e005e85b0e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 24 Aug 2025 20:39:34 +0200 Subject: [PATCH] [compiler-rt] Avoid depending on the libnvmm header for NetBSD (#153534) Use the system headers instead since we don't actually need anything from libnvmm; we only care about ioctls and related structures. This makes it possible to cross-compile TSan for NetBSD with `zig cc` which does not provide libnvmm when cross-compiling. I also removed a `term.h` include (ncurses) which appeared to be unnecessary and likewise prevented cross-compilation with `zig cc` from working. (cherry picked from commit 9ec771bd4a16198cec04b4b9c30c22ee89140a2d) --- .../lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp index aacd28c55ceaa..435f3b2861dc9 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp @@ -498,7 +498,6 @@ struct urio_command { #include #include #include -#include #include #include #include @@ -515,7 +514,7 @@ struct urio_command { #include #if defined(__x86_64__) -#include +#include #endif // clang-format on ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] 362b99f - [libcxx][fstream][NFC] Make __failed helper lambda a member function (#149390)
Author: Michael Buch Date: 2025-09-08T09:33:25+02:00 New Revision: 362b99f60ef555b00287c78146fac87c9d9a28a6 URL: https://github.com/llvm/llvm-project/commit/362b99f60ef555b00287c78146fac87c9d9a28a6 DIFF: https://github.com/llvm/llvm-project/commit/362b99f60ef555b00287c78146fac87c9d9a28a6.diff LOG: [libcxx][fstream][NFC] Make __failed helper lambda a member function (#149390) This patch makes the `__failed` lambda a member function on `fstream`. This fixes two LLDB expression evaluation test failures that got introduced with https://github.com/llvm/llvm-project/pull/147389: ``` 16:22:51 16:22:51 Unresolved Tests (2): 16:22:51lldb-api :: commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py 16:22:51lldb-api :: commands/expression/import-std-module/list/TestListFromStdModule.py ``` The expression evaluator is asserting in the Clang parser: ``` Assertion failed: (capture_size() == Class->capture_size() && "Wrong number of captures"), function LambdaExpr, file ExprCXX.cpp, line 1277. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. ``` Ideally we'd figure out why LLDB is falling over on this lambda. But to unblock CI for now, make this a member function. In the long run we should figure out the LLDB bug here so libc++ doesn't need to care about whether it uses lambdas like this or not. (cherry picked from commit 8f4deff5d51ac190e056a6738018fc8aa3114151) Added: Modified: libcxx/include/fstream Removed: diff --git a/libcxx/include/fstream b/libcxx/include/fstream index dc5c47304f014..6d3f20fff688f 100644 --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -401,6 +401,14 @@ private: } } } + + _LIBCPP_HIDE_FROM_ABI typename traits_type::int_type __overflow_failed() { +if (this->pptr() == this->epptr() + 1) { + this->pbump(-1); // lose the character we overflowed above -- we don't really have a + // choice since we couldn't commit the contents of the put area +} +return traits_type::eof(); + } }; template @@ -821,14 +829,6 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> template typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::overflow(int_type __c) { - auto __failed = [this]() { -if (this->pptr() == this->epptr() + 1) { - this->pbump(-1); // lose the character we overflowed above -- we don't really have a - // choice since we couldn't commit the contents of the put area -} -return traits_type::eof(); - }; - if (__file_ == nullptr) return traits_type::eof(); __write_mode(); @@ -850,7 +850,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> if (__always_noconv_) { size_t __n = static_cast(this->pptr() - this->pbase()); if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) { - return __failed(); + return __overflow_failed(); } } else { if (!__cv_) @@ -864,14 +864,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> do { codecvt_base::result __r = __cv_->out(__st_, __b, __p, __end, __extbuf_, __extbuf_ + __ebs_, __extbuf_end); if (__end == __b) { -return __failed(); +return __overflow_failed(); } // No conversion needed: output characters directly to the file, done. if (__r == codecvt_base::noconv) { size_t __n = static_cast(__p - __b); if (std::fwrite(__b, 1, __n, __file_) != __n) { - return __failed(); + return __overflow_failed(); } break; @@ -879,7 +879,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> } else if (__r == codecvt_base::ok) { size_t __n = static_cast(__extbuf_end - __extbuf_); if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { - return __failed(); + return __overflow_failed(); } break; @@ -888,13 +888,13 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> } else if (__r == codecvt_base::partial) { size_t __n = static_cast(__extbuf_end - __extbuf_); if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { - return __failed(); + return __overflow_failed(); } __b = const_cast(__end); continue; } else { -return __failed(); +return __overflow_failed(); } } while (true); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] b7c18c1 - [libc++] Ensure that we restore invariants in basic_filebuf::overflow (#147389)
Author: Louis Dionne Date: 2025-09-08T09:33:25+02:00 New Revision: b7c18c1e7ac029cd8305bcdb1745bb25a931c209 URL: https://github.com/llvm/llvm-project/commit/b7c18c1e7ac029cd8305bcdb1745bb25a931c209 DIFF: https://github.com/llvm/llvm-project/commit/b7c18c1e7ac029cd8305bcdb1745bb25a931c209.diff LOG: [libc++] Ensure that we restore invariants in basic_filebuf::overflow (#147389) In rare circumstances, the invariants could fail to be restored. (cherry picked from commit 6291b63a9a104fe93f8e4e279ef2237dc081304f) Added: libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp Modified: libcxx/include/fstream Removed: diff --git a/libcxx/include/fstream b/libcxx/include/fstream index c86f709bedb80..dc5c47304f014 100644 --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -821,6 +821,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> template typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::overflow(int_type __c) { + auto __failed = [this]() { +if (this->pptr() == this->epptr() + 1) { + this->pbump(-1); // lose the character we overflowed above -- we don't really have a + // choice since we couldn't commit the contents of the put area +} +return traits_type::eof(); + }; + if (__file_ == nullptr) return traits_type::eof(); __write_mode(); @@ -841,8 +849,9 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> if (__always_noconv_) { size_t __n = static_cast(this->pptr() - this->pbase()); -if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) { + return __failed(); +} } else { if (!__cv_) std::__throw_bad_cast(); @@ -854,34 +863,38 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> char* __extbuf_end = __extbuf_; do { codecvt_base::result __r = __cv_->out(__st_, __b, __p, __end, __extbuf_, __extbuf_ + __ebs_, __extbuf_end); - if (__end == __b) -return traits_type::eof(); + if (__end == __b) { +return __failed(); + } // No conversion needed: output characters directly to the file, done. if (__r == codecvt_base::noconv) { size_t __n = static_cast(__p - __b); -if (std::fwrite(__b, 1, __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(__b, 1, __n, __file_) != __n) { + return __failed(); +} break; // Conversion successful: output the converted characters to the file, done. } else if (__r == codecvt_base::ok) { size_t __n = static_cast(__extbuf_end - __extbuf_); -if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { + return __failed(); +} break; // Conversion partially successful: output converted characters to the file and repeat with the // remaining characters. } else if (__r == codecvt_base::partial) { size_t __n = static_cast(__extbuf_end - __extbuf_); -if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) - return traits_type::eof(); +if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { + return __failed(); +} __b = const_cast(__end); continue; } else { -return traits_type::eof(); +return __failed(); } } while (true); } diff --git a/libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp new file mode 100644 index 0..27e06982d749b --- /dev/null +++ b/libcxx/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.writefail.pass.cpp @@ -0,0 +1,72 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// UNSUPPORTED: no-filesystem + +// setrlimit(RLIMIT_FSIZE) seems to only work as intended on Apple platforms +// REQUIRES: target={{.+}}-apple-{{.+}} + +// + +// Make sure that we properly handle the case where we try to write content to a file +// but we fail to do so because std::fwrite fails. + +#include +#include +#include +#include +#include + +#include "platform_support.h" +#inc
[llvm-branch-commits] [libcxx] [lldb] release/21.x: [libc++] Ensure that we restore invariants in basic_filebuf::overflow (#147389) (PR #155712)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/155712 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] release/21.x: [compiler-rt] Avoid depending on the libnvmm header for NetBSD (#153534) (PR #155717)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/155717 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] f8a0ecf - [compiler-rt] Avoid depending on the libnvmm header for NetBSD (#153534)
Author: Alex Rønne Petersen Date: 2025-09-08T09:34:13+02:00 New Revision: f8a0ecfc6108fc51f2ff518307b5e005e85b0e7f URL: https://github.com/llvm/llvm-project/commit/f8a0ecfc6108fc51f2ff518307b5e005e85b0e7f DIFF: https://github.com/llvm/llvm-project/commit/f8a0ecfc6108fc51f2ff518307b5e005e85b0e7f.diff LOG: [compiler-rt] Avoid depending on the libnvmm header for NetBSD (#153534) Use the system headers instead since we don't actually need anything from libnvmm; we only care about ioctls and related structures. This makes it possible to cross-compile TSan for NetBSD with `zig cc` which does not provide libnvmm when cross-compiling. I also removed a `term.h` include (ncurses) which appeared to be unnecessary and likewise prevented cross-compilation with `zig cc` from working. (cherry picked from commit 9ec771bd4a16198cec04b4b9c30c22ee89140a2d) Added: Modified: compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp Removed: diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp index aacd28c55ceaa..435f3b2861dc9 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp @@ -498,7 +498,6 @@ struct urio_command { #include #include #include -#include #include #include #include @@ -515,7 +514,7 @@ struct urio_command { #include #if defined(__x86_64__) -#include +#include #endif // clang-format on ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [lldb] release/21.x: [libc++] Ensure that we restore invariants in basic_filebuf::overflow (#147389) (PR #155712)
github-actions[bot] wrote: @var-const (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/155712 ___ 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] release/21.x: [clang][docs] Fix implicit-int-conversion-on-negation typos (PR #156815)
github-actions[bot] wrote: @correctmost Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/156815 ___ 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] [lldb] release/21.x: [lldb][DWARFASTParserClang] Don't complete conflicting Objective-C++ types (#156681) (PR #156764)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/156764 >From e0d94d9626e4e942b608cd39cadf367cbe2b0c96 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 3 Sep 2025 20:04:53 +0100 Subject: [PATCH] [lldb][DWARFASTParserClang] Don't complete conflicting Objective-C++ types (#156681) This upstreams https://github.com/swiftlang/llvm-project/pull/10313. If we detect a situation where a forward declaration is C++ and the definition DIE is Objective-C, then just don't try to complete the type (it would crash otherwise). In the long term we might want to add support for completing such types. We've seen real world crashes when debugging WebKit and wxWidgets because of this. Both projects forward declare ObjC++ decls in the way shown in the test. rdar://145959981 (cherry picked from commit a862225813c251c28b085603b7d32d4b111dbc57) --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 12 .../DWARF/objcxx-forward-decls.test | 70 +++ 2 files changed, 82 insertions(+) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index c76d67b47b336..8916c58beec0f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2201,6 +2201,18 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, for (DelayedAddObjCClassProperty &property : delayed_properties) property.Finalize(); } + } else if (Language::LanguageIsObjC( + static_cast(die.GetAttributeValueAsUnsigned( + DW_AT_APPLE_runtime_class, eLanguageTypeUnknown { +/// The forward declaration was C++ but the definition is Objective-C. +/// We currently don't handle such situations. In such cases, keep the +/// forward declaration without a definition to avoid violating Clang AST +/// invariants. +LLDB_LOG(GetLog(LLDBLog::Expressions), + "WARNING: Type completion aborted because forward declaration for " + "'{0}' is C++ while definition is Objective-C.", + llvm::StringRef(die.GetName())); +return {}; } if (!bases.empty()) { diff --git a/lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test b/lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test new file mode 100644 index 0..30109c2943c9b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test @@ -0,0 +1,70 @@ +# REQUIRES: system-darwin + +# In this test we have two CUs with conflicting forward declaration +# depending on the CU language (one is C++ and the other is Objective-C++). +# We are then stopped in the C++ CU and try to print the type, at which +# point LLDB will try to make it into an Clang AST node. If LLDB were to +# interpret the type as C++ instead of Objective-C, we'd violate Clang +# invariants and crash. +# +# RUN: split-file %s %t +# RUN: %clangxx_host -c -g -x objective-c++ %t/request.m -o %t/request_objc.o +# RUN: %clangxx_host -c -g %t/main.cpp -o %t/main.o +# RUN: %clangxx_host %t/main.o %t/request_objc.o -framework Foundation -o %t/a.out +# +# RUN: %lldb %t/a.out \ +# RUN:-o "breakpoint set -p return -X main" \ +# RUN:-o run \ +# RUN:-o "frame variable r" \ +# RUN:-o exit | FileCheck %s +# +# RUN: dsymutil %t/a.out +# +# RUN: %lldb %t/a.out \ +# RUN:-o "breakpoint set -p return -X main" \ +# RUN:-o run \ +# RUN:-o "frame variable r" \ +# RUN:-o exit | FileCheck %s --check-prefix=CHECK-DSYM + +# CHECK: (lldb) frame variable r +# CHECK-NEXT: (Request) ::r = (m_request = "Hello, World!") + +# CHECK-DSYM: (lldb) frame variable r +# CHECK-DSYM-NEXT: (Request) ::r = (m_request = "Hello, World!") + +#--- lib.h +#ifndef LIB_H_IN +#define LIB_H_IN + +#ifdef __OBJC__ +@class NSString; +#else +class NSString; +#endif + +struct Request { + NSString * m_request = nullptr; +}; + +#endif // _H_IN + +#--- main.cpp +#include "lib.h" + +void process(Request *); + +Request r; + +int main() { +process(&r); +return 0; +} + +#--- request.m +#import + +#include "lib.h" + +void process(Request * r) { + r->m_request = @"Hello, World!"; +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] release/21.x: [compiler-rt] Remove leftovers of FreeBSD md5/sha2 interceptors (#153351) (PR #155718)
alexrp wrote: Basically same deal as #155717, i.e. it's a build-time dependency on non-libc headers (libncurses and libcrypt). https://github.com/llvm/llvm-project/pull/155718 ___ 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] release/21.x: [DebugInfo] When referencing structured bindings use the reference's location, not the binding's declaration's location (#153637) (PR #156664)
github-actions[bot] wrote: @Michael137 (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/156664 ___ 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] [lldb] release/21.x: [lldb][DataFormatter] Allow std::string formatters to match against custom allocators (#156050) (PR #157048)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/157048 ___ 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] release/21.x: [Coroutines] Restore accidentally dropped intrinsic IDs (PR #156925)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/156925 >From 12fbb344a1e84aed4a34d3d00a387f15cebc82e1 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 24 Jul 2025 14:36:02 +0200 Subject: [PATCH] [Coroutines] Restore accidentally dropped intrinsic IDs These were unintentionally dropped in #145518. These intrinsics are not overloaded, so should be part of this list. (cherry picked from commit a647bb4a7ba23b5a7c7484fd5162fef2d10c7068) --- llvm/lib/Transforms/Coroutines/Coroutines.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp index 59ae057cae793..ac93f748ce65c 100644 --- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp +++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp @@ -85,6 +85,9 @@ static Intrinsic::ID NonOverloadedCoroIntrinsics[] = { Intrinsic::coro_id_async, Intrinsic::coro_id_retcon, Intrinsic::coro_id_retcon_once, +Intrinsic::coro_noop, +Intrinsic::coro_prepare_async, +Intrinsic::coro_prepare_retcon, Intrinsic::coro_promise, Intrinsic::coro_resume, Intrinsic::coro_save, ___ 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] Sparc: Remove Is64Bit field from SparcTargetMachine (PR #157400)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/157400 ___ 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] release/21.x: [AArch64][BTI] Add BTI at EH entries. (#155308) (PR #156170)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/156170 ___ 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] [lldb] release/21.x: [lldb][DataFormatter] Allow std::string formatters to match against custom allocators (#156050) (PR #157048)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/157048 >From fa462a66e418b08b486b56dc943ade47ab1c9ea3 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 5 Sep 2025 09:24:50 +0100 Subject: [PATCH] [lldb][DataFormatter] Allow std::string formatters to match against custom allocators (#156050) This came up in https://github.com/llvm/llvm-project/issues/155691. For `std::basic_string` our formatter matching logic required the allocator template parameter to be a `std::allocator`. There is no compelling reason (that I know of) why this would be required for us to apply the existing formatter to the string. We don't check the `allocator` parameter for other STL containers either. This meant that `std::string` that used custom allocators wouldn't be formatted. This patch relaxes the regex for `basic_string`. (cherry picked from commit 4b362f152e58abd6aeed5d603a6dfc10115ed1ab) --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 50 +++ .../string/TestDataFormatterStdString.py | 6 +++ .../generic/string/main.cpp | 35 + 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 9a869f3ea0289..862082f8a16ba 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -790,31 +790,27 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { lldb_private::formatters::LibcxxStringSummaryProviderASCII, "std::string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxStringSummaryProviderASCII, "std::string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxStringSummaryProviderUTF16, "std::u16string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxStringSummaryProviderUTF32, "std::u32string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, @@ -825,8 +821,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { lldb_private::formatters::LibcxxWStringSummaryProvider, "std::wstring summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, @@ -1342,24 +1337,16 @@ static void RegisterStdStringSummaryProvider( category_sp->AddTypeSummary(makeSpecifier(string_ty), summary_sp); - // std::basic_string category_sp->AddTypeSummary( makeSpecifier(llvm::formatv("std::basic_string<{}>", char_ty).str()), summary_sp); - // std::basic_string,std::allocator > - category_sp->AddTypeSummary( - makeSpecifier(llvm::formatv("std::basic_string<{0},std::char_traits<{0}>," - "std::allocator<{0}> >", - char_ty) -.str()), - summary_sp); - // std::basic_string, std::allocator > + category_sp->AddTypeSummary( - makeSpecifier( - llvm::formatv("std::basic_string<{0}, std::char_traits<{0}>, " -"std::allocator<{0}> >", + std::make_shared( + llvm::formatv("^std::basic_string<{0}, ?std::char_traits<{0}>,.*>$", char_ty) - .str()), + .str(), + eFormatterMatchRegex), summary_sp); } @@ -1382,20 +1369,17 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { cpp_category_sp->AddTypeSummary("std::__cxx11::string", eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary( - "std::__cxx11::basic_string, " - "std::allocator >", - eFormatterMatchExact, str
[llvm-branch-commits] [lldb] release/21.x: [lldb][DWARFASTParserClang] Don't complete conflicting Objective-C++ types (#156681) (PR #156764)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/156764 ___ 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] release/21.x: [AArch64][BTI] Add BTI at EH entries. (#155308) (PR #156170)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/156170 >From 3751e53c3e89af153b8ac17120e3c427dd6b564c Mon Sep 17 00:00:00 2001 From: Shashi Shankar Date: Sat, 30 Aug 2025 11:56:03 +0200 Subject: [PATCH 1/2] [AArch64][BTI] Add BTI at EH entries. (#155308) Mark EH landing pads as indirect-branch targets (BTI j) and treat WinEH funclet entries as call-like (BTI c). Add lit tests for ELF and COFF. Tests: Adds lit tests: bti-ehpad.ll and wineh-bti-funclet.ll. Fixes: #149267 Signed-off-by: Shashi Shankar (cherry picked from commit 1b37b9e6d788d7058381b68b5ab265bcb6181335) --- .../Target/AArch64/AArch64BranchTargets.cpp | 46 --- llvm/test/CodeGen/AArch64/bti-ehpad.ll| 44 +++ .../AArch64/sign-return-address-pauth-lr.ll | 16 ++-- .../test/CodeGen/AArch64/wineh-bti-funclet.ll | 79 +++ llvm/test/CodeGen/AArch64/wineh-bti.ll| 2 +- 5 files changed, 167 insertions(+), 20 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/bti-ehpad.ll create mode 100644 llvm/test/CodeGen/AArch64/wineh-bti-funclet.ll diff --git a/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp b/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp index 3436dc9ef4521..137ff898e86a3 100644 --- a/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp +++ b/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp @@ -30,6 +30,14 @@ using namespace llvm; #define AARCH64_BRANCH_TARGETS_NAME "AArch64 Branch Targets" namespace { +// BTI HINT encoding: base (32) plus 'c' (2) and/or 'j' (4). +enum : unsigned { + BTIBase = 32, // Base immediate for BTI HINT + BTIC = 1u << 1, // 2 + BTIJ = 1u << 2, // 4 + BTIMask = BTIC | BTIJ, +}; + class AArch64BranchTargets : public MachineFunctionPass { public: static char ID; @@ -42,6 +50,7 @@ class AArch64BranchTargets : public MachineFunctionPass { void addBTI(MachineBasicBlock &MBB, bool CouldCall, bool CouldJump, bool NeedsWinCFI); }; + } // end anonymous namespace char AArch64BranchTargets::ID = 0; @@ -62,9 +71,8 @@ bool AArch64BranchTargets::runOnMachineFunction(MachineFunction &MF) { if (!MF.getInfo()->branchTargetEnforcement()) return false; - LLVM_DEBUG( - dbgs() << "** AArch64 Branch Targets **\n" - << "** Function: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "** AArch64 Branch Targets **\n" +<< "** Function: " << MF.getName() << '\n'); const Function &F = MF.getFunction(); // LLVM does not consider basic blocks which are the targets of jump tables @@ -103,6 +111,12 @@ bool AArch64BranchTargets::runOnMachineFunction(MachineFunction &MF) { JumpTableTargets.count(&MBB)) CouldJump = true; +if (MBB.isEHPad()) { + if (HasWinCFI && (MBB.isEHFuncletEntry() || MBB.isCleanupFuncletEntry())) +CouldCall = true; + else +CouldJump = true; +} if (CouldCall || CouldJump) { addBTI(MBB, CouldCall, CouldJump, HasWinCFI); MadeChange = true; @@ -130,7 +144,12 @@ void AArch64BranchTargets::addBTI(MachineBasicBlock &MBB, bool CouldCall, auto MBBI = MBB.begin(); - // Skip the meta instructions, those will be removed anyway. + // If the block starts with EH_LABEL(s), skip them first. + while (MBBI != MBB.end() && MBBI->isEHLabel()) { +++MBBI; + } + + // Skip meta/CFI/etc. (and EMITBKEY) to reach the first executable insn. for (; MBBI != MBB.end() && (MBBI->isMetaInstruction() || MBBI->getOpcode() == AArch64::EMITBKEY); ++MBBI) @@ -138,16 +157,21 @@ void AArch64BranchTargets::addBTI(MachineBasicBlock &MBB, bool CouldCall, // SCTLR_EL1.BT[01] is set to 0 by default which means // PACI[AB]SP are implicitly BTI C so no BTI C instruction is needed there. - if (MBBI != MBB.end() && HintNum == 34 && + if (MBBI != MBB.end() && ((HintNum & BTIMask) == BTIC) && (MBBI->getOpcode() == AArch64::PACIASP || MBBI->getOpcode() == AArch64::PACIBSP)) return; - if (HasWinCFI && MBBI->getFlag(MachineInstr::FrameSetup)) { -BuildMI(MBB, MBB.begin(), MBB.findDebugLoc(MBB.begin()), -TII->get(AArch64::SEH_Nop)); + // Insert BTI exactly at the first executable instruction. + const DebugLoc DL = MBB.findDebugLoc(MBBI); + MachineInstr *BTI = BuildMI(MBB, MBBI, DL, TII->get(AArch64::HINT)) + .addImm(HintNum) + .getInstr(); + + // WinEH: put .seh_nop after BTI when the first real insn is FrameSetup. + if (HasWinCFI && MBBI != MBB.end() && + MBBI->getFlag(MachineInstr::FrameSetup)) { +auto AfterBTI = std::next(MachineBasicBlock::iterator(BTI)); +BuildMI(MBB, AfterBTI, DL, TII->get(AArch64::SEH_Nop)); } - BuildMI(MBB, MBB.begin(), MBB.findDebugLoc(MBB.begin()), - TII->get(AArch64::HINT)) - .addImm(HintNum); } diff --git a/llvm/test/CodeGen/AArch64/bti-ehpad.ll b/llvm/test/CodeGen/AArch64/bti-ehpad
[llvm-branch-commits] [compiler-rt] release/21.x: [compiler-rt] Avoid depending on the libnvmm header for NetBSD (#153534) (PR #155717)
github-actions[bot] wrote: @alexrp (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/155717 ___ 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] release/21.x: [AArch64][BTI] Add BTI at EH entries. (#155308) (PR #156170)
github-actions[bot] wrote: @davemgreen (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/156170 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++] Fix broken precondition of __bit_log2 (#155476) (PR #155932)
tru wrote: Still unclear if this should be merged or not. https://github.com/llvm/llvm-project/pull/155932 ___ 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] b4274c3 - [DebugInfo] When referencing structured bindings use the reference's location, not the binding's declaration's location (#153637)
Author: David Blaikie Date: 2025-09-08T09:39:28+02:00 New Revision: b4274c3bc8eee764ad048c77b9a4baa12eb708a0 URL: https://github.com/llvm/llvm-project/commit/b4274c3bc8eee764ad048c77b9a4baa12eb708a0 DIFF: https://github.com/llvm/llvm-project/commit/b4274c3bc8eee764ad048c77b9a4baa12eb708a0.diff LOG: [DebugInfo] When referencing structured bindings use the reference's location, not the binding's declaration's location (#153637) For structured bindings that use custom `get` specializations, the resulting LLVM IR ascribes the load of the result of `get` to the binding's declaration, rather than the place where the binding is referenced - this caused awkward sequencing in the debug info where, when stepping through the code you'd step back to the binding declaration every time there was a reference to the binding. To fix that - when we cross into IRGening a binding - suppress the debug info location of that subexpression. I don't represent this as a great bit of API design - certainly open to ideas, but putting it out here as a place to start. It's /possible/ this is an incomplete fix, even - if the binding decl had other subexpressions, those would still get their location applied & it'd likely be wrong. So maybe that's a direction to go with to productionize this - add a new location scoped device that suppresses any overriding - this might be more robust. How do people feel about that? (cherry picked from commit 665e875f1a86be650e044bb20744bb272d03e11d) Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGCall.h clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGenCXX/debug-info-structured-binding.cpp Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index c8c3d6b20c496..5344a9710d642 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -4787,19 +4787,6 @@ struct DestroyUnpassedArg final : EHScopeStack::Cleanup { } }; -struct DisableDebugLocationUpdates { - CodeGenFunction &CGF; - bool disabledDebugInfo; - DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) { -if ((disabledDebugInfo = isa(E) && CGF.getDebugInfo())) - CGF.disableDebugInfo(); - } - ~DisableDebugLocationUpdates() { -if (disabledDebugInfo) - CGF.enableDebugInfo(); - } -}; - } // end anonymous namespace RValue CallArg::getRValue(CodeGenFunction &CGF) const { @@ -4836,7 +4823,9 @@ void CodeGenFunction::EmitWritebacks(const CallArgList &args) { void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, QualType type) { - DisableDebugLocationUpdates Dis(*this, E); + std::optional Dis; + if (isa(E)) +Dis.emplace(*this); if (const ObjCIndirectCopyRestoreExpr *CRE = dyn_cast(E)) { assert(getLangOpts().ObjCAutoRefCount); @@ -6229,3 +6218,12 @@ RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr, return CGM.getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty, Slot); return CGM.getABIInfo().EmitVAArg(*this, VAListAddr, Ty, Slot); } + +DisableDebugLocationUpdates::DisableDebugLocationUpdates(CodeGenFunction &CGF) +: CGF(CGF) { + CGF.disableDebugInfo(); +} + +DisableDebugLocationUpdates::~DisableDebugLocationUpdates() { + CGF.enableDebugInfo(); +} diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h index 0b4e3f9cb0365..17b2ce558f711 100644 --- a/clang/lib/CodeGen/CGCall.h +++ b/clang/lib/CodeGen/CGCall.h @@ -457,6 +457,12 @@ inline FnInfoOpts &operator&=(FnInfoOpts &A, FnInfoOpts B) { return A; } +struct DisableDebugLocationUpdates { + CodeGenFunction &CGF; + DisableDebugLocationUpdates(CodeGenFunction &CGF); + ~DisableDebugLocationUpdates(); +}; + } // end namespace CodeGen } // end namespace clang diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 85c768807572f..b5debd93b0f61 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3314,7 +3314,14 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { auto *FD = LambdaCaptureFields.lookup(BD); return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue); } -return EmitLValue(BD->getBinding()); +// Suppress debug location updates when visiting the binding, since the +// binding may emit instructions that would otherwise be associated with the +// binding itself, rather than the expression referencing the binding. (this +// leads to jumpy debug stepping behavior where the location/debugger jump +// back to the binding declaration, then back to the expression referencing +// the binding) +DisableDebugLocationUpdates D(*this); +return EmitLValue(BD->getBinding(), NotKnownNonNull); } // We can form DeclRefExprs naming GUID declarations when reconstituting diff --git a/clang/test/CodeGenCXX/debug-inf
[llvm-branch-commits] [libcxx] 7a077a1 - [libc++][AIX] Fixup problems with ABI list checking (#155643)
Author: David Tenty Date: 2025-09-08T09:39:07+02:00 New Revision: 7a077a1b312b66055643e05d88795c5b1f329874 URL: https://github.com/llvm/llvm-project/commit/7a077a1b312b66055643e05d88795c5b1f329874 DIFF: https://github.com/llvm/llvm-project/commit/7a077a1b312b66055643e05d88795c5b1f329874.diff LOG: [libc++][AIX] Fixup problems with ABI list checking (#155643) There are some problems with our ABI list checking exposed by recent compiler/cmake upgrades. - For symcheck, there are typos in how XCOFF magic are defined, we intended the second two digits to be a hex value, but our syntax doesn't say that. Thus this will never match a valid XCOFF file. - AIX triples can have version numbers. Those need to be discarded when looking for an libc++ ABI list, like we do for other targets. (cherry picked from commit b8456e2a9698aa927d7b3f9c38213f3219aa0498) Added: Modified: libcxx/lib/abi/CMakeLists.txt libcxx/utils/libcxx/sym_check/util.py Removed: diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt index 7c08bd06c50b2..8f277aad2dcd5 100644 --- a/libcxx/lib/abi/CMakeLists.txt +++ b/libcxx/lib/abi/CMakeLists.txt @@ -16,6 +16,9 @@ function(cxx_abi_list_identifier result triple abi_library abi_version unstable elseif("${triple}" MATCHES "freebsd") # Ignore the major and minor versions of freebsd targets. string(REGEX REPLACE "freebsd[0-9]+\\.[0-9]+" "freebsd" triple "${triple}") + elseif("${triple}" MATCHES "aix") +# Ignore the V.R.M.F version string of aix targets. +string(REGEX REPLACE "aix[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" "aix" triple "${triple}") endif() list(APPEND abi_properties "${triple}") list(APPEND abi_properties "${abi_library}") diff --git a/libcxx/utils/libcxx/sym_check/util.py b/libcxx/utils/libcxx/sym_check/util.py index fc7ba4244ab5a..dbc886f29ddea 100644 --- a/libcxx/utils/libcxx/sym_check/util.py +++ b/libcxx/utils/libcxx/sym_check/util.py @@ -95,7 +95,7 @@ def is_xcoff_or_big_ar(filename): with open(filename, "rb") as f: magic_bytes = f.read(7) return ( -magic_bytes[:4] in [b"\x01DF", b"\x01F7"] # XCOFF32 # XCOFF64 +magic_bytes[:2] in [b"\x01\xDF", b"\x01\xF7"] # XCOFF32 # XCOFF64 or magic_bytes == b"" ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++][AIX] Fixup problems with ABI list checking (#155643) (PR #156502)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/156502 ___ 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] release/21.x: [DebugInfo] When referencing structured bindings use the reference's location, not the binding's declaration's location (#153637) (PR #156664)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (llvmbot) Changes Backport 665e875f1a86be650e044bb20744bb272d03e11d Requested by: @Michael137 --- Full diff: https://github.com/llvm/llvm-project/pull/156664.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CGCall.cpp (+12-14) - (modified) clang/lib/CodeGen/CGCall.h (+6) - (modified) clang/lib/CodeGen/CGExpr.cpp (+8-1) - (modified) clang/test/CodeGenCXX/debug-info-structured-binding.cpp (+43-1) ``diff diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index c8c3d6b20c496..5344a9710d642 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -4787,19 +4787,6 @@ struct DestroyUnpassedArg final : EHScopeStack::Cleanup { } }; -struct DisableDebugLocationUpdates { - CodeGenFunction &CGF; - bool disabledDebugInfo; - DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) { -if ((disabledDebugInfo = isa(E) && CGF.getDebugInfo())) - CGF.disableDebugInfo(); - } - ~DisableDebugLocationUpdates() { -if (disabledDebugInfo) - CGF.enableDebugInfo(); - } -}; - } // end anonymous namespace RValue CallArg::getRValue(CodeGenFunction &CGF) const { @@ -4836,7 +4823,9 @@ void CodeGenFunction::EmitWritebacks(const CallArgList &args) { void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, QualType type) { - DisableDebugLocationUpdates Dis(*this, E); + std::optional Dis; + if (isa(E)) +Dis.emplace(*this); if (const ObjCIndirectCopyRestoreExpr *CRE = dyn_cast(E)) { assert(getLangOpts().ObjCAutoRefCount); @@ -6229,3 +6218,12 @@ RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr, return CGM.getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty, Slot); return CGM.getABIInfo().EmitVAArg(*this, VAListAddr, Ty, Slot); } + +DisableDebugLocationUpdates::DisableDebugLocationUpdates(CodeGenFunction &CGF) +: CGF(CGF) { + CGF.disableDebugInfo(); +} + +DisableDebugLocationUpdates::~DisableDebugLocationUpdates() { + CGF.enableDebugInfo(); +} diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h index 0b4e3f9cb0365..17b2ce558f711 100644 --- a/clang/lib/CodeGen/CGCall.h +++ b/clang/lib/CodeGen/CGCall.h @@ -457,6 +457,12 @@ inline FnInfoOpts &operator&=(FnInfoOpts &A, FnInfoOpts B) { return A; } +struct DisableDebugLocationUpdates { + CodeGenFunction &CGF; + DisableDebugLocationUpdates(CodeGenFunction &CGF); + ~DisableDebugLocationUpdates(); +}; + } // end namespace CodeGen } // end namespace clang diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 85c768807572f..b5debd93b0f61 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3314,7 +3314,14 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { auto *FD = LambdaCaptureFields.lookup(BD); return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue); } -return EmitLValue(BD->getBinding()); +// Suppress debug location updates when visiting the binding, since the +// binding may emit instructions that would otherwise be associated with the +// binding itself, rather than the expression referencing the binding. (this +// leads to jumpy debug stepping behavior where the location/debugger jump +// back to the binding declaration, then back to the expression referencing +// the binding) +DisableDebugLocationUpdates D(*this); +return EmitLValue(BD->getBinding(), NotKnownNonNull); } // We can form DeclRefExprs naming GUID declarations when reconstituting diff --git a/clang/test/CodeGenCXX/debug-info-structured-binding.cpp b/clang/test/CodeGenCXX/debug-info-structured-binding.cpp index 5fbd54c16382c..4a4a4d8bdfaad 100644 --- a/clang/test/CodeGenCXX/debug-info-structured-binding.cpp +++ b/clang/test/CodeGenCXX/debug-info-structured-binding.cpp @@ -7,6 +7,12 @@ // CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_4:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 4), // CHECK: #dbg_declare(ptr %z1, ![[VAR_5:[0-9]+]], !DIExpression() // CHECK: #dbg_declare(ptr %z2, ![[VAR_6:[0-9]+]], !DIExpression() +// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y1_DEBUG_LOC:[0-9]+]] +// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y2_DEBUG_LOC:[0-9]+]] +// CHECK: load ptr, ptr %z2, {{.*}}!dbg ![[Z2_DEBUG_LOC:[0-9]+]] +// CHECK: getelementptr inbounds [2 x i32], ptr {{.*}}, i64 0, i64 1, !dbg ![[A2_DEBUG_LOC:[0-9]+]] +// CHECK: getelementptr inbounds nuw { i32, i32 }, ptr {{.*}}, i32 0, i32 1, !dbg ![[C2_DEBUG_LOC:[0-9]+]] +// CHECK: extractelement <2 x i32> {{.*}}, i32 1, !dbg ![[V2_DEBUG_LOC:[0-9]+]] // CHECK: ![[VAR_0]] = !DILocalVariable(name: "a" // CHECK: ![[VAR_1]] = !DILocalVariable(name: "x1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) // CHECK: ![[VAR_2
[llvm-branch-commits] [lldb] e0d94d9 - [lldb][DWARFASTParserClang] Don't complete conflicting Objective-C++ types (#156681)
Author: Michael Buch Date: 2025-09-08T09:40:07+02:00 New Revision: e0d94d9626e4e942b608cd39cadf367cbe2b0c96 URL: https://github.com/llvm/llvm-project/commit/e0d94d9626e4e942b608cd39cadf367cbe2b0c96 DIFF: https://github.com/llvm/llvm-project/commit/e0d94d9626e4e942b608cd39cadf367cbe2b0c96.diff LOG: [lldb][DWARFASTParserClang] Don't complete conflicting Objective-C++ types (#156681) This upstreams https://github.com/swiftlang/llvm-project/pull/10313. If we detect a situation where a forward declaration is C++ and the definition DIE is Objective-C, then just don't try to complete the type (it would crash otherwise). In the long term we might want to add support for completing such types. We've seen real world crashes when debugging WebKit and wxWidgets because of this. Both projects forward declare ObjC++ decls in the way shown in the test. rdar://145959981 (cherry picked from commit a862225813c251c28b085603b7d32d4b111dbc57) Added: lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index c76d67b47b336..8916c58beec0f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2201,6 +2201,18 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, for (DelayedAddObjCClassProperty &property : delayed_properties) property.Finalize(); } + } else if (Language::LanguageIsObjC( + static_cast(die.GetAttributeValueAsUnsigned( + DW_AT_APPLE_runtime_class, eLanguageTypeUnknown { +/// The forward declaration was C++ but the definition is Objective-C. +/// We currently don't handle such situations. In such cases, keep the +/// forward declaration without a definition to avoid violating Clang AST +/// invariants. +LLDB_LOG(GetLog(LLDBLog::Expressions), + "WARNING: Type completion aborted because forward declaration for " + "'{0}' is C++ while definition is Objective-C.", + llvm::StringRef(die.GetName())); +return {}; } if (!bases.empty()) { diff --git a/lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test b/lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test new file mode 100644 index 0..30109c2943c9b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/objcxx-forward-decls.test @@ -0,0 +1,70 @@ +# REQUIRES: system-darwin + +# In this test we have two CUs with conflicting forward declaration +# depending on the CU language (one is C++ and the other is Objective-C++). +# We are then stopped in the C++ CU and try to print the type, at which +# point LLDB will try to make it into an Clang AST node. If LLDB were to +# interpret the type as C++ instead of Objective-C, we'd violate Clang +# invariants and crash. +# +# RUN: split-file %s %t +# RUN: %clangxx_host -c -g -x objective-c++ %t/request.m -o %t/request_objc.o +# RUN: %clangxx_host -c -g %t/main.cpp -o %t/main.o +# RUN: %clangxx_host %t/main.o %t/request_objc.o -framework Foundation -o %t/a.out +# +# RUN: %lldb %t/a.out \ +# RUN:-o "breakpoint set -p return -X main" \ +# RUN:-o run \ +# RUN:-o "frame variable r" \ +# RUN:-o exit | FileCheck %s +# +# RUN: dsymutil %t/a.out +# +# RUN: %lldb %t/a.out \ +# RUN:-o "breakpoint set -p return -X main" \ +# RUN:-o run \ +# RUN:-o "frame variable r" \ +# RUN:-o exit | FileCheck %s --check-prefix=CHECK-DSYM + +# CHECK: (lldb) frame variable r +# CHECK-NEXT: (Request) ::r = (m_request = "Hello, World!") + +# CHECK-DSYM: (lldb) frame variable r +# CHECK-DSYM-NEXT: (Request) ::r = (m_request = "Hello, World!") + +#--- lib.h +#ifndef LIB_H_IN +#define LIB_H_IN + +#ifdef __OBJC__ +@class NSString; +#else +class NSString; +#endif + +struct Request { + NSString * m_request = nullptr; +}; + +#endif // _H_IN + +#--- main.cpp +#include "lib.h" + +void process(Request *); + +Request r; + +int main() { +process(&r); +return 0; +} + +#--- request.m +#import + +#include "lib.h" + +void process(Request * r) { + r->m_request = @"Hello, World!"; +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++][AIX] Fixup problems with ABI list checking (#155643) (PR #156502)
github-actions[bot] wrote: @amy-kwan (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/156502 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt] release/21.x: compiler-rt: Use OpenBSD's elf_aux_info to detect AArch64 HW features (#155768) (PR #155899)
devnexen wrote: I think it s borderline fix/improvement as these arm64 features are wrongly discarded otherwise. Also probably to decrease openbsd internal patches amount. https://github.com/llvm/llvm-project/pull/155899 ___ 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] 12fbb34 - [Coroutines] Restore accidentally dropped intrinsic IDs
Author: Nikita Popov Date: 2025-09-08T09:41:17+02:00 New Revision: 12fbb344a1e84aed4a34d3d00a387f15cebc82e1 URL: https://github.com/llvm/llvm-project/commit/12fbb344a1e84aed4a34d3d00a387f15cebc82e1 DIFF: https://github.com/llvm/llvm-project/commit/12fbb344a1e84aed4a34d3d00a387f15cebc82e1.diff LOG: [Coroutines] Restore accidentally dropped intrinsic IDs These were unintentionally dropped in #145518. These intrinsics are not overloaded, so should be part of this list. (cherry picked from commit a647bb4a7ba23b5a7c7484fd5162fef2d10c7068) Added: Modified: llvm/lib/Transforms/Coroutines/Coroutines.cpp Removed: diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp index 59ae057cae793..ac93f748ce65c 100644 --- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp +++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp @@ -85,6 +85,9 @@ static Intrinsic::ID NonOverloadedCoroIntrinsics[] = { Intrinsic::coro_id_async, Intrinsic::coro_id_retcon, Intrinsic::coro_id_retcon_once, +Intrinsic::coro_noop, +Intrinsic::coro_prepare_async, +Intrinsic::coro_prepare_retcon, Intrinsic::coro_promise, Intrinsic::coro_resume, Intrinsic::coro_save, ___ 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] release/21.x: [Coroutines] Restore accidentally dropped intrinsic IDs (PR #156925)
github-actions[bot] wrote: @nikic (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/156925 ___ 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] release/21.x: [Coroutines] Restore accidentally dropped intrinsic IDs (PR #156925)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/156925 ___ 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] Sparc: Remove Is64Bit field from SparcTargetMachine (PR #157400)
llvmbot wrote: @llvm/pr-subscribers-backend-sparc Author: Matt Arsenault (arsenm) Changes Directly use the triple instead of having an additional field. --- Full diff: https://github.com/llvm/llvm-project/pull/157400.diff 4 Files Affected: - (modified) llvm/lib/Target/Sparc/SparcSubtarget.cpp (+4-4) - (modified) llvm/lib/Target/Sparc/SparcSubtarget.h (+2-2) - (modified) llvm/lib/Target/Sparc/SparcTargetMachine.cpp (+12-12) - (modified) llvm/lib/Target/Sparc/SparcTargetMachine.h (+1-2) ``diff diff --git a/llvm/lib/Target/Sparc/SparcSubtarget.cpp b/llvm/lib/Target/Sparc/SparcSubtarget.cpp index 5a71e49467b14..f2721ead00697 100644 --- a/llvm/lib/Target/Sparc/SparcSubtarget.cpp +++ b/llvm/lib/Target/Sparc/SparcSubtarget.cpp @@ -31,7 +31,7 @@ SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies( // Determine default and user specified characteristics std::string CPUName = std::string(CPU); if (CPUName.empty()) -CPUName = (Is64Bit) ? "v9" : "v8"; +CPUName = getTargetTriple().isSPARC64() ? "v9" : "v8"; if (TuneCPU.empty()) TuneCPU = CPUName; @@ -47,10 +47,10 @@ SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies( } SparcSubtarget::SparcSubtarget(const StringRef &CPU, const StringRef &TuneCPU, - const StringRef &FS, const TargetMachine &TM, - bool is64Bit) + const StringRef &FS, const TargetMachine &TM) : SparcGenSubtargetInfo(TM.getTargetTriple(), CPU, TuneCPU, FS), - ReserveRegister(TM.getMCRegisterInfo()->getNumRegs()), Is64Bit(is64Bit), + ReserveRegister(TM.getMCRegisterInfo()->getNumRegs()), + Is64Bit(TM.getTargetTriple().isSPARC64()), InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)), TLInfo(TM, *this), FrameLowering(*this) { TSInfo = std::make_unique(); diff --git a/llvm/lib/Target/Sparc/SparcSubtarget.h b/llvm/lib/Target/Sparc/SparcSubtarget.h index 502be1e06d41c..f98aef012a867 100644 --- a/llvm/lib/Target/Sparc/SparcSubtarget.h +++ b/llvm/lib/Target/Sparc/SparcSubtarget.h @@ -36,7 +36,7 @@ class SparcSubtarget : public SparcGenSubtargetInfo { virtual void anchor(); - bool Is64Bit; + const bool Is64Bit; #define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \ bool ATTRIBUTE = DEFAULT; @@ -49,7 +49,7 @@ class SparcSubtarget : public SparcGenSubtargetInfo { public: SparcSubtarget(const StringRef &CPU, const StringRef &TuneCPU, - const StringRef &FS, const TargetMachine &TM, bool is64bit); + const StringRef &FS, const TargetMachine &TM); ~SparcSubtarget() override; diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp index 52076a6b4dd22..754c8f63ca4ec 100644 --- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp @@ -38,7 +38,9 @@ static cl::opt BranchRelaxation("sparc-enable-branch-relax", cl::Hidden, cl::init(true), cl::desc("Relax out of range conditional branches")); -static std::string computeDataLayout(const Triple &T, bool is64Bit) { +static std::string computeDataLayout(const Triple &T) { + const bool is64Bit = T.isSPARC64(); + // Sparc is typically big endian, but some are little. std::string Ret = T.getArch() == Triple::sparcel ? "e" : "E"; Ret += "-m:e"; @@ -107,15 +109,14 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOptLevel OL, bool JIT, - bool is64bit) + CodeGenOptLevel OL, bool JIT) : CodeGenTargetMachineImpl( - T, computeDataLayout(TT, is64bit), TT, CPU, FS, Options, + T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), - getEffectiveSparcCodeModel(CM, getEffectiveRelocModel(RM), is64bit, - JIT), + getEffectiveSparcCodeModel(CM, getEffectiveRelocModel(RM), + TT.isSPARC64(), JIT), OL), - TLOF(std::make_unique()), is64Bit(is64bit) { + TLOF(std::make_unique()) { initAsmInfo(); } @@ -148,8 +149,7 @@ SparcTargetMachine::getSubtargetImpl(const Function &F) const { // creation will depend on the TM and the code generation flags on the // function that reside in TargetOptions. resetTargetOptions(F); -I = std::make_unique(CPU, TuneCPU, FS, *this, - this->is64Bit); +I = std::make_unique(CPU, TuneCPU, FS, *this); } return I.get(); } @@ -212,7 +212,7 @@ SparcV8TargetMachine::SparcV8TargetMac
[llvm-branch-commits] [clang] release/21.x: [clang][docs] Fix implicit-int-conversion-on-negation typos (PR #156815)
https://github.com/tru closed https://github.com/llvm/llvm-project/pull/156815 ___ 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] Sparc: Remove Is64Bit field from SparcTargetMachine (PR #157400)
arsenm wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/157400?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#157400** https://app.graphite.dev/github/pr/llvm/llvm-project/157400?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/157400?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#157397** https://app.graphite.dev/github/pr/llvm/llvm-project/157397?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/157400 ___ 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] PPC: Use StringRef for subtarget constructor arguments (PR #157409)
llvmbot wrote: @llvm/pr-subscribers-backend-powerpc Author: Matt Arsenault (arsenm) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/157409.diff 2 Files Affected: - (modified) llvm/lib/Target/PowerPC/PPCSubtarget.cpp (+2-3) - (modified) llvm/lib/Target/PowerPC/PPCSubtarget.h (+1-2) ``diff diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp index 5f80929e86f99..736ba1edcaea6 100644 --- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp @@ -52,9 +52,8 @@ PPCSubtarget &PPCSubtarget::initializeSubtargetDependencies(StringRef CPU, return *this; } -PPCSubtarget::PPCSubtarget(const Triple &TT, const std::string &CPU, - const std::string &TuneCPU, const std::string &FS, - const PPCTargetMachine &TM) +PPCSubtarget::PPCSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, + StringRef FS, const PPCTargetMachine &TM) : PPCGenSubtargetInfo(TT, CPU, TuneCPU, FS), IsPPC64(getTargetTriple().getArch() == Triple::ppc64 || getTargetTriple().getArch() == Triple::ppc64le), diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.h b/llvm/lib/Target/PowerPC/PPCSubtarget.h index 17d9d2ab402be..c17fca7f70a3c 100644 --- a/llvm/lib/Target/PowerPC/PPCSubtarget.h +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.h @@ -116,8 +116,7 @@ class PPCSubtarget : public PPCGenSubtargetInfo { /// This constructor initializes the data members to match that /// of the specified triple. /// - PPCSubtarget(const Triple &TT, const std::string &CPU, - const std::string &TuneCPU, const std::string &FS, + PPCSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS, const PPCTargetMachine &TM); ~PPCSubtarget() override; `` https://github.com/llvm/llvm-project/pull/157409 ___ 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] PPC: Use StringRef for subtarget constructor arguments (PR #157409)
arsenm wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/157409?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#157409** https://app.graphite.dev/github/pr/llvm/llvm-project/157409?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/157409?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#157404** https://app.graphite.dev/github/pr/llvm/llvm-project/157404?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/157409 ___ 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] [MC] Rewrite stdin.s to use python (PR #157232)
nikic wrote: > > I don't know if I understand what you're going for in this patch. How is > > this an improvement over just keeping REQUIRES: shell? The REQUIRES: bit > > is what's going to stop the test from running in the wrong environment. > > That seems like the right tradeoff. > > If we don't get rid of all the `REQUIRES: shell` checks and we want to turn > on the internal shell by default, we end up losing test coverage here. Unless > we explicitly have a buildbot running tests with the exteral shell, which > seems like a bit of a waste. Somewhat off-topic for this PR, but why can't `REQUIRES: shell` force use of shell even if internal shell is the default? Then we don't lose test coverage and don't block this on migration of the long-tail of tests. https://github.com/llvm/llvm-project/pull/157232 ___ 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] [LifetimeSafety] Add support for GSL Pointer types (PR #154009)
https://github.com/Xazax-hun commented: We already have some logic in the statement local analysis about when we consider a gsl pointer to be a borrow from an owner and when we propagate the underlying borrow. I wonder if it was possible to somehow factor that logic out and reuse it instead of reimplementing it. https://github.com/llvm/llvm-project/pull/154009 ___ 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] PPC: Split 64bit target feature into 64bit and 64bit-support (PR #157206)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/157206 >From 0d4d26ae9d6ee802c46d8115ccee28a9470aaced Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 6 Sep 2025 08:50:20 +0900 Subject: [PATCH] PPC: Split 64bit target feature into 64bit and 64bit-support This was being used for 2 different purposes. The TargetMachine constructor prepends +64bit based on isPPC64 triples as a mode switch. The same feature name was also explicitly added to different processors, making it impossible to perform a pure feature check for whether 64-bit mode is enabled ir not. i.e., checkFeatures("+64bit") would be true even for ppc32 triples. The comment in tablegen suggests it's relevant to track which processors support 64-bit mode independently of whether that's the active compile target, so replace that with a new feature. --- llvm/lib/Target/PowerPC/PPC.td | 33 ++-- llvm/lib/Target/PowerPC/PPCSubtarget.cpp | 7 ++--- llvm/lib/Target/PowerPC/PPCSubtarget.h | 5 llvm/test/CodeGen/PowerPC/i64_fp.ll | 8 +++--- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPC.td b/llvm/lib/Target/PowerPC/PPC.td index db6427cfe8482..386d0f65d1ed1 100644 --- a/llvm/lib/Target/PowerPC/PPC.td +++ b/llvm/lib/Target/PowerPC/PPC.td @@ -58,8 +58,13 @@ def DirectivePwrFuture // Specifies that the selected CPU supports 64-bit instructions, regardless of // whether we are in 32-bit or 64-bit mode. -def Feature64Bit : SubtargetFeature<"64bit","Has64BitSupport", "true", -"Enable 64-bit instructions">; +def Feature64BitSupport : SubtargetFeature<"64bit-support", "Has64BitSupport", "true", +"Supports 64-bit instructions">; +// 64-bit is enabled. +def Feature64Bit : SubtargetFeature<"64bit", "IsPPC64", "true", +"Enable 64-bit mode", +[Feature64BitSupport]>; + def AIXOS: SubtargetFeature<"aix", "IsAIX", "true", "AIX OS">; def FeatureModernAIXAs : SubtargetFeature<"modern-aix-as", "HasModernAIXAs", "true", @@ -85,7 +90,7 @@ def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", "true", def FeatureSPE : SubtargetFeature<"spe","HasSPE", "true", "Enable SPE instructions", [FeatureHardFloat]>; -def FeatureEFPU2 : SubtargetFeature<"efpu2", "HasEFPU2", "true", +def FeatureEFPU2 : SubtargetFeature<"efpu2", "HasEFPU2", "true", "Enable Embedded Floating-Point APU 2 instructions", [FeatureSPE]>; def FeatureMFOCRF: SubtargetFeature<"mfocrf","HasMFOCRF", "true", @@ -429,7 +434,7 @@ def ProcessorFeatures { FeaturePOPCNTD, FeatureCMPB, FeatureLDBRX, - Feature64Bit, + Feature64BitSupport, /* Feature64BitRegs, */ FeatureBPERMD, FeatureExtDiv, @@ -667,13 +672,13 @@ def : ProcessorModel<"970", G5Model, [Directive970, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureFRES, FeatureFRSQRTE, FeatureSTFIWX, - Feature64Bit /*, Feature64BitRegs */, + Feature64BitSupport /*, Feature64BitRegs */, FeatureMFTB]>; def : ProcessorModel<"g5", G5Model, [Directive970, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX, FeatureFRES, FeatureFRSQRTE, - Feature64Bit /*, Feature64BitRegs */, + Feature64BitSupport /*, Feature64BitRegs */, FeatureMFTB, DeprecatedDST]>; def : ProcessorModel<"e500", PPCE500Model, [DirectiveE500, @@ -694,41 +699,41 @@ def : ProcessorModel<"a2", PPCA2Model, FeatureSTFIWX, FeatureLFIWAX, FeatureFPRND, FeatureFPCVT, FeatureISEL, FeatureSlowPOPCNTD, FeatureCMPB, FeatureLDBRX, - Feature64Bit /*, Feature64BitRegs */, FeatureMFTB, + Feature64BitSupport /*, Feature64BitRegs */, FeatureMFTB, FeatureISA2_06]>; def : ProcessorModel<"pwr3", G5Model, [DirectivePwr3, FeatureAltivec, FeatureFRES, FeatureFRSQRTE, FeatureMFOCRF, - FeatureSTFIWX, Feature64Bit]>; + FeatureSTFIWX, Feature64BitSupport]>; def : ProcessorModel<"pwr4", G5Model,
[llvm-branch-commits] [clang] release/21.x: [Driver] Enable outline atomics for OpenBSD/aarch64 (#155713) (PR #155759)
tru wrote: ping https://github.com/llvm/llvm-project/pull/155759 ___ 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] [Offload] Add GenericPluginTy::get_mem_info (PR #157484)
https://github.com/RossBrunton created https://github.com/llvm/llvm-project/pull/157484 This takes a pointer allocated by the plugin, and returns a struct containing important information about it. This is now used in `olMemFree` instead of using a map to track allocation info. >From 7011463403d584ac8145bbbcdef2f0879c983d78 Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Mon, 8 Sep 2025 10:45:42 +0100 Subject: [PATCH] [Offload] Add GenericPluginTy::get_mem_info This takes a pointer allocated by the plugin, and returns a struct containing important information about it. This is now used in `olMemFree` instead of using a map to track allocation info. --- offload/include/omptarget.h | 2 + offload/liboffload/src/OffloadImpl.cpp| 27 +-- .../amdgpu/dynamic_hsa/hsa.cpp| 1 + .../amdgpu/dynamic_hsa/hsa_ext_amd.h | 3 + offload/plugins-nextgen/amdgpu/src/rtl.cpp| 31 ++- .../common/include/PluginInterface.h | 15 ++ offload/plugins-nextgen/cuda/src/rtl.cpp | 216 +++--- offload/plugins-nextgen/host/src/rtl.cpp | 5 + 8 files changed, 195 insertions(+), 105 deletions(-) diff --git a/offload/include/omptarget.h b/offload/include/omptarget.h index 8fd722bb15022..4807429521ce4 100644 --- a/offload/include/omptarget.h +++ b/offload/include/omptarget.h @@ -96,6 +96,8 @@ enum OpenMPOffloadingDeclareTargetFlags { OMP_REGISTER_REQUIRES = 0x10, }; +// Note: This type should be no larger than 3 bits, as the amdgpu driver uses +// the lower 3 bits of a pointer to store it enum TargetAllocTy : int32_t { TARGET_ALLOC_DEVICE = 0, TARGET_ALLOC_HOST, diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp index fef3a5669e0d5..9620c35ac5c10 100644 --- a/offload/liboffload/src/OffloadImpl.cpp +++ b/offload/liboffload/src/OffloadImpl.cpp @@ -201,8 +201,6 @@ struct OffloadContext { bool TracingEnabled = false; bool ValidationEnabled = true; - DenseMap AllocInfoMap{}; - std::mutex AllocInfoMapMutex{}; SmallVector Platforms{}; size_t RefCount; @@ -624,32 +622,15 @@ Error olMemAlloc_impl(ol_device_handle_t Device, ol_alloc_type_t Type, return Alloc.takeError(); *AllocationOut = *Alloc; - { -std::lock_guard Lock(OffloadContext::get().AllocInfoMapMutex); -OffloadContext::get().AllocInfoMap.insert_or_assign( -*Alloc, AllocInfo{Device, Type}); - } return Error::success(); } Error olMemFree_impl(ol_platform_handle_t Platform, void *Address) { - ol_device_handle_t Device; - ol_alloc_type_t Type; - { -std::lock_guard Lock(OffloadContext::get().AllocInfoMapMutex); -if (!OffloadContext::get().AllocInfoMap.contains(Address)) - return createOffloadError(ErrorCode::INVALID_ARGUMENT, -"address is not a known allocation"); - -auto AllocInfo = OffloadContext::get().AllocInfoMap.at(Address); -Device = AllocInfo.Device; -Type = AllocInfo.Type; -OffloadContext::get().AllocInfoMap.erase(Address); - } - assert(Platform == Device->Platform); + auto MemInfo = Platform->Plugin->get_memory_info(Address); + if (auto Err = MemInfo.takeError()) +return Err; - if (auto Res = - Device->Device->dataDelete(Address, convertOlToPluginAllocTy(Type))) + if (auto Res = MemInfo->Device->dataDelete(Address, MemInfo->Type)) return Res; return Error::success(); diff --git a/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp b/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp index bc92f4a46a5c0..7f0e75cb9b500 100644 --- a/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp +++ b/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp @@ -68,6 +68,7 @@ DLWRAP(hsa_amd_register_system_event_handler, 2) DLWRAP(hsa_amd_signal_create, 5) DLWRAP(hsa_amd_signal_async_handler, 5) DLWRAP(hsa_amd_pointer_info, 5) +DLWRAP(hsa_amd_pointer_info_set_userdata, 2) DLWRAP(hsa_code_object_reader_create_from_memory, 3) DLWRAP(hsa_code_object_reader_destroy, 1) DLWRAP(hsa_executable_load_agent_code_object, 5) diff --git a/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa_ext_amd.h b/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa_ext_amd.h index 29cfe78082dbb..5c2fbd127c86d 100644 --- a/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa_ext_amd.h +++ b/offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa_ext_amd.h @@ -160,6 +160,7 @@ typedef struct hsa_amd_pointer_info_s { void* agentBaseAddress; void* hostBaseAddress; size_t sizeInBytes; + void *userData; } hsa_amd_pointer_info_t; hsa_status_t hsa_amd_pointer_info(const void* ptr, @@ -168,6 +169,8 @@ hsa_status_t hsa_amd_pointer_info(const void* ptr, uint32_t* num_agents_accessible, hsa_agent_t** accessible); +hsa_status_t hsa_amd_pointer_info_set_userdata(const void *ptr, void *userdata); + #ifdef __cplusplus } #endif diff --git a/offload/plugins-ne
[llvm-branch-commits] [llvm] release/21.x: [RISCV] Cost casts with illegal types that can't be legalized (#153030) (PR #153118)
github-actions[bot] wrote: @lukel97 (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/153118 ___ 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] [mlir] [flang][OpenMP] Support multi-block reduction combiner regions on the GPU (PR #156837)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/156837 >From 8467dbc57b43097ac049610eb68585d186c55228 Mon Sep 17 00:00:00 2001 From: ergawy Date: Thu, 4 Sep 2025 01:06:21 -0500 Subject: [PATCH] [flang][OpenMP] Support multi-block reduction combiner regions on the GPU Fixes a bug related to insertion points when inlining multi-block combiner reduction regions. The IP at the end of the inlined region was not used resulting in emitting BBs with multiple terminators. --- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 3 + .../omptarget-multi-block-reduction.mlir | 85 +++ 2 files changed, 88 insertions(+) create mode 100644 mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 3d5e487c8990f..fe00a2a5696dc 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -3506,6 +3506,8 @@ Expected OpenMPIRBuilder::createReductionFunction( return AfterIP.takeError(); if (!Builder.GetInsertBlock()) return ReductionFunc; + + Builder.SetInsertPoint(AfterIP->getBlock(), AfterIP->getPoint()); Builder.CreateStore(Reduced, LHSPtr); } } @@ -3750,6 +3752,7 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createReductionsGPU( RI.ReductionGen(Builder.saveIP(), RHSValue, LHSValue, Reduced); if (!AfterIP) return AfterIP.takeError(); + Builder.SetInsertPoint(AfterIP->getBlock(), AfterIP->getPoint()); Builder.CreateStore(Reduced, LHS, false); } } diff --git a/mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir b/mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir new file mode 100644 index 0..aaf06d2d0e0c2 --- /dev/null +++ b/mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir @@ -0,0 +1,85 @@ +// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s + +// Verifies that the IR builder can handle reductions with multi-block combiner +// regions on the GPU. + +module attributes {dlti.dl_spec = #dlti.dl_spec<"dlti.alloca_memory_space" = 5 : ui64, "dlti.global_memory_space" = 1 : ui64>, llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, omp.is_target_device = true} { + llvm.func @bar() {} + llvm.func @baz() {} + + omp.declare_reduction @add_reduction_byref_box_5xf32 : !llvm.ptr alloc { +%0 = llvm.mlir.constant(1 : i64) : i64 +%1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> : (i64) -> !llvm.ptr<5> +%2 = llvm.addrspacecast %1 : !llvm.ptr<5> to !llvm.ptr +omp.yield(%2 : !llvm.ptr) + } init { + ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): +omp.yield(%arg1 : !llvm.ptr) + } combiner { + ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): +llvm.call @bar() : () -> () +llvm.br ^bb3 + + ^bb3: // pred: ^bb1 +llvm.call @baz() : () -> () +omp.yield(%arg0 : !llvm.ptr) + } + llvm.func @foo_() { +%c1 = llvm.mlir.constant(1 : i64) : i64 +%10 = llvm.alloca %c1 x !llvm.array<5 x f32> {bindc_name = "x"} : (i64) -> !llvm.ptr<5> +%11 = llvm.addrspacecast %10 : !llvm.ptr<5> to !llvm.ptr +%74 = omp.map.info var_ptr(%11 : !llvm.ptr, !llvm.array<5 x f32>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "x"} +omp.target map_entries(%74 -> %arg0 : !llvm.ptr) { + %c1_2 = llvm.mlir.constant(1 : i32) : i32 + %c10 = llvm.mlir.constant(10 : i32) : i32 + omp.teams reduction(byref @add_reduction_byref_box_5xf32 %arg0 -> %arg2 : !llvm.ptr) { +omp.parallel { + omp.distribute { +omp.wsloop { + omp.loop_nest (%arg5) : i32 = (%c1_2) to (%c10) inclusive step (%c1_2) { +omp.yield + } +} {omp.composite} + } {omp.composite} + omp.terminator +} {omp.composite} +omp.terminator + } + omp.terminator +} +llvm.return + } +} + +// CHECK: call void @__kmpc_parallel_51({{.*}}, i32 1, i32 -1, i32 -1, +// CHECK-SAME: ptr @[[PAR_OUTLINED:.*]], ptr null, ptr %2, i64 1) + +// CHECK: define internal void @[[PAR_OUTLINED]]{{.*}} { +// CHECK: .omp.reduction.then: +// CHECK: br label %omp.reduction.nonatomic.body + +// CHECK: omp.reduction.nonatomic.body: +// CHECK: call void @bar() +// CHECK: br label %[[BODY_2ND_BB:.*]] + +// CHECK: [[BODY_2ND_BB]]: +// CHECK: call void @baz() +// CHECK: br label %[[CONT_BB:.*]] + +// CHECK: [[CONT_BB]]: +// CHECK: br label %.omp.reduction.done +// CHECK: } + +// CHECK: define internal void @"{{.*}}$reduction$reduction_func"(ptr noundef %0, ptr noundef %1) #0 { +// CHECK: br label %omp.reduction.nonatomic.body + +// CHECK: [[BODY_2ND_BB:.*]]: +// CHECK: call void @baz() +// CHECK: br label %omp.region.cont + + +// CHECK: omp.reduction.nonatomic.body: +// CHECK: call void @bar()
[llvm-branch-commits] [lldb] 113916c - [lldb][ClangASTImporter] Don't ASTImport LambdaExpr nodes (#154962)
Author: Michael Buch Date: 2025-09-08T09:33:25+02:00 New Revision: 113916ccf75f099da8c07fff29648acd3e6e7ab4 URL: https://github.com/llvm/llvm-project/commit/113916ccf75f099da8c07fff29648acd3e6e7ab4 DIFF: https://github.com/llvm/llvm-project/commit/113916ccf75f099da8c07fff29648acd3e6e7ab4.diff LOG: [lldb][ClangASTImporter] Don't ASTImport LambdaExpr nodes (#154962) This patch works around an assertion that we hit in the `LambdaExpr` constructor when we call it from `ASTNodeImporter::VisitLambdaExpr` (see https://github.com/llvm/llvm-project/issues/149477). The lambda that we imported doesn't have the `NumCaptures` field accurately set to the one on the source decl. This is because in `MinimalImport` mode, we skip importing of lambda definitions: https://github.com/llvm/llvm-project/blob/e21b0dd81928a3266df0e3ede008fb7a6676ff95/clang/lib/AST/ASTImporter.cpp#L2499 In practice we have seen this assertion occur in our `import-std-module` test-suite when libc++ headers decide to use lambdas inside inline function bodies (the latest failure being caused by https://github.com/llvm/llvm-project/pull/144602). To avoid running into this whenever libc++ decides to use lambdas in headers, this patch skips `ASTImport` of lambdas alltogether. Ideally this would bubble up to the user or log as an error, but we swallow the `ASTImportError`s currently. The only way this codepath is hit is when lambdas are used inside functions in defined in the expression evaluator, or when importing AST nodes from Clang modules. Both of these are very niche use-cases (for now), so a workaround seemed appropriate. (cherry picked from commit 0bbb79475432f72ee0e7d99cc5dc48bb8f8ff443) Added: lldb/test/Shell/Expr/TestLambdaExprImport.test Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp lldb/test/API/lang/cpp/lambdas/TestLambdas.py Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 2529e78f78bca..633b860b5784c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -1053,6 +1053,16 @@ ClangASTImporter::MapCompleter::~MapCompleter() = default; llvm::Expected ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) { + // FIXME: The Minimal import mode of clang::ASTImporter does not correctly + // import Lambda definitions. Work around this for now by not importing + // lambdas at all. This is most likely encountered when importing decls from + // the `std` module (not from debug-info), where lambdas can be defined in + // inline function bodies. Those will be imported by LLDB. + if (const auto *CXX = llvm::dyn_cast(From)) +if (CXX->isLambda()) + return llvm::make_error( + ASTImportError::UnsupportedConstruct); + if (m_std_handler) { std::optional D = m_std_handler->Import(From); if (D) { diff --git a/lldb/test/API/lang/cpp/lambdas/TestLambdas.py b/lldb/test/API/lang/cpp/lambdas/TestLambdas.py index c8308c16011e0..112f375c0ef2f 100644 --- a/lldb/test/API/lang/cpp/lambdas/TestLambdas.py +++ b/lldb/test/API/lang/cpp/lambdas/TestLambdas.py @@ -1,4 +1,12 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals()) +lldbinline.MakeInlineTest( +__file__, +globals(), +[ +decorators.expectedFailureAll( +bugnumber="https://github.com/llvm/llvm-project/issues/149477"; +) +], +) diff --git a/lldb/test/Shell/Expr/TestLambdaExprImport.test b/lldb/test/Shell/Expr/TestLambdaExprImport.test new file mode 100644 index 0..c57ce06453fe2 --- /dev/null +++ b/lldb/test/Shell/Expr/TestLambdaExprImport.test @@ -0,0 +1,26 @@ +# Test that we can successfully ASTImport clang::LambdaExpr nodes. +# Currently this is not supported in MinimalImport mode (which LLDB +# uses always). + +# RUN: split-file %s %t +# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out +# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \ +# RUN: -x -b -s %t/commands.input %t.out 2>&1 \ +# RUN: | FileCheck %s + +#--- main.cpp + +int main() { + __builtin_debugtrap(); +} + +#--- commands.input + +run +expression --top-level -- void method(int x) { [x=x] { ; }; } +target dump typesystem + +# CHECK: expression +# CHECK: target dump typesystem +# CHECK-NOT: FunctionDecl +# CHECK-NOT: LambdaExpr ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++][AIX] Fixup problems with ABI list checking (#155643) (PR #156502)
llvmbot wrote: @llvm/pr-subscribers-libcxx Author: None (llvmbot) Changes Backport b8456e2a9698aa927d7b3f9c38213f3219aa0498 Requested by: @amy-kwan --- Full diff: https://github.com/llvm/llvm-project/pull/156502.diff 2 Files Affected: - (modified) libcxx/lib/abi/CMakeLists.txt (+3) - (modified) libcxx/utils/libcxx/sym_check/util.py (+1-1) ``diff diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt index 7c08bd06c50b2..8f277aad2dcd5 100644 --- a/libcxx/lib/abi/CMakeLists.txt +++ b/libcxx/lib/abi/CMakeLists.txt @@ -16,6 +16,9 @@ function(cxx_abi_list_identifier result triple abi_library abi_version unstable elseif("${triple}" MATCHES "freebsd") # Ignore the major and minor versions of freebsd targets. string(REGEX REPLACE "freebsd[0-9]+\\.[0-9]+" "freebsd" triple "${triple}") + elseif("${triple}" MATCHES "aix") +# Ignore the V.R.M.F version string of aix targets. +string(REGEX REPLACE "aix[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" "aix" triple "${triple}") endif() list(APPEND abi_properties "${triple}") list(APPEND abi_properties "${abi_library}") diff --git a/libcxx/utils/libcxx/sym_check/util.py b/libcxx/utils/libcxx/sym_check/util.py index fc7ba4244ab5a..dbc886f29ddea 100644 --- a/libcxx/utils/libcxx/sym_check/util.py +++ b/libcxx/utils/libcxx/sym_check/util.py @@ -95,7 +95,7 @@ def is_xcoff_or_big_ar(filename): with open(filename, "rb") as f: magic_bytes = f.read(7) return ( -magic_bytes[:4] in [b"\x01DF", b"\x01F7"] # XCOFF32 # XCOFF64 +magic_bytes[:2] in [b"\x01\xDF", b"\x01\xF7"] # XCOFF32 # XCOFF64 or magic_bytes == b"" ) `` https://github.com/llvm/llvm-project/pull/156502 ___ 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] Prepare for split ZPR and PPR area allocation (NFCI) (PR #142391)
https://github.com/MacDue updated https://github.com/llvm/llvm-project/pull/142391 >From c8d07fa80c65e0a33f237bbe915b95faebfc58a4 Mon Sep 17 00:00:00 2001 From: Benjamin Maxwell Date: Thu, 8 May 2025 17:38:27 + Subject: [PATCH 1/9] [AArch64] Prepare for split ZPR and PPR area allocation (NFCI) This patch attempts to refactor AArch64FrameLowering to allow the size of the ZPR and PPR areas to be calculated separately. This will be used by a subsequent patch to support allocating ZPRs and PPRs to separate areas. This patch should be an NFC and is split out to make later functional changes easier to spot. --- .../Target/AArch64/AArch64FrameLowering.cpp | 304 -- .../lib/Target/AArch64/AArch64FrameLowering.h | 12 +- .../AArch64/AArch64MachineFunctionInfo.h | 61 ++-- .../Target/AArch64/AArch64RegisterInfo.cpp| 7 +- 4 files changed, 256 insertions(+), 128 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp index 649b1bb7b9297..e6cc739ee508a 100644 --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp @@ -330,10 +330,13 @@ static int64_t getArgumentStackToRestore(MachineFunction &MF, static bool produceCompactUnwindFrame(MachineFunction &MF); static bool needsWinCFI(const MachineFunction &MF); +static StackOffset getZPRStackSize(const MachineFunction &MF); +static StackOffset getPPRStackSize(const MachineFunction &MF); static StackOffset getSVEStackSize(const MachineFunction &MF); static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB, bool HasCall = false); static bool requiresSaveVG(const MachineFunction &MF); +static bool hasSVEStackSize(const MachineFunction &MF); // Conservatively, returns true if the function is likely to have SVE vectors // on the stack. This function is safe to be called before callee-saves or @@ -493,10 +496,36 @@ static unsigned getFixedObjectSize(const MachineFunction &MF, } } -/// Returns the size of the entire SVE stackframe (calleesaves + spills). +static unsigned getStackHazardSize(const MachineFunction &MF) { + return MF.getSubtarget().getStreamingHazardSize(); +} + +/// Returns the size of the entire ZPR stackframe (calleesaves + spills). +static StackOffset getZPRStackSize(const MachineFunction &MF) { + const AArch64FunctionInfo *AFI = MF.getInfo(); + return StackOffset::getScalable(AFI->getStackSizeZPR()); +} + +/// Returns the size of the entire PPR stackframe (calleesaves + spills). +static StackOffset getPPRStackSize(const MachineFunction &MF) { + const AArch64FunctionInfo *AFI = MF.getInfo(); + return StackOffset::getScalable(AFI->getStackSizePPR()); +} + +/// Returns the size of the entire SVE stackframe (PPRs + ZPRs). static StackOffset getSVEStackSize(const MachineFunction &MF) { + return getZPRStackSize(MF) + getPPRStackSize(MF); +} + +static bool hasSVEStackSize(const MachineFunction &MF) { const AArch64FunctionInfo *AFI = MF.getInfo(); - return StackOffset::getScalable((int64_t)AFI->getStackSizeSVE()); + return AFI->getStackSizeZPR() > 0 || AFI->getStackSizePPR() > 0; +} + +/// Returns true if PPRs are spilled as ZPRs. +static bool arePPRsSpilledAsZPR(const MachineFunction &MF) { + return MF.getSubtarget().getRegisterInfo()->getSpillSize( + AArch64::PPRRegClass) == 16; } bool AArch64FrameLowering::canUseRedZone(const MachineFunction &MF) const { @@ -524,7 +553,7 @@ bool AArch64FrameLowering::canUseRedZone(const MachineFunction &MF) const { !Subtarget.hasSVE(); return !(MFI.hasCalls() || hasFP(MF) || NumBytes > RedZoneSize || - getSVEStackSize(MF) || LowerQRegCopyThroughMem); + hasSVEStackSize(MF) || LowerQRegCopyThroughMem); } /// hasFPImpl - Return true if the specified function should have a dedicated @@ -1251,7 +1280,7 @@ bool AArch64FrameLowering::shouldCombineCSRLocalStackBump( // When there is an SVE area on the stack, always allocate the // callee-saves and spills/locals separately. - if (getSVEStackSize(MF)) + if (hasSVEStackSize(MF)) return false; return true; @@ -1697,25 +1726,19 @@ static bool isTargetWindows(const MachineFunction &MF) { return MF.getSubtarget().isTargetWindows(); } -static unsigned getStackHazardSize(const MachineFunction &MF) { - return MF.getSubtarget().getStreamingHazardSize(); -} - // Convenience function to determine whether I is an SVE callee save. -static bool IsSVECalleeSave(MachineBasicBlock::iterator I) { +static bool IsZPRCalleeSave(MachineBasicBlock::iterator I) { switch (I->getOpcode()) { default: return false; - case AArch64::PTRUE_C_B: case AArch64::LD1B_2Z_IMM: case AArch64::ST1B_2Z_IMM: case AArch64::STR_ZXI: - case AArch64::STR_PXI: case AArch64::LDR_ZXI: - case AArch64::LDR_PXI: - case AArch64::PTRUE_B: case AArch64
[llvm-branch-commits] [llvm] release/21.x: [SCEVExp] Fix early exit in ComputeEndCheck. (PR #157410)
https://github.com/fhahn approved this pull request. LGTM,thanks https://github.com/llvm/llvm-project/pull/157410 ___ 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] [LifetimeSafety] Add support for GSL Pointer types (PR #154009)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/154009 ___ 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] PPC: Use StringRef for subtarget constructor arguments (PR #157409)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/157409 ___ 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] release/21.x: [SCEVExp] Fix early exit in ComputeEndCheck. (PR #157410)
https://github.com/nikic milestoned https://github.com/llvm/llvm-project/pull/157410 ___ 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] release/21.x: [SCEVExp] Fix early exit in ComputeEndCheck. (PR #157410)
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/157410 Backport of: https://github.com/llvm/llvm-project/commit/a6148071300302b451ae92fbd8f8b955a6974891 https://github.com/llvm/llvm-project/commit/ec581e460ae92ef29c1ea4f200b36b79188fdd21 https://github.com/llvm/llvm-project/commit/f8972c8280d28660aaff888c093a9e01b9ee71e6 >From 4318653a981d4f938323fcfb4fd6f9de04e28563 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 4 Sep 2025 15:45:15 +0100 Subject: [PATCH 1/3] [LV] Add more tests for interleave groups requiring predicates. Adds tests for https://github.com/llvm/llvm-project/issues/156849. Also tidies up the existing related test a bit. (cherry picked from commit a6148071300302b451ae92fbd8f8b955a6974891) --- .../LoopVectorize/interleaved-accesses-3.ll | 124 - ...aved-accesses-requiring-scev-predicates.ll | 242 ++ 2 files changed, 242 insertions(+), 124 deletions(-) delete mode 100644 llvm/test/Transforms/LoopVectorize/interleaved-accesses-3.ll create mode 100644 llvm/test/Transforms/LoopVectorize/interleaved-accesses-requiring-scev-predicates.ll diff --git a/llvm/test/Transforms/LoopVectorize/interleaved-accesses-3.ll b/llvm/test/Transforms/LoopVectorize/interleaved-accesses-3.ll deleted file mode 100644 index 661e8eb666d54..0 --- a/llvm/test/Transforms/LoopVectorize/interleaved-accesses-3.ll +++ /dev/null @@ -1,124 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 -; RUN: opt -S -passes=loop-vectorize,instcombine -force-vector-width=4 -force-vector-interleave=1 -enable-interleaved-mem-accesses=true < %s | FileCheck %s - -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" - -; Check that the interleaved-mem-access analysis currently does not create an -; interleave group for access 'a' due to the possible pointer wrap-around. -; -; To begin with, in this test the candidate interleave group can be created -; only when getPtrStride is called with Assume=true. Next, because -; the interleave-group of the loads is not full (has gaps), we also need to check -; for possible pointer wrapping. Here we currently use Assume=false and as a -; result cannot prove the transformation is safe and therefore invalidate the -; candidate interleave group. -; - -; void func(unsigned * __restrict a, unsigned * __restrict b, unsigned char x, unsigned char y) { -; int i = 0; -; for (unsigned char index = x; i < y; index +=2, ++i) -;b[i] = aptr 2; -; -; } - -define void @_Z4funcPjS_hh(ptr noalias nocapture readonly %a, ptr noalias nocapture %b, i8 zeroext %x, i8 zeroext %y) local_unnamed_addr { -; CHECK-LABEL: define void @_Z4funcPjS_hh( -; CHECK-SAME: ptr noalias readonly captures(none) [[A:%.*]], ptr noalias captures(none) [[B:%.*]], i8 zeroext [[X:%.*]], i8 zeroext [[Y:%.*]]) local_unnamed_addr { -; CHECK-NEXT: [[ENTRY:.*:]] -; CHECK-NEXT:[[CMP9:%.*]] = icmp eq i8 [[Y]], 0 -; CHECK-NEXT:br i1 [[CMP9]], label %[[FOR_COND_CLEANUP:.*]], label %[[FOR_BODY_PREHEADER:.*]] -; CHECK: [[FOR_BODY_PREHEADER]]: -; CHECK-NEXT:[[WIDE_TRIP_COUNT:%.*]] = zext i8 [[Y]] to i64 -; CHECK-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i8 [[Y]], 5 -; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_SCEVCHECK:.*]] -; CHECK: [[VECTOR_SCEVCHECK]]: -; CHECK-NEXT:[[TMP0:%.*]] = add nsw i64 [[WIDE_TRIP_COUNT]], -1 -; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[TMP0]] to i8 -; CHECK-NEXT:[[MUL_RESULT:%.*]] = shl i8 [[TMP1]], 1 -; CHECK-NEXT:[[TMP2:%.*]] = xor i8 [[X]], -1 -; CHECK-NEXT:[[TMP3:%.*]] = icmp ugt i8 [[MUL_RESULT]], [[TMP2]] -; CHECK-NEXT:[[TMP4:%.*]] = icmp ugt i64 [[TMP0]], 127 -; CHECK-NEXT:[[TMP5:%.*]] = or i1 [[TMP3]], [[TMP4]] -; CHECK-NEXT:br i1 [[TMP5]], label %[[SCALAR_PH]], label %[[VECTOR_PH:.*]] -; CHECK: [[VECTOR_PH]]: -; CHECK-NEXT:[[N_MOD_VF:%.*]] = and i64 [[WIDE_TRIP_COUNT]], 3 -; CHECK-NEXT:[[TMP8:%.*]] = icmp eq i64 [[N_MOD_VF]], 0 -; CHECK-NEXT:[[TMP7:%.*]] = select i1 [[TMP8]], i64 4, i64 [[N_MOD_VF]] -; CHECK-NEXT:[[N_VEC:%.*]] = sub nsw i64 [[WIDE_TRIP_COUNT]], [[TMP7]] -; CHECK-NEXT:[[DOTCAST:%.*]] = trunc i64 [[N_VEC]] to i8 -; CHECK-NEXT:[[TMP6:%.*]] = shl i8 [[DOTCAST]], 1 -; CHECK-NEXT:[[IND_END:%.*]] = add i8 [[X]], [[TMP6]] -; CHECK-NEXT:br label %[[VECTOR_BODY:.*]] -; CHECK: [[VECTOR_BODY]]: -; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ] -; CHECK-NEXT:[[DOTCAST3:%.*]] = trunc i64 [[INDEX]] to i8 -; CHECK-NEXT:[[TMP9:%.*]] = shl i8 [[DOTCAST3]], 1 -; CHECK-NEXT:[[OFFSET_IDX:%.*]] = add i8 [[X]], [[TMP9]] -; CHECK-NEXT:[[TMP14:%.*]] = zext i8 [[OFFSET_IDX]] to i64 -; CHECK-NEXT:[[TMP15:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP14]] -; CHECK-NEXT:[[WIDE_VEC:%.*]] = load <8 x i32>, ptr [[TMP15]], align 4 -; CHECK-NEXT:
[llvm-branch-commits] [llvm] release/21.x: [SCEVExp] Fix early exit in ComputeEndCheck. (PR #157410)
llvmbot wrote: @llvm/pr-subscribers-llvm-transforms Author: Nikita Popov (nikic) Changes Backport of: https://github.com/llvm/llvm-project/commit/a6148071300302b451ae92fbd8f8b955a6974891 https://github.com/llvm/llvm-project/commit/ec581e460ae92ef29c1ea4f200b36b79188fdd21 https://github.com/llvm/llvm-project/commit/f8972c8280d28660aaff888c093a9e01b9ee71e6 --- Patch is 31.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/157410.diff 7 Files Affected: - (modified) llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp (+9-2) - (modified) llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll (+14-4) - (modified) llvm/test/Transforms/LoopVectorize/X86/cost-model.ll (+3-2) - (removed) llvm/test/Transforms/LoopVectorize/interleaved-accesses-3.ll (-124) - (added) llvm/test/Transforms/LoopVectorize/interleaved-accesses-requiring-scev-predicates.ll (+258) - (modified) llvm/test/Transforms/LoopVectorize/runtime-check-small-clamped-bounds.ll (+3) - (modified) llvm/test/Transforms/LoopVersioning/wrapping-pointer-versioning.ll (+7-2) ``diff diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 24fe08d6c3e4e..bf457194bfd8e 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -2133,8 +2133,15 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR, // negative. If Step is known to be positive or negative, only create // either 1. or 2. auto ComputeEndCheck = [&]() -> Value * { -// Checking isZero() && SE.isKnownPositive(Step)) +// Checking isZero() && SE.isKnownPositive(Step) && +DstBits < SrcBits && +ExitCount == SE.getZeroExtendExpr(SE.getTruncateExpr(ExitCount, ARTy), + ExitCount->getType()) && +SE.willNotOverflow(Instruction::Mul, Signed, Step, + SE.getTruncateExpr(ExitCount, ARTy))) return ConstantInt::getFalse(Loc->getContext()); // Get the backedge taken count and truncate or extended to the AR type. diff --git a/llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll b/llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll index 98b89abfeafda..057a60918ecf3 100644 --- a/llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll +++ b/llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll @@ -10,8 +10,13 @@ define void @f(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d, p ; CHECK-NEXT:br label [[FOR_BODY_LVER_CHECK:%.*]] ; CHECK: for.body.lver.check: ; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[N:%.*]], -1 +; CHECK-NEXT:[[TMP2:%.*]] = trunc i64 [[TMP0]] to i32 +; CHECK-NEXT:[[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP2]]) +; CHECK-NEXT:[[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0 +; CHECK-NEXT:[[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1 ; CHECK-NEXT:[[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 4294967295 -; CHECK-NEXT:br i1 [[TMP1]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH_LDIST1:%.*]] +; CHECK-NEXT:[[TMP3:%.*]] = or i1 [[MUL_OVERFLOW]], [[TMP1]] +; CHECK-NEXT:br i1 [[TMP3]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH_LDIST1:%.*]] ; CHECK: for.body.ph.lver.orig: ; CHECK-NEXT:br label [[FOR_BODY_LVER_ORIG:%.*]] ; CHECK: for.body.lver.orig: @@ -75,7 +80,7 @@ define void @f(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d, p ; CHECK-NEXT:br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT2:%.*]], label [[FOR_BODY]] ; CHECK: for.end.loopexit: ; CHECK-NEXT:br label [[FOR_END:%.*]] -; CHECK: for.end.loopexit1: +; CHECK: for.end.loopexit2: ; CHECK-NEXT:br label [[FOR_END]] ; CHECK: for.end: ; CHECK-NEXT:ret void @@ -135,8 +140,13 @@ define void @f_with_offset(ptr noalias %b, ptr noalias %c, ptr noalias %d, ptr n ; CHECK-NEXT:br label [[FOR_BODY_LVER_CHECK:%.*]] ; CHECK: for.body.lver.check: ; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[N:%.*]], -1 +; CHECK-NEXT:[[TMP2:%.*]] = trunc i64 [[TMP0]] to i32 +; CHECK-NEXT:[[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP2]]) +; CHECK-NEXT:[[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0 +; CHECK-NEXT:[[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1 ; CHECK-NEXT:[[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 4294967295 -; CHECK-NEXT:br i1 [[TMP1]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH_LDIST1:%.*]] +; CHECK-NEXT:[[TMP3:%.*]] = or i1 [[MUL_OVERFLOW]], [[TMP1]] +; CHECK-NEXT:br i1 [[TMP3]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH_LDIST1:%.*]] ; CHECK: for.body.ph.lver.orig: ; CHECK-NEXT:br label [[FOR_BODY_LV
[llvm-branch-commits] [flang] [flang][OpenMP] `do concurrent` to device mapping lit tests (PR #155992)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/155992 >From db09d54306271dfc2bf5b3d9a11b94c3d13c6787 Mon Sep 17 00:00:00 2001 From: ergawy Date: Fri, 29 Aug 2025 03:53:51 -0500 Subject: [PATCH] [flang][OpenMP] `do concurrent` to device mapping lit tests Adds more lit tests for `do concurrent` device mapping. --- .../Transforms/DoConcurrent/allocatable.f90 | 29 + .../Transforms/DoConcurrent/host_eval.f90 | 63 +++ .../DoConcurrent/locally_destroyed_temp.f90 | 43 --- .../DoConcurrent/map_shape_info.f90 | 104 + .../multiple_iteration_ranges.f90 | 106 +++--- .../DoConcurrent/non_reference_to_device.f90 | 34 ++ .../DoConcurrent/not_perfectly_nested.f90 | 66 +++ .../DoConcurrent/runtime_sized_array.f90 | 42 +++ .../DoConcurrent/skip_all_nested_loops.f90| 68 +++ 9 files changed, 478 insertions(+), 77 deletions(-) create mode 100644 flang/test/Transforms/DoConcurrent/allocatable.f90 create mode 100644 flang/test/Transforms/DoConcurrent/host_eval.f90 create mode 100644 flang/test/Transforms/DoConcurrent/map_shape_info.f90 create mode 100644 flang/test/Transforms/DoConcurrent/non_reference_to_device.f90 create mode 100644 flang/test/Transforms/DoConcurrent/runtime_sized_array.f90 create mode 100644 flang/test/Transforms/DoConcurrent/skip_all_nested_loops.f90 diff --git a/flang/test/Transforms/DoConcurrent/allocatable.f90 b/flang/test/Transforms/DoConcurrent/allocatable.f90 new file mode 100644 index 0..03962f150eb95 --- /dev/null +++ b/flang/test/Transforms/DoConcurrent/allocatable.f90 @@ -0,0 +1,29 @@ +! Verifies that proper `omp.map.bounds` ops are emitted when an allocatable is +! implicitly mapped by a `do concurrent` loop. + +! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=device %s -o - \ +! RUN: | FileCheck %s +program main + implicit none + + integer,parameter :: n = 100 + real, allocatable, dimension(:) :: y + integer :: i + + allocate(y(1:n)) + + do concurrent(i=1:n) + y(i) = 42 + end do + + deallocate(y) +end program main + +! CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEy"} +! CHECK: %[[Y_VAL:.*]] = fir.load %[[Y_DECL]]#0 +! CHECK: %[[Y_DIM0:.*]]:3 = fir.box_dims %[[Y_VAL]], %{{c0_.*}} +! CHECK: %[[Y_LB:.*]] = arith.constant 0 : index +! CHECK: %[[Y_UB:.*]] = arith.subi %[[Y_DIM0]]#1, %{{c1_.*}} : index +! CHECK: %[[Y_BOUNDS:.*]] = omp.map.bounds lower_bound(%[[Y_LB]] : index) upper_bound(%[[Y_UB]] : index) extent(%[[Y_DIM0]]#1 : index) +! CHECK: %[[MEM_MAP:.*]] = omp.map.info {{.*}} bounds(%[[Y_BOUNDS]]) +! CHECK: omp.map.info var_ptr(%[[Y_DECL]]#1 : {{.*}}) {{.*}} members(%[[MEM_MAP]] : {{.*}}) diff --git a/flang/test/Transforms/DoConcurrent/host_eval.f90 b/flang/test/Transforms/DoConcurrent/host_eval.f90 new file mode 100644 index 0..7d16a91ae6941 --- /dev/null +++ b/flang/test/Transforms/DoConcurrent/host_eval.f90 @@ -0,0 +1,63 @@ +! Tests `host_eval` clause code-gen and loop nest bounds on host vs. device. + +! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \ +! RUN: -fdo-concurrent-to-openmp=device %s -o - \ +! RUN: | FileCheck %s --check-prefix=HOST -vv + +! RUN: %flang_fc1 -triple amdgcn-amd-amdhsa -emit-hlfir -fopenmp\ +! RUN: -fopenmp-is-target-device -fdo-concurrent-to-openmp=device %s -o - \ +! RUN: | FileCheck %s --check-prefix=DEVICE + +program do_concurrent_host_eval +implicit none +integer :: i, j + +do concurrent (i=1:10, j=1:20) +end do +end program do_concurrent_host_eval + +! HOST: omp.target host_eval( +! HOST-SAME:%{{[^[:space:]]+}} -> %[[I_LB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[I_UB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[I_ST:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[J_LB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[J_UB:[^,]+]], +! HOST-SAME:%{{[^[:space:]]+}} -> %[[J_ST:[^,]+]] : {{.*}}) map_entries + +! HOST: omp.loop_nest ({{.*}}, {{.*}}) : index = (%[[I_LB]], %[[J_LB]]) to +! HOST-SAME:(%[[I_UB]], %[[J_UB]]) inclusive step +! HOST-SAME:(%[[I_ST]], %[[J_ST]]) + +! DEVICE: omp.target map_entries( +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_LB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_UB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_ST_MAP:[^,]+]], + +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_LB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_UB_MAP:[^,]+]], +! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_ST_MAP:[^,]+]], + +! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}}, +! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}} : {{.*}}) + +! DEVICE: %[[I_LB_DECL:.*]]:2 = hlfir.declare %[[I_LB_MAP]] +! DEVICE: %[[I_LB:.*]] = fir.load %[[I_LB_DECL]]#1 : !fir.ref + +! DEVICE: %[[I_UB_DECL:.*]]:2 = hlfir.declare %[[I_UB_MAP]
[llvm-branch-commits] [llvm] PPC: Split 64bit target feature into 64bit and 64bit-support (PR #157206)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/157206 >From 0d4d26ae9d6ee802c46d8115ccee28a9470aaced Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 6 Sep 2025 08:50:20 +0900 Subject: [PATCH] PPC: Split 64bit target feature into 64bit and 64bit-support This was being used for 2 different purposes. The TargetMachine constructor prepends +64bit based on isPPC64 triples as a mode switch. The same feature name was also explicitly added to different processors, making it impossible to perform a pure feature check for whether 64-bit mode is enabled ir not. i.e., checkFeatures("+64bit") would be true even for ppc32 triples. The comment in tablegen suggests it's relevant to track which processors support 64-bit mode independently of whether that's the active compile target, so replace that with a new feature. --- llvm/lib/Target/PowerPC/PPC.td | 33 ++-- llvm/lib/Target/PowerPC/PPCSubtarget.cpp | 7 ++--- llvm/lib/Target/PowerPC/PPCSubtarget.h | 5 llvm/test/CodeGen/PowerPC/i64_fp.ll | 8 +++--- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPC.td b/llvm/lib/Target/PowerPC/PPC.td index db6427cfe8482..386d0f65d1ed1 100644 --- a/llvm/lib/Target/PowerPC/PPC.td +++ b/llvm/lib/Target/PowerPC/PPC.td @@ -58,8 +58,13 @@ def DirectivePwrFuture // Specifies that the selected CPU supports 64-bit instructions, regardless of // whether we are in 32-bit or 64-bit mode. -def Feature64Bit : SubtargetFeature<"64bit","Has64BitSupport", "true", -"Enable 64-bit instructions">; +def Feature64BitSupport : SubtargetFeature<"64bit-support", "Has64BitSupport", "true", +"Supports 64-bit instructions">; +// 64-bit is enabled. +def Feature64Bit : SubtargetFeature<"64bit", "IsPPC64", "true", +"Enable 64-bit mode", +[Feature64BitSupport]>; + def AIXOS: SubtargetFeature<"aix", "IsAIX", "true", "AIX OS">; def FeatureModernAIXAs : SubtargetFeature<"modern-aix-as", "HasModernAIXAs", "true", @@ -85,7 +90,7 @@ def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", "true", def FeatureSPE : SubtargetFeature<"spe","HasSPE", "true", "Enable SPE instructions", [FeatureHardFloat]>; -def FeatureEFPU2 : SubtargetFeature<"efpu2", "HasEFPU2", "true", +def FeatureEFPU2 : SubtargetFeature<"efpu2", "HasEFPU2", "true", "Enable Embedded Floating-Point APU 2 instructions", [FeatureSPE]>; def FeatureMFOCRF: SubtargetFeature<"mfocrf","HasMFOCRF", "true", @@ -429,7 +434,7 @@ def ProcessorFeatures { FeaturePOPCNTD, FeatureCMPB, FeatureLDBRX, - Feature64Bit, + Feature64BitSupport, /* Feature64BitRegs, */ FeatureBPERMD, FeatureExtDiv, @@ -667,13 +672,13 @@ def : ProcessorModel<"970", G5Model, [Directive970, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureFRES, FeatureFRSQRTE, FeatureSTFIWX, - Feature64Bit /*, Feature64BitRegs */, + Feature64BitSupport /*, Feature64BitRegs */, FeatureMFTB]>; def : ProcessorModel<"g5", G5Model, [Directive970, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX, FeatureFRES, FeatureFRSQRTE, - Feature64Bit /*, Feature64BitRegs */, + Feature64BitSupport /*, Feature64BitRegs */, FeatureMFTB, DeprecatedDST]>; def : ProcessorModel<"e500", PPCE500Model, [DirectiveE500, @@ -694,41 +699,41 @@ def : ProcessorModel<"a2", PPCA2Model, FeatureSTFIWX, FeatureLFIWAX, FeatureFPRND, FeatureFPCVT, FeatureISEL, FeatureSlowPOPCNTD, FeatureCMPB, FeatureLDBRX, - Feature64Bit /*, Feature64BitRegs */, FeatureMFTB, + Feature64BitSupport /*, Feature64BitRegs */, FeatureMFTB, FeatureISA2_06]>; def : ProcessorModel<"pwr3", G5Model, [DirectivePwr3, FeatureAltivec, FeatureFRES, FeatureFRSQRTE, FeatureMFOCRF, - FeatureSTFIWX, Feature64Bit]>; + FeatureSTFIWX, Feature64BitSupport]>; def : ProcessorModel<"pwr4", G5Model,
[llvm-branch-commits] [compiler-rt] release/21.x: compiler-rt: Use OpenBSD's elf_aux_info to detect AArch64 HW features (#155768) (PR #155899)
tru wrote: ping https://github.com/llvm/llvm-project/pull/155899 ___ 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] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113152 >From d8bcbde876239223fac3190faf13fe2503a4f4ec Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 12:18:56 +0300 Subject: [PATCH 1/8] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin Most ptrauth flags are ABI-affecting, so they should not be exposed to end users. Under certain conditions, some ptrauth driver flags are intended to be used for ARM64 Darwin, so allow them in this case. Leave `-faarch64-jump-table-hardening` available for all AArch64 targets since it's not ABI-affecting. --- clang/lib/Driver/ToolChains/Clang.cpp | 28 - clang/lib/Driver/ToolChains/Linux.cpp | 53 ++--- clang/test/Driver/aarch64-ptrauth.c | 164 -- 3 files changed, 135 insertions(+), 110 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 42368e7d8ef7e..7cb609b5c000b 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1665,34 +1665,6 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, AddUnalignedAccessWarning(CmdArgs); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_intrinsics, -options::OPT_fno_ptrauth_intrinsics); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_calls, -options::OPT_fno_ptrauth_calls); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_returns, -options::OPT_fno_ptrauth_returns); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_auth_traps, -options::OPT_fno_ptrauth_auth_traps); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_vtable_pointer_address_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_address_discrimination); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_vtable_pointer_type_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_type_discrimination); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_type_info_vtable_pointer_discrimination, - options::OPT_fno_ptrauth_type_info_vtable_pointer_discrimination); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_function_pointer_type_discrimination, - options::OPT_fno_ptrauth_function_pointer_type_discrimination); - - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_indirect_gotos, -options::OPT_fno_ptrauth_indirect_gotos); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_init_fini, -options::OPT_fno_ptrauth_init_fini); - Args.addOptInFlag(CmdArgs, -options::OPT_fptrauth_init_fini_address_discrimination, -options::OPT_fno_ptrauth_init_fini_address_discrimination); Args.addOptInFlag(CmdArgs, options::OPT_faarch64_jump_table_hardening, options::OPT_fno_aarch64_jump_table_hardening); diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index 04a8ad1d165d4..1e93b3aafbf47 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -484,49 +484,16 @@ std::string Linux::ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, // options represent the default signing schema. static void handlePAuthABI(const Driver &D, const ArgList &DriverArgs, ArgStringList &CC1Args) { - if (!DriverArgs.hasArg(options::OPT_fptrauth_intrinsics, - options::OPT_fno_ptrauth_intrinsics)) -CC1Args.push_back("-fptrauth-intrinsics"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_calls, - options::OPT_fno_ptrauth_calls)) -CC1Args.push_back("-fptrauth-calls"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_returns, - options::OPT_fno_ptrauth_returns)) -CC1Args.push_back("-fptrauth-returns"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_auth_traps, - options::OPT_fno_ptrauth_auth_traps)) -CC1Args.push_back("-fptrauth-auth-traps"); - - if (!DriverArgs.hasArg( - options::OPT_fptrauth_vtable_pointer_address_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_address_discrimination)) -CC1Args.push_back("-fptrauth-vtable-pointer-address-discrimination"); - - if (!DriverArgs.hasArg( - options::OPT_fptrauth_vtable_pointer_type_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_type_discrimination)) -CC1Args.push_back("-fptrauth-vtable-pointer-type-discrimination"); - - if (!DriverArgs.hasArg( - options::OPT_fptrauth_type_info_vtable_pointer_discrimination, - options::OPT_fno_ptrauth_type_info_vtable_pointer_discrimination)) -CC1Args.push_back("-fptrauth-type-info-vtable-pointer-discrimination"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_indirect_gotos, - options::OPT_fno_ptrauth_indirect_gotos)) -CC1Args.
[llvm-branch-commits] [clang] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin or with pauthtest ABI (PR #113152)
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113152 >From d8bcbde876239223fac3190faf13fe2503a4f4ec Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 12:18:56 +0300 Subject: [PATCH 1/8] [PAC][Driver] Support ptrauth flags only on ARM64 Darwin Most ptrauth flags are ABI-affecting, so they should not be exposed to end users. Under certain conditions, some ptrauth driver flags are intended to be used for ARM64 Darwin, so allow them in this case. Leave `-faarch64-jump-table-hardening` available for all AArch64 targets since it's not ABI-affecting. --- clang/lib/Driver/ToolChains/Clang.cpp | 28 - clang/lib/Driver/ToolChains/Linux.cpp | 53 ++--- clang/test/Driver/aarch64-ptrauth.c | 164 -- 3 files changed, 135 insertions(+), 110 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 42368e7d8ef7e..7cb609b5c000b 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1665,34 +1665,6 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, AddUnalignedAccessWarning(CmdArgs); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_intrinsics, -options::OPT_fno_ptrauth_intrinsics); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_calls, -options::OPT_fno_ptrauth_calls); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_returns, -options::OPT_fno_ptrauth_returns); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_auth_traps, -options::OPT_fno_ptrauth_auth_traps); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_vtable_pointer_address_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_address_discrimination); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_vtable_pointer_type_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_type_discrimination); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_type_info_vtable_pointer_discrimination, - options::OPT_fno_ptrauth_type_info_vtable_pointer_discrimination); - Args.addOptInFlag( - CmdArgs, options::OPT_fptrauth_function_pointer_type_discrimination, - options::OPT_fno_ptrauth_function_pointer_type_discrimination); - - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_indirect_gotos, -options::OPT_fno_ptrauth_indirect_gotos); - Args.addOptInFlag(CmdArgs, options::OPT_fptrauth_init_fini, -options::OPT_fno_ptrauth_init_fini); - Args.addOptInFlag(CmdArgs, -options::OPT_fptrauth_init_fini_address_discrimination, -options::OPT_fno_ptrauth_init_fini_address_discrimination); Args.addOptInFlag(CmdArgs, options::OPT_faarch64_jump_table_hardening, options::OPT_fno_aarch64_jump_table_hardening); diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index 04a8ad1d165d4..1e93b3aafbf47 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -484,49 +484,16 @@ std::string Linux::ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, // options represent the default signing schema. static void handlePAuthABI(const Driver &D, const ArgList &DriverArgs, ArgStringList &CC1Args) { - if (!DriverArgs.hasArg(options::OPT_fptrauth_intrinsics, - options::OPT_fno_ptrauth_intrinsics)) -CC1Args.push_back("-fptrauth-intrinsics"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_calls, - options::OPT_fno_ptrauth_calls)) -CC1Args.push_back("-fptrauth-calls"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_returns, - options::OPT_fno_ptrauth_returns)) -CC1Args.push_back("-fptrauth-returns"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_auth_traps, - options::OPT_fno_ptrauth_auth_traps)) -CC1Args.push_back("-fptrauth-auth-traps"); - - if (!DriverArgs.hasArg( - options::OPT_fptrauth_vtable_pointer_address_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_address_discrimination)) -CC1Args.push_back("-fptrauth-vtable-pointer-address-discrimination"); - - if (!DriverArgs.hasArg( - options::OPT_fptrauth_vtable_pointer_type_discrimination, - options::OPT_fno_ptrauth_vtable_pointer_type_discrimination)) -CC1Args.push_back("-fptrauth-vtable-pointer-type-discrimination"); - - if (!DriverArgs.hasArg( - options::OPT_fptrauth_type_info_vtable_pointer_discrimination, - options::OPT_fno_ptrauth_type_info_vtable_pointer_discrimination)) -CC1Args.push_back("-fptrauth-type-info-vtable-pointer-discrimination"); - - if (!DriverArgs.hasArg(options::OPT_fptrauth_indirect_gotos, - options::OPT_fno_ptrauth_indirect_gotos)) -CC1Args.
[llvm-branch-commits] [clang] [PAC][clang] Handle pauthtest environment and ABI in Linux-specific code (PR #113151)
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/113151 >From 7af8e3d4514626ca2dacde8cbaa33d568b1f4aed Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Mon, 21 Oct 2024 12:00:19 +0300 Subject: [PATCH] [PAC][clang] Handle pauthtest environment and ABI in Linux-specific code Since pauthtest is a Linux-specific ABI, it should not be handled in common driver code. --- clang/lib/Basic/Targets/AArch64.cpp | 9 +- clang/lib/Basic/Targets/AArch64.h| 11 +++ clang/lib/Basic/Targets/OSTargets.cpp| 1 + clang/lib/Basic/Targets/OSTargets.h | 6 ++ clang/lib/CodeGen/CodeGenModule.cpp | 2 - clang/lib/CodeGen/TargetInfo.h | 1 - clang/lib/Driver/ToolChain.cpp | 1 - clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 21 - clang/lib/Driver/ToolChains/Arch/AArch64.h | 2 - clang/lib/Driver/ToolChains/Clang.cpp| 62 ++--- clang/lib/Driver/ToolChains/Linux.cpp| 96 clang/lib/Driver/ToolChains/Linux.h | 7 ++ clang/test/Driver/aarch64-ptrauth.c | 34 +-- 13 files changed, 153 insertions(+), 100 deletions(-) diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 9e03a0846ffba..fef26d3b8f328 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -206,8 +206,7 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple, StringRef AArch64TargetInfo::getABI() const { return ABI; } bool AArch64TargetInfo::setABI(const std::string &Name) { - if (Name != "aapcs" && Name != "aapcs-soft" && Name != "darwinpcs" && - Name != "pauthtest") + if (Name != "aapcs" && Name != "aapcs-soft" && Name != "darwinpcs") return false; ABI = Name; @@ -221,12 +220,6 @@ bool AArch64TargetInfo::validateTarget(DiagnosticsEngine &Diags) const { Diags.Report(diag::err_target_unsupported_abi_with_fpu) << ABI; return false; } - if (getTriple().getEnvironment() == llvm::Triple::PAuthTest && - getTriple().getOS() != llvm::Triple::Linux) { -Diags.Report(diag::err_target_unsupported_abi_for_triple) -<< getTriple().getEnvironmentName() << getTriple().getTriple(); -return false; - } return true; } diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index dfd89b2f3..dda8b745ff175 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -135,6 +135,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A; +protected: std::string ABI; public: @@ -277,6 +278,16 @@ class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo { void setDataLayout() override; }; +template <> +inline bool +LinuxTargetInfo::setABI(const std::string &Name) { + if (Name == "pauthtest") { +ABI = Name; +return true; + } + return AArch64leTargetInfo::setABI(Name); +} + class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo : public WindowsTargetInfo { const llvm::Triple Triple; diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp index e744e84a5b079..e99bbd159929c 100644 --- a/clang/lib/Basic/Targets/OSTargets.cpp +++ b/clang/lib/Basic/Targets/OSTargets.cpp @@ -10,6 +10,7 @@ //===--===// #include "OSTargets.h" +#include "AArch64.h" #include "clang/Basic/MacroBuilder.h" #include "llvm/ADT/StringRef.h" diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index a733f6e97b3a4..82c87847a31d8 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -396,6 +396,12 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo { const char *getStaticInitSectionSpecifier() const override { return ".text.startup"; } + + // This allows template specializations, see + // LinuxTargetInfo::setABI + bool setABI(const std::string &Name) override { +return OSTargetInfo::setABI(Name); + } }; // Managarm Target diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c0cfc24f02877..779e16fc18e59 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -145,8 +145,6 @@ createTargetCodeGenInfo(CodeGenModule &CGM) { return createWindowsAArch64TargetCodeGenInfo(CGM, AArch64ABIKind::Win64); else if (Target.getABI() == "aapcs-soft") Kind = AArch64ABIKind::AAPCSSoft; -else if (Target.getABI() == "pauthtest") - Kind = AArch64ABIKind::PAuthTest; return createAArch64TargetCodeGenInfo(CGM, Kind); } diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index d0edae1295094..f63e900669d97 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clan
[llvm-branch-commits] [llvm] [MC] Rewrite stdin.s to use python (PR #157232)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157232 >From d749f30964e57caa797b3df87ae88ffc3d4a2f54 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sun, 7 Sep 2025 17:39:19 + Subject: [PATCH 1/2] feedback Created using spr 1.3.6 --- llvm/test/MC/COFF/stdin.py | 17 + llvm/test/MC/COFF/stdin.s | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 llvm/test/MC/COFF/stdin.py delete mode 100644 llvm/test/MC/COFF/stdin.s diff --git a/llvm/test/MC/COFF/stdin.py b/llvm/test/MC/COFF/stdin.py new file mode 100644 index 0..8b7b6ae1fba13 --- /dev/null +++ b/llvm/test/MC/COFF/stdin.py @@ -0,0 +1,17 @@ +# RUN: echo "// comment" > %t.input +# RUN: which llvm-mc | %python %s %t + +import subprocess +import sys + +llvm_mc_binary = sys.stdin.readlines()[0].strip() +temp_file = sys.argv[1] +input_file = temp_file + ".input" + +with open(temp_file, "w") as mc_stdout: +mc_stdout.seek(4) +subprocess.run( +[llvm_mc_binary, "-filetype=obj", "-triple", "i686-pc-win32", input_file], +stdout=mc_stdout, +check=True, +) diff --git a/llvm/test/MC/COFF/stdin.s b/llvm/test/MC/COFF/stdin.s deleted file mode 100644 index 8ceae7fdef501..0 --- a/llvm/test/MC/COFF/stdin.s +++ /dev/null @@ -1 +0,0 @@ -// RUN: bash -c '(echo "test"; llvm-mc -filetype=obj -triple i686-pc-win32 %s ) > %t' >From 0bfe954d4cd5edf4312e924c278c59e57644d5f1 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Mon, 8 Sep 2025 17:28:59 + Subject: [PATCH 2/2] feedback Created using spr 1.3.6 --- llvm/test/MC/COFF/stdin.py | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/test/MC/COFF/stdin.py b/llvm/test/MC/COFF/stdin.py index 8b7b6ae1fba13..1d9b50c022523 100644 --- a/llvm/test/MC/COFF/stdin.py +++ b/llvm/test/MC/COFF/stdin.py @@ -1,14 +1,22 @@ # RUN: echo "// comment" > %t.input # RUN: which llvm-mc | %python %s %t +import argparse import subprocess import sys +parser = argparse.ArgumentParser() +parser.add_argument("temp_file") +arguments = parser.parse_args() + llvm_mc_binary = sys.stdin.readlines()[0].strip() -temp_file = sys.argv[1] +temp_file = arguments.temp_file input_file = temp_file + ".input" with open(temp_file, "w") as mc_stdout: +## We need to test that starting on an input stream with a non-zero offset +## does not trigger an assertion in WinCOFFObjectWriter.cpp, so we seek +## past zero for STDOUT. mc_stdout.seek(4) subprocess.run( [llvm_mc_binary, "-filetype=obj", "-triple", "i686-pc-win32", input_file], ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [MC] Rewrite stdin.s to use python (PR #157232)
@@ -0,0 +1,17 @@ +# RUN: echo "// comment" > %t.input +# RUN: which llvm-mc | %python %s %t + +import subprocess +import sys + +llvm_mc_binary = sys.stdin.readlines()[0].strip() +temp_file = sys.argv[1] boomanaiden154 wrote: Python doesn't include the interpreter in `sys.argv`: ``` aidengrossman-mac2:build aidengrossman$ python3 /tmp/test.py hello ['/tmp/test.py', 'hello'] aidengrossman-mac2:build aidengrossman$ cat /tmp/test.py import sys print(sys.argv) aidengrossman-mac2:build aidengrossman$ ``` Point taken about `argparse` though. I'll wire that up. https://github.com/llvm/llvm-project/pull/157232 ___ 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] [lldb] release/21.x: [lldb][DWARFASTParserClang] Don't complete conflicting Objective-C++ types (#156681) (PR #156764)
github-actions[bot] wrote: @Michael137 (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/156764 ___ 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] release/21.x: [DebugInfo] When referencing structured bindings use the reference's location, not the binding's declaration's location (#153637) (PR #156664)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/156664 >From b4274c3bc8eee764ad048c77b9a4baa12eb708a0 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 2 Sep 2025 14:03:58 -0700 Subject: [PATCH] [DebugInfo] When referencing structured bindings use the reference's location, not the binding's declaration's location (#153637) For structured bindings that use custom `get` specializations, the resulting LLVM IR ascribes the load of the result of `get` to the binding's declaration, rather than the place where the binding is referenced - this caused awkward sequencing in the debug info where, when stepping through the code you'd step back to the binding declaration every time there was a reference to the binding. To fix that - when we cross into IRGening a binding - suppress the debug info location of that subexpression. I don't represent this as a great bit of API design - certainly open to ideas, but putting it out here as a place to start. It's /possible/ this is an incomplete fix, even - if the binding decl had other subexpressions, those would still get their location applied & it'd likely be wrong. So maybe that's a direction to go with to productionize this - add a new location scoped device that suppresses any overriding - this might be more robust. How do people feel about that? (cherry picked from commit 665e875f1a86be650e044bb20744bb272d03e11d) --- clang/lib/CodeGen/CGCall.cpp | 26 +-- clang/lib/CodeGen/CGCall.h| 6 +++ clang/lib/CodeGen/CGExpr.cpp | 9 +++- .../debug-info-structured-binding.cpp | 44 ++- 4 files changed, 69 insertions(+), 16 deletions(-) diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index c8c3d6b20c496..5344a9710d642 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -4787,19 +4787,6 @@ struct DestroyUnpassedArg final : EHScopeStack::Cleanup { } }; -struct DisableDebugLocationUpdates { - CodeGenFunction &CGF; - bool disabledDebugInfo; - DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) { -if ((disabledDebugInfo = isa(E) && CGF.getDebugInfo())) - CGF.disableDebugInfo(); - } - ~DisableDebugLocationUpdates() { -if (disabledDebugInfo) - CGF.enableDebugInfo(); - } -}; - } // end anonymous namespace RValue CallArg::getRValue(CodeGenFunction &CGF) const { @@ -4836,7 +4823,9 @@ void CodeGenFunction::EmitWritebacks(const CallArgList &args) { void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, QualType type) { - DisableDebugLocationUpdates Dis(*this, E); + std::optional Dis; + if (isa(E)) +Dis.emplace(*this); if (const ObjCIndirectCopyRestoreExpr *CRE = dyn_cast(E)) { assert(getLangOpts().ObjCAutoRefCount); @@ -6229,3 +6218,12 @@ RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr, return CGM.getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty, Slot); return CGM.getABIInfo().EmitVAArg(*this, VAListAddr, Ty, Slot); } + +DisableDebugLocationUpdates::DisableDebugLocationUpdates(CodeGenFunction &CGF) +: CGF(CGF) { + CGF.disableDebugInfo(); +} + +DisableDebugLocationUpdates::~DisableDebugLocationUpdates() { + CGF.enableDebugInfo(); +} diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h index 0b4e3f9cb0365..17b2ce558f711 100644 --- a/clang/lib/CodeGen/CGCall.h +++ b/clang/lib/CodeGen/CGCall.h @@ -457,6 +457,12 @@ inline FnInfoOpts &operator&=(FnInfoOpts &A, FnInfoOpts B) { return A; } +struct DisableDebugLocationUpdates { + CodeGenFunction &CGF; + DisableDebugLocationUpdates(CodeGenFunction &CGF); + ~DisableDebugLocationUpdates(); +}; + } // end namespace CodeGen } // end namespace clang diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 85c768807572f..b5debd93b0f61 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3314,7 +3314,14 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { auto *FD = LambdaCaptureFields.lookup(BD); return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue); } -return EmitLValue(BD->getBinding()); +// Suppress debug location updates when visiting the binding, since the +// binding may emit instructions that would otherwise be associated with the +// binding itself, rather than the expression referencing the binding. (this +// leads to jumpy debug stepping behavior where the location/debugger jump +// back to the binding declaration, then back to the expression referencing +// the binding) +DisableDebugLocationUpdates D(*this); +return EmitLValue(BD->getBinding(), NotKnownNonNull); } // We can form DeclRefExprs naming GUID declarations when reconstituting diff --git a/clang/test/CodeGenCXX/debug-info-structured-binding.cpp b/clang/test/CodeGenCXX/debug-inf
[llvm-branch-commits] [clang] release/21.x: [clang][docs] Fix implicit-int-conversion-on-negation typos (PR #156815)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/156815 >From 160ad51687ccc3e78d80c94d70cb8f4e3ddd97a5 Mon Sep 17 00:00:00 2001 From: correctmost Date: Thu, 4 Sep 2025 13:13:57 -0400 Subject: [PATCH] [clang][docs] Fix implicit-int-conversion-on-negation typos References to -Wimplicit-int-comparison-on-negation should be -Wimplicit-int-conversion-on-negation instead. --- clang/docs/ReleaseNotes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9400be296e7c2..f03a3273c4518 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -677,8 +677,8 @@ Improvements to Clang's diagnostics trigger a ``'Blue' is deprecated`` warning, which can be turned off with ``-Wno-deprecated-declarations-switch-case``. -- Split diagnosis of implicit integer comparison on negation to a new - diagnostic group ``-Wimplicit-int-comparison-on-negation``, grouped under +- Split diagnosis of implicit integer conversion on negation to a new + diagnostic group ``-Wimplicit-int-conversion-on-negation``, grouped under ``-Wimplicit-int-conversion``, so user can turn it off independently. - Improved the FixIts for unused lambda captures. ___ 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] 85e3f8e - Remove EH_LABEL comments from tests
Author: David Green Date: 2025-09-08T09:37:04+02:00 New Revision: 85e3f8ec7ff614fda65d7407d8f20f12a037a095 URL: https://github.com/llvm/llvm-project/commit/85e3f8ec7ff614fda65d7407d8f20f12a037a095 DIFF: https://github.com/llvm/llvm-project/commit/85e3f8ec7ff614fda65d7407d8f20f12a037a095.diff LOG: Remove EH_LABEL comments from tests Added: Modified: llvm/test/CodeGen/AArch64/bti-ehpad.ll llvm/test/CodeGen/AArch64/wineh-bti-funclet.ll Removed: diff --git a/llvm/test/CodeGen/AArch64/bti-ehpad.ll b/llvm/test/CodeGen/AArch64/bti-ehpad.ll index 674421adaf51c..dee4bd3ec8adf 100644 --- a/llvm/test/CodeGen/AArch64/bti-ehpad.ll +++ b/llvm/test/CodeGen/AArch64/bti-ehpad.ll @@ -18,14 +18,14 @@ define void @test() #0 personality ptr @__gxx_personality_v0 { ; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill ; CHECK-NEXT:.cfi_def_cfa_offset 16 ; CHECK-NEXT:.cfi_offset w30, -16 -; CHECK-NEXT: .Ltmp0: // EH_LABEL +; CHECK-NEXT: .Ltmp0: ; CHECK-NEXT:bl may_throw -; CHECK-NEXT: .Ltmp1: // EH_LABEL +; CHECK-NEXT: .Ltmp1: ; CHECK-NEXT: // %bb.1: // %common.ret ; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload ; CHECK-NEXT:ret ; CHECK-NEXT: .LBB0_2: // %lpad -; CHECK-NEXT: .Ltmp2: // EH_LABEL +; CHECK-NEXT: .Ltmp2: ; CHECK-NEXT:bti j ; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload ; CHECK-NEXT:ret diff --git a/llvm/test/CodeGen/AArch64/wineh-bti-funclet.ll b/llvm/test/CodeGen/AArch64/wineh-bti-funclet.ll index 4f4f984b8974b..3a1eaf04af5ab 100644 --- a/llvm/test/CodeGen/AArch64/wineh-bti-funclet.ll +++ b/llvm/test/CodeGen/AArch64/wineh-bti-funclet.ll @@ -21,9 +21,9 @@ define dso_local void @wineh_funclet() #0 personality ptr @__CxxFrameHandler3 { ; CHECK-NEXT:.seh_endprologue ; CHECK-NEXT:mov x0, #-2 // =0xfffe ; CHECK-NEXT:stur x0, [x29, #16] -; CHECK-NEXT: .Ltmp0: // EH_LABEL +; CHECK-NEXT: .Ltmp0: ; CHECK-NEXT:bl may_throw -; CHECK-NEXT: .Ltmp1: // EH_LABEL +; CHECK-NEXT: .Ltmp1: ; CHECK-NEXT: .LBB0_1: // Block address taken ; CHECK-NEXT:// %try.cont ; CHECK-NEXT: $ehgcr_0_1: ___ 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] 3751e53 - [AArch64][BTI] Add BTI at EH entries. (#155308)
Author: Shashi Shankar Date: 2025-09-08T09:37:04+02:00 New Revision: 3751e53c3e89af153b8ac17120e3c427dd6b564c URL: https://github.com/llvm/llvm-project/commit/3751e53c3e89af153b8ac17120e3c427dd6b564c DIFF: https://github.com/llvm/llvm-project/commit/3751e53c3e89af153b8ac17120e3c427dd6b564c.diff LOG: [AArch64][BTI] Add BTI at EH entries. (#155308) Mark EH landing pads as indirect-branch targets (BTI j) and treat WinEH funclet entries as call-like (BTI c). Add lit tests for ELF and COFF. Tests: Adds lit tests: bti-ehpad.ll and wineh-bti-funclet.ll. Fixes: #149267 Signed-off-by: Shashi Shankar (cherry picked from commit 1b37b9e6d788d7058381b68b5ab265bcb6181335) Added: llvm/test/CodeGen/AArch64/bti-ehpad.ll llvm/test/CodeGen/AArch64/wineh-bti-funclet.ll Modified: llvm/lib/Target/AArch64/AArch64BranchTargets.cpp llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll llvm/test/CodeGen/AArch64/wineh-bti.ll Removed: diff --git a/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp b/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp index 3436dc9ef4521..137ff898e86a3 100644 --- a/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp +++ b/llvm/lib/Target/AArch64/AArch64BranchTargets.cpp @@ -30,6 +30,14 @@ using namespace llvm; #define AARCH64_BRANCH_TARGETS_NAME "AArch64 Branch Targets" namespace { +// BTI HINT encoding: base (32) plus 'c' (2) and/or 'j' (4). +enum : unsigned { + BTIBase = 32, // Base immediate for BTI HINT + BTIC = 1u << 1, // 2 + BTIJ = 1u << 2, // 4 + BTIMask = BTIC | BTIJ, +}; + class AArch64BranchTargets : public MachineFunctionPass { public: static char ID; @@ -42,6 +50,7 @@ class AArch64BranchTargets : public MachineFunctionPass { void addBTI(MachineBasicBlock &MBB, bool CouldCall, bool CouldJump, bool NeedsWinCFI); }; + } // end anonymous namespace char AArch64BranchTargets::ID = 0; @@ -62,9 +71,8 @@ bool AArch64BranchTargets::runOnMachineFunction(MachineFunction &MF) { if (!MF.getInfo()->branchTargetEnforcement()) return false; - LLVM_DEBUG( - dbgs() << "** AArch64 Branch Targets **\n" - << "** Function: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "** AArch64 Branch Targets **\n" +<< "** Function: " << MF.getName() << '\n'); const Function &F = MF.getFunction(); // LLVM does not consider basic blocks which are the targets of jump tables @@ -103,6 +111,12 @@ bool AArch64BranchTargets::runOnMachineFunction(MachineFunction &MF) { JumpTableTargets.count(&MBB)) CouldJump = true; +if (MBB.isEHPad()) { + if (HasWinCFI && (MBB.isEHFuncletEntry() || MBB.isCleanupFuncletEntry())) +CouldCall = true; + else +CouldJump = true; +} if (CouldCall || CouldJump) { addBTI(MBB, CouldCall, CouldJump, HasWinCFI); MadeChange = true; @@ -130,7 +144,12 @@ void AArch64BranchTargets::addBTI(MachineBasicBlock &MBB, bool CouldCall, auto MBBI = MBB.begin(); - // Skip the meta instructions, those will be removed anyway. + // If the block starts with EH_LABEL(s), skip them first. + while (MBBI != MBB.end() && MBBI->isEHLabel()) { +++MBBI; + } + + // Skip meta/CFI/etc. (and EMITBKEY) to reach the first executable insn. for (; MBBI != MBB.end() && (MBBI->isMetaInstruction() || MBBI->getOpcode() == AArch64::EMITBKEY); ++MBBI) @@ -138,16 +157,21 @@ void AArch64BranchTargets::addBTI(MachineBasicBlock &MBB, bool CouldCall, // SCTLR_EL1.BT[01] is set to 0 by default which means // PACI[AB]SP are implicitly BTI C so no BTI C instruction is needed there. - if (MBBI != MBB.end() && HintNum == 34 && + if (MBBI != MBB.end() && ((HintNum & BTIMask) == BTIC) && (MBBI->getOpcode() == AArch64::PACIASP || MBBI->getOpcode() == AArch64::PACIBSP)) return; - if (HasWinCFI && MBBI->getFlag(MachineInstr::FrameSetup)) { -BuildMI(MBB, MBB.begin(), MBB.findDebugLoc(MBB.begin()), -TII->get(AArch64::SEH_Nop)); + // Insert BTI exactly at the first executable instruction. + const DebugLoc DL = MBB.findDebugLoc(MBBI); + MachineInstr *BTI = BuildMI(MBB, MBBI, DL, TII->get(AArch64::HINT)) + .addImm(HintNum) + .getInstr(); + + // WinEH: put .seh_nop after BTI when the first real insn is FrameSetup. + if (HasWinCFI && MBBI != MBB.end() && + MBBI->getFlag(MachineInstr::FrameSetup)) { +auto AfterBTI = std::next(MachineBasicBlock::iterator(BTI)); +BuildMI(MBB, AfterBTI, DL, TII->get(AArch64::SEH_Nop)); } - BuildMI(MBB, MBB.begin(), MBB.findDebugLoc(MBB.begin()), - TII->get(AArch64::HINT)) - .addImm(HintNum); } diff --git a/llvm/test/CodeGen/AArch64/bti-ehpad.ll b/llvm/test/CodeGen/AArch64/bti-ehpad.ll new file mode 100644 index 0..6744
[llvm-branch-commits] [lldb] fa462a6 - [lldb][DataFormatter] Allow std::string formatters to match against custom allocators (#156050)
Author: Michael Buch Date: 2025-09-08T09:42:05+02:00 New Revision: fa462a66e418b08b486b56dc943ade47ab1c9ea3 URL: https://github.com/llvm/llvm-project/commit/fa462a66e418b08b486b56dc943ade47ab1c9ea3 DIFF: https://github.com/llvm/llvm-project/commit/fa462a66e418b08b486b56dc943ade47ab1c9ea3.diff LOG: [lldb][DataFormatter] Allow std::string formatters to match against custom allocators (#156050) This came up in https://github.com/llvm/llvm-project/issues/155691. For `std::basic_string` our formatter matching logic required the allocator template parameter to be a `std::allocator`. There is no compelling reason (that I know of) why this would be required for us to apply the existing formatter to the string. We don't check the `allocator` parameter for other STL containers either. This meant that `std::string` that used custom allocators wouldn't be formatted. This patch relaxes the regex for `basic_string`. (cherry picked from commit 4b362f152e58abd6aeed5d603a6dfc10115ed1ab) Added: Modified: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp Removed: diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 9a869f3ea0289..862082f8a16ba 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -790,31 +790,27 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { lldb_private::formatters::LibcxxStringSummaryProviderASCII, "std::string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxStringSummaryProviderASCII, "std::string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxStringSummaryProviderUTF16, "std::u16string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxStringSummaryProviderUTF32, "std::u32string summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, @@ -825,8 +821,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { lldb_private::formatters::LibcxxWStringSummaryProvider, "std::wstring summary provider", "^std::__[[:alnum:]]+::basic_string, " -"std::__[[:alnum:]]+::allocator >$", +"std::__[[:alnum:]]+::char_traits,.*>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, @@ -1342,24 +1337,16 @@ static void RegisterStdStringSummaryProvider( category_sp->AddTypeSummary(makeSpecifier(string_ty), summary_sp); - // std::basic_string category_sp->AddTypeSummary( makeSpecifier(llvm::formatv("std::basic_string<{}>", char_ty).str()), summary_sp); - // std::basic_string,std::allocator > - category_sp->AddTypeSummary( - makeSpecifier(llvm::formatv("std::basic_string<{0},std::char_traits<{0}>," - "std::allocator<{0}> >", - char_ty) -.str()), - summary_sp); - // std::basic_string, std::allocator > + category_sp->AddTypeSummary( - makeSpecifier( - llvm::formatv("std::basic_string<{0}, std::char_traits<{0}>, " -"std::allocator<{0}> >", + std::make_shared( + llvm::formatv("^std::basic_string<{0}, ?std::char_traits<{0}>,.*>$", char_ty) - .str()), + .str(), + eFormatterMatchRegex), summary_sp); } @@ -1382,20 +1369,17 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { cpp_category_sp->AddTypeSummary("std::__cxx
[llvm-branch-commits] [llvm] [Xtensa] Fix lowering FP compare operations. (PR #157520)
andreisfr wrote: @arsenm, @mgorny, may I ask you for review of this PR? This is same fix like https://github.com/llvm/llvm-project/pull/156740. Unfortunately as I understand I haven't access rights to merge it to release/21.x, maybe you can help with that? https://github.com/llvm/llvm-project/pull/157520 ___ 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] [Xtensa] Fix lowering FP compare operations. (PR #157520)
https://github.com/mgorny milestoned https://github.com/llvm/llvm-project/pull/157520 ___ 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] [MC] Rewrite stdin.s to use python (PR #157232)
ilovepi wrote: > Somewhat off-topic for this PR, but why can't `REQUIRES: shell` force use of > shell even if internal shell is the default? Then we don't lose test coverage > and don't block this on migration of the long-tail of tests. Previously, we've discussed giving lit a hybrid mode that would allow you to run all the tests w/o `REQUIRES: shell` in the internal shell, but still allow it to run all the shell tests if the shell is available. That would allow us to burn down the `REQUIRES: shell` bits over time, and figure out what features we want the internal shell to support. https://github.com/llvm/llvm-project/pull/157232 ___ 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] 160ad51 - [clang][docs] Fix implicit-int-conversion-on-negation typos
Author: correctmost Date: 2025-09-08T09:40:27+02:00 New Revision: 160ad51687ccc3e78d80c94d70cb8f4e3ddd97a5 URL: https://github.com/llvm/llvm-project/commit/160ad51687ccc3e78d80c94d70cb8f4e3ddd97a5 DIFF: https://github.com/llvm/llvm-project/commit/160ad51687ccc3e78d80c94d70cb8f4e3ddd97a5.diff LOG: [clang][docs] Fix implicit-int-conversion-on-negation typos References to -Wimplicit-int-comparison-on-negation should be -Wimplicit-int-conversion-on-negation instead. Added: Modified: clang/docs/ReleaseNotes.rst Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9400be296e7c2..f03a3273c4518 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -677,8 +677,8 @@ Improvements to Clang's diagnostics trigger a ``'Blue' is deprecated`` warning, which can be turned off with ``-Wno-deprecated-declarations-switch-case``. -- Split diagnosis of implicit integer comparison on negation to a new - diagnostic group ``-Wimplicit-int-comparison-on-negation``, grouped under +- Split diagnosis of implicit integer conversion on negation to a new + diagnostic group ``-Wimplicit-int-conversion-on-negation``, grouped under ``-Wimplicit-int-conversion``, so user can turn it off independently. - Improved the FixIts for unused lambda captures. ___ 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] [MC] Rewrite stdin.s to use python (PR #157232)
boomanaiden154 wrote: > Somewhat off-topic for this PR, but why can't REQUIRES: shell force use of > shell even if internal shell is the default? Then we don't lose test coverage > and don't block this on migration of the long-tail of tests. That's another option. The long tail isn't actually that long though. There are only a handful of tests left in the monorepo that don't pass with the internal shell (~10 for clang, similar numbers for compiler-rt as far as I'm aware, PRs are already up for all the LLVM tests). Most of the tests don't require any complicated adjustments to work with the internal shell and end up cleaner (or at least I would argue) after being ported. https://github.com/llvm/llvm-project/pull/157232 ___ 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] [CGData] Rewrite tests to not use subshells (PR #157234)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157234 ___ 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] [not] Update disable-symbolization.test to work with internal shell (PR #157236)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157236 ___ 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] Use lit internal shell by default (PR #157237)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157237 ___ 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] [Offload] Add GenericPluginTy::get_mem_info (PR #157484)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff origin/main HEAD --extensions cpp,h -- offload/include/omptarget.h offload/liboffload/src/OffloadImpl.cpp offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp offload/plugins-nextgen/amdgpu/dynamic_hsa/hsa_ext_amd.h offload/plugins-nextgen/amdgpu/src/rtl.cpp offload/plugins-nextgen/common/include/PluginInterface.h offload/plugins-nextgen/cuda/src/rtl.cpp offload/plugins-nextgen/host/src/rtl.cpp `` :warning: The reproduction instructions above might return results for more than one PR in a stack if you are using a stacked PR workflow. You can limit the results by changing `origin/main` to the base branch/commit you want to compare against. :warning: View the diff from clang-format here. ``diff diff --git a/offload/plugins-nextgen/common/include/PluginInterface.h b/offload/plugins-nextgen/common/include/PluginInterface.h index 600114407..ce270b3f1 100644 --- a/offload/plugins-nextgen/common/include/PluginInterface.h +++ b/offload/plugins-nextgen/common/include/PluginInterface.h @@ -1277,9 +1277,7 @@ struct MemoryInfoTy { TargetAllocTy Type; GenericDeviceTy *Device; - void *limit() const { -return reinterpret_cast(Base) + Size; - } + void *limit() const { return reinterpret_cast(Base) + Size; } }; /// Class implementing common functionalities of offload plugins. Each plugin `` https://github.com/llvm/llvm-project/pull/157484 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang][OpenMP] `do concurrent`: support `local` on device (PR #156589)
https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/156589 >From c29c8a23bcc0cecbd4c93e3af231be90859030a2 Mon Sep 17 00:00:00 2001 From: ergawy Date: Tue, 2 Sep 2025 05:54:00 -0500 Subject: [PATCH] [flang][OpenMP] `do concurrent`: support `local` on device Extends support for mapping `do concurrent` on the device by adding support for `local` specifiers. The changes in this PR map the local variable to the `omp.target` op and uses the mapped value as the `private` clause operand in the nested `omp.parallel` op. --- .../include/flang/Optimizer/Dialect/FIROps.td | 12 ++ .../OpenMP/DoConcurrentConversion.cpp | 192 +++--- .../Transforms/DoConcurrent/local_device.mlir | 49 + 3 files changed, 175 insertions(+), 78 deletions(-) create mode 100644 flang/test/Transforms/DoConcurrent/local_device.mlir diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td index bc971e8fd6600..fc6eedc6ed4c6 100644 --- a/flang/include/flang/Optimizer/Dialect/FIROps.td +++ b/flang/include/flang/Optimizer/Dialect/FIROps.td @@ -3894,6 +3894,18 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop", return getReduceVars().size(); } +unsigned getInductionVarsStart() { + return 0; +} + +unsigned getLocalOperandsStart() { + return getNumInductionVars(); +} + +unsigned getReduceOperandsStart() { + return getLocalOperandsStart() + getNumLocalOperands(); +} + mlir::Block::BlockArgListType getInductionVars() { return getBody()->getArguments().slice(0, getNumInductionVars()); } diff --git a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp index 44be055e555e1..1add508ec153b 100644 --- a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp +++ b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp @@ -137,6 +137,9 @@ void collectLoopLiveIns(fir::DoConcurrentLoopOp loop, liveIns.push_back(operand->get()); }); + + for (mlir::Value local : loop.getLocalVars()) +liveIns.push_back(local); } /// Collects values that are local to a loop: "loop-local values". A loop-local @@ -251,8 +254,7 @@ class DoConcurrentConversion .getIsTargetDevice(); mlir::omp::TargetOperands targetClauseOps; - genLoopNestClauseOps(doLoop.getLoc(), rewriter, loop, mapper, - loopNestClauseOps, + genLoopNestClauseOps(doLoop.getLoc(), rewriter, loop, loopNestClauseOps, isTargetDevice ? nullptr : &targetClauseOps); LiveInShapeInfoMap liveInShapeInfoMap; @@ -274,14 +276,13 @@ class DoConcurrentConversion } mlir::omp::ParallelOp parallelOp = -genParallelOp(doLoop.getLoc(), rewriter, ivInfos, mapper); +genParallelOp(rewriter, loop, ivInfos, mapper); // Only set as composite when part of `distribute parallel do`. parallelOp.setComposite(mapToDevice); if (!mapToDevice) - genLoopNestClauseOps(doLoop.getLoc(), rewriter, loop, mapper, - loopNestClauseOps); + genLoopNestClauseOps(doLoop.getLoc(), rewriter, loop, loopNestClauseOps); for (mlir::Value local : locals) looputils::localizeLoopLocalValue(local, parallelOp.getRegion(), @@ -290,10 +291,38 @@ class DoConcurrentConversion if (mapToDevice) genDistributeOp(doLoop.getLoc(), rewriter).setComposite(/*val=*/true); -mlir::omp::LoopNestOp ompLoopNest = +auto [loopNestOp, wsLoopOp] = genWsLoopOp(rewriter, loop, mapper, loopNestClauseOps, /*isComposite=*/mapToDevice); +// `local` region arguments are transferred/cloned from the `do concurrent` +// loop to the loopnest op when the region is cloned above. Instead, these +// region arguments should be on the workshare loop's region. +if (mapToDevice) { + for (auto [parallelArg, loopNestArg] : llvm::zip_equal( + parallelOp.getRegion().getArguments(), + loopNestOp.getRegion().getArguments().slice( + loop.getLocalOperandsStart(), loop.getNumLocalOperands( +rewriter.replaceAllUsesWith(loopNestArg, parallelArg); + + for (auto [wsloopArg, loopNestArg] : llvm::zip_equal( + wsLoopOp.getRegion().getArguments(), + loopNestOp.getRegion().getArguments().slice( + loop.getReduceOperandsStart(), loop.getNumReduceOperands( +rewriter.replaceAllUsesWith(loopNestArg, wsloopArg); +} else { + for (auto [wsloopArg, loopNestArg] : + llvm::zip_equal(wsLoopOp.getRegion().getArguments(), + loopNestOp.getRegion().getArguments().drop_front( + loopNestClauseOps.loopLowerBounds.size( +rewriter.replaceAllUsesWith(loopNestArg, wsloopArg); +} + +for (unsigned i = 0; + i
[llvm-branch-commits] [llvm] Use lit internal shell by default (PR #157237)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157237 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits