[llvm-branch-commits] [flang] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits

https://github.com/agozillon edited 
https://github.com/llvm/llvm-project/pull/96266
___
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] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits


@@ -953,6 +954,22 @@ bool ClauseProcessor::processMap(
   if (origSymbol && fir::isTypeWithDescriptor(origSymbol.getType()))
 symAddr = origSymbol;
 
+  if (object.sym()->owner().IsDerivedType()) {
+omp::ObjectList objectList = gatherObjects(object, semaCtx);
+parentObj = objectList[0];
+parentMemberIndices.insert({parentObj.value(), {}});

agozillon wrote:

The same is indeed true for insert, although, I have no issue using emplace 
either :-) 

https://github.com/llvm/llvm-project/pull/96266
___
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] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits


@@ -85,67 +135,227 @@ class OMPMapInfoFinalizationPass
   descriptor = alloca;
 }
 
+return descriptor;
+  }
+
+  /// Simple function that will generate a FIR operation accessing
+  /// the descriptors base address (BoxOffsetOp) and then generate a
+  /// MapInfoOp for it, the most important thing to note is that
+  /// we normally move the bounds from the descriptor map onto the
+  /// base address map.
+  mlir::omp::MapInfoOp getBaseAddrMap(mlir::Value descriptor,
+  mlir::OperandRange bounds,
+  int64_t mapType,
+  fir::FirOpBuilder &builder) {
+mlir::Location loc = descriptor.getLoc();
 mlir::Value baseAddrAddr = builder.create(
 loc, descriptor, fir::BoxFieldAttr::base_addr);
 
 // Member of the descriptor pointing at the allocated data
-mlir::Value baseAddr = builder.create(
+return builder.create(
 loc, baseAddrAddr.getType(), descriptor,
 mlir::TypeAttr::get(llvm::cast(
 fir::unwrapRefType(baseAddrAddr.getType()))
 .getElementType()),
-baseAddrAddr, /*members=*/mlir::SmallVector{},
-/*member_index=*/mlir::DenseIntElementsAttr{}, op.getBounds(),
-builder.getIntegerAttr(builder.getIntegerType(64, false),
-   op.getMapType().value()),
+baseAddrAddr, mlir::SmallVector{},
+mlir::DenseIntElementsAttr{}, bounds,
+builder.getIntegerAttr(builder.getIntegerType(64, false), mapType),
 builder.getAttr(
 mlir::omp::VariableCaptureKind::ByRef),
-/*name=*/builder.getStringAttr(""),
-/*partial_map=*/builder.getBoolAttr(false));
+builder.getStringAttr("") /*name*/,
+builder.getBoolAttr(false) /*partial_map*/);
+  }
 
-// TODO: map the addendum segment of the descriptor, similarly to the
-// above base address/data pointer member.
+  /// This function adjusts the member indices vector to include a new
+  /// base address member, we take the position of the descriptor in
+  /// the member indices list, which is the index data that the base
+  /// addresses index will be based off of, as the base address is
+  /// a member of the descriptor, we must also alter other members
+  /// indices in the list to account for this new addition. This
+  /// requires extending all members with -1's if the addition of
+  /// the new base address has increased the member vector past the
+  /// original size, as we must make sure all member indices are of
+  /// the same length (think rectangle matrix) due to DenseIntElementsAttr
+  /// requiring this. We also need to be aware that we are inserting
+  /// into the middle of a member index vector in some cases (i.e.
+  /// we could be accessing the member of a descriptor type with a
+  /// subsequent map, so we must be sure to adjust any of these cases
+  /// with the addition of the new base address index value).
+  void adjustMemberIndices(
+  llvm::SmallVector> &memberIndices,
+  size_t memberIndex) {
+// Find if the descriptor member we are basing our new base address index
+// off of has a -1 somewhere, indicating an empty index already exists (due
+// to a larger sized member position elsewhere) which allows us to simplify
+// later steps a little
+auto baseAddrIndex = memberIndices[memberIndex];
+auto *iterPos = std::find(baseAddrIndex.begin(), baseAddrIndex.end(), -1);
 
-if (auto mapClauseOwner =
-llvm::dyn_cast(target)) {
-  llvm::SmallVector newMapOps;
-  mlir::OperandRange mapOperandsArr = mapClauseOwner.getMapOperands();
+// If we aren't at the end, as we found a -1, we can simply modify the -1
+// to the base addresses index in the descriptor (which will always be the
+// first member in the descriptor, so 0). If not, then we're extending the
+// index list and have to push on a 0 and adjust the position to the new
+// end.
+if (iterPos != baseAddrIndex.end()) {
+  *iterPos = 0;
+} else {
+  baseAddrIndex.push_back(0);
+  iterPos = baseAddrIndex.end();
+}
 
-  for (size_t i = 0; i < mapOperandsArr.size(); ++i) {
-if (mapOperandsArr[i] == op) {
-  // Push new implicit maps generated for the descriptor.
-  newMapOps.push_back(baseAddr);
+auto isEqual = [](auto first1, auto last1, auto first2, auto last2) {
+  int v1, v2;
+  for (; first1 != last1; ++first1, ++first2) {
+v1 = (first1 == last1) ? -1 : *first1;
+v2 = (first2 == last2) ? -1 : *first2;
 
-  // for TargetOp's which have IsolatedFromAbove we must align the
-  // new additional map operand with an appropriate BlockArgument,
-  // as the printing and later processing currently requires a 1:1
-  // mapping of BlockArgs to MapInfoOp's at the same placement i

[llvm-branch-commits] [flang] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits

https://github.com/agozillon commented:

Recent PR update aims to address the prior comments where they're still 
relevant after making the suggested changes by @skatrak to move away from using 
the DenseIntElementsAttr (thank you very much for the suggestion, it's 
simplified things a fair bit in a few places :-)).

Please do have a subsequent look over the changeset to check any comments made 
previously that were still relevant after the move to a new attribute type for 
the indices have been addressed (quite a few comments and some may have been 
lost in the shuffle/changes so sorry if I have missed any, please feel free to 
re-iterate on them with a ping and I'll address them or comment as to why I 
couldn't)! 
 


https://github.com/llvm/llvm-project/pull/96266
___
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] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits


@@ -671,4 +672,51 @@ static inline bool isEqual(const Fortran::lower::SomeExpr 
*x,
 }
 } // end namespace Fortran::lower
 
+// OpenMP utility functions used in locations outside of the
+// OpenMP lowering.
+namespace Fortran::lower::omp {
+
+[[maybe_unused]] static void fillMemberIndices(
+llvm::SmallVector> &memberPlacementData) {

agozillon wrote:

It seems to only be feasible to do this with the other portion of the vector, 
which I've done, the nested vector will yield some compiler errors 
unfortunately. It is always highly possible I am missing something though! 

https://github.com/llvm/llvm-project/pull/96266
___
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] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits

https://github.com/agozillon updated 
https://github.com/llvm/llvm-project/pull/96266

>From 2e24a3b56c2be7203aa87b1d6bb886706e138496 Mon Sep 17 00:00:00 2001
From: agozillon 
Date: Tue, 25 Jun 2024 17:40:04 -0500
Subject: [PATCH 1/2] removal of some leftover artifacts

Created using spr 1.3.4
---
 flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp 
b/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
index 8749daf757f52..c88b3cf4cc0b4 100644
--- a/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
+++ b/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
@@ -493,13 +493,6 @@ class OMPMapInfoFinalizationPass
   mlir::isa_and_present(
   op.getVarPtr().getDefiningOp())) {
 builder.setInsertionPoint(op);
-
-// - contact benifit people
-// - update broken  lit tests
-// -create commit and apply clang-format
-// -cherry pick pr onto PR stack and split the commit into relevant
-// components and rebase fixup into orignal corresponding PR. -push
-// upstream
 genDescriptorMemberMaps(op, builder, getFirstTargetUser(op));
   }
 });

>From d81e63d0f8cfa4d63463a10dcca2ea36ced0c02f Mon Sep 17 00:00:00 2001
From: agozillon 
Date: Fri, 2 Aug 2024 02:04:59 -0500
Subject: [PATCH 2/2] remove leftover cmake artifact

Created using spr 1.3.4
---
 flang/lib/Common/CMakeLists.txt | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 60de8e0f7427a..c6f818ad27cd1 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -43,9 +43,6 @@ add_flang_library(FortranCommon
   Version.cpp
   ${version_inc}
 
-  LINK_LIBS
-  MLIRDialect
-
   LINK_COMPONENTS
   Support
 )

___
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/19.x: [InstrProf] Remove duplicate definition of IntPtrT (PR #101061)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101061

>From 19ebcf8685f2ef010a0bc8474b4bf732024a3576 Mon Sep 17 00:00:00 2001
From: Dimitry Andric 
Date: Mon, 29 Jul 2024 20:34:01 +0200
Subject: [PATCH] [InstrProf] Remove duplicate definition of IntPtrT

In 16e74fd48988a (for #82711) a duplicate definition of `IntPtrT` was
added to `InstrProfiling.h`, leading to warnings:

compiler-rt/lib/profile/InstrProfiling.h:52:15: warning: redefinition of 
typedef 'IntPtrT' is a C11 feature [-Wtypedef-redefinition]
   52 | typedef void *IntPtrT;
  |   ^
compiler-rt/lib/profile/InstrProfiling.h:34:15: note: previous definition 
is here
   34 | typedef void *IntPtrT;
  |   ^

Fix the warnings by removing the duplicate typedef.

(cherry picked from commit 2c376fe96c83443c15e6485d043ebe321904546b)
---
 compiler-rt/lib/profile/InstrProfiling.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/compiler-rt/lib/profile/InstrProfiling.h 
b/compiler-rt/lib/profile/InstrProfiling.h
index d424a22c212c3..6906d52eacaf1 100644
--- a/compiler-rt/lib/profile/InstrProfiling.h
+++ b/compiler-rt/lib/profile/InstrProfiling.h
@@ -49,7 +49,6 @@ typedef struct ValueProfNode {
 #include "profile/InstrProfData.inc"
 } ValueProfNode;
 
-typedef void *IntPtrT;
 typedef struct COMPILER_RT_ALIGNAS(INSTR_PROF_DATA_ALIGNMENT) VTableProfData {
 #define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer) Type Name;
 #include "profile/InstrProfData.inc"

___
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] 19ebcf8 - [InstrProf] Remove duplicate definition of IntPtrT

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

Author: Dimitry Andric
Date: 2024-08-02T09:22:20+02:00
New Revision: 19ebcf8685f2ef010a0bc8474b4bf732024a3576

URL: 
https://github.com/llvm/llvm-project/commit/19ebcf8685f2ef010a0bc8474b4bf732024a3576
DIFF: 
https://github.com/llvm/llvm-project/commit/19ebcf8685f2ef010a0bc8474b4bf732024a3576.diff

LOG: [InstrProf] Remove duplicate definition of IntPtrT

In 16e74fd48988a (for #82711) a duplicate definition of `IntPtrT` was
added to `InstrProfiling.h`, leading to warnings:

compiler-rt/lib/profile/InstrProfiling.h:52:15: warning: redefinition of 
typedef 'IntPtrT' is a C11 feature [-Wtypedef-redefinition]
   52 | typedef void *IntPtrT;
  |   ^
compiler-rt/lib/profile/InstrProfiling.h:34:15: note: previous definition 
is here
   34 | typedef void *IntPtrT;
  |   ^

Fix the warnings by removing the duplicate typedef.

(cherry picked from commit 2c376fe96c83443c15e6485d043ebe321904546b)

Added: 


Modified: 
compiler-rt/lib/profile/InstrProfiling.h

Removed: 




diff  --git a/compiler-rt/lib/profile/InstrProfiling.h 
b/compiler-rt/lib/profile/InstrProfiling.h
index d424a22c212c3..6906d52eacaf1 100644
--- a/compiler-rt/lib/profile/InstrProfiling.h
+++ b/compiler-rt/lib/profile/InstrProfiling.h
@@ -49,7 +49,6 @@ typedef struct ValueProfNode {
 #include "profile/InstrProfData.inc"
 } ValueProfNode;
 
-typedef void *IntPtrT;
 typedef struct COMPILER_RT_ALIGNAS(INSTR_PROF_DATA_ALIGNMENT) VTableProfData {
 #define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer) Type Name;
 #include "profile/InstrProfData.inc"



___
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/19.x: [InstrProf] Remove duplicate definition of IntPtrT (PR #101061)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101061
___
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] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching EEW (PR #101464)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101464

>From 9140ce331ec9dc0bd4df3f503168057a09a94972 Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Wed, 31 Jul 2024 00:28:52 +0800
Subject: [PATCH] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with
 mismatching EEW (#101152)

As noted in
https://github.com/llvm/llvm-project/pull/100367/files#r1695448771, we
currently fold in vmerge.vvms and vmv.v.vs into their ops even if the
EEW is different which leads to an incorrect transform.

This checks the op's EEW via its simple value type for now since there
doesn't seem to be any existing information about the EEW size of
instructions. We'll probably need to encode this at some point if we
want to be able to access it at the MachineInstr level in #100367
---
 llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp   |  4 
 llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll| 14 +
 .../RISCV/rvv/rvv-peephole-vmerge-vops.ll | 21 +++
 3 files changed, 39 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp 
b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index eef6ae677ac85..db949f3476e2b 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -3721,6 +3721,10 @@ bool 
RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
   assert(!Mask || cast(Mask)->getReg() == RISCV::V0);
   assert(!Glue || Glue.getValueType() == MVT::Glue);
 
+  // If the EEW of True is different from vmerge's SEW, then we can't fold.
+  if (True.getSimpleValueType() != N->getSimpleValueType(0))
+return false;
+
   // We require that either merge and false are the same, or that merge
   // is undefined.
   if (Merge != False && !isImplicitDef(Merge))
diff --git a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll 
b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
index ec03f773c7108..dfc2b2bdda026 100644
--- a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
@@ -168,3 +168,17 @@ define  @unfoldable_vredsum( %passthru,  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a, iXLen 1)
   ret  %b
 }
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y, iXLen %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, iXLen %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a.bitcast, iXLen %avl)
+  ret  %b
+}
diff --git a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll 
b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
index a08bcae074b9b..259515f160048 100644
--- a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
@@ -1196,3 +1196,24 @@ define  
@true_mask_vmerge_implicit_passthru(
   )
   ret  %b
 }
+
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y,  
%mask, i64 %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, i64 %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmerge.nxv2i32.nxv2i32(
+ %passthru,
+ %passthru,
+ %a.bitcast,
+ splat (i1 true),
+i64 %avl
+  )
+  ret  %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] [compiler-rt] release/19.x: [InstrProf] Remove duplicate definition of IntPtrT (PR #101061)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@DimitryAndric (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/101061
___
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/19.x: workflows: Fix libclc-tests (#101524) (PR #101539)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101539

>From 2d7539381c278dd47c9dd6ecb9943d9685ab66f4 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Thu, 1 Aug 2024 11:23:03 -0700
Subject: [PATCH] workflows: Fix libclc-tests (#101524)

The old out-of-tree build configuration stopped working and in tree
builds are supported now, so we should use the in tree configuration.
The only downside is we can't run the tests any more, but at least we
will be able to test the build again.

(cherry picked from commit 0512ba0a435a9d693cb61f182fc9e3eb7f6dbd6a)
---
 .github/workflows/llvm-project-tests.yml | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/llvm-project-tests.yml 
b/.github/workflows/llvm-project-tests.yml
index 0a228c41f354e..17a54be16badc 100644
--- a/.github/workflows/llvm-project-tests.yml
+++ b/.github/workflows/llvm-project-tests.yml
@@ -131,6 +131,7 @@ jobs:
 -DCMAKE_BUILD_TYPE=Release \
 -DLLVM_ENABLE_ASSERTIONS=ON \
 -DLLDB_INCLUDE_TESTS=OFF \
+
-DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl"
 \
 -DCMAKE_C_COMPILER_LAUNCHER=sccache \
 -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
 $extra_cmake_args \
@@ -142,8 +143,6 @@ jobs:
 env:
   LLVM_BUILDDIR: ${{ steps.build-llvm.outputs.llvm-builddir }}
 run: |
-  # Make sure all of LLVM libraries that llvm-config needs are built.
+  # The libclc tests don't have a generated check target so all we can
+  # do is build it.
   ninja -C "$LLVM_BUILDDIR"
-  cmake -G Ninja -S libclc -B libclc-build 
-DLLVM_DIR="$LLVM_BUILDDIR"/lib/cmake/llvm 
-DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl"
-  ninja -C libclc-build
-  ninja -C libclc-build test

___
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/19.x: workflows: Fix libclc-tests (#101524) (PR #101539)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101539
___
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] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching EEW (PR #101464)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101464

>From 551b80047ae9b22a80a4c4833d6a9e19ab730173 Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Wed, 31 Jul 2024 00:28:52 +0800
Subject: [PATCH] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with
 mismatching EEW (#101152)

As noted in
https://github.com/llvm/llvm-project/pull/100367/files#r1695448771, we
currently fold in vmerge.vvms and vmv.v.vs into their ops even if the
EEW is different which leads to an incorrect transform.

This checks the op's EEW via its simple value type for now since there
doesn't seem to be any existing information about the EEW size of
instructions. We'll probably need to encode this at some point if we
want to be able to access it at the MachineInstr level in #100367
---
 llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp   |  4 
 llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll| 14 +
 .../RISCV/rvv/rvv-peephole-vmerge-vops.ll | 21 +++
 3 files changed, 39 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp 
b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index eef6ae677ac85..db949f3476e2b 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -3721,6 +3721,10 @@ bool 
RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
   assert(!Mask || cast(Mask)->getReg() == RISCV::V0);
   assert(!Glue || Glue.getValueType() == MVT::Glue);
 
+  // If the EEW of True is different from vmerge's SEW, then we can't fold.
+  if (True.getSimpleValueType() != N->getSimpleValueType(0))
+return false;
+
   // We require that either merge and false are the same, or that merge
   // is undefined.
   if (Merge != False && !isImplicitDef(Merge))
diff --git a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll 
b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
index ec03f773c7108..dfc2b2bdda026 100644
--- a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
@@ -168,3 +168,17 @@ define  @unfoldable_vredsum( %passthru,  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a, iXLen 1)
   ret  %b
 }
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y, iXLen %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, iXLen %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a.bitcast, iXLen %avl)
+  ret  %b
+}
diff --git a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll 
b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
index a08bcae074b9b..259515f160048 100644
--- a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
@@ -1196,3 +1196,24 @@ define  
@true_mask_vmerge_implicit_passthru(
   )
   ret  %b
 }
+
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y,  
%mask, i64 %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, i64 %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmerge.nxv2i32.nxv2i32(
+ %passthru,
+ %passthru,
+ %a.bitcast,
+ splat (i1 true),
+i64 %avl
+  )
+  ret  %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] [clang] release/19.x: [AIX] Turn on `#pragma mc_func` check by default (#101336) (PR #101505)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101505

>From a0206c9906c52aa9e2bd2508f503da21c3757c94 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <274595+qiongs...@users.noreply.github.com>
Date: Thu, 1 Aug 2024 09:51:07 -0400
Subject: [PATCH] [AIX] Turn on `#pragma mc_func` check by default (#101336)

https://github.com/llvm/llvm-project/pull/99888 added a check (and
corresponding options) to flag uses of `#pragma mc_func` on AIX.

This PR turns on the check by default.

(cherry picked from commit b9335176db718bf64c72d48107eb9dff28ed979e)
---
 clang/include/clang/Driver/Options.td | 4 ++--
 clang/include/clang/Lex/PreprocessorOptions.h | 4 ++--
 clang/lib/Driver/ToolChains/AIX.cpp   | 6 ++
 clang/test/Preprocessor/pragma_mc_func.c  | 6 --
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 359a698ea87dd..bed6e7af9dce9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8087,8 +8087,8 @@ def source_date_epoch : Separate<["-"], 
"source-date-epoch">,
 } // let Visibility = [CC1Option]
 
 defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix",
-  PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultFalse,
-  PosFlag, DefaultTrue,
+  PosFlag,
   NegFlag>;
diff --git a/clang/include/clang/Lex/PreprocessorOptions.h 
b/clang/include/clang/Lex/PreprocessorOptions.h
index 3f7dd9db18ba7..f48b7ecb90e1e 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -213,7 +213,7 @@ class PreprocessorOptions {
 
   /// If set, the preprocessor reports an error when processing #pragma mc_func
   /// on AIX.
-  bool ErrorOnPragmaMcfuncOnAIX = false;
+  bool ErrorOnPragmaMcfuncOnAIX = true;
 
 public:
   PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
@@ -252,7 +252,7 @@ class PreprocessorOptions {
 PrecompiledPreambleBytes.first = 0;
 PrecompiledPreambleBytes.second = false;
 RetainExcludedConditionalBlocks = false;
-ErrorOnPragmaMcfuncOnAIX = false;
+ErrorOnPragmaMcfuncOnAIX = true;
   }
 };
 
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index fb780fb75651d..0615a8a9e8d17 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -558,10 +558,8 @@ void AIX::addClangTargetOptions(
   options::OPT_fno_sized_deallocation))
 CC1Args.push_back("-fno-sized-deallocation");
 
-  if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
-   options::OPT_fno_err_pragma_mc_func_aix, false))
-CC1Args.push_back("-ferr-pragma-mc-func-aix");
-  else
+  if (!Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
+options::OPT_fno_err_pragma_mc_func_aix, true))
 CC1Args.push_back("-fno-err-pragma-mc-func-aix");
 }
 
