[PATCH] D125171: [clang-format] Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-04-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/include/clang/Format/Format.h:816
+/// \code
+///original:
+///int someFunction(int arg1, int arg2);

Can you format this as we do the other documentation? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125171/new/

https://reviews.llvm.org/D125171

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


[clang] 61fee67 - [Clang][Driver] Handle LoongArch multiarch tuples

2023-04-24 Thread Weining Lu via cfe-commits

Author: WANG Xuerui
Date: 2023-04-24T15:18:59+08:00
New Revision: 61fee67cd77aedcb6f172ee0cfb0a0e5fa3c9c0d

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

LOG: [Clang][Driver] Handle LoongArch multiarch tuples

This follows v1.00 of the [[ 
https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html
 | LoongArch Toolchain Conventions ]],
but notably with [[ https://github.com/loongson/LoongArch-Documentation/pull/80 
| this patch ]]
applied (a proper version bump to v2.00 was not done, so it is
indistinguishable from the "original" but now incompatible v1.00
otherwise).

Only `loongarch64` is implemented in `Linux::getMultiarchTriple`
because support for LA32 and ILP32* ABIs are incomplete right now.

The Debian sysroot layout is based on Han Gao's recent porting effort,
specifically the ghcr.io/rabenda/beige:loong64-v23-preview-20230330
container image.

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D142688

Added: 

clang/test/Driver/Inputs/debian_loong64_tree/usr/include/c++/13/backward/.keep

clang/test/Driver/Inputs/debian_loong64_tree/usr/include/loongarch64-linux-gnu/c++/.keep

clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/gcc/loongarch64-linux-gnu/13/crtbegin.o

clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/gcc/loongarch64-linux-gnu/13/crtend.o

clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/gcc/loongarch64-linux-gnu/13/include/.keep

clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/loongarch64-linux-gnu/crt1.o

clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/loongarch64-linux-gnu/crti.o

clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/loongarch64-linux-gnu/crtn.o

Modified: 
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-header-search.cpp
clang/test/Driver/linux-ld.c
clang/test/Driver/loongarch-abi.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp 
b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index c1c220633b6bd..dce003e769577 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -54,7 +54,28 @@ StringRef loongarch::getLoongArchABI(const Driver &D, const 
ArgList &Args,
   }
 
   // Choose a default based on the triple.
-  return IsLA32 ? "ilp32d" : "lp64d";
+  // Honor the explicit ABI modifier suffix in triple's environment part if
+  // present, falling back to {ILP32,LP64}D otherwise.
+  switch (Triple.getEnvironment()) {
+  case llvm::Triple::GNUSF:
+return IsLA32 ? "ilp32s" : "lp64s";
+  case llvm::Triple::GNUF32:
+return IsLA32 ? "ilp32f" : "lp64f";
+  case llvm::Triple::GNUF64:
+// This was originally permitted (and indeed the canonical way) to
+// represent the {ILP32,LP64}D ABIs, but in Feb 2023 Loongson decided to
+// drop the explicit suffix in favor of unmarked `-gnu` for the
+// "general-purpose" ABIs, among other non-technical reasons.
+//
+// The spec change did not mention whether existing usages of "gnuf64"
+// shall remain valid or not, so we are going to continue recognizing it
+// for some time, until it is clear that everyone else has migrated away
+// from it.
+[[fallthrough]];
+  case llvm::Triple::GNU:
+  default:
+return IsLA32 ? "ilp32d" : "lp64d";
+  }
 }
 
 void loongarch::getLoongArchTargetFeatures(const Driver &D,

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 77ad9605addab..8ce5a16bfe0d8 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -86,6 +86,39 @@ std::string Linux::getMultiarchTriple(const Driver &D,
   case llvm::Triple::aarch64_be:
 return "aarch64_be-linux-gnu";
 
+  case llvm::Triple::loongarch64: {
+const char *Libc;
+const char *FPFlavor;
+
+if (TargetTriple.isGNUEnvironment()) {
+  Libc = "gnu";
+} else if (TargetTriple.isMusl()) {
+  Libc = "musl";
+} else {
+  return TargetTriple.str();
+}
+
+switch (TargetEnvironment) {
+default:
+  return TargetTriple.str();
+case llvm::Triple::GNUSF:
+  FPFlavor = "sf";
+  break;
+case llvm::Triple::GNUF32:
+  FPFlavor = "f32";
+  break;
+case llvm::Triple::GNU:
+case llvm::Triple::GNUF64:
+  // This was going to be "f64" in an earlier Toolchain Conventions
+  // revision, but starting from Feb 2023 the F64 ABI variants are
+  // unmarked in their canonical forms.
+  FPFlavor = "";
+  break;
+}
+
+return (Twine("loongarch64-linux-") + Libc + FPFlavor).str();
+  }
+
   case llvm::Triple::m68k:
 return "m68k-linux-gnu";
 

diff  --git 

[PATCH] D142688: [Clang][Driver] Handle LoongArch multiarch tuples

2023-04-24 Thread Lu Weining via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61fee67cd77a: [Clang][Driver] Handle LoongArch multiarch 
tuples (authored by WANG Xuerui , committed by 
SixWeining).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142688/new/

https://reviews.llvm.org/D142688

Files:
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/debian_loong64_tree/usr/include/c++/13/backward/.keep
  
clang/test/Driver/Inputs/debian_loong64_tree/usr/include/loongarch64-linux-gnu/c++/.keep
  
clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/gcc/loongarch64-linux-gnu/13/crtbegin.o
  
clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/gcc/loongarch64-linux-gnu/13/crtend.o
  
clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/gcc/loongarch64-linux-gnu/13/include/.keep
  
clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/loongarch64-linux-gnu/crt1.o
  
clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/loongarch64-linux-gnu/crti.o
  
clang/test/Driver/Inputs/debian_loong64_tree/usr/lib/loongarch64-linux-gnu/crtn.o
  clang/test/Driver/linux-header-search.cpp
  clang/test/Driver/linux-ld.c
  clang/test/Driver/loongarch-abi.c

Index: clang/test/Driver/loongarch-abi.c
===
--- clang/test/Driver/loongarch-abi.c
+++ clang/test/Driver/loongarch-abi.c
@@ -16,6 +16,34 @@
 // RUN: %clang --target=loongarch64-unknown-elf %s -fsyntax-only -### -mabi=lp64d 2>&1 \
 // RUN:   | FileCheck --check-prefix=LP64D %s
 
+// RUN: %clang --target=loongarch32-linux-gnusf %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32S %s
+// RUN: %clang --target=loongarch32-linux-gnuf32 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32F %s
+// RUN: %clang --target=loongarch32-linux-gnuf64 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32D %s
+// RUN: %clang --target=loongarch32-linux-gnu %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32D %s
+
+// RUN: %clang --target=loongarch64-linux-gnusf %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64S %s
+// RUN: %clang --target=loongarch64-linux-gnuf32 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64F %s
+// RUN: %clang --target=loongarch64-linux-gnuf64 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64D %s
+// RUN: %clang --target=loongarch64-linux-gnu %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64D %s
+
+// Check that -mabi prevails in case of conflicts with the triple-implied ABI.
+// RUN: %clang --target=loongarch32-linux-gnuf64 %s -fsyntax-only -### -mabi=ilp32s 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32S %s
+// RUN: %clang --target=loongarch64-linux-gnuf64 %s -fsyntax-only -### -mabi=lp64s 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64S %s
+// RUN: %clang --target=loongarch32-linux-gnu %s -fsyntax-only -### -mabi=ilp32s 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32S %s
+// RUN: %clang --target=loongarch64-linux-gnu %s -fsyntax-only -### -mabi=lp64s 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64S %s
+
 // ILP32S: "-target-abi" "ilp32s"
 // ILP32F: "-target-abi" "ilp32f"
 // ILP32D: "-target-abi" "ilp32d"
Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -830,6 +830,30 @@
 // CHECK-ARM-HF: "-dynamic-linker" "{{.*}}/lib/ld-linux-armhf.so.3"
 //
 // RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: --target=loongarch64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONGARCH-LP64D %s
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: --target=loongarch64-linux-gnuf64 \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONGARCH-LP64D %s
+// CHECK-LOONGARCH-LP64D: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LOONGARCH-LP64D: "-m" "elf64loongarch"
+// CHECK-LOONGARCH-LP64D: "-dynamic-linker" "{{.*}}/lib64/ld-linux-loongarch-lp64d.so.1"
+//
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: --target=loongarch64-linux-gnuf32 \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONGARCH-LP64F %s
+// CHECK-LOONGARCH-LP64F: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LOONGARCH-LP64F: "-m" "elf64loongarch"
+// CHECK-LOONGARCH-LP64F: "-dynamic-linker" "{{.*}}/lib64/ld-linux-loongarch-lp64f.so.1"
+//
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: --target=loongarch64-linux-gnusf \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONGARCH-LP64S %s
+// CHECK-LOONGARCH-LP64S: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LOONGARCH-LP64S: "-m" "elf64loongarch"
+// CHECK-LOONGARCH-LP64S: "-dynamic-linker" "{{.*}}/lib64/ld-linux-loongarch-lp64s.so.1"
+//
+// RUN: %clang -### %s -no-pie 2>&1 \
 // RUN: --target=powerpc64-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC64 %s
 // CHECK-PPC64: "{{.*}}ld{{(.exe)?}}"
@

[PATCH] D147731: [3/11][POC][Clang][RISCV] Add typedef of the tuple type and define tuple type variant of vlseg2e32

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516294.
eopXD marked an inline comment as done.
eopXD added a comment.

Address comments from Craig.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147731/new/

https://reviews.llvm.org/D147731

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32_tuple.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -65,6 +65,7 @@
   bool HasMaskedOffOperand :1;
   bool HasTailPolicy : 1;
   bool HasMaskPolicy : 1;
+  bool IsTuple : 1;
   uint8_t UnMaskedPolicyScheme : 2;
   uint8_t MaskedPolicyScheme : 2;
 };
@@ -363,6 +364,16 @@
 TypeModifier::UnsignedInteger));
 printType(*UT);
   }
+  // FIXME: Expand more type declaration
+  if (I == 'i' && Log2LMUL == 0) { // vint32m1x2_t
+auto TupleT = TypeCache.computeType(
+BT, Log2LMUL,
+PrototypeDescriptor(BaseTypeModifier::Vector,
+VectorTypeModifier::Tuple2,
+TypeModifier::SignedInteger));
+if (TupleT)
+  printType(*TupleT);
+  }
 }
   }
 
@@ -512,6 +523,7 @@
 StringRef IRName = R->getValueAsString("IRName");
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
+bool IsTuple = R->getValueAsBit("IsTuple");
 
 const Policy DefaultPolicy;
 SmallVector SupportedUnMaskedPolicies =
@@ -532,10 +544,10 @@
 auto Prototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF, UnMaskedPolicyScheme,
-DefaultPolicy);
+DefaultPolicy, IsTuple);
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-MaskedPolicyScheme, DefaultPolicy);
+MaskedPolicyScheme, DefaultPolicy, IsTuple);
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -557,14 +569,14 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-DefaultPolicy));
+DefaultPolicy, IsTuple));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
 RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF,
-UnMaskedPolicyScheme, P);
+UnMaskedPolicyScheme, P, IsTuple);
 std::optional PolicyTypes =
 TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
 Out.push_back(std::make_unique(
@@ -572,7 +584,7 @@
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
-NF, P));
+NF, P, IsTuple));
   }
 if (!HasMasked)
   continue;
@@ -583,14 +595,14 @@
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
 SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
-IntrinsicTypes, RequiredFeatures, NF, DefaultPolicy));
+IntrinsicTypes, RequiredFeatures, NF, DefaultPolicy, IsTuple));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
   SmallVector PolicyPrototype =
   RVVIntrinsic::computeBuiltinTypes(
   BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  NF, MaskedPolicyScheme, P);
