[llvm-branch-commits] Extract EmitCheckedArgForAssume (PR #109880)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Vitaly Buka (vitalybuka)


Changes



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


3 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+21-12) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-2) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+4) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 83da5d7d75be3b..bf68841c4bc7ed 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1996,21 +1996,16 @@ struct CallObjCArcUse final : EHScopeStack::Cleanup {
 
 Value *CodeGenFunction::EmitCheckedArgForBuiltin(const Expr *E,
  BuiltinCheckKind Kind) {
-  assert((Kind == BCK_CLZPassedZero || Kind == BCK_CTZPassedZero ||
-  Kind == BCK_AssumePassedFalse) &&
- "Unsupported builtin check kind");
+  assert((Kind == BCK_CLZPassedZero || Kind == BCK_CTZPassedZero)
+  && "Unsupported builtin check kind");
 
-  Value *ArgValue =
-  Kind == BCK_AssumePassedFalse ? EvaluateExprAsBool(E) : 
EmitScalarExpr(E);
+  Value *ArgValue = EmitScalarExpr(E);
   if (!SanOpts.has(SanitizerKind::Builtin))
 return ArgValue;
 
   SanitizerScope SanScope(this);
-  Value *Cond =
-  Kind == BCK_AssumePassedFalse
-  ? ArgValue
-  : Builder.CreateICmpNE(
-ArgValue, llvm::Constant::getNullValue(ArgValue->getType()));
+  Value *Cond = Builder.CreateICmpNE(
+  ArgValue, llvm::Constant::getNullValue(ArgValue->getType()));
   EmitCheck(std::make_pair(Cond, SanitizerKind::Builtin),
 SanitizerHandler::InvalidBuiltin,
 {EmitCheckSourceLocation(E->getExprLoc()),
@@ -2019,6 +2014,21 @@ Value *CodeGenFunction::EmitCheckedArgForBuiltin(const 
Expr *E,
   return ArgValue;
 }
 
+Value *CodeGenFunction::EmitCheckedArgForAssume(const Expr *E) {
+  Value *ArgValue = EvaluateExprAsBool(E);
+  if (!SanOpts.has(SanitizerKind::Builtin))
+return ArgValue;
+
+  SanitizerScope SanScope(this);
+  EmitCheck(
+  std::make_pair(ArgValue, SanitizerKind::Builtin),
+  SanitizerHandler::InvalidBuiltin,
+  {EmitCheckSourceLocation(E->getExprLoc()),
+   llvm::ConstantInt::get(Builder.getInt8Ty(), BCK_AssumePassedFalse)},
+  std::nullopt);
+  return ArgValue;
+}
+
 static Value *EmitAbs(CodeGenFunction &CGF, Value *ArgValue, bool HasNSW) {
   return CGF.Builder.CreateBinaryIntrinsic(
   Intrinsic::abs, ArgValue,
@@ -3429,8 +3439,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 if (E->getArg(0)->HasSideEffects(getContext()))
   return RValue::get(nullptr);
 
-Value *ArgValue =
-EmitCheckedArgForBuiltin(E->getArg(0), BCK_AssumePassedFalse);
+Value *ArgValue = EmitCheckedArgForAssume(E->getArg(0));
 Function *FnAssume = CGM.getIntrinsic(Intrinsic::assume);
 Builder.CreateCall(FnAssume, ArgValue);
 return RValue::get(nullptr);
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 291639346d8952..f4ecc01598f936 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -754,8 +754,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
   const Expr *Assumption = cast(A)->getAssumption();
   if (getLangOpts().CXXAssumptions &&
   !Assumption->HasSideEffects(getContext())) {
-llvm::Value *AssumptionVal =
-EmitCheckedArgForBuiltin(Assumption, BCK_AssumePassedFalse);
+llvm::Value *AssumptionVal = EmitCheckedArgForAssume(Assumption);
 Builder.CreateAssumption(AssumptionVal);
   }
 } break;
diff --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 99db330f3316e5..04dfaffd811c02 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -5077,6 +5077,10 @@ class CodeGenFunction : public CodeGenTypeCache {
   /// enabled, a runtime check specified by \p Kind is also emitted.
   llvm::Value *EmitCheckedArgForBuiltin(const Expr *E, BuiltinCheckKind Kind);
 
+  /// Emits an argument for a call to a `__builtin_assume`. If the builtin
+  /// sanitizer is enabled, a runtime check is also emitted.
+  llvm::Value *EmitCheckedArgForAssume(const Expr *E);
+
   /// Emit a description of a type in a format suitable for passing to
   /// a runtime sanitizer handler.
   llvm::Constant *EmitCheckTypeDescriptor(QualType T);

``




https://github.com/llvm/llvm-project/pull/109880
___
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] Extract EmitCheckedArgForAssume (PR #109880)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)


Changes



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


3 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+21-12) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-2) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+4) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 83da5d7d75be3b..bf68841c4bc7ed 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1996,21 +1996,16 @@ struct CallObjCArcUse final : EHScopeStack::Cleanup {
 
 Value *CodeGenFunction::EmitCheckedArgForBuiltin(const Expr *E,
  BuiltinCheckKind Kind) {
-  assert((Kind == BCK_CLZPassedZero || Kind == BCK_CTZPassedZero ||
-  Kind == BCK_AssumePassedFalse) &&
- "Unsupported builtin check kind");
+  assert((Kind == BCK_CLZPassedZero || Kind == BCK_CTZPassedZero)
+  && "Unsupported builtin check kind");
 
-  Value *ArgValue =
-  Kind == BCK_AssumePassedFalse ? EvaluateExprAsBool(E) : 
EmitScalarExpr(E);
+  Value *ArgValue = EmitScalarExpr(E);
   if (!SanOpts.has(SanitizerKind::Builtin))
 return ArgValue;
 
   SanitizerScope SanScope(this);
-  Value *Cond =
-  Kind == BCK_AssumePassedFalse
-  ? ArgValue
-  : Builder.CreateICmpNE(
-ArgValue, llvm::Constant::getNullValue(ArgValue->getType()));
+  Value *Cond = Builder.CreateICmpNE(
+  ArgValue, llvm::Constant::getNullValue(ArgValue->getType()));
   EmitCheck(std::make_pair(Cond, SanitizerKind::Builtin),
 SanitizerHandler::InvalidBuiltin,
 {EmitCheckSourceLocation(E->getExprLoc()),
@@ -2019,6 +2014,21 @@ Value *CodeGenFunction::EmitCheckedArgForBuiltin(const 
Expr *E,
   return ArgValue;
 }
 
+Value *CodeGenFunction::EmitCheckedArgForAssume(const Expr *E) {
+  Value *ArgValue = EvaluateExprAsBool(E);
+  if (!SanOpts.has(SanitizerKind::Builtin))
+return ArgValue;
+
+  SanitizerScope SanScope(this);
+  EmitCheck(
+  std::make_pair(ArgValue, SanitizerKind::Builtin),
+  SanitizerHandler::InvalidBuiltin,
+  {EmitCheckSourceLocation(E->getExprLoc()),
+   llvm::ConstantInt::get(Builder.getInt8Ty(), BCK_AssumePassedFalse)},
+  std::nullopt);
+  return ArgValue;
+}
+
 static Value *EmitAbs(CodeGenFunction &CGF, Value *ArgValue, bool HasNSW) {
   return CGF.Builder.CreateBinaryIntrinsic(
   Intrinsic::abs, ArgValue,
@@ -3429,8 +3439,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 if (E->getArg(0)->HasSideEffects(getContext()))
   return RValue::get(nullptr);
 
-Value *ArgValue =
-EmitCheckedArgForBuiltin(E->getArg(0), BCK_AssumePassedFalse);
+Value *ArgValue = EmitCheckedArgForAssume(E->getArg(0));
 Function *FnAssume = CGM.getIntrinsic(Intrinsic::assume);
 Builder.CreateCall(FnAssume, ArgValue);
 return RValue::get(nullptr);
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 291639346d8952..f4ecc01598f936 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -754,8 +754,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
   const Expr *Assumption = cast(A)->getAssumption();
   if (getLangOpts().CXXAssumptions &&
   !Assumption->HasSideEffects(getContext())) {
-llvm::Value *AssumptionVal =
-EmitCheckedArgForBuiltin(Assumption, BCK_AssumePassedFalse);
+llvm::Value *AssumptionVal = EmitCheckedArgForAssume(Assumption);
 Builder.CreateAssumption(AssumptionVal);
   }
 } break;
diff --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 99db330f3316e5..04dfaffd811c02 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -5077,6 +5077,10 @@ class CodeGenFunction : public CodeGenTypeCache {
   /// enabled, a runtime check specified by \p Kind is also emitted.
   llvm::Value *EmitCheckedArgForBuiltin(const Expr *E, BuiltinCheckKind Kind);
 
+  /// Emits an argument for a call to a `__builtin_assume`. If the builtin
+  /// sanitizer is enabled, a runtime check is also emitted.
+  llvm::Value *EmitCheckedArgForAssume(const Expr *E);
+
   /// Emit a description of a type in a format suitable for passing to
   /// a runtime sanitizer handler.
   llvm::Constant *EmitCheckTypeDescriptor(QualType T);

``




https://github.com/llvm/llvm-project/pull/109880
___
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] [MLIR][OpenMP] Use map format to represent use_device_{addr, ptr} (PR #109810)

2024-09-24 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak created 
https://github.com/llvm/llvm-project/pull/109810

This patch updates the `omp.target_data` operation to use the same formatting 
as `map` clauses on `omp.target` for `use_device_addr` and `use_device_ptr`. 
This is done so the mapping that is being enforced between op arguments and 
associated entry block arguments is explicit.

The way it is achieved is by marking these clauses as entry block 
argument-defining and adjusting printer/parsers accordingly.

As a result of this change, block arguments for `use_device_addr` come before 
those for `use_device_ptr`, which is the opposite of the previous undocumented 
situation. Some unit tests are updated based on this change, in addition to 
those updated because of the format change.

>From b0b762580647f488d5b5aa64f3853800fd207388 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Fri, 20 Sep 2024 17:11:34 +0100
Subject: [PATCH] [MLIR][OpenMP] Use map format to represent
 use_device_{addr,ptr}

This patch updates the `omp.target_data` operation to use the same formatting
as `map` clauses on `omp.target` for `use_device_addr` and `use_device_ptr`.
This is done so the mapping that is being enforced between op arguments and
associated entry block arguments is explicit.

The way it is achieved is by marking these clauses as entry block
argument-defining and adjusting printer/parsers accordingly.

As a result of this change, block arguments for `use_device_addr` come before
those for `use_device_ptr`, which is the opposite of the previous undocumented
situation. Some unit tests are updated based on this change, in addition to
those updated because of the format change.
---
 .../Fir/convert-to-llvm-openmp-and-fir.fir|  5 +-
 flang/test/Lower/OpenMP/target.f90|  6 +-
 .../use-device-ptr-to-use-device-addr.f90 | 12 +--
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 28 ++-
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  6 ++
 .../Dialect/OpenMP/OpenMPOpsInterfaces.td | 28 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  | 43 ++
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 80 ---
 mlir/test/Dialect/OpenMP/ops.mlir |  6 +-
 mlir/test/Target/LLVMIR/omptarget-llvm.mlir   | 19 ++---
 .../openmp-target-use-device-nested.mlir  |  3 +-
 11 files changed, 173 insertions(+), 63 deletions(-)

diff --git a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir 
b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
index 4d226eaa754c12..61f18008633d50 100644
--- a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
+++ b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
@@ -429,13 +429,14 @@ func.func @_QPopenmp_target_data_region() {
 
 func.func @_QPomp_target_data_empty() {
   %0 = fir.alloca !fir.array<1024xi32> {bindc_name = "a", uniq_name = 
"_QFomp_target_data_emptyEa"}
-  omp.target_data use_device_addr(%0 : !fir.ref>) {
+  omp.target_data use_device_addr(%0 -> %arg0 : 
!fir.ref>) {
+omp.terminator
   }
   return
 }
 
 // CHECK-LABEL:   llvm.func @_QPomp_target_data_empty
-// CHECK: omp.target_data   use_device_addr(%1 : !llvm.ptr) {
+// CHECK: omp.target_data   use_device_addr(%1 -> %{{.*}} : !llvm.ptr) {
 // CHECK: }
 
 // -
diff --git a/flang/test/Lower/OpenMP/target.f90 
b/flang/test/Lower/OpenMP/target.f90
index dedce581436490..ab33b6b3808315 100644
--- a/flang/test/Lower/OpenMP/target.f90
+++ b/flang/test/Lower/OpenMP/target.f90
@@ -506,9 +506,8 @@ subroutine omp_target_device_ptr
type(c_ptr) :: a
integer, target :: b
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}})   map_clauses(tofrom) 
capture(ByRef) -> {{.*}} {name = "a"}
-   !CHECK: omp.target_data map_entries(%[[MAP]]{{.*}}) use_device_ptr({{.*}})
+   !CHECK: omp.target_data map_entries(%[[MAP]]{{.*}}) use_device_ptr({{.*}} 
-> %[[VAL_1:.*]] : 
!fir.ref>)
!$omp target data map(tofrom: a) use_device_ptr(a)
-   !CHECK: ^bb0(%[[VAL_1:.*]]: 
!fir.ref>):
!CHECK: {{.*}} = fir.coordinate_of %[[VAL_1:.*]], {{.*}} : 
(!fir.ref>, 
!fir.field) -> !fir.ref
   a = c_loc(b)
!CHECK: omp.terminator
@@ -529,9 +528,8 @@ subroutine omp_target_device_addr
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}} : 
!fir.ref>>, !fir.box>) map_clauses(tofrom) 
capture(ByRef) members(%[[MAP_MEMBERS]] : [0] : !fir.llvm_ptr>) 
-> !fir.ref>> {name = "a"}
!CHECK: %[[DEV_ADDR_MEMBERS:.*]] = omp.map.info var_ptr({{.*}} : 
!fir.ref>>, i32) var_ptr_ptr({{.*}} : 
!fir.llvm_ptr>) map_clauses(tofrom) capture(ByRef) -> 
!fir.llvm_ptr> {name = ""}
!CHECK: %[[DEV_ADDR:.*]] = omp.map.info var_ptr({{.*}} : 
!fir.ref>>, !fir.box>) map_clauses(tofrom) 
capture(ByRef) members(%[[DEV_ADDR_MEMBERS]] : [0] : 
!fir.llvm_ptr>) -> !fir.ref>> {name = "a"}
-   !CHECK: omp.target_data map_entries(%[[MAP_MEMBERS]], %[[MAP]] : {{.*}}) 
use_device_addr(%[[DEV_ADDR_MEMBERS]], %[[DEV_ADDR]] : {{.*}}) {
+   !CHECK: omp.target_data map_entries(%[[MAP_MEMBERS]], %[[MAP]] : {{.*}}) 
use_device_addr(%[[DEV_ADDR_MEMBERS]] 

[llvm-branch-commits] [mlir] [MLIR][OpenMP] Document entry block argument-defining clauses (NFC) (PR #109811)

2024-09-24 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak created 
https://github.com/llvm/llvm-project/pull/109811

This patch adds general information on the proposed approach to unify the 
handling and representation of clauses that define entry block arguments 
attached to operations that accept them.

>From 5849d254865554276d44635d73778fba64db5a47 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Tue, 24 Sep 2024 15:40:17 +0100
Subject: [PATCH] [MLIR][OpenMP] Document entry block argument-defining clauses
 (NFC)

This patch adds general information on the proposed approach to unify the
handling and representation of clauses that define entry block arguments
attached to operations that accept them.
---
 mlir/docs/Dialects/OpenMPDialect/_index.md | 70 +-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/mlir/docs/Dialects/OpenMPDialect/_index.md 
b/mlir/docs/Dialects/OpenMPDialect/_index.md
index 88437b8cf828cc..3c30b29d09356b 100644
--- a/mlir/docs/Dialects/OpenMPDialect/_index.md
+++ b/mlir/docs/Dialects/OpenMPDialect/_index.md
@@ -285,7 +285,75 @@ argument's type:
   specific `mlir::Attribute` subclass) will be used instead.
   - Other attribute types will be represented with their `storageType`.
 - It will create `Operands` structure for each operation, which is an
-empty structure subclassing all operand structures defined for the 
corresponding `OpenMP_Op`'s clauses.
+empty structure subclassing all operand structures defined for the 
corresponding
+`OpenMP_Op`'s clauses.
+
+### Entry Block Argument-Defining Clauses
+
+Certain OpenMP clauses introduce in their MLIR representation mappings between
+outside values and entry block arguments for the region of the MLIR operation
+they are applied to. This enables, for example, the introduction of private
+copies of the same underlying variable. Currently, clauses with this property
+can be classified in three main categories:
+  - Map-like clauses: `map`, `use_device_addr` and `use_device_ptr`.
+  - Reduction-like clauses: `in_reduction`, `reduction` and `task_reduction`.
+  - Privatization clause: `private`.
+
+All three kinds of entry block argument-defining clauses use a similar custom
+assembly format representation, only differing based on the different pieces of
+information attached to each kind. Below, one example of each is shown:
+
+```mlir
+omp.target map_entries(%x -> %x.m, %y -> %y.m : !llvm.ptr, !llvm.ptr) {
+  // Use %x.m, %y.m in place of %x and %y...
+}
+
+omp.wsloop reduction(@add.i32 %x -> %x.r, byref @add.f32 %y -> %y.r : 
!llvm.ptr, !llvm.ptr) {
+  // Use %x.r, %y.r in place of %x and %y...
+}
+
+omp.parallel private(@x.privatizer %x -> %x.p, @y.privatizer %y -> %y.p : 
!llvm.ptr, !llvm.ptr) {
+  // Use %x.p, %y.p in place of %x and %y...
+}
+```
+
+As a consequence of parsing and printing the operation's first region entry
+block argument names together with the custom assembly format of these clauses,
+entry block arguments (i.e. the `^bb0(...):` line) must not be explicitly
+defined for these operations. Additionally, it is not possible to implement 
this
+feature while allowing each clause to be independently parsed and printed,
+because they need to be printed/parsed together with the corresponding
+operation's first region. They must have a well-defined ordering in which
+multiple of these clauses are specified for a given operation, as well.
+
+The parsing/printing of these clauses together with the region provides the
+ability to define entry block arguments directly after the `->`. Forcing a
+specific ordering between these clauses makes the block argument ordering
+well-defined, which is the property used to easily match each clause with the
+entry block arguments defined by it.
+
+Custom printers and parsers for operation regions based on the entry block
+argument-defining clauses they take are implemented based on the
+`{parse,print}BlockArgRegion` functions, which take care of the sorting and
+formatting of each kind of clause, minimizing code duplication resulting from
+this approach. One example of the custom assembly format of an operation taking
+the `private` and `reduction` clauses is the following:
+
+```tablegen
+let assemblyFormat = clausesAssemblyFormat # [{
+  custom($region, $private_vars, type($private_vars),
+  $private_syms, $reduction_vars, type($reduction_vars), $reduction_byref,
+  $reduction_syms) attr-dict
+}];
+```
+
+The `BlockArgOpenMPOpInterface` has been introduced to simplify the addition 
and
+handling of these kinds of clauses. It holds `numBlockArgs()`
+functions that by default return 0, to be overriden by each clause through the
+`extraClassDeclaration` property. Based on these functions and the expected
+alphabetical sorting between entry block argument-defining clauses, it
+implements `getBlockArgs()` functions that are the intended method
+of accessing clause-defined block arguments.
 
 ## Loop-Associated Directives
 

___
llvm-b

[llvm-branch-commits] [flang] [mlir] [MLIR][OpenMP] Normalize representation of entry block arg-defining clauses (PR #109809)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-flang-fir-hlfir

Author: Sergio Afonso (skatrak)


Changes

This patch updates printing and parsing of operations including clauses that 
define entry block arguments to the operation's region. This impacts 
`in_reduction`, `map`, `private`, `reduction` and `task_reduction`.

The proposed representation to be used by all such clauses is the following:
```
([byref] [@] %value -> %block_arg [, ...] : 
[, ...]) {
  ...
}
```

The `byref` tag is only allowed for reduction-like clauses and the 
`@` is required and only allowed for the `private` and 
reduction-like clauses. The `map` clause does not accept any of these two.

This change fixes some currently broken op representations, like `omp.teams` or 
`omp.sections` reduction:
```
omp.teams reduction([byref] @ -> %value : ) {
^bb0(%block_arg : ):
  ...
}
```

Additionally, it addresses some redundancy in the representation of the 
previously mentioned cases, as well as e.g. `map` in `omp.target`. The problem 
is that the block argument name after the arrow is not checked in any way, 
which makes some misleading representations legal:
```mlir
omp.target map_entries(%x -> %arg1, %y -> %arg0, %z -> %doesnt_exist : 
!llvm.ptr, !llvm.ptr, !llvm.ptr) {
^bb0(%arg0 : !llvm.ptr, %arg1 : !llvm.ptr, %arg2 : !llvm.ptr):
  ...
}
```

In that case, `%x` maps to `%arg0`, contrary to what the representation states, 
and `%z` maps to `%arg2`. `%doesnt_exist` is not resolved, so it would likely 
cause issues if used anywhere inside of the operation's region.

The solution implemented in this patch makes it so that values introduced after 
the arrow on the representation of these clauses implicitly define the 
corresponding entry block arguments, removing the potential for these 
problematic representations. This is what is already implemented for the 
`private` and `reduction` clauses of `omp.parallel`.

There are a couple of consequences of this change:
- Entry block argument-defining clauses must come at the end of the operation's 
representation and in alphabetical order. This is because they are 
printed/parsed as part of the region and a standardized ordering is needed to 
reliably match op arguments with their corresponding entry block arguments via 
the `BlockArgOpenMPOpInterface`.
- We can no longer define per-clause assembly formats to be reused by all 
operations that take these clauses, since they must be passed to a custom 
printer including the region and arguments of all other entry block 
argument-defining clauses. Code duplication and potential for introducing 
issues is minimized by providing the generic `{print,parse}BlockArgRegion` 
helpers and associated structures.

MLIR and Flang lowering unit tests are updated due to changes in the order and 
formatting of impacted operations.

---

Patch is 237.16 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/109809.diff


78 Files Affected:

- (modified) flang/test/Fir/convert-to-llvm-openmp-and-fir.fir (+1-11) 
- (modified) 
flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90
 (+7-6) 
- (modified) 
flang/test/Lower/OpenMP/DelayedPrivatization/target-private-simple.f90 (+1-2) 
- (modified) flang/test/Lower/OpenMP/Todo/omp-default-clause-inner-loop.f90 
(+1-1) 
- (modified) flang/test/Lower/OpenMP/common-block-map.f90 (-3) 
- (modified) flang/test/Lower/OpenMP/default-clause-byref.f90 (+15-15) 
- (modified) flang/test/Lower/OpenMP/default-clause.f90 (+18-18) 
- (modified) 
flang/test/Lower/OpenMP/delayed-privatization-private-firstprivate.f90 (+3-2) 
- (modified) flang/test/Lower/OpenMP/derived-type-map.f90 (-9) 
- (modified) flang/test/Lower/OpenMP/distribute-parallel-do-simd.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/distribute-parallel-do.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/firstprivate-commonblock.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/implicit-dsa.f90 (+3-3) 
- (modified) flang/test/Lower/OpenMP/map-component-ref.f90 (-1) 
- (modified) flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90 
(+5-5) 
- (modified) flang/test/Lower/OpenMP/parallel-private-clause.f90 (+4-4) 
- (modified) flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/parallel-reduction-add.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/parallel-wsloop.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/private-commonblock.f90 (+3-3) 
- (modified) flang/test/Lower/OpenMP/sections-array-reduction.f90 (+1-2) 
- (modified) flang/test/Lower/OpenMP/sections-reduction.f90 (+2-4) 
- (modified) flang/test/Lower/OpenMP/statement-function.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/target.f90 (+1-8) 
- (modified) flang/test/Lower/OpenMP/unstructured.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/wsloop-reduction-add-byref.f90 (+3-3) 
-

[llvm-branch-commits] [flang] [mlir] [MLIR][OpenMP] Normalize representation of entry block arg-defining clauses (PR #109809)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Sergio Afonso (skatrak)


Changes

This patch updates printing and parsing of operations including clauses that 
define entry block arguments to the operation's region. This impacts 
`in_reduction`, `map`, `private`, `reduction` and `task_reduction`.

The proposed representation to be used by all such clauses is the following:
```
([byref] [@] %value -> %block_arg [, ...] : 
[, ...]) {
  ...
}
```

The `byref` tag is only allowed for reduction-like clauses and the 
`@` is required and only allowed for the `private` and 
reduction-like clauses. The `map` clause does not accept any of these two.

This change fixes some currently broken op representations, like `omp.teams` or 
`omp.sections` reduction:
```
omp.teams reduction([byref] @ -> %value : ) {
^bb0(%block_arg : ):
  ...
}
```

Additionally, it addresses some redundancy in the representation of the 
previously mentioned cases, as well as e.g. `map` in `omp.target`. The problem 
is that the block argument name after the arrow is not checked in any way, 
which makes some misleading representations legal:
```mlir
omp.target map_entries(%x -> %arg1, %y -> %arg0, %z -> %doesnt_exist : 
!llvm.ptr, !llvm.ptr, !llvm.ptr) {
^bb0(%arg0 : !llvm.ptr, %arg1 : !llvm.ptr, %arg2 : !llvm.ptr):
  ...
}
```

In that case, `%x` maps to `%arg0`, contrary to what the representation states, 
and `%z` maps to `%arg2`. `%doesnt_exist` is not resolved, so it would likely 
cause issues if used anywhere inside of the operation's region.

The solution implemented in this patch makes it so that values introduced after 
the arrow on the representation of these clauses implicitly define the 
corresponding entry block arguments, removing the potential for these 
problematic representations. This is what is already implemented for the 
`private` and `reduction` clauses of `omp.parallel`.

There are a couple of consequences of this change:
- Entry block argument-defining clauses must come at the end of the operation's 
representation and in alphabetical order. This is because they are 
printed/parsed as part of the region and a standardized ordering is needed to 
reliably match op arguments with their corresponding entry block arguments via 
the `BlockArgOpenMPOpInterface`.
- We can no longer define per-clause assembly formats to be reused by all 
operations that take these clauses, since they must be passed to a custom 
printer including the region and arguments of all other entry block 
argument-defining clauses. Code duplication and potential for introducing 
issues is minimized by providing the generic `{print,parse}BlockArgRegion` 
helpers and associated structures.

MLIR and Flang lowering unit tests are updated due to changes in the order and 
formatting of impacted operations.

---

Patch is 237.16 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/109809.diff


78 Files Affected:

- (modified) flang/test/Fir/convert-to-llvm-openmp-and-fir.fir (+1-11) 
- (modified) 
flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90
 (+7-6) 
- (modified) 
flang/test/Lower/OpenMP/DelayedPrivatization/target-private-simple.f90 (+1-2) 
- (modified) flang/test/Lower/OpenMP/Todo/omp-default-clause-inner-loop.f90 
(+1-1) 
- (modified) flang/test/Lower/OpenMP/common-block-map.f90 (-3) 
- (modified) flang/test/Lower/OpenMP/default-clause-byref.f90 (+15-15) 
- (modified) flang/test/Lower/OpenMP/default-clause.f90 (+18-18) 
- (modified) 
flang/test/Lower/OpenMP/delayed-privatization-private-firstprivate.f90 (+3-2) 
- (modified) flang/test/Lower/OpenMP/derived-type-map.f90 (-9) 
- (modified) flang/test/Lower/OpenMP/distribute-parallel-do-simd.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/distribute-parallel-do.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/firstprivate-commonblock.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/implicit-dsa.f90 (+3-3) 
- (modified) flang/test/Lower/OpenMP/map-component-ref.f90 (-1) 
- (modified) flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90 
(+5-5) 
- (modified) flang/test/Lower/OpenMP/parallel-private-clause.f90 (+4-4) 
- (modified) flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/parallel-reduction-add.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/parallel-wsloop.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/private-commonblock.f90 (+3-3) 
- (modified) flang/test/Lower/OpenMP/sections-array-reduction.f90 (+1-2) 
- (modified) flang/test/Lower/OpenMP/sections-reduction.f90 (+2-4) 
- (modified) flang/test/Lower/OpenMP/statement-function.f90 (+2-2) 
- (modified) flang/test/Lower/OpenMP/target.f90 (+1-8) 
- (modified) flang/test/Lower/OpenMP/unstructured.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/wsloop-reduction-add-byref.f90 (+3-3) 
- (modified)

[llvm-branch-commits] [flang] [mlir] [MLIR][OpenMP] Use map format to represent use_device_{addr, ptr} (PR #109810)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-openmp

Author: Sergio Afonso (skatrak)


Changes

This patch updates the `omp.target_data` operation to use the same formatting 
as `map` clauses on `omp.target` for `use_device_addr` and `use_device_ptr`. 
This is done so the mapping that is being enforced between op arguments and 
associated entry block arguments is explicit.

The way it is achieved is by marking these clauses as entry block 
argument-defining and adjusting printer/parsers accordingly.

As a result of this change, block arguments for `use_device_addr` come before 
those for `use_device_ptr`, which is the opposite of the previous undocumented 
situation. Some unit tests are updated based on this change, in addition to 
those updated because of the format change.

---

Patch is 32.20 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/109810.diff


11 Files Affected:

- (modified) flang/test/Fir/convert-to-llvm-openmp-and-fir.fir (+3-2) 
- (modified) flang/test/Lower/OpenMP/target.f90 (+2-4) 
- (modified) flang/test/Lower/OpenMP/use-device-ptr-to-use-device-addr.f90 
(+4-8) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td (+24-4) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (+6) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td (+27-1) 
- (modified) mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp (+43) 
- (modified) 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+52-28) 
- (modified) mlir/test/Dialect/OpenMP/ops.mlir (+4-2) 
- (modified) mlir/test/Target/LLVMIR/omptarget-llvm.mlir (+7-12) 
- (modified) mlir/test/Target/LLVMIR/openmp-target-use-device-nested.mlir 
(+1-2) 


``diff
diff --git a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir 
b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
index 4d226eaa754c12..61f18008633d50 100644
--- a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
+++ b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
@@ -429,13 +429,14 @@ func.func @_QPopenmp_target_data_region() {
 
 func.func @_QPomp_target_data_empty() {
   %0 = fir.alloca !fir.array<1024xi32> {bindc_name = "a", uniq_name = 
"_QFomp_target_data_emptyEa"}
-  omp.target_data use_device_addr(%0 : !fir.ref>) {
+  omp.target_data use_device_addr(%0 -> %arg0 : 
!fir.ref>) {
+omp.terminator
   }
   return
 }
 
 // CHECK-LABEL:   llvm.func @_QPomp_target_data_empty
-// CHECK: omp.target_data   use_device_addr(%1 : !llvm.ptr) {
+// CHECK: omp.target_data   use_device_addr(%1 -> %{{.*}} : !llvm.ptr) {
 // CHECK: }
 
 // -
diff --git a/flang/test/Lower/OpenMP/target.f90 
b/flang/test/Lower/OpenMP/target.f90
index dedce581436490..ab33b6b3808315 100644
--- a/flang/test/Lower/OpenMP/target.f90
+++ b/flang/test/Lower/OpenMP/target.f90
@@ -506,9 +506,8 @@ subroutine omp_target_device_ptr
type(c_ptr) :: a
integer, target :: b
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}})   map_clauses(tofrom) 
capture(ByRef) -> {{.*}} {name = "a"}
-   !CHECK: omp.target_data map_entries(%[[MAP]]{{.*}}) use_device_ptr({{.*}})
+   !CHECK: omp.target_data map_entries(%[[MAP]]{{.*}}) use_device_ptr({{.*}} 
-> %[[VAL_1:.*]] : 
!fir.ref>)
!$omp target data map(tofrom: a) use_device_ptr(a)
-   !CHECK: ^bb0(%[[VAL_1:.*]]: 
!fir.ref>):
!CHECK: {{.*}} = fir.coordinate_of %[[VAL_1:.*]], {{.*}} : 
(!fir.ref>, 
!fir.field) -> !fir.ref
   a = c_loc(b)
!CHECK: omp.terminator
@@ -529,9 +528,8 @@ subroutine omp_target_device_addr
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}} : 
!fir.ref>>, !fir.box>) map_clauses(tofrom) 
capture(ByRef) members(%[[MAP_MEMBERS]] : [0] : !fir.llvm_ptr>) 
-> !fir.ref>> {name = "a"}
!CHECK: %[[DEV_ADDR_MEMBERS:.*]] = omp.map.info var_ptr({{.*}} : 
!fir.ref>>, i32) var_ptr_ptr({{.*}} : 
!fir.llvm_ptr>) map_clauses(tofrom) capture(ByRef) -> 
!fir.llvm_ptr> {name = ""}
!CHECK: %[[DEV_ADDR:.*]] = omp.map.info var_ptr({{.*}} : 
!fir.ref>>, !fir.box>) map_clauses(tofrom) 
capture(ByRef) members(%[[DEV_ADDR_MEMBERS]] : [0] : 
!fir.llvm_ptr>) -> !fir.ref>> {name = "a"}
-   !CHECK: omp.target_data map_entries(%[[MAP_MEMBERS]], %[[MAP]] : {{.*}}) 
use_device_addr(%[[DEV_ADDR_MEMBERS]], %[[DEV_ADDR]] : {{.*}}) {
+   !CHECK: omp.target_data map_entries(%[[MAP_MEMBERS]], %[[MAP]] : {{.*}}) 
use_device_addr(%[[DEV_ADDR_MEMBERS]] -> %[[ARG_0:.*]], %[[DEV_ADDR]] -> 
%[[ARG_1:.*]] : !fir.llvm_ptr>, 
!fir.ref>>) {
!$omp target data map(tofrom: a) use_device_addr(a)
-   !CHECK: ^bb0(%[[ARG_0:.*]]: !fir.llvm_ptr>, %[[ARG_1:.*]]: 
!fir.ref>>):
!CHECK: %[[VAL_1_DECL:.*]]:2 = hlfir.declare %[[ARG_1]] {fortran_attrs = 
#fir.var_attrs, uniq_name = "_QFomp_target_device_addrEa"} : 
(!fir.ref>>) -> (!fir.ref>>, 
!fir.ref>>)
!CHECK: %[[C10:.*]] = arith.constant 10 : i32
!CHECK: %[[A_BOX:.*]] = fir.load %[[VAL_1_DECL]]#0 : 
!fir.ref>>
diff --git a/flang/test/Lower/OpenMP/use-device-ptr-to-use-device-addr.f90 
b/flang/test/Lower/OpenMP/use-device-ptr-to-use-

[llvm-branch-commits] [mlir] [MLIR][OpenMP] Document entry block argument-defining clauses (NFC) (PR #109811)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Sergio Afonso (skatrak)


Changes

This patch adds general information on the proposed approach to unify the 
handling and representation of clauses that define entry block arguments 
attached to operations that accept them.

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


1 Files Affected:

- (modified) mlir/docs/Dialects/OpenMPDialect/_index.md (+69-1) 


``diff
diff --git a/mlir/docs/Dialects/OpenMPDialect/_index.md 
b/mlir/docs/Dialects/OpenMPDialect/_index.md
index 88437b8cf828cc..3c30b29d09356b 100644
--- a/mlir/docs/Dialects/OpenMPDialect/_index.md
+++ b/mlir/docs/Dialects/OpenMPDialect/_index.md
@@ -285,7 +285,75 @@ argument's type:
   specific `mlir::Attribute` subclass) will be used instead.
   - Other attribute types will be represented with their `storageType`.
 - It will create `Operands` structure for each operation, which is an
-empty structure subclassing all operand structures defined for the 
corresponding `OpenMP_Op`'s clauses.
+empty structure subclassing all operand structures defined for the 
corresponding
+`OpenMP_Op`'s clauses.
+
+### Entry Block Argument-Defining Clauses
+
+Certain OpenMP clauses introduce in their MLIR representation mappings between
+outside values and entry block arguments for the region of the MLIR operation
+they are applied to. This enables, for example, the introduction of private
+copies of the same underlying variable. Currently, clauses with this property
+can be classified in three main categories:
+  - Map-like clauses: `map`, `use_device_addr` and `use_device_ptr`.
+  - Reduction-like clauses: `in_reduction`, `reduction` and `task_reduction`.
+  - Privatization clause: `private`.
+
+All three kinds of entry block argument-defining clauses use a similar custom
+assembly format representation, only differing based on the different pieces of
+information attached to each kind. Below, one example of each is shown:
+
+```mlir
+omp.target map_entries(%x -> %x.m, %y -> %y.m : !llvm.ptr, !llvm.ptr) {
+  // Use %x.m, %y.m in place of %x and %y...
+}
+
+omp.wsloop reduction(@add.i32 %x -> %x.r, byref @add.f32 %y -> %y.r : 
!llvm.ptr, !llvm.ptr) {
+  // Use %x.r, %y.r in place of %x and %y...
+}
+
+omp.parallel private(@x.privatizer %x -> %x.p, @y.privatizer %y -> %y.p : 
!llvm.ptr, !llvm.ptr) {
+  // Use %x.p, %y.p in place of %x and %y...
+}
+```
+
+As a consequence of parsing and printing the operation's first region entry
+block argument names together with the custom assembly format of these clauses,
+entry block arguments (i.e. the `^bb0(...):` line) must not be explicitly
+defined for these operations. Additionally, it is not possible to implement 
this
+feature while allowing each clause to be independently parsed and printed,
+because they need to be printed/parsed together with the corresponding
+operation's first region. They must have a well-defined ordering in which
+multiple of these clauses are specified for a given operation, as well.
+
+The parsing/printing of these clauses together with the region provides the
+ability to define entry block arguments directly after the `->`. Forcing a
+specific ordering between these clauses makes the block argument ordering
+well-defined, which is the property used to easily match each clause with the
+entry block arguments defined by it.
+
+Custom printers and parsers for operation regions based on the entry block
+argument-defining clauses they take are implemented based on the
+`{parse,print}BlockArgRegion` functions, which take care of the sorting and
+formatting of each kind of clause, minimizing code duplication resulting from
+this approach. One example of the custom assembly format of an operation taking
+the `private` and `reduction` clauses is the following:
+
+```tablegen
+let assemblyFormat = clausesAssemblyFormat # [{
+  custom($region, $private_vars, type($private_vars),
+  $private_syms, $reduction_vars, type($reduction_vars), $reduction_byref,
+  $reduction_syms) attr-dict
+}];
+```
+
+The `BlockArgOpenMPOpInterface` has been introduced to simplify the addition 
and
+handling of these kinds of clauses. It holds `numBlockArgs()`
+functions that by default return 0, to be overriden by each clause through the
+`extraClassDeclaration` property. Based on these functions and the expected
+alphabetical sorting between entry block argument-defining clauses, it
+implements `getBlockArgs()` functions that are the intended method
+of accessing clause-defined block arguments.
 
 ## Loop-Associated Directives
 

``




https://github.com/llvm/llvm-project/pull/109811
___
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: [C++20] [Modules] Treat in class defined member functions in language linkage as implicitly inline (PR #109077)

2024-09-24 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

Seems that way - I will revert this.

https://github.com/llvm/llvm-project/pull/109077
___
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: [C++20] [Modules] Treat in class defined member functions in language linkage as implicitly inline (PR #109077)

2024-09-24 Thread Chuanqi Xu via llvm-branch-commits

ChuanqiXu9 wrote:

> If you can put up another patch I'll just wait with reverting.

trying : )

https://github.com/llvm/llvm-project/pull/109077
___
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: [C++20] [Modules] Treat in class defined member functions in language linkage as implicitly inline (PR #109077)

2024-09-24 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

If you can put up another patch I'll just wait with reverting. 

https://github.com/llvm/llvm-project/pull/109077
___
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: [C++20] [Modules] Treat in class defined member functions in language linkage as implicitly inline (PR #109077)

2024-09-24 Thread Sylvestre Ledru via llvm-branch-commits

sylvestre wrote:

Seems it doesn't build:
https://github.com/llvm/llvm-project/pull/109077/files

https://github.com/llvm/llvm-project/pull/109077
___
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: [loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on loongarch (#107791) (PR #109093)

2024-09-24 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

fp16 support is generally quite broken outside of a few targets -- from a Rust 
perspective, we'd prefer full support in LLVM 20 rather than backporting things 
piecemeal to LLVM 19. Especially if it's going to change the ABI, which I think 
means we'd need LLVM-patch-version-specific handling in compiler-builtins.

https://github.com/llvm/llvm-project/pull/109093
___
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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits

https://github.com/kuhar edited https://github.com/llvm/llvm-project/pull/108601
___
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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -147,6 +148,22 @@ class SmallSet {
   using const_iterator = SmallSetIterator;
 
   SmallSet() = default;
+  SmallSet(const SmallSet &) = default;
+  SmallSet(SmallSet &&) = default;
+
+  template  SmallSet(IterT Begin, IterT End) {
+insert(Begin, End);
+  }
+
+  template 
+  explicit SmallSet(const iterator_range &R) {
+insert(R.begin(), R.end());
+  }
+
+  SmallSet(std::initializer_list L) { this->insert(L.begin(), L.end()); }

kuhar wrote:

One remaining `this->`

https://github.com/llvm/llvm-project/pull/108601
___
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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/108601
___
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] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer edited 
https://github.com/llvm/llvm-project/pull/109620
___
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] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Florian Mayer via llvm-branch-commits


@@ -1935,12 +1940,12 @@ void HWAddressSanitizer::ShadowMapping::init(Triple 
&TargetTriple,
 SetFixed(0);
   } else if (ClMappingOffset.getNumOccurrences() > 0) {
 SetFixed(ClMappingOffset);
-WithFrameRecord = false;
   } else if (ClEnableKhwasan || InstrumentWithCalls) {
 SetFixed(0);
 WithFrameRecord = false;

fmayer wrote:

Please add

"Do not disable frame records for fixed offset"

to the commit message, because that's what this change also does, correct?

https://github.com/llvm/llvm-project/pull/109620
___
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] [hwasan] Consider order of mapping copts (PR #109621)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/109621


___
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] [hwasan] Consider order of mapping copts (PR #109621)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/109621


___
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] Extract EmitCheckedArgForAssume (PR #109880)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka converted_to_draft 
https://github.com/llvm/llvm-project/pull/109880
___
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] cf31625 - Revert "[clang][CodeGen] Zero init unspecified fields in initializers in C (#…"

2024-09-24 Thread via llvm-branch-commits

Author: Eli Friedman
Date: 2024-09-24T20:21:42-07:00
New Revision: cf31625ebefd05e8ca07f6f6b664d9a5bee9cd0f

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

LOG: Revert "[clang][CodeGen] Zero init unspecified fields in initializers in C 
(#…"

This reverts commit 7a086e1b2dc05f54afae3591614feede727601fa.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
clang/test/CodeGen/2008-08-07-AlignPadding1.c
clang/test/CodeGen/2009-06-14-anonymous-union-init.c
clang/test/CodeGen/64bit-swiftcall.c
clang/test/CodeGen/arm-swiftcall.c
clang/test/CodeGen/const-init.c
clang/test/CodeGen/decl.c
clang/test/CodeGen/designated-initializers.c
clang/test/CodeGen/ext-int.c
clang/test/CodeGen/flexible-array-init.c
clang/test/CodeGen/global-init.c
clang/test/CodeGen/init.c
clang/test/CodeGen/mingw-long-double.c
clang/test/CodeGen/mms-bitfields.c
clang/test/CodeGen/union-init2.c
clang/test/CodeGen/windows-swiftcall.c
clang/test/CodeGenObjC/designated-initializers.m

Removed: 
clang/test/CodeGen/linux-kernel-struct-union-initializer.c
clang/test/CodeGen/linux-kernel-struct-union-initializer2.c



diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f4be97047422fa..0c6b9b1b8f9ce4 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -5860,26 +5860,3 @@ specify the starting offset to begin embedding from. The 
resources is treated
 as being empty if the specified offset is larger than the number of bytes in
 the resource. The offset will be applied *before* any ``limit`` parameters are
 applied.
-
-Union and aggregate initialization in C
-===
-
-In C23 (N2900), when an object is initialized from initializer ``= {}``, all
-elements of arrays, all members of structs, and the first members of unions are
-empty-initialized recursively. In addition, all padding bits are initialized to
-zero.
-
-Clang guarantees the following behaviors:
-
-* ``1:`` Clang supports initializer ``= {}`` mentioned above in all C
-  standards.
-
-* ``2:`` When unions are initialized from initializer ``= {}``, bytes outside
-  of the first members of unions are also initialized to zero.
-
-* ``3:`` When unions, structures and arrays are initialized from initializer
-  ``= { initializer-list }``, all members not explicitly initialized in
-  the initializer list are empty-initialized recursively. In addition, all
-  padding bits are initialized to zero.
-
-Currently, the above extension only applies to C source code, not C++.

diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 43f3bcc95fe767..bbfc6672ecc25a 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1698,17 +1698,6 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
   // Prepare a 'this' for CXXDefaultInitExprs.
   CodeGenFunction::FieldConstructionScope FCS(CGF, Dest.getAddress());
 
-  const bool ZeroInitPadding =
-  CGF.CGM.shouldZeroInitPadding() && !Dest.isZeroed();
-  const Address BaseLoc = Dest.getAddress().withElementType(CGF.Int8Ty);
-  auto DoZeroInitPadding = [&](CharUnits Offset, CharUnits Size) {
-if (Size.isPositive()) {
-  Address Loc = CGF.Builder.CreateConstGEP(BaseLoc, Offset.getQuantity());
-  llvm::Constant *SizeVal = CGF.Builder.getInt64(Size.getQuantity());
-  CGF.Builder.CreateMemSet(Loc, CGF.Builder.getInt8(0), SizeVal, false);
-}
-  };
-
   if (record->isUnion()) {
 // Only initialize one field of a union. The field itself is
 // specified by the initializer list.
@@ -1733,37 +1722,17 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
 if (NumInitElements) {
   // Store the initializer into the field
   EmitInitializationToLValue(InitExprs[0], FieldLoc);
-  if (ZeroInitPadding) {
-CharUnits TotalSize =
-Dest.getPreferredSize(CGF.getContext(), DestLV.getType());
-CharUnits FieldSize =
-CGF.getContext().getTypeSizeInChars(FieldLoc.getType());
-DoZeroInitPadding(FieldSize, TotalSize - FieldSize);
-  }
 } else {
   // Default-initialize to null.
-  if (ZeroInitPadding)
-EmitNullInitializationToLValue(DestLV);
-  else
-EmitNullInitializationToLValue(FieldLoc);
+  EmitNullInitializationToLValue(FieldLoc);
 }
+
 return;
   }
 
   // Here we iterate over the fields; this makes it simpler to both
   // default-initialize fields and skip over unnamed fields.
-  const ASTRecord

[llvm-branch-commits] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/109620
___
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-scan-deps] Don't inspect Args[0] as an option (#109050) (PR #109865)

2024-09-24 Thread Martin Storsjö via llvm-branch-commits

mstorsjo wrote:

Admittedly, these changes aren't regression fixes, but fixes using 
clang-scan-deps without requiring a wrapper script in certain distribution 
setups.

The changes are somewhat small and localized, and have been cooking in git main 
for a couple weeks now soon, without any complaints or feedback.

https://github.com/llvm/llvm-project/pull/109865
___
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] Extract EmitCheckedArgForAssume (PR #109880)

2024-09-24 Thread via llvm-branch-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 4cef51a82570188afadf4b0b3836c67a4bf513e1 
6a7134c2619bca5bcf47b3674efe169e67b7c1b0 --extensions cpp,h -- 
clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGStmt.cpp 
clang/lib/CodeGen/CodeGenFunction.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index bf68841c4b..e74b58b318 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1996,8 +1996,8 @@ struct CallObjCArcUse final : EHScopeStack::Cleanup {
 
 Value *CodeGenFunction::EmitCheckedArgForBuiltin(const Expr *E,
  BuiltinCheckKind Kind) {
-  assert((Kind == BCK_CLZPassedZero || Kind == BCK_CTZPassedZero)
-  && "Unsupported builtin check kind");
+  assert((Kind == BCK_CLZPassedZero || Kind == BCK_CTZPassedZero) &&
+ "Unsupported builtin check kind");
 
   Value *ArgValue = EmitScalarExpr(E);
   if (!SanOpts.has(SanitizerKind::Builtin))

``




https://github.com/llvm/llvm-project/pull/109880
___
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] Extract EmitCheckedArgForAssume (PR #109880)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/109880

None


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


[llvm-branch-commits] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits

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


[llvm-branch-commits] [libcxx] [libc++] Adjust the version of __cpp_lib_ranges in C++20 mode (PR #109324)

2024-09-24 Thread A. Jiang via llvm-branch-commits

frederick-vs-ja wrote:

I guess 6f6422f4a2b8647a59936c131e50a79906d89510 and 
cdd608b8f0ce090b3568238387df368751bdbb5d should also be cherry-picked. @tru 
@ldionne 

https://github.com/llvm/llvm-project/pull/109324
___
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] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Florian Mayer via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/109620
___
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] [C++20] [Modules] Add Decl::isFromGlobalModule (PR #109762)

2024-09-24 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru milestoned 
https://github.com/llvm/llvm-project/pull/109762
___
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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-24 Thread Victor Campos via llvm-branch-commits

https://github.com/vhscampos updated 
https://github.com/llvm/llvm-project/pull/108590

>From 964abdd8e2c5d9089b831ad242452cb83605db3a Mon Sep 17 00:00:00 2001
From: Victor Campos 
Date: Fri, 9 Aug 2024 13:57:42 +0100
Subject: [PATCH 1/3] [ADT] Use perfect forwarding in SmallSet::insert()

Previously this method took arguments by const-ref. This patch changes
the implementation to take perfectly forwarded arguments in the form of
a universal reference. Now, the insertion method will take advantage of
arguments passed as rvalue, potentially leading to performance
improvements.
---
 llvm/include/llvm/ADT/SmallSet.h | 47 +++-
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index 8d7511bf0bc8d9..49e641a07eda3f 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -161,26 +161,10 @@ class SmallSet {
   /// Returns a pair. The first value of it is an iterator to the inserted
   /// element or the existing element in the set. The second value is true
   /// if the element is inserted (it was not in the set before).
-  std::pair insert(const T &V) {
-if (!isSmall()) {
-  auto [I, Inserted] = Set.insert(V);
-  return std::make_pair(const_iterator(I), Inserted);
-}
+  std::pair insert(const T &V) { return insertImpl(V); }
 
-auto I = std::find(Vector.begin(), Vector.end(), V);
-if (I != Vector.end())// Don't reinsert if it already exists.
-  return std::make_pair(const_iterator(I), false);
-if (Vector.size() < N) {
-  Vector.push_back(V);
-  return std::make_pair(const_iterator(std::prev(Vector.end())), true);
-}
-
-// Otherwise, grow from vector to set.
-while (!Vector.empty()) {
-  Set.insert(Vector.back());
-  Vector.pop_back();
-}
-return std::make_pair(const_iterator(Set.insert(V).first), true);
+  std::pair insert(T &&V) {
+return insertImpl(std::move(V));
   }
 
   template 
@@ -226,6 +210,31 @@ class SmallSet {
 
 private:
   bool isSmall() const { return Set.empty(); }
+
+  template 
+  std::pair insertImpl(ArgType &&V) {
+static_assert(std::is_convertible_v,
+  "ArgType must be convertible to T!");
+if (!isSmall()) {
+  auto [I, Inserted] = Set.insert(std::forward(V));
+  return std::make_pair(const_iterator(I), Inserted);
+}
+
+auto I = std::find(Vector.begin(), Vector.end(), V);
+if (I != Vector.end()) // Don't reinsert if it already exists.
+  return std::make_pair(const_iterator(I), false);
+if (Vector.size() < N) {
+  Vector.push_back(std::forward(V));
+  return std::make_pair(const_iterator(std::prev(Vector.end())), true);
+}
+
+// Otherwise, grow from vector to set.
+Set.insert(std::make_move_iterator(Vector.begin()),
+   std::make_move_iterator(Vector.end()));
+Vector.clear();
+return std::make_pair(
+const_iterator(Set.insert(std::forward(V)).first), true);
+  }
 };
 
 /// If this set is of pointer values, transparently switch over to using

>From 7970dad69c790748f0ffcd5c45d5961c178bef8b Mon Sep 17 00:00:00 2001
From: Victor Campos 
Date: Tue, 17 Sep 2024 13:11:00 +0100
Subject: [PATCH 2/3] Add test for SmallSet::insert perfect forwarding

---
 llvm/unittests/ADT/SmallSetTest.cpp | 34 +
 1 file changed, 34 insertions(+)

diff --git a/llvm/unittests/ADT/SmallSetTest.cpp 
b/llvm/unittests/ADT/SmallSetTest.cpp
index b50b368ae66361..0fb20b19df9254 100644
--- a/llvm/unittests/ADT/SmallSetTest.cpp
+++ b/llvm/unittests/ADT/SmallSetTest.cpp
@@ -41,6 +41,40 @@ TEST(SmallSetTest, Insert) {
   EXPECT_EQ(0u, s1.count(4));
 }
 
+TEST(SmallSetTest, InsertPerfectFwd) {
+  struct Value {
+int Key;
+bool Moved;
+
+Value(int Key) : Key(Key), Moved(false) {}
+Value(const Value &) = default;
+Value(Value &&Other) : Key(Other.Key), Moved(false) { Other.Moved = true; }
+bool operator==(const Value &Other) const { return Key == Other.Key; }
+bool operator<(const Value &Other) const { return Key < Other.Key; }
+  };
+
+  {
+SmallSet S;
+Value V1(1), V2(2);
+
+S.insert(V1);
+EXPECT_EQ(V1.Moved, false);
+
+S.insert(std::move(V2));
+EXPECT_EQ(V2.Moved, true);
+  }
+  {
+SmallSet S;
+Value V1(1), V2(2);
+
+S.insert(V1);
+EXPECT_EQ(V1.Moved, false);
+
+S.insert(std::move(V2));
+EXPECT_EQ(V2.Moved, true);
+  }
+}
+
 TEST(SmallSetTest, Grow) {
   SmallSet s1;
 

>From 8a9e20edaa526a88f4e16eea03f0aca511805965 Mon Sep 17 00:00:00 2001
From: Victor Campos 
Date: Tue, 17 Sep 2024 13:16:24 +0100
Subject: [PATCH 3/3] Style changes

---
 llvm/include/llvm/ADT/SmallSet.h | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index 49e641a07eda3f..56259ea7cf9d0f 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/ll

[llvm-branch-commits] [llvm] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Victor Campos via llvm-branch-commits

https://github.com/vhscampos updated 
https://github.com/llvm/llvm-project/pull/108601

>From 12b657a4761351d52fccb93ce52e64c3c1b1e91f Mon Sep 17 00:00:00 2001
From: Victor Campos 
Date: Fri, 9 Aug 2024 14:00:32 +0100
Subject: [PATCH] [ADT] Add more useful methods to SmallSet API

This patch adds useful methods to the SmallSet API:

 - Constructor that takes pair of iterators.
 - Constructor that takes a range.
 - Constructor that takes an initializer list.
 - Copy constructor.
 - Move constructor.
 - Copy assignment operator.
 - Move assignment operator.
---
 llvm/include/llvm/ADT/SmallSet.h| 17 
 llvm/unittests/ADT/SmallSetTest.cpp | 60 +
 2 files changed, 77 insertions(+)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index 56259ea7cf9d0f..431fdee56c20e0 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/iterator.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -147,6 +148,22 @@ class SmallSet {
   using const_iterator = SmallSetIterator;
 
   SmallSet() = default;
+  SmallSet(const SmallSet &) = default;
+  SmallSet(SmallSet &&) = default;
+
+  template  SmallSet(IterT Begin, IterT End) {
+this->insert(Begin, End);
+  }
+
+  template 
+  explicit SmallSet(const iterator_range &R) {
+this->insert(R.begin(), R.end());
+  }
+
+  SmallSet(std::initializer_list L) { this->insert(L.begin(), L.end()); }
+
+  SmallSet &operator=(const SmallSet &) = default;
+  SmallSet &operator=(SmallSet &&) = default;
 
   [[nodiscard]] bool empty() const { return Vector.empty() && Set.empty(); }
 
diff --git a/llvm/unittests/ADT/SmallSetTest.cpp 
b/llvm/unittests/ADT/SmallSetTest.cpp
index 0fb20b19df9254..8219bf6f4b4c55 100644
--- a/llvm/unittests/ADT/SmallSetTest.cpp
+++ b/llvm/unittests/ADT/SmallSetTest.cpp
@@ -17,6 +17,66 @@
 
 using namespace llvm;
 
+TEST(SmallSetTest, ConstructorIteratorPair) {
+  auto L = {1, 2, 3, 4, 5};
+  SmallSet S(std::begin(L), std::end(L));
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));
+}
+
+TEST(SmallSet, ConstructorRange) {
+  auto L = {1, 2, 3, 4, 5};
+
+  SmallSet S(llvm::make_range(std::begin(L), std::end(L)));
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));
+}
+
+TEST(SmallSet, ConstructorInitializerList) {
+  auto L = {1, 2, 3, 4, 5};
+  SmallSet S = {1, 2, 3, 4, 5};
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));
+}
+
+TEST(SmallSet, CopyConstructor) {
+  SmallSet S = {1, 2, 3};
+  SmallSet T = S;
+
+  EXPECT_EQ(S, T);
+}
+
+TEST(SmallSet, MoveConstructor) {
+  auto L = {1, 2, 3};
+  SmallSet S = L;
+  SmallSet T = std::move(S);
+
+  EXPECT_TRUE(T.size() == L.size());
+  for (int Value : L) {
+EXPECT_TRUE(T.contains(Value));
+  }
+}
+
+TEST(SmallSet, CopyAssignment) {
+  SmallSet S = {1, 2, 3};
+  SmallSet T;
+  T = S;
+
+  EXPECT_EQ(S, T);
+}
+
+TEST(SmallSet, MoveAssignment) {
+  auto L = {1, 2, 3};
+  SmallSet S = L;
+  SmallSet T;
+  T = std::move(S);
+
+  EXPECT_TRUE(T.size() == L.size());
+  for (int Value : L) {
+EXPECT_TRUE(T.contains(Value));
+  }
+}
+
 TEST(SmallSetTest, Insert) {
 
   SmallSet s1;

___
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: [X86][APX] Fix wrong encoding of promoted KMOV instructions due to missing NoCD8 (#109759) (PR #109767)

2024-09-24 Thread Shengchen Kan via llvm-branch-commits

KanRobert wrote:

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

LGTM

https://github.com/llvm/llvm-project/pull/109767
___
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: [X86][APX] Fix wrong encoding of promoted KMOV instructions due to missing NoCD8 (#109759) (PR #109767)

2024-09-24 Thread Shengchen Kan via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/109767
___
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: [X86][APX] Fix wrong encoding of promoted KMOV instructions due to missing NoCD8 (#109759) (PR #109767)

2024-09-24 Thread Phoebe Wang via llvm-branch-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/109767
___
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] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-09-24 Thread Chuanqi Xu via llvm-branch-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/83237

>From f2e53e44eebab4720a1dbade24fcb14d698fb03f Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Wed, 28 Feb 2024 11:41:53 +0800
Subject: [PATCH 1/7] [Serialization] Code cleanups and polish 83233

---
 clang/include/clang/AST/DeclTemplate.h|  39 +-
 clang/include/clang/AST/ExternalASTSource.h   |   8 +-
 .../clang/Sema/MultiplexExternalSemaSource.h  |   4 +-
 .../include/clang/Serialization/ASTBitCodes.h |   2 +-
 clang/include/clang/Serialization/ASTReader.h |   4 +-
 clang/lib/AST/DeclTemplate.cpp|  85 ++--
 clang/lib/AST/ExternalASTSource.cpp   |  10 +-
 clang/lib/AST/ODRHash.cpp |  10 -
 .../lib/Sema/MultiplexExternalSemaSource.cpp  |  13 +-
 clang/lib/Serialization/ASTCommon.h   |   1 -
 clang/lib/Serialization/ASTReader.cpp |  42 +-
 clang/lib/Serialization/ASTReaderDecl.cpp |  76 +---
 clang/lib/Serialization/ASTReaderInternals.h  |   1 -
 clang/lib/Serialization/ASTWriter.cpp |  27 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  52 +--
 clang/lib/Serialization/CMakeLists.txt|   1 +
 .../Serialization/TemplateArgumentHasher.cpp  | 423 ++
 .../Serialization/TemplateArgumentHasher.h|  34 ++
 clang/test/Modules/cxx-templates.cpp  |   8 +-
 .../Modules/recursive-instantiations.cppm |  40 ++
 .../test/OpenMP/target_parallel_ast_print.cpp |   4 -
 clang/test/OpenMP/target_teams_ast_print.cpp  |   4 -
 clang/test/OpenMP/task_ast_print.cpp  |   4 -
 clang/test/OpenMP/teams_ast_print.cpp |   4 -
 24 files changed, 610 insertions(+), 286 deletions(-)
 create mode 100644 clang/lib/Serialization/TemplateArgumentHasher.cpp
 create mode 100644 clang/lib/Serialization/TemplateArgumentHasher.h
 create mode 100644 clang/test/Modules/recursive-instantiations.cppm

diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 44f840d297465d..7406252363d223 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -256,9 +256,6 @@ class TemplateArgumentList final
   TemplateArgumentList(const TemplateArgumentList &) = delete;
   TemplateArgumentList &operator=(const TemplateArgumentList &) = delete;
 
-  /// Create hash for the given arguments.
-  static unsigned ComputeODRHash(ArrayRef Args);
-
   /// Create a new template argument list that copies the given set of
   /// template arguments.
   static TemplateArgumentList *CreateCopy(ASTContext &Context,
@@ -732,25 +729,6 @@ class RedeclarableTemplateDecl : public TemplateDecl,
   }
 
   void anchor() override;
-  struct LazySpecializationInfo {
-GlobalDeclID DeclID = GlobalDeclID();
-unsigned ODRHash = ~0U;
-bool IsPartial = false;
-LazySpecializationInfo(GlobalDeclID ID, unsigned Hash = ~0U,
-   bool Partial = false)
-: DeclID(ID), ODRHash(Hash), IsPartial(Partial) {}
-LazySpecializationInfo() {}
-bool operator<(const LazySpecializationInfo &Other) const {
-  return DeclID < Other.DeclID;
-}
-bool operator==(const LazySpecializationInfo &Other) const {
-  assert((DeclID != Other.DeclID || ODRHash == Other.ODRHash) &&
- "Hashes differ!");
-  assert((DeclID != Other.DeclID || IsPartial == Other.IsPartial) &&
- "Both must be the same kinds!");
-  return DeclID == Other.DeclID;
-}
-  };
 
 protected:
   template  struct SpecEntryTraits {
@@ -794,16 +772,20 @@ class RedeclarableTemplateDecl : public TemplateDecl,
 
   void loadLazySpecializationsImpl(bool OnlyPartial = false) const;
 
-  void loadLazySpecializationsImpl(llvm::ArrayRef Args,
+  bool loadLazySpecializationsImpl(llvm::ArrayRef Args,
TemplateParameterList *TPL = nullptr) const;
 
-  Decl *loadLazySpecializationImpl(LazySpecializationInfo &LazySpecInfo) const;
-
   template 
   typename SpecEntryTraits::DeclType*
   findSpecializationImpl(llvm::FoldingSetVector &Specs,
  void *&InsertPos, ProfileArguments &&...ProfileArgs);
 
+  template 
+  typename SpecEntryTraits::DeclType *
+  findSpecializationLocally(llvm::FoldingSetVector &Specs,
+void *&InsertPos,
+ProfileArguments &&...ProfileArgs);
+
   template 
   void addSpecializationImpl(llvm::FoldingSetVector &Specs,
  EntryType *Entry, void *InsertPos);
@@ -819,13 +801,6 @@ class RedeclarableTemplateDecl : public TemplateDecl,
 llvm::PointerIntPair
   InstantiatedFromMember;
 
-/// If non-null, points to an array of specializations (including
-/// partial specializations) known only by their external declaration IDs.
-///
-/// The first value in the array is the number of specializations/partial
-/// specializations that follow.
-LazySpecializationInfo *LazySpecializations = n

[llvm-branch-commits] [llvm] [Inliner][Backport] Fix bug where attributes are propagated incorrectly (#109347) (PR #109502)

2024-09-24 Thread via llvm-branch-commits

github-actions[bot] wrote:

@goldsteinn (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/109502
___
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] [X86][APX] Fix wrong encoding of promoted KMOV instructions due to missing NoCD8 (#109579) (PR #109635)

2024-09-24 Thread Phoebe Wang via llvm-branch-commits

phoebewang wrote:

Sorry, there was a mistake with the patch. I'll close it and create another one.

https://github.com/llvm/llvm-project/pull/109635
___
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] [X86][APX] Fix wrong encoding of promoted KMOV instructions due to missing NoCD8 (#109579) (PR #109635)

2024-09-24 Thread Phoebe Wang via llvm-branch-commits

https://github.com/phoebewang closed 
https://github.com/llvm/llvm-project/pull/109635
___
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: workflows/release-binaries: Enable flang builds on Windows (#101344) (PR #106480)

2024-09-24 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/106480
___
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] [C++20] [Modules] Add Decl::isFromGlobalModule (PR #109762)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Chuanqi Xu (ChuanqiXu9)


Changes

Close https://github.com/llvm/llvm-project/issues/109758

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


2 Files Affected:

- (modified) clang/include/clang/AST/DeclBase.h (+3) 
- (modified) clang/lib/AST/DeclBase.cpp (+4) 


``diff
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 2a4bd0f9c2fda3..04dbd1db6cba81 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -680,6 +680,9 @@ class alignas(8) Decl {
   /// Whether this declaration comes from explicit global module.
   bool isFromExplicitGlobalModule() const;
 
+  /// Whether this declaration comes from global module.
+  bool isFromGlobalModule() const;
+
   /// Whether this declaration comes from a named module.
   bool isInNamedModule() const;
 
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index b59f118380ca4b..c4e948a38e2641 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1161,6 +1161,10 @@ bool Decl::isFromExplicitGlobalModule() const {
   return getOwningModule() && getOwningModule()->isExplicitGlobalModule();
 }
 
+bool Decl::isFromGlobalModule() const {
+  return getOwningModule() && getOwningModule()->isGlobalModule();
+}
+
 bool Decl::isInNamedModule() const {
   return getOwningModule() && getOwningModule()->isNamedModule();
 }

``




https://github.com/llvm/llvm-project/pull/109762
___
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] [C++20] [Modules] Add Decl::isFromGlobalModule (PR #109762)

2024-09-24 Thread Chuanqi Xu via llvm-branch-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/109762

>From 4c51d827e58aaa8c5b3d75b3b61a43627ab53491 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Tue, 24 Sep 2024 15:37:02 +0800
Subject: [PATCH] [C++20] [Modules] Add Decl::isFromGlobalModule

---
 clang/include/clang/AST/DeclBase.h | 3 +++
 clang/lib/AST/DeclBase.cpp | 4 
 2 files changed, 7 insertions(+)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 2a4bd0f9c2fda3..04dbd1db6cba81 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -680,6 +680,9 @@ class alignas(8) Decl {
   /// Whether this declaration comes from explicit global module.
   bool isFromExplicitGlobalModule() const;
 
+  /// Whether this declaration comes from global module.
+  bool isFromGlobalModule() const;
+
   /// Whether this declaration comes from a named module.
   bool isInNamedModule() const;
 
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index b59f118380ca4b..c4e948a38e2641 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1161,6 +1161,10 @@ bool Decl::isFromExplicitGlobalModule() const {
   return getOwningModule() && getOwningModule()->isExplicitGlobalModule();
 }
 
+bool Decl::isFromGlobalModule() const {
+  return getOwningModule() && getOwningModule()->isGlobalModule();
+}
+
 bool Decl::isInNamedModule() const {
   return getOwningModule() && getOwningModule()->isNamedModule();
 }

___
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: [loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on loongarch (#107791) (PR #109093)

2024-09-24 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

This patch is fixing the stated issue in a roundabout way. You do not need to 
change the ABI or half promotion strategy just to support freeze on half values 

https://github.com/llvm/llvm-project/pull/109093
___
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] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-09-24 Thread Chuanqi Xu via llvm-branch-commits

ChuanqiXu9 wrote:

@ilya-biryukov thanks for the high quality reproducer! I've reproduced it and 
fixed it in the newest commit.

The root cause of the failure is the same with the last time: merging 
specializations with the same key. The previous fix is not clear since, I just 
found, the underlying LLVM component OnDiskChainedHashTableGenerator doesn't 
support insert values with the same key multiple times! The values with the 
same key have to be inserted once. So I have to merge the table manually in the 
newest commit. I think this is ready and please test again. Appreciate in ahead.

https://github.com/llvm/llvm-project/pull/83237
___
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: [X86][APX] Do not emit {evex} prefix for memory variant (#109759) (PR #109767)

2024-09-24 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/109767
___
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: [X86][APX] Do not emit {evex} prefix for memory variant (#109759) (PR #109767)

2024-09-24 Thread via llvm-branch-commits

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

Backport 0d334d83a4c7ce16fa1bc0e5e56bbdeaf01c2b2d 
70529b24a30943d46e361d2990268499921e28a2

Requested by: @phoebewang

>From 0ab42b366ccb2650cd292bd8f101f22ff29d9f6e Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 23 Sep 2024 09:41:43 +0800
Subject: [PATCH 1/2] [X86][APX] Fix wrong encoding of promoted KMOV
 instructions due to missing NoCD8 (#109579)

Promoted KMOV* was encoded with CD8 incorrectly, see
https://godbolt.org/z/cax513hG1

(cherry picked from commit 0d334d83a4c7ce16fa1bc0e5e56bbdeaf01c2b2d)
---
 llvm/lib/Target/X86/X86InstrAVX512.td  | 27 +++---
 llvm/test/MC/Disassembler/X86/apx/kmov.txt | 16 +
 llvm/test/MC/X86/apx/kmov-att.s| 14 ++-
 llvm/test/MC/X86/apx/kmov-intel.s  | 12 ++
 4 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td 
b/llvm/lib/Target/X86/X86InstrAVX512.td
index da690aea43f5c0..1bf201f2bb87e4 100644
--- a/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -2617,19 +2617,20 @@ defm VFPCLASS : avx512_fp_fpclass_all<"vfpclass", 0x66, 
0x67, SchedWriteFCmp>, E
 multiclass avx512_mask_mov opc_kk, bits<8> opc_km, bits<8> opc_mk,
   string OpcodeStr, RegisterClass KRC, ValueType vvt,
   X86MemOperand x86memop, string Suffix = ""> {
-  let isMoveReg = 1, hasSideEffects = 0, SchedRW = [WriteMove],
-  explicitOpPrefix = !if(!eq(Suffix, ""), NoExplicitOpPrefix, 
ExplicitEVEX) in
-  def kk#Suffix : I,
-  Sched<[WriteMove]>;
-  def km#Suffix : I,
-  Sched<[WriteLoad]>;
-  def mk#Suffix : I,
-  Sched<[WriteStore]>;
+  let explicitOpPrefix = !if(!eq(Suffix, ""), NoExplicitOpPrefix, 
ExplicitEVEX) in {
+let isMoveReg = 1, hasSideEffects = 0, SchedRW = [WriteMove] in
+def kk#Suffix : I,
+Sched<[WriteMove]>;
+def km#Suffix : I,
+Sched<[WriteLoad]>, NoCD8;
+def mk#Suffix : I,
+Sched<[WriteStore]>, NoCD8;
+  }
 }
 
 multiclass avx512_mask_mov_gpr opc_kr, bits<8> opc_rk,
diff --git a/llvm/test/MC/Disassembler/X86/apx/kmov.txt 
b/llvm/test/MC/Disassembler/X86/apx/kmov.txt
index 5d947ff39f2314..45fedbd0da587b 100644
--- a/llvm/test/MC/Disassembler/X86/apx/kmov.txt
+++ b/llvm/test/MC/Disassembler/X86/apx/kmov.txt
@@ -17,6 +17,22 @@
 # INTEL: {evex} kmovq  k2, k1
 0x62,0xf1,0xfc,0x08,0x90,0xd1
 
+# ATT:   {evex} kmovb   -16(%rax), %k0
+# INTEL: {evex} kmovb   k0, byte ptr [rax - 16]
+0x62,0xf1,0x7d,0x08,0x90,0x40,0xf0
+
+# ATT:   {evex} kmovw   -16(%rax), %k0
+# INTEL: {evex} kmovw   k0, word ptr [rax - 16]
+0x62,0xf1,0x7c,0x08,0x90,0x40,0xf0
+
+# ATT:   {evex} kmovd   -16(%rax), %k0
+# INTEL: {evex} kmovd   k0, dword ptr [rax - 16]
+0x62,0xf1,0xfd,0x08,0x90,0x40,0xf0
+
+# ATT:   {evex} kmovq   -16(%rax), %k0
+# INTEL: {evex} kmovq   k0, qword ptr [rax - 16]
+0x62,0xf1,0xfc,0x08,0x90,0x40,0xf0
+
 # ATT-NOT: {evex}
 # INTEL-NOT: {evex}
 
diff --git a/llvm/test/MC/X86/apx/kmov-att.s b/llvm/test/MC/X86/apx/kmov-att.s
index 949ef65be98d4c..5f59e0a505b235 100644
--- a/llvm/test/MC/X86/apx/kmov-att.s
+++ b/llvm/test/MC/X86/apx/kmov-att.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple x86_64 -show-encoding %s | FileCheck %s
 # RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s 
--check-prefix=ERROR
 
-# ERROR-COUNT-20: error:
+# ERROR-COUNT-24: error:
 # ERROR-NOT: error:
 # CHECK: {evex}kmovb   %k1, %k2
 # CHECK: encoding: [0x62,0xf1,0x7d,0x08,0x90,0xd1]
@@ -15,6 +15,18 @@
 # CHECK: {evex}kmovq   %k1, %k2
 # CHECK: encoding: [0x62,0xf1,0xfc,0x08,0x90,0xd1]
  {evex}kmovq   %k1, %k2
+# CHECK: {evex} kmovb   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0x7d,0x08,0x90,0x40,0xf0]
+ {evex} kmovb   -0x10(%rax), %k0
+# CHECK: {evex} kmovw   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0x7c,0x08,0x90,0x40,0xf0]
+ {evex} kmovw   -0x10(%rax), %k0
+# CHECK: {evex} kmovd   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0xfd,0x08,0x90,0x40,0xf0]
+ {evex} kmovd   -0x10(%rax), %k0
+# CHECK: {evex} kmovq   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0xfc,0x08,0x90,0x40,0xf0]
+ {evex} kmovq   -0x10(%rax), %k0
 
 # CHECK-NOT: {evex}
 
diff --git a/llvm/test/MC/X86/apx/kmov-intel.s 
b/llvm/test/MC/X86/apx/kmov-intel.s
index 0cdbd310062eba..51cec67caf9a04 100644
--- a/llvm/test/MC/X86/apx/kmov-intel.s
+++ b/llvm/test/MC/X86/apx/kmov-intel.s
@@ -12,6 +12,18 @@
 # CHECK: {evex}kmovq   k2, k1
 # CHECK: encoding: [0x62,0xf1,0xfc,0x08,0x90,0xd1]
  {evex}kmovq   k2, k1
+# CHECK: {evex} kmovb   k0, byte ptr [rax - 16]
+# CHECK: encoding: [0x62,0xf1,0x7d,0x08,0x90,0x40,0xf0]
+ {evex} kmovb   k0, byte ptr [rax - 0x10]
+# CHECK: {evex} kmovw   k0, word ptr [rax - 16]
+# CHECK: encoding: [0x62,0xf1,0x7c,0x08,0x90,0x4

[llvm-branch-commits] [llvm] release/19.x: [X86][APX] Do not emit {evex} prefix for memory variant (#109759) (PR #109767)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/109767
___
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: [X86][APX] Do not emit {evex} prefix for memory variant (#109759) (PR #109767)

2024-09-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: None (llvmbot)


Changes

Backport 0d334d83a4c7ce16fa1bc0e5e56bbdeaf01c2b2d 
70529b24a30943d46e361d2990268499921e28a2

Requested by: @phoebewang

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


4 Files Affected:

- (modified) llvm/lib/Target/X86/X86InstrAVX512.td (+2-2) 
- (modified) llvm/test/MC/Disassembler/X86/apx/kmov.txt (+16) 
- (modified) llvm/test/MC/X86/apx/kmov-att.s (+13-1) 
- (modified) llvm/test/MC/X86/apx/kmov-intel.s (+12) 


``diff
diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td 
b/llvm/lib/Target/X86/X86InstrAVX512.td
index da690aea43f5c0..cc1f9090c11acc 100644
--- a/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -2625,11 +2625,11 @@ multiclass avx512_mask_mov opc_kk, bits<8> 
opc_km, bits<8> opc_mk,
   def km#Suffix : I,
-  Sched<[WriteLoad]>;
+  Sched<[WriteLoad]>, NoCD8;
   def mk#Suffix : I,
-  Sched<[WriteStore]>;
+  Sched<[WriteStore]>, NoCD8;
 }
 
 multiclass avx512_mask_mov_gpr opc_kr, bits<8> opc_rk,
diff --git a/llvm/test/MC/Disassembler/X86/apx/kmov.txt 
b/llvm/test/MC/Disassembler/X86/apx/kmov.txt
index 5d947ff39f2314..ba77dda64e59f5 100644
--- a/llvm/test/MC/Disassembler/X86/apx/kmov.txt
+++ b/llvm/test/MC/Disassembler/X86/apx/kmov.txt
@@ -17,6 +17,22 @@
 # INTEL: {evex} kmovq  k2, k1
 0x62,0xf1,0xfc,0x08,0x90,0xd1
 
+# ATT:   kmovb -16(%rax), %k0
+# INTEL: kmovb k0, byte ptr [rax - 16]
+0x62,0xf1,0x7d,0x08,0x90,0x40,0xf0
+
+# ATT:   kmovw -16(%rax), %k0
+# INTEL: kmovw k0, word ptr [rax - 16]
+0x62,0xf1,0x7c,0x08,0x90,0x40,0xf0
+
+# ATT:   kmovd -16(%rax), %k0
+# INTEL: kmovd k0, dword ptr [rax - 16]
+0x62,0xf1,0xfd,0x08,0x90,0x40,0xf0
+
+# ATT:   kmovq -16(%rax), %k0
+# INTEL: kmovq k0, qword ptr [rax - 16]
+0x62,0xf1,0xfc,0x08,0x90,0x40,0xf0
+
 # ATT-NOT: {evex}
 # INTEL-NOT: {evex}
 
diff --git a/llvm/test/MC/X86/apx/kmov-att.s b/llvm/test/MC/X86/apx/kmov-att.s
index 949ef65be98d4c..5f59e0a505b235 100644
--- a/llvm/test/MC/X86/apx/kmov-att.s
+++ b/llvm/test/MC/X86/apx/kmov-att.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple x86_64 -show-encoding %s | FileCheck %s
 # RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s 
--check-prefix=ERROR
 
-# ERROR-COUNT-20: error:
+# ERROR-COUNT-24: error:
 # ERROR-NOT: error:
 # CHECK: {evex}kmovb   %k1, %k2
 # CHECK: encoding: [0x62,0xf1,0x7d,0x08,0x90,0xd1]
@@ -15,6 +15,18 @@
 # CHECK: {evex}kmovq   %k1, %k2
 # CHECK: encoding: [0x62,0xf1,0xfc,0x08,0x90,0xd1]
  {evex}kmovq   %k1, %k2
+# CHECK: {evex} kmovb   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0x7d,0x08,0x90,0x40,0xf0]
+ {evex} kmovb   -0x10(%rax), %k0
+# CHECK: {evex} kmovw   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0x7c,0x08,0x90,0x40,0xf0]
+ {evex} kmovw   -0x10(%rax), %k0
+# CHECK: {evex} kmovd   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0xfd,0x08,0x90,0x40,0xf0]
+ {evex} kmovd   -0x10(%rax), %k0
+# CHECK: {evex} kmovq   -16(%rax), %k0
+# CHECK: encoding: [0x62,0xf1,0xfc,0x08,0x90,0x40,0xf0]
+ {evex} kmovq   -0x10(%rax), %k0
 
 # CHECK-NOT: {evex}
 
diff --git a/llvm/test/MC/X86/apx/kmov-intel.s 
b/llvm/test/MC/X86/apx/kmov-intel.s
index 0cdbd310062eba..51cec67caf9a04 100644
--- a/llvm/test/MC/X86/apx/kmov-intel.s
+++ b/llvm/test/MC/X86/apx/kmov-intel.s
@@ -12,6 +12,18 @@
 # CHECK: {evex}kmovq   k2, k1
 # CHECK: encoding: [0x62,0xf1,0xfc,0x08,0x90,0xd1]
  {evex}kmovq   k2, k1
+# CHECK: {evex} kmovb   k0, byte ptr [rax - 16]
+# CHECK: encoding: [0x62,0xf1,0x7d,0x08,0x90,0x40,0xf0]
+ {evex} kmovb   k0, byte ptr [rax - 0x10]
+# CHECK: {evex} kmovw   k0, word ptr [rax - 16]
+# CHECK: encoding: [0x62,0xf1,0x7c,0x08,0x90,0x40,0xf0]
+ {evex} kmovw   k0, word ptr [rax - 0x10]
+# CHECK: {evex} kmovd   k0, dword ptr [rax - 16]
+# CHECK: encoding: [0x62,0xf1,0xfd,0x08,0x90,0x40,0xf0]
+ {evex} kmovd   k0, dword ptr [rax - 0x10]
+# CHECK: {evex} kmovq   k0, qword ptr [rax - 16]
+# CHECK: encoding: [0x62,0xf1,0xfc,0x08,0x90,0x40,0xf0]
+ {evex} kmovq   k0, qword ptr [rax - 0x10]
 
 # CHECK-NOT: {evex}
 

``




https://github.com/llvm/llvm-project/pull/109767
___
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: [C++20] [Modules] Treat in class defined member functions in language linkage as implicitly inline (PR #109077)

2024-09-24 Thread Chuanqi Xu via llvm-branch-commits

ChuanqiXu9 wrote:

Oh, maybe some implicit conflicts. I'll add one manually

https://github.com/llvm/llvm-project/pull/109077
___
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] [C++20] [Modules] Add Decl::isFromGlobalModule (PR #109762)

2024-09-24 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/109762
___
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] [C++20] [Modules] Add Decl::isFromGlobalModule (PR #109762)

2024-09-24 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

Thanks for the quick fix.

https://github.com/llvm/llvm-project/pull/109762
___
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] 4c51d82 - [C++20] [Modules] Add Decl::isFromGlobalModule

2024-09-24 Thread Chuanqi Xu via llvm-branch-commits

Author: Chuanqi Xu
Date: 2024-09-24T15:41:11+08:00
New Revision: 4c51d827e58aaa8c5b3d75b3b61a43627ab53491

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

LOG: [C++20] [Modules] Add Decl::isFromGlobalModule

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/lib/AST/DeclBase.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 2a4bd0f9c2fda3..04dbd1db6cba81 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -680,6 +680,9 @@ class alignas(8) Decl {
   /// Whether this declaration comes from explicit global module.
   bool isFromExplicitGlobalModule() const;
 
+  /// Whether this declaration comes from global module.
+  bool isFromGlobalModule() const;
+
   /// Whether this declaration comes from a named module.
   bool isInNamedModule() const;
 

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index b59f118380ca4b..c4e948a38e2641 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1161,6 +1161,10 @@ bool Decl::isFromExplicitGlobalModule() const {
   return getOwningModule() && getOwningModule()->isExplicitGlobalModule();
 }
 
+bool Decl::isFromGlobalModule() const {
+  return getOwningModule() && getOwningModule()->isGlobalModule();
+}
+
 bool Decl::isInNamedModule() const {
   return getOwningModule() && getOwningModule()->isNamedModule();
 }



___
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] [C++20] [Modules] Add Decl::isFromGlobalModule (PR #109762)

2024-09-24 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ChuanqiXu9 (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/109762
___
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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Victor Campos via llvm-branch-commits

https://github.com/vhscampos updated 
https://github.com/llvm/llvm-project/pull/108601

>From 12b657a4761351d52fccb93ce52e64c3c1b1e91f Mon Sep 17 00:00:00 2001
From: Victor Campos 
Date: Fri, 9 Aug 2024 14:00:32 +0100
Subject: [PATCH 1/2] [ADT] Add more useful methods to SmallSet API

This patch adds useful methods to the SmallSet API:

 - Constructor that takes pair of iterators.
 - Constructor that takes a range.
 - Constructor that takes an initializer list.
 - Copy constructor.
 - Move constructor.
 - Copy assignment operator.
 - Move assignment operator.
---
 llvm/include/llvm/ADT/SmallSet.h| 17 
 llvm/unittests/ADT/SmallSetTest.cpp | 60 +
 2 files changed, 77 insertions(+)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index 56259ea7cf9d0f..431fdee56c20e0 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/iterator.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -147,6 +148,22 @@ class SmallSet {
   using const_iterator = SmallSetIterator;
 
   SmallSet() = default;
+  SmallSet(const SmallSet &) = default;
+  SmallSet(SmallSet &&) = default;
+
+  template  SmallSet(IterT Begin, IterT End) {
+this->insert(Begin, End);
+  }
+
+  template 
+  explicit SmallSet(const iterator_range &R) {
+this->insert(R.begin(), R.end());
+  }
+
+  SmallSet(std::initializer_list L) { this->insert(L.begin(), L.end()); }
+
+  SmallSet &operator=(const SmallSet &) = default;
+  SmallSet &operator=(SmallSet &&) = default;
 
   [[nodiscard]] bool empty() const { return Vector.empty() && Set.empty(); }
 
diff --git a/llvm/unittests/ADT/SmallSetTest.cpp 
b/llvm/unittests/ADT/SmallSetTest.cpp
index 0fb20b19df9254..8219bf6f4b4c55 100644
--- a/llvm/unittests/ADT/SmallSetTest.cpp
+++ b/llvm/unittests/ADT/SmallSetTest.cpp
@@ -17,6 +17,66 @@
 
 using namespace llvm;
 
+TEST(SmallSetTest, ConstructorIteratorPair) {
+  auto L = {1, 2, 3, 4, 5};
+  SmallSet S(std::begin(L), std::end(L));
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));
+}
+
+TEST(SmallSet, ConstructorRange) {
+  auto L = {1, 2, 3, 4, 5};
+
+  SmallSet S(llvm::make_range(std::begin(L), std::end(L)));
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));
+}
+
+TEST(SmallSet, ConstructorInitializerList) {
+  auto L = {1, 2, 3, 4, 5};
+  SmallSet S = {1, 2, 3, 4, 5};
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));
+}
+
+TEST(SmallSet, CopyConstructor) {
+  SmallSet S = {1, 2, 3};
+  SmallSet T = S;
+
+  EXPECT_EQ(S, T);
+}
+
+TEST(SmallSet, MoveConstructor) {
+  auto L = {1, 2, 3};
+  SmallSet S = L;
+  SmallSet T = std::move(S);
+
+  EXPECT_TRUE(T.size() == L.size());
+  for (int Value : L) {
+EXPECT_TRUE(T.contains(Value));
+  }
+}
+
+TEST(SmallSet, CopyAssignment) {
+  SmallSet S = {1, 2, 3};
+  SmallSet T;
+  T = S;
+
+  EXPECT_EQ(S, T);
+}
+
+TEST(SmallSet, MoveAssignment) {
+  auto L = {1, 2, 3};
+  SmallSet S = L;
+  SmallSet T;
+  T = std::move(S);
+
+  EXPECT_TRUE(T.size() == L.size());
+  for (int Value : L) {
+EXPECT_TRUE(T.contains(Value));
+  }
+}
+
 TEST(SmallSetTest, Insert) {
 
   SmallSet s1;

>From d122983eb4f1f66da2a4a6b5bcdb9c8171d18205 Mon Sep 17 00:00:00 2001
From: Victor Campos 
Date: Tue, 24 Sep 2024 17:43:42 +0100
Subject: [PATCH 2/2] fixup! [ADT] Add more useful methods to SmallSet API

---
 llvm/include/llvm/ADT/SmallSet.h|  4 ++--
 llvm/unittests/ADT/SmallSetTest.cpp | 34 +++--
 2 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index 431fdee56c20e0..1b8ad542846630 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -152,12 +152,12 @@ class SmallSet {
   SmallSet(SmallSet &&) = default;
 
   template  SmallSet(IterT Begin, IterT End) {
-this->insert(Begin, End);
+insert(Begin, End);
   }
 
   template 
   explicit SmallSet(const iterator_range &R) {
-this->insert(R.begin(), R.end());
+insert(R.begin(), R.end());
   }
 
   SmallSet(std::initializer_list L) { this->insert(L.begin(), L.end()); }
diff --git a/llvm/unittests/ADT/SmallSetTest.cpp 
b/llvm/unittests/ADT/SmallSetTest.cpp
index 8219bf6f4b4c55..2feb0b1feb421b 100644
--- a/llvm/unittests/ADT/SmallSetTest.cpp
+++ b/llvm/unittests/ADT/SmallSetTest.cpp
@@ -12,49 +12,44 @@
 
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/STLExtras.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 
 using namespace llvm;
 
 TEST(SmallSetTest, ConstructorIteratorPair) {
-  auto L = {1, 2, 3, 4, 5};
+  std::initializer_list L = {1, 2, 3, 4, 5};
   SmallSet S(std::begin(L), std::end(L));
-  for (int Value : L)
-EXPECT_TRUE(S.contains(Value));
+  EXPECT_THAT(S, testing::UnorderedElementsAreArray(L));
 }
 
 TEST(SmallSet, ConstructorRange) {
-  auto L = {1, 2, 3, 4, 5};
+  std::initializer_list L = {1, 2, 3, 4, 5};
 
   SmallSet S

[llvm-branch-commits] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits


@@ -1935,12 +1940,12 @@ void HWAddressSanitizer::ShadowMapping::init(Triple 
&TargetTriple,
 SetFixed(0);
   } else if (ClMappingOffset.getNumOccurrences() > 0) {
 SetFixed(ClMappingOffset);
-WithFrameRecord = false;
   } else if (ClEnableKhwasan || InstrumentWithCalls) {
 SetFixed(0);
 WithFrameRecord = false;

vitalybuka wrote:

We need to fix this, but this is not the point of PR, here I break mapping => 
WithFrameRecord.

https://github.com/llvm/llvm-project/pull/109620
___
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] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer edited 
https://github.com/llvm/llvm-project/pull/109620
___
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] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Florian Mayer via llvm-branch-commits


@@ -1935,12 +1940,12 @@ void HWAddressSanitizer::ShadowMapping::init(Triple 
&TargetTriple,
 SetFixed(0);
   } else if (ClMappingOffset.getNumOccurrences() > 0) {
 SetFixed(ClMappingOffset);
-WithFrameRecord = false;
   } else if (ClEnableKhwasan || InstrumentWithCalls) {
 SetFixed(0);
 WithFrameRecord = false;

fmayer wrote:

We change it for `ClMappingOffset`. Please be more explicit in the commit 
message about what behaior changes.

https://github.com/llvm/llvm-project/pull/109620
___
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] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Vitaly Buka via llvm-branch-commits


@@ -1935,12 +1940,12 @@ void HWAddressSanitizer::ShadowMapping::init(Triple 
&TargetTriple,
 SetFixed(0);
   } else if (ClMappingOffset.getNumOccurrences() > 0) {
 SetFixed(ClMappingOffset);
-WithFrameRecord = false;
   } else if (ClEnableKhwasan || InstrumentWithCalls) {
 SetFixed(0);
 WithFrameRecord = false;

vitalybuka wrote:

No, that's exactly what I mean.
We will not set 'WithFrameRecord = false;' from ClMappingOffset or 
ClMappingOffsetDynamic

https://github.com/llvm/llvm-project/pull/109620
___
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] [hwasan] Consider order of mapping copts (PR #109621)

2024-09-24 Thread Florian Mayer via llvm-branch-commits

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

LGTM.

https://github.com/llvm/llvm-project/pull/109621
___
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] [hwasan] Add "-hwasan-with-frame-record" (PR #109620)

2024-09-24 Thread Florian Mayer via llvm-branch-commits


@@ -1935,12 +1940,12 @@ void HWAddressSanitizer::ShadowMapping::init(Triple 
&TargetTriple,
 SetFixed(0);
   } else if (ClMappingOffset.getNumOccurrences() > 0) {
 SetFixed(ClMappingOffset);
-WithFrameRecord = false;
   } else if (ClEnableKhwasan || InstrumentWithCalls) {
 SetFixed(0);
 WithFrameRecord = false;

fmayer wrote:

It is still implied from `InstrumentWithCalls`. Why?

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


[llvm-branch-commits] [mlir] [MLIR][OpenMP] Document entry block argument-defining clauses (NFC) (PR #109811)

2024-09-24 Thread Sergio Afonso via llvm-branch-commits

skatrak wrote:

PR stack:
- #109808
- #109809
- #109810
- #109811

https://github.com/llvm/llvm-project/pull/109811
___
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] [MLIR][OpenMP] Normalize representation of entry block arg-defining clauses (PR #109809)

2024-09-24 Thread Sergio Afonso via llvm-branch-commits

skatrak wrote:

PR stack:
- #109808
- #109809
- #109810
- #109811

https://github.com/llvm/llvm-project/pull/109809
___
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] [MLIR][OpenMP] Use map format to represent use_device_{addr, ptr} (PR #109810)

2024-09-24 Thread Sergio Afonso via llvm-branch-commits

skatrak wrote:

PR stack:
- #109808
- #109809
- #109810
- #109811

https://github.com/llvm/llvm-project/pull/109810
___
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] 41f3483 - Revert "[DirectX] Add atan2 intrinsic and expand for DXIL backend (p1) (#108865)"

2024-09-24 Thread via llvm-branch-commits

Author: Farzon Lotfi
Date: 2024-09-24T14:09:51-04:00
New Revision: 41f348332ec7d34bb5c1425e71fcfc90ecfc1470

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

LOG: Revert "[DirectX] Add atan2 intrinsic and expand for DXIL backend (p1) 
(#108865)"

This reverts commit 26029d77a57cb4aaa1479064109e985a90d0edd8.

Added: 


Modified: 
llvm/docs/LangRef.rst
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp

Removed: 
llvm/test/CodeGen/DirectX/atan2.ll
llvm/test/CodeGen/DirectX/atan2_error.ll



diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 41d1efab752fd7..91c3e60bb0acb1 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -15583,43 +15583,6 @@ trapping or setting ``errno``.
 When specified with the fast-math-flag 'afn', the result may be approximated
 using a less accurate calculation.
 
-'``llvm.atan2.*``' Intrinsic
-^^^
-
-Syntax:
-"""
-
-This is an overloaded intrinsic. You can use ``llvm.atan2`` on any
-floating-point or vector of floating-point type. Not all targets support
-all types however.
-
-::
-
-  declare float @llvm.atan2.f32(float  %X, float %Y)
-  declare double@llvm.atan2.f64(double %X, double %Y)
-  declare x86_fp80  @llvm.atan2.f80(x86_fp80  %X, x86_fp80 %Y)
-  declare fp128 @llvm.atan2.f128(fp128 %X, fp128 %Y)
-  declare ppc_fp128 @llvm.atan2.ppcf128(ppc_fp128  %X, ppc_fp128 %Y)
-
-Overview:
-"
-
-The '``llvm.atan2.*``' intrinsics return the arctangent of the operand.
-
-Arguments:
-""
-
-The arguments and return value are floating-point numbers of the same type.
-
-Semantics:
-""
-
-Return the same value as a corresponding libm '``atan2``' function but without
-trapping or setting ``errno``.
-
-When specified with the fast-math-flag 'afn', the result may be approximated
-using a less accurate calculation.
-
 '``llvm.sinh.*``' Intrinsic
 ^^^
 

diff  --git a/llvm/include/llvm/IR/Intrinsics.td 
b/llvm/include/llvm/IR/Intrinsics.td
index 48d57907e6d0bc..0a74a217a5f010 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1016,7 +1016,6 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable, 
IntrWillReturn] in {
   def int_asin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
   def int_acos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
   def int_atan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
-  def int_atan2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, 
LLVMMatchType<0>]>;
   def int_sin  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
   def int_cos  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
   def int_tan  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;

diff  --git a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp 
b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
index 926cbe97f24fda..dd73b895b14d37 100644
--- a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
+++ b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
@@ -36,7 +36,6 @@ using namespace llvm;
 static bool isIntrinsicExpansion(Function &F) {
   switch (F.getIntrinsicID()) {
   case Intrinsic::abs:
-  case Intrinsic::atan2:
   case Intrinsic::exp:
   case Intrinsic::log:
   case Intrinsic::log10:
@@ -308,54 +307,6 @@ static Value *expandNormalizeIntrinsic(CallInst *Orig) {
   return Builder.CreateFMul(X, MultiplicandVec);
 }
 
-static Value *expandAtan2Intrinsic(CallInst *Orig) {
-  Value *Y = Orig->getOperand(0);
-  Value *X = Orig->getOperand(1);
-  Type *Ty = X->getType();
-  IRBuilder<> Builder(Orig);
-  Builder.setFastMathFlags(Orig->getFastMathFlags());
-
-  Value *Tan = Builder.CreateFDiv(Y, X);
-
-  CallInst *Atan =
-  Builder.CreateIntrinsic(Ty, Intrinsic::atan, {Tan}, nullptr, "Elt.Atan");
-  Atan->setTailCall(Orig->isTailCall());
-  Atan->setAttributes(Orig->getAttributes());
-
-  // Modify atan result based on https://en.wikipedia.org/wiki/Atan2.
-  Constant *Pi = ConstantFP::get(Ty, llvm::numbers::pi);
-  Constant *HalfPi = ConstantFP::get(Ty, llvm::numbers::pi / 2);
-  Constant *NegHalfPi = ConstantFP::get(Ty, -llvm::numbers::pi / 2);
-  Constant *Zero = ConstantFP::get(Ty, 0);
-  Value *AtanAddPi = Builder.CreateFAdd(Atan, Pi);
-  Value *AtanSubPi = Builder.CreateFSub(Atan, Pi);
-
-  // x > 0 -> atan.
-  Value *Result = Atan;
-  Value *XLt0 = Builder.CreateFCmpOLT(X, Zero);
-  Value *XEq0 = Builder.CreateFCmpOEQ(X, Zero);
-  Value *YGe0 = Builder.CreateFCmpOGE(Y, Zero);
-  Value *YLt0 = Builder.CreateFCmpOLT(Y, Zero);
-
-  // x < 0, y >= 0 -> atan + pi.
-  Value *XLt0AndYGe0 = Builder.CreateAnd(XLt0, YGe0);
-  Result = Bui

[llvm-branch-commits] [llvm] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -17,6 +17,66 @@
 
 using namespace llvm;
 
+TEST(SmallSetTest, ConstructorIteratorPair) {
+  auto L = {1, 2, 3, 4, 5};
+  SmallSet S(std::begin(L), std::end(L));
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));

kuhar wrote:

You can also do `EXPECT_THAT(S, UnorderedElementsAreArray(L));`. This prints 
nice error messages.
Also elsewhere below.

https://github.com/llvm/llvm-project/pull/108601
___
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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -147,6 +148,22 @@ class SmallSet {
   using const_iterator = SmallSetIterator;
 
   SmallSet() = default;
+  SmallSet(const SmallSet &) = default;
+  SmallSet(SmallSet &&) = default;
+
+  template  SmallSet(IterT Begin, IterT End) {
+this->insert(Begin, End);
+  }
+
+  template 
+  explicit SmallSet(const iterator_range &R) {
+this->insert(R.begin(), R.end());
+  }
+
+  SmallSet(std::initializer_list L) { this->insert(L.begin(), L.end()); }

kuhar wrote:

The rest of the code in the class doesn't use `this->` for member functions

https://github.com/llvm/llvm-project/pull/108601
___
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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -17,6 +17,66 @@
 
 using namespace llvm;
 
+TEST(SmallSetTest, ConstructorIteratorPair) {
+  auto L = {1, 2, 3, 4, 5};

kuhar wrote:

Could you make the type explicit, both here and everywhere else below. Either 
initializer list or some other vector type is fine.

https://github.com/llvm/llvm-project/pull/108601
___
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-scan-deps] Don't inspect Args[0] as an option (#109050) (PR #109865)

2024-09-24 Thread via llvm-branch-commits
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= 
Message-ID:
In-Reply-To: 


https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/109865
___
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-scan-deps] Don't inspect Args[0] as an option (#109050) (PR #109865)

2024-09-24 Thread via llvm-branch-commits
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= 
Message-ID: 
In-Reply-To:


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

Backport 87e1104cf0e2de0d04bee2944893fa7897277b2f 
aa3465793a250faa5426ac626989375465256658 
a26ec542371652e1d774696e90016fd5b0b1c191 
cead9044a995910306e2e64b426fcc8042d7e0ef

Requested by: @mstorsjo

>From 257d8d38789076aae5d9e2814e0422b861ed103d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Thu, 12 Sep 2024 22:20:14 +0300
Subject: [PATCH 1/4] [clang-scan-deps] Infer the target from the executable
 name (#108189)

This allows clang-scan-deps to work correctly when using cross compilers
with names like -clang.

(cherry picked from commit 87e1104cf0e2de0d04bee2944893fa7897277b2f)
---
 clang/test/ClangScanDeps/implicit-target.c| 31 +++
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  5 +++
 2 files changed, 36 insertions(+)
 create mode 100644 clang/test/ClangScanDeps/implicit-target.c

diff --git a/clang/test/ClangScanDeps/implicit-target.c 
b/clang/test/ClangScanDeps/implicit-target.c
new file mode 100644
index 00..cf757f937331a6
--- /dev/null
+++ b/clang/test/ClangScanDeps/implicit-target.c
@@ -0,0 +1,31 @@
+// Check that we can detect an implicit target when clang is invoked as
+// clang. Using an implicit triple requires that the target actually
+// is available, too.
+// REQUIRES: x86-registered-target
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
+
+// Check that we can deduce this both when using a compilation database, and 
when using
+// a literal command line.
+
+// RUN: clang-scan-deps -format experimental-full -compilation-database 
%t/cdb.json | FileCheck %s
+
+// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-clang 
%t/source.c -o %t/source.o | FileCheck %s
+
+// CHECK: "-triple",
+// CHECK-NEXT: "x86_64-w64-windows-gnu",
+
+
+//--- cdb.json.in
+[
+  {
+"directory": "DIR"
+"command": "x86_64-w64-mingw32-clang -c DIR/source.c -o DIR/source.o"
+"file": "DIR/source.c"
+  },
+]
+
+//--- source.c
+void func(void) {}
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index a8f6150dd3493d..cd6dd2620152a6 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -15,6 +15,7 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
@@ -24,6 +25,7 @@
 #include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/Timer.h"
@@ -795,6 +797,7 @@ getCompilationDatabase(int argc, char **argv, std::string 
&ErrorMessage) {
 }
 
 int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
+  llvm::InitializeAllTargetInfos();
   std::string ErrorMessage;
   std::unique_ptr Compilations =
   getCompilationDatabase(argc, argv, ErrorMessage);
@@ -810,6 +813,8 @@ int clang_scan_deps_main(int argc, char **argv, const 
llvm::ToolContext &) {
   Compilations = expandResponseFiles(std::move(Compilations),
  llvm::vfs::getRealFileSystem());
 
+  Compilations = inferTargetAndDriverMode(std::move(Compilations));
+
   // The command options are rewritten to run Clang in preprocessor only mode.
   auto AdjustingCompilations =
   std::make_unique(

>From 34463f84f8f3cb8b977ae755aadecb5a2c50db15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Thu, 12 Sep 2024 23:11:27 +0300
Subject: [PATCH 2/4] [clang-scan-deps] Fix builds with BUILD_SHARED_LIBS=ON

This fixes building in this configuration after
87e1104cf0e2de0d04bee2944893fa7897277b2f.

(cherry picked from commit aa3465793a250faa5426ac626989375465256658)
---
 clang/tools/clang-scan-deps/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/tools/clang-scan-deps/CMakeLists.txt 
b/clang/tools/clang-scan-deps/CMakeLists.txt
index f0be6a546ff882..10bc0ff23c5482 100644
--- a/clang/tools/clang-scan-deps/CMakeLists.txt
+++ b/clang/tools/clang-scan-deps/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
   Core
   Option
   Support

>From 4d90a8856f641aac9846f073e2e06c4b738644d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Fri, 13 Sep 2024 23:18:10 +0300
Subject: [PATCH 3/4] [clang-scan-deps] Infer the tool locations from PATH
 (#108539)

This allows the clang driver to know which tool is meant to be executed,
wh

[llvm-branch-commits] [clang] release/19.x: [clang-scan-deps] Don't inspect Args[0] as an option (#109050) (PR #109865)

2024-09-24 Thread via llvm-branch-commits
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= 
Message-ID:
In-Reply-To: 


llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/109865
___
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-scan-deps] Don't inspect Args[0] as an option (#109050) (PR #109865)

2024-09-24 Thread via llvm-branch-commits
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= ,
Martin =?utf-8?q?Storsjö?= 
Message-ID:
In-Reply-To: 


llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

Backport 87e1104cf0e2de0d04bee2944893fa7897277b2f 
aa3465793a250faa5426ac626989375465256658 
a26ec542371652e1d774696e90016fd5b0b1c191 
cead9044a995910306e2e64b426fcc8042d7e0ef

Requested by: @mstorsjo

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


14 Files Affected:

- (modified) clang/include/clang/Tooling/CompilationDatabase.h (+6) 
- (modified) clang/lib/Tooling/CMakeLists.txt (+1) 
- (added) clang/lib/Tooling/LocateToolCompilationDatabase.cpp (+71) 
- (added) clang/test/ClangScanDeps/implicit-target.c (+31) 
- (modified) clang/test/ClangScanDeps/modules-extern-submodule.c (+1-2) 
- (modified) clang/test/ClangScanDeps/modules-full-output-tu-order.c (+2-4) 
- (modified) clang/test/ClangScanDeps/modules-has-include-umbrella-header.c 
(+1-2) 
- (modified) clang/test/ClangScanDeps/modules-header-sharing.m (+1-2) 
- (modified) clang/test/ClangScanDeps/modules-implementation-module-map.c 
(+1-2) 
- (modified) clang/test/ClangScanDeps/modules-implementation-private.m (+1-2) 
- (modified) clang/test/ClangScanDeps/modules-priv-fw-from-pub.m (+1-2) 
- (added) clang/test/ClangScanDeps/resolve-executable-path.c (+32) 
- (modified) clang/tools/clang-scan-deps/CMakeLists.txt (+1) 
- (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+13-1) 


``diff
diff --git a/clang/include/clang/Tooling/CompilationDatabase.h 
b/clang/include/clang/Tooling/CompilationDatabase.h
index fee584acb48623..36fe0812ebe974 100644
--- a/clang/include/clang/Tooling/CompilationDatabase.h
+++ b/clang/include/clang/Tooling/CompilationDatabase.h
@@ -234,6 +234,12 @@ std::unique_ptr
 std::unique_ptr
 inferTargetAndDriverMode(std::unique_ptr Base);
 
+/// Returns a wrapped CompilationDatabase that will transform argv[0] to an
+/// absolute path, if it currently is a plain tool name, looking it up in
+/// PATH.
+std::unique_ptr
+inferToolLocation(std::unique_ptr Base);
+
 /// Returns a wrapped CompilationDatabase that will expand all rsp(response)
 /// files on commandline returned by underlying database.
 std::unique_ptr
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index 93a9e707a134cf..fc1f1f9f9d367e 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_library(clangTooling
   GuessTargetAndModeCompilationDatabase.cpp
   InterpolatingCompilationDatabase.cpp
   JSONCompilationDatabase.cpp
+  LocateToolCompilationDatabase.cpp
   Refactoring.cpp
   RefactoringCallbacks.cpp
   StandaloneExecution.cpp
diff --git a/clang/lib/Tooling/LocateToolCompilationDatabase.cpp 
b/clang/lib/Tooling/LocateToolCompilationDatabase.cpp
new file mode 100644
index 00..033f69f3760c6d
--- /dev/null
+++ b/clang/lib/Tooling/LocateToolCompilationDatabase.cpp
@@ -0,0 +1,71 @@
+//===- GuessTargetAndModeCompilationDatabase.cpp 
--===//
+//
+// 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
+//
+//===--===//
+
+#include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include 
+
+namespace clang {
+namespace tooling {
+
+namespace {
+class LocationAdderDatabase : public CompilationDatabase {
+public:
+  LocationAdderDatabase(std::unique_ptr Base)
+  : Base(std::move(Base)) {
+assert(this->Base != nullptr);
+  }
+
+  std::vector getAllFiles() const override {
+return Base->getAllFiles();
+  }
+
+  std::vector getAllCompileCommands() const override {
+return addLocation(Base->getAllCompileCommands());
+  }
+
+  std::vector
+  getCompileCommands(StringRef FilePath) const override {
+return addLocation(Base->getCompileCommands(FilePath));
+  }
+
+private:
+  std::vector
+  addLocation(std::vector Cmds) const {
+for (auto &Cmd : Cmds) {
+  if (Cmd.CommandLine.empty())
+continue;
+  std::string &Driver = Cmd.CommandLine.front();
+  // If the driver name already is absolute, we don't need to do anything.
+  if (llvm::sys::path::is_absolute(Driver))
+continue;
+  // If the name is a relative path, like bin/clang, we assume it's
+  // possible to resolve it and don't do anything about it either.
+  if (llvm::any_of(Driver,
+   [](char C) { return llvm::sys::path::is_separator(C); 
}))
+continue;
+  auto Absolute = llvm::sys::findProgramByName(Driver);
+  // If we found it in path, update the entry in Cmd.CommandLine
+  if (Absolute && llvm::sys::path::is_absolute(*Absolute))
+Driver = std::move(*Absolute);

[llvm-branch-commits] [llvm] [Attributor] Take the address space from addrspacecast directly (PR #108258)

2024-09-24 Thread Shilei Tian via llvm-branch-commits


@@ -12571,17 +12571,59 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
   void initialize(Attributor &A) override {
 assert(getAssociatedType()->isPtrOrPtrVectorTy() &&
"Associated value is not a pointer");
-if (getAssociatedType()->getPointerAddressSpace())
+// If the pointer already has non-generic address space, we assume it is 
the
+// correct one.
+if (getAssociatedType()->getPointerAddressSpace()) {
+  [[maybe_unused]] bool R =
+  takeAddressSpace(getAssociatedType()->getPointerAddressSpace());
+  assert(R && "the take should happen");
   indicateOptimisticFixpoint();
+  return;
+}
+// If the pointer is an addrspacecast, we assume the source address space 
is
+// the correct one.
+Value *V = &getAssociatedValue();
+if (auto *ASC = dyn_cast(V)) {
+  [[maybe_unused]] bool R = takeAddressSpace(ASC->getSrcAddressSpace());
+  assert(R && "the take should happen");
+  indicateOptimisticFixpoint();
+  return;
+}
+if (auto *C = dyn_cast(V)) {
+  if (C->getOpcode() == Instruction::AddrSpaceCast) {
+[[maybe_unused]] bool R = takeAddressSpace(
+C->getOperand(0)->getType()->getPointerAddressSpace());
+assert(R && "the take should happen");
+indicateOptimisticFixpoint();
+return;
+  }
+}
   }
 
   ChangeStatus updateImpl(Attributor &A) override {
-int32_t OldAddressSpace = AssumedAddressSpace;
+uint32_t OldAddressSpace = AssumedAddressSpace;
 auto *AUO = A.getOrCreateAAFor(getIRPosition(), this,
 DepClassTy::REQUIRED);
 auto Pred = [&](Value &Obj) {
   if (isa(&Obj))
 return true;
+  // If an argument in generic address space has addrspace cast uses, and
+  // those casts are same, then we take the dst addrspace.
+  if (auto *Arg = dyn_cast(&Obj)) {

shiltian wrote:

It looks like for HIP we already emit the kernel with AS 1 pointer arguments. 
However, is it always the case?

```
#include 
#include 

__device__ __constant__ int constNumber[4] = {1, 2, 3, 4};

__global__ void kernel(int *out, int *in) { *out = in[3]; }

int main(int argc, char *argv[]) {
  int out;

  int *out_dev = nullptr;
  hipError_t err = hipMalloc(&out_dev, sizeof(int));
  if (err != hipSuccess)
return 1;

  kernel<<<1, 1>>>(out_dev, constNumber);

  err = hipMemcpyDtoH(&out, out_dev, sizeof(int));
  if (err != hipSuccess)
return 2;

  printf("out=%d\n", out);

  return 0;
}
```

The compiler doesn't complain anything, but at runtime it crashes due to memory 
access fault. The IR shows the kernel signature is:

```
define protected amdgpu_kernel void @_Z6kernelPiS_(ptr addrspace(1) noundef 
%out.coerce, ptr addrspace(1) noundef %in.coerce)
```

https://github.com/llvm/llvm-project/pull/108258
___
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: [ORC] Remove EDU from dependants list of dependencies before destroying. (PR #109355)

2024-09-24 Thread via llvm-branch-commits

github-actions[bot] wrote:

@lhames (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/109355
___
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] [Attributor] Take the address space from addrspacecast directly (PR #108258)

2024-09-24 Thread Shilei Tian via llvm-branch-commits

https://github.com/shiltian deleted 
https://github.com/llvm/llvm-project/pull/108258
___
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: [LoongArch] Fix the assertion for atomic store with 'ptr' type (PR #109915)

2024-09-24 Thread Lu Weining via llvm-branch-commits

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


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