diff --git a/clang/test/Preprocessor/pragma_mc_func.c 
b/clang/test/Preprocessor/pragma_mc_func.c
index f0d3e49e5dddc..bf12f7107ff5c 100644
--- a/clang/test/Preprocessor/pragma_mc_func.c
+++ b/clang/test/Preprocessor/pragma_mc_func.c
@@ -1,5 +1,8 @@
+// RUN: not %clang --target=powerpc64-ibm-aix -fsyntax-only %s 2>&1 | 
FileCheck %s
 // RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix 
-fsyntax-only \
 // RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix \
+// RUN:   -ferr-pragma-mc-func-aix -fsyntax-only %s 2>&1 | FileCheck %s
 #pragma mc_func asm_barrier {"6000"}
 
 // CHECK:  error: #pragma mc_func is not supported
@@ -8,11 +11,10 @@
 // RUN: %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix 
-fsyntax-only %s
 // RUN: %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix 
-fsyntax-only \
 // RUN:-fno-err-pragma-mc-func-aix %s
-// RUN: %clang --target=powerpc64-ibm-aix -fsyntax-only %s
 // RUN: %clang --target=powerpc64-ibm-aix -Werror=unknown-pragmas \
 // RUN:   -fno-err-pragma-mc-func-aix -fsyntax-only %s
 
-// Cases where we have errors or warnings.
+// Cases on a non-AIX target.
 // RUN: not %clang --target=powerpc64le-unknown-linux-gnu \
 // RUN:   -Werror=unknown-pragmas -fno-err-pragma-mc-func-aix -fsyntax-only %s 
2>&1 | \
 // RUN:   FileCheck --check-prefix=UNUSED %s