+  NF, MaskedPolicyScheme, P, IsTuple);
   std::optional PolicyTypes =
   TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
   Out.push_back(std::make_unique(
@@ -598,7 +610,7 @@
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   MaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
   ManualCodegen, *PolicyTypes, IntrinsicTyp

[PATCH] D147731: [3/11][POC][Clang][RISCV] Add typedef of the tuple type and define tuple type variant of vlseg2e32

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:1486
+  QualType getScalableVectorTupleType(QualType EltTy, unsigned NumElts,
+  unsigned Tuple) const;
+

craig.topper wrote:
> Use `NF` or `NumFields` instead of `Tuple`?
Changed to `NumFields`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147731/new/

https://reviews.llvm.org/D147731

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


[PATCH] D147774: [4/11][POC][Clang][RISCV] Define tuple type variant of vsseg2e32

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516296.
eopXD added a comment.

Rebase upon update of parent patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147774/new/

https://reviews.llvm.org/D147774

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c
@@ -0,0 +1,31 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_tuple_i32m1(int32_t *base, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_v_tuple_i32m1(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[V0:%.*]],  [[V1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.mask.nxv2i32.i64( [[V0]],  [[V1]], ptr [[BASE]],  [[MASK]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_i32m1_m(vbool32_t mask, int32_t *base, vint32m1_t v0, vint32m1_t v1, size_t vl) {
+  return __riscv_vsseg2e32_v_i32m1_m(mask, base, v0, v1, vl);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -19763,6 +19763,14 @@
   }
 
   for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
+// Handle aggregate argument, namely RVV tuple types in segment load/store
+if (hasAggregateEvaluationKind(E->getArg(i)->getType())) {
+  LValue L = EmitAggExprToLValue(E->getArg(i));
+  llvm::Value *AggValue = Builder.CreateLoad(L.getAddress(*this));
+  Ops.push_back(AggValue);
+  continue;
+}
+
 // If this is a normal argument, just emit it as a scalar.
 if ((ICEArguments & (1 << i)) == 0) {
   Ops.push_back(EmitScalarExpr(E->getArg(i)));
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1779,6 +1779,51 @@
 }
   }
 }
+
+multiclass RVVUnitStridedSegStoreTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+foreach nf = [2] in {
+  let Name = op # nf # "e" # eew # "_v_tuple",
+  OverloadedName = op # nf # "e" # eew # "_tuple",
+  IRName = op # nf,
+  MaskedIRName = op # nf # "_mask",
+  NF = nf,
+  HasMaskedOffOperand = false,
+  ManualCodegen = [{
+{
+  // Masked
+  // Builtin: (mask, ptr, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, mask, vl)
+  // Unmasked
+  // Builtin: (ptr, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, vl)
+  llvm::Value *MaskOperand = IsMasked ? Ops[0] : nullptr;
+  llvm::Value *PtrOperand = IsMasked ? Ops[1] : Ops[0];
+  llvm::Value *VTupleOperand = IsMasked ? Ops[2] : Ops[1];
+  llvm::Value *VLOperand = IsMasked ? Ops[3] : Ops[2];
+
+  SmallVector Operands;
+  for (unsigned I = 0; I < NF; ++I) {
+llvm::Value *V = Builder.CreateExtractValue(VTupleOperand, {I});
+Operands.push_back(V);
+  }
+  Operands.push_back(PtrOperand);
+  if (MaskOperand)
+Operands.push_back(MaskOperand);
+  Operands.push_back(VLOperand);
+
+  IntrinsicTypes = {Operands[0]->getType(), Operands.back()->getType()};
+  llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
+  return Builder.CreateCall(F, Operan

[PATCH] D148919: [Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.

2023-04-24 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

This LGTM, but I don't remember why it was written this way. (I am not an 
expert in this area either). It seems to still give correct error messages 
with/without `__attribute__((target("sve")))`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148919/new/

https://reviews.llvm.org/D148919

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


[PATCH] D72538: [ThinLTO] Add additional ThinLTO pipeline testing with new PM

2023-04-24 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.
Herald added subscribers: wlei, pcwang-thead, ormris, wenlei.
Herald added a project: All.

Would it be possible to cut down the Clang side tests to only check parts that 
Clang controls in some way, e.g. that SLPVectorizer is enabled? This test is 
something of a PITA because it tests LLVM implementation details but is not 
part of the LLVM tests, so it usually gets missed when doing pipeline changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72538/new/

https://reviews.llvm.org/D72538

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


[clang] e7e4c76 - [Pipelines] Don't run ForceFunctionAttrs post-link

2023-04-24 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-04-24T09:58:06+02:00
New Revision: e7e4c7632075fef21bc8f90ad76dc68680e3bac8

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

LOG: [Pipelines] Don't run ForceFunctionAttrs post-link

This is effectively a debugging pass to adjust function attributes.
I don't think it makes sense to run it in the post-link pipeline.

Differential Revision: https://reviews.llvm.org/D148904

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 57e2011f55aed..c85ce0f6a27da 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -21,7 +21,6 @@
 
 ; CHECK-O: Running pass: WholeProgramDevirtPass
 ; CHECK-O: Running pass: LowerTypeTestsPass
-; CHECK-O: Running pass: ForceFunctionAttrsPass
 ; CHECK-O: Running pass: PGOIndirectCallPromotion
 ; CHECK-O: Running pass: InferFunctionAttrsPass
 ; CHECK-O: Running pass: LowerExpectIntrinsicPass on main

diff  --git a/llvm/lib/Passes/PassBuilderPipelines.cpp 
b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 4fa7326b24719..4407ad0131e12 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1557,9 +1557,6 @@ ModulePassManager 
PassBuilder::buildThinLTODefaultPipeline(
 return MPM;
   }
 
-  // Force any function attributes we want the rest of the pipeline to observe.
-  MPM.addPass(ForceFunctionAttrsPass());
-
   // Add the core simplification pipeline.
   MPM.addPass(buildModuleSimplificationPipeline(
   Level, ThinOrFullLTOPhase::ThinLTOPostLink));
@@ -1626,9 +1623,6 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel 
Level,
   // whole-program devirtualization and bitset lowering.
   MPM.addPass(GlobalDCEPass());
 
-  // Force any function attributes we want the rest of the pipeline to observe.
-  MPM.addPass(ForceFunctionAttrsPass());
-
   // Do basic inference of function attributes from known properties of system
   // libraries and other oracles.
   MPM.addPass(InferFunctionAttrsPass());

diff  --git a/llvm/test/Other/new-pm-lto-defaults.ll 
b/llvm/test/Other/new-pm-lto-defaults.ll
index 7fc0185070ece..eb4ad0610b326 100644
--- a/llvm/test/Other/new-pm-lto-defaults.ll
+++ b/llvm/test/Other/new-pm-lto-defaults.ll
@@ -31,7 +31,6 @@
 ; CHECK-O: Running pass: CrossDSOCFIPass
 ; CHECK-O-NEXT: Running pass: OpenMPOptPass
 ; CHECK-O-NEXT: Running pass: GlobalDCEPass
-; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
 ; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass
 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Module
 ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis

diff  --git a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
index def42f91a34e0..e99250d768aa5 100644
--- a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
@@ -36,11 +36,10 @@
 ; Suppress FileCheck --allow-unused-prefixes=false diagnostics.
 ; CHECK-NOEXT: {{^}}
 
-; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
-; CHECK-DIS-NEXT: Running analysis: InnerAnalysisManagerProxy
+; CHECK-EP-PIPELINE-START: Running pass: NoOpModulePass
+; CHECK-DIS: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-DIS-NEXT: Running pass: AddDiscriminatorsPass
-; CHECK-POSTLINK-O-NEXT: Running pass: PGOIndirectCallPromotion
+; CHECK-POSTLINK-O: Running pass: PGOIndirectCallPromotion
 ; CHECK-POSTLINK-O-NEXT: Running analysis: ProfileSummaryAnalysis
 ; CHECK-POSTLINK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-POSTLINK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis

diff  --git a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
index 8288a530e7299..e460b541ac5b1 100644
--- a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
@@ -23,9 +23,8 @@
 ; Suppress FileCheck --allow-unused-prefixes=false diagnostics.
 ; CHECK-NOEXT: {{^}}
 
-; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
-; CHECK-O-NEXT: Running pass: PGOIndirectCallPromotion
+; CHECK-EP-PIPELINE-START: Running pass: NoOpModulePass
+; CHECK-O: Running pass: PG

[PATCH] D148904: [Pipelines] Don't run ForceFunctionAttrs post-link

2023-04-24 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7e4c7632075: [Pipelines] Don't run ForceFunctionAttrs 
post-link (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D148904?vs=515639&id=516297#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148904/new/

https://reviews.llvm.org/D148904

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll


Index: llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
@@ -28,9 +28,8 @@
 ; Suppress FileCheck --allow-unused-prefixes=false diagnostics.
 ; CHECK-NOEXT: {{^}}
 
-; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
-; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass
+; CHECK-EP-PIPELINE-START: Running pass: NoOpModulePass
+; CHECK-O: Running pass: InferFunctionAttrsPass
 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
 ; CHECK-O-NEXT: Running pass: CoroEarlyPass
Index: llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
@@ -23,9 +23,8 @@
 ; Suppress FileCheck --allow-unused-prefixes=false diagnostics.
 ; CHECK-NOEXT: {{^}}
 
-; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
-; CHECK-O-NEXT: Running pass: PGOIndirectCallPromotion
+; CHECK-EP-PIPELINE-START: Running pass: NoOpModulePass
+; CHECK-O: Running pass: PGOIndirectCallPromotion
 ; CHECK-O-NEXT: Running analysis: ProfileSummaryAnalysis
 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis
Index: llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
@@ -36,11 +36,10 @@
 ; Suppress FileCheck --allow-unused-prefixes=false diagnostics.
 ; CHECK-NOEXT: {{^}}
 
-; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
-; CHECK-DIS-NEXT: Running analysis: InnerAnalysisManagerProxy
+; CHECK-EP-PIPELINE-START: Running pass: NoOpModulePass
+; CHECK-DIS: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-DIS-NEXT: Running pass: AddDiscriminatorsPass
-; CHECK-POSTLINK-O-NEXT: Running pass: PGOIndirectCallPromotion
+; CHECK-POSTLINK-O: Running pass: PGOIndirectCallPromotion
 ; CHECK-POSTLINK-O-NEXT: Running analysis: ProfileSummaryAnalysis
 ; CHECK-POSTLINK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-POSTLINK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis
Index: llvm/test/Other/new-pm-lto-defaults.ll
===
--- llvm/test/Other/new-pm-lto-defaults.ll
+++ llvm/test/Other/new-pm-lto-defaults.ll
@@ -31,7 +31,6 @@
 ; CHECK-O: Running pass: CrossDSOCFIPass
 ; CHECK-O-NEXT: Running pass: OpenMPOptPass
 ; CHECK-O-NEXT: Running pass: GlobalDCEPass
-; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
 ; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass
 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Module
 ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
Index: llvm/lib/Passes/PassBuilderPipelines.cpp
===
--- llvm/lib/Passes/PassBuilderPipelines.cpp
+++ llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1557,9 +1557,6 @@
 return MPM;
   }
 
-  // Force any function attributes we want the rest of the pipeline to observe.
-  MPM.addPass(ForceFunctionAttrsPass());
-
   // Add the core simplification pipeline.
   MPM.addPass(buildModuleSimplificationPipeline(
   Level, ThinOrFullLTOPhase::ThinLTOPostLink));
@@ -1626,9 +1623,6 @@
   // whole-program devirtualization and bitset lowering.
   MPM.addPass(GlobalDCEPass());
 
-  // Force any function attributes we want the rest of the pipeline to observe.
-  MPM.addPass(ForceFunctionAttrsPass());
-
   // Do basic inference of function attributes from known properties of system
   // libraries and other oracles.
   MPM.addPass(I

[PATCH] D147911: [5/11][POC][Clang][RISCV] Define tuple type variant of vlseg2e32ff

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516298.
eopXD added a comment.

Address comments from Craig.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147911/new/

https://reviews.llvm.org/D147911

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff_tuple.c
@@ -0,0 +1,39 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vlseg2e32ff_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], ptr noundef [[NEW_VL:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.nxv2i32.i64( poison,  poison, ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = insertvalue { ,  } poison,  [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:[[TMP4:%.*]] = insertvalue { ,  } [[TMP2]],  [[TMP3]], 1
+// CHECK-RV64-NEXT:[[TMP5:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP5]], ptr [[NEW_VL]], align 8
+// CHECK-RV64-NEXT:ret { ,  } [[TMP4]]
+//
+vint32m1x2_t test_vlseg2e32ff_v_tuple_i32m1(const int32_t *base, size_t *new_vl, size_t vl) {
+  return __riscv_vlseg2e32ff_v_tuple_i32m1(base, new_vl, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vlseg2e32ff_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]], ptr noundef [[NEW_VL:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.mask.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[MASK]], i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = insertvalue { ,  } poison,  [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:[[TMP4:%.*]] = insertvalue { ,  } [[TMP2]],  [[TMP3]], 1
+// CHECK-RV64-NEXT:[[TMP5:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP5]], ptr [[NEW_VL]], align 8
+// CHECK-RV64-NEXT:ret { ,  } [[TMP4]]
+//
+vint32m1x2_t test_vlseg2e32ff_v_tuple_i32m1_m(vbool32_t mask, const int32_t *base, size_t *new_vl, size_t vl) {
+  return __riscv_vlseg2e32ff_v_tuple_i32m1_m(mask, base, new_vl, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1824,11 +1824,79 @@
 }
   }
 }
+
+multiclass RVVUnitStridedSegLoadFFTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+  foreach nf = [2] in {
+let Name = op # nf # "e" # eew # "ff_v_tuple",
+OverloadedName = op # nf # "e" # eew # "ff_tuple",
+IRName = op # nf # "ff",
+MaskedIRName = op # nf # "ff_mask",
+NF = nf,
+ManualCodegen = [{
+{
+  assert(((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
+ (!IsMasked && (PolicyAttrs & RVV_VTA))) &&
+ "FIXME: Only handling default policy (TAMA) for now");
+
+  llvm::Type *ElementVectorType = cast(ResultType)->elements()[0];
+
+  IntrinsicTypes = {ElementVectorType, Ops.back()->getType()};
+  SmallVector Operands;
+
+  Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
+
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *MaskOperand = IsMasked ? Ops[0] : nullptr;
+  llvm::Value *PtrOperand = Ops[Offset];
+  unsigned NewVLOperandIdx = Offset + 1;
+  unsigned VLOperandIdx = Offset + 2;
+  llvm::Value *NewVLOperand = Ops[NewVLOperandIdx];
+  llvm::Value *VLOperand = Ops[VLOperandIdx];
+
+  Operands.push_back(PtrOperand);
+  if (MaskOperand)
+Operands.push_back(MaskOperand);
+  Operands.push_back(VLOperand);
+  if (IsMasked)
+Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
+
+  llvm::Function *F = CGM.getIntrinsic(ID, Intr

[PATCH] D147912: [6/11][POC][Clang][RISCV] Define tuple type variant of vlsseg2e32

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516301.
eopXD added a comment.

Address comment from Craig.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147912/new/

https://reviews.llvm.org/D147912

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c
@@ -0,0 +1,27 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vlsseg2e32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlsseg2.nxv2i32.i64( poison,  poison, ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vlsseg2e32_v_tuple_i32m1(const int32_t *base, ptrdiff_t bstride, size_t vl) {
+  return __riscv_vlsseg2e32_v_tuple_i32m1(base, bstride, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vlsseg2e32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlsseg2.mask.nxv2i32.i64( poison,  poison, ptr [[BASE]], i64 [[BSTRIDE]],  [[MASK]], i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vlsseg2e32_v_tuple_i32m1_m(vbool32_t mask, const int32_t *base, ptrdiff_t bstride, size_t vl) {
+  return __riscv_vlsseg2e32_v_tuple_i32m1_m(mask, base, bstride, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1891,12 +1891,67 @@
   }
 }
 
+multiclass RVVStridedSegLoadTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+  foreach nf = [2] in {
+let Name = op # nf # "e" # eew # "_v_tuple",
+OverloadedName = op # nf # "e" # eew # "_tuple",
+IRName = op # nf,
+MaskedIRName = op # nf # "_mask",
+NF = nf,
+ManualCodegen = [{
+{
+  assert(((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
+ (!IsMasked && (PolicyAttrs & RVV_VTA))) &&
+ "FIXME: Only handling default policy (TAMA) for now");
+
+  llvm::Type *ElementVectorType = cast(ResultType)->elements()[0];
+
+  IntrinsicTypes = {ElementVectorType, Ops.back()->getType()};
+  SmallVector Operands;
+
+  Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
+
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *MaskOperand = IsMasked ? Ops[0] : nullptr;
+  llvm::Value *PtrOperand = IsMasked ? Ops[1] : Ops[0];
+  unsigned StrideOperandIdx = Offset + 1;
+  unsigned VLOperandIdx = Offset + 2;
+  llvm::Value *StrideOperand = Ops[StrideOperandIdx];
+  llvm::Value *VLOperand = Ops[VLOperandIdx];
+
+  Operands.push_back(PtrOperand);
+  Operands.push_back(StrideOperand);
+  if (MaskOperand)
+Operands.push_back(MaskOperand);
+  Operands.push_back(VLOperand);
+  if (IsMasked)
+Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
+
+  llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
+  llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
+
+  if (ReturnValue.isNull())
+return LoadValue;
+  else
+return Builder.CreateStore(LoadValue, ReturnValue.getValue());  
+}
+}] in {
+  defvar T = "(Tuple:" # nf # ")";
+  def : RVVBuiltin<"v", T # "vPCet", type>;
+  }
+}
+  }
+}
+
 // TODO: Extend for policy
 let UnMaskedPolicyScheme = NonePolicy,
 MaskedPolicyScheme = NonePolicy,
 IsTuple = true in {
 defm : RVVUnitStridedSegLoadTuple<"vlseg">;
 defm : RVVUnitStridedSegLoadFFTuple<"vlseg">;
+defm : RVVStridedSegLoadTuple<"vlsseg">;
 }
 
 let UnMaskedPolicyScheme = NonePolicy,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147913: [7/11][POC][Clang][RISCV] Define tuple type variant of vssseg2e32

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516302.
eopXD added a comment.

Address comment from Craig.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147913/new/

https://reviews.llvm.org/D147913

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_tuple_i32m1(int32_t *base, ptrdiff_t bstride, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_v_tuple_i32m1(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.mask.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]],  [[MASK]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_tuple_i32m1_m(vbool32_t mask, int32_t *base, ptrdiff_t bstride, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_v_tuple_i32m1_m(mask, base, bstride, v_tuple, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1945,6 +1945,58 @@
   }
 }
 
+multiclass RVVStridedSegStoreTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+  foreach nf = [2] in {
+let Name = op # nf # "e" # eew # "_v_tuple",
+OverloadedName = op # nf # "e" # eew # "_tuple",
+IRName = op # nf,
+MaskedIRName = op # nf # "_mask",
+NF = nf,
+HasMaskedOffOperand = false,
+MaskedPolicyScheme = NonePolicy,
+ManualCodegen = [{
+{
+  // Masked
+  // Builtin: (mask, ptr, stride, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
+  // Unmasked
+  // Builtin: (ptr, stride, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, stride, vl)
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *MaskOperand = IsMasked ? Ops[0] : nullptr;
+  llvm::Value *PtrOperand = Ops[Offset];
+  unsigned StrideOperandIdx = Offset + 1;
+  unsigned VTupleOperandIdx = Offset + 2;
+  unsigned VLOperandIdx = Offset + 3;
+  llvm::Value *StrideOperand = Ops[StrideOperandIdx];
+  llvm::Value *VTupleOperand = Ops[VTupleOperandIdx];
+  llvm::Value *VLOperand = Ops[VLOperandIdx];
+
+  SmallVector Operands;
+  for (unsigned I = 0; I < NF; ++I) {
+llvm::Value *V = Builder.CreateExtractValue(VTupleOperand, {I});
+Operands.push_back(V);
+  }
+  Operands.push_back(PtrOperand);
+  Operands.push_back(StrideOperand);
+  if (MaskOperand)
+Operands.push_back(MaskOperand);
+  Operands.push_back(VLOperand);
+
+  IntrinsicTypes = {Operands[0]->getType(), Operands.back()->getType()};
+  llvm::Function *F = CGM.getIntrinsic(ID

[PATCH] D147914: [8/11][POC][Clang][RISCV] Define tuple type variant of vloxseg2ei32 vluxseg2ei32

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516306.
eopXD marked an inline comment as done.
eopXD added a comment.

Address comments from Craig.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147914/new/

https://reviews.llvm.org/D147914

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vluxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vluxseg2.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vluxseg2ei32_v_tuple_i32m1(const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vluxseg2ei32_v_tuple_i32m1(base, bindex, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vluxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vluxseg2.mask.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]],  [[MASK]], i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vluxseg2ei32_v_tuple_i32m1_m(vbool32_t mask, const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vluxseg2ei32_v_tuple_i32m1_m(mask, base, bindex, vl);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vloxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vloxseg2.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vloxseg2ei32_v_tuple_i32m1(const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vloxseg2ei32_v_tuple_i32m1(base, bindex, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vloxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vloxseg2.mask.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]],  [[MASK]], i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vloxseg2ei32_v_tuple_i32m1_m(vbool32_t mask, const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vloxseg2ei32_v_tuple_i32m1_m(mask, base, bindex, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1997,6 +1997,63 @@
   }
 }
 
+multiclass RVVIndexedSegLoadTuple {
+  foreach type = ["i"] in {
+foreach eew_info = [["32", "(Log2EEW:5)"]] in {
+  defvar eew = eew_info[0];
+  defvar eew_type = eew_info[1];
+  foreach nf = [2] in {
+let Name = op # nf # "ei" # eew # "_v_tuple",
+OverloadedName = op # nf # "ei" # eew # "

[PATCH] D147610: [RISCV][MC] Add support for experimental Zfbfmin extension

2023-04-24 Thread Jun Sha via Phabricator via cfe-commits
joshua-arch1 added a comment.

What's the difference between fcvt.bf16.s and fcvt.h.s? In your implementation, 
it seems that you just replace fcvt.h.s with fcvt.bf16.s in Zfbfmin extension.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147610/new/

https://reviews.llvm.org/D147610

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


[clang] 0a113c4 - [clang] Mark CWG2009 as N/A

2023-04-24 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-24T11:53:04+03:00
New Revision: 0a113c4c50f65a7d26d20be84bfb56562154753f

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

LOG: [clang] Mark CWG2009 as N/A

[[https://wg21.link/p1787 | P1787]]: CWG2331 is resolved by defining lookup 
from complete-class contexts and out-of-line member definitions. The rest of 
CWG2009 is resolved by making it ill-formed NDR for forward lookup outside a 
complete-class context to change the results (before overload resolution, to 
avoid differences in instantiation).
Wording: The result of the search is the declaration set of S(N, T). If it is 
an invalid set, the program is ill-formed. If it differs from the result of a 
search in T for N from immediately after the class-specifier of T, the program 
is ill-formed, no diagnostic required. ([class.member.lookup]/7)

Reviewed By: #clang-language-wg, shafik

Differential Revision: https://reviews.llvm.org/D148263

Added: 


Modified: 
clang/test/CXX/drs/dr20xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index 2d3398cda5413..aea1e23527181 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -19,6 +19,8 @@ int a = b2[0]; // expected-error {{does not provide a 
subscript operator}}
 int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
 }
 
+// dr2009: na
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 855a4408fc245..29532e4e42299 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -11861,7 +11861,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2009.html";>2009
 CD6
 Unclear specification of class scope
-Unknown
+N/A
   
   
 https://cplusplus.github.io/CWG/issues/2010.html";>2010



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


[PATCH] D148263: [clang] Mark CWG2009 as N/A

2023-04-24 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a113c4c50f6: [clang] Mark CWG2009 as N/A (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148263/new/

https://reviews.llvm.org/D148263

Files:
  clang/test/CXX/drs/dr20xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11861,7 +11861,7 @@
 https://cplusplus.github.io/CWG/issues/2009.html";>2009
 CD6
 Unclear specification of class scope
-Unknown
+N/A
   
   
 https://cplusplus.github.io/CWG/issues/2010.html";>2010
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -19,6 +19,8 @@
 int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
 }
 
+// dr2009: na
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11861,7 +11861,7 @@
 https://cplusplus.github.io/CWG/issues/2009.html";>2009
 CD6
 Unclear specification of class scope
-Unknown
+N/A
   
   
 https://cplusplus.github.io/CWG/issues/2010.html";>2010
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -19,6 +19,8 @@
 int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
 }
 
+// dr2009: na
+
 namespace dr2026 { // dr2026: 11
   template struct X {};
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145262: [clang-format] Treat AttributeMacros more like attribute macros

2023-04-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.h:231
   /// Used e.g. to break like:
+  /// ```
   /// functionCall(Parameter, otherCall(

If you want this to look like code you need to use \code \endcode


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145262/new/

https://reviews.llvm.org/D145262

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


[PATCH] D147915: [9/11][POC][Clang][RISCV] Define tuple type variant of vsoxseg2ei32 vsuxseg2ei32

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516313.
eopXD added a comment.

Address comment from Craig.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147915/new/

https://reviews.llvm.org/D147915

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32_tuple.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsuxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsuxseg2.nxv2i32.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsuxseg2ei32_v_tuple_i32m1(int32_t *base, vuint32m1_t bindex, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsuxseg2ei32_v_tuple_i32m1(base, bindex, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsuxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsuxseg2.mask.nxv2i32.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]],  [[BINDEX]],  [[MASK]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsuxseg2ei32_v_tuple_i32m1_m(vbool32_t mask, int32_t *base, vuint32m1_t bindex, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsuxseg2ei32_v_tuple_i32m1_m(mask, base, bindex, v_tuple, vl);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32_tuple.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsoxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsoxseg2.nxv2i32.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsoxseg2ei32_v_tuple_i32m1(int32_t *base, vuint32m1_t bindex, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsoxseg2ei32_v_tuple_i32m1(base, bindex, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsoxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  

[PATCH] D145262: [clang-format] Treat AttributeMacros more like attribute macros

2023-04-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.h:231
   /// Used e.g. to break like:
+  /// ```
   /// functionCall(Parameter, otherCall(

MyDeveloperDay wrote:
> If you want this to look like code you need to use \code \endcode
Ok my bad this is the ContinuationIndenter.h, not Format.h


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145262/new/

https://reviews.llvm.org/D145262

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


[clang] 40136ec - [clang] Make access to submodules via `iterator_range`

2023-04-24 Thread via cfe-commits

Author: Stoorx
Date: 2023-04-24T12:05:59+03:00
New Revision: 40136ecefc0a542da7d0f1736c51325edc5539b4

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

LOG: [clang] Make access to submodules via `iterator_range`

In file `clang/lib/Basic/Module.cpp` the `Module` class had `submodule_begin()` 
and `submodule_end()` functions to retrieve corresponding iterators for private 
vector of Modules. This commit removes mentioned functions, and replaces all of 
theirs usages with `submodules()` function and range-based for-loops.

Differential Revision: https://reviews.llvm.org/D148954

Added: 


Modified: 
clang-tools-extra/modularize/CoverageChecker.cpp
clang-tools-extra/modularize/ModularizeUtilities.cpp
clang/include/clang/Basic/Module.h
clang/lib/Basic/Module.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/CoverageChecker.cpp 
b/clang-tools-extra/modularize/CoverageChecker.cpp
index 80e5749cf4172..900a88df68ca2 100644
--- a/clang-tools-extra/modularize/CoverageChecker.cpp
+++ b/clang-tools-extra/modularize/CoverageChecker.cpp
@@ -226,9 +226,8 @@ bool CoverageChecker::collectModuleHeaders(const Module 
&Mod) {
   ModuleMapHeadersSet.insert(ModularizeUtilities::getCanonicalPath(
 Header.Entry->getName()));
 
-  for (auto MI = Mod.submodule_begin(), MIEnd = Mod.submodule_end();
-   MI != MIEnd; ++MI)
-collectModuleHeaders(**MI);
+  for (auto *Submodule : Mod.submodules())
+collectModuleHeaders(*Submodule);
 
   return true;
 }

diff  --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 3bf761c0a22c3..e3f9a6eba8f6a 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -346,9 +346,8 @@ bool ModularizeUtilities::collectModuleHeaders(const 
clang::Module &Mod) {
   DependentsVector UmbrellaDependents;
 
   // Recursively do submodules.
-  for (auto MI = Mod.submodule_begin(), MIEnd = Mod.submodule_end();
-   MI != MIEnd; ++MI)
-collectModuleHeaders(**MI);
+  for (auto *Submodule : Mod.submodules())
+collectModuleHeaders(*Submodule);
 
   if (const FileEntry *UmbrellaHeader = Mod.getUmbrellaHeader().Entry) {
 std::string HeaderPath = getCanonicalPath(UmbrellaHeader->getName());

diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index c0c99eb8b6d62..7ed9a2b2ca386 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -741,16 +741,11 @@ class alignas(8) Module {
   using submodule_iterator = std::vector::iterator;
   using submodule_const_iterator = std::vector::const_iterator;
 
-  submodule_iterator submodule_begin() { return SubModules.begin(); }
-  submodule_const_iterator submodule_begin() const {return SubModules.begin();}
-  submodule_iterator submodule_end()   { return SubModules.end(); }
-  submodule_const_iterator submodule_end() const { return SubModules.end(); }
-
   llvm::iterator_range submodules() {
-return llvm::make_range(submodule_begin(), submodule_end());
+return llvm::make_range(SubModules.begin(), SubModules.end());
   }
   llvm::iterator_range submodules() const {
-return llvm::make_range(submodule_begin(), submodule_end());
+return llvm::make_range(SubModules.begin(), SubModules.end());
   }
 
   /// Appends this module's list of exported modules to \p Exported.

diff  --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 9c4c83486c2d2..e5994a7cc2fad 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -59,9 +59,8 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, 
Module *Parent,
 }
 
 Module::~Module() {
-  for (submodule_iterator I = submodule_begin(), IEnd = submodule_end();
-   I != IEnd; ++I) {
-delete *I;
+  for (auto *Submodule : SubModules) {
+delete Submodule;
   }
 }
 
@@ -339,11 +338,9 @@ void Module::markUnavailable(bool Unimportable) {
 
 Current->IsAvailable = false;
 Current->IsUnimportable |= Unimportable;
-for (submodule_iterator Sub = Current->submodule_begin(),
- SubEnd = Current->submodule_end();
- Sub != SubEnd; ++Sub) {
-  if (needUpdate(*Sub))
-Stack.push_back(*Sub);
+for (auto *Submodule : Current->submodules()) {
+  if (needUpdate(Submodule))
+Stack.push_back(Submodule);
 }
   }
 }
@@ -550,14 +547,13 @@ void Module::p

[PATCH] D148954: [clang] Make access to submodules via `iterator_range`

2023-04-24 Thread Sviatoslav Osipov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40136ecefc0a: [clang] Make access to submodules via 
`iterator_range` (authored by Stoorx).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148954/new/

https://reviews.llvm.org/D148954

Files:
  clang-tools-extra/modularize/CoverageChecker.cpp
  clang-tools-extra/modularize/ModularizeUtilities.cpp
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -500,8 +500,7 @@
   // Submodule order depends on order of header includes for inferred submodules
   // we don't care about the exact order, so sort so that it's consistent across
   // TUs to improve sharing.
-  SmallVector Submodules(M->submodule_begin(),
- M->submodule_end());
+  SmallVector Submodules(M->submodules());
   llvm::stable_sort(Submodules, [](const Module *A, const Module *B) {
 return A->Name < B->Name;
   });
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1903,18 +1903,16 @@
 SavedStrings.push_back(FilenameDup.data());
 
 HeaderFileInfoTrait::key_type Key = {
-  FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
-};
+FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0};
 HeaderFileInfoTrait::data_type Data = {
-  Empty, {}, {M, ModuleMap::headerKindToRole(U.Kind)}
-};
+Empty, {}, {M, ModuleMap::headerKindToRole(U.Kind)}};
 // FIXME: Deal with cases where there are multiple unresolved header
 // directives in different submodules for the same header.
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
   }
-
-  Worklist.append(M->submodule_begin(), M->submodule_end());
+  auto SubmodulesRange = M->submodules();
+  Worklist.append(SubmodulesRange.begin(), SubmodulesRange.end());
 }
   }
 
@@ -2701,9 +2699,8 @@
 /// given module).
 static unsigned getNumberOfModules(Module *Mod) {
   unsigned ChildModules = 0;
-  for (auto Sub = Mod->submodule_begin(), SubEnd = Mod->submodule_end();
-   Sub != SubEnd; ++Sub)
-ChildModules += getNumberOfModules(*Sub);
+  for (auto *Submodule : Mod->submodules())
+ChildModules += getNumberOfModules(Submodule);
 
   return ChildModules + 1;
 }
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4309,16 +4309,13 @@
 /*IsInclusionDirective=*/false);
 // Enumerate submodules.
 if (Mod) {
-  for (Module::submodule_iterator Sub = Mod->submodule_begin(),
-  SubEnd = Mod->submodule_end();
-   Sub != SubEnd; ++Sub) {
-
+  for (auto *Submodule : Mod->submodules()) {
 Builder.AddTypedTextChunk(
-Builder.getAllocator().CopyString((*Sub)->Name));
+Builder.getAllocator().CopyString(Submodule->Name));
 Results.AddResult(Result(
 Builder.TakeString(), CCP_Declaration, CXCursor_ModuleImportDecl,
-(*Sub)->isAvailable() ? CXAvailability_Available
-  : CXAvailability_NotAvailable));
+Submodule->isAvailable() ? CXAvailability_Available
+ : CXAvailability_NotAvailable));
   }
 }
   }
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1240,7 +1240,8 @@
 ModMap.resolveConflicts(Mod, /*Complain=*/false);
 
 // Queue the submodules, so their exports will also be resolved.
-Stack.append(Mod->submodule_begin(), Mod->submodule_end());
+auto SubmodulesRange = Mod->submodules();
+Stack.append(SubmodulesRange.begin(), SubmodulesRange.end());
   }
 }
 
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -429,11 +429,9 @@
   }
 
   // Recurse into submodules.
-  for (clang::Module::submodule_iterator Su

[clang] 368112e - [clang] Remove unnecessary virtual inheritance in `TargetInfo`

2023-04-24 Thread via cfe-commits

Author: Stoorx
Date: 2023-04-24T12:14:30+03:00
New Revision: 368112e2024aabc91592cd21347968787919f044

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

LOG: [clang] Remove unnecessary virtual inheritance in `TargetInfo`

Since the `TargetInfo` has no diamond-like inheritance diagram,
the `virtual` keyword is not necessary.

Differential Revision: https://reviews.llvm.org/D148961

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 6de5d90b12634..9e4d099b2e4d0 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -202,7 +202,7 @@ enum OpenCLTypeKind : uint8_t {
 
 /// Exposes information about the current target.
 ///
-class TargetInfo : public virtual TransferrableTargetInfo,
+class TargetInfo : public TransferrableTargetInfo,
public RefCountedBase {
   std::shared_ptr TargetOpts;
   llvm::Triple Triple;



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


[PATCH] D148961: [clang] Remove unnecessary virtual inheritance in `TargetInfo`

2023-04-24 Thread Sviatoslav Osipov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG368112e2024a: [clang] Remove unnecessary virtual inheritance 
in `TargetInfo` (authored by Stoorx).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148961/new/

https://reviews.llvm.org/D148961

Files:
  clang/include/clang/Basic/TargetInfo.h


Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -202,7 +202,7 @@
 
 /// Exposes information about the current target.
 ///
-class TargetInfo : public virtual TransferrableTargetInfo,
+class TargetInfo : public TransferrableTargetInfo,
public RefCountedBase {
   std::shared_ptr TargetOpts;
   llvm::Triple Triple;


Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -202,7 +202,7 @@
 
 /// Exposes information about the current target.
 ///
-class TargetInfo : public virtual TransferrableTargetInfo,
+class TargetInfo : public TransferrableTargetInfo,
public RefCountedBase {
   std::shared_ptr TargetOpts;
   llvm::Triple Triple;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 42d758b - [clang] Return `std::string_view` from `TargetInfo::getClobbers()`

2023-04-24 Thread via cfe-commits

Author: Stoorx
Date: 2023-04-24T12:16:54+03:00
New Revision: 42d758bfa690d898918816509490a55bc50779df

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

LOG: [clang] Return `std::string_view` from `TargetInfo::getClobbers()`

Change the return type of `getClobbers` function from `const char*`
to `std::string_view`. Update the function usages in CodeGen module.

The reasoning of these changes is to remove unsafe `const char*`
strings and prevent unnecessary allocations for constructing the
`std::string` in usages of `getClobbers()` function.

Differential Revision: https://reviews.llvm.org/D148799

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/ARC.h
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h
clang/lib/Basic/Targets/AVR.h
clang/lib/Basic/Targets/BPF.h
clang/lib/Basic/Targets/CSKY.h
clang/lib/Basic/Targets/DirectX.h
clang/lib/Basic/Targets/Hexagon.h
clang/lib/Basic/Targets/Lanai.h
clang/lib/Basic/Targets/Le64.h
clang/lib/Basic/Targets/LoongArch.h
clang/lib/Basic/Targets/M68k.cpp
clang/lib/Basic/Targets/M68k.h
clang/lib/Basic/Targets/MSP430.h
clang/lib/Basic/Targets/Mips.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/PNaCl.h
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/RISCV.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/Sparc.h
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/VE.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.h
clang/lib/Basic/Targets/XCore.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGStmt.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 9e4d099b2e4d0..741a62e18f3ce 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1178,7 +1178,7 @@ class TargetInfo : public TransferrableTargetInfo,
   }
 
   /// Returns a string of target-specific clobbers, in LLVM format.
-  virtual const char *getClobbers() const = 0;
+  virtual std::string_view getClobbers() const = 0;
 
   /// Returns true if NaN encoding is IEEE 754-2008.
   /// Only MIPS allows a 
diff erent encoding.

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 1711e16b46cdc..67ba5f6b35145 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1295,7 +1295,7 @@ bool AArch64TargetInfo::validateConstraintModifier(
   }
 }
 
-const char *AArch64TargetInfo::getClobbers() const { return ""; }
+std::string_view AArch64TargetInfo::getClobbers() const { return ""; }
 
 int AArch64TargetInfo::getEHDataRegisterNumber(unsigned RegNo) const {
   if (RegNo == 0)

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index c973efc21bde2..967a888f6b6f8 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -192,7 +192,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool
   validateConstraintModifier(StringRef Constraint, char Modifier, unsigned 
Size,
  std::string &SuggestedModifier) const override;
-  const char *getClobbers() const override;
+  std::string_view getClobbers() const override;
 
   StringRef getConstraintRegister(StringRef Constraint,
   StringRef Expression) const override {

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index ab8482b3df9a6..0c65fa6c64463 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -117,7 +117,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   bool hasBFloat16Type() const override { return isAMDGCN(getTriple()); }
   const char *getBFloat16Mangling() const override { return "u6__bf16"; };
 
-  const char *getClobbers() const override { return ""; }
+  std::string_view getClobbers() const override { return ""; }
 
   ArrayRef getGCCRegNames() const override;
 

diff  --git a/clang/lib/Basic/Targets/ARC.h b/clang/lib/Basic/Targets/ARC.h
index 60435ff824c52..fcbfdd6eec586 100644
--- a/clang/lib/Basic/Targets/ARC.h
+++ b/clang/lib/Basic/Targets/ARC.h
@@ -48,7 +48,7 @@ class LLVM_LIBRARY_VISIBILITY ARCTargetInfo : public 
TargetInfo {
 return TargetInfo::VoidPtrBuiltinVaList;
   }
 
-  const char *getClobbers() const override { return ""; }
+  std::string_view getClobbers() const override { return ""; }
 
   ArrayRef getGCCRegNames() const override {
 

[PATCH] D148799: [clang] Return `std::string_view` from `TargetInfo::getClobbers()`

2023-04-24 Thread Sviatoslav Osipov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42d758bfa690: [clang] Return `std::string_view` from 
`TargetInfo::getClobbers()` (authored by Stoorx).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148799/new/

https://reviews.llvm.org/D148799

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARC.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/AVR.h
  clang/lib/Basic/Targets/BPF.h
  clang/lib/Basic/Targets/CSKY.h
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/Hexagon.h
  clang/lib/Basic/Targets/Lanai.h
  clang/lib/Basic/Targets/Le64.h
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Basic/Targets/M68k.cpp
  clang/lib/Basic/Targets/M68k.h
  clang/lib/Basic/Targets/MSP430.h
  clang/lib/Basic/Targets/Mips.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/PNaCl.h
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/Sparc.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/VE.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Basic/Targets/XCore.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGStmt.cpp

Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2779,7 +2779,7 @@
  "unwind clobber can't be used with asm goto");
 
   // Add machine specific clobbers
-  std::string MachineClobbers = getTarget().getClobbers();
+  std::string_view MachineClobbers = getTarget().getClobbers();
   if (!MachineClobbers.empty()) {
 if (!Constraints.empty())
   Constraints += ',';
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -939,7 +939,7 @@
 
   // Build the constraints. FIXME: We should support immediates when possible.
   std::string Constraints = "={@ccc},r,r,~{cc},~{memory}";
-  std::string MachineClobbers = CGF.getTarget().getClobbers();
+  std::string_view MachineClobbers = CGF.getTarget().getClobbers();
   if (!MachineClobbers.empty()) {
 Constraints += ',';
 Constraints += MachineClobbers;
@@ -1082,7 +1082,7 @@
   AsmOS << "$0, ${1:y}";
 
   std::string Constraints = "=r,*Z,~{memory}";
-  std::string MachineClobbers = CGF.getTarget().getClobbers();
+  std::string_view MachineClobbers = CGF.getTarget().getClobbers();
   if (!MachineClobbers.empty()) {
 Constraints += ',';
 Constraints += MachineClobbers;
Index: clang/lib/Basic/Targets/XCore.h
===
--- clang/lib/Basic/Targets/XCore.h
+++ clang/lib/Basic/Targets/XCore.h
@@ -49,7 +49,7 @@
 return TargetInfo::VoidPtrBuiltinVaList;
   }
 
-  const char *getClobbers() const override { return ""; }
+  std::string_view getClobbers() const override { return ""; }
 
   ArrayRef getGCCRegNames() const override {
 static const char *const GCCRegNames[] = {
Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -262,7 +262,7 @@
StringRef Constraint, unsigned Size) const;
 
   std::string convertConstraint(const char *&Constraint) const override;
-  const char *getClobbers() const override {
+  std::string_view getClobbers() const override {
 return "~{dirflag},~{fpsr},~{flags}";
   }
 
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -130,7 +130,7 @@
 return false;
   }
 
-  const char *getClobbers() const final { return ""; }
+  std::string_view getClobbers() const final { return ""; }
 
   bool isCLZForZeroUndef() const final { return false; }
 
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -69,7 +69,7 @@
 }
   }
 
-  const char *getClobbers() const override { return ""; }
+  std::string_view getClobbers() const override { return ""; }
 
   ArrayRef getGCCRegNames() const override {
 static const char *const GCCRegNames[] = {
Index: clang/lib/Basic/Targets/TCE.h
===
--- clang/lib/Basic/Targets/TCE.h
+++ clang/lib/Basic/Targets/TCE.h
@@ -99,7 +99,7 @@
 return std::nullopt;
   }
 
-  const char *getClobbers() const override { return ""; }
+  std::string_view getClobbe

[PATCH] D148211: [clang][tests] Fix Flang driver tests for Windows

2023-04-24 Thread Ádám Kallai via Phabricator via cfe-commits
kaadam added a comment.

Bryan, thanks for the review. Is another acceptance required for merging? May I 
ask you to commit the change? I do not have commit access. Thanks, Adam


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148211/new/

https://reviews.llvm.org/D148211

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


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-04-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

To conclude the review, please respond to the "Not Done" inline comments, and 
mark them "Done" if you think they are resolved.
Thank you for your patience.




Comment at: clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp:108-109
+  if ((stateNotZero && stateZero)) {
+std::vector taintedSyms = getTaintedSymbols(C.getState(), *DV);
+if (!taintedSyms.empty()) {
+  reportTaintBug("Division by a tainted value, possibly zero", stateZero, 
C,

dkrupp wrote:
> steakhal wrote:
> > 
> We cannot get rid off the getTaintedSymbols() call, as we need to pass all 
> tainted symbols to reportTaintBug if we want to track back multiple 
> variables. taintedSyms is a parameter of reportTaintBug(...)
Yes, makes sense. mb.
One more thing: if `reportTaintBug()` takes the `taintedSyms` vector 
"by-value", you should express your intent by `std::move()`-ing your collection 
expressing that it's meant to be consumed instead of taking a copy.
Otherwise, you could express this intent if the `reportTaintBug()` take a 
//view// type for the collection, such as `llvm::ArrayRef` - which 
would neither copy nor move from the callsite's vector, being more performant 
and expressive.

I get that this vector is small and bugreport construction will dominate the 
runtime anyway so I'm not complaining about this specific case, I'm just noting 
this for the next time. So, here I'm not expecting any actions.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:875-879
+  std::vector TaintedSyms = getTaintedSymbols(State, *V);
+  if (!TaintedSyms.empty()) {
+TaintedSymbols.push_back(TaintedSyms[0]);
+TaintedIndexes.push_back(ArgNum);
+  }

dkrupp wrote:
> steakhal wrote:
> > In these cases, the code would acquire all the tainted subsymbols, which 
> > then we throw away and keep only the first one.
> > This is why I suggested the approach I did I'm my last review.
> I think this suggested solution would not be correct here, as ArgSym might 
> not be the actual _tainted_ symbol (inside a more complex expression).
> 
> So I would prefer to leave it like this for correctness.
Okay, I also checked out the code and verified this. Indeed we would have 
failing tests with my recommendation.
I still think it's suboptimal. This is somewhat related to the tainted API. It 
shouldn't make sense to have tainted regions in the first place, which bites 
here again. Let's keep it as-is, no actions are required.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:947-948
+  if (!TaintedArgSyms.empty()) {
+TaintedSymbols.insert(TaintedSymbols.begin(), TaintedArgSyms.begin(),
+  TaintedArgSyms.end());
+TaintedIndexes.push_back(I);

steakhal wrote:
> 
I observed you didn't take any action about this suggestion.
It leaves me wonder if this suggestion - in general - makes sense or if there 
are other reasons what I cannot foresee.
I've seen you using the fully spelled-out version in total 8 times.
Shouldn't we prefer the shorter, more expressive version instead?



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:920
   /// Check for taint filters.
   ForEachCallArg([this, &C, &State](ArgIdxTy I, const Expr *E, SVal S) {
 if (FilterArgs.contains(I)) {

This unused variable generates a compiler warning.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:995
+  const NoteTag *InjectionTag = taintOriginTrackerTag(
+  C, TaintedSymbols, TaintedIndexes, Call.getCalleeStackFrame(0));
+  C.addTransition(State, InjectionTag);





Comment at: clang/lib/StaticAnalyzer/Checkers/Taint.cpp:275
+TaintedSymbols.push_back(*SI);
+if (returnFirstOnly && !TaintedSymbols.empty())
+  return TaintedSymbols; // return early if needed

The second part of the conjunction should be tautologically true.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144269/new/

https://reviews.llvm.org/D144269

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


[PATCH] D133863: [RISCV] Add MC support of RISCV zcmt Extension

2023-04-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:903
+return createStringError(errc::invalid_argument,
+ "zcmt is not allowed when c is specified");
+

craig.topper wrote:
> Extension names should be in single quotes.
> 
> Should we use `'zcmt' and 'c' extensions are incompatible` to match line 863?
My understanding is Zcmt still compatible with C if no D/Zcd is present.

`rv32ic_zcmt` in theory is valid combination according to spec[1].

[1] 
https://github.com/riscv/riscv-code-size-reduction/blob/main/Zc-specification/Zc.adoc#19-zcmt

> This extension reuses some encodings from c.fsdsp. Therefore it is 
> incompatible with Zcd, which is included when C and D extensions are both 
> present.







Comment at: llvm/lib/Target/RISCV/RISCVFeatures.td:354-360
+def FeatureStdExtZcmt
+: SubtargetFeature<"experimental-zcmt", "HasStdExtZcmt", "true",
+   "'Zcmt' (table jump instuctions for code-size 
reduction)", 
+   [FeatureStdExtZca, FeatureStdExtZicsr]>; 
+def HasStdExtZcmt : Predicate<"Subtarget->hasStdExtZcmt() && 
!Subtarget->hasStdExtC()">,
+   AssemblerPredicate<(all_of FeatureStdExtZcmt, (not 
FeatureStdExtC)),
+   "'Zcmt' (table jump instuctions for code-size 
reduction)">;

I would suggest do not check incompatible stuffs here, let RISCVISAInfo handle 
that, we already did that for others like `Zfinx` and `F`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133863/new/

https://reviews.llvm.org/D133863

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


[PATCH] D148954: [clang] Make access to submodules via `iterator_range`

2023-04-24 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/include/clang/Basic/Module.h:744-747
-  submodule_iterator submodule_begin() { return SubModules.begin(); }
-  submodule_const_iterator submodule_begin() const {return SubModules.begin();}
-  submodule_iterator submodule_end()   { return SubModules.end(); }
-  submodule_const_iterator submodule_end() const { return SubModules.end(); }

There was no need to delete these, they were useful (e.g. the change in 
Sema.cpp).
Well, I guess I'm late.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148954/new/

https://reviews.llvm.org/D148954

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


[PATCH] D148949: [dataflow] HTMLLogger - show the value of the current expr

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:96
+for (const auto& Prop : V.properties())
+  JOS.attributeObject(Prop.first(), [&] { dump(*Prop.second); });
+

IIUC, this places properties on the current HTML element as attributes, just 
like the built-in attributes that we add for other purposes (e.g. "value_id", 
"kind").

  - What happens if we have a property whose name conflicts with one of the 
built-in attributes?
  - Even if we don't have a naming conflict, I think it could be potentially 
confusing to have user-defined properties appear in the same list and in the 
same way as built-in attributes.

Suggestion: Can we nest all properties inside of a "properties" attribute?

Edit: Having looked at the HTML template now, I see that we exclude certain 
attributes there ('kind', 'value_id', 'type', 'location') when listing 
properties. I still think naming conflicts are a potential problem though. I 
think it would also be clearer to explicitly pick the properties out of a 
`properties` attribute rather than excluding a blocklist of attributes.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:121-123
+  for (const auto &Child : cast(V).children())
+JOS.attributeObject(Child.first->getNameAsString(),
+[&] { dump(*Child.second); });





Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:122
+  for (const auto &Child : cast(V).children())
+JOS.attributeObject(Child.first->getNameAsString(),
+[&] { dump(*Child.second); });

Same rationale as for properties above: can we nest the fields inside of a 
`fields` attribute?

I think it would also be useful to distinguish between properties and fields in 
the HTML output; probably not with another nesting level (yikes!), but just 
rendered differently. This could easily be done if they were separated into 
`properties` and `fields` attributes.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:149
+case Value::Kind::Biconditional: {
+  auto &VV = cast(V);
+  JOS.attributeObject("lhs", [&] { dump(VV.getLeftSubValue()); });





Comment at: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp:179
   EXPECT_THAT(Logs[0], HasSubstr("LocToVal")) << "has built-in lattice dump";
+  EXPECT_THAT(Logs[0], HasSubstr("\"type\": \"int\"")) << "has value dump";
 }

Can you add some additional tests for the following?

  - Pointers
  - References
  - Properties
  - Struct fields

Ideally, other value kinds too (see copy-paste error above for 
`BiconditionalValue`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148949/new/

https://reviews.llvm.org/D148949

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


[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-04-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: llvm/test/CodeGen/RISCV/O0-pipeline.ll:66-67
 ; CHECK-NEXT:   Stack Frame Layout Analysis
+; CHECK-NEXT:   RISC-V Zce move merging pass 
+; CHECK-NEXT:   RISC-V Zce Push/Pop optimization pass 
 ; CHECK-NEXT:   RISC-V pseudo instruction expansion pass

This should split out into separated patch?



Comment at: llvm/test/CodeGen/RISCV/O3-pipeline.ll:179-180
 ; CHECK-NEXT:   Stack Frame Layout Analysis
+; CHECK-NEXT:   RISC-V Zce move merging pass 
+; CHECK-NEXT:   RISC-V Zce Push/Pop optimization pass 
 ; CHECK-NEXT:   RISC-V pseudo instruction expansion pass

This should split out into separated patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132819/new/

https://reviews.llvm.org/D132819

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


[PATCH] D147916: [10/11][POC][Clang][RISCV] Define vget for tuple type

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516338.
eopXD added a comment.
Herald added a subscriber: arphaman.

Address comment from Craig.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147916/new/

https://reviews.llvm.org/D147916

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
@@ -339,3 +339,8 @@
   // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
   return __riscv_vget_v_f16m8_f16m4(src, 2);
 }
+
+vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src, size_t index) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return __riscv_vget_v_i32m1x2_i32m1(src, 2);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
@@ -0,0 +1,20 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local  @test_vget_v_i32m1x2_i32m1
+// CHECK-RV64-SAME: ( [[SRC_COERCE0:%.*]],  [[SRC_COERCE1:%.*]], i64 noundef [[INDEX:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[SRC_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[SRC_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:ret  [[TMP2]]
+//
+vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src, size_t index) {
+  return __riscv_vget_v_i32m1x2_i32m1(src, 0);
+}
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -332,6 +332,8 @@
   }
   if (isVector())
 ShortStr += LMUL.str();
+  if (isTuple())
+ShortStr += "x" + utostr(NF);
 }
 
 void RVVType::applyBasicType() {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4624,9 +4624,12 @@
 ASTContext::BuiltinVectorTypeInfo VecInfo =
 Context.getBuiltinVectorTypeInfo(cast(
 TheCall->getArg(0)->getType().getCanonicalType().getTypePtr()));
-unsigned MaxIndex =
-(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
-(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
+unsigned MaxIndex;
+if (VecInfo.NumVectors != 1) // vget for tuple type
+  MaxIndex = VecInfo.NumVectors;
+else // vget for non-tuple type
+  MaxIndex = (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
+ (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
   }
   case RISCVVector::BI__builtin_rvv_vset_v: {
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2730,6 +2730,16 @@
   let Name = "vget_v", MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
+if (isa(Ops[0]->getType())) { // codegen for tuple type
+  llvm::Value *VTupleOperand = Ops[0];
+  llvm::Value *IndexOperand = Ops[1];
+  assert(isa(IndexOperand));
+  unsigned Index = cast(IndexOperand)->getZExtValue();
+  unsigned MaxIndex = cast(VTupleOperand->getType())->getNumElements();
+  Index = std::min(Index, MaxIndex);
+
+  return Builder.CreateExtractValue(VTupleOperand, {Index});
+}
 ID = Intrinsic::vector_extract;
 auto *VecTy = cast(ResultType);
 auto *OpVecTy = cast(Ops[0]->getType());
@@ -2749,6 +2759,10 @@
   def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilxfd", dst_lmul # "v">;
   def : RVVBuiltin<"Uv" # dst_lmul

[PATCH] D147916: [10/11][POC][Clang][RISCV] Define vget for tuple type

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD marked 2 inline comments as done.
eopXD added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:2723
+  unsigned MaxIndex = 
cast(VTupleOperand->getType())->getNumElements();
+  Index = std::min(Index, MaxIndex);
+

craig.topper wrote:
> craig.topper wrote:
> > Does SemaChecking.cpp already guarantee Index is less than Maxindex?
> Actually it looks like maybe SemaChecking considers MaxIndex to be LMUL*NF? 
> Does that mean vget can extract an LMUL1 value from an LMUL4 tuple?
Modified code under SemaChecking.cpp for vector tuple types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147916/new/

https://reviews.llvm.org/D147916

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


[clang] cd5c4cb - [RISCV] Add SiFive extension support

2023-04-24 Thread via cfe-commits

Author: Kito Cheng
Date: 2023-04-24T03:12:49-07:00
New Revision: cd5c4cb7e0aea8beffe9642c9202f677fff59ca0

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

LOG: [RISCV] Add SiFive extension support

Add SiFive extension support
Depends on D147934

Differential Revision: https://reviews.llvm.org/D147935

Added: 


Modified: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index bf31dced98b2b..1a626e6a776a8 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -462,8 +462,9 @@ enum RVVRequire : uint8_t {
   RVV_REQ_None = 0,
   RVV_REQ_RV64 = 1 << 0,
   RVV_REQ_FullMultiply = 1 << 1,
+  RVV_REQ_Xsfvcp = 1 << 2,
 
-  LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_FullMultiply)
+  LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_Xsfvcp)
 };
 
 // Raw RVV intrinsic info, used to expand later.

diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 365fa8a67ffa1..6228e0256d54e 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -633,6 +633,7 @@ void RVVEmitter::createRVVIntrinsics(
   RVVRequire RequireExt = StringSwitch(RequiredFeature)
   .Case("RV64", RVV_REQ_RV64)
   .Case("FullMultiply", RVV_REQ_FullMultiply)
+  .Case("Xsfvcp", RVV_REQ_Xsfvcp)
   .Default(RVV_REQ_None);
   assert(RequireExt != RVV_REQ_None && "Unrecognized required feature?");
   SR.RequiredExtensions |= RequireExt;



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


[PATCH] D147935: [RISCV] Add SiFive extension support

2023-04-24 Thread Brandon Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd5c4cb7e0ae: [RISCV] Add SiFive extension support (authored 
by kito-cheng, committed by 4vtomat).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147935/new/

https://reviews.llvm.org/D147935

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -633,6 +633,7 @@
   RVVRequire RequireExt = StringSwitch(RequiredFeature)
   .Case("RV64", RVV_REQ_RV64)
   .Case("FullMultiply", RVV_REQ_FullMultiply)
+  .Case("Xsfvcp", RVV_REQ_Xsfvcp)
   .Default(RVV_REQ_None);
   assert(RequireExt != RVV_REQ_None && "Unrecognized required feature?");
   SR.RequiredExtensions |= RequireExt;
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -462,8 +462,9 @@
   RVV_REQ_None = 0,
   RVV_REQ_RV64 = 1 << 0,
   RVV_REQ_FullMultiply = 1 << 1,
+  RVV_REQ_Xsfvcp = 1 << 2,
 
-  LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_FullMultiply)
+  LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_Xsfvcp)
 };
 
 // Raw RVV intrinsic info, used to expand later.


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -633,6 +633,7 @@
   RVVRequire RequireExt = StringSwitch(RequiredFeature)
   .Case("RV64", RVV_REQ_RV64)
   .Case("FullMultiply", RVV_REQ_FullMultiply)
+  .Case("Xsfvcp", RVV_REQ_Xsfvcp)
   .Default(RVV_REQ_None);
   assert(RequireExt != RVV_REQ_None && "Unrecognized required feature?");
   SR.RequiredExtensions |= RequireExt;
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -462,8 +462,9 @@
   RVV_REQ_None = 0,
   RVV_REQ_RV64 = 1 << 0,
   RVV_REQ_FullMultiply = 1 << 1,
+  RVV_REQ_Xsfvcp = 1 << 2,
 
-  LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_FullMultiply)
+  LLVM_MARK_AS_BITMASK_ENUM(RVV_REQ_Xsfvcp)
 };
 
 // Raw RVV intrinsic info, used to expand later.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147917: [11/11][POC][Clang][RISCV] Define vset for tuple type

2023-04-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 516341.
eopXD added a comment.
Herald added a subscriber: arphaman.

Add test case for out-of-range access and guard vset correctly under 
SemaChecking.cpp.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147917/new/

https://reviews.llvm.org/D147917

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
@@ -339,3 +339,8 @@
   // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
   return __riscv_vset_v_f16m4_f16m8(dest, 2, val);
 }
+
+vint32m1x2_t test_vset_v_i32m1x2_i32m1(vint32m1x2_t dest, size_t index, 
vint32m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return __riscv_vset_v_i32m1x2_i32m1(dest, 2, val);
+}
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
===
--- /dev/null
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
@@ -0,0 +1,20 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  
} @test_vget_v_i32m1x2_i32m1
+// CHECK-RV64-SAME: ( [[DEST_COERCE0:%.*]],  [[DEST_COERCE1:%.*]], i64 noundef [[INDEX:%.*]],  
[[VAL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { , 
 } undef,  [[DEST_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { , 
 } [[TMP0]],  [[DEST_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = insertvalue { , 
 } [[TMP1]],  [[VAL]], 0
+// CHECK-RV64-NEXT:ret { ,  } [[TMP2]]
+//
+vint32m1x2_t test_vset_v_i32m1x2_i32m1(vint32m1x2_t dest, size_t index, 
vint32m1_t val) {
+  return __riscv_vset_v_i32m1x2_i32m1(dest, 0, val);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4639,9 +4639,12 @@
 ASTContext::BuiltinVectorTypeInfo VecInfo =
 Context.getBuiltinVectorTypeInfo(cast(
 TheCall->getArg(2)->getType().getCanonicalType().getTypePtr()));
-unsigned MaxIndex =
-(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
-(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
+unsigned MaxIndex;
+if (ResVecInfo.NumVectors != 1) // vset for tuple type
+  MaxIndex = ResVecInfo.NumVectors;
+else // vset fo non-tuple type
+  MaxIndex = (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
+ (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
   }
   // Check if byteselect is in [0, 3]
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2768,6 +2768,18 @@
   let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
+if (isa(ResultType)) { // codegen for tuple type
+  llvm::Value *VTupleOperand = Ops[0];
+  llvm::Value *IndexOperand = Ops[1];
+  llvm::Value *VOperand = Ops[2];
+  assert(isa(IndexOperand));
+
+  unsigned Index = cast(IndexOperand)->getZExtValue();
+  unsigned MaxIndex = 
cast(VTupleOperand->getType())->getNumElements();
+  Index = std::min(Index, MaxIndex);
+
+  return Builder.CreateInsertValue(VTupleOperand, VOperand, {Index});
+}
 ID = Intrinsic::vector_insert;
 IntrinsicTypes = {ResultType, Ops[2]->getType()};
 auto *ResVecTy = cast(ResultType);
@@ -2788,5 +2800,9 @@
   def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # 
"vKzv", "csilxfd">;
   def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "Uv" # dst_lmul 
#"UvKzUv", "csil">;
 }
+foreach nf = [2] in {
+  defvar T = "(Tuple:" # nf # ")";
+  def : RVVBuiltin;
+}
   }
 }


I

[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-04-24 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis marked 3 inline comments as done.
TIFitis added inline comments.



Comment at: 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1491
+mapTypes = exitDataOp.getMapTypes();
+mapperFunc = false;
+return success();

mehdi_amini wrote:
> This line is not needed after the fix you pushed right?
> 
> Seems like we could also just set `bool mapperFunc = 
> isa(op);` or something like that.
I've already removed this line in my fix.

Yes, I think we can get rid of the variable altogether and just pass the `isa` 
as an argument when calling. I'll add this change in one of my ongoing patches.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142914/new/

https://reviews.llvm.org/D142914

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


[PATCH] D145581: [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 516359.
mboehme marked 2 inline comments as done.
mboehme added a comment.

Changes in response to review comments, and rebased to head.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145581/new/

https://reviews.llvm.org/D145581

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
@@ -1,3 +1,4 @@
+// RUN: %check_clang_tidy -std=c++11 -check-suffixes=,CXX11 %s bugprone-use-after-move %t -- -- -fno-delayed-template-parsing
 // RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-use-after-move %t -- -- -fno-delayed-template-parsing
 
 typedef decltype(nullptr) nullptr_t;
@@ -123,6 +124,7 @@
   A &operator=(A &&);
 
   void foo() const;
+  void bar(int i) const;
   int getInt() const;
 
   operator bool() const;
@@ -564,6 +566,19 @@
   std::move(a);
 }
   }
+  // Same as above, but the use and the move are in different CFG blocks.
+  {
+A a;
+for (int i = 0; i < 10; ++i) {
+  if (i < 10)
+a.foo();
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: 'a' used after it was moved
+  // CHECK-NOTES: [[@LINE+3]]:9: note: move occurred here
+  // CHECK-NOTES: [[@LINE-3]]:9: note: the use happens in a later loop
+  if (i < 10)
+std::move(a);
+}
+  }
   // However, this case shouldn't be flagged -- the scope of the declaration of
   // 'a' is important.
   {
@@ -1319,6 +1334,40 @@
   }
 }
 
+// In a function call, the expression that determines the callee is sequenced
+// before the arguments -- but only in C++17 and later.
+namespace CalleeSequencedBeforeArguments {
+int consumeA(std::unique_ptr a);
+int consumeA(A &&a);
+
+void calleeSequencedBeforeArguments() {
+  {
+std::unique_ptr a;
+a->bar(consumeA(std::move(a)));
+// CHECK-NOTES-CXX11: [[@LINE-1]]:5: warning: 'a' used after it was moved
+// CHECK-NOTES-CXX11: [[@LINE-2]]:21: note: move occurred here
+// CHECK-NOTES-CXX11: [[@LINE-3]]:5: note: the use and move are unsequenced
+  }
+  {
+std::unique_ptr a;
+std::unique_ptr getArg(std::unique_ptr a);
+getArg(std::move(a))->bar(a->getInt());
+// CHECK-NOTES: [[@LINE-1]]:31: warning: 'a' used after it was moved
+// CHECK-NOTES: [[@LINE-2]]:12: note: move occurred here
+// CHECK-NOTES-CXX11: [[@LINE-3]]:31: note: the use and move are unsequenced
+  }
+  {
+A a;
+// Nominally, the callee `a.bar` is evaluated before the argument
+// `consumeA(std::move(a))`, but in effect `a` is only accessed after the
+// call to `A::bar()` happens, i.e. after the argument has been evaluted.
+a.bar(consumeA(std::move(a)));
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'a' used after it was moved
+// CHECK-NOTES: [[@LINE-2]]:11: note: move occurred here
+  }
+}
+} // namespace CalleeSequencedBeforeArguments
+
 // Some statements in templates (e.g. null, break and continue statements) may
 // be shared between the uninstantiated and instantiated versions of the
 // template and therefore have multiple parents. Make sure the sequencing code
@@ -1436,7 +1485,6 @@
 // CHECK-NOTES: [[@LINE-1]]:11: warning: 'val' used after it was moved
 s{std::move(val)} {} // wrong order
   // CHECK-NOTES: [[@LINE-1]]:9: note: move occurred here
-  // CHECK-NOTES: [[@LINE-4]]:11: note: the use happens in a later loop iteration than the move
 
 private:
   bool a;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -213,9 +213,12 @@
   ` check to properly handle calls
   to ``std::forward``.
 
-- Improved :doc:`bugprone-use-after-move
-  ` check to also cover constructor
-  initializers.
+- :doc:`bugprone-use-after-move
+  `: Improved check to also cover
+  constructor initializers. Fixed sequencing of designated initializers.
+  Fixed sequencing of callees: In C++17 and later, the callee of a function is
+  guaranteed to be sequenced before the arguments, so don't warn if the use
+  happens in the callee and the move happens in one of the arguments.
 
 - Deprecated :doc:`cert-dcl21-cpp
   ` check.
@@ -330,10 +333,6 @@
   ` check when warning would be
   emitted in constructor for virtual base class initialization.
 
-- Improved :doc:`bugprone-use-after-move
-  ` to understand that there is a
-  sequence point between designated initializers.
-
 - Fixed an issue in the :doc:`performance-noexcept-move-constructor
   `

[PATCH] D145581: [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked 4 inline comments as done.
mboehme added a comment.

In D145581#4290839 , @PiotrZSL wrote:

> First, re-base code, looks like there were some changes in this check, and 
> now there are conflicts with this path.

Done. (Not sure what the etiquette is with respect to rebasing -- that's why I 
kept it based on an old revision.)

> Second I don't any more comments, for me this code looks fine, BUT I'm not 
> familiar too much with this check.
> Check history for this check, and maybe consider adding to review some other 
> people who modify it recently.

Thanks, will do.




Comment at: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp:68-73
+  for (const Expr *Arg : Call->arguments()) {
+if (isDescendantOrEqual(Descendant, Arg, Context))
+  return true;
+  }
+
+  return false;

PiotrZSL wrote:
> NOTE: This looks like llvm::any_of 
Done.



Comment at: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp:77-82
+  for (const Expr *Arg : Call->arguments()) {
+if (Arg == TheStmt)
+  return true;
+  }
+
+  return false;

PiotrZSL wrote:
> NOTE: this looks like llvm::any_of, or even something like contains/find
Done (with find).



Comment at: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp:161-165
+if (const auto *call = dyn_cast(Parent);
+call && call->getCallee() == Before) {
+  if (isDescendantOfArgs(After, call, Context))
+return true;
+}

PiotrZSL wrote:
> NOTE: probably you could move call outside if, and do rest with single if...
Or as a single if statement like this?



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:167
+  `:
+  - Fixed handling for designated initializers.
+  - Fix: In C++17 and later, the callee of a function is guaranteed to be

PiotrZSL wrote:
> NOTE: Probably better would be to keep similar template to rest of checks, 
> just list fixes in sentences (or separated with ,), not as an list.
Done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145581/new/

https://reviews.llvm.org/D145581

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


[PATCH] D145581: [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked 4 inline comments as done.
mboehme added a comment.

@MarcoFalke Would you be willing to review? (Thanks for your recent fix in 
D146288 !)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145581/new/

https://reviews.llvm.org/D145581

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


[PATCH] D145581: [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp:1439
   // CHECK-NOTES: [[@LINE-1]]:9: note: move occurred here
-  // CHECK-NOTES: [[@LINE-4]]:11: note: the use happens in a later loop 
iteration than the move
 

Rewriting the logic for the "use happens in a later loop iteration" has also 
eliminated this erroneous note.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145581/new/

https://reviews.llvm.org/D145581

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


[clang] 039c356 - Minor cleanup of the Open Projects page

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T08:27:09-04:00
New Revision: 039c356cda674530b8e16b55a83f092b2d8c35ff

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

LOG: Minor cleanup of the Open Projects page

Sets the charset to UTF-8, fixes the page title, replaces mention of
cfe-dev with Discourse, points out Discord and IRC.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index e1693cb0e52b..07d7140643df 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -2,8 +2,8 @@
   "http://www.w3.org/TR/html4/strict.dtd";>
 
 
-  
-  Clang - Get Involved
+  
+  Clang - Open Projects
   
   
 
@@ -15,10 +15,11 @@
 
 Open Clang Projects
 
-Here are a few tasks that are available for newcomers to work on, depending
-on what your interests are.  This list is provided to generate ideas, it is not
-intended to be comprehensive.  Please ask on cfe-dev for more specifics or to
-verify that one of these isn't already completed. :)
+Here are a few tasks that are available for anyone to work on, depending
+on what your interests are. This list is provided to generate ideas, it is not
+intended to be comprehensive. Please ask on
+https://discourse.llvm.org/c/clang";>Discourse for more specifics
+or to verify that one of these isn't already completed.
 
 
 Undefined behavior checking:
@@ -123,9 +124,11 @@ Open Clang Projects
 a text editor could change.
 
 
-If you hit a bug with clang, it is very useful for us if you reduce the code
-that demonstrates the problem down to something small.  There are many ways to
-do this; ask on cfe-dev for advice.
+If you hit a bug with Clang, it is very useful for us if you reduce the code
+that demonstrates the problem down to something small. There are many ways to
+do this; ask on https://discourse.llvm.org/c/clang";>Discourse,
+https://discord.com/channels/636084430946959380/636725486533345280";>Discord,
+or https://llvm.org/docs/GettingInvolved.html#irc"IRC for 
advice.
 
 
 



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


[clang] 4475dd6 - Fix file info comment; NFC

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T08:36:27-04:00
New Revision: 4475dd62d0fcf59713791f608f8ade29bbca94ee

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

LOG: Fix file info comment; NFC

There is no TargetInfoImpl class any longer.

Added: 


Modified: 
clang/lib/Basic/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 1ae85928b234..eb56d669933f 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-//  This file implements the TargetInfo and TargetInfoImpl interfaces.
+//  This file implements the TargetInfo interface.
 //
 
//===--===//
 



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


[clang] 946b326 - [InstSimplify] sdiv a (1 srem b) --> a

2023-04-24 Thread Nikita Popov via cfe-commits

Author: Siyuan Zhu
Date: 2023-04-24T14:37:07+02:00
New Revision: 946b32680311f43a349d0199f9e286f385cd9847

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

LOG: [InstSimplify] sdiv a (1 srem b) --> a

Extend the existing fold for division by zero or one to use known
bits, so it catches additional patterns like division by
(1 srem b).

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

Differential Revision: https://reviews.llvm.org/D149001

Added: 


Modified: 
clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/for_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
clang/test/OpenMP/sections_reduction_task_codegen.cpp
clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/zext-or-icmp.ll
llvm/test/Transforms/InstSimplify/div.ll

Removed: 




diff  --git 
a/clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp 
b/clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
index 7cd29b2f70574..de9b18bbb5fba 100644
--- a/clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
@@ -568,22 +568,20 @@ int main(int argc, char **argv) {
 // CHECK1-NEXT:[[TMP28:%.*]] = ptrtoint ptr [[ARRAYIDX3_I]] to i64
 // CHECK1-NEXT:[[TMP29:%.*]] = ptrtoint ptr [[TMP20]] to i64
 // CHECK1-NEXT:[[TMP30:%.*]] = sub i64 [[TMP28]], [[TMP29]]
-// CHECK1-NEXT:[[TMP31:%.*]] = sdiv exact i64 [[TMP30]], ptrtoint (ptr 
getelementptr (i8, ptr null, i32 1) to i64)
-// CHECK1-NEXT:[[TMP32:%.*]] = add nuw i64 [[TMP31]], 1
-// CHECK1-NEXT:[[TMP33:%.*]] = mul nuw i64 [[TMP32]], ptrtoint (ptr 
getelementptr (i8, ptr null, i32 1) to i64)
-// CHECK1-NEXT:store i64 [[TMP32]], ptr @{{reduction_size[.].+[.]}}, align 
8, !noalias !12
-// CHECK1-NEXT:[[TMP34:%.*]] = load ptr, ptr [[TMP12]], align 8
-// CHECK1-NEXT:[[TMP35:%.*]] = call ptr 
@__kmpc_task_reduction_get_th_data(i32 [[TMP16]], ptr [[TMP34]], ptr [[TMP20]])
-// CHECK1-NEXT:[[TMP36:%.*]] = getelementptr inbounds [[STRUCT_ANON]], ptr 
[[TMP9]], i32 0, i32 2
+// CHECK1-NEXT:[[TMP31:%.*]] = add nuw i64 [[TMP30]], 1
+// CHECK1-NEXT:[[TMP32:%.*]] = mul nuw i64 [[TMP31]], ptrtoint (ptr 
getelementptr (i8, ptr null, i32 1) to i64)
+// CHECK1-NEXT:store i64 [[TMP31]], ptr @{{reduction_size[.].+[.]}}, align 
8, !noalias !12
+// CHECK1-NEXT:[[TMP33:%.*]] = load ptr, ptr [[TMP12]], align 8
+// CHECK1-NEXT:[[TMP34:%.*]] = call ptr 
@__kmpc_task_reduction_get_th_data(i32 [[TMP16]], ptr [[TMP33]], ptr [[TMP20]])
+// CHECK1-NEXT:[[TMP35:%.*]] = getelementptr inbounds [[STRUCT_ANON]], ptr 
[[TMP9]], i32 0, i32 2
+// CHECK1-NEXT:[[TMP36:%.*]] = load ptr, ptr [[TMP35]], align 8
 // CHECK1-NEXT:[[TMP37:%.*]] = load ptr, ptr [[TMP36]], align 8
-// CHECK1-NEXT:[[TMP38:%.*]] = load ptr, ptr [[TMP37]], align 8
-// CHECK1-NEXT:[[TMP39:%.*]] = ptrtoint ptr [[TMP38]] to i64
-// CHECK1-NEXT:[[TMP40:%.*]] = ptrtoint ptr [[TMP20]] to i64
-// CHECK1-NEXT:[[TMP41:%.*]] = sub i64 [[TMP39]], [[TMP40]]
-// CHECK1-NEXT:[[TMP42:%.*]] = sdiv exact i64 [[TMP41]], ptrtoint (ptr 
getelementptr (i8, ptr null, i32 1) to i64)
-// CHECK1-NEXT:[[TMP43:%.*]] = getelementptr i8, ptr [[TMP35]], i64 
[[TMP42]]
+// CHECK1-NEXT:[[TMP38:%.*]] = ptrtoint ptr [[TMP37]] to i64
+// CHECK1-NEXT:[[TMP39:%.*]] = ptrtoint ptr [[TMP20]] to i64
+// CHECK1-NEXT:[[TMP40:%.*]] = sub i64 [[TMP38]], [[TMP39]]
+// CHECK1-NEXT:[[TMP41:%.*]] = getelementptr i8, ptr [[TMP34]], i64 
[[TMP40]]
 // CHECK1-NEXT:store ptr [[TMP4_I]], ptr [[TMP_I]], align 8, !noalias !12
-// CHECK1-NEXT:store ptr [[TMP43]], ptr [[TMP4_I]], align 8, !noalias !12
+// CHECK1-NEXT:store ptr [[TMP41]], ptr [[TMP4_I]], align 8, !noalias !12
 // CHECK1-NEXT:ret i32 0
 //
 //

diff  --git a/clang/test/OpenMP/for_reduction_task_codegen.cpp 
b/clang/test/OpenMP/for_reduction_task_codegen.cpp
index 687aa973dde27..48587ce9a34b6 100644
--- a/clang/test/OpenMP/for_reduction_task_codegen.cpp
+++ b/clang/test/OpenMP/for_reduction_task_codegen.cpp
@@ -481,22 +481,20 @@ int main(int argc, char **argv) {
 // CHECK1-NEXT:[[TMP28:%.*]] =

[PATCH] D149001: [InstSimplify] sdiv a (1 srem b) --> a

2023-04-24 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG946b32680311: [InstSimplify] sdiv a (1 srem b) --> a 
(authored by floatshadow, committed by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149001/new/

https://reviews.llvm.org/D149001

Files:
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstCombine/zext-or-icmp.ll
  llvm/test/Transforms/InstSimplify/div.ll

Index: llvm/test/Transforms/InstSimplify/div.ll
===
--- llvm/test/Transforms/InstSimplify/div.ll
+++ llvm/test/Transforms/InstSimplify/div.ll
@@ -437,9 +437,7 @@
 
 define i32 @sdiv_one_srem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @sdiv_one_srem_divisor(
-; CHECK-NEXT:[[SREM:%.*]] = srem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[SDIV:%.*]] = sdiv i32 [[A:%.*]], [[SREM]]
-; CHECK-NEXT:ret i32 [[SDIV]]
+; CHECK-NEXT:ret i32 [[A:%.*]]
 ;
   %srem = srem i32 1, %b
   %sdiv = sdiv i32 %a, %srem
@@ -448,9 +446,7 @@
 
 define i32 @sdiv_one_urem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @sdiv_one_urem_divisor(
-; CHECK-NEXT:[[UREM:%.*]] = urem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[SDIV:%.*]] = sdiv i32 [[A:%.*]], [[UREM]]
-; CHECK-NEXT:ret i32 [[SDIV]]
+; CHECK-NEXT:ret i32 [[A:%.*]]
 ;
   %urem = urem i32 1, %b
   %sdiv = sdiv i32 %a, %urem
@@ -459,9 +455,7 @@
 
 define i32 @udiv_one_srem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @udiv_one_srem_divisor(
-; CHECK-NEXT:[[SREM:%.*]] = srem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[UDIV:%.*]] = udiv i32 [[A:%.*]], [[SREM]]
-; CHECK-NEXT:ret i32 [[UDIV]]
+; CHECK-NEXT:ret i32 [[A:%.*]]
 ;
   %srem = srem i32 1, %b
   %udiv = udiv i32 %a, %srem
@@ -470,9 +464,7 @@
 
 define i32 @udiv_one_urem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @udiv_one_urem_divisor(
-; CHECK-NEXT:[[UREM:%.*]] = urem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[UDIV:%.*]] = udiv i32 [[A:%.*]], [[UREM]]
-; CHECK-NEXT:ret i32 [[UDIV]]
+; CHECK-NEXT:ret i32 [[A:%.*]]
 ;
   %urem = urem i32 1, %b
   %udiv = udiv i32 %a, %urem
@@ -481,9 +473,7 @@
 
 define i32 @srem_one_srem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @srem_one_srem_divisor(
-; CHECK-NEXT:[[SREM:%.*]] = srem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[SREM1:%.*]] = srem i32 [[A:%.*]], [[SREM]]
-; CHECK-NEXT:ret i32 [[SREM1]]
+; CHECK-NEXT:ret i32 0
 ;
   %srem = srem i32 1, %b
   %srem1 = srem i32 %a, %srem
@@ -492,9 +482,7 @@
 
 define i32 @urem_one_srem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @urem_one_srem_divisor(
-; CHECK-NEXT:[[SREM:%.*]] = srem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[UREM:%.*]] = urem i32 [[A:%.*]], [[SREM]]
-; CHECK-NEXT:ret i32 [[UREM]]
+; CHECK-NEXT:ret i32 0
 ;
   %srem = srem i32 1, %b
   %urem = urem i32 %a, %srem
@@ -503,9 +491,7 @@
 
 define i32 @srem_one_urem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @srem_one_urem_divisor(
-; CHECK-NEXT:[[UREM:%.*]] = urem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[SREM:%.*]] = srem i32 [[A:%.*]], [[UREM]]
-; CHECK-NEXT:ret i32 [[SREM]]
+; CHECK-NEXT:ret i32 0
 ;
   %urem = urem i32 1, %b
   %srem = srem i32 %a, %urem
@@ -514,9 +500,7 @@
 
 define i32 @urem_one_urem_divisor(i32 %a, i32 %b) {
 ; CHECK-LABEL: @urem_one_urem_divisor(
-; CHECK-NEXT:[[UREM:%.*]] = urem i32 1, [[B:%.*]]
-; CHECK-NEXT:[[UREM1:%.*]] = urem i32 [[A:%.*]], [[UREM]]
-; CHECK-NEXT:ret i32 [[UREM1]]
+; CHECK-NEXT:ret i32 0
 ;
   %urem = urem i32 1, %b
   %urem1 = urem i32 %a, %urem
@@ -525,9 +509,7 @@
 
 define <2 x i8> @sdiv_one_vec_srem_divisor(<2 x i8> %a, <2 x i8> %b) {
 ; CHECK-LABEL: @sdiv_one_vec_srem_divisor(
-; CHECK-NEXT:[[SREM:%.*]] = srem <2 x i8> , [[B:%.*]]
-; CHECK-NEXT:[[SDIV:%.*]] = sdiv <2 x i8> [[A:%.*]], [[SREM]]
-; CHECK-NEXT:ret <2 x i8> [[SDIV]]
+; CHECK-NEXT:ret <2 x i8> [[A:%.*]]
 ;
   %srem = srem <2 x i8> , %b
   %sdiv = sdiv <2 x i8> %a, %srem
@@ -536,9 +518,7 @@
 
 define i32 @sdiv_and_one_divisor(i32 %x, i32 %y) {
 ; CHECK-LABEL: @sdiv_and_one_divisor(
-; CHECK-NEXT:[[AND:%.*]] = and i32 [[X:%.*]], 1
-; CHECK-NEXT:[[RE

[PATCH] D148355: [analyzer] Fix comparison logic in ArrayBoundCheckerV2

2023-04-24 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy updated this revision to Diff 516365.
donat.nagy marked 11 inline comments as done.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148355/new/

https://reviews.llvm.org/D148355

Files:
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/test/Analysis/array-bound-v2-constraint-check.c
  clang/test/Analysis/out-of-bounds-false-positive.c

Index: clang/test/Analysis/array-bound-v2-constraint-check.c
===
--- clang/test/Analysis/array-bound-v2-constraint-check.c
+++ clang/test/Analysis/array-bound-v2-constraint-check.c
@@ -8,12 +8,11 @@
 const char a[] = "abcd"; // extent: 5 bytes
 
 void symbolic_size_t_and_int0(size_t len) {
-  // FIXME: Should not warn for this.
-  (void)a[len + 1]; // expected-warning {{Out of bound memory access}}
+  (void)a[len + 1]; // no-warning
   // We infered that the 'len' must be in a specific range to make the previous indexing valid.
   // len: [0,3]
-  clang_analyzer_eval(len <= 3); // expected - warning {{TRUE}}
-  clang_analyzer_eval(len <= 2); // expected - warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 3); // expected-warning {{TRUE}}
+  clang_analyzer_eval(len <= 2); // expected-warning {{UNKNOWN}}
 }
 
 void symbolic_size_t_and_int1(size_t len) {
Index: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -54,8 +54,8 @@
 : baseRegion(nullptr), byteOffset(UnknownVal()) {}
 
 public:
-  RegionRawOffsetV2(const SubRegion* base, SVal offset)
-: baseRegion(base), byteOffset(offset) {}
+  RegionRawOffsetV2(const SubRegion *base, NonLoc offset)
+  : baseRegion(base), byteOffset(offset) { assert(base); }
 
   NonLoc getByteOffset() const { return byteOffset.castAs(); }
   const SubRegion *getRegion() const { return baseRegion; }
@@ -69,19 +69,12 @@
 };
 }
 
-static SVal computeExtentBegin(SValBuilder &svalBuilder,
-   const MemRegion *region) {
-  const MemSpaceRegion *SR = region->getMemorySpace();
-  if (SR->getKind() == MemRegion::UnknownSpaceRegionKind)
-return UnknownVal();
-  else
-return svalBuilder.makeZeroArrayIndex();
-}
-
 // TODO: once the constraint manager is smart enough to handle non simplified
 // symbolic expressions remove this function. Note that this can not be used in
 // the constraint manager as is, since this does not handle overflows. It is
 // safe to assume, however, that memory offsets will not overflow.
+// NOTE: callers of this function need to be aware of the effects of overflows
+// and signed<->unsigned conversions!
 static std::pair
 getSimplifiedOffsets(NonLoc offset, nonloc::ConcreteInt extent,
  SValBuilder &svalBuilder) {
@@ -114,6 +107,38 @@
   return std::pair(offset, extent);
 }
 
+// Evaluate the comparison Value < Threshold with the help of the custom
+// simplification algorithm defined for this checker. Return a pair of states,
+// where the first one corresponds to "value below threshold" and the second
+// corresponds to "value at or above threshold". Returns {nullptr, nullptr} in
+// the case when the evaluation fails.
+static std::pair
+compareValueToThreshold(ProgramStateRef State, NonLoc Value, NonLoc Threshold,
+SValBuilder &SVB) {
+  if (auto ConcreteThreshold = Threshold.getAs()) {
+std::tie(Value, Threshold) = getSimplifiedOffsets(Value, *ConcreteThreshold, SVB);
+  }
+  if (auto ConcreteThreshold = Threshold.getAs()) {
+QualType T = Value.getType(SVB.getContext());
+if (T->isUnsignedIntegerType() && ConcreteThreshold->getValue().isNegative()) {
+  // In this case we reduced the bound check to a comparison of the form
+  //   (symbol or value with unsigned type) < (negative number)
+  // which is always false. We are handling these cases separately because
+  // evalBinOpNN can perform a signed->unsigned conversion that turns the
+  // negative number into a huge positive value and leads to wildly
+  // inaccurate conclusions.
+  return {nullptr, State};
+}
+  }
+  auto BelowThreshold =
+  SVB.evalBinOpNN(State, BO_LT, Value, Threshold, SVB.getConditionType()).getAs();
+
+  if (BelowThreshold)
+return State->assume(*BelowThreshold);
+
+  return {nullptr, nullptr};
+}
+
 void ArrayBoundCheckerV2::checkLocation(SVal location, bool isLoad,
 const Stmt* LoadS,
 CheckerContext &checkerContext) const {
@@ -136,93 +161,52 @@
   if (!rawOffset.getRegion())
 return;
 
-  NonLoc rawOffsetVal = rawOffset.getByteOffset();
-
-  // CHECK LOWER BOUND: Is byteOffset < extent begin?
-  //  If so, we are doing a load/store
-  //  before the first valid offset in the memory region.
-
- 

[PATCH] D148355: [analyzer] Fix comparison logic in ArrayBoundCheckerV2

2023-04-24 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy marked an inline comment as done.
donat.nagy added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:173
+  const MemSpaceRegion *SR = rawOffset.getRegion()->getMemorySpace();
+  if (SR->getKind() != MemRegion::UnknownSpaceRegionKind) {
+// a pointer to UnknownSpaceRegionKind may point to the middle of

steakhal wrote:
> donat.nagy wrote:
> > steakhal wrote:
> > > 
> > You're completely right, I just blindly copied this test from the 
> > needlessly overcomplicated `computeExtentBegin()`.
> Hold on. This would only skip the lower bounds check if it's an 
> `UnknownSpaceRegion`.
> Shouldn't we early return instead?
This behavior is inherited from the code before my commit: the old block `if ( 
/*... =*/ extentBegin.getAs() ) { /* ... */ }` is equivalent to `if 
(llvm::isa(SR)) { /*...*/ }` and there was no early return 
connected to //this// NonLocness check. (The old code skipped the upper bound 
check if the result of `evalBinOpNN()` is unknown, and that's what I changed 
because I saw no reason to do an early return there.)

After some research into the memory region model, I think that there is no 
reason to perform an early return -- in fact, the condition of this  `if` seems 
to be too narrow because we would like to warn about code like
  struct foo {
int tag;
int array[5];
  };
  int f(struct foo *p) {
return p->arr[-1];
  }
despite the fact that it's indexing into a `FieldRegion` inside a 
`SymbolicRegion` in `UnknownSpaceRegion`. That is, instead of checking the 
top-level MemorySpace, the correct logic would be checking the kind of the 
memory region and/or perhaps its immediate super-region.

As this is a complex topic and completely unrelated to the main goal of this 
commit; I'd prefer to keep the old (not ideal, but working) logic in this 
patch, then revisit this question by creating a separate follow-up commit.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:173
+  const MemSpaceRegion *SR = rawOffset.getRegion()->getMemorySpace();
+  if (SR->getKind() != MemRegion::UnknownSpaceRegionKind) {
+// a pointer to UnknownSpaceRegionKind may point to the middle of

donat.nagy wrote:
> steakhal wrote:
> > donat.nagy wrote:
> > > steakhal wrote:
> > > > 
> > > You're completely right, I just blindly copied this test from the 
> > > needlessly overcomplicated `computeExtentBegin()`.
> > Hold on. This would only skip the lower bounds check if it's an 
> > `UnknownSpaceRegion`.
> > Shouldn't we early return instead?
> This behavior is inherited from the code before my commit: the old block `if 
> ( /*... =*/ extentBegin.getAs() ) { /* ... */ }` is equivalent to `if 
> (llvm::isa(SR)) { /*...*/ }` and there was no early 
> return connected to //this// NonLocness check. (The old code skipped the 
> upper bound check if the result of `evalBinOpNN()` is unknown, and that's 
> what I changed because I saw no reason to do an early return there.)
> 
> After some research into the memory region model, I think that there is no 
> reason to perform an early return -- in fact, the condition of this  `if` 
> seems to be too narrow because we would like to warn about code like
>   struct foo {
> int tag;
> int array[5];
>   };
>   int f(struct foo *p) {
> return p->arr[-1];
>   }
> despite the fact that it's indexing into a `FieldRegion` inside a 
> `SymbolicRegion` in `UnknownSpaceRegion`. That is, instead of checking the 
> top-level MemorySpace, the correct logic would be checking the kind of the 
> memory region and/or perhaps its immediate super-region.
> 
> As this is a complex topic and completely unrelated to the main goal of this 
> commit; I'd prefer to keep the old (not ideal, but working) logic in this 
> patch, then revisit this question by creating a separate follow-up commit.
Minor nitpick: your suggested change accidentally negated the conditional :) 
... and I said that it's "completely right". I'm glad that I noticed this and 
inserted the "!" before the `isa` check because otherwise it could've been 
annoying to debug this...



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:174-175
+  if (SR->getKind() != MemRegion::UnknownSpaceRegionKind) {
+// a pointer to UnknownSpaceRegionKind may point to the middle of
+// an allocated region
 

steakhal wrote:
> Good point.
For now I'm keeping this comment (with your formatting changes), because it's 
"approximately correct", but I'll replace or elaborate it when I refine the 
condition for skipping the lower bound check.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:196-198
+ProgramStateRef state_withinUpperBound, state_exceedsUpperBound;
+std::tie(state_withinUpperBound, state_exceedsUpperBound) =
+compareValueToThreshold(state, ByteOffset, *KnownSize, svalBuilder);

[clang] 2bb7e00 - [Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.

2023-04-24 Thread Paul Walker via cfe-commits

Author: Paul Walker
Date: 2023-04-24T12:45:19Z
New Revision: 2bb7e00b098cdbf87b9e2e2f5ec85b661664b709

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

LOG: [Clang][Sema] Fix invalid cast when validating SVE types within 
CheckVariableDeclarationType.

Fixes #62087

Differential Revision: https://reviews.llvm.org/D148919

Added: 
clang/test/SemaOpenMP/arm-sve-acle-types.cpp

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 575459c3c6920..719215d3f38c4 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8705,7 +8705,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
   }
 
   // Check that SVE types are only used in functions with SVE available.
-  if (T->isSVESizelessBuiltinType() && CurContext->isFunctionOrMethod()) {
+  if (T->isSVESizelessBuiltinType() && isa(CurContext)) {
 const FunctionDecl *FD = cast(CurContext);
 llvm::StringMap CallerFeatureMap;
 Context.getFunctionFeatureMap(CallerFeatureMap, FD);

diff  --git a/clang/test/SemaOpenMP/arm-sve-acle-types.cpp 
b/clang/test/SemaOpenMP/arm-sve-acle-types.cpp
new file mode 100644
index 0..7afa6e9da24da
--- /dev/null
+++ b/clang/test/SemaOpenMP/arm-sve-acle-types.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -triple aarch64-arm-none-eabi 
-target-feature +sve -verify %s
+// expected-no-diagnostics
+
+__SVBool_t foo(int);
+
+void test() {
+#pragma omp parallel
+  {
+__SVBool_t pg = foo(1);
+  }
+}



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


[PATCH] D148919: [Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.

2023-04-24 Thread Paul Walker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2bb7e00b098c: [Clang][Sema] Fix invalid cast when validating 
SVE types within… (authored by paulwalker-arm).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148919/new/

https://reviews.llvm.org/D148919

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenMP/arm-sve-acle-types.cpp


Index: clang/test/SemaOpenMP/arm-sve-acle-types.cpp
===
--- /dev/null
+++ clang/test/SemaOpenMP/arm-sve-acle-types.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -triple aarch64-arm-none-eabi 
-target-feature +sve -verify %s
+// expected-no-diagnostics
+
+__SVBool_t foo(int);
+
+void test() {
+#pragma omp parallel
+  {
+__SVBool_t pg = foo(1);
+  }
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8705,7 +8705,7 @@
   }
 
   // Check that SVE types are only used in functions with SVE available.
-  if (T->isSVESizelessBuiltinType() && CurContext->isFunctionOrMethod()) {
+  if (T->isSVESizelessBuiltinType() && isa(CurContext)) {
 const FunctionDecl *FD = cast(CurContext);
 llvm::StringMap CallerFeatureMap;
 Context.getFunctionFeatureMap(CallerFeatureMap, FD);


Index: clang/test/SemaOpenMP/arm-sve-acle-types.cpp
===
--- /dev/null
+++ clang/test/SemaOpenMP/arm-sve-acle-types.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -triple aarch64-arm-none-eabi -target-feature +sve -verify %s
+// expected-no-diagnostics
+
+__SVBool_t foo(int);
+
+void test() {
+#pragma omp parallel
+  {
+__SVBool_t pg = foo(1);
+  }
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8705,7 +8705,7 @@
   }
 
   // Check that SVE types are only used in functions with SVE available.
-  if (T->isSVESizelessBuiltinType() && CurContext->isFunctionOrMethod()) {
+  if (T->isSVESizelessBuiltinType() && isa(CurContext)) {
 const FunctionDecl *FD = cast(CurContext);
 llvm::StringMap CallerFeatureMap;
 Context.getFunctionFeatureMap(CallerFeatureMap, FD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5e10cd7 - Remove known-stale projects from the open projects page

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T08:58:56-04:00
New Revision: 5e10cd78780891ee6777ff6268cd727f1785d373

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

LOG: Remove known-stale projects from the open projects page

This removes or modifies:

Undefined behavior checking -- we've got UBSan and it's well-known
enough that we don't need to call it out specifically as a need.

Improve target support -- this is largely already complete.

Use clang libraries to extend Ragel with a JIT -- this wasn't really
related to improving Clang.

C++1y feature work -- now talks about C++20, C++2b, and C2x instead.

Universal driver -- the bug report linked to by the UniversalDriver
web page has been closed since 2017.

XML representation of the AST -- we removed this functionality in 2013
and replaced it with a JSON representation a few years later. That is a
best-effort project.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 
clang/www/UniversalDriver.html



diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 07d7140643df..fb3bd1b5edec 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -22,16 +22,6 @@ Open Clang Projects
 or to verify that one of these isn't already completed.
 
 
-Undefined behavior checking:
-Improve and extend the runtime checks for undefined behavior which CodeGen
-inserts for the various -fsanitize= modes. A lot of issues can already
-be caught, but there is more to do here.
-
-Improve target support: The current target interfaces are heavily
-stubbed out and need to be implemented fully.  See the FIXME's in TargetInfo.
-Additionally, the actual target implementations (instances of TargetInfoImpl)
-also need to be completed.
-
 Implement an tool to generate code documentation: Clang's
 library-based design allows it to be used by a variety of tools that reason
 about source code. One great application of Clang would be to build an
@@ -56,12 +46,6 @@ Open Clang Projects
 
href="https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code";>the
 LLVM coding
 standards.
 
-Use clang libraries to extend Ragel with a JIT: https://www.colm.net/open-source/ragel/";>Ragel is a state
-machine compiler that lets you embed C code into state machines and generate
-C code.  It would be relatively easy to turn this into a JIT compiler using
-LLVM.
-
 Self-testing using clang: There are several neat ways to
 improve the quality of clang by self-testing. Some examples:
 
@@ -77,30 +61,17 @@ Open Clang Projects
 
 
 
-Continue work on C++1y support:
-  C++98 and C++11 are feature-complete, but there are still several C++1y 
features to
-  implement.  Please see the C++ status report
-  page to find out what is missing.
+Continue work on C++20, C++2b, and C2x support:
+  There are still several C++20 features to complete, and work has begun on
+  supporting the latest language standards. Please see the
+  C++ status report page to find out what is
+  missing.
 
 StringRef'ize APIs: A thankless but incredibly useful project is
 StringRef'izing (converting to use llvm::StringRef instead of 
const
 char * or std::string) various clang interfaces. This generally
 simplifies the code and makes it more efficient.
 
-Universal Driver: Clang is inherently a cross compiler. We would 
like
-to define a new model for cross compilation which provides a great user
-experience -- it should be easy to cross compile applications, install support
-for new architectures, access 
diff erent compilers and tools, and be consistent
-across 
diff erent platforms. See the Universal
-Driver web page for more information.
-
-XML Representation of ASTs: Clang maintains a rich Abstract Syntax 
Tree that describes the program. Clang could emit an XML document that 
describes the program, which others tools could consume rather than being tied 
directly to the Clang binary.The XML representation needs to meet several 
requirements:
-  
-General, so that it's able to represent C/C++/Objective-C 
abstractly, and isn't tied to the specific internal ASTs that Clang uses.
-Documented, with appropriate Schema against which the output of 
Clang's XML formatter can be verified.
-Stable across Clang versions.
-  
-
 Configuration Manager: Clang/LLVM works on a large number of
 architectures and operating systems and can cross-compile to a similarly large
 number of configurations, but the pitfalls of choosing the command-line

diff  --git a/clang/www/UniversalDriver.html b/clang/www/UniversalDriver.html
deleted file mode 100755
index a6759f0aa34c..
--- a/clang/www/UniversalDriver.html
+++ /dev/null
@@ -1,87 +0,0 @@
-http://www.w3.org/TR/html4/strict.dtd";>
-
-
-  
-  Clang - Universal Driver
-  
-  
-
-
-
-

[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon updated this revision to Diff 516374.
agozillon added a comment.

- Resolve some of the reviewer comments
- [Flang][OpenMP][Driver][MLIR] Add diagnostic error test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148038/new/

https://reviews.llvm.org/D148038

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/LangOptions.h
  flang/include/flang/Tools/CrossToolHelpers.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/omp-driver-offload.f90
  flang/test/Lower/OpenMP/omp-host-ir-flag.f90
  mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td

Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
@@ -71,7 +71,7 @@
   InterfaceMethod<
   /*description=*/[{
 Get the IsDeviceAttr attribute on the current module if it exists and return
-its value, if it doesn't exit it returns false by default.
+its value, if it doesn't exist it returns false by default.
   }],
   /*retTy=*/"bool",
   /*methodName=*/"getIsDevice",
@@ -138,6 +138,34 @@
  targetCPU.str(),
  targetFeatures.str()));
   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Set a StringAttr on the current module containing the host IR file path. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"void",
+  /*methodName=*/"setHostIRFilePath", 
+  (ins "std::string":$hostIRFilePath), [{}], [{
+$_op->setAttr(
+  mlir::StringAttr::get($_op->getContext(), llvm::Twine{"omp.host_ir_filepath"}),
+mlir::StringAttr::get($_op->getContext(), hostIRFilePath));
+   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Find the host-ir file path StringAttr from the current module if it exists and 
+return its contained value, if it doesn't exist it returns an empty string. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"llvm::StringRef",
+  /*methodName=*/"getHostIRFilePath", 
+  (ins), [{}], [{
+if (Attribute filepath = $_op->getAttr("omp.host_ir_filepath"))
+  if (filepath.isa())
+return filepath.dyn_cast().getValue();
+return {};
+  }]>
   ];
 }
 
Index: flang/test/Lower/OpenMP/omp-host-ir-flag.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/omp-host-ir-flag.f90
@@ -0,0 +1,6 @@
+!RUN: %flang_fc1 -emit-llvm-bc -fopenmp -o %t.bc %s 2>&1
+!RUN: %flang_fc1 -emit-mlir -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -o - %s 2>&1 | FileCheck %s
+
+!CHECK: module attributes {{{.*}}, omp.host_ir_filepath = "{{.*}}.bc", omp.is_device = #omp.isdevice{{.*}}}
+subroutine omp_subroutine()
+end subroutine omp_subroutine
Index: flang/test/Driver/omp-driver-offload.f90
===
--- flang/test/Driver/omp-driver-offload.f90
+++ flang/test/Driver/omp-driver-offload.f90
@@ -47,15 +47,15 @@
 ! RUN: %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-DEVICE %s
 ! CHECK-OPENMP-IS-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
 
-! Testing fembed-offload-object and fopenmp-is-device
+! Testing appropriate flags are gnerated and appropriately assigned by the driver when offloading
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a \
 ! RUN: --target=aarch64-unknown-linux-gnu \
-! RUN:   | FileCheck %s --check-prefixes=CHECK-OPENMP-EMBED
-! CHECK-OPENMP-EMBED: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}}.f90"
-! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
-! CHECK-OPENMP-EMBED: "{{[^"]*}}clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"
-! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}} "-fembed-offload-object={{.*}}.out" {{.*}}.bc"
+! RUN:   | FileCheck %s --check-prefix=OPENMP-OFFLOAD-ARGS
+! OPENMP-OFFLOAD-ARGS: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}}.f90"
+! OPENMP-OFFLOAD-ARGS-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp" 

[PATCH] D149059: [clang][Interp] Fix zero-init of float and pointer arrays

2023-04-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  Our Zero opcode only exists for integer types. Use
  visitZeroInitializer() here as well so it works for floats and pointers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149059

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/arrays.cpp


Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -334,3 +334,19 @@
// ref-error {{not an integral constant 
expression}} \
   // ref-note {{in call to}}
 };
+
+namespace ZeroInit {
+  struct A {
+int *p[2];
+  };
+  constexpr A a = {};
+  static_assert(a.p[0] == nullptr, "");
+  static_assert(a.p[1] == nullptr, "");
+
+  struct B {
+double f[2];
+  };
+  constexpr B b = {};
+  static_assert(b.f[0] == 0.0, "");
+  static_assert(b.f[1] == 0.0, "");
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1432,7 +1432,7 @@
   //   since we memset our Block*s to 0 and so we have the desired value
   //   without this.
   for (size_t I = 0; I != NumElems; ++I) {
-if (!this->emitZero(*ElemT, Initializer))
+if (!this->visitZeroInitializer(CAT->getElementType(), Initializer))
   return false;
 if (!this->emitInitElem(*ElemT, I, Initializer))
   return false;


Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -334,3 +334,19 @@
// ref-error {{not an integral constant expression}} \
   // ref-note {{in call to}}
 };
+
+namespace ZeroInit {
+  struct A {
+int *p[2];
+  };
+  constexpr A a = {};
+  static_assert(a.p[0] == nullptr, "");
+  static_assert(a.p[1] == nullptr, "");
+
+  struct B {
+double f[2];
+  };
+  constexpr B b = {};
+  static_assert(b.f[0] == 0.0, "");
+  static_assert(b.f[1] == 0.0, "");
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1432,7 +1432,7 @@
   //   since we memset our Block*s to 0 and so we have the desired value
   //   without this.
   for (size_t I = 0; I != NumElems; ++I) {
-if (!this->emitZero(*ElemT, Initializer))
+if (!this->visitZeroInitializer(CAT->getElementType(), Initializer))
   return false;
 if (!this->emitInitElem(*ElemT, I, Initializer))
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon marked an inline comment as done.
agozillon added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:730
+res.getLangOpts().OMPHostIRFile = arg->getValue();
+if (!llvm::sys::fs::exists(res.getLangOpts().OMPHostIRFile))
+  diags.Report(clang::diag::err_drv_omp_host_ir_file_not_found)

awarzynski wrote:
> agozillon wrote:
> > awarzynski wrote:
> > > I think that this is expecting a bit too much from `CompilerInvocation`. 
> > > Instead, whatever is going to use this file should complain if the file 
> > > does not exist (`CompilerInvocation` is merely a messenger here, and file 
> > > I/O can be quite expensive, hence my reservations).
> > > 
> > > Is it possible to create a test for "invalid file path" wherever this 
> > > becomes relevant? 
> > I believe the follow up patch I have here which uses the file, emits an 
> > error if it can't find it: https://reviews.llvm.org/D148370 
> > However, in this case it's an assert rather than more useful Diagnostics 
> > unfortunately. 
> > 
> > Although, this segment of code does currently just mimic what Clang does in 
> > it's own 
> > `CompilerInvocation`: 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/CompilerInvocation.cpp#L3883
> >  
> > 
> > So it depends if we wish to try to maintain the status quo for the shared 
> > argument across the compiler frontends! 
> > 
> > So whichever you prefer, I am happy to remove the check at this level and 
> > let the lowering handle the problem if it arises :-) but I do like sharing 
> > the commonality with Clang where possible.
> Consistency with Clang is a good idea 👍🏻  Though I would appreciate a test 
> that demonstrates that this diagnostic is indeed issues when a non-existing 
> files is specified :)
Thank you for pointing out a test was required! I've added one now :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148038/new/

https://reviews.llvm.org/D148038

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


[PATCH] D144651: [Serialization] Place command line defines in the correct file

2023-04-24 Thread John Brawn via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG524ed4b1ba51: [Serialization] Place command line defines in 
the correct file (authored by john.brawn).

Changed prior to commit:
  https://reviews.llvm.org/D144651?vs=511153&id=516377#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144651/new/

https://reviews.llvm.org/D144651

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang/docs/ReleaseNotes.rst
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/PCH/macro-cmdline.c
  clang/test/PCH/ms-pch-macro.c

Index: clang/test/PCH/ms-pch-macro.c
===
--- clang/test/PCH/ms-pch-macro.c
+++ clang/test/PCH/ms-pch-macro.c
@@ -36,4 +36,4 @@
 // CHECK-FOO: definition of macro 'FOO' differs between the precompiled header ('1') and the command line ('blah')
 // CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line
 
-// expected-warning@1 {{definition of macro 'BAR' does not match definition in precompiled header}}
+// expected-warning@2 {{definition of macro 'BAR' does not match definition in precompiled header}}
Index: clang/test/PCH/macro-cmdline.c
===
--- /dev/null
+++ clang/test/PCH/macro-cmdline.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-pch -o %t1.pch -DMACRO1=1
+// RUN: %clang_cc1 -fsyntax-only %s -include-pch %t1.pch -DMACRO2=1 2>&1 | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+#else
+#define MACRO1 2
+// CHECK: macro-cmdline.c{{.*}}'MACRO1' macro redefined
+// CHECK: {{.*}}previous definition is here
+#define MACRO2 2
+// CHECK: macro-cmdline.c{{.*}}'MACRO2' macro redefined
+// CHECK: {{.*}}previous definition is here
+#endif
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -4441,6 +4441,11 @@
 bool ASTWriter::PreparePathForOutput(SmallVectorImpl &Path) {
   assert(Context && "should have context when outputting path");
 
+  // Leave special file names as they are.
+  StringRef PathStr(Path.data(), Path.size());
+  if (PathStr == "" || PathStr == "")
+return false;
+
   bool Changed =
   cleanPathForOutput(Context->getSourceManager().getFileManager(), Path);
 
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -654,6 +654,10 @@
   SmallVector ExistingMacroNames;
   collectMacroDefinitions(ExistingPPOpts, ExistingMacros, &ExistingMacroNames);
 
+  // Use a line marker to enter the  file, as the defines and
+  // undefines here will have come from the command line.
+  SuggestedPredefines += "# 1 \"\" 1\n";
+
   for (unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
 // Dig out the macro definition in the existing preprocessor options.
 StringRef MacroName = ExistingMacroNames[I];
@@ -713,6 +717,10 @@
 }
 return true;
   }
+
+  // Leave the  file and return to .
+  SuggestedPredefines += "# 1 \"\" 2\n";
+
   if (Validation == OptionValidateStrictMatches) {
 // If strict matches are requested, don't tolerate any extra defines in
 // the AST file that are missing on the command line.
@@ -1579,8 +1587,13 @@
 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
 if (!Buffer)
   return true;
-SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
-   BaseOffset + Offset, IncludeLoc);
+FileID FID = SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
+BaseOffset + Offset, IncludeLoc);
+if (Record[3]) {
+  auto &FileInfo =
+  const_cast(SourceMgr.getSLocEntry(FID).getFile());
+  FileInfo.setHasLineDirectives();
+}
 break;
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -207,8 +207,8 @@
 - Diagnostic notes and fix-its are now generated for ``ifunc``/``alias`` attributes
   which point to functions whose names are mangled.
 - Diagnostics relating to macros on the command line of a preprocessed assembly
-  file are now reported as coming from the file  instead of
-  .
+  file or precompiled header are now reported as coming from the file
+   instead of .
 - Clang constexpr evaluator now provides a more concise diagnostic when calling
   function pointer that is known to be null.
 - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` statements
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
=

[clang-tools-extra] 524ed4b - [Serialization] Place command line defines in the correct file

2023-04-24 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-04-24T14:07:41+01:00
New Revision: 524ed4b1ba518d5dd5d67fb9593e0864b0e664a4

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

LOG: [Serialization] Place command line defines in the correct file

Fix several problems related to serialization causing command line
defines to be reported as being built-in defines:
 * When serializing the  and  files don't
   convert them into absolute paths.
 * When deserializing SM_SLOC_BUFFER_ENTRY we need to call
   setHasLineDirectives in the same way as we do for
   SM_SLOC_FILE_ENTRY.
 * When created suggested predefines based on the current command line
   options we need to add line markers in the same way that
   InitializePreprocessor does.
 * Adjust a place in clangd where it was implicitly relying on command
   line defines being treated as builtin.

Differential Revision: https://reviews.llvm.org/D144651

Added: 
clang/test/PCH/macro-cmdline.c

Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang/docs/ReleaseNotes.rst
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/PCH/ms-pch-macro.c

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 5c8112e60b224..a2f8cd2a0cdaf 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -687,8 +687,10 @@ bool SymbolCollector::handleMacroOccurrence(const 
IdentifierInfo *Name,
 
   const auto &SM = PP->getSourceManager();
   auto DefLoc = MI->getDefinitionLoc();
-  // Also avoid storing predefined macros like __DBL_MIN__.
+  // Also avoid storing macros that aren't defined in any file, i.e. predefined
+  // macros like __DBL_MIN__ and those defined on the command line.
   if (SM.isWrittenInBuiltinFile(DefLoc) ||
+  SM.isWrittenInCommandLineFile(DefLoc) ||
   Name->getName() == "__GCC_HAVE_DWARF2_CFI_ASM")
 return true;
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7beae03247796..a1bb925e8ae24 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -207,8 +207,8 @@ Improvements to Clang's diagnostics
 - Diagnostic notes and fix-its are now generated for ``ifunc``/``alias`` 
attributes
   which point to functions whose names are mangled.
 - Diagnostics relating to macros on the command line of a preprocessed assembly
-  file are now reported as coming from the file  instead of
-  .
+  file or precompiled header are now reported as coming from the file
+   instead of .
 - Clang constexpr evaluator now provides a more concise diagnostic when calling
   function pointer that is known to be null.
 - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` 
statements

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index b27304deb33c9..098ce5314ab17 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -654,6 +654,10 @@ static bool checkPreprocessorOptions(
   SmallVector ExistingMacroNames;
   collectMacroDefinitions(ExistingPPOpts, ExistingMacros, &ExistingMacroNames);
 
+  // Use a line marker to enter the  file, as the defines and
+  // undefines here will have come from the command line.
+  SuggestedPredefines += "# 1 \"\" 1\n";
+
   for (unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
 // Dig out the macro definition in the existing preprocessor options.
 StringRef MacroName = ExistingMacroNames[I];
@@ -713,6 +717,10 @@ static bool checkPreprocessorOptions(
 }
 return true;
   }
+
+  // Leave the  file and return to .
+  SuggestedPredefines += "# 1 \"\" 2\n";
+
   if (Validation == OptionValidateStrictMatches) {
 // If strict matches are requested, don't tolerate any extra defines in
 // the AST file that are missing on the command line.
@@ -1579,8 +1587,13 @@ bool ASTReader::ReadSLocEntry(int ID) {
 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
 if (!Buffer)
   return true;
-SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
-   BaseOffset + Offset, IncludeLoc);
+FileID FID = SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
+BaseOffset + Offset, IncludeLoc);
+if (Record[3]) {
+  auto &FileInfo =
+  const_cast(SourceMgr.getSLocEntry(FID).getFile());
+  FileInfo.setHasLineDirectives();
+}
 break;
   }
 

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 7c62aac9901f1..3d738149febcb 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Se

[PATCH] D148612: [clang][dataflow] Use existing accessors to check for copy and move assignment ops.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 516378.
mboehme added a comment.

Rebased to head


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148612/new/

https://reviews.llvm.org/D148612

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp


Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -646,9 +646,12 @@
   assert(Arg1 != nullptr);
 
   // Evaluate only copy and move assignment operators.
-  auto *Arg0Type = Arg0->getType()->getUnqualifiedDesugaredType();
-  auto *Arg1Type = Arg1->getType()->getUnqualifiedDesugaredType();
-  if (Arg0Type != Arg1Type)
+  const auto *Method =
+  dyn_cast_or_null(S->getDirectCallee());
+  if (!Method)
+return;
+  if (!Method->isCopyAssignmentOperator() &&
+  !Method->isMoveAssignmentOperator())
 return;
 
   auto *ObjectLoc = Env.getStorageLocation(*Arg0, SkipPast::Reference);


Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -646,9 +646,12 @@
   assert(Arg1 != nullptr);
 
   // Evaluate only copy and move assignment operators.
-  auto *Arg0Type = Arg0->getType()->getUnqualifiedDesugaredType();
-  auto *Arg1Type = Arg1->getType()->getUnqualifiedDesugaredType();
-  if (Arg0Type != Arg1Type)
+  const auto *Method =
+  dyn_cast_or_null(S->getDirectCallee());
+  if (!Method)
+return;
+  if (!Method->isCopyAssignmentOperator() &&
+  !Method->isMoveAssignmentOperator())
 return;
 
   auto *ObjectLoc = Env.getStorageLocation(*Arg0, SkipPast::Reference);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146557: [MLIR][OpenMP] Refactoring how map clause is processed

2023-04-24 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 516379.
TIFitis marked an inline comment as done.
TIFitis added a comment.

Cleaned up how IsBegin argument is passed for createTargetData call.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146557/new/

https://reviews.llvm.org/D146557

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -12,32 +12,24 @@
 }
 
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
-// CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
-// CHECK: br label %[[VAL_4:.*]]
-// CHECK:   entry:; preds = %[[VAL_5:.*]]
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_8]], align 4
+// CHECK: %[[VAL_2:.*]] = alloca i32, i64 1, align 4
+// CHECK: br label %[[VAL_3:.*]]
+// CHECK:   entry:; preds = %[[VAL_4:.*]]
+// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_2]], ptr %[[VAL_5]], align 8
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_2]], ptr %[[VAL_6]], align 8
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_7]], ptr %[[VAL_8]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: store i32 99, ptr %[[VAL_2]], align 4
 // CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr %[[VAL_11]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
-// CHECK: br label %[[VAL_12:.*]]
-// CHECK:   omp.data.region:  ; preds = %[[VAL_4]]
-// CHECK: store i32 99, ptr %[[VAL_3]], align 4
-// CHECK: br label %[[VAL_13:.*]]
-// CHECK:   omp.region.cont:  ; preds = %[[VAL_12]]
-// CHECK: %[[VAL_14:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_15:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_16:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_14]], ptr %[[VAL_15]], ptr %[[VAL_16]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
 // CHECK: ret void
 
 // -
@@ -56,38 +48,30 @@
 }
 
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x p

[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-04-24 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp updated this revision to Diff 516380.
dkrupp marked 10 inline comments as done.
dkrupp added a comment.

-append_range(..) used instead of std::vector.insert(...) to improve readability
-minor updates based on @steakhal comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144269/new/

https://reviews.llvm.org/D144269

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Taint.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Taint.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
  clang/test/Analysis/taint-diagnostic-visitor.c
  clang/test/Analysis/taint-tester.c

Index: clang/test/Analysis/taint-tester.c
===
--- clang/test/Analysis/taint-tester.c
+++ clang/test/Analysis/taint-tester.c
@@ -122,7 +122,7 @@
   fscanf(pp, "%d", &ii);
   int jj = ii;// expected-warning + {{tainted}}
 
-  fscanf(p, "%d", &ii);
+  fscanf(p, "%d", &ii);// expected-warning + {{tainted}}
   int jj2 = ii;// expected-warning + {{tainted}}
 
   ii = 3;
Index: clang/test/Analysis/taint-diagnostic-visitor.c
===
--- clang/test/Analysis/taint-diagnostic-visitor.c
+++ clang/test/Analysis/taint-diagnostic-visitor.c
@@ -2,13 +2,24 @@
 
 // This file is for testing enhanced diagnostics produced by the GenericTaintChecker
 
+typedef __typeof(sizeof(int)) size_t;
+struct _IO_FILE;
+typedef struct _IO_FILE FILE;
+
 int scanf(const char *restrict format, ...);
 int system(const char *command);
+char* getenv( const char* env_var );
+size_t strlen( const char* str );
+void *malloc(size_t size );
+void free( void *ptr );
+char *fgets(char *str, int n, FILE *stream);
+FILE *stdin;
 
 void taintDiagnostic(void)
 {
   char buf[128];
   scanf("%s", buf); // expected-note {{Taint originated here}}
+// expected-note@-1 {{Taint propagated to the 2nd argument}}
   system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}}
 }
 
@@ -16,6 +27,7 @@
   int index;
   int Array[] = {1, 2, 3, 4, 5};
   scanf("%d", &index); // expected-note {{Taint originated here}}
+   // expected-note@-1 {{Taint propagated to the 2nd argument}}
   return Array[index]; // expected-warning {{Out of bound memory access (index is tainted)}}
// expected-note@-1 {{Out of bound memory access (index is tainted)}}
 }
@@ -23,6 +35,7 @@
 int taintDiagnosticDivZero(int operand) {
   scanf("%d", &operand); // expected-note {{Value assigned to 'operand'}}
  // expected-note@-1 {{Taint originated here}}
+ // expected-note@-2 {{Taint propagated to the 2nd argument}}
   return 10 / operand; // expected-warning {{Division by a tainted value, possibly zero}}
// expected-note@-1 {{Division by a tainted value, possibly zero}}
 }
@@ -31,6 +44,72 @@
   int x;
   scanf("%d", &x); // expected-note {{Value assigned to 'x'}}
// expected-note@-1 {{Taint originated here}}
+   // expected-note@-2 {{Taint propagated to the 2nd argument}}
   int vla[x]; // expected-warning {{Declared variable-length array (VLA) has tainted size}}
   // expected-note@-1 {{Declared variable-length array (VLA) has tainted size}}
 }
+
+
+// Tests if the originated note is correctly placed even if the path is
+// propagating through variables and expressions
+char *taintDiagnosticPropagation(){
+  char *pathbuf;
+  char *pathlist=getenv("PATH"); // expected-note {{Taint originated here}}
+ // expected-note@-1 {{Taint propagated to the return value}}
+  if (pathlist){ // expected-note {{Assuming 'pathlist' is non-null}}
+	   // expected-note@-1 {{Taking true branch}}
+pathbuf=(char*) malloc(strlen(pathlist)+1); // expected-warning{{Untrusted data is used to specify the buffer size}}
+// expected-note@-1{{Untrusted data is used to specify the buffer size}}
+// expected-note@-2 {{Taint propagated to the return value}}
+return pathbuf;
+  }
+  return 0;
+}
+
+// Taint origin should be marked correctly even if there are multiple taint
+// sources in the function
+char *taintDiagnosticPropagation2(){
+  char *pathbuf;
+  char *user_env2=getenv("USER_ENV_VAR2");//unrelated taint source
+  char *pathlist=getenv("PATH"); // expected-note {{Taint originated here}}
+ // expected-note@-1 {{Taint propagated

[PATCH] D147684: [clangd] Add batch fixes for include-cleaner diagnostics

2023-04-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 516382.
hokein marked 6 inline comments as done.
hokein added a comment.

- address review comments
- add LSP's ChangeAnnotations support and use it in the include-cleaner batch 
fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147684/new/

https://reviews.llvm.org/D147684

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -45,8 +45,8 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-Matcher withFix(::testing::Matcher FixMatcher) {
-  return Field(&Diag::Fixes, ElementsAre(FixMatcher));
+Matcher withFix(std::vector<::testing::Matcher> FixMatcheres) {
+  return Field(&Diag::Fixes, testing::UnorderedElementsAreArray(FixMatcheres));
 }
 
 MATCHER_P2(Diag, Range, Message,
@@ -60,6 +60,8 @@
   return arg.Message == Message && arg.Edits.size() == 1 &&
  arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
 }
+MATCHER_P(FixMessage, Message, "") { return arg.Message == Message; }
+
 
 std::string guard(llvm::StringRef Code) {
   return "#pragma once\n" + Code.str();
@@ -255,42 +257,51 @@
   UnorderedElementsAre(
   AllOf(Diag(MainFile.range("b"),
  "No header providing \"b\" is directly included"),
-withFix(Fix(MainFile.range("insert_b"), "#include \"b.h\"\n",
-"#include \"b.h\""))),
+withFix({Fix(MainFile.range("insert_b"), "#include \"b.h\"\n",
+ "#include \"b.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("bar"),
  "No header providing \"ns::Bar\" is directly included"),
-withFix(Fix(MainFile.range("insert_d"),
-"#include \"dir/d.h\"\n", "#include \"dir/d.h\""))),
+withFix({Fix(MainFile.range("insert_d"),
+ "#include \"dir/d.h\"\n", "#include \"dir/d.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("f"),
  "No header providing \"f\" is directly included"),
-withFix(Fix(MainFile.range("insert_f"), "#include \n",
-"#include "))),
+withFix({Fix(MainFile.range("insert_f"), "#include \n",
+ "#include "),
+ FixMessage("add all missing includes")})),
   AllOf(
   Diag(MainFile.range("foobar"),
"No header providing \"foobar\" is directly included"),
-  withFix(Fix(MainFile.range("insert_foobar"),
-  "#include \"public.h\"\n", "#include \"public.h\""))),
+  withFix({Fix(MainFile.range("insert_foobar"),
+   "#include \"public.h\"\n", "#include \"public.h\""),
+   FixMessage("add all missing includes")})),
   AllOf(
   Diag(MainFile.range("vector"),
"No header providing \"std::vector\" is directly included"),
-  withFix(Fix(MainFile.range("insert_vector"),
-  "#include \n", "#include "))),
+  withFix({Fix(MainFile.range("insert_vector"),
+   "#include \n", "#include "),
+   FixMessage("add all missing includes"),})),
   AllOf(Diag(MainFile.range("FOO"),
  "No header providing \"FOO\" is directly included"),
-withFix(Fix(MainFile.range("insert_foo"),
-"#include \"foo.h\"\n", "#include \"foo.h\""))),
+withFix({Fix(MainFile.range("insert_foo"),
+ "#include \"foo.h\"\n", "#include \"foo.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("DEF"),
  "No header providing \"Foo\" is directly included"),
-withFix(Fix(MainFile.range("insert_foo"),
-"#include \"foo.h\"\n", "#include \"foo.h\""))),
+withFix({Fix(MainFile.range("insert_foo"),
+ "#include \"foo.h\"\n", "#include \"foo.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("BAR"

[PATCH] D147684: [clangd] Add batch fixes for include-cleaner diagnostics

2023-04-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 516384.
hokein added a comment.

some cleanups.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147684/new/

https://reviews.llvm.org/D147684

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -45,8 +45,8 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-Matcher withFix(::testing::Matcher FixMatcher) {
-  return Field(&Diag::Fixes, ElementsAre(FixMatcher));
+Matcher withFix(std::vector<::testing::Matcher> FixMatcheres) {
+  return Field(&Diag::Fixes, testing::UnorderedElementsAreArray(FixMatcheres));
 }
 
 MATCHER_P2(Diag, Range, Message,
@@ -60,6 +60,8 @@
   return arg.Message == Message && arg.Edits.size() == 1 &&
  arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
 }
+MATCHER_P(FixMessage, Message, "") { return arg.Message == Message; }
+
 
 std::string guard(llvm::StringRef Code) {
   return "#pragma once\n" + Code.str();
@@ -255,42 +257,51 @@
   UnorderedElementsAre(
   AllOf(Diag(MainFile.range("b"),
  "No header providing \"b\" is directly included"),
-withFix(Fix(MainFile.range("insert_b"), "#include \"b.h\"\n",
-"#include \"b.h\""))),
+withFix({Fix(MainFile.range("insert_b"), "#include \"b.h\"\n",
+ "#include \"b.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("bar"),
  "No header providing \"ns::Bar\" is directly included"),
-withFix(Fix(MainFile.range("insert_d"),
-"#include \"dir/d.h\"\n", "#include \"dir/d.h\""))),
+withFix({Fix(MainFile.range("insert_d"),
+ "#include \"dir/d.h\"\n", "#include \"dir/d.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("f"),
  "No header providing \"f\" is directly included"),
-withFix(Fix(MainFile.range("insert_f"), "#include \n",
-"#include "))),
+withFix({Fix(MainFile.range("insert_f"), "#include \n",
+ "#include "),
+ FixMessage("add all missing includes")})),
   AllOf(
   Diag(MainFile.range("foobar"),
"No header providing \"foobar\" is directly included"),
-  withFix(Fix(MainFile.range("insert_foobar"),
-  "#include \"public.h\"\n", "#include \"public.h\""))),
+  withFix({Fix(MainFile.range("insert_foobar"),
+   "#include \"public.h\"\n", "#include \"public.h\""),
+   FixMessage("add all missing includes")})),
   AllOf(
   Diag(MainFile.range("vector"),
"No header providing \"std::vector\" is directly included"),
-  withFix(Fix(MainFile.range("insert_vector"),
-  "#include \n", "#include "))),
+  withFix({Fix(MainFile.range("insert_vector"),
+   "#include \n", "#include "),
+   FixMessage("add all missing includes"),})),
   AllOf(Diag(MainFile.range("FOO"),
  "No header providing \"FOO\" is directly included"),
-withFix(Fix(MainFile.range("insert_foo"),
-"#include \"foo.h\"\n", "#include \"foo.h\""))),
+withFix({Fix(MainFile.range("insert_foo"),
+ "#include \"foo.h\"\n", "#include \"foo.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("DEF"),
  "No header providing \"Foo\" is directly included"),
-withFix(Fix(MainFile.range("insert_foo"),
-"#include \"foo.h\"\n", "#include \"foo.h\""))),
+withFix({Fix(MainFile.range("insert_foo"),
+ "#include \"foo.h\"\n", "#include \"foo.h\""),
+ FixMessage("add all missing includes")})),
   AllOf(Diag(MainFile.range("BAR"),
  "No header providing \"BAR\" is directly included"),
-withFix(Fix(MainFile.range("insert_foo")

[PATCH] D147684: [clangd] Add batch fixes for include-cleaner diagnostics

2023-04-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

I have extended this patch a bit more (including the LSP `ChangeAnnotation` 
support part), it is based on https://reviews.llvm.org/D148783), and it 
implements a full workflow of batch fixes (verified it with VSCode). I hope it 
is not too big to review, happy to split it if you want.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147684/new/

https://reviews.llvm.org/D147684

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


[PATCH] D148712: [clang] Diagnose shadowing of lambda's template parameter by a capture

2023-04-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

Thanks, this looks good to me now!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148712/new/

https://reviews.llvm.org/D148712

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


[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for addressing my comments!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148038/new/

https://reviews.llvm.org/D148038

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


[PATCH] D142401: [Clang] Fix a crash when recursively callig a default member initializer.

2023-04-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 516387.
cor3ntin added a comment.

Address comments, implement Aaron's clever solution, Rebase and add release note


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142401/new/

https://reviews.llvm.org/D142401

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers-recurse.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers.cpp

Index: clang/test/SemaCXX/cxx11-default-member-initializers.cpp
===
--- clang/test/SemaCXX/cxx11-default-member-initializers.cpp
+++ clang/test/SemaCXX/cxx11-default-member-initializers.cpp
@@ -106,3 +106,20 @@
 }
 
 #endif
+
+// Recursively constructing default member initializers
+// should not crash clang.
+namespace GH60082 {
+
+struct A;
+
+int f(const A&) { return 42; }
+
+struct A {
+   int x = f(A());
+   A() { }
+};
+
+void foo() { A(); }
+
+}
Index: clang/test/SemaCXX/cxx11-default-member-initializers-recurse.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx11-default-member-initializers-recurse.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++20 %s
+
+// Recursively constructing default member initializers
+// should not crash clang.
+namespace GH60082 {
+
+struct A;
+
+int f(const A&) { return 42; }
+
+struct A {
+   int x = f(A());
+   A() { }
+};
+
+void foo() { A(); }
+
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5926,7 +5926,9 @@
   Param);
   ExprEvalContexts.back().IsCurrentlyCheckingDefaultArgumentOrInitializer =
   SkipImmediateInvocations;
-  MarkDeclarationsReferencedInExpr(Init, /*SkipLocalVariables*/ true);
+  runWithSufficientStackSpace(CallLoc, [&] {
+MarkDeclarationsReferencedInExpr(Init, /*SkipLocalVariables=*/true);
+  });
   return false;
 }
 
@@ -6036,8 +6038,11 @@
   ExprEvalContexts.back().DelayedDefaultInitializationContext = {
   CallLoc, Param, CurContext};
   EnsureImmediateInvocationInDefaultArgs Immediate(*this);
-  ExprResult Res = Immediate.TransformInitializer(Param->getInit(),
-  /*NotCopy=*/false);
+  ExprResult Res;
+  runWithSufficientStackSpace(CallLoc, [&] {
+Res = Immediate.TransformInitializer(Param->getInit(),
+ /*NotCopy=*/false);
+  });
   if (Res.isInvalid())
 return ExprError();
   Res = ConvertParamDefaultArgument(Param, Res.get(),
@@ -6117,10 +6122,11 @@
 NestedDefaultChecking;
 
 EnsureImmediateInvocationInDefaultArgs Immediate(*this);
-
-ExprResult Res =
-Immediate.TransformInitializer(Field->getInClassInitializer(),
-   /*CXXDirectInit=*/false);
+ExprResult Res;
+runWithSufficientStackSpace(Loc, [&] {
+  Res = Immediate.TransformInitializer(Field->getInClassInitializer(),
+   /*CXXDirectInit=*/false);
+});
 if (!Res.isInvalid())
   Res = ConvertMemberDefaultInitExpression(Field, Res.get(), Loc);
 if (Res.isInvalid()) {
@@ -6133,7 +6139,9 @@
   if (Field->getInClassInitializer()) {
 Expr *E = Init ? Init : Field->getInClassInitializer();
 if (!NestedDefaultChecking)
-  MarkDeclarationsReferencedInExpr(E, /*SkipLocalVariables=*/false);
+  runWithSufficientStackSpace(Loc, [&] {
+MarkDeclarationsReferencedInExpr(E, /*SkipLocalVariables=*/false);
+  });
 // C++11 [class.base.init]p7:
 //   The initialization of each base and member constitutes a
 //   full-expression.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -307,8 +307,8 @@
   not a type concept.
 - Fix crash when a doc comment contains a line splicing.
   (`#62054 `_)
-- Work around with a clang coverage crash which happens when visiting 
-  expressions/statements with invalid source locations in non-assert builds. 
+- Work around with a clang coverage crash which happens when visiting
+  expressions/statements with invalid source locations in non-assert builds.
   Assert builds may still see assertions triggered from this.
 - Fix a failed assertion due to an invalid source location when trying to form
   a coverage report for an unresolved constructor expression.
@@ -321,6 +321,8 @@
   (`#61885 `_)
 - Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
   member pointer as an invalid expression.
+- Fix a stack overflow issue when evaluating ``consteval`` default arguments.
+  (`#60082` 

[PATCH] D142401: [Clang] Fix a crash when recursively callig a default member initializer.

2023-04-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 516388.
cor3ntin added a comment.

Remove duplicated test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142401/new/

https://reviews.llvm.org/D142401

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers-recurse.cpp

Index: clang/test/SemaCXX/cxx11-default-member-initializers-recurse.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx11-default-member-initializers-recurse.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++20 %s
+
+// Recursively constructing default member initializers
+// should not crash clang.
+namespace GH60082 {
+
+struct A;
+
+int f(const A&) { return 42; }
+
+struct A {
+   int x = f(A());
+   A() { }
+};
+
+void foo() { A(); }
+
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5926,7 +5926,9 @@
   Param);
   ExprEvalContexts.back().IsCurrentlyCheckingDefaultArgumentOrInitializer =
   SkipImmediateInvocations;
-  MarkDeclarationsReferencedInExpr(Init, /*SkipLocalVariables*/ true);
+  runWithSufficientStackSpace(CallLoc, [&] {
+MarkDeclarationsReferencedInExpr(Init, /*SkipLocalVariables=*/true);
+  });
   return false;
 }
 
@@ -6036,8 +6038,11 @@
   ExprEvalContexts.back().DelayedDefaultInitializationContext = {
   CallLoc, Param, CurContext};
   EnsureImmediateInvocationInDefaultArgs Immediate(*this);
-  ExprResult Res = Immediate.TransformInitializer(Param->getInit(),
-  /*NotCopy=*/false);
+  ExprResult Res;
+  runWithSufficientStackSpace(CallLoc, [&] {
+Res = Immediate.TransformInitializer(Param->getInit(),
+ /*NotCopy=*/false);
+  });
   if (Res.isInvalid())
 return ExprError();
   Res = ConvertParamDefaultArgument(Param, Res.get(),
@@ -6117,10 +6122,11 @@
 NestedDefaultChecking;
 
 EnsureImmediateInvocationInDefaultArgs Immediate(*this);
-
-ExprResult Res =
-Immediate.TransformInitializer(Field->getInClassInitializer(),
-   /*CXXDirectInit=*/false);
+ExprResult Res;
+runWithSufficientStackSpace(Loc, [&] {
+  Res = Immediate.TransformInitializer(Field->getInClassInitializer(),
+   /*CXXDirectInit=*/false);
+});
 if (!Res.isInvalid())
   Res = ConvertMemberDefaultInitExpression(Field, Res.get(), Loc);
 if (Res.isInvalid()) {
@@ -6133,7 +6139,9 @@
   if (Field->getInClassInitializer()) {
 Expr *E = Init ? Init : Field->getInClassInitializer();
 if (!NestedDefaultChecking)
-  MarkDeclarationsReferencedInExpr(E, /*SkipLocalVariables=*/false);
+  runWithSufficientStackSpace(Loc, [&] {
+MarkDeclarationsReferencedInExpr(E, /*SkipLocalVariables=*/false);
+  });
 // C++11 [class.base.init]p7:
 //   The initialization of each base and member constitutes a
 //   full-expression.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -307,8 +307,8 @@
   not a type concept.
 - Fix crash when a doc comment contains a line splicing.
   (`#62054 `_)
-- Work around with a clang coverage crash which happens when visiting 
-  expressions/statements with invalid source locations in non-assert builds. 
+- Work around with a clang coverage crash which happens when visiting
+  expressions/statements with invalid source locations in non-assert builds.
   Assert builds may still see assertions triggered from this.
 - Fix a failed assertion due to an invalid source location when trying to form
   a coverage report for an unresolved constructor expression.
@@ -321,6 +321,8 @@
   (`#61885 `_)
 - Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
   member pointer as an invalid expression.
+- Fix a stack overflow issue when evaluating ``consteval`` default arguments.
+  (`#60082` `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-04-24 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp updated this revision to Diff 516389.
dkrupp marked an inline comment as done.
dkrupp added a comment.

-using llvm::ArrayRef in the reportTaintBug(..) function in the 
DivZero Checker


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144269/new/

https://reviews.llvm.org/D144269

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Taint.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Taint.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
  clang/test/Analysis/taint-diagnostic-visitor.c
  clang/test/Analysis/taint-tester.c

Index: clang/test/Analysis/taint-tester.c
===
--- clang/test/Analysis/taint-tester.c
+++ clang/test/Analysis/taint-tester.c
@@ -122,7 +122,7 @@
   fscanf(pp, "%d", &ii);
   int jj = ii;// expected-warning + {{tainted}}
 
-  fscanf(p, "%d", &ii);
+  fscanf(p, "%d", &ii);// expected-warning + {{tainted}}
   int jj2 = ii;// expected-warning + {{tainted}}
 
   ii = 3;
Index: clang/test/Analysis/taint-diagnostic-visitor.c
===
--- clang/test/Analysis/taint-diagnostic-visitor.c
+++ clang/test/Analysis/taint-diagnostic-visitor.c
@@ -2,13 +2,24 @@
 
 // This file is for testing enhanced diagnostics produced by the GenericTaintChecker
 
+typedef __typeof(sizeof(int)) size_t;
+struct _IO_FILE;
+typedef struct _IO_FILE FILE;
+
 int scanf(const char *restrict format, ...);
 int system(const char *command);
+char* getenv( const char* env_var );
+size_t strlen( const char* str );
+void *malloc(size_t size );
+void free( void *ptr );
+char *fgets(char *str, int n, FILE *stream);
+FILE *stdin;
 
 void taintDiagnostic(void)
 {
   char buf[128];
   scanf("%s", buf); // expected-note {{Taint originated here}}
+// expected-note@-1 {{Taint propagated to the 2nd argument}}
   system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}}
 }
 
@@ -16,6 +27,7 @@
   int index;
   int Array[] = {1, 2, 3, 4, 5};
   scanf("%d", &index); // expected-note {{Taint originated here}}
+   // expected-note@-1 {{Taint propagated to the 2nd argument}}
   return Array[index]; // expected-warning {{Out of bound memory access (index is tainted)}}
// expected-note@-1 {{Out of bound memory access (index is tainted)}}
 }
@@ -23,6 +35,7 @@
 int taintDiagnosticDivZero(int operand) {
   scanf("%d", &operand); // expected-note {{Value assigned to 'operand'}}
  // expected-note@-1 {{Taint originated here}}
+ // expected-note@-2 {{Taint propagated to the 2nd argument}}
   return 10 / operand; // expected-warning {{Division by a tainted value, possibly zero}}
// expected-note@-1 {{Division by a tainted value, possibly zero}}
 }
@@ -31,6 +44,72 @@
   int x;
   scanf("%d", &x); // expected-note {{Value assigned to 'x'}}
// expected-note@-1 {{Taint originated here}}
+   // expected-note@-2 {{Taint propagated to the 2nd argument}}
   int vla[x]; // expected-warning {{Declared variable-length array (VLA) has tainted size}}
   // expected-note@-1 {{Declared variable-length array (VLA) has tainted size}}
 }
+
+
+// Tests if the originated note is correctly placed even if the path is
+// propagating through variables and expressions
+char *taintDiagnosticPropagation(){
+  char *pathbuf;
+  char *pathlist=getenv("PATH"); // expected-note {{Taint originated here}}
+ // expected-note@-1 {{Taint propagated to the return value}}
+  if (pathlist){ // expected-note {{Assuming 'pathlist' is non-null}}
+	   // expected-note@-1 {{Taking true branch}}
+pathbuf=(char*) malloc(strlen(pathlist)+1); // expected-warning{{Untrusted data is used to specify the buffer size}}
+// expected-note@-1{{Untrusted data is used to specify the buffer size}}
+// expected-note@-2 {{Taint propagated to the return value}}
+return pathbuf;
+  }
+  return 0;
+}
+
+// Taint origin should be marked correctly even if there are multiple taint
+// sources in the function
+char *taintDiagnosticPropagation2(){
+  char *pathbuf;
+  char *user_env2=getenv("USER_ENV_VAR2");//unrelated taint source
+  char *pathlist=getenv("PATH"); // expected-note {{Taint originated here}}
+ // expected-note@-1 {{Taint propagated to the return value}}
+  char *user_env=get

[PATCH] D148110: [clang-tidy] Ctor arguments are sequenced if ctor call is written as list-initialization.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 516390.
mboehme marked 2 inline comments as done.
mboehme added a comment.

Changes in response to review comments, and rebased to head.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148110/new/

https://reviews.llvm.org/D148110

Files:
  clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
@@ -1160,42 +1160,63 @@
   }
 }
 
+namespace InitializerListSequences {
+
+struct S1 {
+  int i;
+  A a;
+};
+
+struct S2 {
+  A a;
+  int i;
+};
+
+struct S3 {
+  S3() {}
+  S3(int, A) {}
+  S3(A, int) {}
+};
+
 // An initializer list sequences its initialization clauses.
 void initializerListSequences() {
   {
-struct S1 {
-  int i;
-  A a;
-};
-{
-  A a;
-  S1 s1{a.getInt(), std::move(a)};
-}
-{
-  A a;
-  S1 s1{.i = a.getInt(), .a = std::move(a)};
-}
+A a;
+S1 s1{a.getInt(), std::move(a)};
   }
   {
-struct S2 {
-  A a;
-  int i;
-};
-{
-  A a;
-  S2 s2{std::move(a), a.getInt()};
-  // CHECK-NOTES: [[@LINE-1]]:27: warning: 'a' used after it was moved
-  // CHECK-NOTES: [[@LINE-2]]:13: note: move occurred here
-}
-{
-  A a;
-  S2 s2{.a = std::move(a), .i = a.getInt()};
-  // CHECK-NOTES: [[@LINE-1]]:37: warning: 'a' used after it was moved
-  // CHECK-NOTES: [[@LINE-2]]:13: note: move occurred here
-}
+A a;
+S1 s1{.i = a.getInt(), .a = std::move(a)};
+  }
+  {
+A a;
+S2 s2{std::move(a), a.getInt()};
+// CHECK-NOTES: [[@LINE-1]]:25: warning: 'a' used after it was moved
+// CHECK-NOTES: [[@LINE-2]]:11: note: move occurred here
+  }
+  {
+A a;
+S2 s2{.a = std::move(a), .i = a.getInt()};
+// CHECK-NOTES: [[@LINE-1]]:35: warning: 'a' used after it was moved
+// CHECK-NOTES: [[@LINE-2]]:11: note: move occurred here
+  }
+  {
+// Check the case where the constructed type has a constructor and the
+// initializer list therefore manifests as a `CXXConstructExpr` instead of
+// an `InitListExpr`.
+A a;
+S3 s3{a.getInt(), std::move(a)};
+  }
+  {
+A a;
+S3 s3{std::move(a), a.getInt()};
+// CHECK-NOTES: [[@LINE-1]]:25: warning: 'a' used after it was moved
+// CHECK-NOTES: [[@LINE-2]]:11: note: move occurred here
   }
 }
 
+} // namespace InitializerListSequences
+
 // A declaration statement containing multiple declarations sequences the
 // initializer expressions.
 void declarationSequences() {
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -214,8 +214,9 @@
   to ``std::forward``.
 
 - Improved :doc:`bugprone-use-after-move
-  ` check to also cover constructor
-  initializers.
+  ` check: Also cover constructor
+  initializers. Fix check to understand that constructor arguments are
+  sequenced when constructor call is written as list-initialization.
 
 - Deprecated :doc:`cert-dcl21-cpp
   ` check.
Index: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
+++ clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
@@ -131,6 +131,16 @@
   }
 }
   }
+} else if (const auto *ConstructExpr = dyn_cast(Parent)) {
+  // Constructor arguments are sequenced if the constructor call is written
+  // as list-initialization.
+  if (ConstructExpr->isListInitialization()) {
+for (unsigned I = 1; I < ConstructExpr->getNumArgs(); ++I) {
+  if (ConstructExpr->getArg(I - 1) == S) {
+return ConstructExpr->getArg(I);
+  }
+}
+  }
 } else if (const auto *Compound = dyn_cast(Parent)) {
   // Compound statement: Each sub-statement is sequenced after the
   // statements that precede it.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-04-24 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp added a comment.

@steakhal  thanks for the review. I fixed all outstanding remarks.
I left the test taint-diagnostic-visitor.c formatting as is to remain 
consistent with the rest of the file. I think we should keep it as is, or 
reformat the whole file.




Comment at: clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp:108-109
+  if ((stateNotZero && stateZero)) {
+std::vector taintedSyms = getTaintedSymbols(C.getState(), *DV);
+if (!taintedSyms.empty()) {
+  reportTaintBug("Division by a tainted value, possibly zero", stateZero, 
C,

steakhal wrote:
> dkrupp wrote:
> > steakhal wrote:
> > > 
> > We cannot get rid off the getTaintedSymbols() call, as we need to pass all 
> > tainted symbols to reportTaintBug if we want to track back multiple 
> > variables. taintedSyms is a parameter of reportTaintBug(...)
> Yes, makes sense. mb.
> One more thing: if `reportTaintBug()` takes the `taintedSyms` vector 
> "by-value", you should express your intent by `std::move()`-ing your 
> collection expressing that it's meant to be consumed instead of taking a copy.
> Otherwise, you could express this intent if the `reportTaintBug()` take a 
> //view// type for the collection, such as `llvm::ArrayRef` - which 
> would neither copy nor move from the callsite's vector, being more performant 
> and expressive.
> 
> I get that this vector is small and bugreport construction will dominate the 
> runtime anyway so I'm not complaining about this specific case, I'm just 
> noting this for the next time. So, here I'm not expecting any actions.
Fixed as suggested. thanks.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:947-948
+  if (!TaintedArgSyms.empty()) {
+TaintedSymbols.insert(TaintedSymbols.begin(), TaintedArgSyms.begin(),
+  TaintedArgSyms.end());
+TaintedIndexes.push_back(I);

steakhal wrote:
> steakhal wrote:
> > 
> I observed you didn't take any action about this suggestion.
> It leaves me wonder if this suggestion - in general - makes sense or if there 
> are other reasons what I cannot foresee.
> I've seen you using the fully spelled-out version in total 8 times.
> Shouldn't we prefer the shorter, more expressive version instead?
Sorry I overlooked this comment. I like this shorter version. It is so much 
consize!  Changed at all places. Thanks for the suggestion.



Comment at: clang/test/Analysis/taint-diagnostic-visitor.c:53-67
+//Tests if the originated note is correctly placed even if the path is
+//propagating through variables and expressions
+char* taintDiagnosticPropagation(){
+  char *pathbuf;
+  char *pathlist=getenv("PATH"); // expected-note {{Taint originated here}}
+ // expected-note@-1 {{Taint propagated to the 
return value}}
+  if (pathlist){ // expected-note {{Assuming 'pathlist' is non-null}}

steakhal wrote:
> steakhal wrote:
> > I know this is subjective, but I'd suggest to reformat the tests to match 
> > LLVM style guidelines, unless the formatting is important for the test.
> > Consistency helps the reader and reviewer, as code and tests are read many 
> > more times than written.
> > 
> > This applies to the rest of the touched tests.
> Originally I meant this to the rest of the test cases you change or add part 
> of this patch. I hope it clarifies.
I made some formatting changes you suggested, but 
I would like to leave the //expected-note tags as they are now, because then it 
remains consistent with the rest of the test cases.

Would it be okay like this, or should I reformat the whole file (untouched 
parts too)?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144269/new/

https://reviews.llvm.org/D144269

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


[PATCH] D148110: [clang-tidy] bugprone-use-after-move: Ctor arguments should be sequenced if ctor call is written as list-initialization.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In D148110#4290400 , @carlosgalvezp 
wrote:

> The commit message doesn't really tell me "what" this commit is fixing, it 
> only points to a section of the Standard. It talks about "a false positive" 
> but it doesn't tell what this FP is about. Could you write a little bit more 
> about what the problem is? Preferably if you can link a Github issue 
> describing the problem.

I've expanded the patch description to reference the specific test added here 
that used to be falsely diagnosed as a use-after-free.

I hope this is acceptable in lieu of a github issue?

> The subject of the commit message should indicate which particular check it 
> relates to.

Done.

> Document change in release notes.

Done.

In D148110#4290905 , @PiotrZSL wrote:

> Tests in lines 1195, 1201 actually tests InitListExpr.

That's understood. (These tests existed before this patch.)

> Test in line 1207 test negative scenario of CXXConstructExpr (list), but I 
> didn't found any positive test for CXXConstructExpr with list expr, please 
> add such test to show that warnings are still produced for such case.

Good point, done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148110/new/

https://reviews.llvm.org/D148110

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


[PATCH] D148949: [dataflow] HTMLLogger - show the value of the current expr

2023-04-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:96
+for (const auto& Prop : V.properties())
+  JOS.attributeObject(Prop.first(), [&] { dump(*Prop.second); });
+

mboehme wrote:
> IIUC, this places properties on the current HTML element as attributes, just 
> like the built-in attributes that we add for other purposes (e.g. "value_id", 
> "kind").
> 
>   - What happens if we have a property whose name conflicts with one of the 
> built-in attributes?
>   - Even if we don't have a naming conflict, I think it could be potentially 
> confusing to have user-defined properties appear in the same list and in the 
> same way as built-in attributes.
> 
> Suggestion: Can we nest all properties inside of a "properties" attribute?
> 
> Edit: Having looked at the HTML template now, I see that we exclude certain 
> attributes there ('kind', 'value_id', 'type', 'location') when listing 
> properties. I still think naming conflicts are a potential problem though. I 
> think it would also be clearer to explicitly pick the properties out of a 
> `properties` attribute rather than excluding a blocklist of attributes.
Right, the data model is: a value (really, a Value/StorageLocation mashed 
together) is just a bag of attributes.

I don't think making it more complicated is an improvement: being built-in 
isn't the same thing as being custom-rendered.
e.g. "pointee" and "truth" want the default key-value rendering despite being 
built-in.
Having the exclude list in the template is ugly, but either you end up encoding 
the rendering info twice in the template like that, or you encode it once in 
the template and once in the JSON generation (by what goes in the "properties" 
map vs the main map). I'd rather call this purely a template concern.

Namespace conflict could be a problem: the current behavior is that the last 
value wins (per JS rules).
IMO the simplest fix is to prepend "p:" and "f:" to properties/struct fields. 
These would be shown - otherwise the user can't distinguish between a property 
& field with the same name.

I had this in the prototype, but dropped them because they seemed a bit ugly 
and conflicts unlikely in practice. WDYT?



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:121-123
+  for (const auto &Child : cast(V).children())
+JOS.attributeObject(Child.first->getNameAsString(),
+[&] { dump(*Child.second); });

mboehme wrote:
> 
this is neat but capturing the structured binding `Val` is a C++20 feature



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:149
+case Value::Kind::Biconditional: {
+  auto &VV = cast(V);
+  JOS.attributeObject("lhs", [&] { dump(VV.getLeftSubValue()); });

mboehme wrote:
> 
right, thanks :-(
Can't wait to get rid of this stuff :-)



Comment at: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp:179
   EXPECT_THAT(Logs[0], HasSubstr("LocToVal")) << "has built-in lattice dump";
+  EXPECT_THAT(Logs[0], HasSubstr("\"type\": \"int\"")) << "has value dump";
 }

mboehme wrote:
> Can you add some additional tests for the following?
> 
>   - Pointers
>   - References
>   - Properties
>   - Struct fields
> 
> Ideally, other value kinds too (see copy-paste error above for 
> `BiconditionalValue`).
There isn't a reasonable way to test in that level of detail without paying a 
lot for it. 
String assertions on the HTML are not suitable for testing nontrivial 
structures in the JSON.

If we restructure to allow such assertions on the JSON:
 - it would be significantly expensive/intrusive
 - we would be relying on details of the analysis itself and setting them up 
indirectly - quite brittle
 - we would spend a lot on testing and still not look at all at what matters 
(the rendering)

My experience is that not having proper tests for these kind of tools is the 
least-worst option: better than brittle tests where true vs spurious errors are 
unclear, and better than expensive+still incomplete tests.
The debugging tools tend to get changed infrequently, manually verified, and 
sometimes an annoying regression creeps in.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148949/new/

https://reviews.llvm.org/D148949

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


[PATCH] D148949: [dataflow] HTMLLogger - show the value of the current expr

2023-04-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 516392.
sammccall marked an inline comment as done.
sammccall added a comment.

fix bad cast


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148949/new/

https://reviews.llvm.org/D148949

Files:
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.css
  clang/lib/Analysis/FlowSensitive/HTMLLogger.html
  clang/lib/Analysis/FlowSensitive/HTMLLogger.js
  clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
@@ -176,6 +176,7 @@
   << "has analysis point state";
   EXPECT_THAT(Logs[0], HasSubstr("transferBranch(0)")) << "has analysis logs";
   EXPECT_THAT(Logs[0], HasSubstr("LocToVal")) << "has built-in lattice dump";
+  EXPECT_THAT(Logs[0], HasSubstr("\"type\": \"int\"")) << "has value dump";
 }
 
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.js
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.js
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.js
@@ -73,6 +73,9 @@
 }
 return parent.insertBefore(clone, next);
   }
+  // data-use="xyz": use  instead. (Allows recursion.)
+  if ('use' in tmpl.dataset)
+return inflate(document.getElementById(tmpl.dataset.use), data, parent, next);
   //  tag handling. Base case: recursively inflate.
   function handle(data) {
 for (c of tmpl.content.childNodes)
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.html
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -10,6 +10,30 @@
 
 
 
+
+
+  
+
+  {{v.kind}}
+#{{v.value_id}}
+  
+  
+{{v.type}} @{{v.location}}
+  
+
+
+  {{kv[0]}}
+{{kv[1]}}
+
+  
+
+  
+
+  
+
+
 
 
 
@@ -50,6 +74,10 @@
   {{state.block}} (iteration {{state.iter}}) initial state
   Element {{selection.elt}} (iteration {{state.iter}})
 
+
+  Value
+  
+
 
   Logs
   {{state.logs}}
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.css
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -116,3 +116,27 @@
   position: relative;
   margin-left: 0.5em;
 }
+
+.value {
+  border: 1px solid #888;
+  font-size: x-small;
+  flex-grow: 1;
+}
+.value summary {
+  background-color: #ace;
+  display: flex;
+  justify-content: space-between;
+}
+.value .address {
+  font-size: xx-small;
+  font-family: monospace;
+  color: #888;
+}
+.value .property {
+  display: flex;
+  margin-top: 0.5em;
+}
+.value .property .key {
+  font-weight: bold;
+  min-width: 5em;
+}
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -67,6 +67,7 @@
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 // Defines assets: HTMLLogger_{html_js,css}
 #include "HTMLLogger.inc"
@@ -79,6 +80,94 @@
 
 using StreamFactory = std::function()>;
 
+// Recursively dumps Values/StorageLocations as JSON
+class ModelDumper {
+public:
+  ModelDumper(llvm::json::OStream &JOS, const Environment &Env)
+  : JOS(JOS), Env(Env) {}
+
+  void dump(Value &V) {
+JOS.attribute("value_id", llvm::to_string(&V));
+if (!Visited.insert(&V).second)
+  return;
+
+JOS.attribute("kind", debugString(V.getKind()));
+for (const auto& Prop : V.properties())
+  JOS.attributeObject(Prop.first(), [&] { dump(*Prop.second); });
+
+// Running the SAT solver is expensive, but knowing which booleans are
+// guaranteed true/false here is valuable and hard to determine by hand.
+if (auto *B = llvm::dyn_cast(&V)) {
+  JOS.attribute("truth", Env.flowConditionImplies(*B) ? "true"
+ : Env.flowConditionImplies(Env.makeNot(*B))
+ ? "false"
+ : "unknown");
+}
+
+switch (V.getKind()) {
+case Value::Kind::Integer:
+case Value::Kind::TopBool:
+case Value::Kind::AtomicBool:
+  break;
+case Value::Kind::Reference:
+  JOS.attributeObject(
+  "referent", [&] { dump(cast(V).getReferentLoc()); });
+  break;
+case Value::Kind::Pointer:
+  JOS.attributeObject(
+  "pointee", [&] { dump(cast(V).getPointeeLoc());

[clang] 271a73d - [dataflow] HTMLLogger: fix off-by-one in the BB listing

2023-04-24 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-04-24T15:55:21+02:00
New Revision: 271a73dae32f5eac2011a2f85351975484496262

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

LOG: [dataflow] HTMLLogger: fix off-by-one in the BB listing

The indexes of analysis state within a BB element is a bit odd:
  BB.0 is the initial state
  BB.1 is the state after the first element
etc

This means we have N+1 states and we need N+1 elements in the BB list.
We add a dummy element at the beginning rather than the end, because we want
selecting a CFG element to show the state *afterwards*.
For example, if we click on an expr, we want to be able to see its value model!

Differential Revision: https://reviews.llvm.org/D148951

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/HTMLLogger.html

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index c97f3ea8ac7d4..99d4debd05be3 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -35,9 +35,15 @@
   
 
 
+
+  
+{{selection.bb}}.0
+(initial state)
+  
+
 
-  
-{{selection.bb}}.{{elt_index}}
+  
+{{selection.bb}}.{{elt_index+1}}
 {{elt}}
   
 



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


[PATCH] D148951: [dataflow] HTMLLogger: fix off-by-one in the BB listing

2023-04-24 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG271a73dae32f: [dataflow] HTMLLogger: fix off-by-one in the 
BB listing (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148951/new/

https://reviews.llvm.org/D148951

Files:
  clang/lib/Analysis/FlowSensitive/HTMLLogger.html


Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.html
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -35,9 +35,15 @@
   
 
 
+
+  
+{{selection.bb}}.0
+(initial state)
+  
+
 
-  
-{{selection.bb}}.{{elt_index}}
+  
+{{selection.bb}}.{{elt_index+1}}
 {{elt}}
   
 


Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.html
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -35,9 +35,15 @@
   
 
 
+
+  
+{{selection.bb}}.0
+(initial state)
+  
+
 
-  
-{{selection.bb}}.{{elt_index}}
+  
+{{selection.bb}}.{{elt_index+1}}
 {{elt}}
   
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148949: [dataflow] HTMLLogger - show the value of the current expr

2023-04-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 516395.
sammccall added a comment.

use p: and f: prefixes for properties/fields respectively

(we can remove these again if too annoying)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148949/new/

https://reviews.llvm.org/D148949

Files:
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.css
  clang/lib/Analysis/FlowSensitive/HTMLLogger.html
  clang/lib/Analysis/FlowSensitive/HTMLLogger.js
  clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
@@ -176,6 +176,7 @@
   << "has analysis point state";
   EXPECT_THAT(Logs[0], HasSubstr("transferBranch(0)")) << "has analysis logs";
   EXPECT_THAT(Logs[0], HasSubstr("LocToVal")) << "has built-in lattice dump";
+  EXPECT_THAT(Logs[0], HasSubstr("\"type\": \"int\"")) << "has value dump";
 }
 
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.js
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.js
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.js
@@ -73,6 +73,9 @@
 }
 return parent.insertBefore(clone, next);
   }
+  // data-use="xyz": use  instead. (Allows recursion.)
+  if ('use' in tmpl.dataset)
+return inflate(document.getElementById(tmpl.dataset.use), data, parent, next);
   //  tag handling. Base case: recursively inflate.
   function handle(data) {
 for (c of tmpl.content.childNodes)
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.html
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -10,6 +10,30 @@
 
 
 
+
+
+  
+
+  {{v.kind}}
+#{{v.value_id}}
+  
+  
+{{v.type}} @{{v.location}}
+  
+
+
+  {{kv[0]}}
+{{kv[1]}}
+
+  
+
+  
+
+  
+
+
 
 
 
@@ -50,6 +74,10 @@
   {{state.block}} (iteration {{state.iter}}) initial state
   Element {{selection.elt}} (iteration {{state.iter}})
 
+
+  Value
+  
+
 
   Logs
   {{state.logs}}
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.css
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -116,3 +116,27 @@
   position: relative;
   margin-left: 0.5em;
 }
+
+.value {
+  border: 1px solid #888;
+  font-size: x-small;
+  flex-grow: 1;
+}
+.value summary {
+  background-color: #ace;
+  display: flex;
+  justify-content: space-between;
+}
+.value .address {
+  font-size: xx-small;
+  font-family: monospace;
+  color: #888;
+}
+.value .property {
+  display: flex;
+  margin-top: 0.5em;
+}
+.value .property .key {
+  font-weight: bold;
+  min-width: 5em;
+}
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -67,6 +67,7 @@
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 // Defines assets: HTMLLogger_{html_js,css}
 #include "HTMLLogger.inc"
@@ -79,6 +80,95 @@
 
 using StreamFactory = std::function()>;
 
+// Recursively dumps Values/StorageLocations as JSON
+class ModelDumper {
+public:
+  ModelDumper(llvm::json::OStream &JOS, const Environment &Env)
+  : JOS(JOS), Env(Env) {}
+
+  void dump(Value &V) {
+JOS.attribute("value_id", llvm::to_string(&V));
+if (!Visited.insert(&V).second)
+  return;
+
+JOS.attribute("kind", debugString(V.getKind()));
+for (const auto& Prop : V.properties())
+  JOS.attributeObject(("p:" + Prop.first()).str(),
+  [&] { dump(*Prop.second); });
+
+// Running the SAT solver is expensive, but knowing which booleans are
+// guaranteed true/false here is valuable and hard to determine by hand.
+if (auto *B = llvm::dyn_cast(&V)) {
+  JOS.attribute("truth", Env.flowConditionImplies(*B) ? "true"
+ : Env.flowConditionImplies(Env.makeNot(*B))
+ ? "false"
+ : "unknown");
+}
+
+switch (V.getKind()) {
+case Value::Kind::Integer:
+case Value::Kind::TopBool:
+case Value::Kind::AtomicBool:
+  break;
+case Value::Kind::Reference:
+  JOS.attributeObject(
+  "referent", [&] { dump(cast(V).getReferentLoc()); });
+  break;
+case Value::Kind::Pointer

[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-04-24 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

@hubert.reinterpretcast please let me know if there are comments/suggestions! 
Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144190/new/

https://reviews.llvm.org/D144190

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


[PATCH] D147217: [OpenMP][OMPIRBuilder] OpenMPIRBuilder support for requires directive

2023-04-24 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak added a comment.

I have been able to track down the failed `lld.wasm::stub_library.s` unit test 
to be due to the buildbot picking up line endings for the 
`lld/test/wasm/Inputs/libstub.so` to be Windows ones ("\r\n"), so the condition 
`if (mbref.getBuffer().starts_with("#STUB\n"))` in `lld/wasm/Driver.cpp:285` 
evaluates to false and the file is not processed. I'm not sure why this problem 
is being specifically picked up by the buildbot for this patch and whether it's 
already fixed upstream.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147217/new/

https://reviews.llvm.org/D147217

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


[PATCH] D148783: [clangd] Add support TextDocumentEdit.

2023-04-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D148783#4286652 , @hokein wrote:

>> can you also have a version of the 
>> clang-tools-extra/clangd/test/fixits-command.test with documentChanges 
>> support? it's unlikely to have clients in that configuration but i believe 
>> the deserialization issue i mentioned above would be discoverable by such a 
>> test.
>
> I'm happy to add a test for that, but I'm not sure the deserialization issue 
> you mentioned in the comment, is the one to use `mapOptional`?

yes it was for `mapOptional`, which turns out not to be an issue as there's a 
specialization for `optional`.

but still having that test to verify deserialization logic wouldn't hurt.




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1746
+
+ if (DiagOpts.EmbedFixesInDiagnostics && !CodeActions.empty()) 
{
+   Diag.codeActions.emplace(CodeActions);

we didn't have the empty check before, let's not introduce it now (i.e. we'll 
still reply with an empty set of code actions rather than "none" when there are 
no fixes known to clangd)



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1751-1753
  auto &FixItsForDiagnostic = LocalFixIts[Diag];
- llvm::copy(Fixes, std::back_inserter(FixItsForDiagnostic));
+ llvm::move(std::move(CodeActions),
+std::back_inserter(FixItsForDiagnostic));

i am not sure why this logic was appending to the vector rather than just 
overwriting. but we shouldn't receive the same diagnostics from the callback 
here, am i missing something? so what about just:
```
LocalFixIts[Diag] = std::move(CodeActions);
```



Comment at: clang-tools-extra/clangd/Protocol.cpp:735
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.map("changes", R.changes);
+  return O && O.map("changes", R.changes) && O.map("documentChanges", 
R.documentChanges);
 }

hokein wrote:
> kadircet wrote:
> > we actually want `O.mapOptional` for both "changes" and "documentChanges".
> I think `map` is a better fit here, it has a specific version of 
> `std::optional`, see 
> https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/JSON.h#L852.
> 
> `mapOptional`  doesn't set the field when missing the key in json object,
yeah you're right, i missed the specialization of `map` for `optional`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148783/new/

https://reviews.llvm.org/D148783

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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

2023-04-24 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber updated this revision to Diff 516397.
Krishna-13-cyber added a comment.

- Update with addition of testcase
- There is an issue for which the build fails,actually when I replace the 
diagnostic by `comparison of address of 'x' not equal to a null pointer is 
always true` in **/clang/test/Sema/conditional-expr.c Line 89**,it shows `C99 
forbids conditional expressions with only one void side` and vice versa.It 
regresses either ways.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149000/new/

https://reviews.llvm.org/D149000

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conditional-expr.c
  clang/test/Sema/warn-tautological-compare.c
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -249,7 +249,7 @@
   // During construction of C, A is unambiguous subobject of dynamic type C.
   static_assert(g.c == (C*)&g);
   // ... but in the complete object, the same is not true, so the runtime 
fails.
-  static_assert(dynamic_cast(static_cast(&g)) == nullptr);
+  static_assert(dynamic_cast(static_cast(&g)) == 
nullptr); // expected-warning {{comparison of address of 'g' equal to a null 
pointer is always false}}
 
   // dynamic_cast produces a pointer to the object of the dynamic type.
   static_assert(g.f == (void*)(F*)&g);
Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,9 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void)
+{
+int *a = (void *) 0;
+int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 
'a' equal to a null pointer is always false}}
+}
\ No newline at end of file
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,7 @@
 
 int Postgresql(void) {
   char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{comparison of address 
of 'x' not equal to a null pointer is always true}}
 }
 
 #define nil ((void*) 0)
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14723,7 +14723,7 @@
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -249,7 +249,7 @@
   // During construction of C, A is unambiguous subobject of dynamic type C.
   static_assert(g.c == (C*)&g);
   // ... but in the complete object, the same is not true, so the runtime fails.
-  static_assert(dynamic_cast(static_cast(&g)) == nullptr);
+  static_assert(dynamic_cast(static_cast(&g)) == nullptr); // expected-warning {{comparison of address of 'g' equal to a null pointer is always false}}
 
   // dynamic_cast produces a pointer to the object of the dynamic type.
   static_assert(g.f == (void*)(F*)&g);
Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,9 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void)
+{
+int *a = (void *) 0;
+int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 'a' equal to a null pointer is always false}}
+}
\ No newline at end of file
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,7 @@
 
 int Postgresql(void) {
   char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
+  return &x

[clang] f665760 - [Clang] Accept and forward `-fconvergent-functions` in the driver

2023-04-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-04-24T09:11:21-05:00
New Revision: f6657601629005cc9e488f159e310ae4008a25ea

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

LOG: [Clang] Accept and forward `-fconvergent-functions` in the driver

Currently the `-fconvergent-functions` option is primarily used by GPU
toolchains to enforce convergent operations in line with the semantics.
This option previously was only supported via `-Xclang` and would show
up as unused if passed to the driver. This patch allows the driver to
forward it. This is mostly useful for users wishing to target GPU
toolchains directly via `--target=` without an offloading runtime.

Reviewed By: JonChesterfield, MaskRay

Differential Revision: https://reviews.llvm.org/D149019

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/amdgpu-toolchain.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2abec84271356..3b07244b98e82 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -967,8 +967,10 @@ def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, 
Group,
   MetaVarName<"">;
 def c : Flag<["-"], "c">, Flags<[NoXarchOption, FlangOption]>, 
Group,
   HelpText<"Only run preprocess, compile, and assemble steps">;
-def fconvergent_functions : Flag<["-"], "fconvergent-functions">, 
Group, Flags<[CC1Option]>,
-  HelpText<"Assume functions may be convergent">;
+defm convergent_functions : BoolFOption<"convergent-functions",
+  LangOpts<"ConvergentFunctions">, DefaultFalse,
+  NegFlag,
+  PosFlag>;
 
 def gpu_use_aux_triple_only : Flag<["--"], "gpu-use-aux-triple-only">,
   InternalDriverOpt, HelpText<"Prepare '-aux-triple' only without populating "

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index edea4acfc3abd..f7544c8f593c8 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5700,6 +5700,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 options::OPT_fno_unique_internal_linkage_names);
   Args.addOptInFlag(CmdArgs, options::OPT_funique_basic_block_section_names,
 options::OPT_fno_unique_basic_block_section_names);
+  Args.addOptInFlag(CmdArgs, options::OPT_fconvergent_functions,
+options::OPT_fno_convergent_functions);
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index cb29049d5a3dd..34e0e8d53e50e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3731,9 +3731,9 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, 
ArgList &Args,
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
 && Opts.OpenCLVersion == 200);
 
-  Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
- Opts.SYCLIsDevice ||
- Args.hasArg(OPT_fconvergent_functions);
+  Opts.ConvergentFunctions = Args.hasArg(OPT_fconvergent_functions) ||
+ Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
+ Opts.SYCLIsDevice;
 
   Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
   if (!Opts.NoBuiltin)

diff  --git a/clang/test/Driver/amdgpu-toolchain.c 
b/clang/test/Driver/amdgpu-toolchain.c
index 3477d50527c66..b8b6667333d81 100644
--- a/clang/test/Driver/amdgpu-toolchain.c
+++ b/clang/test/Driver/amdgpu-toolchain.c
@@ -11,6 +11,6 @@
 // DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
-// LTO: clang{{.*}} "-flto=full"
+// RUN:   -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
+// LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
 // LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906



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


[PATCH] D149019: [Clang] Accept and forward `-fconvergent-functions` in the driver

2023-04-24 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf66576016290: [Clang] Accept and forward 
`-fconvergent-functions` in the driver (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D149019?vs=516188&id=516400#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149019/new/

https://reviews.llvm.org/D149019

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -11,6 +11,6 @@
 // DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
-// LTO: clang{{.*}} "-flto=full"
+// RUN:   -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
+// LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
 // LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3731,9 +3731,9 @@
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
 && Opts.OpenCLVersion == 200);
 
-  Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
- Opts.SYCLIsDevice ||
- Args.hasArg(OPT_fconvergent_functions);
+  Opts.ConvergentFunctions = Args.hasArg(OPT_fconvergent_functions) ||
+ Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
+ Opts.SYCLIsDevice;
 
   Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
   if (!Opts.NoBuiltin)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5700,6 +5700,8 @@
 options::OPT_fno_unique_internal_linkage_names);
   Args.addOptInFlag(CmdArgs, options::OPT_funique_basic_block_section_names,
 options::OPT_fno_unique_basic_block_section_names);
+  Args.addOptInFlag(CmdArgs, options::OPT_fconvergent_functions,
+options::OPT_fno_convergent_functions);
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -967,8 +967,10 @@
   MetaVarName<"">;
 def c : Flag<["-"], "c">, Flags<[NoXarchOption, FlangOption]>, 
Group,
   HelpText<"Only run preprocess, compile, and assemble steps">;
-def fconvergent_functions : Flag<["-"], "fconvergent-functions">, 
Group, Flags<[CC1Option]>,
-  HelpText<"Assume functions may be convergent">;
+defm convergent_functions : BoolFOption<"convergent-functions",
+  LangOpts<"ConvergentFunctions">, DefaultFalse,
+  NegFlag,
+  PosFlag>;
 
 def gpu_use_aux_triple_only : Flag<["--"], "gpu-use-aux-triple-only">,
   InternalDriverOpt, HelpText<"Prepare '-aux-triple' only without populating "


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -11,6 +11,6 @@
 // DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
-// LTO: clang{{.*}} "-flto=full"
+// RUN:   -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
+// LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
 // LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3731,9 +3731,9 @@
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
 && Opts.OpenCLVersion == 200);
 
-  Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
- Opts.SYCLIsDevice ||
- Args.hasArg(OPT_fconvergent_functions);
+  Opts.ConvergentFunctions = Args.hasArg(OPT_fconvergent_functions) ||
+ Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
+ Opts.SYCLIsDevice;
 
   Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
   if (!Opts.NoBuiltin)
Index: c

[PATCH] D148110: [clang-tidy] bugprone-use-after-move: Ctor arguments should be sequenced if ctor call is written as list-initialization.

2023-04-24 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:216-219
 - Improved :doc:`bugprone-use-after-move
-  ` check to also cover constructor
-  initializers.
+  ` check: Also cover constructor
+  initializers. Fix check to understand that constructor arguments are
+  sequenced when constructor call is written as list-initialization.

NOTE: Consider: "Improved XYZ check by including coverage for constructor 
initializers, and by correcting the handling of constructor arguments when they 
are sequenced during a constructor call that is written as 
list-initialization." or
"The XYZ check now covers constructor initializers and handles constructor 
arguments correctly during list-initialization."

I  just pointing this because I don't like this "check: Also"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148110/new/

https://reviews.llvm.org/D148110

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


[clang] 6b85cc1 - [clang][dataflow] Use existing accessors to check for copy and move assignment ops.

2023-04-24 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-04-24T14:32:09Z
New Revision: 6b85cc18eb7be0fdc01b8586347750e65e56a4c3

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

LOG: [clang][dataflow] Use existing accessors to check for copy and move 
assignment ops.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D148612

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/Transfer.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 2d85e7b90f73..0814257d5cd3 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -646,9 +646,12 @@ class TransferVisitor : public 
ConstStmtVisitor {
   assert(Arg1 != nullptr);
 
   // Evaluate only copy and move assignment operators.
-  auto *Arg0Type = Arg0->getType()->getUnqualifiedDesugaredType();
-  auto *Arg1Type = Arg1->getType()->getUnqualifiedDesugaredType();
-  if (Arg0Type != Arg1Type)
+  const auto *Method =
+  dyn_cast_or_null(S->getDirectCallee());
+  if (!Method)
+return;
+  if (!Method->isCopyAssignmentOperator() &&
+  !Method->isMoveAssignmentOperator())
 return;
 
   auto *ObjectLoc = Env.getStorageLocation(*Arg0, SkipPast::Reference);



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


[PATCH] D148612: [clang][dataflow] Use existing accessors to check for copy and move assignment ops.

2023-04-24 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b85cc18eb7b: [clang][dataflow] Use existing accessors to 
check for copy and move assignment… (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148612/new/

https://reviews.llvm.org/D148612

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp


Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -646,9 +646,12 @@
   assert(Arg1 != nullptr);
 
   // Evaluate only copy and move assignment operators.
-  auto *Arg0Type = Arg0->getType()->getUnqualifiedDesugaredType();
-  auto *Arg1Type = Arg1->getType()->getUnqualifiedDesugaredType();
-  if (Arg0Type != Arg1Type)
+  const auto *Method =
+  dyn_cast_or_null(S->getDirectCallee());
+  if (!Method)
+return;
+  if (!Method->isCopyAssignmentOperator() &&
+  !Method->isMoveAssignmentOperator())
 return;
 
   auto *ObjectLoc = Env.getStorageLocation(*Arg0, SkipPast::Reference);


Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -646,9 +646,12 @@
   assert(Arg1 != nullptr);
 
   // Evaluate only copy and move assignment operators.
-  auto *Arg0Type = Arg0->getType()->getUnqualifiedDesugaredType();
-  auto *Arg1Type = Arg1->getType()->getUnqualifiedDesugaredType();
-  if (Arg0Type != Arg1Type)
+  const auto *Method =
+  dyn_cast_or_null(S->getDirectCallee());
+  if (!Method)
+return;
+  if (!Method->isCopyAssignmentOperator() &&
+  !Method->isMoveAssignmentOperator())
 return;
 
   auto *ObjectLoc = Env.getStorageLocation(*Arg0, SkipPast::Reference);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149009: [Sema]Select correct lexical context during template instantiate

2023-04-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.






Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3597
+  if (FD->getFriendObjectKind() == Decl::FriendObjectKind::FOK_None &&
+  FD->isDefined(FDFriend, true) &&
+  FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) {

I was originally REALLY suspicious about this function call here (and the setup 
with the out parameter/2nd variable here).  but it seems that the 'true' 
argument (which, needs a `/*ParamName */` comment) is specifically designed for 
this situation.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3598
+  FD->isDefined(FDFriend, true) &&
+  FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) {
+// if Function defined by inline friend, use inline fried as DeclContext

So in what case would the currently-instantiated definition NOT also be a 
friend?  I would think this last condition should be able to be an assert 
instead.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3601
+FD = const_cast(FDFriend);
+Owner = FD->getDescribedFunctionTemplate()->getLexicalDeclContext();
+  }

I THINK this should just be:
`Owner = FD->getLexicalDeclContext()` here.  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149009/new/

https://reviews.llvm.org/D149009

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


[clang] 78086af - [Serialization] Correctly handle special files when deserializing

2023-04-24 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-04-24T15:35:37+01:00
New Revision: 78086af43ade0c91546a2688bb6e97906eee6c2a

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

LOG: [Serialization] Correctly handle special files when deserializing

This was supposed to be part of my previous commit, but I accidentally
pushed an old version of the patch.

Added: 


Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 098ce5314ab1..723dd99ffada 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2523,7 +2523,8 @@ void ASTReader::ResolveImportedPath(ModuleFile &M, 
std::string &Filename) {
 }
 
 void ASTReader::ResolveImportedPath(std::string &Filename, StringRef Prefix) {
-  if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
+  if (Filename.empty() || llvm::sys::path::is_absolute(Filename) ||
+  Filename == "" || Filename == "")
 return;
 
   SmallString<128> Buffer;



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


[PATCH] D144651: [Serialization] Place command line defines in the correct file

2023-04-24 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

I accidentally pushed the old version of this patch in rG524ed4b1ba51 
, I've 
pushed a change to match what was reviewed here in rG78086af43ade 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144651/new/

https://reviews.llvm.org/D144651

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


[clang] f0630a3 - Add some open projects for people to consider

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T10:54:32-04:00
New Revision: f0630a37b616ec81bf65f5e36e0586a396bfb6d6

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

LOG: Add some open projects for people to consider

These projects are ones that are already known within the community as
areas we would like to see improvements on.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index fb3bd1b5edec..7683dac7af09 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -22,6 +22,47 @@ Open Clang Projects
 or to verify that one of these isn't already completed.
 
 
+Refresh and improve Clang's documentation: Clang is inconsistent
+with documenting implementation-defined behaviors. We have significant
+documentation in the https://clang.llvm.org/docs/LanguageExtensions.html";>
+Language Extensions page, but the information is incomplete and the page is
+
diff icult to navigate. We would appreciate help with:
+
+  improving the way this information is presented to users,
+  https://llvm.org/docs/TableGen/";>table generating
+  documentation where possible, such as for implementation limits or other
+  target-specific information,
+  adding documentation for currently
+ https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/AttrDocs.td";>
+ undocumented attributes,
+  documenting https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticDocs.td";>
+  diagnostic group flags (adding code examples of what is diagnosed, or
+  other relevant information), or
+  help with completing other missing documentation.
+
+These projects are independent of each other.
+
+Improve Clang's standard conformance test coverage: Clang's test
+suite is structured such that most tests are written to provide coverage for
+what part of the compiler the feature's implementation exists in; we have
+parsing tests in clang/test/Parser, and semantic analysis tests in
+clang/test/Sema*, etc. We also have tests written to provide
+coverage for the standard requirements (clang/test/CXX and 
+clang/test/C). The standards coverage is not structured in a way that
+makes it easy to maintain as the standards change over time. No commercial
+conformance test suite has a license model suitable for open source projects,
+so we would appreciate help in improving the existing coverage we have both in
+terms of layout of the tests as well as in coverage of the various standard
+modes.
+
+Bug triage: Clang's https://github.com/llvm/llvm-project/issues";>
+issue trackercurrently has over 20,000 open issues, many of which are not
+appropriately tagged, are no longer reproducible, could use a reduced test 
case,
+or otherwise needs some manual interaction. We can always use help with
+https://llvm.org/docs/BugLifeCycle.html#triaging-bugs";>bug triage and
+issue tracker maintenance.
+
+
 Implement an tool to generate code documentation: Clang's
 library-based design allows it to be used by a variety of tools that reason
 about source code. One great application of Clang would be to build an
@@ -80,7 +121,7 @@ Open Clang Projects
 
 A tool that would investigate hosts and targets, and store the configuration
 in files that can later be used by Clang itself to avoid command-line options,
-especially the ones regarding which target options to use, would greatle 
alleviate
+especially the ones regarding which target options to use, would greatly 
alleviate
 this problem. A simple tool, with little or no dependency on LLVM itself, that
 will investigate a target architecture by probing hardware, software, libraries
 and compiling and executing code to identify all properties that would be 
relevant



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


[clang] 2e63436 - [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrew Gozillon via cfe-commits

Author: Andrew Gozillon
Date: 2023-04-24T10:06:21-05:00
New Revision: 2e634367be6a2ed6b8a4ee5c29b720dd90c0d70a

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

LOG: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add 
MLIR module attribute to proliferate to OpenMP IR lowering

This patch ports the fopenmp-host-ir-file-path flag from Clang to Flang-new, 
this flag
is added by the driver to the device pass when doing two phase compilation 
(device + host).

This flag is then applied to the module when compiling during the OpenMP device 
phase.
This file can then be utilised during lowering of the OpenMP dialect to 
LLVM-IR, which
allows the device and host to maintain 1:1 mapping of OpenMP metadata for 
variables
during lowering via the OpenMPIRBuilders loadOffloadInfoMetadata facilities
(which is used for declare target and I believe target regions as well).

Reviewer: awarzynski

Differential Revision: https://reviews.llvm.org/D148038

Added: 
flang/test/Lower/OpenMP/omp-host-ir-flag.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/LangOptions.h
flang/include/flang/Tools/CrossToolHelpers.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help.f90
flang/test/Driver/omp-driver-offload.f90
mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3b07244b98e82..d8ae398c61218 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6554,12 +6554,14 @@ def fno_cuda_host_device_constexpr : Flag<["-"], 
"fno-cuda-host-device-constexpr
 // OpenMP Options
 
//===--===//
 
+let Flags = [CC1Option, FC1Option, NoDriverOption] in {
+
 def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">,
-  HelpText<"Generate code only for an OpenMP target device.">,
-  Flags<[CC1Option, FC1Option, NoDriverOption]>;
+  HelpText<"Generate code only for an OpenMP target device.">;
 def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
-  HelpText<"Path to the IR file produced by the frontend for the host.">,
-  Flags<[CC1Option, NoDriverOption]>;
+  HelpText<"Path to the IR file produced by the frontend for the host.">;
+
+} // let Flags = [CC1Option, FC1Option, NoDriverOption]
 
 
//===--===//
 // SYCL Options

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 300072db35edc..ffd30af08fd0d 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -194,15 +194,29 @@ void Flang::addOffloadOptions(Compilation &C, const 
InputInfoList &Inputs,
 
   // Skips the primary input file, which is the input file that the compilation
   // proccess will be executed upon (e.g. the host bitcode file) and
-  // adds the other secondary input (e.g. device bitcode files for embedding)
-  // to the embed offload object. This is condensed logic from the Clang driver
-  // for embedding offload objects during HostOffloading.
-  if (IsHostOffloadingAction) {
-for (size_t i = 1; i < Inputs.size(); ++i) {
-  if (Inputs[i].getType() != types::TY_Nothing)
-CmdArgs.push_back(
-Args.MakeArgString("-fembed-offload-object=" +
-   getToolChain().getInputFilename(Inputs[i])));
+  // adds other secondary input (e.g. device bitcode files for embedding to the
+  // -fembed-offload-object argument or the host IR file for proccessing
+  // during device compilation to the fopenmp-host-ir-file-path argument via
+  // OpenMPDeviceInput). This is condensed logic from the ConstructJob
+  // function inside of the Clang driver for pushing on further input arguments
+  // needed for offloading during various phases of compilation.
+  for (size_t i = 1; i < Inputs.size(); ++i) {
+if (Inputs[i].getType() == types::TY_Nothing) {
+  // contains nothing, so it's skippable
+} else if (IsHostOffloadingAction) {
+  CmdArgs.push_back(
+  Args.MakeArgString("-fembed-offload-object=" +
+ getToolChain().getInputFilename(Inputs[i])));
+} else if (IsOpenMPDevice) {
+  if (Inputs[i].getFilename()) {
+CmdArgs.push_back("-fopenmp-host-ir-file-path");
+CmdArgs.push_back(Args.MakeArgString(Inputs[i].getFilename()));
+  } else {
+llvm_unreachable("missing openmp host-ir file for device offloading");
+  }
+} else {
+  llvm_unreachable(
+  "unexpectedly given multiple inputs

[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrew Gozillon via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
agozillon marked an inline comment as done.
Closed by commit rG2e634367be6a: [Flang][OpenMP][Driver][MLIR] Port 
fopenmp-host-ir-file-path flag and add MLIR… (authored by agozillon).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148038/new/

https://reviews.llvm.org/D148038

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/LangOptions.h
  flang/include/flang/Tools/CrossToolHelpers.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/omp-driver-offload.f90
  flang/test/Lower/OpenMP/omp-host-ir-flag.f90
  mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td

Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
@@ -71,7 +71,7 @@
   InterfaceMethod<
   /*description=*/[{
 Get the IsDeviceAttr attribute on the current module if it exists and return
-its value, if it doesn't exit it returns false by default.
+its value, if it doesn't exist it returns false by default.
   }],
   /*retTy=*/"bool",
   /*methodName=*/"getIsDevice",
@@ -138,6 +138,34 @@
  targetCPU.str(),
  targetFeatures.str()));
   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Set a StringAttr on the current module containing the host IR file path. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"void",
+  /*methodName=*/"setHostIRFilePath", 
+  (ins "std::string":$hostIRFilePath), [{}], [{
+$_op->setAttr(
+  mlir::StringAttr::get($_op->getContext(), llvm::Twine{"omp.host_ir_filepath"}),
+mlir::StringAttr::get($_op->getContext(), hostIRFilePath));
+   }]>,
+  InterfaceMethod<
+  /*description=*/[{
+Find the host-ir file path StringAttr from the current module if it exists and 
+return its contained value, if it doesn't exist it returns an empty string. This 
+file path is used in two-phase compilation during the device phase to generate
+device side LLVM IR when lowering MLIR. 
+  }],
+  /*retTy=*/"llvm::StringRef",
+  /*methodName=*/"getHostIRFilePath", 
+  (ins), [{}], [{
+if (Attribute filepath = $_op->getAttr("omp.host_ir_filepath"))
+  if (filepath.isa())
+return filepath.dyn_cast().getValue();
+return {};
+  }]>
   ];
 }
 
Index: flang/test/Lower/OpenMP/omp-host-ir-flag.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/omp-host-ir-flag.f90
@@ -0,0 +1,6 @@
+!RUN: %flang_fc1 -emit-llvm-bc -fopenmp -o %t.bc %s 2>&1
+!RUN: %flang_fc1 -emit-mlir -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -o - %s 2>&1 | FileCheck %s
+
+!CHECK: module attributes {{{.*}}, omp.host_ir_filepath = "{{.*}}.bc", omp.is_device = #omp.isdevice{{.*}}}
+subroutine omp_subroutine()
+end subroutine omp_subroutine
Index: flang/test/Driver/omp-driver-offload.f90
===
--- flang/test/Driver/omp-driver-offload.f90
+++ flang/test/Driver/omp-driver-offload.f90
@@ -47,15 +47,15 @@
 ! RUN: %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-DEVICE %s
 ! CHECK-OPENMP-IS-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
 
-! Testing fembed-offload-object and fopenmp-is-device
+! Testing appropriate flags are gnerated and appropriately assigned by the driver when offloading
 ! RUN: %flang -S -### %s -o %t 2>&1 \
 ! RUN: -fopenmp --offload-arch=gfx90a \
 ! RUN: --target=aarch64-unknown-linux-gnu \
-! RUN:   | FileCheck %s --check-prefixes=CHECK-OPENMP-EMBED
-! CHECK-OPENMP-EMBED: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}}.f90"
-! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
-! CHECK-OPENMP-EMBED: "{{[^"]*}}clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"
-! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}} "-fembed-offload-object={{.*}}.out" {{.*}}.bc"
+! RUN:   | FileCheck %s --check-prefix=OPENMP-OFFLOAD-ARGS
+! OPENMP-OFFLOAD-ARGS: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gn

[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

In D148038#4292262 , @awarzynski 
wrote:

> LGTM, thanks for addressing my comments!

Thank you for your time and the great review comments as always!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148038/new/

https://reviews.llvm.org/D148038

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


[clang] 6e696b1 - Add some more open project for Clang

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T11:44:27-04:00
New Revision: 6e696b12b7f536400a1bac2d9cd5717b8813c94c

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

LOG: Add some more open project for Clang

This adds open projects for updating the status of our C conformance,
DR conformance for both C and C++, and improving build times.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 7683dac7af09..3d55099df869 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -34,27 +34,46 @@ Open Clang Projects
   target-specific information,
   adding documentation for currently
  https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/AttrDocs.td";>
- undocumented attributes,
+ undocumented attributes,
   documenting https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticDocs.td";>
-  diagnostic group flags (adding code examples of what is diagnosed, or
+  diagnostic group flags (adding code examples of what is diagnosed, or
   other relevant information), or
   help with completing other missing documentation.
 
 These projects are independent of each other.
 
-Improve Clang's standard conformance test coverage: Clang's test
-suite is structured such that most tests are written to provide coverage for
-what part of the compiler the feature's implementation exists in; we have
-parsing tests in clang/test/Parser, and semantic analysis tests in
-clang/test/Sema*, etc. We also have tests written to provide
-coverage for the standard requirements (clang/test/CXX and 
-clang/test/C). The standards coverage is not structured in a way that
-makes it easy to maintain as the standards change over time. No commercial
+Complete the investigation into Clang's C conformance: Clang's
+C status page contain a number of entries marked as
+Unknown. Completing the investigation involves adding
+https://github.com/llvm/llvm-project/tree/main/clang/test/C";>test
+coverage for the various standards papers and updating the documentation
+accordingly.
+
+
+Improve Clang's C and C++ standard conformance test coverage:
+Clang's test suite is structured such that most tests are written to provide
+coverage for what part of the compiler the feature's implementation exists in;
+we have parsing tests in clang/test/Parser, and semantic analysis
+tests in clang/test/Sema*, etc. We also have tests written to
+provide coverage for the standard requirements (clang/test/CXX and
+clang/test/C). The standards coverage is not structured in a way
+that makes it easy to maintain as the standards change over time. No commercial
 conformance test suite has a license model suitable for open source projects,
 so we would appreciate help in improving the existing coverage we have both in
 terms of layout of the tests as well as in coverage of the various standard
 modes.
 
+Complete the investigation into Clang's C and C++ Defect Report
+conformance: Separate from (but related to) general conformance testing is
+determining which C defect reports and
+C++ defect reports Clang implements. These
+lists currently have a number of entries marked as Unknown.
+Completing the investigation involves adding test coverage for
+https://github.com/llvm/llvm-project/tree/main/clang/test/C/drs";>C
+and
+https://github.com/llvm/llvm-project/tree/main/clang/test/CXX/drs";>C++
+defect reports and updating the documentation accordingly.
+
 Bug triage: Clang's https://github.com/llvm/llvm-project/issues";>
 issue trackercurrently has over 20,000 open issues, many of which are not
 appropriately tagged, are no longer reproducible, could use a reduced test 
case,
@@ -63,6 +82,12 @@ Open Clang Projects
 issue tracker maintenance.
 
 
+Improve build times with Clang: the time it takes Clang to process a
+translation unit is very important to our users; the lower the build time, the
+better the overall user experience. It would be good to improve Clang's
+performance as well as to find ways to proactively alert us when we've
+introduced a change that has significant negative impact on build times.
+
 Implement an tool to generate code documentation: Clang's
 library-based design allows it to be used by a variety of tools that reason
 about source code. One great application of Clang would be to build an



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


[PATCH] D147684: [clangd] Add batch fixes for include-cleaner diagnostics

2023-04-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

can you also add test coverage for the new LSP fields?




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:439
+  for (auto &E : RemoveAll.Edits) {
+E.annotationId.emplace();
+*E.annotationId = RemoveAllUnusedID;

nit: `E.annotationId.emplace(RemoveAllUnusedID);` (same for others)



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:443
+  RemoveAll.Annotations.push_back({RemoveAllUnusedID,
+   {/*label=*/"", /*needsConfirmation=*/true,
+/*description=*/std::nullopt}});

rather than an empty label, let's duplicate `RemoveAll.Message` here. As that 
context will probably be lost after executing the code action.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:464
+  "AddAllMissingIncludes";
+  for (auto &E : AddAllMissing.Edits) {
+E.annotationId.emplace();

i think you want to populate `AddAllMissing.Edits` from `Edits` first



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:468
+  }
+  // FIXME(hokein): emit used symbol reference in the annotation.
+  AddAllMissing.Annotations.push_back(

unless we want a really wordy description, this would actually require us to 
attach one annotation per edit, rather than using the same annotation for all 
the edits.
can you check what changes in the UI when we have multiple annotations for a 
single workspace edit?



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:484
+  FixAll.Annotations.push_back({FixAllID, {
+/*label=*/"", /*needsConfirmation=*/true, /*description=*/std::nullopt
+  }});

again let's use `FixAll.Message` as label



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:493
+llvm::StringRef Code) {
+  std::optional RemoveAllUnused, AddAllMissing, FixAll;
+  std::vector UnusedIncludes = generateUnusedIncludeDiagnostics(

can you declare these right before their use sides, rather than on the same 
line?



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:496
+  AST.tuPath(), Findings.UnusedIncludes, Code);
+  if (!UnusedIncludes.empty())
+RemoveAllUnused = removeAllUnusedIncludes(UnusedIncludes);

UnusedIncludes.size() > 1



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:501
+  AST, Findings.MissingIncludes, Code);
+  if (!MissingIncludeDiags.empty())
+AddAllMissing = addAllMissingIncludes(MissingIncludeDiags);

MissingIncludeDiags.size() > 1



Comment at: clang-tools-extra/clangd/Protocol.h:253
+  /// The actual annotation identifier.
+  std::optional annotationId = std::nullopt;
 };

rather than packing up a new field here, can we have a `struct 
AnnotatedTextEdit : TextEdit` ?

it's surely more convenient this way but creates some confusion in call sites 
that're trying to create a regular textedit.

also we can use the empty string again, no need for optional.



Comment at: clang-tools-extra/clangd/Protocol.h:264
+struct ChangeAnnotation {
+  // A human-readable string describing the actual change. The string
+  // is rendered prominent in the user interface.

nit: triple slashes, here and elsewhere



Comment at: clang-tools-extra/clangd/Protocol.h:274
+  // the user interface.
+  std::optional description;
+};

no need for optional here, we can use the empty string



Comment at: clang-tools-extra/clangd/Protocol.h:1027
+   /// AnnotatedTextEdit.
+  std::optional> changeAnnotations;
 };

i don't think there's any difference between an empty map and a nullopt here, 
right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147684/new/

https://reviews.llvm.org/D147684

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


[clang] 5259ff7 - Reword the open project for generating documentation

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T11:55:11-04:00
New Revision: 5259ff7f0aef9aa1871e623608d5c00d3284adb0

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

LOG: Reword the open project for generating documentation

Work already began on this project, so this updates the wording to
discuss clang-doc specifically.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 3d55099df869..c7cde4f2c040 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -88,14 +88,12 @@ Open Clang Projects
 performance as well as to find ways to proactively alert us when we've
 introduced a change that has significant negative impact on build times.
 
-Implement an tool to generate code documentation: Clang's
-library-based design allows it to be used by a variety of tools that reason
-about source code. One great application of Clang would be to build an
-auto-documentation system like doxygen that generates code documentation from
-source code. The advantage of using Clang for such a tool is that the tool 
would
-use the same preprocessor/parser/ASTs as the compiler itself, giving it a very
-rich understanding of the code. Clang is already able to read and understand
-doxygen markup, but cannot yet generate documentation from it.
+Improve clang-doc: Clang's library-based design allows it to be used
+by a variety of tools that reason about source code.
+https://clang.llvm.org/extra/clang-doc.html";>clang-doc is one
+great application of this functionality, which generates code documentation
+from source code. The tool is in early stages of development and could use more
+dedicated effort to complete the implementation.
 
 Use clang libraries to implement better versions of existing tools:
 Clang is built as a set of libraries, which means that it is possible to



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


[clang] d64811f - Remove the "implement better version of existing tools" open project

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T11:56:25-04:00
New Revision: d64811f976b4305b54a5cbe0427002f5460c2d89

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

LOG: Remove the "implement better version of existing tools" open project

This project doesn't really relate to improving Clang itself and it
contained stale suggestions like working on code modification
functionality in clang-format.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index c7cde4f2c040..423fc0e1ae4a 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -95,21 +95,6 @@ Open Clang Projects
 from source code. The tool is in early stages of development and could use more
 dedicated effort to complete the implementation.
 
-Use clang libraries to implement better versions of existing tools:
-Clang is built as a set of libraries, which means that it is possible to
-implement capabilities similar to other source language tools, improving them
-in various ways.  Three examples are https://github.com/distcc";>distcc, the http://delta.tigris.org/";>delta testcase reduction tool, and the
-"indent" source reformatting tool.
-distcc can be improved to scale better and be more efficient.  Delta could be
-faster and more efficient at reducing C-family programs if built on the clang
-preprocessor. The clang-based indent replacement,
-https://clang.llvm.org/docs/ClangFormat.html";>clang-format,
-could be taught to handle simple structural rules like those in https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code";>the
 LLVM coding
-standards.
-
 Self-testing using clang: There are several neat ways to
 improve the quality of clang by self-testing. Some examples:
 



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


[clang] 8aea6e0 - [clang][Interp][NFC] Take a QualType in visitZeroInitializer()

2023-04-24 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-04-24T17:58:15+02:00
New Revision: 8aea6e004fd2edafbdee2d3d13571ab5eace004e

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

LOG: [clang][Interp][NFC] Take a QualType in visitZeroInitializer()

The given expression is not necessarily usable to obtain a type for,
so we can't use it to get the floating point semantics. Pass a QualType
instead, which we can use--and classify() that here.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index a8e8b2997ddef..e28532b288871 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -390,7 +390,7 @@ bool 
ByteCodeExprGen::VisitImplicitValueInitExpr(const ImplicitValueIni
   if (!T)
 return false;
 
-  return this->visitZeroInitializer(*T, E);
+  return this->visitZeroInitializer(E->getType(), E);
 }
 
 template 
@@ -929,7 +929,12 @@ bool ByteCodeExprGen::visitConditional(
 }
 
 template 
-bool ByteCodeExprGen::visitZeroInitializer(PrimType T, const Expr *E) 
{
+bool ByteCodeExprGen::visitZeroInitializer(QualType QT,
+const Expr *E) {
+  // FIXME: We need the QualType to get the float semantics, but that means we
+  //   classify it over and over again in array situations.
+  PrimType T = classifyPrim(QT);
+
   switch (T) {
   case PT_Bool:
 return this->emitZeroBool(E);
@@ -954,8 +959,7 @@ bool 
ByteCodeExprGen::visitZeroInitializer(PrimType T, const Expr *E) {
   case PT_FnPtr:
 return this->emitNullFnPtr(E);
   case PT_Float: {
-return this->emitConstFloat(
-APFloat::getZero(Ctx.getFloatSemantics(E->getType())), E);
+return this->emitConstFloat(APFloat::getZero(Ctx.getFloatSemantics(QT)), 
E);
   }
   }
   llvm_unreachable("unknown primitive type");

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 85588c6ecd3c1..a3aab16c4a083 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -201,7 +201,7 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
   friend class ArrayIndexScope;
 
   /// Emits a zero initializer.
-  bool visitZeroInitializer(PrimType T, const Expr *E);
+  bool visitZeroInitializer(QualType QT, const Expr *E);
 
   enum class DerefKind {
 /// Value is read and pushed to stack.



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


[clang] 8eea50c - Add missing HTML closing tag

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T11:58:50-04:00
New Revision: 8eea50c7c5569b13f8c910349754c72337075b1f

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

LOG: Add missing HTML closing tag

The  tag was missing for this entry.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 423fc0e1ae4a..4b6b0283767c 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -141,7 +141,7 @@ Open Clang Projects
 The second stage would be to produce a configuration file (that can be used
 independently of the Host) so that Clang can read it and not need a gazillion
 of command-line options. Such file should be simple JSON / INI or anything that
-a text editor could change.
+a text editor could change.
 
 
 If you hit a bug with Clang, it is very useful for us if you reduce the code



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


[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D148038#4292549 , @agozillon wrote:

> In D148038#4292262 , @awarzynski 
> wrote:
>
>> LGTM, thanks for addressing my comments!
>
> Thank you for your time and the great review comments as always!

Thanks you 🙏🏻


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148038/new/

https://reviews.llvm.org/D148038

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


[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-04-24 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 516435.
VincentWu marked 2 inline comments as done.
VincentWu added a comment.

remove testcse of Codegen & rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132819/new/

https://reviews.llvm.org/D132819

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmp-invalid.s
  llvm/test/MC/RISCV/rv32zcmp-valid.s
  llvm/test/MC/RISCV/rv64zcmp-invalid.s
  llvm/test/MC/RISCV/rv64zcmp-valid.s

Index: llvm/test/MC/RISCV/rv64zcmp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmp-valid.s
@@ -0,0 +1,149 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=experimental-zcmp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=experimental-zcmp < %s \
+# RUN: | llvm-objdump --mattr=-c,experimental-zcmp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.mvsa01 s1, s0
+# CHECK-ASM: encoding: [0xa2,0xac]
+cm.mvsa01 s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.mva01s s1, s0
+# CHECK-ASM: encoding: [0xe2,0xac]
+cm.mva01s s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbe]
+cm.popret {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbe]
+cm.popret {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbe]
+cm.popret {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbe]
+cm.popret {ra,s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbe]
+cm.popret {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbe]
+cm.popret {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbe]
+cm.popret {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbe]
+cm.popret {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbe]
+cm.popret {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbc]
+cm.popretz {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbc]
+cm.popretz {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbc]
+cm.popretz {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbc]
+cm.popretz {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbc]
+cm.popretz {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbc]
+cm.popretz {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbc]
+cm.popretz {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbc]
+cm.popretz {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbc]
+cm.popretz {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xba]
+cm.pop {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xba]
+cm.pop {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0}, 16
+# CHECK-ASM: encoding: [0x52,0xba]
+cm.pop {ra, s0}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xba]
+cm.pop {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xba]
+cm.pop {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xba]
+cm.pop {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xba]
+cm.pop {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xba]
+cm.pop {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.push {ra}, -16
+# CHECK-ASM: encoding: [0x42,0xb8]
+cm.push {ra}, -16
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0}, -32
+# CHECK-ASM: encoding: [0x56,0xb8]
+cm.push {ra, s0}, -32
+
+# CHECK-ASM-AND-OBJ: cm.p

[PATCH] D145416: [clang] model 'p' inline asm constraint as reading memory

2023-04-24 Thread James Y Knight via Phabricator via cfe-commits
jyknight requested changes to this revision.
jyknight added a comment.
This revision now requires changes to proceed.

I believe this is abandoned, correct?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145416/new/

https://reviews.llvm.org/D145416

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


  1   2   3   >