___
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/19.x: workflows: Fix libclc-tests (#101524) (PR #101539)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@tstellar (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/101539
___
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/19.x: [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_{arm, mips64, powerpc} declarations (#101403) (PR #101465)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101465

>From 23f3b64082ecd06fcfbfbc2098fcaa008862545b Mon Sep 17 00:00:00 2001
From: Dimitry Andric 
Date: Thu, 1 Aug 2024 09:28:29 +0200
Subject: [PATCH] [lldb][FreeBSD] Fix
 NativeRegisterContextFreeBSD_{arm,mips64,powerpc} declarations (#101403)

Similar to #97796, fix the type of the `native_thread` parameter for the
arm, mips64 and powerpc variants of `NativeRegisterContextFreeBSD_*`.

Otherwise, this leads to compile errors similar to:

```
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.cpp:85:39:
 error: out-of-line definition of 'NativeRegisterContextFreeBSD_powerpc' does 
not match any declaration in 
'lldb_private::process_freebsd::NativeRegisterContextFreeBSD_powerpc'
   85 | 
NativeRegisterContextFreeBSD_powerpc::NativeRegisterContextFreeBSD_powerpc(
  |   
^~~~
```

(cherry picked from commit 7088a5ed880f29129ec844c66068e8cb61ca98bf)
---
 .../Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h  | 2 +-
 .../Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h   | 2 +-
 .../Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
index 89ffa617294aa..b9537e6952f6c 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
@@ -30,7 +30,7 @@ class NativeProcessFreeBSD;
 class NativeRegisterContextFreeBSD_arm : public NativeRegisterContextFreeBSD {
 public:
   NativeRegisterContextFreeBSD_arm(const ArchSpec &target_arch,
-   NativeThreadProtocol &native_thread);
+   NativeThreadFreeBSD &native_thread);
 
   uint32_t GetRegisterSetCount() const override;
 
diff --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
index 0b4a508a7d5dd..286b4fd8d8b99 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
@@ -31,7 +31,7 @@ class NativeRegisterContextFreeBSD_mips64
 : public NativeRegisterContextFreeBSD {
 public:
   NativeRegisterContextFreeBSD_mips64(const ArchSpec &target_arch,
-  NativeThreadProtocol &native_thread);
+  NativeThreadFreeBSD &native_thread);
 
   uint32_t GetRegisterSetCount() const override;
 
diff --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h
index 3df371036f915..420db822acc0f 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h
@@ -31,7 +31,7 @@ class NativeRegisterContextFreeBSD_powerpc
 : public NativeRegisterContextFreeBSD {
 public:
   NativeRegisterContextFreeBSD_powerpc(const ArchSpec &target_arch,
-   NativeThreadProtocol &native_thread);
+   NativeThreadFreeBSD &native_thread);
 
   uint32_t GetRegisterSetCount() const override;
 

___
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] 23f3b64 - [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_{arm, mips64, powerpc} declarations (#101403)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

Author: Dimitry Andric
Date: 2024-08-02T09:24:50+02:00
New Revision: 23f3b64082ecd06fcfbfbc2098fcaa008862545b

URL: 
https://github.com/llvm/llvm-project/commit/23f3b64082ecd06fcfbfbc2098fcaa008862545b
DIFF: 
https://github.com/llvm/llvm-project/commit/23f3b64082ecd06fcfbfbc2098fcaa008862545b.diff

LOG: [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_{arm,mips64,powerpc} 
declarations (#101403)

Similar to #97796, fix the type of the `native_thread` parameter for the
arm, mips64 and powerpc variants of `NativeRegisterContextFreeBSD_*`.

Otherwise, this leads to compile errors similar to:

```
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.cpp:85:39:
 error: out-of-line definition of 'NativeRegisterContextFreeBSD_powerpc' does 
not match any declaration in 
'lldb_private::process_freebsd::NativeRegisterContextFreeBSD_powerpc'
   85 | 
NativeRegisterContextFreeBSD_powerpc::NativeRegisterContextFreeBSD_powerpc(
  |   
^~~~
```

(cherry picked from commit 7088a5ed880f29129ec844c66068e8cb61ca98bf)

Added: 


Modified: 
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
index 89ffa617294aa..b9537e6952f6c 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
@@ -30,7 +30,7 @@ class NativeProcessFreeBSD;
 class NativeRegisterContextFreeBSD_arm : public NativeRegisterContextFreeBSD {
 public:
   NativeRegisterContextFreeBSD_arm(const ArchSpec &target_arch,
-   NativeThreadProtocol &native_thread);
+   NativeThreadFreeBSD &native_thread);
 
   uint32_t GetRegisterSetCount() const override;
 

diff  --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
index 0b4a508a7d5dd..286b4fd8d8b99 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
@@ -31,7 +31,7 @@ class NativeRegisterContextFreeBSD_mips64
 : public NativeRegisterContextFreeBSD {
 public:
   NativeRegisterContextFreeBSD_mips64(const ArchSpec &target_arch,
-  NativeThreadProtocol &native_thread);
+  NativeThreadFreeBSD &native_thread);
 
   uint32_t GetRegisterSetCount() const override;
 

diff  --git 
a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h 
b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h
index 3df371036f915..420db822acc0f 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h
@@ -31,7 +31,7 @@ class NativeRegisterContextFreeBSD_powerpc
 : public NativeRegisterContextFreeBSD {
 public:
   NativeRegisterContextFreeBSD_powerpc(const ArchSpec &target_arch,
-   NativeThreadProtocol &native_thread);
+   NativeThreadFreeBSD &native_thread);
 
   uint32_t GetRegisterSetCount() const override;
 



___
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/19.x: [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_{arm, mips64, powerpc} declarations (#101403) (PR #101465)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101465
___
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/19.x: [libc++] Increase atomic_ref's required alignment for small types (#99654) (PR #101492)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101492

>From 39e8e7797ae868e82b4184fbadf4572ff9bd3aa3 Mon Sep 17 00:00:00 2001
From: Damien L-G 
Date: Thu, 1 Aug 2024 10:39:27 -0400
Subject: [PATCH] [libc++] Increase atomic_ref's required alignment for small
 types (#99654)

This patch increases the alignment requirement for std::atomic_ref
such that we can guarantee lockfree operations more often. Specifically,
we require types that are 1, 2, 4, 8, or 16 bytes in size to be aligned
to at least their size to be used with std::atomic_ref.

This is the case for most types, however a notable exception is
`long long` on x86, which is 8 bytes in length but has an alignment
of 4.

As a result of this patch, one has to be more careful about the
alignment of objects used with std::atomic_ref. Failure to provide
a properly-aligned object to std::atomic_ref is a precondition
violation and is technically UB. On the flipside, this allows us
to provide an atomic_ref that is actually lockfree more often,
which is an important QOI property.

More information in the discussion at 
https://github.com/llvm/llvm-project/pull/99570#issuecomment-2237668661.

Co-authored-by: Louis Dionne 
(cherry picked from commit 59ca618e3b7aec8c32e24d781bae436dc99b2727)
---
 libcxx/include/__atomic/atomic_ref.h| 17 +++--
 .../atomics.ref/is_always_lock_free.pass.cpp|  2 +-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/libcxx/include/__atomic/atomic_ref.h 
b/libcxx/include/__atomic/atomic_ref.h
index 2849b82e1a3dd..b0180a37ab500 100644
--- a/libcxx/include/__atomic/atomic_ref.h
+++ b/libcxx/include/__atomic/atomic_ref.h
@@ -57,11 +57,6 @@ struct __get_aligner_instance {
 
 template 
 struct __atomic_ref_base {
-protected:
-  _Tp* __ptr_;
-
-  _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : 
__ptr_(std::addressof(__obj)) {}
-
 private:
   _LIBCPP_HIDE_FROM_ABI static _Tp* __clear_padding(_Tp& __val) noexcept {
 _Tp* __ptr = std::addressof(__val);
@@ -108,10 +103,14 @@ struct __atomic_ref_base {
 
   friend struct __atomic_waitable_traits<__atomic_ref_base<_Tp>>;
 
+  // require types that are 1, 2, 4, 8, or 16 bytes in length to be aligned to 
at least their size to be potentially
+  // used lock-free
+  static constexpr size_t __min_alignment = (sizeof(_Tp) & (sizeof(_Tp) - 1)) 
|| (sizeof(_Tp) > 16) ? 0 : sizeof(_Tp);
+
 public:
   using value_type = _Tp;
 
-  static constexpr size_t required_alignment = alignof(_Tp);
+  static constexpr size_t required_alignment = alignof(_Tp) > __min_alignment 
? alignof(_Tp) : __min_alignment;
 
   // The __atomic_always_lock_free builtin takes into account the alignment of 
the pointer if provided,
   // so we create a fake pointer with a suitable alignment when querying it. 
Note that we are guaranteed
@@ -218,6 +217,12 @@ struct __atomic_ref_base {
   }
   _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { 
std::__atomic_notify_one(*this); }
   _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { 
std::__atomic_notify_all(*this); }
+
+protected:
+  typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment)));
+  _Aligned_Tp* __ptr_;
+
+  _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : 
__ptr_(std::addressof(__obj)) {}
 };
 
 template 
diff --git a/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp 
b/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp
index acdbf63a24d85..78e46c0397951 100644
--- a/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp
@@ -54,7 +54,7 @@ void check_always_lock_free(std::atomic_ref const& a) {
 #define CHECK_ALWAYS_LOCK_FREE(T)  
\
   do { 
\
 typedef T type;
\
-type obj{};
\
+alignas(std::atomic_ref::required_alignment) type obj{}; 
\
 std::atomic_ref a(obj);  
\
 check_always_lock_free(a); 
\
   } while (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] [libcxx] 39e8e77 - [libc++] Increase atomic_ref's required alignment for small types (#99654)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

Author: Damien L-G
Date: 2024-08-02T09:25:20+02:00
New Revision: 39e8e7797ae868e82b4184fbadf4572ff9bd3aa3

URL: 
https://github.com/llvm/llvm-project/commit/39e8e7797ae868e82b4184fbadf4572ff9bd3aa3
DIFF: 
https://github.com/llvm/llvm-project/commit/39e8e7797ae868e82b4184fbadf4572ff9bd3aa3.diff

LOG: [libc++] Increase atomic_ref's required alignment for small types (#99654)

This patch increases the alignment requirement for std::atomic_ref
such that we can guarantee lockfree operations more often. Specifically,
we require types that are 1, 2, 4, 8, or 16 bytes in size to be aligned
to at least their size to be used with std::atomic_ref.

This is the case for most types, however a notable exception is
`long long` on x86, which is 8 bytes in length but has an alignment
of 4.

As a result of this patch, one has to be more careful about the
alignment of objects used with std::atomic_ref. Failure to provide
a properly-aligned object to std::atomic_ref is a precondition
violation and is technically UB. On the flipside, this allows us
to provide an atomic_ref that is actually lockfree more often,
which is an important QOI property.

More information in the discussion at 
https://github.com/llvm/llvm-project/pull/99570#issuecomment-2237668661.

Co-authored-by: Louis Dionne 
(cherry picked from commit 59ca618e3b7aec8c32e24d781bae436dc99b2727)

Added: 


Modified: 
libcxx/include/__atomic/atomic_ref.h
libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp

Removed: 




diff  --git a/libcxx/include/__atomic/atomic_ref.h 
b/libcxx/include/__atomic/atomic_ref.h
index 2849b82e1a3dd..b0180a37ab500 100644
--- a/libcxx/include/__atomic/atomic_ref.h
+++ b/libcxx/include/__atomic/atomic_ref.h
@@ -57,11 +57,6 @@ struct __get_aligner_instance {
 
 template 
 struct __atomic_ref_base {
-protected:
-  _Tp* __ptr_;
-
-  _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : 
__ptr_(std::addressof(__obj)) {}
-
 private:
   _LIBCPP_HIDE_FROM_ABI static _Tp* __clear_padding(_Tp& __val) noexcept {
 _Tp* __ptr = std::addressof(__val);
@@ -108,10 +103,14 @@ struct __atomic_ref_base {
 
   friend struct __atomic_waitable_traits<__atomic_ref_base<_Tp>>;
 
+  // require types that are 1, 2, 4, 8, or 16 bytes in length to be aligned to 
at least their size to be potentially
+  // used lock-free
+  static constexpr size_t __min_alignment = (sizeof(_Tp) & (sizeof(_Tp) - 1)) 
|| (sizeof(_Tp) > 16) ? 0 : sizeof(_Tp);
+
 public:
   using value_type = _Tp;
 
-  static constexpr size_t required_alignment = alignof(_Tp);
+  static constexpr size_t required_alignment = alignof(_Tp) > __min_alignment 
? alignof(_Tp) : __min_alignment;
 
   // The __atomic_always_lock_free builtin takes into account the alignment of 
the pointer if provided,
   // so we create a fake pointer with a suitable alignment when querying it. 
Note that we are guaranteed
@@ -218,6 +217,12 @@ struct __atomic_ref_base {
   }
   _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { 
std::__atomic_notify_one(*this); }
   _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { 
std::__atomic_notify_all(*this); }
+
+protected:
+  typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment)));
+  _Aligned_Tp* __ptr_;
+
+  _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : 
__ptr_(std::addressof(__obj)) {}
 };
 
 template 

diff  --git a/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp 
b/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp
index acdbf63a24d85..78e46c0397951 100644
--- a/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.ref/is_always_lock_free.pass.cpp
@@ -54,7 +54,7 @@ void check_always_lock_free(std::atomic_ref const& a) {
 #define CHECK_ALWAYS_LOCK_FREE(T)  
\
   do { 
\
 typedef T type;
\
-type obj{};
\
+alignas(std::atomic_ref::required_alignment) type obj{}; 
\
 std::atomic_ref a(obj);  
\
 check_always_lock_free(a); 
\
   } while (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] [libcxx] release/19.x: [libc++] Increase atomic_ref's required alignment for small types (#99654) (PR #101492)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101492
___
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/19.x: [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_{arm, mips64, powerpc} declarations (#101403) (PR #101465)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@DimitryAndric (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/101465
___
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] [libcxxabi] [libunwind] release/19x: [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (#101196) (PR #101527)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101527

>From 3ee69f240579430c0c0abdc4641ccdf85b4efe92 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Thu, 1 Aug 2024 07:25:01 -0400
Subject: [PATCH] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX
 triples used in LIT tests (#101196)

This patch fixes/unifies AIX target triples used in libc++, libc++abi,
and libunwind LIT tests.

(cherry picked from commit 2d3655037ccfa276cb0949c2ce0cff56985f6637)
---
 libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp| 2 +-
 libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s  | 2 +-
 libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s  | 2 +-
 .../test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S   | 2 +-
 .../test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S   | 2 +-
 libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp | 2 +-
 libcxxabi/test/vendor/ibm/vec_reg_restore.pass.cpp  | 2 +-
 libunwind/test/aix_signal_unwind.pass.sh.S  | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp 
b/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
index 2b684465650fa..3714e4037a2dc 100644
--- a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
+++ b/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-// REQUIRES: target={{powerpc.*-ibm-aix.*}}
+// REQUIRES: target={{.+}}-aix{{.*}}
 // ADDITIONAL_COMPILE_FLAGS: -fvisibility-inlines-hidden
 
 // When there is a weak hidden symbol in user code and a strong definition
diff --git a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s 
b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
index ce90045586082..b35c999e6e50d 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
@@ -9,7 +9,7 @@
 # Test that a nested exception is thrown by a destructor inside a try-block
 # when the code is generated by the legacy AIX xlclang compiler.
 
-# REQUIRES: target=powerpc-ibm-aix
+# REQUIRES: target=powerpc-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 # RUN: %{cxx} %{flags} %s %{link_flags} \
diff --git a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s 
b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
index 7b0afb9ebae38..16754db2837ca 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
@@ -8,7 +8,7 @@
 # Test that a nested exception is thrown by a destructor inside a try-block
 # when the code is generated by the legacy AIX xlclang compiler.
 
-# REQUIRES: target=powerpc64-ibm-aix
+# REQUIRES: target=powerpc64-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 # RUN: %{cxx} %{flags} %s %{link_flags} \
diff --git 
a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S 
b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
index 71c3ab9409a81..8b92e4febf562 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
@@ -14,7 +14,7 @@
 // xlclang++ compiler included in this file. This file tests for the 32-bit
 // mode.
 
-# REQUIRES: target=powerpc-ibm-aix
+# REQUIRES: target=powerpc-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 // RUN: %{cxx} -c %s -o %t1_32.o -DT1_CPP_CODE %{flags} %{compile_flags}
diff --git 
a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S 
b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
index da413577bd38f..64d7c80e9e6dd 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
@@ -14,7 +14,7 @@
 // xlclang++ compiler included in this file. This file tests for the 64-bit
 // mode.
 
-# REQUIRES: target=powerpc64-ibm-aix
+# REQUIRES: target=powerpc64-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 // RUN: %{cxx} -c %s -o %t1_64.o -DT1_CPP_CODE %{flags} %{compile_flags}
diff --git a/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp 
b/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
index 63817e1b13a25..a5eb3c20534a3 100644
--- a/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
+++ b/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
@@ -10,7 +10,7 @@
 // on AIX. Option -O3 is required so that the compiler will re-use the value
 // in the condition register instead of re-evaluating the condition expression.
 
-// REQUIRES: target=powerpc{{(64)?}}-ibm-aix
+// REQUIRES: target={{.+}}-aix{{.*}}
 // ADDITIONAL_COMPILE_FLAGS: -O3
 // UNSUPPORTED: no-exceptions
 
diff --git a/libcxxabi/test/vendor/ibm/vec_reg_restore.pass.cpp 
b/libcxxabi/test/vendor/ibm/vec_reg_resto

[llvm-branch-commits] [libcxx] release/19.x: [libc++] Increase atomic_ref's required alignment for small types (#99654) (PR #101492)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ldionne (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/101492
___
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] 3ee69f2 - [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (#101196)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

Author: Xing Xue
Date: 2024-08-02T09:26:00+02:00
New Revision: 3ee69f240579430c0c0abdc4641ccdf85b4efe92

URL: 
https://github.com/llvm/llvm-project/commit/3ee69f240579430c0c0abdc4641ccdf85b4efe92
DIFF: 
https://github.com/llvm/llvm-project/commit/3ee69f240579430c0c0abdc4641ccdf85b4efe92.diff

LOG: [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in 
LIT tests (#101196)

This patch fixes/unifies AIX target triples used in libc++, libc++abi,
and libunwind LIT tests.

(cherry picked from commit 2d3655037ccfa276cb0949c2ce0cff56985f6637)

Added: 


Modified: 
libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
libcxxabi/test/vendor/ibm/vec_reg_restore.pass.cpp
libunwind/test/aix_signal_unwind.pass.sh.S

Removed: 




diff  --git a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp 
b/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
index 2b684465650fa..3714e4037a2dc 100644
--- a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
+++ b/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-// REQUIRES: target={{powerpc.*-ibm-aix.*}}
+// REQUIRES: target={{.+}}-aix{{.*}}
 // ADDITIONAL_COMPILE_FLAGS: -fvisibility-inlines-hidden
 
 // When there is a weak hidden symbol in user code and a strong definition

diff  --git a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s 
b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
index ce90045586082..b35c999e6e50d 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
@@ -9,7 +9,7 @@
 # Test that a nested exception is thrown by a destructor inside a try-block
 # when the code is generated by the legacy AIX xlclang compiler.
 
-# REQUIRES: target=powerpc-ibm-aix
+# REQUIRES: target=powerpc-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 # RUN: %{cxx} %{flags} %s %{link_flags} \

diff  --git a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s 
b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
index 7b0afb9ebae38..16754db2837ca 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
@@ -8,7 +8,7 @@
 # Test that a nested exception is thrown by a destructor inside a try-block
 # when the code is generated by the legacy AIX xlclang compiler.
 
-# REQUIRES: target=powerpc64-ibm-aix
+# REQUIRES: target=powerpc64-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 # RUN: %{cxx} %{flags} %s %{link_flags} \

diff  --git 
a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S 
b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
index 71c3ab9409a81..8b92e4febf562 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
@@ -14,7 +14,7 @@
 // xlclang++ compiler included in this file. This file tests for the 32-bit
 // mode.
 
-# REQUIRES: target=powerpc-ibm-aix
+# REQUIRES: target=powerpc-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 // RUN: %{cxx} -c %s -o %t1_32.o -DT1_CPP_CODE %{flags} %{compile_flags}

diff  --git 
a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S 
b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
index da413577bd38f..64d7c80e9e6dd 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
@@ -14,7 +14,7 @@
 // xlclang++ compiler included in this file. This file tests for the 64-bit
 // mode.
 
-# REQUIRES: target=powerpc64-ibm-aix
+# REQUIRES: target=powerpc64-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 // RUN: %{cxx} -c %s -o %t1_64.o -DT1_CPP_CODE %{flags} %{compile_flags}

diff  --git a/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp 
b/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
index 63817e1b13a25..a5eb3c20534a3 100644
--- a/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
+++ b/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
@@ -10,7 +10,7 @@
 // on AIX. Option -O3 is required so that the compiler will re-use the value
 // in the condition register instead of re-evaluating the condition expression.
 
-// REQUIRES: target=powerpc{{(64)?}}-ibm-aix
+// REQUIRES: target={{.+}}-aix{{.*}}
 // ADDITIONAL_COMPILE_FLAGS: -O3
 // UNSUPPORTED: no-exceptions
 

diff  --git a/libcxxabi/tes

[llvm-branch-commits] [libcxx] [libcxxabi] [libunwind] release/19x: [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (#101196) (PR #101527)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101527
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] release/19.x: [ELF] Support relocatable files using CREL with explicit addends (PR #101532)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101532

>From 142499d9a21309c7c5bacf34c35bb42fbffb7a8f Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 1 Aug 2024 10:22:03 -0700
Subject: [PATCH] [ELF] Support relocatable files using CREL with explicit
 addends

... using the temporary section type code 0x4020
(`clang -c -Wa,--crel,--allow-experimental-crel`). LLVM will change the
code and break compatibility (Clang and lld of different versions are
not guaranteed to cooperate, unlike other features). CREL with implicit
addends are not supported.

---

Introduce `RelsOrRelas::crels` to iterate over SHT_CREL sections and
update users to check `crels`.

(The decoding performance is critical and error checking is difficult.
Follow `skipLeb` and `R_*LEB128` handling, do not use
`llvm::decodeULEB128`, whichs compiles to a lot of code.)

A few users (e.g. .eh_frame, LLDDwarfObj, s390x) require random access. Pass
`/*supportsCrel=*/false` to `relsOrRelas` to allocate a buffer and
convert CREL to RELA (`relas` instead of `crels` will be used). Since
allocating a buffer increases, the conversion is only performed when
absolutely necessary.

---

Non-alloc SHT_CREL sections may be created in -r and --emit-relocs
links. SHT_CREL and SHT_RELA components need reencoding since
r_offset/r_symidx/r_type/r_addend may change. (r_type may change because
relocations referencing a symbol in a discarded section are converted to
`R_*_NONE`).

* SHT_CREL components: decode with `RelsOrRelas` and re-encode 
(`OutputSection::finalizeNonAllocCrel`)
* SHT_RELA components: convert to CREL (`relToCrel`). An output section can 
only have one relocation section.
* SHT_REL components: print an error for now.

SHT_REL to SHT_CREL conversion for -r/--emit-relocs is complex and
unsupported yet.

Link: 
https://discourse.llvm.org/t/rfc-crel-a-compact-relocation-format-for-elf/77600

Pull Request: https://github.com/llvm/llvm-project/pull/98115

(cherry picked from commit 0af07c078798b7c427e2981377781b5cc555a568)
---
 lld/ELF/DWARF.cpp  |   3 +-
 lld/ELF/ICF.cpp|   8 +-
 lld/ELF/InputFiles.cpp |   1 +
 lld/ELF/InputFiles.h   |   1 +
 lld/ELF/InputSection.cpp   |  67 ---
 lld/ELF/InputSection.h |  14 ++-
 lld/ELF/LinkerScript.cpp   |   2 +
 lld/ELF/MarkLive.cpp   |  12 +-
 lld/ELF/OutputSections.cpp | 132 -
 lld/ELF/OutputSections.h   |   6 +
 lld/ELF/Relocations.cpp|  38 --
 lld/ELF/Relocations.h  |  92 ++
 lld/ELF/SyntheticSections.cpp  |   6 +-
 lld/ELF/Writer.cpp |  13 +-
 lld/test/ELF/crel-rel-mixed.s  |  22 
 lld/test/ELF/crel.s|  90 ++
 lld/test/ELF/debug-names.s |   2 +-
 lld/test/ELF/gc-sections.s |   4 +
 lld/test/ELF/icf1.s|   3 +
 lld/test/ELF/icf4.s|   2 +-
 lld/test/ELF/linkerscript/nocrossrefs.test |   4 +-
 lld/test/ELF/relocatable-crel-32.s |  71 +++
 lld/test/ELF/relocatable-crel.s| 107 +
 23 files changed, 656 insertions(+), 44 deletions(-)
 create mode 100644 lld/test/ELF/crel-rel-mixed.s
 create mode 100644 lld/test/ELF/crel.s
 create mode 100644 lld/test/ELF/relocatable-crel-32.s
 create mode 100644 lld/test/ELF/relocatable-crel.s

diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp
index 5d58e0c60a952..517d26810a378 100644
--- a/lld/ELF/DWARF.cpp
+++ b/lld/ELF/DWARF.cpp
@@ -136,7 +136,8 @@ template 
 std::optional
 LLDDwarfObj::find(const llvm::DWARFSection &s, uint64_t pos) const {
   auto &sec = static_cast(s);
-  const RelsOrRelas rels = sec.sec->template relsOrRelas();
+  const RelsOrRelas rels =
+  sec.sec->template relsOrRelas(/*supportsCrel=*/false);
   if (rels.areRelocsRel())
 return findAux(*sec.sec, pos, rels.rels);
   return findAux(*sec.sec, pos, rels.relas);
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index a6b52d78fa806..44e8a71cc6286 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -324,6 +324,8 @@ bool ICF::equalsConstant(const InputSection *a, const 
InputSection *b) {
 
   const RelsOrRelas ra = a->template relsOrRelas();
   const RelsOrRelas rb = b->template relsOrRelas();
+  if (ra.areRelocsCrel())
+return constantEq(a, ra.crels, b, rb.crels);
   return ra.areRelocsRel() || rb.areRelocsRel()
  ? constantEq(a, ra.rels, b, rb.rels)
  : constantEq(a, ra.relas, b, rb.relas);
@@ -374,6 +376,8 @@ template 
 bool ICF::equalsVariable(const InputSection *a, const InputSection *b) {
   const RelsOrRelas ra = a->template relsOrRelas();
   const RelsOrRelas rb = b->template relsOrRelas();
+  if (ra.areRelocsCrel())
+return variableEq(a, ra.crels, b,

[llvm-branch-commits] [lld] 142499d - [ELF] Support relocatable files using CREL with explicit addends

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

Author: Fangrui Song
Date: 2024-08-02T09:26:37+02:00
New Revision: 142499d9a21309c7c5bacf34c35bb42fbffb7a8f

URL: 
https://github.com/llvm/llvm-project/commit/142499d9a21309c7c5bacf34c35bb42fbffb7a8f
DIFF: 
https://github.com/llvm/llvm-project/commit/142499d9a21309c7c5bacf34c35bb42fbffb7a8f.diff

LOG: [ELF] Support relocatable files using CREL with explicit addends

... using the temporary section type code 0x4020
(`clang -c -Wa,--crel,--allow-experimental-crel`). LLVM will change the
code and break compatibility (Clang and lld of different versions are
not guaranteed to cooperate, unlike other features). CREL with implicit
addends are not supported.

---

Introduce `RelsOrRelas::crels` to iterate over SHT_CREL sections and
update users to check `crels`.

(The decoding performance is critical and error checking is difficult.
Follow `skipLeb` and `R_*LEB128` handling, do not use
`llvm::decodeULEB128`, whichs compiles to a lot of code.)

A few users (e.g. .eh_frame, LLDDwarfObj, s390x) require random access. Pass
`/*supportsCrel=*/false` to `relsOrRelas` to allocate a buffer and
convert CREL to RELA (`relas` instead of `crels` will be used). Since
allocating a buffer increases, the conversion is only performed when
absolutely necessary.

---

Non-alloc SHT_CREL sections may be created in -r and --emit-relocs
links. SHT_CREL and SHT_RELA components need reencoding since
r_offset/r_symidx/r_type/r_addend may change. (r_type may change because
relocations referencing a symbol in a discarded section are converted to
`R_*_NONE`).

* SHT_CREL components: decode with `RelsOrRelas` and re-encode 
(`OutputSection::finalizeNonAllocCrel`)
* SHT_RELA components: convert to CREL (`relToCrel`). An output section can 
only have one relocation section.
* SHT_REL components: print an error for now.

SHT_REL to SHT_CREL conversion for -r/--emit-relocs is complex and
unsupported yet.

Link: 
https://discourse.llvm.org/t/rfc-crel-a-compact-relocation-format-for-elf/77600

Pull Request: https://github.com/llvm/llvm-project/pull/98115

(cherry picked from commit 0af07c078798b7c427e2981377781b5cc555a568)

Added: 
lld/test/ELF/crel-rel-mixed.s
lld/test/ELF/crel.s
lld/test/ELF/relocatable-crel-32.s
lld/test/ELF/relocatable-crel.s

Modified: 
lld/ELF/DWARF.cpp
lld/ELF/ICF.cpp
lld/ELF/InputFiles.cpp
lld/ELF/InputFiles.h
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h
lld/ELF/LinkerScript.cpp
lld/ELF/MarkLive.cpp
lld/ELF/OutputSections.cpp
lld/ELF/OutputSections.h
lld/ELF/Relocations.cpp
lld/ELF/Relocations.h
lld/ELF/SyntheticSections.cpp
lld/ELF/Writer.cpp
lld/test/ELF/debug-names.s
lld/test/ELF/gc-sections.s
lld/test/ELF/icf1.s
lld/test/ELF/icf4.s
lld/test/ELF/linkerscript/nocrossrefs.test

Removed: 




diff  --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp
index 5d58e0c60a952..517d26810a378 100644
--- a/lld/ELF/DWARF.cpp
+++ b/lld/ELF/DWARF.cpp
@@ -136,7 +136,8 @@ template 
 std::optional
 LLDDwarfObj::find(const llvm::DWARFSection &s, uint64_t pos) const {
   auto &sec = static_cast(s);
-  const RelsOrRelas rels = sec.sec->template relsOrRelas();
+  const RelsOrRelas rels =
+  sec.sec->template relsOrRelas(/*supportsCrel=*/false);
   if (rels.areRelocsRel())
 return findAux(*sec.sec, pos, rels.rels);
   return findAux(*sec.sec, pos, rels.relas);

diff  --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index a6b52d78fa806..44e8a71cc6286 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -324,6 +324,8 @@ bool ICF::equalsConstant(const InputSection *a, const 
InputSection *b) {
 
   const RelsOrRelas ra = a->template relsOrRelas();
   const RelsOrRelas rb = b->template relsOrRelas();
+  if (ra.areRelocsCrel())
+return constantEq(a, ra.crels, b, rb.crels);
   return ra.areRelocsRel() || rb.areRelocsRel()
  ? constantEq(a, ra.rels, b, rb.rels)
  : constantEq(a, ra.relas, b, rb.relas);
@@ -374,6 +376,8 @@ template 
 bool ICF::equalsVariable(const InputSection *a, const InputSection *b) {
   const RelsOrRelas ra = a->template relsOrRelas();
   const RelsOrRelas rb = b->template relsOrRelas();
+  if (ra.areRelocsCrel())
+return variableEq(a, ra.crels, b, rb.crels);
   return ra.areRelocsRel() || rb.areRelocsRel()
  ? variableEq(a, ra.rels, b, rb.rels)
  : variableEq(a, ra.relas, b, rb.relas);
@@ -505,7 +509,9 @@ template  void ICF::run() {
   for (unsigned cnt = 0; cnt != 2; ++cnt) {
 parallelForEach(sections, [&](InputSection *s) {
   const RelsOrRelas rels = s->template relsOrRelas();
-  if (rels.areRelocsRel())
+  if (rels.areRelocsCrel())
+combineRelocHashes(cnt, s, rels.crels);
+  else if (rels.areRelocsRel())
 combineRelocHashes(cnt, s, rels.rels);
   else
 combineRelocHashes(cnt, s, rels.relas);

diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFile

[llvm-branch-commits] [lld] release/19.x: [ELF] Support relocatable files using CREL with explicit addends (PR #101532)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101532
___
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] [libcxxabi] [libunwind] release/19x: [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (#101196) (PR #101527)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@xingxue-ibm (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/101527
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] release/19.x: [ELF] Support relocatable files using CREL with explicit addends (PR #101532)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@MaskRay (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/101532
___
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] Lower omp.workshare to other omp constructs (PR #101446)

2024-08-02 Thread Ivan R. Ivanov via llvm-branch-commits


@@ -0,0 +1,259 @@
+//===- LowerWorkshare.cpp - special cases for bufferization ---===//
+//
+// 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
+//
+//===--===//
+// Lower omp workshare construct.
+//===--===//
+
+#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/OpenMP/Passes.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/IRMapping.h"
+#include "mlir/IR/OpDefinition.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Support/LLVM.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/iterator_range.h"
+
+#include 
+
+namespace flangomp {
+#define GEN_PASS_DEF_LOWERWORKSHARE
+#include "flang/Optimizer/OpenMP/Passes.h.inc"
+} // namespace flangomp
+
+#define DEBUG_TYPE "lower-workshare"
+
+using namespace mlir;
+
+namespace flangomp {
+bool shouldUseWorkshareLowering(Operation *op) {
+  auto workshare = dyn_cast(op->getParentOp());
+  if (!workshare)
+return false;
+  return workshare->getParentOfType();
+}
+} // namespace flangomp
+
+namespace {
+
+struct SingleRegion {
+  Block::iterator begin, end;
+};
+
+static bool isSupportedByFirAlloca(Type ty) {
+  return !isa(ty);
+}
+
+static bool isSafeToParallelize(Operation *op) {
+  if (isa(op))
+return true;
+
+  llvm::SmallVector effects;
+  MemoryEffectOpInterface interface = dyn_cast(op);
+  if (!interface) {
+return false;
+  }
+  interface.getEffects(effects);
+  if (effects.empty())
+return true;
+
+  return false;
+}
+
+/// Lowers workshare to a sequence of single-thread regions and parallel loops
+///
+/// For example:
+///
+/// omp.workshare {
+///   %a = fir.allocmem
+///   omp.wsloop {}
+///   fir.call Assign %b %a
+///   fir.freemem %a
+/// }
+///
+/// becomes
+///
+/// omp.single {
+///   %a = fir.allocmem
+///   fir.store %a %tmp
+/// }
+/// %a_reloaded = fir.load %tmp
+/// omp.wsloop {}
+/// omp.single {
+///   fir.call Assign %b %a_reloaded
+///   fir.freemem %a_reloaded
+/// }
+///
+/// Note that we allocate temporary memory for values in omp.single's which 
need
+/// to be accessed in all threads in the closest omp.parallel
+///
+/// TODO currently we need to be able to access the encompassing omp.parallel 
so
+/// that we can allocate temporaries accessible by all threads outside of it.
+/// In case we do not find it, we fall back to converting the omp.workshare to
+/// omp.single.
+/// To better handle this we should probably enable yielding values out of an
+/// omp.single which will be supported by the omp runtime.
+void lowerWorkshare(mlir::omp::WorkshareOp wsOp) {
+  assert(wsOp.getRegion().getBlocks().size() == 1);
+
+  Location loc = wsOp->getLoc();
+
+  omp::ParallelOp parallelOp = wsOp->getParentOfType();
+  if (!parallelOp) {
+wsOp.emitWarning("cannot handle workshare, converting to single");
+Operation *terminator = wsOp.getRegion().front().getTerminator();
+wsOp->getBlock()->getOperations().splice(
+wsOp->getIterator(), wsOp.getRegion().front().getOperations());
+terminator->erase();
+return;
+  }
+
+  OpBuilder allocBuilder(parallelOp);
+  OpBuilder rootBuilder(wsOp);
+  IRMapping rootMapping;
+
+  omp::SingleOp singleOp = nullptr;
+
+  auto mapReloadedValue = [&](Value v, OpBuilder singleBuilder,
+  IRMapping singleMapping) {
+if (auto reloaded = rootMapping.lookupOrNull(v))
+  return;
+Type llvmPtrTy = LLVM::LLVMPointerType::get(allocBuilder.getContext());
+Type ty = v.getType();
+Value alloc, reloaded;
+if (isSupportedByFirAlloca(ty)) {
+  alloc = allocBuilder.create(loc, ty);
+  singleBuilder.create(loc, singleMapping.lookup(v), alloc);
+  reloaded = rootBuilder.create(loc, ty, alloc);
+} else {

ivanradanov wrote:

I think building a fir.alloca for a ReferenceType fails and I encountered that 
somewhere. I will check again to see if I can get an example.

https://github.com/llvm/llvm-project/pull/101446
___
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] Lower omp.workshare to other omp constructs (PR #101446)

2024-08-02 Thread Ivan R. Ivanov via llvm-branch-commits


@@ -0,0 +1,259 @@
+//===- LowerWorkshare.cpp - special cases for bufferization ---===//
+//
+// 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
+//
+//===--===//
+// Lower omp workshare construct.
+//===--===//
+
+#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/OpenMP/Passes.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/IRMapping.h"
+#include "mlir/IR/OpDefinition.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Support/LLVM.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/iterator_range.h"
+
+#include 
+
+namespace flangomp {
+#define GEN_PASS_DEF_LOWERWORKSHARE
+#include "flang/Optimizer/OpenMP/Passes.h.inc"
+} // namespace flangomp
+
+#define DEBUG_TYPE "lower-workshare"
+
+using namespace mlir;
+
+namespace flangomp {
+bool shouldUseWorkshareLowering(Operation *op) {
+  auto workshare = dyn_cast(op->getParentOp());
+  if (!workshare)
+return false;
+  return workshare->getParentOfType();
+}
+} // namespace flangomp
+
+namespace {
+
+struct SingleRegion {
+  Block::iterator begin, end;
+};
+
+static bool isSupportedByFirAlloca(Type ty) {
+  return !isa(ty);
+}
+
+static bool isSafeToParallelize(Operation *op) {
+  if (isa(op))
+return true;
+
+  llvm::SmallVector effects;
+  MemoryEffectOpInterface interface = dyn_cast(op);
+  if (!interface) {
+return false;
+  }
+  interface.getEffects(effects);
+  if (effects.empty())
+return true;
+
+  return false;
+}
+
+/// Lowers workshare to a sequence of single-thread regions and parallel loops
+///
+/// For example:
+///
+/// omp.workshare {
+///   %a = fir.allocmem
+///   omp.wsloop {}
+///   fir.call Assign %b %a
+///   fir.freemem %a
+/// }
+///
+/// becomes
+///
+/// omp.single {
+///   %a = fir.allocmem
+///   fir.store %a %tmp
+/// }
+/// %a_reloaded = fir.load %tmp
+/// omp.wsloop {}
+/// omp.single {
+///   fir.call Assign %b %a_reloaded
+///   fir.freemem %a_reloaded
+/// }
+///
+/// Note that we allocate temporary memory for values in omp.single's which 
need
+/// to be accessed in all threads in the closest omp.parallel
+///
+/// TODO currently we need to be able to access the encompassing omp.parallel 
so
+/// that we can allocate temporaries accessible by all threads outside of it.
+/// In case we do not find it, we fall back to converting the omp.workshare to
+/// omp.single.
+/// To better handle this we should probably enable yielding values out of an
+/// omp.single which will be supported by the omp runtime.
+void lowerWorkshare(mlir::omp::WorkshareOp wsOp) {
+  assert(wsOp.getRegion().getBlocks().size() == 1);
+
+  Location loc = wsOp->getLoc();
+
+  omp::ParallelOp parallelOp = wsOp->getParentOfType();
+  if (!parallelOp) {
+wsOp.emitWarning("cannot handle workshare, converting to single");
+Operation *terminator = wsOp.getRegion().front().getTerminator();
+wsOp->getBlock()->getOperations().splice(
+wsOp->getIterator(), wsOp.getRegion().front().getOperations());
+terminator->erase();
+return;
+  }
+
+  OpBuilder allocBuilder(parallelOp);
+  OpBuilder rootBuilder(wsOp);
+  IRMapping rootMapping;
+
+  omp::SingleOp singleOp = nullptr;
+
+  auto mapReloadedValue = [&](Value v, OpBuilder singleBuilder,
+  IRMapping singleMapping) {
+if (auto reloaded = rootMapping.lookupOrNull(v))
+  return;
+Type llvmPtrTy = LLVM::LLVMPointerType::get(allocBuilder.getContext());
+Type ty = v.getType();
+Value alloc, reloaded;
+if (isSupportedByFirAlloca(ty)) {
+  alloc = allocBuilder.create(loc, ty);
+  singleBuilder.create(loc, singleMapping.lookup(v), alloc);

ivanradanov wrote:

I am sorry, this is probably due to my inexperience with flang/fortran, are 
there any types in flang that get automatically freed on scope exit? Because if 
I make a shallow copy of an allocatable array, the operation that frees it will 
be put in a omp.single, thus freeing it only once sincle the free operation 
would not be `IsSafeToParallelize`.

e.g. 

```
%a = fir.allocmem
use(%a)
fir.freemem %a

->

omp.single{ %a = fir.allocmem}
use(%a)
omp.single{ fir.freemem %a }
```



https://github.com/llvm/llvm-project/pull/101446
___
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] Lower omp.workshare to other omp constructs (PR #101446)

2024-08-02 Thread Ivan R. Ivanov via llvm-branch-commits

https://github.com/ivanradanov edited 
https://github.com/llvm/llvm-project/pull/101446
___
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] [llvm] release/19.x: Fix for #96126, add `BitmapBiasAddr` to definitions for unsupported targets. (PR #101629)

2024-08-02 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/101629
___
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] [llvm] release/19.x: Fix for #96126, add `BitmapBiasAddr` to definitions for unsupported targets. (PR #101629)

2024-08-02 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/101629

Backport d2f77eb8ec620c8068fa471a1d7b9c9756da1913 
891d89804b9a8a2be949aa2aca30acba9bc64ebb 
20d723e626befde6d1de66595ce37521cbde0538

Requested by: @chapuni

>From c44d2e04aa51ef928a4f400e4e1f55a5d2234fb8 Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi 
Date: Wed, 31 Jul 2024 10:14:12 +0900
Subject: [PATCH 1/3] [MC/DC][Coverage] Introduce "Bitmap Bias" for continuous
 mode (#96126)

`counter_bias` is incompatible to Bitmap. The distance between Counters
and Bitmap is different between on-memory sections and profraw image.

Reference to `__llvm_profile_bitmap_bias` is generated only if
`-fcoverge-mcdc` `-runtime-counter-relocation` are specified. The
current implementation rejected their options.

```
Runtime counter relocation is presently not supported for MC/DC bitmaps
```

(cherry picked from commit d2f77eb8ec620c8068fa471a1d7b9c9756da1913)
---
 compiler-rt/include/profile/InstrProfData.inc |  1 +
 compiler-rt/lib/profile/InstrProfilingFile.c  | 40 +--
 llvm/include/llvm/ProfileData/InstrProf.h |  4 ++
 .../llvm/ProfileData/InstrProfData.inc|  1 +
 .../Instrumentation/InstrProfiling.cpp| 26 +++-
 .../Instrumentation/InstrProfiling/mcdc.ll| 12 --
 6 files changed, 67 insertions(+), 17 deletions(-)

diff --git a/compiler-rt/include/profile/InstrProfData.inc 
b/compiler-rt/include/profile/InstrProfData.inc
index 847e53cfa74328..b9df3266fbcf8f 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -738,6 +738,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 #define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
 #define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
 #define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias
+#define INSTR_PROF_PROFILE_BITMAP_BIAS_VAR __llvm_profile_bitmap_bias
 #define INSTR_PROF_PROFILE_SET_TIMESTAMP __llvm_profile_set_timestamp
 #define INSTR_PROF_PROFILE_SAMPLING_VAR __llvm_profile_sampling
 
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index 1c58584d2d4f73..1116ea0bb23961 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -101,6 +101,8 @@ static const int UseBiasVar = 0;
 static const char *FileOpenMode = "a+b";
 static void *BiasAddr = NULL;
 static void *BiasDefaultAddr = NULL;
+static void *BitmapBiasAddr = NULL;
+static void *BitmapBiasDefaultAddr = NULL;
 static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
   /* Get the sizes of various profile data sections. Taken from
* __llvm_profile_get_size_for_buffer(). */
@@ -199,11 +201,15 @@ static int mmapForContinuousMode(uint64_t 
CurrentFileOffset, FILE *File) {
 #define INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR
\
   INSTR_PROF_CONCAT(INSTR_PROF_PROFILE_COUNTER_BIAS_VAR, _default)
 COMPILER_RT_VISIBILITY intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR = 
0;
+#define INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR 
\
+  INSTR_PROF_CONCAT(INSTR_PROF_PROFILE_BITMAP_BIAS_VAR, _default)
+COMPILER_RT_VISIBILITY intptr_t INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR = 0;
 
 /* This variable is a weak external reference which could be used to detect
  * whether or not the compiler defined this symbol. */
 #if defined(_MSC_VER)
 COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_VAR;
+COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_BITMAP_BIAS_VAR;
 #if defined(_M_IX86) || defined(__i386__)
 #define WIN_SYM_PREFIX "_"
 #else
@@ -213,10 +219,17 @@ COMPILER_RT_VISIBILITY extern intptr_t 
INSTR_PROF_PROFILE_COUNTER_BIAS_VAR;
 linker, "/alternatename:" WIN_SYM_PREFIX INSTR_PROF_QUOTE( 
\
 INSTR_PROF_PROFILE_COUNTER_BIAS_VAR) "=" WIN_SYM_PREFIX
\
 INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR))
+#pragma comment(   
\
+linker, "/alternatename:" WIN_SYM_PREFIX INSTR_PROF_QUOTE( 
\
+INSTR_PROF_PROFILE_BITMAP_BIAS_VAR) "=" WIN_SYM_PREFIX 
\
+INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR))
 #else
 COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_VAR
 __attribute__((weak, alias(INSTR_PROF_QUOTE(
  INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR;
+COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_BITMAP_BIAS_VAR
+__attribute__((weak, alias(INSTR_PROF_QUOTE(
+ INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR;
 #endif
 static const int ContinuousModeSupported = 1;
 static const int UseBiasVar = 1;
@@ -227,6 +240,9 @@ static const char *FileOpenMode = "w+b";
  * used and runtime 

[llvm-branch-commits] [compiler-rt] [llvm] release/19.x: Fix for #96126, add `BitmapBiasAddr` to definitions for unsupported targets. (PR #101629)

2024-08-02 Thread via llvm-branch-commits

llvmbot wrote:

@chapuni What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/101629
___
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] [llvm] release/19.x: Fix for #96126, add `BitmapBiasAddr` to definitions for unsupported targets. (PR #101629)

2024-08-02 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

Backport d2f77eb8ec620c8068fa471a1d7b9c9756da1913 
891d89804b9a8a2be949aa2aca30acba9bc64ebb 
20d723e626befde6d1de66595ce37521cbde0538

Requested by: @chapuni

---
Full diff: https://github.com/llvm/llvm-project/pull/101629.diff


6 Files Affected:

- (modified) compiler-rt/include/profile/InstrProfData.inc (+1) 
- (modified) compiler-rt/lib/profile/InstrProfilingFile.c (+39-3) 
- (modified) llvm/include/llvm/ProfileData/InstrProf.h (+4) 
- (modified) llvm/include/llvm/ProfileData/InstrProfData.inc (+1) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+15-11) 
- (modified) llvm/test/Instrumentation/InstrProfiling/mcdc.ll (+9-3) 


``diff
diff --git a/compiler-rt/include/profile/InstrProfData.inc 
b/compiler-rt/include/profile/InstrProfData.inc
index 847e53cfa74328..b9df3266fbcf8f 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -738,6 +738,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 #define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
 #define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
 #define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias
+#define INSTR_PROF_PROFILE_BITMAP_BIAS_VAR __llvm_profile_bitmap_bias
 #define INSTR_PROF_PROFILE_SET_TIMESTAMP __llvm_profile_set_timestamp
 #define INSTR_PROF_PROFILE_SAMPLING_VAR __llvm_profile_sampling
 
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index 1c58584d2d4f73..db3918d8410319 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -101,6 +101,8 @@ static const int UseBiasVar = 0;
 static const char *FileOpenMode = "a+b";
 static void *BiasAddr = NULL;
 static void *BiasDefaultAddr = NULL;
+static void *BitmapBiasAddr = NULL;
+static void *BitmapBiasDefaultAddr = NULL;
 static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
   /* Get the sizes of various profile data sections. Taken from
* __llvm_profile_get_size_for_buffer(). */
@@ -199,11 +201,15 @@ static int mmapForContinuousMode(uint64_t 
CurrentFileOffset, FILE *File) {
 #define INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR
\
   INSTR_PROF_CONCAT(INSTR_PROF_PROFILE_COUNTER_BIAS_VAR, _default)
 COMPILER_RT_VISIBILITY intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR = 
0;
+#define INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR 
\
+  INSTR_PROF_CONCAT(INSTR_PROF_PROFILE_BITMAP_BIAS_VAR, _default)
+COMPILER_RT_VISIBILITY intptr_t INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR = 0;
 
 /* This variable is a weak external reference which could be used to detect
  * whether or not the compiler defined this symbol. */
 #if defined(_MSC_VER)
 COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_VAR;
+COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_BITMAP_BIAS_VAR;
 #if defined(_M_IX86) || defined(__i386__)
 #define WIN_SYM_PREFIX "_"
 #else
@@ -213,10 +219,17 @@ COMPILER_RT_VISIBILITY extern intptr_t 
INSTR_PROF_PROFILE_COUNTER_BIAS_VAR;
 linker, "/alternatename:" WIN_SYM_PREFIX INSTR_PROF_QUOTE( 
\
 INSTR_PROF_PROFILE_COUNTER_BIAS_VAR) "=" WIN_SYM_PREFIX
\
 INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR))
+#pragma comment(   
\
+linker, "/alternatename:" WIN_SYM_PREFIX INSTR_PROF_QUOTE( 
\
+INSTR_PROF_PROFILE_BITMAP_BIAS_VAR) "=" WIN_SYM_PREFIX 
\
+INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR))
 #else
 COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_COUNTER_BIAS_VAR
 __attribute__((weak, alias(INSTR_PROF_QUOTE(
  INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR;
+COMPILER_RT_VISIBILITY extern intptr_t INSTR_PROF_PROFILE_BITMAP_BIAS_VAR
+__attribute__((weak, alias(INSTR_PROF_QUOTE(
+ INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR;
 #endif
 static const int ContinuousModeSupported = 1;
 static const int UseBiasVar = 1;
@@ -227,6 +240,9 @@ static const char *FileOpenMode = "w+b";
  * used and runtime provides a weak alias so we can check if it's defined. */
 static void *BiasAddr = &INSTR_PROF_PROFILE_COUNTER_BIAS_VAR;
 static void *BiasDefaultAddr = &INSTR_PROF_PROFILE_COUNTER_BIAS_DEFAULT_VAR;
+static void *BitmapBiasAddr = &INSTR_PROF_PROFILE_BITMAP_BIAS_VAR;
+static void *BitmapBiasDefaultAddr =
+&INSTR_PROF_PROFILE_BITMAP_BIAS_DEFAULT_VAR;
 static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
   /* Get the sizes of various profile data sections. Taken from
* __llvm_profile_get_size_for_buffer(). */
@@ -237,12 +253,18 @@ static int mmapForContinuous

[llvm-branch-commits] [compiler-rt] [llvm] release/19.x: [MC/DC][Coverage] Introduce "Bitmap Bias" for continuous mode (#96126) (PR #101629)

2024-08-02 Thread NAKAMURA Takumi via llvm-branch-commits

https://github.com/chapuni edited 
https://github.com/llvm/llvm-project/pull/101629
___
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] [mlir] [flang] Lower omp.workshare to other omp constructs (PR #101446)

2024-08-02 Thread Ivan R. Ivanov via llvm-branch-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/101446

>From 62057f90e1e6e9e89df1bb666a3676421e2e52ac Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 2 Aug 2024 16:10:25 +0900
Subject: [PATCH 1/9] Add custom omp loop wrapper

---
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 5199ff50abb95..76f0c472cfdb1 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -308,6 +308,17 @@ def WorkshareOp : OpenMP_Op<"workshare", clauses = [
   let hasVerifier = 1;
 }
 
+def WorkshareLoopWrapperOp : OpenMP_Op<"workshare_loop_wrapper", traits = [
+DeclareOpInterfaceMethods,
+RecursiveMemoryEffects, SingleBlock
+  ], singleRegion = true> {
+  let summary = "contains loop nests to be parallelized by workshare";
+
+  let builders = [
+OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
+  ];
+}
+
 
//===--===//
 // Loop Nest
 
//===--===//

>From d882f2b7413a9ad306334cc69691671b498985fc Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 2 Aug 2024 16:08:58 +0900
Subject: [PATCH 2/9] Add recursive memory effects trait to workshare

---
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 76f0c472cfdb1..7d1c80333855e 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -290,7 +290,9 @@ def SingleOp : OpenMP_Op<"single", traits = [
 // 2.8.3 Workshare Construct
 
//===--===//
 
-def WorkshareOp : OpenMP_Op<"workshare", clauses = [
+def WorkshareOp : OpenMP_Op<"workshare", traits = [
+RecursiveMemoryEffects,
+  ], clauses = [
 OpenMP_NowaitClause,
   ], singleRegion = true> {
   let summary = "workshare directive";

>From 14878e80f5bcf8dac5100951de803ce584a33b25 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Wed, 31 Jul 2024 14:11:47 +0900
Subject: [PATCH 3/9] [flang][omp] Emit omp.workshare in frontend

---
 flang/lib/Lower/OpenMP/OpenMP.cpp | 30 ++
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 2b1839b5270d4..f7bc565ea8cbc 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1270,6 +1270,15 @@ static void genTaskwaitClauses(lower::AbstractConverter 
&converter,
   loc, llvm::omp::Directive::OMPD_taskwait);
 }
 
+static void genWorkshareClauses(lower::AbstractConverter &converter,
+semantics::SemanticsContext &semaCtx,
+lower::StatementContext &stmtCtx,
+const List &clauses, mlir::Location 
loc,
+mlir::omp::WorkshareOperands &clauseOps) {
+  ClauseProcessor cp(converter, semaCtx, clauses);
+  cp.processNowait(clauseOps);
+}
+
 static void genTeamsClauses(lower::AbstractConverter &converter,
 semantics::SemanticsContext &semaCtx,
 lower::StatementContext &stmtCtx,
@@ -1890,6 +1899,22 @@ genTaskyieldOp(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
   return converter.getFirOpBuilder().create(loc);
 }
 
+static mlir::omp::WorkshareOp
+genWorkshareOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+   semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+   mlir::Location loc, const ConstructQueue &queue,
+   ConstructQueue::iterator item) {
+  lower::StatementContext stmtCtx;
+  mlir::omp::WorkshareOperands clauseOps;
+  genWorkshareClauses(converter, semaCtx, stmtCtx, item->clauses, loc, 
clauseOps);
+
+  return genOpWithBody(
+  OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
+llvm::omp::Directive::OMPD_workshare)
+  .setClauses(&item->clauses),
+  queue, item, clauseOps);
+}
+
 static mlir::omp::TeamsOp
 genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
@@ -2249,10 +2274,7 @@ static void genOMPDispatch(lower::AbstractConverter 
&converter,
   llvm::omp::getOpenMPDirectiveName(dir) + ")");
   // case llvm::omp::Directive::OMPD_workdistribute:
   case llvm::omp::Directive::OMPD_workshare:
-// FIXME: Workshare is not a commonly used OpenMP construct, an
-// implementation for this feature will come later. F

[llvm-branch-commits] [flang] [flang][omp] Emit omp.workshare in frontend (PR #101444)

2024-08-02 Thread Ivan R. Ivanov via llvm-branch-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/101444

>From 14878e80f5bcf8dac5100951de803ce584a33b25 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Wed, 31 Jul 2024 14:11:47 +0900
Subject: [PATCH] [flang][omp] Emit omp.workshare in frontend

---
 flang/lib/Lower/OpenMP/OpenMP.cpp | 30 ++
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 2b1839b5270d4..f7bc565ea8cbc 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1270,6 +1270,15 @@ static void genTaskwaitClauses(lower::AbstractConverter 
&converter,
   loc, llvm::omp::Directive::OMPD_taskwait);
 }
 
+static void genWorkshareClauses(lower::AbstractConverter &converter,
+semantics::SemanticsContext &semaCtx,
+lower::StatementContext &stmtCtx,
+const List &clauses, mlir::Location 
loc,
+mlir::omp::WorkshareOperands &clauseOps) {
+  ClauseProcessor cp(converter, semaCtx, clauses);
+  cp.processNowait(clauseOps);
+}
+
 static void genTeamsClauses(lower::AbstractConverter &converter,
 semantics::SemanticsContext &semaCtx,
 lower::StatementContext &stmtCtx,
@@ -1890,6 +1899,22 @@ genTaskyieldOp(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
   return converter.getFirOpBuilder().create(loc);
 }
 
+static mlir::omp::WorkshareOp
+genWorkshareOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+   semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+   mlir::Location loc, const ConstructQueue &queue,
+   ConstructQueue::iterator item) {
+  lower::StatementContext stmtCtx;
+  mlir::omp::WorkshareOperands clauseOps;
+  genWorkshareClauses(converter, semaCtx, stmtCtx, item->clauses, loc, 
clauseOps);
+
+  return genOpWithBody(
+  OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
+llvm::omp::Directive::OMPD_workshare)
+  .setClauses(&item->clauses),
+  queue, item, clauseOps);
+}
+
 static mlir::omp::TeamsOp
 genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
@@ -2249,10 +2274,7 @@ static void genOMPDispatch(lower::AbstractConverter 
&converter,
   llvm::omp::getOpenMPDirectiveName(dir) + ")");
   // case llvm::omp::Directive::OMPD_workdistribute:
   case llvm::omp::Directive::OMPD_workshare:
-// FIXME: Workshare is not a commonly used OpenMP construct, an
-// implementation for this feature will come later. For the codes
-// that use this construct, add a single construct for now.
-genSingleOp(converter, symTable, semaCtx, eval, loc, queue, item);
+genWorkshareOp(converter, symTable, semaCtx, eval, loc, queue, item);
 break;
 
   // Composite constructs

___
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] Introduce ws loop nest generation for HLFIR lowering (PR #101445)

2024-08-02 Thread Ivan R. Ivanov via llvm-branch-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/101445

>From 16f7146a45ee9b31c00d9d54be4859df312dcb1b Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Wed, 31 Jul 2024 14:12:34 +0900
Subject: [PATCH 1/2] [flang] Introduce ws loop nest generation for HLFIR
 lowering

---
 .../flang/Optimizer/Builder/HLFIRTools.h  | 12 +++--
 flang/lib/Lower/ConvertCall.cpp   |  2 +-
 flang/lib/Lower/OpenMP/ReductionProcessor.cpp |  4 +-
 flang/lib/Optimizer/Builder/HLFIRTools.cpp| 52 ++-
 .../HLFIR/Transforms/BufferizeHLFIR.cpp   |  3 +-
 .../LowerHLFIROrderedAssignments.cpp  | 30 +--
 .../Transforms/OptimizedBufferization.cpp |  6 +--
 7 files changed, 69 insertions(+), 40 deletions(-)

diff --git a/flang/include/flang/Optimizer/Builder/HLFIRTools.h 
b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
index 6b41025eea078..14e42c6f358e4 100644
--- a/flang/include/flang/Optimizer/Builder/HLFIRTools.h
+++ b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
@@ -357,8 +357,8 @@ hlfir::ElementalOp genElementalOp(
 
 /// Structure to describe a loop nest.
 struct LoopNest {
-  fir::DoLoopOp outerLoop;
-  fir::DoLoopOp innerLoop;
+  mlir::Operation *outerOp;
+  mlir::Block *body;
   llvm::SmallVector oneBasedIndices;
 };
 
@@ -366,11 +366,13 @@ struct LoopNest {
 /// \p isUnordered specifies whether the loops in the loop nest
 /// are unordered.
 LoopNest genLoopNest(mlir::Location loc, fir::FirOpBuilder &builder,
- mlir::ValueRange extents, bool isUnordered = false);
+ mlir::ValueRange extents, bool isUnordered = false,
+ bool emitWsLoop = false);
 inline LoopNest genLoopNest(mlir::Location loc, fir::FirOpBuilder &builder,
-mlir::Value shape, bool isUnordered = false) {
+mlir::Value shape, bool isUnordered = false,
+bool emitWsLoop = false) {
   return genLoopNest(loc, builder, getIndexExtents(loc, builder, shape),
- isUnordered);
+ isUnordered, emitWsLoop);
 }
 
 /// Inline the body of an hlfir.elemental at the current insertion point
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index fd873f55dd844..0689d6e033dd9 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -2128,7 +2128,7 @@ class ElementalCallBuilder {
   hlfir::genLoopNest(loc, builder, shape, !mustBeOrdered);
   mlir::ValueRange oneBasedIndices = loopNest.oneBasedIndices;
   auto insPt = builder.saveInsertionPoint();
-  builder.setInsertionPointToStart(loopNest.innerLoop.getBody());
+  builder.setInsertionPointToStart(loopNest.body);
   callContext.stmtCtx.pushScope();
   for (auto &preparedActual : loweredActuals)
 if (preparedActual)
diff --git a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp 
b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
index c3c1f363033c2..72a90dd0d6f29 100644
--- a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
@@ -375,7 +375,7 @@ static void genBoxCombiner(fir::FirOpBuilder &builder, 
mlir::Location loc,
   // know this won't miss any opportuinties for clever elemental inlining
   hlfir::LoopNest nest = hlfir::genLoopNest(
   loc, builder, shapeShift.getExtents(), /*isUnordered=*/true);
-  builder.setInsertionPointToStart(nest.innerLoop.getBody());
+  builder.setInsertionPointToStart(nest.body);
   mlir::Type refTy = fir::ReferenceType::get(seqTy.getEleTy());
   auto lhsEleAddr = builder.create(
   loc, refTy, lhs, shapeShift, /*slice=*/mlir::Value{},
@@ -389,7 +389,7 @@ static void genBoxCombiner(fir::FirOpBuilder &builder, 
mlir::Location loc,
   builder, loc, redId, refTy, lhsEle, rhsEle);
   builder.create(loc, scalarReduction, lhsEleAddr);
 
-  builder.setInsertionPointAfter(nest.outerLoop);
+  builder.setInsertionPointAfter(nest.outerOp);
   builder.create(loc, lhsAddr);
 }
 
diff --git a/flang/lib/Optimizer/Builder/HLFIRTools.cpp 
b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
index 8d0ae2f195178..cd07cb741eb4b 100644
--- a/flang/lib/Optimizer/Builder/HLFIRTools.cpp
+++ b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
@@ -20,6 +20,7 @@
 #include "mlir/IR/IRMapping.h"
 #include "mlir/Support/LLVM.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include 
 #include 
 
 // Return explicit extents. If the base is a fir.box, this won't read it to
@@ -855,26 +856,51 @@ mlir::Value hlfir::inlineElementalOp(
 
 hlfir::LoopNest hlfir::genLoopNest(mlir::Location loc,
fir::FirOpBuilder &builder,
-   mlir::ValueRange extents, bool isUnordered) 
{
+   mlir::ValueRange extents, bool isUnordered,
+   bool emitWsLoop) {
   hlfir::LoopNest loopNest;
   assert(!extents.empty() && "must ha

[llvm-branch-commits] [flang] [flang] Lower omp.workshare to other omp constructs (PR #101446)

2024-08-02 Thread Ivan R. Ivanov via llvm-branch-commits


@@ -0,0 +1,259 @@
+//===- LowerWorkshare.cpp - special cases for bufferization ---===//
+//
+// 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
+//
+//===--===//
+// Lower omp workshare construct.
+//===--===//
+
+#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/OpenMP/Passes.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/IRMapping.h"
+#include "mlir/IR/OpDefinition.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Support/LLVM.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/iterator_range.h"
+
+#include 
+
+namespace flangomp {
+#define GEN_PASS_DEF_LOWERWORKSHARE
+#include "flang/Optimizer/OpenMP/Passes.h.inc"
+} // namespace flangomp
+
+#define DEBUG_TYPE "lower-workshare"
+
+using namespace mlir;
+
+namespace flangomp {
+bool shouldUseWorkshareLowering(Operation *op) {
+  auto workshare = dyn_cast(op->getParentOp());
+  if (!workshare)
+return false;
+  return workshare->getParentOfType();
+}
+} // namespace flangomp
+
+namespace {
+
+struct SingleRegion {
+  Block::iterator begin, end;
+};
+
+static bool isSupportedByFirAlloca(Type ty) {
+  return !isa(ty);
+}
+
+static bool isSafeToParallelize(Operation *op) {
+  if (isa(op))
+return true;
+
+  llvm::SmallVector effects;
+  MemoryEffectOpInterface interface = dyn_cast(op);
+  if (!interface) {
+return false;
+  }
+  interface.getEffects(effects);
+  if (effects.empty())
+return true;
+
+  return false;
+}
+
+/// Lowers workshare to a sequence of single-thread regions and parallel loops
+///
+/// For example:
+///
+/// omp.workshare {
+///   %a = fir.allocmem
+///   omp.wsloop {}
+///   fir.call Assign %b %a
+///   fir.freemem %a
+/// }
+///
+/// becomes
+///
+/// omp.single {
+///   %a = fir.allocmem
+///   fir.store %a %tmp
+/// }
+/// %a_reloaded = fir.load %tmp
+/// omp.wsloop {}
+/// omp.single {
+///   fir.call Assign %b %a_reloaded
+///   fir.freemem %a_reloaded
+/// }
+///
+/// Note that we allocate temporary memory for values in omp.single's which 
need
+/// to be accessed in all threads in the closest omp.parallel
+///
+/// TODO currently we need to be able to access the encompassing omp.parallel 
so
+/// that we can allocate temporaries accessible by all threads outside of it.
+/// In case we do not find it, we fall back to converting the omp.workshare to
+/// omp.single.
+/// To better handle this we should probably enable yielding values out of an
+/// omp.single which will be supported by the omp runtime.
+void lowerWorkshare(mlir::omp::WorkshareOp wsOp) {
+  assert(wsOp.getRegion().getBlocks().size() == 1);
+
+  Location loc = wsOp->getLoc();
+
+  omp::ParallelOp parallelOp = wsOp->getParentOfType();
+  if (!parallelOp) {
+wsOp.emitWarning("cannot handle workshare, converting to single");
+Operation *terminator = wsOp.getRegion().front().getTerminator();
+wsOp->getBlock()->getOperations().splice(
+wsOp->getIterator(), wsOp.getRegion().front().getOperations());
+terminator->erase();
+return;
+  }
+
+  OpBuilder allocBuilder(parallelOp);
+  OpBuilder rootBuilder(wsOp);
+  IRMapping rootMapping;
+
+  omp::SingleOp singleOp = nullptr;
+
+  auto mapReloadedValue = [&](Value v, OpBuilder singleBuilder,
+  IRMapping singleMapping) {
+if (auto reloaded = rootMapping.lookupOrNull(v))
+  return;
+Type llvmPtrTy = LLVM::LLVMPointerType::get(allocBuilder.getContext());
+Type ty = v.getType();
+Value alloc, reloaded;
+if (isSupportedByFirAlloca(ty)) {
+  alloc = allocBuilder.create(loc, ty);
+  singleBuilder.create(loc, singleMapping.lookup(v), alloc);

ivanradanov wrote:

I suppose it will be a problem with if we try to do this to a fir.alloca, which 
goes out of scope, we would need to firstprivate those for the omp.single 
regions. Thank you for the comment

https://github.com/llvm/llvm-project/pull/101446
___
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 note is nullptr removal (PR #101638)

2024-08-02 Thread Nikolas Klauser via llvm-branch-commits

https://github.com/philnik777 edited 
https://github.com/llvm/llvm-project/pull/101638
___
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 note is nullptr removal (PR #101638)

2024-08-02 Thread Nikolas Klauser via llvm-branch-commits

https://github.com/philnik777 edited 
https://github.com/llvm/llvm-project/pull/101638
___
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] Add a release note deprecating __is_nullptr (PR #101638)

2024-08-02 Thread Nikolas Klauser via llvm-branch-commits

https://github.com/philnik777 edited 
https://github.com/llvm/llvm-project/pull/101638
___
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] Add a release note deprecating __is_nullptr (PR #101638)

2024-08-02 Thread Nikolas Klauser via llvm-branch-commits

https://github.com/philnik777 edited 
https://github.com/llvm/llvm-project/pull/101638
___
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] Add a release note deprecating __is_nullptr (PR #101638)

2024-08-02 Thread Vlad Serebrennikov via llvm-branch-commits

https://github.com/Endilll milestoned 
https://github.com/llvm/llvm-project/pull/101638
___
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] Add a release note deprecating __is_nullptr (PR #101638)

2024-08-02 Thread Vlad Serebrennikov via llvm-branch-commits

https://github.com/Endilll approved this pull request.


https://github.com/llvm/llvm-project/pull/101638
___
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] Add a release note deprecating __is_nullptr (PR #101638)

2024-08-02 Thread via llvm-branch-commits


@@ -447,6 +447,10 @@ Non-comprehensive list of changes in this release
   type of the pointer was taken into account. This improves
   compatibility with GCC's libstdc++.
 
+- The type traits builtin ``__is_nullptr`` is deprecated in CLang 19 and will 
be

h-vetinari wrote:

```suggestion
- The type traits builtin ``__is_nullptr`` is deprecated in Clang 19 and will be
```

https://github.com/llvm/llvm-project/pull/101638
___
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] b2eab34 - [Clang] Add a release note deprecating __is_nullptr

2024-08-02 Thread Nikolas Klauser via llvm-branch-commits

Author: Nikolas Klauser
Date: 2024-08-02T10:53:33+02:00
New Revision: b2eab3486499656ec6ef30ace5033f80d4d9dfc9

URL: 
https://github.com/llvm/llvm-project/commit/b2eab3486499656ec6ef30ace5033f80d4d9dfc9
DIFF: 
https://github.com/llvm/llvm-project/commit/b2eab3486499656ec6ef30ace5033f80d4d9dfc9.diff

LOG: [Clang] Add a release note deprecating __is_nullptr

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b4ef1e9672a5d..c42cb9932f3f7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -447,6 +447,10 @@ Non-comprehensive list of changes in this release
   type of the pointer was taken into account. This improves
   compatibility with GCC's libstdc++.
 
+- The type traits builtin ``__is_nullptr`` is deprecated in CLang 19 and will 
be
+  removed in Clang 20. ``__is_same(__remove_cv(T), decltype(nullptr))`` can be
+  used instead to check whether a type ``T`` is a ``nullptr``.
+
 New Compiler Flags
 --
 - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
@@ -754,7 +758,7 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses dangling assignments for pointer-like objects (annotated 
with `[[gsl::Pointer]]`) under `-Wdangling-assignment-gsl` (off by default)
   Fixes #GH63310.
-  
+
 - Clang now diagnoses uses of alias templates with a deprecated attribute. 
(Fixes #GH18236).
 
   .. code-block:: c++



___
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] Add a release note deprecating __is_nullptr (PR #101638)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101638
___
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] Add a release note deprecating __is_nullptr (PR #101638)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@philnik777 (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/101638
___
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/19.x: [AIX] Turn on `#pragma mc_func` check by default (#101336) (PR #101505)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101505

>From 7fa3ba52ba4c918298b67ef74891319464017bf4 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <274595+qiongs...@users.noreply.github.com>
Date: Thu, 1 Aug 2024 09:51:07 -0400
Subject: [PATCH] [AIX] Turn on `#pragma mc_func` check by default (#101336)

https://github.com/llvm/llvm-project/pull/99888 added a check (and
corresponding options) to flag uses of `#pragma mc_func` on AIX.

This PR turns on the check by default.

(cherry picked from commit b9335176db718bf64c72d48107eb9dff28ed979e)
---
 clang/include/clang/Driver/Options.td | 4 ++--
 clang/include/clang/Lex/PreprocessorOptions.h | 4 ++--
 clang/lib/Driver/ToolChains/AIX.cpp   | 6 ++
 clang/test/Preprocessor/pragma_mc_func.c  | 6 --
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 359a698ea87dd..bed6e7af9dce9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8087,8 +8087,8 @@ def source_date_epoch : Separate<["-"], 
"source-date-epoch">,
 } // let Visibility = [CC1Option]
 
 defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix",
-  PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultFalse,
-  PosFlag, DefaultTrue,
+  PosFlag,
   NegFlag>;
diff --git a/clang/include/clang/Lex/PreprocessorOptions.h 
b/clang/include/clang/Lex/PreprocessorOptions.h
index 3f7dd9db18ba7..f48b7ecb90e1e 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -213,7 +213,7 @@ class PreprocessorOptions {
 
   /// If set, the preprocessor reports an error when processing #pragma mc_func
   /// on AIX.
-  bool ErrorOnPragmaMcfuncOnAIX = false;
+  bool ErrorOnPragmaMcfuncOnAIX = true;
 
 public:
   PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
@@ -252,7 +252,7 @@ class PreprocessorOptions {
 PrecompiledPreambleBytes.first = 0;
 PrecompiledPreambleBytes.second = false;
 RetainExcludedConditionalBlocks = false;
-ErrorOnPragmaMcfuncOnAIX = false;
+ErrorOnPragmaMcfuncOnAIX = true;
   }
 };
 
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index fb780fb75651d..0615a8a9e8d17 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -558,10 +558,8 @@ void AIX::addClangTargetOptions(
   options::OPT_fno_sized_deallocation))
 CC1Args.push_back("-fno-sized-deallocation");
 
-  if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
-   options::OPT_fno_err_pragma_mc_func_aix, false))
-CC1Args.push_back("-ferr-pragma-mc-func-aix");
-  else
+  if (!Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
+options::OPT_fno_err_pragma_mc_func_aix, true))
 CC1Args.push_back("-fno-err-pragma-mc-func-aix");
 }
 
diff --git a/clang/test/Preprocessor/pragma_mc_func.c 
b/clang/test/Preprocessor/pragma_mc_func.c
index f0d3e49e5dddc..bf12f7107ff5c 100644
--- a/clang/test/Preprocessor/pragma_mc_func.c
+++ b/clang/test/Preprocessor/pragma_mc_func.c
@@ -1,5 +1,8 @@
+// RUN: not %clang --target=powerpc64-ibm-aix -fsyntax-only %s 2>&1 | 
FileCheck %s
 // RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix 
-fsyntax-only \
 // RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix \
+// RUN:   -ferr-pragma-mc-func-aix -fsyntax-only %s 2>&1 | FileCheck %s
 #pragma mc_func asm_barrier {"6000"}
 
 // CHECK:  error: #pragma mc_func is not supported
@@ -8,11 +11,10 @@
 // RUN: %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix 
-fsyntax-only %s
 // RUN: %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix 
-fsyntax-only \
 // RUN:-fno-err-pragma-mc-func-aix %s
-// RUN: %clang --target=powerpc64-ibm-aix -fsyntax-only %s
 // RUN: %clang --target=powerpc64-ibm-aix -Werror=unknown-pragmas \
 // RUN:   -fno-err-pragma-mc-func-aix -fsyntax-only %s
 
-// Cases where we have errors or warnings.
+// Cases on a non-AIX target.
 // RUN: not %clang --target=powerpc64le-unknown-linux-gnu \
 // RUN:   -Werror=unknown-pragmas -fno-err-pragma-mc-func-aix -fsyntax-only %s 
2>&1 | \
 // RUN:   FileCheck --check-prefix=UNUSED %s

___
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] 7fa3ba5 - [AIX] Turn on `#pragma mc_func` check by default (#101336)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

Author: Qiongsi Wu
Date: 2024-08-02T12:09:45+02:00
New Revision: 7fa3ba52ba4c918298b67ef74891319464017bf4

URL: 
https://github.com/llvm/llvm-project/commit/7fa3ba52ba4c918298b67ef74891319464017bf4
DIFF: 
https://github.com/llvm/llvm-project/commit/7fa3ba52ba4c918298b67ef74891319464017bf4.diff

LOG: [AIX] Turn on `#pragma mc_func` check by default (#101336)

https://github.com/llvm/llvm-project/pull/99888 added a check (and
corresponding options) to flag uses of `#pragma mc_func` on AIX.

This PR turns on the check by default.

(cherry picked from commit b9335176db718bf64c72d48107eb9dff28ed979e)

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Preprocessor/pragma_mc_func.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 359a698ea87dd..bed6e7af9dce9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8087,8 +8087,8 @@ def source_date_epoch : Separate<["-"], 
"source-date-epoch">,
 } // let Visibility = [CC1Option]
 
 defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix",
-  PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultFalse,
-  PosFlag, DefaultTrue,
+  PosFlag,
   NegFlag>;

diff  --git a/clang/include/clang/Lex/PreprocessorOptions.h 
b/clang/include/clang/Lex/PreprocessorOptions.h
index 3f7dd9db18ba7..f48b7ecb90e1e 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -213,7 +213,7 @@ class PreprocessorOptions {
 
   /// If set, the preprocessor reports an error when processing #pragma mc_func
   /// on AIX.
-  bool ErrorOnPragmaMcfuncOnAIX = false;
+  bool ErrorOnPragmaMcfuncOnAIX = true;
 
 public:
   PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
@@ -252,7 +252,7 @@ class PreprocessorOptions {
 PrecompiledPreambleBytes.first = 0;
 PrecompiledPreambleBytes.second = false;
 RetainExcludedConditionalBlocks = false;
-ErrorOnPragmaMcfuncOnAIX = false;
+ErrorOnPragmaMcfuncOnAIX = true;
   }
 };
 

diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index fb780fb75651d..0615a8a9e8d17 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -558,10 +558,8 @@ void AIX::addClangTargetOptions(
   options::OPT_fno_sized_deallocation))
 CC1Args.push_back("-fno-sized-deallocation");
 
-  if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
-   options::OPT_fno_err_pragma_mc_func_aix, false))
-CC1Args.push_back("-ferr-pragma-mc-func-aix");
-  else
+  if (!Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
+options::OPT_fno_err_pragma_mc_func_aix, true))
 CC1Args.push_back("-fno-err-pragma-mc-func-aix");
 }
 

diff  --git a/clang/test/Preprocessor/pragma_mc_func.c 
b/clang/test/Preprocessor/pragma_mc_func.c
index f0d3e49e5dddc..bf12f7107ff5c 100644
--- a/clang/test/Preprocessor/pragma_mc_func.c
+++ b/clang/test/Preprocessor/pragma_mc_func.c
@@ -1,5 +1,8 @@
+// RUN: not %clang --target=powerpc64-ibm-aix -fsyntax-only %s 2>&1 | 
FileCheck %s
 // RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix 
-fsyntax-only \
 // RUN:   %s 2>&1 | FileCheck %s
+// RUN: not %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix \
+// RUN:   -ferr-pragma-mc-func-aix -fsyntax-only %s 2>&1 | FileCheck %s
 #pragma mc_func asm_barrier {"6000"}
 
 // CHECK:  error: #pragma mc_func is not supported
@@ -8,11 +11,10 @@
 // RUN: %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix 
-fsyntax-only %s
 // RUN: %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix 
-fsyntax-only \
 // RUN:-fno-err-pragma-mc-func-aix %s
-// RUN: %clang --target=powerpc64-ibm-aix -fsyntax-only %s
 // RUN: %clang --target=powerpc64-ibm-aix -Werror=unknown-pragmas \
 // RUN:   -fno-err-pragma-mc-func-aix -fsyntax-only %s
 
-// Cases where we have errors or warnings.
+// Cases on a non-AIX target.
 // RUN: not %clang --target=powerpc64le-unknown-linux-gnu \
 // RUN:   -Werror=unknown-pragmas -fno-err-pragma-mc-func-aix -fsyntax-only %s 
2>&1 | \
 // RUN:   FileCheck --check-prefix=UNUSED %s



___
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/19.x: [AIX] Turn on `#pragma mc_func` check by default (#101336) (PR #101505)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101505
___
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/19.x: [AIX] Turn on `#pragma mc_func` check by default (#101336) (PR #101505)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@qiongsiwu (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/101505
___
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] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching EEW (PR #101464)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101464

>From 6b52570dcd5d34a9b44ccd0bb2b2d4ffd661d9d7 Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Wed, 31 Jul 2024 00:28:52 +0800
Subject: [PATCH] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with
 mismatching EEW (#101152)

As noted in
https://github.com/llvm/llvm-project/pull/100367/files#r1695448771, we
currently fold in vmerge.vvms and vmv.v.vs into their ops even if the
EEW is different which leads to an incorrect transform.

This checks the op's EEW via its simple value type for now since there
doesn't seem to be any existing information about the EEW size of
instructions. We'll probably need to encode this at some point if we
want to be able to access it at the MachineInstr level in #100367
---
 llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp   |  4 
 llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll| 14 +
 .../RISCV/rvv/rvv-peephole-vmerge-vops.ll | 21 +++
 3 files changed, 39 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp 
b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index eef6ae677ac85..db949f3476e2b 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -3721,6 +3721,10 @@ bool 
RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
   assert(!Mask || cast(Mask)->getReg() == RISCV::V0);
   assert(!Glue || Glue.getValueType() == MVT::Glue);
 
+  // If the EEW of True is different from vmerge's SEW, then we can't fold.
+  if (True.getSimpleValueType() != N->getSimpleValueType(0))
+return false;
+
   // We require that either merge and false are the same, or that merge
   // is undefined.
   if (Merge != False && !isImplicitDef(Merge))
diff --git a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll 
b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
index ec03f773c7108..dfc2b2bdda026 100644
--- a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
@@ -168,3 +168,17 @@ define  @unfoldable_vredsum( %passthru,  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a, iXLen 1)
   ret  %b
 }
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y, iXLen %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, iXLen %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a.bitcast, iXLen %avl)
+  ret  %b
+}
diff --git a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll 
b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
index a08bcae074b9b..259515f160048 100644
--- a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
@@ -1196,3 +1196,24 @@ define  
@true_mask_vmerge_implicit_passthru(
   )
   ret  %b
 }
+
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y,  
%mask, i64 %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, i64 %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmerge.nxv2i32.nxv2i32(
+ %passthru,
+ %passthru,
+ %a.bitcast,
+ splat (i1 true),
+i64 %avl
+  )
+  ret  %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] [llvm] 6b52570 - [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching EEW (#101152)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

Author: Luke Lau
Date: 2024-08-02T12:10:42+02:00
New Revision: 6b52570dcd5d34a9b44ccd0bb2b2d4ffd661d9d7

URL: 
https://github.com/llvm/llvm-project/commit/6b52570dcd5d34a9b44ccd0bb2b2d4ffd661d9d7
DIFF: 
https://github.com/llvm/llvm-project/commit/6b52570dcd5d34a9b44ccd0bb2b2d4ffd661d9d7.diff

LOG: [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching 
EEW (#101152)

As noted in
https://github.com/llvm/llvm-project/pull/100367/files#r1695448771, we
currently fold in vmerge.vvms and vmv.v.vs into their ops even if the
EEW is different which leads to an incorrect transform.

This checks the op's EEW via its simple value type for now since there
doesn't seem to be any existing information about the EEW size of
instructions. We'll probably need to encode this at some point if we
want to be able to access it at the MachineInstr level in #100367

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp 
b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index eef6ae677ac85..db949f3476e2b 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -3721,6 +3721,10 @@ bool 
RISCVDAGToDAGISel::performCombineVMergeAndVOps(SDNode *N) {
   assert(!Mask || cast(Mask)->getReg() == RISCV::V0);
   assert(!Glue || Glue.getValueType() == MVT::Glue);
 
+  // If the EEW of True is 
diff erent from vmerge's SEW, then we can't fold.
+  if (True.getSimpleValueType() != N->getSimpleValueType(0))
+return false;
+
   // We require that either merge and false are the same, or that merge
   // is undefined.
   if (Merge != False && !isImplicitDef(Merge))

diff  --git a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll 
b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
index ec03f773c7108..dfc2b2bdda026 100644
--- a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
@@ -168,3 +168,17 @@ define  @unfoldable_vredsum( %passthru,  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a, iXLen 1)
   ret  %b
 }
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y, iXLen %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, iXLen %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmv.v.v.nxv2i32( 
%passthru,  %a.bitcast, iXLen %avl)
+  ret  %b
+}

diff  --git a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll 
b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
index a08bcae074b9b..259515f160048 100644
--- a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
@@ -1196,3 +1196,24 @@ define  
@true_mask_vmerge_implicit_passthru(
   )
   ret  %b
 }
+
+
+define  @unfoldable_mismatched_sew( 
%passthru,  %x,  %y,  
%mask, i64 %avl) {
+; CHECK-LABEL: unfoldable_mismatched_sew:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli zero, a0, e64, m1, ta, ma
+; CHECK-NEXT:vadd.vv v9, v9, v10
+; CHECK-NEXT:vsetvli zero, a0, e32, m1, tu, ma
+; CHECK-NEXT:vmv.v.v v8, v9
+; CHECK-NEXT:ret
+  %a = call  @llvm.riscv.vadd.nxv1i64.nxv1i64( poison,  %x,  %y, i64 %avl)
+  %a.bitcast = bitcast  %a to 
+  %b = call  @llvm.riscv.vmerge.nxv2i32.nxv2i32(
+ %passthru,
+ %passthru,
+ %a.bitcast,
+ splat (i1 true),
+i64 %avl
+  )
+  ret  %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] [llvm] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching EEW (PR #101464)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101464
___
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] [RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching EEW (PR #101464)

2024-08-02 Thread via llvm-branch-commits

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/101464
___
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] Backport "[analyzer] Restore recognition of mutex methods" (PR #101651)

2024-08-02 Thread Balazs Benics via llvm-branch-commits

https://github.com/steakhal created 
https://github.com/llvm/llvm-project/pull/101651

Before commit 705788c the checker alpha.unix.BlockInCriticalSection 
"recognized" the methods `std::mutex::lock` and `std::mutex::unlock` with an 
extremely trivial check that accepted any function (or method) named 
lock/unlock.

To avoid matching unrelated user-defined function, this was refined to a check 
that also requires the presence of "std" and "mutex" as distinct parts of the 
qualified name.

However, as #99628 reported, there are standard library implementations where 
some methods of `std::mutex` are inherited from an implementation detail base 
class and the new code wasn't able to recognize these methods, which led to 
emitting false positive reports.

As a workaround, this commit partially restores the old behavior by omitting 
the check for the class name.

In the future, it would be good to replace this hack with a solution which 
ensures that `CallDescription` understands inherited methods.

(cherry picked from commit 99ae2edc2592e602b0eb5a287f4d003aa3902440)

>From 18ad0209550ed258fc1a24e710613bc5e3e220af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Fri, 2 Aug 2024 12:43:06 +0200
Subject: [PATCH] [analyzer] Restore recognition of mutex methods (#101511)

Before commit 705788c the checker alpha.unix.BlockInCriticalSection
"recognized" the methods `std::mutex::lock` and `std::mutex::unlock`
with an extremely trivial check that accepted any function (or method)
named lock/unlock.

To avoid matching unrelated user-defined function, this was refined to a
check that also requires the presence of "std" and "mutex" as distinct
parts of the qualified name.

However, as #99628 reported, there are standard library implementations
where some methods of `std::mutex` are inherited from an implementation
detail base class and the new code wasn't able to recognize these
methods, which led to emitting false positive reports.

As a workaround, this commit partially restores the old behavior by
omitting the check for the class name.

In the future, it would be good to replace this hack with a solution
which ensures that `CallDescription` understands inherited methods.

(cherry picked from commit 99ae2edc2592e602b0eb5a287f4d003aa3902440)
---
 .../BlockInCriticalSectionChecker.cpp | 16 +++---
 .../block-in-critical-section-inheritance.cpp | 31 +++
 2 files changed, 43 insertions(+), 4 deletions(-)
 create mode 100644 
clang/test/Analysis/block-in-critical-section-inheritance.cpp

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
index 40f7e9cede1f1..4cd2f2802f30c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
@@ -147,10 +147,18 @@ using MutexDescriptor =
 class BlockInCriticalSectionChecker : public Checker {
 private:
   const std::array MutexDescriptors{
-  MemberMutexDescriptor({/*MatchAs=*/CDM::CXXMethod,
- /*QualifiedName=*/{"std", "mutex", "lock"},
- /*RequiredArgs=*/0},
-{CDM::CXXMethod, {"std", "mutex", "unlock"}, 0}),
+  // NOTE: There are standard library implementations where some methods
+  // of `std::mutex` are inherited from an implementation detail base
+  // class, and those aren't matched by the name specification {"std",
+  // "mutex", "lock"}.
+  // As a workaround here we omit the class name and only require the
+  // presence of the name parts "std" and "lock"/"unlock".
+  // TODO: Ensure that CallDescription understands inherited methods.
+  MemberMutexDescriptor(
+  {/*MatchAs=*/CDM::CXXMethod,
+   /*QualifiedName=*/{"std", /*"mutex",*/ "lock"},
+   /*RequiredArgs=*/0},
+  {CDM::CXXMethod, {"std", /*"mutex",*/ "unlock"}, 0}),
   FirstArgMutexDescriptor({CDM::CLibrary, {"pthread_mutex_lock"}, 1},
   {CDM::CLibrary, {"pthread_mutex_unlock"}, 1}),
   FirstArgMutexDescriptor({CDM::CLibrary, {"mtx_lock"}, 1},
diff --git a/clang/test/Analysis/block-in-critical-section-inheritance.cpp 
b/clang/test/Analysis/block-in-critical-section-inheritance.cpp
new file mode 100644
index 0..db20df8c60a5c
--- /dev/null
+++ b/clang/test/Analysis/block-in-critical-section-inheritance.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=unix.BlockInCriticalSection \
+// RUN:   -std=c++11 \
+// RUN:   -analyzer-output text \
+// RUN:   -verify %s
+
+unsigned int sleep(unsigned int seconds) {return 0;}
+namespace std {
+// There are some standard library implementations where some mutex methods
+// come from an implementation detail base class. We need to ensure that these
+// are matched correctly.
+class __mutex_base {
+public:
+  void lock(

[llvm-branch-commits] [clang] Backport "[analyzer] Restore recognition of mutex methods" (PR #101651)

2024-08-02 Thread Balazs Benics via llvm-branch-commits

https://github.com/steakhal milestoned 
https://github.com/llvm/llvm-project/pull/101651
___
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] Backport "[analyzer] Restore recognition of mutex methods" (PR #101651)

2024-08-02 Thread Balazs Benics via llvm-branch-commits

https://github.com/steakhal edited 
https://github.com/llvm/llvm-project/pull/101651
___
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] Backport "[analyzer] Restore recognition of mutex methods" (PR #101651)

2024-08-02 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balazs Benics (steakhal)


Changes

Before commit 705788c the checker alpha.unix.BlockInCriticalSection 
"recognized" the methods `std::mutex::lock` and `std::mutex::unlock` with an 
extremely trivial check that accepted any function (or method) named 
lock/unlock.

To avoid matching unrelated user-defined function, this was refined to a check 
that also requires the presence of "std" and "mutex" as distinct parts of the 
qualified name.

However, as #99628 reported, there are standard library implementations 
where some methods of `std::mutex` are inherited from an implementation detail 
base class and the new code wasn't able to recognize these methods, which led 
to emitting false positive reports.

As a workaround, this commit partially restores the old behavior by omitting 
the check for the class name.

In the future, it would be good to replace this hack with a solution which 
ensures that `CallDescription` understands inherited methods.

(cherry picked from commit 99ae2edc2592e602b0eb5a287f4d003aa3902440)

---
Full diff: https://github.com/llvm/llvm-project/pull/101651.diff


2 Files Affected:

- (modified) 
clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp (+12-4) 
- (added) clang/test/Analysis/block-in-critical-section-inheritance.cpp (+31) 


``diff
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
index 40f7e9cede1f1..4cd2f2802f30c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
@@ -147,10 +147,18 @@ using MutexDescriptor =
 class BlockInCriticalSectionChecker : public Checker {
 private:
   const std::array MutexDescriptors{
-  MemberMutexDescriptor({/*MatchAs=*/CDM::CXXMethod,
- /*QualifiedName=*/{"std", "mutex", "lock"},
- /*RequiredArgs=*/0},
-{CDM::CXXMethod, {"std", "mutex", "unlock"}, 0}),
+  // NOTE: There are standard library implementations where some methods
+  // of `std::mutex` are inherited from an implementation detail base
+  // class, and those aren't matched by the name specification {"std",
+  // "mutex", "lock"}.
+  // As a workaround here we omit the class name and only require the
+  // presence of the name parts "std" and "lock"/"unlock".
+  // TODO: Ensure that CallDescription understands inherited methods.
+  MemberMutexDescriptor(
+  {/*MatchAs=*/CDM::CXXMethod,
+   /*QualifiedName=*/{"std", /*"mutex",*/ "lock"},
+   /*RequiredArgs=*/0},
+  {CDM::CXXMethod, {"std", /*"mutex",*/ "unlock"}, 0}),
   FirstArgMutexDescriptor({CDM::CLibrary, {"pthread_mutex_lock"}, 1},
   {CDM::CLibrary, {"pthread_mutex_unlock"}, 1}),
   FirstArgMutexDescriptor({CDM::CLibrary, {"mtx_lock"}, 1},
diff --git a/clang/test/Analysis/block-in-critical-section-inheritance.cpp 
b/clang/test/Analysis/block-in-critical-section-inheritance.cpp
new file mode 100644
index 0..db20df8c60a5c
--- /dev/null
+++ b/clang/test/Analysis/block-in-critical-section-inheritance.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=unix.BlockInCriticalSection \
+// RUN:   -std=c++11 \
+// RUN:   -analyzer-output text \
+// RUN:   -verify %s
+
+unsigned int sleep(unsigned int seconds) {return 0;}
+namespace std {
+// There are some standard library implementations where some mutex methods
+// come from an implementation detail base class. We need to ensure that these
+// are matched correctly.
+class __mutex_base {
+public:
+  void lock();
+};
+class mutex : public __mutex_base{
+public:
+  void unlock();
+  bool try_lock();
+};
+} // namespace std
+
+void gh_99628() {
+  std::mutex m;
+  m.lock();
+  // expected-note@-1 {{Entering critical section here}}
+  sleep(10);
+  // expected-warning@-1 {{Call to blocking function 'sleep' inside of 
critical section}}
+  // expected-note@-2 {{Call to blocking function 'sleep' inside of critical 
section}}
+  m.unlock();
+}

``




https://github.com/llvm/llvm-project/pull/101651
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU][SILoadStoreOptimizer] Include constrained buffer load variants (PR #101619)

2024-08-02 Thread Matt Arsenault via llvm-branch-commits


@@ -1679,6 +1711,12 @@ MachineBasicBlock::iterator 
SILoadStoreOptimizer::mergeFlatStorePair(
   return New;
 }
 
+static bool needsConstraintedOpcode(const GCNSubtarget &STM,

arsenm wrote:

Typo needsConstraintedOpcode

https://github.com/llvm/llvm-project/pull/101619
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU][SILoadStoreOptimizer] Include constrained buffer load variants (PR #101619)

2024-08-02 Thread Matt Arsenault via llvm-branch-commits


@@ -1696,38 +1734,51 @@ unsigned SILoadStoreOptimizer::getNewOpcode(const 
CombineInfo &CI,
 
   case UNKNOWN:
 llvm_unreachable("Unknown instruction class");
-  case S_BUFFER_LOAD_IMM:
+  case S_BUFFER_LOAD_IMM: {
+const MachineMemOperand *MMO = *CI.I->memoperands_begin();

arsenm wrote:

Avoid assuming there is an MMO, the verifier does not enforce this 

https://github.com/llvm/llvm-project/pull/101619
___
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] Backport "[analyzer] Restore recognition of mutex methods" (PR #101651)

2024-08-02 Thread GĂ¡bor HorvĂ¡th via llvm-branch-commits

https://github.com/Xazax-hun approved this pull request.

LGTM, makes sense to backport.

https://github.com/llvm/llvm-project/pull/101651
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU][SILoadStoreOptimizer] Include constrained buffer load variants (PR #101619)

2024-08-02 Thread Christudasan Devadasan via llvm-branch-commits

https://github.com/cdevadas updated 
https://github.com/llvm/llvm-project/pull/101619

>From ad8a8dfea913c92fb94079aab0a4a5905b30384d Mon Sep 17 00:00:00 2001
From: Christudasan Devadasan 
Date: Tue, 30 Jul 2024 14:46:36 +0530
Subject: [PATCH 1/3] [AMDGPU][SILoadStoreOptimizer] Include constrained buffer
 load variants

Use the constrained buffer load opcodes while combining under-aligned
load for XNACK enabled subtargets.
---
 .../Target/AMDGPU/SILoadStoreOptimizer.cpp|  75 ++-
 .../AMDGPU/llvm.amdgcn.s.buffer.load.ll   |  56 +-
 .../CodeGen/AMDGPU/merge-sbuffer-load.mir | 564 --
 3 files changed, 613 insertions(+), 82 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp 
b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
index ae537b194f50c..7553c370f694f 100644
--- a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
@@ -352,6 +352,8 @@ static unsigned getOpcodeWidth(const MachineInstr &MI, 
const SIInstrInfo &TII) {
 return 1;
   case AMDGPU::S_BUFFER_LOAD_DWORDX2_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX2_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR_IMM_ec:
   case AMDGPU::S_LOAD_DWORDX2_IMM:
   case AMDGPU::S_LOAD_DWORDX2_IMM_ec:
   case AMDGPU::GLOBAL_LOAD_DWORDX2:
@@ -363,6 +365,8 @@ static unsigned getOpcodeWidth(const MachineInstr &MI, 
const SIInstrInfo &TII) {
 return 2;
   case AMDGPU::S_BUFFER_LOAD_DWORDX3_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX3_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM_ec:
   case AMDGPU::S_LOAD_DWORDX3_IMM:
   case AMDGPU::S_LOAD_DWORDX3_IMM_ec:
   case AMDGPU::GLOBAL_LOAD_DWORDX3:
@@ -374,6 +378,8 @@ static unsigned getOpcodeWidth(const MachineInstr &MI, 
const SIInstrInfo &TII) {
 return 3;
   case AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM_ec:
   case AMDGPU::S_LOAD_DWORDX4_IMM:
   case AMDGPU::S_LOAD_DWORDX4_IMM_ec:
   case AMDGPU::GLOBAL_LOAD_DWORDX4:
@@ -385,6 +391,8 @@ static unsigned getOpcodeWidth(const MachineInstr &MI, 
const SIInstrInfo &TII) {
 return 4;
   case AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR_IMM_ec:
   case AMDGPU::S_LOAD_DWORDX8_IMM:
   case AMDGPU::S_LOAD_DWORDX8_IMM_ec:
 return 8;
@@ -499,12 +507,20 @@ static InstClassEnum getInstClass(unsigned Opc, const 
SIInstrInfo &TII) {
   case AMDGPU::S_BUFFER_LOAD_DWORDX3_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX2_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX3_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM_ec:
 return S_BUFFER_LOAD_IMM;
   case AMDGPU::S_BUFFER_LOAD_DWORD_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR_IMM_ec:
 return S_BUFFER_LOAD_SGPR_IMM;
   case AMDGPU::S_LOAD_DWORD_IMM:
   case AMDGPU::S_LOAD_DWORDX2_IMM:
@@ -587,12 +603,20 @@ static unsigned getInstSubclass(unsigned Opc, const 
SIInstrInfo &TII) {
   case AMDGPU::S_BUFFER_LOAD_DWORDX3_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX2_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX3_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM_ec:
 return AMDGPU::S_BUFFER_LOAD_DWORD_IMM;
   case AMDGPU::S_BUFFER_LOAD_DWORD_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR_IMM_ec:
 return AMDGPU::S_BUFFER_LOAD_DWORD_SGPR_IMM;
   case AMDGPU::S_LOAD_DWORD_IMM:
   case AMDGPU::S_LOAD_DWORDX2_IMM:
@@ -703,6 +727,10 @@ static AddressRegs getRegs(unsigned Opc, const SIInstrInfo 
&TII) {
   case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM:
   case AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR_IMM:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX3_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR_IMM_ec:
+  case AMDGPU::S_BUFFER_LOAD_

[llvm-branch-commits] [compiler-rt] [llvm] release/19.x: [MC/DC][Coverage] Introduce "Bitmap Bias" for continuous mode (#96126) (PR #101629)

2024-08-02 Thread Jessica Paquette via llvm-branch-commits

ornata wrote:

IIUC

- Scope: Programs built with MC/DC coverage with continuous mode enabled.
- Risk: This is a new feature for MC/DC coverage. Previously, MC/DC had no 
support for continuous mode. There should be no breakage introduced for 
existing features.
- Testing: LLVM lit tests attached.

@chapuni What testing have you done other than LLVM lit tests? LLVM test suite? 
Clang itself?

https://github.com/llvm/llvm-project/pull/101629
___
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] 18ad020 - [analyzer] Restore recognition of mutex methods (#101511)

2024-08-02 Thread Balazs Benics via llvm-branch-commits

Author: DonĂ¡t Nagy
Date: 2024-08-02T12:44:40+02:00
New Revision: 18ad0209550ed258fc1a24e710613bc5e3e220af

URL: 
https://github.com/llvm/llvm-project/commit/18ad0209550ed258fc1a24e710613bc5e3e220af
DIFF: 
https://github.com/llvm/llvm-project/commit/18ad0209550ed258fc1a24e710613bc5e3e220af.diff

LOG: [analyzer] Restore recognition of mutex methods (#101511)

Before commit 705788c the checker alpha.unix.BlockInCriticalSection
"recognized" the methods `std::mutex::lock` and `std::mutex::unlock`
with an extremely trivial check that accepted any function (or method)
named lock/unlock.

To avoid matching unrelated user-defined function, this was refined to a
check that also requires the presence of "std" and "mutex" as distinct
parts of the qualified name.

However, as #99628 reported, there are standard library implementations
where some methods of `std::mutex` are inherited from an implementation
detail base class and the new code wasn't able to recognize these
methods, which led to emitting false positive reports.

As a workaround, this commit partially restores the old behavior by
omitting the check for the class name.

In the future, it would be good to replace this hack with a solution
which ensures that `CallDescription` understands inherited methods.

(cherry picked from commit 99ae2edc2592e602b0eb5a287f4d003aa3902440)

Added: 
clang/test/Analysis/block-in-critical-section-inheritance.cpp

Modified: 
clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp

Removed: 




diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
index 40f7e9cede1f1..4cd2f2802f30c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
@@ -147,10 +147,18 @@ using MutexDescriptor =
 class BlockInCriticalSectionChecker : public Checker {
 private:
   const std::array MutexDescriptors{
-  MemberMutexDescriptor({/*MatchAs=*/CDM::CXXMethod,
- /*QualifiedName=*/{"std", "mutex", "lock"},
- /*RequiredArgs=*/0},
-{CDM::CXXMethod, {"std", "mutex", "unlock"}, 0}),
+  // NOTE: There are standard library implementations where some methods
+  // of `std::mutex` are inherited from an implementation detail base
+  // class, and those aren't matched by the name specification {"std",
+  // "mutex", "lock"}.
+  // As a workaround here we omit the class name and only require the
+  // presence of the name parts "std" and "lock"/"unlock".
+  // TODO: Ensure that CallDescription understands inherited methods.
+  MemberMutexDescriptor(
+  {/*MatchAs=*/CDM::CXXMethod,
+   /*QualifiedName=*/{"std", /*"mutex",*/ "lock"},
+   /*RequiredArgs=*/0},
+  {CDM::CXXMethod, {"std", /*"mutex",*/ "unlock"}, 0}),
   FirstArgMutexDescriptor({CDM::CLibrary, {"pthread_mutex_lock"}, 1},
   {CDM::CLibrary, {"pthread_mutex_unlock"}, 1}),
   FirstArgMutexDescriptor({CDM::CLibrary, {"mtx_lock"}, 1},

diff  --git a/clang/test/Analysis/block-in-critical-section-inheritance.cpp 
b/clang/test/Analysis/block-in-critical-section-inheritance.cpp
new file mode 100644
index 0..db20df8c60a5c
--- /dev/null
+++ b/clang/test/Analysis/block-in-critical-section-inheritance.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=unix.BlockInCriticalSection \
+// RUN:   -std=c++11 \
+// RUN:   -analyzer-output text \
+// RUN:   -verify %s
+
+unsigned int sleep(unsigned int seconds) {return 0;}
+namespace std {
+// There are some standard library implementations where some mutex methods
+// come from an implementation detail base class. We need to ensure that these
+// are matched correctly.
+class __mutex_base {
+public:
+  void lock();
+};
+class mutex : public __mutex_base{
+public:
+  void unlock();
+  bool try_lock();
+};
+} // namespace std
+
+void gh_99628() {
+  std::mutex m;
+  m.lock();
+  // expected-note@-1 {{Entering critical section here}}
+  sleep(10);
+  // expected-warning@-1 {{Call to blocking function 'sleep' inside of 
critical section}}
+  // expected-note@-2 {{Call to blocking function 'sleep' inside of critical 
section}}
+  m.unlock();
+}



___
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] Backport "[analyzer] Restore recognition of mutex methods" (PR #101651)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101651
___
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] Backport "[analyzer] Restore recognition of mutex methods" (PR #101651)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@steakhal (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/101651
___
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/19.x: [Clang] Correctly forward `--cuda-path` to the nvlink wrapper (#100170) (PR #100216)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/100216

>From fef6b297b77e24239dccedf734b1fe85ff5eb9aa Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Tue, 23 Jul 2024 14:41:57 -0500
Subject: [PATCH 1/5] [Clang] Correctly forward `--cuda-path` to the nvlink
 wrapper (#100170)

Summary:
This was not forwarded properly as it would try to pass it to `nvlink`.

Fixes https://github.com/llvm/llvm-project/issues/100168

(cherry picked from commit 7e1fcf5dd657d465c3fc846f56c6f9d3a4560b43)
---
 clang/lib/Driver/ToolChains/Cuda.cpp   |  4 
 clang/test/Driver/linker-wrapper-passes.c  | 10 +++---
 clang/test/Driver/nvlink-wrapper.c |  7 +++
 clang/tools/clang-nvlink-wrapper/NVLinkOpts.td |  4 ++--
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 59453c484ae4f..61d12b10dfb62 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -609,6 +609,10 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Args.MakeArgString(
 "--pxtas-path=" + Args.getLastArgValue(options::OPT_ptxas_path_EQ)));
 
+  if (Args.hasArg(options::OPT_cuda_path_EQ))
+CmdArgs.push_back(Args.MakeArgString(
+"--cuda-path=" + Args.getLastArgValue(options::OPT_cuda_path_EQ)));
+
   // Add paths specified in LIBRARY_PATH environment variable as -L options.
   addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 
diff --git a/clang/test/Driver/linker-wrapper-passes.c 
b/clang/test/Driver/linker-wrapper-passes.c
index aadcf472e9b63..8c337ff906d17 100644
--- a/clang/test/Driver/linker-wrapper-passes.c
+++ b/clang/test/Driver/linker-wrapper-passes.c
@@ -1,9 +1,5 @@
 // Check various clang-linker-wrapper pass options after -offload-opt.
 
-// REQUIRES: llvm-plugins, llvm-examples
-// REQUIRES: x86-registered-target
-// REQUIRES: amdgpu-registered-target
-
 // Setup.
 // RUN: mkdir -p %t
 // RUN: %clang -cc1 -emit-llvm-bc -o %t/host-x86_64-unknown-linux-gnu.bc \
@@ -23,14 +19,14 @@
 // RUN: %t/host-x86_64-unknown-linux-gnu.s
 
 // Check plugin, -passes, and no remarks.
-// RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+// RUN: clang-linker-wrapper -o a.out --embed-bitcode --dry-run \
 // RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
 // RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
 // RUN: --offload-opt=-passes="function(goodbye),module(inline)" 2>&1 | \
 // RUN:   FileCheck -match-full-lines -check-prefixes=OUT %s
 
 // Check plugin, -p, and remarks.
-// RUN: clang-linker-wrapper -o a.out --embed-bitcode \
+// RUN: clang-linker-wrapper -o a.out --embed-bitcode --dry-run \
 // RUN: --linker-path=/usr/bin/true %t/host-x86_64-unknown-linux-gnu.o \
 // RUN: %offload-opt-loadbye --offload-opt=-wave-goodbye \
 // RUN: --offload-opt=-p="function(goodbye),module(inline)" \
@@ -43,7 +39,7 @@
 // RUN: -check-prefixes=YML %s
 
 // Check handling of bad plugin.
-// RUN: not clang-linker-wrapper \
+// RUN: not clang-linker-wrapper --dry-run \
 // RUN: --offload-opt=-load-pass-plugin=%t/nonexistent.so 2>&1 | \
 // RUN:   FileCheck -match-full-lines -check-prefixes=BAD-PLUGIN %s
 
diff --git a/clang/test/Driver/nvlink-wrapper.c 
b/clang/test/Driver/nvlink-wrapper.c
index fdda93f1f9cdc..318315ddaca34 100644
--- a/clang/test/Driver/nvlink-wrapper.c
+++ b/clang/test/Driver/nvlink-wrapper.c
@@ -63,3 +63,10 @@ int baz() { return y + x; }
 // RUN:   -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=LTO
 // LTO: ptxas{{.*}} -m64 -c [[PTX:.+]].s -O3 -arch sm_52 -o [[CUBIN:.+]].cubin
 // LTO: nvlink{{.*}} -arch sm_52 -o a.out [[CUBIN]].cubin 
{{.*}}-u-{{.*}}.cubin {{.*}}-y-{{.*}}.cubin
+
+//
+// Check that we don't forward some arguments.
+//
+// RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
+// RUN:   -arch sm_52 --cuda-path/opt/cuda -o a.out 2>&1 | FileCheck %s 
--check-prefix=PATH
+// PATH-NOT: --cuda-path=/opt/cuda
diff --git a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td 
b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
index e84b530f2787d..8c80a51b12a44 100644
--- a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
+++ b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
@@ -12,9 +12,9 @@ def verbose : Flag<["-"], "v">, HelpText<"Print verbose 
information">;
 def version : Flag<["--"], "version">,
   HelpText<"Display the version number and exit">;
 
-def cuda_path_EQ : Joined<["--"], "cuda-path=">,
+def cuda_path_EQ : Joined<["--"], "cuda-path=">, Flags<[WrapperOnlyOption]>,
   MetaVarName<"">, HelpText<"Set the system CUDA path">;
-def ptxas_path_EQ : Joined<["--"], "ptxas-path=">,
+def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Flags<[WrapperOnlyOption]>,
   MetaVarName<"">, HelpText<"Set the 'ptxas' path">;
 
 def o : JoinedOrSeparate<["-"], "o">, MetaVarName<"">,

>From 160b1c126a564d258666465e8fe462ab81fef722 Mon 

[llvm-branch-commits] [llvm] release/19.x: [VP] Refactor VectorBuilder to avoid layering violation. NFC (#99276) (PR #101102)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101102

>From c7a918db5895bf61475e3355c5842911a9153d68 Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi 
Date: Sun, 28 Jul 2024 16:48:23 +0900
Subject: [PATCH 1/3] [Bazel] Use PACKAGE_VERSION for version string.

This enables "-rc" suffix in release branches.

(cherry picked from commit 25efb746d907ce0ffdd9195d191ff0f6944ea3ca)
---
 utils/bazel/llvm-project-overlay/clang/BUILD.bazel | 6 +++---
 utils/bazel/llvm-project-overlay/llvm/config.bzl   | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
index 2d7ce8702a5d9..c50dc174a1def 100644
--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -4,10 +4,10 @@
 
 load(
 "//:vars.bzl",
-"LLVM_VERSION",
 "LLVM_VERSION_MAJOR",
 "LLVM_VERSION_MINOR",
 "LLVM_VERSION_PATCH",
+"PACKAGE_VERSION",
 )
 load("//:workspace_root.bzl", "workspace_root")
 load("//llvm:binary_alias.bzl", "binary_alias")
@@ -553,12 +553,12 @@ genrule(
 "echo '#define CLANG_VERSION_MAJOR_STRING \"{major}\"' >> $@\n" +
 "echo '#define CLANG_VERSION_MINOR {minor}' >> $@\n" +
 "echo '#define CLANG_VERSION_PATCHLEVEL {patch}' >> $@\n" +
-"echo '#define CLANG_VERSION_STRING \"{vers}git\"' >> $@\n"
+"echo '#define CLANG_VERSION_STRING \"{vers}\"' >> $@\n"
 ).format(
 major = LLVM_VERSION_MAJOR,
 minor = LLVM_VERSION_MINOR,
 patch = LLVM_VERSION_PATCH,
-vers = LLVM_VERSION,
+vers = PACKAGE_VERSION,
 ),
 )
 
diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl 
b/utils/bazel/llvm-project-overlay/llvm/config.bzl
index 2e3bff53ead9d..9de966688eda5 100644
--- a/utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -6,10 +6,10 @@
 
 load(
 "//:vars.bzl",
-"LLVM_VERSION",
 "LLVM_VERSION_MAJOR",
 "LLVM_VERSION_MINOR",
 "LLVM_VERSION_PATCH",
+"PACKAGE_VERSION",
 )
 
 def native_arch_defines(arch, triple):
@@ -108,7 +108,7 @@ llvm_config_defines = os_defines + builtin_thread_pointer + 
select({
 "LLVM_VERSION_MAJOR={}".format(LLVM_VERSION_MAJOR),
 "LLVM_VERSION_MINOR={}".format(LLVM_VERSION_MINOR),
 "LLVM_VERSION_PATCH={}".format(LLVM_VERSION_PATCH),
-r'LLVM_VERSION_STRING=\"{}git\"'.format(LLVM_VERSION),
+r'LLVM_VERSION_STRING=\"{}\"'.format(PACKAGE_VERSION),
 # These shouldn't be needed by the C++11 standard, but are for some
 # platforms (e.g. glibc < 2.18. See
 # https://sourceware.org/bugzilla/show_bug.cgi?id=15366). These are also

>From fcc61b888ea648fd541572c202ff92114b677668 Mon Sep 17 00:00:00 2001
From: Mel Chen 
Date: Thu, 25 Jul 2024 15:14:39 +0800
Subject: [PATCH 2/3] [VP] Refactor VectorBuilder to avoid layering violation.
 NFC (#99276)

This patch refactors the handling of reduction to eliminate layering
violations.

* Introduced `getReductionIntrinsicID` in LoopUtils.h for mapping
recurrence kinds to llvm.vector.reduce.* intrinsic IDs.
* Updated `VectorBuilder::createSimpleTargetReduction` to accept
llvm.vector.reduce.* intrinsic directly.
* New function `VPIntrinsic::getForIntrinsic` for mapping intrinsic ID
to the same functional VP intrinsic ID.

(cherry picked from commit 6d12b3f67df429b6e1953d9f55867d7e2469)
---
 llvm/include/llvm/IR/IntrinsicInst.h  |  4 ++
 llvm/include/llvm/IR/VectorBuilder.h  |  5 +-
 .../include/llvm/Transforms/Utils/LoopUtils.h |  4 ++
 llvm/lib/IR/IntrinsicInst.cpp | 19 +++
 llvm/lib/IR/VectorBuilder.cpp | 57 ++-
 llvm/lib/Transforms/Utils/LoopUtils.cpp   | 44 +-
 llvm/unittests/IR/VPIntrinsicTest.cpp | 53 +
 7 files changed, 129 insertions(+), 57 deletions(-)

diff --git a/llvm/include/llvm/IR/IntrinsicInst.h 
b/llvm/include/llvm/IR/IntrinsicInst.h
index fe3f92da400f8..94c8fa092f45e 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -569,6 +569,10 @@ class VPIntrinsic : public IntrinsicInst {
   /// The llvm.vp.* intrinsics for this instruction Opcode
   static Intrinsic::ID getForOpcode(unsigned OC);
 
+  /// The llvm.vp.* intrinsics for this intrinsic ID \p Id. Return \p Id if it
+  /// is already a VP intrinsic.
+  static Intrinsic::ID getForIntrinsic(Intrinsic::ID Id);
+
   // Whether \p ID is a VP intrinsic ID.
   static bool isVPIntrinsic(Intrinsic::ID);
 
diff --git a/llvm/include/llvm/IR/VectorBuilder.h 
b/llvm/include/llvm/IR/VectorBuilder.h
index 6af7f6075551d..dbb9f4c7336d5 100644
--- a/llvm/include/llvm/IR/VectorBuilder.h
+++ b/llvm/include/llvm/IR/VectorBuilder.h
@@ -15,7 +15,6 @@
 #ifndef LLVM_IR_VECTORBUILDER_H
 #define LLVM_IR_VECTORBUILDER_H
 
-#include 
 #include 
 #include 
 #include 
@@ -100,11 +99,11 @@ class 

[llvm-branch-commits] [clang] [llvm] release/19.x: [clang] Fix definition of layout-compatible to ignore empty classes (PR #101491)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101491

>From ce34d89cf88a4bde65cff75ff274a23fa2810159 Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Thu, 1 Aug 2024 15:05:46 +0100
Subject: [PATCH] [Clang] Fix definition of layout-compatible to ignore empty
 classes (#92103)

Also changes the behaviour of `__builtin_is_layout_compatible`

None of the historic nor the current definition of layout-compatible
classes mention anything about base classes (other than implicitly
through being standard-layout) and are defined in terms of members, not
direct members.
---
 clang/include/clang/AST/DeclCXX.h  |  7 +++
 clang/lib/AST/DeclCXX.cpp  | 36 +++
 clang/lib/Sema/SemaChecking.cpp| 74 ++
 clang/test/SemaCXX/type-traits.cpp | 11 +
 llvm/include/llvm/ADT/STLExtras.h  |  6 +++
 5 files changed, 84 insertions(+), 50 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..0923736a95f97 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1210,6 +1210,13 @@ class CXXRecordDecl : public RecordDecl {
 return D.HasPublicFields || D.HasProtectedFields || D.HasPrivateFields;
   }
 
+  /// If this is a standard-layout class or union, any and all data members 
will
+  /// be declared in the same type.
+  ///
+  /// This retrieves the type where any fields are declared,
+  /// or the current class if there is no class with fields.
+  const CXXRecordDecl *getStandardLayoutBaseWithFields() const;
+
   /// Whether this class is polymorphic (C++ [class.virtual]),
   /// which means that the class contains or inherits a virtual function.
   bool isPolymorphic() const { return data().Polymorphic; }
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index b573c2713a3aa..9a3ede426e914 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -561,6 +561,42 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().StructuralIfLiteral = false;
 }
 
+const CXXRecordDecl *CXXRecordDecl::getStandardLayoutBaseWithFields() const {
+  assert(
+  isStandardLayout() &&
+  "getStandardLayoutBaseWithFields called on a non-standard-layout type");
+#ifdef EXPENSIVE_CHECKS
+  {
+unsigned NumberOfBasesWithFields = 0;
+if (!field_empty())
+  ++NumberOfBasesWithFields;
+llvm::SmallPtrSet UniqueBases;
+forallBases([&](const CXXRecordDecl *Base) -> bool {
+  if (!Base->field_empty())
+++NumberOfBasesWithFields;
+  assert(
+  UniqueBases.insert(Base->getCanonicalDecl()).second &&
+  "Standard layout struct has multiple base classes of the same type");
+  return true;
+});
+assert(NumberOfBasesWithFields <= 1 &&
+   "Standard layout struct has fields declared in more than one 
class");
+  }
+#endif
+  if (!field_empty())
+return this;
+  const CXXRecordDecl *Result = this;
+  forallBases([&](const CXXRecordDecl *Base) -> bool {
+if (!Base->field_empty()) {
+  // This is the base where the fields are declared; return early
+  Result = Base;
+  return false;
+}
+return true;
+  });
+  return Result;
+}
+
 bool CXXRecordDecl::hasConstexprDestructor() const {
   auto *Dtor = getDestructor();
   return Dtor ? Dtor->isConstexpr() : defaultedDestructorIsConstexpr();
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index cf1196ad23c21..9088b5e285bf8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -13664,10 +13664,11 @@ void Sema::DiagnoseSelfMove(const Expr *LHSExpr, 
const Expr *RHSExpr,
 
 //===--- Layout compatibility --//
 
-static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2);
+static bool isLayoutCompatible(const ASTContext &C, QualType T1, QualType T2);
 
 /// Check if two enumeration types are layout-compatible.
-static bool isLayoutCompatible(ASTContext &C, EnumDecl *ED1, EnumDecl *ED2) {
+static bool isLayoutCompatible(const ASTContext &C, const EnumDecl *ED1,
+   const EnumDecl *ED2) {
   // C++11 [dcl.enum] p8:
   // Two enumeration types are layout-compatible if they have the same
   // underlying type.
@@ -13678,8 +13679,8 @@ static bool isLayoutCompatible(ASTContext &C, EnumDecl 
*ED1, EnumDecl *ED2) {
 /// Check if two fields are layout-compatible.
 /// Can be used on union members, which are exempt from alignment requirement
 /// of common initial sequence.
-static bool isLayoutCompatible(ASTContext &C, FieldDecl *Field1,
-   FieldDecl *Field2,
+static bool isLayoutCompatible(const ASTContext &C, const FieldDecl *Field1,
+   const FieldDecl *Field2,
bool AreUnionMembers = false) {
   [[maybe_unused]] const Type *Field1Parent =
   Field1->getParent()->get

[llvm-branch-commits] [llvm] [PowerPC] Add phony subregisters to cover the high half of the VSX registers. (#94628) (PR #101498)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

@chenzheng1030 Since this is powerpc related - is this is a good candidate to 
backport?

https://github.com/llvm/llvm-project/pull/101498
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/101663
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread via llvm-branch-commits

llvmbot wrote:

@AaronBallman What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/101663
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

Backport 48d4d4b641702bf6db03a1bac73b7e13dea28349

Requested by: @AaronBallman

---
Full diff: https://github.com/llvm/llvm-project/pull/101663.diff


1 Files Affected:

- (modified) clang/docs/CommandGuide/clang.rst (+6-2) 


``diff
diff --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 663aca1f6ddcb..a0c2594d06c61 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -429,8 +429,12 @@ Code Generation Options
 
 :option:`-Ofast` Enables all the optimizations from :option:`-O3` along
 with other aggressive optimizations that may violate strict compliance with
-language standards. This is deprecated in favor of :option:`-O3`
-in combination with :option:`-ffast-math`.
+language standards. This is deprecated in Clang 19 and a warning is emitted
+that :option:`-O3` in combination with :option:`-ffast-math` should be used
+instead if the request for non-standard math behavior is intended. There
+is no timeline yet for removal; the aim is to discourage use of
+:option:`-Ofast` due to the surprising behavior of an optimization flag
+changing the observable behavior of correct code.
 
 :option:`-Os` Like :option:`-O2` with extra optimizations to reduce code
 size.

``




https://github.com/llvm/llvm-project/pull/101663
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] release/19.x: [clang] Fix definition of layout-compatible to ignore empty classes (PR #101491)

2024-08-02 Thread Aaron Ballman via llvm-branch-commits

https://github.com/AaronBallman approved this pull request.

LGTM!

The ABI precommit CI test failures look to be unrelated to these changes, but 
at the same time, this could potentially impact ABI (any time we change the 
behavior of a type trait, it can potentially impact ABI). So it may be good to 
get a second set of eyes on those failures just to be sure they're not caused 
by this PR.

https://github.com/llvm/llvm-project/pull/101491
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread Aaron Ballman via llvm-branch-commits

https://github.com/AaronBallman approved this pull request.

LGTM! There's no chance these changes are what is breaking the ABI precommit CI 
tests. ;-)

https://github.com/llvm/llvm-project/pull/101663
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/101663
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread via llvm-branch-commits

github-actions[bot] wrote:

@AaronBallman (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/101663
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] release/19.x: [clang] Fix definition of layout-compatible to ignore empty classes (PR #101491)

2024-08-02 Thread Vlad Serebrennikov via llvm-branch-commits

Endilll wrote:

This should only affect `__builtin_is_layout_compatible` introduced in Clang 
19, so we don't have an ABI we need to be compatible with.

https://github.com/llvm/llvm-project/pull/101491
___
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] [PowerPC][GlobalMerge] Reduce TOC usage by merging internal and private global data (PR #101224)

2024-08-02 Thread Kai Nacke via llvm-branch-commits

https://github.com/redstar approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/101224
___
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] [PowerPC][GlobalMerge] Enable GlobalMerge by default on AIX (PR #101226)

2024-08-02 Thread Kai Nacke via llvm-branch-commits


@@ -500,7 +500,10 @@ void PPCPassConfig::addIRPasses() {
 }
 
 bool PPCPassConfig::addPreISel() {
-  if (EnableGlobalMerge)
+  if ((EnableGlobalMerge.getNumOccurrences() > 0)
+  ? EnableGlobalMerge
+  : (TM->getTargetTriple().isOSAIX() &&
+ getOptLevel() != CodeGenOptLevel::None))

redstar wrote:

First thought: there is a slight change in the semantics.
The condition `EnableGlobalMerge.getNumOccurrences() > 0` checks how often the 
option was specified on the command line. If I specify 
`-ppc-global-merge=false` then the original `if` returns `false` (because the 
option was specified 1 time, and it's value is `false` but the value of the 
changed condition depends on being on AIX or not.

If the former is really the intended functionality then IMHO it warrants a big 
comment (e.g. "Specifying the command line option overrides AIX default"), just 
to clarify it.

https://github.com/llvm/llvm-project/pull/101226
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] release/19.x: [clang] Fix definition of layout-compatible to ignore empty classes (PR #101491)

2024-08-02 Thread Aaron Ballman via llvm-branch-commits

AaronBallman wrote:

Thanks for reminding me of that @Endilll -- LGTM still.

https://github.com/llvm/llvm-project/pull/101491
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread Aaron Ballman via llvm-branch-commits

AaronBallman wrote:

The current release note reads as:
```
- The ``-Ofast`` command-line option has been deprecated. This option both
  enables the ``-O3`` optimization-level, as well as enabling non-standard
  ``-ffast-math`` behaviors. As such, it is somewhat misleading as an
  "optimization level". Users are advised to switch to ``-O3 -ffast-math`` if
  the use of non-standard math behavior is intended, and ``-O3`` otherwise.
  See `RFC `_ for 
details.
```
and I think we'd like this to be changed to instead read:
```
- The ``-Ofast`` command-line option has been deprecated. This option both
  enables the ``-O3`` optimization-level, as well as enabling other
  options, including non-standard ``-ffast-math`` behaviors. As such, 
  it is somewhat misleading as an "optimization level". Users are
  advised to switch to ``-O3 -ffast-math -fstrict-aliasing``
  to retain the previous behavior, and ``-O3`` otherwise.
  **Note**: there is no firm date for removal of the option; its
  use is discouraged and the option may or may not be removed
  in the future. See
  `RFC `_
  for details.
```
WDYT @sjoerdmeijer ?

https://github.com/llvm/llvm-project/pull/101663
___
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/19.x: Ofast deprecation clarifications (#101005) (PR #101663)

2024-08-02 Thread Sjoerd Meijer via llvm-branch-commits

https://github.com/sjoerdmeijer commented:

Excellent, thanks, LGTM

https://github.com/llvm/llvm-project/pull/101663
___
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] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)

2024-08-02 Thread Tom Stellard via llvm-branch-commits


@@ -0,0 +1,86 @@
+#!/usr/bin/env bash
+#===-- get-llvm-version.sh - Test the LLVM release candidates 
--===#

tstellar wrote:

Fixed here: PR#101569.  I'll merge #101569 and then backport the change to the 
release branch.

https://github.com/llvm/llvm-project/pull/101554
___
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/19.x: Forward declare OSSpinLockLock on MacOS since it's not shipped on the system. (#101392) (PR #101432)

2024-08-02 Thread Tim Northover via llvm-branch-commits

TNorthover wrote:

Looks safe enough to me. The added declaration matches the one in the header. I 
don't think it's actually gone yet in the latest Xcode 16 beta public SDK, but 
presumably it's happening soon.

https://github.com/llvm/llvm-project/pull/101432
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [OpenMP][MLIR] Descriptor explicit member map lowering changes (PR #96265)

2024-08-02 Thread via llvm-branch-commits

https://github.com/agozillon updated 
https://github.com/llvm/llvm-project/pull/96265


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [OpenMP][MLIR] Descriptor explicit member map lowering changes (PR #96265)

2024-08-02 Thread via llvm-branch-commits

https://github.com/agozillon updated 
https://github.com/llvm/llvm-project/pull/96265


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits

https://github.com/agozillon updated 
https://github.com/llvm/llvm-project/pull/96266

>From 2e24a3b56c2be7203aa87b1d6bb886706e138496 Mon Sep 17 00:00:00 2001
From: agozillon 
Date: Tue, 25 Jun 2024 17:40:04 -0500
Subject: [PATCH 1/2] removal of some leftover artifacts

Created using spr 1.3.4
---
 flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp 
b/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
index 8749daf757f52..c88b3cf4cc0b4 100644
--- a/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
+++ b/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
@@ -493,13 +493,6 @@ class OMPMapInfoFinalizationPass
   mlir::isa_and_present(
   op.getVarPtr().getDefiningOp())) {
 builder.setInsertionPoint(op);
-
-// - contact benifit people
-// - update broken  lit tests
-// -create commit and apply clang-format
-// -cherry pick pr onto PR stack and split the commit into relevant
-// components and rebase fixup into orignal corresponding PR. -push
-// upstream
 genDescriptorMemberMaps(op, builder, getFirstTargetUser(op));
   }
 });

>From d81e63d0f8cfa4d63463a10dcca2ea36ced0c02f Mon Sep 17 00:00:00 2001
From: agozillon 
Date: Fri, 2 Aug 2024 02:04:59 -0500
Subject: [PATCH 2/2] remove leftover cmake artifact

Created using spr 1.3.4
---
 flang/lib/Common/CMakeLists.txt | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 60de8e0f7427a..c6f818ad27cd1 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -43,9 +43,6 @@ add_flang_library(FortranCommon
   Version.cpp
   ${version_inc}
 
-  LINK_LIBS
-  MLIRDialect
-
   LINK_COMPONENTS
   Support
 )

___
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] Derived type explicit allocatable member mapping (PR #96266)

2024-08-02 Thread via llvm-branch-commits

https://github.com/agozillon updated 
https://github.com/llvm/llvm-project/pull/96266

>From 2e24a3b56c2be7203aa87b1d6bb886706e138496 Mon Sep 17 00:00:00 2001
From: agozillon 
Date: Tue, 25 Jun 2024 17:40:04 -0500
Subject: [PATCH 1/2] removal of some leftover artifacts

Created using spr 1.3.4
---
 flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp 
b/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
index 8749daf757f52..c88b3cf4cc0b4 100644
--- a/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
+++ b/flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
@@ -493,13 +493,6 @@ class OMPMapInfoFinalizationPass
   mlir::isa_and_present(
   op.getVarPtr().getDefiningOp())) {
 builder.setInsertionPoint(op);
-
-// - contact benifit people
-// - update broken  lit tests
-// -create commit and apply clang-format
-// -cherry pick pr onto PR stack and split the commit into relevant
-// components and rebase fixup into orignal corresponding PR. -push
-// upstream
 genDescriptorMemberMaps(op, builder, getFirstTargetUser(op));
   }
 });

>From d81e63d0f8cfa4d63463a10dcca2ea36ced0c02f Mon Sep 17 00:00:00 2001
From: agozillon 
Date: Fri, 2 Aug 2024 02:04:59 -0500
Subject: [PATCH 2/2] remove leftover cmake artifact

Created using spr 1.3.4
---
 flang/lib/Common/CMakeLists.txt | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 60de8e0f7427a..c6f818ad27cd1 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -43,9 +43,6 @@ add_flang_library(FortranCommon
   Version.cpp
   ${version_inc}
 
-  LINK_LIBS
-  MLIRDialect
-
   LINK_COMPONENTS
   Support
 )

___
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] [llvm] release/19.x: [MC/DC][Coverage] Introduce "Bitmap Bias" for continuous mode (#96126) (PR #101629)

2024-08-02 Thread NAKAMURA Takumi via llvm-branch-commits

https://github.com/chapuni approved this pull request.

Let me self-approve at first :)

I've checked this functionality with running `check-llvm` on Linux. Note, `%c` 
is extremely slowere than non-continuous mode, even if `%c%m8` on 48 cores.

In general, continuous mode tends to emit better score (than non-continuous 
mode), guessing it will cover also crashing tests.

https://github.com/llvm/llvm-project/pull/101629
___
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/19.x: [VP] Refactor VectorBuilder to avoid layering violation. NFC (#99276) (PR #101102)

2024-08-02 Thread NAKAMURA Takumi via llvm-branch-commits

chapuni wrote:

The layering violation will break modules builds. I don't agree for us to 
release broken headers.

https://github.com/llvm/llvm-project/pull/101102
___
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] Backport "[analyzer] Fix crash on using `bitcast(, )` as array subscript" (PR #101684)

2024-08-02 Thread Balazs Benics via llvm-branch-commits

https://github.com/steakhal milestoned 
https://github.com/llvm/llvm-project/pull/101684
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


  1   2   3   >