[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -3,12 +3,18 @@
 /// 4.7 enables cfg_checksum.
 /// 4.8 (default, compatible with gcov 7) emits the exit block the second.
 // RUN: rm -rf %t && mkdir %t && cd %t
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file=/dev/null 
-coverage-version='304*' %s -o - | \
-// RUN:   FileCheck --check-prefixes=CHECK,304 %s
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file=/dev/null 
-coverage-version='407*' %s -o - | \
-// RUN:   FileCheck --check-prefixes=CHECK,407 %s
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file=/dev/null 
%s -o - | \
-// RUN:   FileCheck --check-prefixes=CHECK,408 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-red-zone 
-coverage-data-file=/dev/null -coverage-version='304*' %s -o - | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK-ELF,304 %s

hubert-reinterpretcast wrote:

`CHECK-ELF` seems to be a misnomer considering that the test passes with the 
previous status quo (which includes Mach-O targets).

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


[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits

https://github.com/bwendling updated 
https://github.com/llvm/llvm-project/pull/110487

>From 375a71d114fffb94c16455f476364a7de9e08191 Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Mon, 30 Sep 2024 03:41:15 -0700
Subject: [PATCH 1/3] [Clang][CodeGen] Emit load of value

We were missing a load of the value after emitting the MemberExpr. This
was causing __builtin_dynamic_object_size to return 0 incorrectly.

Signed-off-by: Bill Wendling 
---
 clang/lib/CodeGen/CGExpr.cpp  |  1 +
 clang/test/CodeGen/attr-counted-by-pr110385.c | 74 +++
 2 files changed, 75 insertions(+)
 create mode 100644 clang/test/CodeGen/attr-counted-by-pr110385.c

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index df4994ba9af6e1..4e26e9f7076777 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1169,6 +1169,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfCountedByField(
 LValue LV = EmitMemberExpr(ME);
 Address Addr = LV.getAddress();
 Res = Addr.emitRawPointer(*this);
+Res = Builder.CreateAlignedLoad(Res->getType(), Res, getPointerAlign());
   } else if (StructBase->getType()->isPointerType()) {
 LValueBaseInfo BaseInfo;
 TBAAAccessInfo TBAAInfo;
diff --git a/clang/test/CodeGen/attr-counted-by-pr110385.c 
b/clang/test/CodeGen/attr-counted-by-pr110385.c
new file mode 100644
index 00..1f11bc1a04c81b
--- /dev/null
+++ b/clang/test/CodeGen/attr-counted-by-pr110385.c
@@ -0,0 +1,74 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fstrict-flex-arrays=2 
-emit-llvm -o - %s | FileCheck %s
+
+struct bch_val {
+  unsigned long int __nothing[0];
+};
+
+struct bch_xattr {
+  struct bch_val v;
+  unsigned char x_type;
+  unsigned char x_name_len;
+  unsigned char x_name[] __attribute__((__counted_by__(x_name_len)));
+};
+
+struct bkey_s_c {
+  const struct bch_val *v;
+};
+
+struct bkey_s_c_xattr {
+  union {
+const struct bch_xattr *v;
+struct bkey_s_c s_c;
+  };
+};
+
+// CHECK-LABEL: define dso_local i64 @test1(
+// CHECK-SAME: ptr [[K_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[K:%.*]] = alloca [[STRUCT_BKEY_S_C:%.*]], align 8
+// CHECK-NEXT:[[XATTR:%.*]] = alloca [[STRUCT_BKEY_S_C_XATTR:%.*]], align 8
+// CHECK-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C]], ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[K_COERCE]], ptr [[COERCE_DIVE]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[V:%.*]] = getelementptr inbounds nuw [[STRUCT_BKEY_S_C]], 
ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[V]], align 8
+// CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_VAL:%.*]], ptr [[TMP1]], i64 0
+// CHECK-NEXT:store ptr [[ADD_PTR]], ptr [[TMP0]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[TMP2]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP3]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP4:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP5:%.*]] = mul nuw i64 [[TMP4]], 1
+// CHECK-NEXT:[[TMP6:%.*]] = icmp sgt i64 [[TMP4]], -1
+// CHECK-NEXT:[[TMP7:%.*]] = select i1 [[TMP6]], i64 [[TMP5]], i64 0
+// CHECK-NEXT:ret i64 [[TMP7]]
+//
+unsigned long int test1(struct bkey_s_c k) {
+  struct bkey_s_c_xattr xattr = (struct bkey_s_c_xattr){
+  .v = (struct bch_xattr *)(k.v - __builtin_offsetof(struct bch_xattr, v))
+  };
+
+  return __builtin_dynamic_object_size(xattr.v->x_name, 0);
+}
+
+// CHECK-LABEL: define dso_local i64 @test2(
+// CHECK-SAME: ptr noundef [[XATTR:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[XATTR_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[XATTR]], ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR:%.*]], ptr [[TMP0]], i32 0, i32 0
+// CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP1]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP3:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP4:%.*]] = mul nuw i64 [[TMP3]], 1
+// CHECK-NEXT:[[TMP5:%.*]] = icmp sgt i64 [[TMP3]], -1
+// CHECK-NEXT:[[TMP6:%.*]] = select i1 [[TMP5]], i64 [[TMP4]], i64 0
+// CHECK-N

[clang] [clang-shlib] Add symbol versioning to all symbols (PR #110758)

2024-10-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Tom Stellard (tstellar)


Changes

We do the same thing for libLLVM.so.  This should help avoid issues when an 
applications loads two different versions of the library at the same time.

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


2 Files Affected:

- (modified) clang/tools/clang-shlib/CMakeLists.txt (+7) 
- (added) clang/tools/clang-shlib/simple_version_script.map.in (+1) 


``diff
diff --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index 298d3a9d18fec8..004ce2897960ca 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -61,3 +61,10 @@ if (MINGW OR CYGWIN)
   # make sure we export all symbols despite potential dllexports.
   target_link_options(clang-cpp PRIVATE LINKER:--export-all-symbols)
 endif()
+
+# Solaris ld does not accept global: *; so there is no way to version *all* 
global symbols
+if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+  target_link_options(clang-cpp PRIVATE 
-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+endif()
diff --git a/clang/tools/clang-shlib/simple_version_script.map.in 
b/clang/tools/clang-shlib/simple_version_script.map.in
new file mode 100644
index 00..cb2306d1f59682
--- /dev/null
+++ b/clang/tools/clang-shlib/simple_version_script.map.in
@@ -0,0 +1 @@
+@LLVM_SHLIB_SYMBOL_VERSION@ { global: *; };

``




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


[clang] [clang][docs] Add documentation for APValue constructors (PR #109994)

2024-10-01 Thread via cfe-commits

https://github.com/Sirraide edited 
https://github.com/llvm/llvm-project/pull/109994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-01 Thread Francis Visoiu Mistrih via cfe-commits

francisvm wrote:

I totally agree with you @tex3d, I wish we could add these constraints 
somewhere in `Builtins.td` in a more structured way. The diagnostic change was 
not unintentional, I just assumed we'd fix the one argument builtins in a 
separate commit from this one (aimed at two args).

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


[clang] 1202c24 - [Modules] Mark CFProtectionOptions.def as a textual header because it is used for x-macro purposes. (#110780)

2024-10-01 Thread via cfe-commits

Author: Volodymyr Sapsai
Date: 2024-10-01T21:47:52-07:00
New Revision: 1202c24b0d128c4838252daeeb1268707da69507

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

LOG: [Modules] Mark CFProtectionOptions.def as a textual header because it is 
used for x-macro purposes. (#110780)

Added: 


Modified: 
clang/include/module.modulemap

Removed: 




diff  --git a/clang/include/module.modulemap b/clang/include/module.modulemap
index b6ab99bb85d8a7..6f18c0a49641c9 100644
--- a/clang/include/module.modulemap
+++ b/clang/include/module.modulemap
@@ -65,6 +65,7 @@ module Clang_Basic {
   textual header "clang/Basic/BuiltinsX86.def"
   textual header "clang/Basic/BuiltinsX86_64.def"
   textual header "clang/Basic/BuiltinsXCore.def"
+  textual header "clang/Basic/CFProtectionOptions.def"
   textual header "clang/Basic/CodeGenOptions.def"
   textual header "clang/Basic/DebugOptions.def"
   textual header "clang/Basic/DiagnosticOptions.def"



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


[clang] [Modules] Mark CFProtectionOptions.def as a textual header because it is used for x-macro purposes. (PR #110780)

2024-10-01 Thread Volodymyr Sapsai via cfe-commits

https://github.com/vsapsai closed 
https://github.com/llvm/llvm-project/pull/110780
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Modules] Mark CFProtectionOptions.def as a textual header because it is used for x-macro purposes. (PR #110780)

2024-10-01 Thread Volodymyr Sapsai via cfe-commits

vsapsai wrote:

CI error
```
Traceback (most recent call last):
  File 
"/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-r8xzr-1/llvm-project/github-pull-requests/libcxx/utils/generate_iwyu_mapping.py",
 line 92, in 
main(sys.argv[1:])
  File 
"/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-r8xzr-1/llvm-project/github-pull-requests/libcxx/utils/generate_iwyu_mapping.py",
 line 82, in main
raise RuntimeError(f"{header}: Header {public} is not a valid header")
RuntimeError: __cxx03/__algorithm/adjacent_find.h: Header cxx03 is not a valid 
header
```
is unrelated to the current change.

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


[clang] [Serialization] Handle uninitialized type constraints (PR #110496)

2024-10-01 Thread Florian Albrechtskirchinger via cfe-commits

https://github.com/falbrechtskirchinger updated 
https://github.com/llvm/llvm-project/pull/110496

>From 220d76a2b2327318a6b5261896736ddd3f05988a Mon Sep 17 00:00:00 2001
From: Florian Albrechtskirchinger 
Date: Mon, 30 Sep 2024 12:58:15 +0200
Subject: [PATCH] [Serialization] Handle uninitialized type constraints

The ASTWriter currently assumes template type constraints to be
initialized ((bool)getTypeConstraint() == hasTypeConstraint()).
The attached test case presents a scenario where that is not the case.

This patch removes the assumption and adds another boolean to the
serialization, to explicitly encode whether the type constraint has been
initialized.

Fixes #99036
Fixes #109354
---
 clang/lib/Serialization/ASTReaderDecl.cpp  |  2 +-
 clang/lib/Serialization/ASTWriterDecl.cpp  |  5 +++--
 clang/test/PCH/cxx2a-constraints-crash.cpp | 18 ++
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 7cead2728ca938..90783963934bb0 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2674,7 +2674,7 @@ void 
ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
 
   D->setDeclaredWithTypename(Record.readInt());
 
-  if (D->hasTypeConstraint()) {
+  if (Record.readBool() && D->hasTypeConstraint()) {
 ConceptReference *CR = nullptr;
 if (Record.readBool())
   CR = Record.readConceptReference();
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index b71684569609ac..4da2108f553127 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1899,7 +1899,7 @@ void 
ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
   Record.push_back(D->wasDeclaredWithTypename());
 
   const TypeConstraint *TC = D->getTypeConstraint();
-  assert((bool)TC == D->hasTypeConstraint());
+  Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
   if (TC) {
 auto *CR = TC->getConceptReference();
 Record.push_back(CR != nullptr);
@@ -1917,7 +1917,7 @@ void 
ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
   if (OwnsDefaultArg)
 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
 
-  if (!TC && !OwnsDefaultArg &&
+  if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
   D->getDeclContext() == D->getLexicalDeclContext() &&
   !D->isInvalidDecl() && !D->hasAttrs() &&
   !D->isTopLevelDeclInObjCContainer() && !D->isImplicit() &&
@@ -2580,6 +2580,7 @@ void ASTWriter::WriteDeclAbbrevs() {
   // TemplateTypeParmDecl
   Abv->Add(
   BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
+  Abv->Add(BitCodeAbbrevOp(0));// TypeConstraintInitialized
   Abv->Add(BitCodeAbbrevOp(0));// OwnsDefaultArg
   DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
 
diff --git a/clang/test/PCH/cxx2a-constraints-crash.cpp 
b/clang/test/PCH/cxx2a-constraints-crash.cpp
index 637c55f0c879c9..0527c572e790b3 100644
--- a/clang/test/PCH/cxx2a-constraints-crash.cpp
+++ b/clang/test/PCH/cxx2a-constraints-crash.cpp
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
-// RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
-
-// expected-no-diagnostics
+// RUN: %clang_cc1 -std=c++2a -fallow-pch-with-compiler-errors -emit-pch %s -o 
%t -verify
+// RUN: %clang_cc1 -std=c++2a -fallow-pch-with-compiler-errors -include-pch %t 
%s -verify
 
 #ifndef HEADER
 #define HEADER
@@ -27,3 +25,15 @@ int main() {
 }
 
 #endif
+
+namespace GH99036 {
+
+template 
+concept C;
+// expected-error@-1 {{expected '='}} \
+// expected-note@-1 {{declared here}}
+
+template  void f();
+// expected-error@-1 {{a concept definition cannot refer to itself}}
+
+} // namespace GH99036

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Lei Wang via cfe-commits

https://github.com/wlei-llvm updated 
https://github.com/llvm/llvm-project/pull/109837

>From 07a2cab3fa5df2965f9f7da9ee2d3603581a47f1 Mon Sep 17 00:00:00 2001
From: wlei 
Date: Sun, 22 Sep 2024 20:23:20 -0700
Subject: [PATCH 1/2] [InstrPGO] Instrument sampling profile based cold
 function

---
 clang/include/clang/Driver/Options.td |  6 +
 clang/lib/Driver/ToolChain.cpp|  4 +++-
 clang/lib/Driver/ToolChains/Clang.cpp | 18 ++
 clang/test/CodeGen/Inputs/pgo-cold-func.prof  |  2 ++
 .../test/CodeGen/pgo-cold-function-coverage.c | 12 ++
 llvm/lib/Passes/PassBuilderPipelines.cpp  | 18 ++
 .../Instrumentation/PGOInstrumentation.cpp| 16 +
 .../PGOProfile/instr-gen-cold-function.ll | 24 +++
 8 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/Inputs/pgo-cold-func.prof
 create mode 100644 clang/test/CodeGen/pgo-cold-function-coverage.c
 create mode 100644 llvm/test/Transforms/PGOProfile/instr-gen-cold-function.ll

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 002f60350543d9..6bb92427f2d53f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1784,6 +1784,12 @@ defm debug_info_for_profiling : 
BoolFOption<"debug-info-for-profiling",
   PosFlag,
   NegFlag>;
+def fprofile_generate_cold_function_coverage : Flag<["-"], 
"fprofile-generate-cold-function-coverage">, 
+Group, Visibility<[ClangOption, CLOption]>,
+HelpText<"Generate instrumented code to cold functions into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;
+def fprofile_generate_cold_function_coverage_EQ : Joined<["-"], 
"fprofile-generate-cold-function-coverage=">, 
+Group, Visibility<[ClangOption, CLOption]>, 
MetaVarName<"">,
+HelpText<"Generate instrumented code to cold functions into 
/default.profraw (overridden by LLVM_PROFILE_FILE env var)">; 
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
 Group, Visibility<[ClangOption, CLOption]>,
 HelpText<"Generate instrumented code to collect execution counts into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 16f9b629fc538c..e56db150c6b47e 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -889,7 +889,9 @@ bool ToolChain::needsProfileRT(const ArgList &Args) {
  Args.hasArg(options::OPT_fprofile_instr_generate) ||
  Args.hasArg(options::OPT_fprofile_instr_generate_EQ) ||
  Args.hasArg(options::OPT_fcreate_profile) ||
- Args.hasArg(options::OPT_forder_file_instrumentation);
+ Args.hasArg(options::OPT_forder_file_instrumentation) ||
+ Args.hasArg(options::OPT_fprofile_generate_cold_function_coverage) ||
+ Args.hasArg(options::OPT_fprofile_generate_cold_function_coverage_EQ);
 }
 
 bool ToolChain::needsGCovInstrumentation(const llvm::opt::ArgList &Args) {
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0bab48caf1a5e2..00602a08232ba2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -649,6 +649,24 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
 }
   }
 
+  if (auto *ColdFuncCoverageArg = Args.getLastArg(
+  options::OPT_fprofile_generate_cold_function_coverage,
+  options::OPT_fprofile_generate_cold_function_coverage_EQ)) {
+SmallString<128> Path(
+ColdFuncCoverageArg->getOption().matches(
+options::OPT_fprofile_generate_cold_function_coverage_EQ)
+? ColdFuncCoverageArg->getValue()
+: "");
+llvm::sys::path::append(Path, "default_%m.profraw");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString(
+Twine("--instrument-sample-cold-function-path=") + Path));
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("--instrument-cold-function-coverage");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("--pgo-function-entry-coverage");
+  }
+
   Arg *PGOGenArg = nullptr;
   if (PGOGenerateArg) {
 assert(!CSPGOGenerateArg);
diff --git a/clang/test/CodeGen/Inputs/pgo-cold-func.prof 
b/clang/test/CodeGen/Inputs/pgo-cold-func.prof
new file mode 100644
index 00..e50be02e0a8545
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/pgo-cold-func.prof
@@ -0,0 +1,2 @@
+foo:1:1
+ 1: 1
diff --git a/clang/test/CodeGen/pgo-cold-function-coverage.c 
b/clang/test/CodeGen/pgo-cold-function-coverage.c
new file mode 100644
index 00..0d2767c022b9f1
--- /dev/null
+++ b/clang/test/CodeGen/pgo-cold-function-coverage.c
@@ -0,0 +1,12 @@
+// Test -fprofile-generate-cold-function-coverage 
+// RUN: %clang -O2 -fprofile-generate-cold-function-coverage=/xxx

[clang] bb8b9ac - [Utils] Add new --update-tests flag to llvm-lit (#108425)

2024-10-01 Thread via cfe-commits

Author: Henrik G. Olsson
Date: 2024-10-01T15:57:10-07:00
New Revision: bb8b9ac0ba5382bcf02f614b5b3a84c3699cf52c

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

LOG: [Utils] Add new --update-tests flag to llvm-lit (#108425)

This adds a flag to lit for detecting and updating failing tests when
possible to do so automatically. The flag uses a plugin architecture
where config files can add additional auto-updaters for the types of
tests in the test suite. When a test fails with `--update-tests` enabled
lit passes the test RUN invocation and output to each registered test
updater until one of them signals that it updated the test (or all test
updaters have been run). As such it is the responsibility of the test
updater to only update tests where it is reasonably certain that it will
actually fix the test, or come close to doing so.

Initially adds support for UpdateVerifyTests and UpdateTestChecks. The
flag is currently only implemented for lit's internal shell, so
`--update-tests` implies `LIT_USE_INTERNAL_SHELL=1`.

Builds on work in #97369
Fixes #81320

Added: 


Modified: 
clang/test/lit.cfg.py
llvm/docs/CommandGuide/lit.rst
llvm/test/lit.cfg.py
llvm/utils/lit/lit/LitConfig.py
llvm/utils/lit/lit/TestRunner.py
llvm/utils/lit/lit/cl_arguments.py
llvm/utils/lit/lit/llvm/config.py
llvm/utils/lit/lit/main.py
llvm/utils/update_any_test_checks.py

Removed: 




diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 92a3361ce672e2..32ed5239b90795 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -362,3 +362,13 @@ def calculate_arch_features(arch_string):
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
 config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
+
+if lit_config.update_tests:
+import sys
+import os
+
+utilspath = os.path.join(config.llvm_src_root, "utils")
+sys.path.append(utilspath)
+from update_any_test_checks import utc_lit_plugin
+
+lit_config.test_updaters.append(utc_lit_plugin)

diff  --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index c9d5baba3e2f49..dadecef567b7c9 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -313,6 +313,11 @@ ADDITIONAL OPTIONS
 
  List all of the discovered tests and exit.
 
+.. option:: --update-tests
+
+ Pass failing tests to functions in the ``lit_config.update_tests`` list to
+ check whether any of them know how to update the test to make it pass.
+
 EXIT STATUS
 ---
 

diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 5a03a85386e0aa..1d5b2bcae1b766 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -630,3 +630,13 @@ def have_ld64_plugin_support():
 
 if config.has_logf128:
 config.available_features.add("has_logf128")
+
+if lit_config.update_tests:
+import sys
+import os
+
+utilspath = os.path.join(config.llvm_src_root, "utils")
+sys.path.append(utilspath)
+from update_any_test_checks import utc_lit_plugin
+
+lit_config.test_updaters.append(utc_lit_plugin)

diff  --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py
index 5dc712ae28370c..198a2bf3172330 100644
--- a/llvm/utils/lit/lit/LitConfig.py
+++ b/llvm/utils/lit/lit/LitConfig.py
@@ -38,6 +38,7 @@ def __init__(
 parallelism_groups={},
 per_test_coverage=False,
 gtest_sharding=True,
+update_tests=False,
 ):
 # The name of the test runner.
 self.progname = progname
@@ -89,6 +90,8 @@ def __init__(
 self.parallelism_groups = parallelism_groups
 self.per_test_coverage = per_test_coverage
 self.gtest_sharding = bool(gtest_sharding)
+self.update_tests = update_tests
+self.test_updaters = []
 
 @property
 def maxIndividualTestTime(self):

diff  --git a/llvm/utils/lit/lit/TestRunner.py 
b/llvm/utils/lit/lit/TestRunner.py
index a1785073547ad0..3a2cdc5026b0c2 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1190,6 +1190,18 @@ def executeScriptInternal(
 str(result.timeoutReached),
 )
 
+if litConfig.update_tests:
+for test_updater in litConfig.test_updaters:
+try:
+update_output = test_updater(result, test)
+except Exception as e:
+out += f"Exception occurred in test updater: {e}"
+continue
+if update_output:
+for line in update_output.splitlines():
+out += f"# {line}\n"
+break
+
 return out, err, exitCode, timeoutInfo
 
 

diff  --git a/llvm/utils/lit/lit

[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Ellis Hoag via cfe-commits


@@ -0,0 +1,24 @@
+; RUN: opt < %s  --passes=pgo-instr-gen -instrument-cold-function-coverage -S  
| FileCheck --check-prefixes=COLD %s
+; RUN: opt < %s  --passes=pgo-instr-gen -instrument-cold-function-coverage 
-cold-function-coverage-max-entry-count=1 -S  | FileCheck 
--check-prefixes=ENTRY-COUNT %s
+
+; COLD: call void @llvm.instrprof.increment(ptr @__profn_foo, i64  [[#]], i32 
1, i32 0)

ellishg wrote:

Do you plan to support `-instrument-cold-function-coverage` without 
`-pgo-function-entry-coverage`? If not, I think we should add the flag here so 
we get the `llvm.instrprof.cover` intrinsic to more closely align with expected 
behavior.

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


[clang] [clang][docs] Add documentation for APValue constructors (PR #109994)

2024-10-01 Thread via cfe-commits


@@ -314,51 +314,91 @@ class APValue {
   DataType Data;
 
 public:
+  /// Creates an empty APValue of type None.
   APValue() : Kind(None) {}
+  /// Creates an integer APValue holding the given value.
   explicit APValue(APSInt I) : Kind(None) {
 MakeInt(); setInt(std::move(I));
   }
+  /// Creates a float APValue holding the given value.
   explicit APValue(APFloat F) : Kind(None) {
 MakeFloat(); setFloat(std::move(F));
   }
+  /// Creates an fixed-point APValue holding the given value.
   explicit APValue(APFixedPoint FX) : Kind(None) {
 MakeFixedPoint(std::move(FX));
   }
+  /// Creates a vector APValue with \p N elements. The elements
+  /// are read from \p E.
   explicit APValue(const APValue *E, unsigned N) : Kind(None) {
 MakeVector(); setVector(E, N);
   }
+  /// Creates an integer complex APValue with the given real and imaginary
+  /// values.
   APValue(APSInt R, APSInt I) : Kind(None) {
 MakeComplexInt(); setComplexInt(std::move(R), std::move(I));
   }
+  /// Creates a float complex APValue with the given real and imaginary values.
   APValue(APFloat R, APFloat I) : Kind(None) {
 MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I));
   }
   APValue(const APValue &RHS);
   APValue(APValue &&RHS);
+  /// Creates an lvalue APValue without an lvalue path.
+  /// \param B The base of the lvalue.
+  /// \param O The offset of the lvalue.
+  /// \param N Marker. Pass an empty NoValuePath.
+  /// \param IsNullPtr Whether this lvalue is a null pointer.
   APValue(LValueBase B, const CharUnits &O, NoLValuePath N,

Sirraide wrote:

(and imo the `NoLValuePath` shouldn’t even have a name to indicate it’s really 
just a marker; you can just make a new one in the call to `setLValue()` since 
that’s a no-op anyway)

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


[clang] [clang][docs] Add documentation for APValue constructors (PR #109994)

2024-10-01 Thread via cfe-commits

https://github.com/Sirraide edited 
https://github.com/llvm/llvm-project/pull/109994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[Utils] Add new --update-tests flag to llvm-lit" (PR #110772)

2024-10-01 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn closed 
https://github.com/llvm/llvm-project/pull/110772
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[Utils] Add new --update-tests flag to llvm-lit" (PR #110772)

2024-10-01 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn created 
https://github.com/llvm/llvm-project/pull/110772

Reverts llvm/llvm-project#108425

>From 133d368b16d11e44bc3fca92a042cf5ad0ce8dd1 Mon Sep 17 00:00:00 2001
From: "Henrik G. Olsson" 
Date: Tue, 1 Oct 2024 17:14:31 -0700
Subject: [PATCH] Revert "[Utils] Add new --update-tests flag to llvm-lit
 (#108425)"

This reverts commit bb8b9ac0ba5382bcf02f614b5b3a84c3699cf52c.
---
 clang/test/lit.cfg.py| 10 --
 llvm/docs/CommandGuide/lit.rst   |  5 ---
 llvm/test/lit.cfg.py | 10 --
 llvm/utils/lit/lit/LitConfig.py  |  3 --
 llvm/utils/lit/lit/TestRunner.py | 12 ---
 llvm/utils/lit/lit/cl_arguments.py   |  6 
 llvm/utils/lit/lit/llvm/config.py|  5 ---
 llvm/utils/lit/lit/main.py   |  1 -
 llvm/utils/update_any_test_checks.py | 54 ++--
 9 files changed, 3 insertions(+), 103 deletions(-)

diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 32ed5239b90795..92a3361ce672e2 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -362,13 +362,3 @@ def calculate_arch_features(arch_string):
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
 config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)
diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index dadecef567b7c9..c9d5baba3e2f49 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -313,11 +313,6 @@ ADDITIONAL OPTIONS
 
  List all of the discovered tests and exit.
 
-.. option:: --update-tests
-
- Pass failing tests to functions in the ``lit_config.update_tests`` list to
- check whether any of them know how to update the test to make it pass.
-
 EXIT STATUS
 ---
 
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 1d5b2bcae1b766..5a03a85386e0aa 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -630,13 +630,3 @@ def have_ld64_plugin_support():
 
 if config.has_logf128:
 config.available_features.add("has_logf128")
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)
diff --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py
index 198a2bf3172330..5dc712ae28370c 100644
--- a/llvm/utils/lit/lit/LitConfig.py
+++ b/llvm/utils/lit/lit/LitConfig.py
@@ -38,7 +38,6 @@ def __init__(
 parallelism_groups={},
 per_test_coverage=False,
 gtest_sharding=True,
-update_tests=False,
 ):
 # The name of the test runner.
 self.progname = progname
@@ -90,8 +89,6 @@ def __init__(
 self.parallelism_groups = parallelism_groups
 self.per_test_coverage = per_test_coverage
 self.gtest_sharding = bool(gtest_sharding)
-self.update_tests = update_tests
-self.test_updaters = []
 
 @property
 def maxIndividualTestTime(self):
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 3a2cdc5026b0c2..a1785073547ad0 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1190,18 +1190,6 @@ def executeScriptInternal(
 str(result.timeoutReached),
 )
 
-if litConfig.update_tests:
-for test_updater in litConfig.test_updaters:
-try:
-update_output = test_updater(result, test)
-except Exception as e:
-out += f"Exception occurred in test updater: {e}"
-continue
-if update_output:
-for line in update_output.splitlines():
-out += f"# {line}\n"
-break
-
 return out, err, exitCode, timeoutInfo
 
 
diff --git a/llvm/utils/lit/lit/cl_arguments.py 
b/llvm/utils/lit/lit/cl_arguments.py
index dcbe553c6d4827..ed78256ee414b4 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -204,12 +204,6 @@ def parse_args():
 action="store_true",
 help="Exit with status zero even if some tests fail",
 )
-execution_group.add_argument(
-"--update-tests",
-dest="update_tests",
-action="store_true",
-help="Try to update regression tests to reflect current behavior, if 
possible",
-)
 execution_test_time_group = execution_group.add_mutually_exclusive_group()
 execution_test_time_group.add_argument(
 "--skip-test-time-recording",
diff --git a/llvm/utils/lit/lit/llv

[libcxx] [libcxxabi] [libunwind] [libc++abi][libunwind] Run c++abi and unwind tests against a fake install root (PR #110171)

2024-10-01 Thread via cfe-commits

zeroomega wrote:

> Thanks for the analysis. Per-target runtime dir strikes again! That setting 
> keeps on creating issues (by no fault of its own) because it's not the 
> default.
> 
> Can we do something like this instead, then?
> 
> ```
> config.substitutions.append(('%{lib}', 
> '@LIBUNWIND_TESTING_INSTALL_PREFIX@/@LIBUNWIND_INSTALL_LIBRARY_DIR@'))
> ```
> 
> We should fix this one forward since there's a complicated dependency chain 
> on top of this (we switched to Github-hosted runners for macOS testing after 
> this patch and they will start failing if we revert this). Hopefully it's not 
> too complicated to fix forward.

That seems to fix the test:
Test run: 
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci.shadow/clang-linux-x64/b8735236964550803665/overview
based on https://github.com/zeroomega/llvm-project/tree/libunwind_fix  
https://github.com/zeroomega/llvm-project/commit/1e3b4a6a97b32cd1b501ad5256036967a0821327


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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread via cfe-commits

c8ef wrote:

Thank you so much for your quick review! However, it seems the current CI is 
blocked by the issues mentioned in #110783 :(

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/110638

>From 38430b6cdfc524972fbdabca6a037174eaf1549f Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 09:08:14 +
Subject: [PATCH 1/5] 110558

---
 clang/lib/Sema/SemaDecl.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ed189e02a51d22 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,6 +9085,11 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+CXXRecordDecl *RD = NewMD->getParent();
+SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
+<< RD->getName() << RD->getLocation();
+  }
 
   bool NewFDisConst = false;
   if (CXXMethodDecl *NewMD = dyn_cast(NewFD))

>From 8f37ce5dec7361b0dbc1ad6f912048fa6bbc38ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 10:19:00 +
Subject: [PATCH 2/5] fix

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed189e02a51d22..7b62b4f6d6433d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,7 +9085,8 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+  CXXMethodDecl *NewMD = dyn_cast(NewFD);
+  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();

>From c875c6cb3c0ec64d29a4b4c31ac4eb3605f43289 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 11:52:22 +
Subject: [PATCH 3/5] fix test

---
 clang/lib/Sema/SemaDecl.cpp|  7 +++
 .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp |  1 +
 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp |  1 +
 clang/test/CXX/dcl/dcl.fct/p17.cpp |  1 +
 clang/test/CXX/drs/cwg22xx.cpp |  1 +
 clang/test/CXX/drs/cwg3xx.cpp  |  7 ++-
 clang/test/CXX/special/class.inhctor/p8.cpp|  1 +
 .../temp.constr.decl/func-template-decl.cpp|  1 +
 clang/test/CXX/temp/temp.res/temp.local/p8.cpp |  8 
 .../test/CXX/temp/temp.spec/temp.expl.spec/p12.cpp |  2 ++
 .../CXX/temp/temp.spec/temp.expl.spec/p14-23.cpp   |  1 +
 .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp |  1 +
 clang/test/FixIt/member-mismatch.cpp   |  2 ++
 clang/test/Parser/cxx-class.cpp|  1 +
 clang/test/SemaCXX/attr-target-mv.cpp  |  7 ---
 clang/test/SemaCXX/attr-target-version.cpp |  7 ---
 clang/test/SemaCXX/enable_if.cpp   |  2 +-
 clang/test/SemaCXX/function-redecl.cpp | 14 --
 clang/test/SemaCXX/lambda-unevaluated.cpp  |  2 ++
 clang/test/SemaCXX/nested-name-spec.cpp|  4 
 clang/test/SemaCXX/out-of-line-def-mismatch.cpp|  6 +-
 clang/test/SemaCXX/typo-correction.cpp |  1 +
 .../test/SemaTemplate/concepts-out-of-line-def.cpp |  4 +++-
 clang/test/SemaTemplate/recovery-crash.cpp |  5 +++--
 24 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7b62b4f6d6433d..e4c45cbc09e0f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,16 +9085,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+
   CXXMethodDecl *NewMD = dyn_cast(NewFD);
-  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
+  if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();
   }
 
-  bool NewFDisConst = false;
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD))
-NewFDisConst = NewMD->isConst();
+  bool NewFDisConst = NewMD && NewMD->isConst();
 
   for (SmallVectorImpl >::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 9e890204c78bd6..f0901733f8afeb 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -170,5 +170,6 @@ namespace ImplicitConstexprDef {
 
   constexpr void A::f() { } // expected-warning {{'constexpr' non-static 
member function will n

[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

> Thank you so much for your quick review! However, it seems the current CI is 
> blocked by the issues mentioned in #110783 :(

I wouldn't be worried about that for a simple change like this, you can go 
ahead and merge.

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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread via cfe-commits

c8ef wrote:

Thanks! 🥰

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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 closed 
https://github.com/llvm/llvm-project/pull/110773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread Younan Zhang via cfe-commits


@@ -9519,15 +9519,28 @@ Sema::ActOnStartRequiresExpr(SourceLocation 
RequiresKWLoc,
   } else if (Param->getType().hasQualifiers()) {
 Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
   }
-}
-
-if (Param->hasDefaultArg())
+} else if (Param->hasDefaultArg()) {
   // C++2a [expr.prim.req] p4
   // [...] A local parameter of a requires-expression shall not have a
   // default argument. [...]
   Diag(Param->getDefaultArgRange().getBegin(),
diag::err_requires_expr_local_parameter_default_argument);
-// Ignore default argument and move on
+  // Ignore default argument and move on
+} else if (Param->isExplicitObjectParameter()) {
+  // C++23 [dcl.fct]p6:
+  //   An explicit-object-parameter-declaration is a parameter-declaration
+  //   with a this specifier. An explicit-object-parameter-declaration
+  //   shall appear only as the first parameter-declaration of a
+  //   parameter-declaration-list of either:
+  //   - a member-declarator that declares a member function, or
+  //   - a lambda-declarator.
+  //
+  // The parameter-declaration-list of a requires-expression is not such
+  // a context.
+  Diag(Param->getExplicitObjectParamThisLoc(),
+   diag::err_requires_expr_explicit_object_parameter);
+  Param->setExplicitObjectParameterLoc(SourceLocation());

zyn0217 wrote:

Why clear the source location? Wouldn't it somehow break the source fidelity?

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


[clang] 679be52 - [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (#110773)

2024-10-01 Thread via cfe-commits

Author: c8ef
Date: 2024-10-02T12:01:31+08:00
New Revision: 679be527095ea60d5933b883ca276d8e593920ee

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

LOG: [Clang][NFC] Consolidate the parameter check for the `requires` expression 
parameter. (#110773)

This patch is a follow-up to #109831. In the discussion, we agreed that
having parameter checks scattered across different areas isn't ideal.
Therefore, I suggest merging the check from #88974 into the void
parameter check. This change won't impact functionality and will enhance
maintainability.

Added: 


Modified: 
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a04eed9873c0d4..122a05be1c039a 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7950,21 +7950,8 @@ void Parser::ParseParameterDeclarationClause(
 // Parse a C++23 Explicit Object Parameter
 // We do that in all language modes to produce a better diagnostic.
 SourceLocation ThisLoc;
-if (getLangOpts().CPlusPlus && Tok.is(tok::kw_this)) {
+if (getLangOpts().CPlusPlus && Tok.is(tok::kw_this))
   ThisLoc = ConsumeToken();
-  // C++23 [dcl.fct]p6:
-  //   An explicit-object-parameter-declaration is a parameter-declaration
-  //   with a this specifier. An explicit-object-parameter-declaration
-  //   shall appear only as the first parameter-declaration of a
-  //   parameter-declaration-list of either:
-  //   - a member-declarator that declares a member function, or
-  //   - a lambda-declarator.
-  //
-  // The parameter-declaration-list of a requires-expression is not such
-  // a context.
-  if (DeclaratorCtx == DeclaratorContext::RequiresExpr)
-Diag(ThisLoc, diag::err_requires_expr_explicit_object_parameter);
-}
 
 ParsedTemplateInfo TemplateInfo;
 ParseDeclarationSpecifiers(DS, TemplateInfo, AS_none,

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index b30414a8a8277a..d490452e91c3bb 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -9519,15 +9519,28 @@ Sema::ActOnStartRequiresExpr(SourceLocation 
RequiresKWLoc,
   } else if (Param->getType().hasQualifiers()) {
 Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
   }
-}
-
-if (Param->hasDefaultArg())
+} else if (Param->hasDefaultArg()) {
   // C++2a [expr.prim.req] p4
   // [...] A local parameter of a requires-expression shall not have a
   // default argument. [...]
   Diag(Param->getDefaultArgRange().getBegin(),
diag::err_requires_expr_local_parameter_default_argument);
-// Ignore default argument and move on
+  // Ignore default argument and move on
+} else if (Param->isExplicitObjectParameter()) {
+  // C++23 [dcl.fct]p6:
+  //   An explicit-object-parameter-declaration is a parameter-declaration
+  //   with a this specifier. An explicit-object-parameter-declaration
+  //   shall appear only as the first parameter-declaration of a
+  //   parameter-declaration-list of either:
+  //   - a member-declarator that declares a member function, or
+  //   - a lambda-declarator.
+  //
+  // The parameter-declaration-list of a requires-expression is not such
+  // a context.
+  Diag(Param->getExplicitObjectParamThisLoc(),
+   diag::err_requires_expr_explicit_object_parameter);
+  Param->setExplicitObjectParameterLoc(SourceLocation());
+}
 
 Param->setDeclContext(Body);
 // If this has an identifier, add it to the scope stack.



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


[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-01 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


tbaederr wrote:

This example from the failing test should warn I think:
```c++

class Foo {
public:
  void foo1();
  void foo2();
  void foo3(Foo *other);

  template
  void fooT1(const T& dummy1);

  template
  void fooT2(const T& dummy2) EXCLUSIVE_LOCKS_REQUIRED(mu_);

  Mutex mu_;
  int a GUARDED_BY(mu_);
};

void Foo::foo2() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
  a = 2;
}
```
Since the definition of `foo2` specifies attributes that aren't present in the 
previous declaration.

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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread via cfe-commits


@@ -9519,15 +9519,28 @@ Sema::ActOnStartRequiresExpr(SourceLocation 
RequiresKWLoc,
   } else if (Param->getType().hasQualifiers()) {
 Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
   }
-}
-
-if (Param->hasDefaultArg())
+} else if (Param->hasDefaultArg()) {
   // C++2a [expr.prim.req] p4
   // [...] A local parameter of a requires-expression shall not have a
   // default argument. [...]
   Diag(Param->getDefaultArgRange().getBegin(),
diag::err_requires_expr_local_parameter_default_argument);
-// Ignore default argument and move on
+  // Ignore default argument and move on
+} else if (Param->isExplicitObjectParameter()) {
+  // C++23 [dcl.fct]p6:
+  //   An explicit-object-parameter-declaration is a parameter-declaration
+  //   with a this specifier. An explicit-object-parameter-declaration
+  //   shall appear only as the first parameter-declaration of a
+  //   parameter-declaration-list of either:
+  //   - a member-declarator that declares a member function, or
+  //   - a lambda-declarator.
+  //
+  // The parameter-declaration-list of a requires-expression is not such
+  // a context.
+  Diag(Param->getExplicitObjectParamThisLoc(),
+   diag::err_requires_expr_explicit_object_parameter);
+  Param->setExplicitObjectParameterLoc(SourceLocation());

c8ef wrote:

https://github.com/llvm/llvm-project/blob/e379094328e49731a606304f7e3559d4f1fa96f9/clang/lib/Sema/SemaType.cpp#L5175-L5179

I'm not entirely sure, but the check in function parameters do indeed perform 
this action.

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


[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-10-01 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn closed 
https://github.com/llvm/llvm-project/pull/108425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Jan Hendrik Farr via cfe-commits

Cydox wrote:

Interesting. You compiled with `-O2`, I compiled without optimization.
When I compile it with `-O2`, I now get `0`.

I've uploaded a gist with the disassembly generated with

```
clang -mllvm --x86-asm-syntax=intel -S test.c -o ./test-no-optimize.S
```
and
```
clang -O2 -mllvm --x86-asm-syntax=intel -S test.c -o ./test-optimize-O2.S
```

Can you do the same?

https://gist.github.com/Cydox/8b48a7d36dbcf6376d5a2d44afe5cf57

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Mircea Trofin via cfe-commits


@@ -1784,6 +1784,12 @@ defm debug_info_for_profiling : 
BoolFOption<"debug-info-for-profiling",
   PosFlag,
   NegFlag>;
+def fprofile_generate_cold_function_coverage : Flag<["-"], 
"fprofile-generate-cold-function-coverage">, 

mtrofin wrote:

I meant, why not just use `clang ... -mllvm 
-instrument-cold-function-coverage`? Is this a clang - only feature (i.e. rust 
can't use it?) Is it just for symmetry with the current PGO flags?

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Mircea Trofin via cfe-commits

https://github.com/mtrofin edited 
https://github.com/llvm/llvm-project/pull/109837
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][DebugInfo] Revert to printing canonical typenames for template aliases (PR #110767)

2024-10-01 Thread Michael Buch via cfe-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/110767
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e495231 - Revert "[Utils] Add new --update-tests flag to llvm-lit" (#110772)

2024-10-01 Thread via cfe-commits

Author: Henrik G. Olsson
Date: 2024-10-01T17:14:50-07:00
New Revision: e495231238b86ae2a3c7bb5f94634c19ca2af19a

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

LOG: Revert "[Utils] Add new --update-tests flag to llvm-lit" (#110772)

Reverts llvm/llvm-project#108425

Added: 


Modified: 
clang/test/lit.cfg.py
llvm/docs/CommandGuide/lit.rst
llvm/test/lit.cfg.py
llvm/utils/lit/lit/LitConfig.py
llvm/utils/lit/lit/TestRunner.py
llvm/utils/lit/lit/cl_arguments.py
llvm/utils/lit/lit/llvm/config.py
llvm/utils/lit/lit/main.py
llvm/utils/update_any_test_checks.py

Removed: 




diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 32ed5239b90795..92a3361ce672e2 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -362,13 +362,3 @@ def calculate_arch_features(arch_string):
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
 config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)

diff  --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index dadecef567b7c9..c9d5baba3e2f49 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -313,11 +313,6 @@ ADDITIONAL OPTIONS
 
  List all of the discovered tests and exit.
 
-.. option:: --update-tests
-
- Pass failing tests to functions in the ``lit_config.update_tests`` list to
- check whether any of them know how to update the test to make it pass.
-
 EXIT STATUS
 ---
 

diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 1d5b2bcae1b766..5a03a85386e0aa 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -630,13 +630,3 @@ def have_ld64_plugin_support():
 
 if config.has_logf128:
 config.available_features.add("has_logf128")
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)

diff  --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py
index 198a2bf3172330..5dc712ae28370c 100644
--- a/llvm/utils/lit/lit/LitConfig.py
+++ b/llvm/utils/lit/lit/LitConfig.py
@@ -38,7 +38,6 @@ def __init__(
 parallelism_groups={},
 per_test_coverage=False,
 gtest_sharding=True,
-update_tests=False,
 ):
 # The name of the test runner.
 self.progname = progname
@@ -90,8 +89,6 @@ def __init__(
 self.parallelism_groups = parallelism_groups
 self.per_test_coverage = per_test_coverage
 self.gtest_sharding = bool(gtest_sharding)
-self.update_tests = update_tests
-self.test_updaters = []
 
 @property
 def maxIndividualTestTime(self):

diff  --git a/llvm/utils/lit/lit/TestRunner.py 
b/llvm/utils/lit/lit/TestRunner.py
index 3a2cdc5026b0c2..a1785073547ad0 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1190,18 +1190,6 @@ def executeScriptInternal(
 str(result.timeoutReached),
 )
 
-if litConfig.update_tests:
-for test_updater in litConfig.test_updaters:
-try:
-update_output = test_updater(result, test)
-except Exception as e:
-out += f"Exception occurred in test updater: {e}"
-continue
-if update_output:
-for line in update_output.splitlines():
-out += f"# {line}\n"
-break
-
 return out, err, exitCode, timeoutInfo
 
 

diff  --git a/llvm/utils/lit/lit/cl_arguments.py 
b/llvm/utils/lit/lit/cl_arguments.py
index dcbe553c6d4827..ed78256ee414b4 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -204,12 +204,6 @@ def parse_args():
 action="store_true",
 help="Exit with status zero even if some tests fail",
 )
-execution_group.add_argument(
-"--update-tests",
-dest="update_tests",
-action="store_true",
-help="Try to update regression tests to reflect current behavior, if 
possible",
-)
 execution_test_time_group = execution_group.add_mutually_exclusive_group()
 execution_test_time_group.add_argument(
 "--skip-test-time-recording",

diff  --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index c05ec16

[clang] [clang][docs] Add documentation for APValue constructors (PR #109994)

2024-10-01 Thread via cfe-commits

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

LGTM overall; I just have some minor comments

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


[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Jan Hendrik Farr via cfe-commits

Cydox wrote:

@bwendling I think you accidentally compiled the wrong branch. Looks like that 
is in `builtin_get_counted_by`, but this PR is in `bdos-member-expr-error`

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


[clang] [llvm] Revert "[Utils] Add new --update-tests flag to llvm-lit" (PR #110772)

2024-10-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-testing-tools

Author: Henrik G. Olsson (hnrklssn)


Changes

Reverts llvm/llvm-project#108425

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


9 Files Affected:

- (modified) clang/test/lit.cfg.py (-10) 
- (modified) llvm/docs/CommandGuide/lit.rst (-5) 
- (modified) llvm/test/lit.cfg.py (-10) 
- (modified) llvm/utils/lit/lit/LitConfig.py (-3) 
- (modified) llvm/utils/lit/lit/TestRunner.py (-12) 
- (modified) llvm/utils/lit/lit/cl_arguments.py (-6) 
- (modified) llvm/utils/lit/lit/llvm/config.py (-5) 
- (modified) llvm/utils/lit/lit/main.py (-1) 
- (modified) llvm/utils/update_any_test_checks.py (+3-51) 


``diff
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 32ed5239b90795..92a3361ce672e2 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -362,13 +362,3 @@ def calculate_arch_features(arch_string):
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
 config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)
diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index dadecef567b7c9..c9d5baba3e2f49 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -313,11 +313,6 @@ ADDITIONAL OPTIONS
 
  List all of the discovered tests and exit.
 
-.. option:: --update-tests
-
- Pass failing tests to functions in the ``lit_config.update_tests`` list to
- check whether any of them know how to update the test to make it pass.
-
 EXIT STATUS
 ---
 
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 1d5b2bcae1b766..5a03a85386e0aa 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -630,13 +630,3 @@ def have_ld64_plugin_support():
 
 if config.has_logf128:
 config.available_features.add("has_logf128")
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)
diff --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py
index 198a2bf3172330..5dc712ae28370c 100644
--- a/llvm/utils/lit/lit/LitConfig.py
+++ b/llvm/utils/lit/lit/LitConfig.py
@@ -38,7 +38,6 @@ def __init__(
 parallelism_groups={},
 per_test_coverage=False,
 gtest_sharding=True,
-update_tests=False,
 ):
 # The name of the test runner.
 self.progname = progname
@@ -90,8 +89,6 @@ def __init__(
 self.parallelism_groups = parallelism_groups
 self.per_test_coverage = per_test_coverage
 self.gtest_sharding = bool(gtest_sharding)
-self.update_tests = update_tests
-self.test_updaters = []
 
 @property
 def maxIndividualTestTime(self):
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 3a2cdc5026b0c2..a1785073547ad0 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1190,18 +1190,6 @@ def executeScriptInternal(
 str(result.timeoutReached),
 )
 
-if litConfig.update_tests:
-for test_updater in litConfig.test_updaters:
-try:
-update_output = test_updater(result, test)
-except Exception as e:
-out += f"Exception occurred in test updater: {e}"
-continue
-if update_output:
-for line in update_output.splitlines():
-out += f"# {line}\n"
-break
-
 return out, err, exitCode, timeoutInfo
 
 
diff --git a/llvm/utils/lit/lit/cl_arguments.py 
b/llvm/utils/lit/lit/cl_arguments.py
index dcbe553c6d4827..ed78256ee414b4 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -204,12 +204,6 @@ def parse_args():
 action="store_true",
 help="Exit with status zero even if some tests fail",
 )
-execution_group.add_argument(
-"--update-tests",
-dest="update_tests",
-action="store_true",
-help="Try to update regression tests to reflect current behavior, if 
possible",
-)
 execution_test_time_group = execution_group.add_mutually_exclusive_group()
 execution_test_time_group.add_argument(
 "--skip-test-time-recording",
diff --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index c05ec1664d4c45..5f762ec7f3514a 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -64,17 +64,12 @@ def __init__(self, lit_config, c

[clang] Allow tag-based API notes on anonymous tag decls with typedef names (PR #110768)

2024-10-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Doug Gregor (DougGregor)


Changes

It is common practice in C to declare anonymous tags that are immediately given 
a typedef name, e.g.,

typedef enum { ... } MyType;

At present, one can only express API notes on the typedef. However, that 
excludes the possibility of tag-specific notes like EnumExtensibility. For 
these anonymous declarations, process API notes using the typedef name as the 
tag name, so that one can add API notes to `MyType` via the `Tags` section.

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


6 Files Affected:

- (modified) clang/lib/Sema/SemaAPINotes.cpp (+9-1) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+3) 
- (modified) 
clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
 (+2) 
- (modified) 
clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h 
(+4) 
- (modified) clang/test/APINotes/types.m (+3) 
- (modified) clang/test/APINotes/yaml-roundtrip-2.test (+1-1) 


``diff
diff --git a/clang/lib/Sema/SemaAPINotes.cpp b/clang/lib/Sema/SemaAPINotes.cpp
index d0236d08c98e68..ec43a0def9c1e6 100644
--- a/clang/lib/Sema/SemaAPINotes.cpp
+++ b/clang/lib/Sema/SemaAPINotes.cpp
@@ -913,7 +913,15 @@ void Sema::ProcessAPINotes(Decl *D) {
 
 // Tags
 if (auto Tag = dyn_cast(D)) {
-  std::string LookupName = Tag->getName().str();
+  // Determine the name of the entity to search for. If this is an
+  // anonymous tag that gets its linked name from a typedef, look for the
+  // typedef name. This allows tag-specific information to be added
+  // to the declaration.
+  std::string LookupName;
+  if (auto typedefName = Tag->getTypedefNameForAnonDecl())
+LookupName = typedefName->getName().str();
+  else
+LookupName = Tag->getName().str();
 
   // Use the source location to discern if this Tag is an OPTIONS macro.
   // For now we would like to limit this trick of looking up the APINote 
tag
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..92c85313d67cdd 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4974,6 +4974,9 @@ void Sema::setTagNameForLinkagePurposes(TagDecl 
*TagFromDeclSpec,
 
   // Otherwise, set this as the anon-decl typedef for the tag.
   TagFromDeclSpec->setTypedefNameForAnonDecl(NewTD);
+
+  // Now that we have a name for the tag, process API notes again.
+  ProcessAPINotes(TagFromDeclSpec);
 }
 
 static unsigned GetDiagnosticTypeSpecifierID(const DeclSpec &DS) {
diff --git 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
index ef6e44c51c21c7..f51811354eb00b 100644
--- 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
+++ 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
@@ -46,3 +46,5 @@ Tags:
 SwiftName:   SuccessfullyRenamedA
   - Name:RenamedAgainInAPINotesB
 SwiftName:   SuccessfullyRenamedB
+  - Name:AnonEnumWithTypedefName
+SwiftName:   SuccessfullyRenamedC
diff --git 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h
index bd73926e9d6af4..7342c3f83141bb 100644
--- 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h
+++ 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h
@@ -27,3 +27,7 @@ void *getCFAuditedToNone_DUMP(void);
 - (id)getOwnedToUnowned __attribute__((__ns_returns_retained__));
 - (id)getUnownedToOwned __attribute__((__ns_returns_not_retained__));
 @end
+
+typedef enum {
+  kConstantInAnonEnum
+} AnonEnumWithTypedefName;
diff --git a/clang/test/APINotes/types.m b/clang/test/APINotes/types.m
index 133d504713d76c..752f1026432844 100644
--- a/clang/test/APINotes/types.m
+++ b/clang/test/APINotes/types.m
@@ -7,6 +7,9 @@
 
 // CHECK: struct __attribute__((swift_name("SuccessfullyRenamedA"))) 
RenamedAgainInAPINotesA {
 // CHECK: struct __attribute__((swift_name("SuccessfullyRenamedB"))) 
RenamedAgainInAPINotesB {
+// CHECK: typedef enum __attribute__((swift_name("SuccessfullyRenamedC"))) {
+// CHECK-NEXT: kConstantInAnonEnum
+// CHECK-NEXT: } AnonEnumWithTypedefName
 
 void test(OverriddenTypes *overridden) {
   int *ip1 = global_int_ptr; // expected-warning{{incompatible pointer types 
initializing 'int *' with an expression of type 'double (*)(int, int)'}}
diff --git a/clang/test/APINotes/yaml-roundtrip-2.test 
b/clang/test/APINotes/yaml-roundtrip-2.test
index b0b777b595060d..63717bda7c0991 100644
--- a/clang/test/APINotes/yaml-roundtrip-2.test
+++ b/clang/test/APINotes/yaml-roundtrip-2.test
@@ -7,5 +7,5 @@ REQUIRES: shell
 
 We expect only the document markers to be emitted

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits

bwendling wrote:

> @bwendling I think you accidentally compiled the wrong branch. Looks like 
> that is in `builtin_get_counted_by`, but this PR is in 
> `bdos-member-expr-error`

Yeah, sorry about that.

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


[libunwind] [libunwind] Fix libunwind library path for runtime test (PR #110777)

2024-10-01 Thread via cfe-commits

zeroomega wrote:

Looks like https://github.com/llvm/llvm-project/pull/108999 broke the check 
bots.

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


[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-01 Thread via cfe-commits

zeroomega wrote:

But IIUC, the diagnostic message change from this PR might be unintentional. 
The expected error message in 793ded7d0b7f1407636a98007f83074b8dd5f765 doesn't 
align to the error message from other tests in the same file. Should that be 
addressed?

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


[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-01 Thread Tex Riddell via cfe-commits

tex3d wrote:

Test fix has re-landed: fea18afeed39fe4435d67eee1834f0f34b23013d.

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


[clang] fea18af - Fix failing test caused by b70d327

2024-10-01 Thread Tex Riddell via cfe-commits

Author: Tex Riddell
Date: 2024-10-01T18:26:05-07:00
New Revision: fea18afeed39fe4435d67eee1834f0f34b23013d

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

LOG: Fix failing test caused by b70d327

`clang/test/Sema/aarch64-sve-vector-trig-ops.c` wasn't updated when merging PR 
#110187, which changed the expected diagnostics for the atan2 test.

Added: 


Modified: 
clang/test/Sema/aarch64-sve-vector-trig-ops.c

Removed: 




diff  --git a/clang/test/Sema/aarch64-sve-vector-trig-ops.c 
b/clang/test/Sema/aarch64-sve-vector-trig-ops.c
index 31f608bf151099..3fe6834be2e0b7 100644
--- a/clang/test/Sema/aarch64-sve-vector-trig-ops.c
+++ b/clang/test/Sema/aarch64-sve-vector-trig-ops.c
@@ -25,7 +25,7 @@ svfloat32_t test_atan_vv_i8mf8(svfloat32_t v) {
 svfloat32_t test_atan2_vv_i8mf8(svfloat32_t v) {
 
   return __builtin_elementwise_atan2(v, v);
-  // expected-error@-1 {{1st argument must be a vector, integer or floating 
point type}}
+  // expected-error@-1 {{1st argument must be a floating point type}}
 }
 
 svfloat32_t test_sin_vv_i8mf8(svfloat32_t v) {



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


[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-01 Thread Tex Riddell via cfe-commits

tex3d wrote:

Unfortunately, I didn't see your revert, and my pull didn't show any changes 
from main before I quickly committed the test change.  So my test change would 
also break the build with your revert.  So I reverted the test change just now! 
Revert: 5d308af894ccc3f7a288d6abd6f9097b4cbc8cf4.

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


[clang] [compiler-rt] [libcxx] [cmake] Add hexagon-linux cmake cache files (PR #98712)

2024-10-01 Thread Brian Cain via cfe-commits


@@ -0,0 +1,25 @@
+

androm3da wrote:

Absolutely.  That's been the status quo and this PR on its own can't change 
that.

The intent of this pull req is to allow anyone to build a toolchain for 
targeting hexagon (of which libc++, libc++abi, libunwind are a part).  But 
another benefit can be that we should be able to setup CI job(s) leveraging 
this, indeed.  We can enable regression tests for the entire toolchain 
including compiler, linker *and* target libraries.

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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (c8ef)


Changes

This patch is a follow-up to #109831. In the discussion, we agreed that 
having parameter checks scattered across different areas isn't ideal. 
Therefore, I suggest merging the check from #88974 into the void 
parameter check. This change won't impact functionality and will enhance 
maintainability.

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


2 Files Affected:

- (modified) clang/lib/Parse/ParseDecl.cpp (+1-14) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+17-4) 


``diff
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a04eed9873c0d4..122a05be1c039a 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7950,21 +7950,8 @@ void Parser::ParseParameterDeclarationClause(
 // Parse a C++23 Explicit Object Parameter
 // We do that in all language modes to produce a better diagnostic.
 SourceLocation ThisLoc;
-if (getLangOpts().CPlusPlus && Tok.is(tok::kw_this)) {
+if (getLangOpts().CPlusPlus && Tok.is(tok::kw_this))
   ThisLoc = ConsumeToken();
-  // C++23 [dcl.fct]p6:
-  //   An explicit-object-parameter-declaration is a parameter-declaration
-  //   with a this specifier. An explicit-object-parameter-declaration
-  //   shall appear only as the first parameter-declaration of a
-  //   parameter-declaration-list of either:
-  //   - a member-declarator that declares a member function, or
-  //   - a lambda-declarator.
-  //
-  // The parameter-declaration-list of a requires-expression is not such
-  // a context.
-  if (DeclaratorCtx == DeclaratorContext::RequiresExpr)
-Diag(ThisLoc, diag::err_requires_expr_explicit_object_parameter);
-}
 
 ParsedTemplateInfo TemplateInfo;
 ParseDeclarationSpecifiers(DS, TemplateInfo, AS_none,
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index b30414a8a8277a..d490452e91c3bb 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -9519,15 +9519,28 @@ Sema::ActOnStartRequiresExpr(SourceLocation 
RequiresKWLoc,
   } else if (Param->getType().hasQualifiers()) {
 Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
   }
-}
-
-if (Param->hasDefaultArg())
+} else if (Param->hasDefaultArg()) {
   // C++2a [expr.prim.req] p4
   // [...] A local parameter of a requires-expression shall not have a
   // default argument. [...]
   Diag(Param->getDefaultArgRange().getBegin(),
diag::err_requires_expr_local_parameter_default_argument);
-// Ignore default argument and move on
+  // Ignore default argument and move on
+} else if (Param->isExplicitObjectParameter()) {
+  // C++23 [dcl.fct]p6:
+  //   An explicit-object-parameter-declaration is a parameter-declaration
+  //   with a this specifier. An explicit-object-parameter-declaration
+  //   shall appear only as the first parameter-declaration of a
+  //   parameter-declaration-list of either:
+  //   - a member-declarator that declares a member function, or
+  //   - a lambda-declarator.
+  //
+  // The parameter-declaration-list of a requires-expression is not such
+  // a context.
+  Diag(Param->getExplicitObjectParamThisLoc(),
+   diag::err_requires_expr_explicit_object_parameter);
+  Param->setExplicitObjectParameterLoc(SourceLocation());
+}
 
 Param->setDeclContext(Body);
 // If this has an identifier, add it to the scope stack.

``




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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread Younan Zhang via cfe-commits

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


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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread via cfe-commits

https://github.com/c8ef ready_for_review 
https://github.com/llvm/llvm-project/pull/110773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread via cfe-commits

https://github.com/c8ef edited https://github.com/llvm/llvm-project/pull/110773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread via cfe-commits

c8ef wrote:

CC @zyn0217 @mizvekov @cor3ntin

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


[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-01 Thread Tex Riddell via cfe-commits

tex3d wrote:

> But IIUC, the diagnostic message change from this PR might be unintentional. 
> The expected error message in 
> [793ded7](https://github.com/llvm/llvm-project/commit/793ded7d0b7f1407636a98007f83074b8dd5f765)
>  doesn't align to the error message from other tests in the same file. Should 
> that be addressed?

The other error messages in the file are now different because the path taken 
for the one arg intrinsic is different (calling 
`PrepareBuiltinElementwiseMathOneArgCall`, which calls 
`checkMathBuiltinElementType`, which emits this error).

It would be nice to fix these somehow, but I don't know if that should be part 
of landing this PR.

I didn't like that wording in the diagnostic for multiple reasons (vector, 
integer or floating point??), but there wasn't a clear fix that wouldn't have 
broader impact, so I avoided rocking the boat here.  I think it would be great 
to have a cleaner diagnostic and a better function structure for this code, but 
that probably makes more sense as a separate cleanup step at this point.

Honestly, this code makes me wish there was a more regular structure to 
defining and applying needed constraints here.  It currently feels a bit 
convoluted and messy.

What do you think?

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/110638

>From 38430b6cdfc524972fbdabca6a037174eaf1549f Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 09:08:14 +
Subject: [PATCH 1/4] 110558

---
 clang/lib/Sema/SemaDecl.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ed189e02a51d22 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,6 +9085,11 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+CXXRecordDecl *RD = NewMD->getParent();
+SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
+<< RD->getName() << RD->getLocation();
+  }
 
   bool NewFDisConst = false;
   if (CXXMethodDecl *NewMD = dyn_cast(NewFD))

>From 8f37ce5dec7361b0dbc1ad6f912048fa6bbc38ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 10:19:00 +
Subject: [PATCH 2/4] fix

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed189e02a51d22..7b62b4f6d6433d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,7 +9085,8 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+  CXXMethodDecl *NewMD = dyn_cast(NewFD);
+  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();

>From c875c6cb3c0ec64d29a4b4c31ac4eb3605f43289 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 11:52:22 +
Subject: [PATCH 3/4] fix test

---
 clang/lib/Sema/SemaDecl.cpp|  7 +++
 .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp |  1 +
 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp |  1 +
 clang/test/CXX/dcl/dcl.fct/p17.cpp |  1 +
 clang/test/CXX/drs/cwg22xx.cpp |  1 +
 clang/test/CXX/drs/cwg3xx.cpp  |  7 ++-
 clang/test/CXX/special/class.inhctor/p8.cpp|  1 +
 .../temp.constr.decl/func-template-decl.cpp|  1 +
 clang/test/CXX/temp/temp.res/temp.local/p8.cpp |  8 
 .../test/CXX/temp/temp.spec/temp.expl.spec/p12.cpp |  2 ++
 .../CXX/temp/temp.spec/temp.expl.spec/p14-23.cpp   |  1 +
 .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp |  1 +
 clang/test/FixIt/member-mismatch.cpp   |  2 ++
 clang/test/Parser/cxx-class.cpp|  1 +
 clang/test/SemaCXX/attr-target-mv.cpp  |  7 ---
 clang/test/SemaCXX/attr-target-version.cpp |  7 ---
 clang/test/SemaCXX/enable_if.cpp   |  2 +-
 clang/test/SemaCXX/function-redecl.cpp | 14 --
 clang/test/SemaCXX/lambda-unevaluated.cpp  |  2 ++
 clang/test/SemaCXX/nested-name-spec.cpp|  4 
 clang/test/SemaCXX/out-of-line-def-mismatch.cpp|  6 +-
 clang/test/SemaCXX/typo-correction.cpp |  1 +
 .../test/SemaTemplate/concepts-out-of-line-def.cpp |  4 +++-
 clang/test/SemaTemplate/recovery-crash.cpp |  5 +++--
 24 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7b62b4f6d6433d..e4c45cbc09e0f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,16 +9085,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+
   CXXMethodDecl *NewMD = dyn_cast(NewFD);
-  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
+  if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();
   }
 
-  bool NewFDisConst = false;
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD))
-NewFDisConst = NewMD->isConst();
+  bool NewFDisConst = NewMD && NewMD->isConst();
 
   for (SmallVectorImpl >::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 9e890204c78bd6..f0901733f8afeb 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -170,5 +170,6 @@ namespace ImplicitConstexprDef {
 
   constexpr void A::f() { } // expected-warning {{'constexpr' non-static 
member function will n

[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -781,6 +798,9 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 #define INSTR_PROF_COVNAME_COFF ".lcovn"
 #define INSTR_PROF_ORDERFILE_COFF ".lorderfile$M"
 
+// TODO: Placeholder for Windows. We need to revise when we upstream this.

hubert-reinterpretcast wrote:

Comment requires update (this PR is for "upstream"). Perhaps the TODO should be 
made a FIXME.

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


[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -1,9 +1,15 @@
 ;; Ensure __llvm_gcov_(writeout|reset|init) have the correct !kcfi_type
 ;; with integer normalization.
 ; RUN: mkdir -p %t && cd %t
-; RUN: opt < %s -S -passes=insert-gcov-profiling | FileCheck %s
+; RUN: opt < %s -S -passes=insert-gcov-profiling \
+; RUN:  -mtriple=x86_64-unknown-linux-gnu | FileCheck \
+; RUN:  --check-prefixes=CHECK,CHECK-ELF %s

hubert-reinterpretcast wrote:

Same comment re: `CHECK-ELF`.

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread Matheus Izvekov via cfe-commits

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


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


[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread Matheus Izvekov via cfe-commits

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


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


[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -1,7 +1,13 @@
 ; RUN: mkdir -p %t && cd %t
-; RUN: opt < %s -S -passes=insert-gcov-profiling | FileCheck %s
+; RUN: opt < %s -S -passes=insert-gcov-profiling \
+; RUN:  -mtriple=x86_64-unknown-linux-gnu | FileCheck \
+; RUN:  --check-prefixes=CHECK,CHECK-ELF %s

hubert-reinterpretcast wrote:

Same comment re: `CHECK-ELF`.

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


[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -2962,13 +2964,34 @@ void PPCAIXAsmPrinter::emitPGORefs(Module &M) {
   }
 }
 
+void PPCAIXAsmPrinter::emitGCOVRefs() {
+  if (!OutContext.hasXCOFFSection(
+  "__llvm_gcov_ctr_section",
+  XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD)))
+return;
+
+  MCSection *CtrSection = OutContext.getXCOFFSection(
+  "__llvm_gcov_ctr_section", SectionKind::getData(),
+  XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD),
+  /*MultiSymbolsAllowed*/ true);
+
+  OutStreamer->switchSection(CtrSection);
+  if (OutContext.hasXCOFFSection(
+  "__llvm_covinit",
+  XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD))) {

hubert-reinterpretcast wrote:

Does not have to be addressed now, but this should be `XMC_RO` depending on the 
`-mxcoff-roptr` option.

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


[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -914,6 +918,7 @@ bool GCOVProfiler::emitProfileNotes(
 GlobalVariable *Counters = new GlobalVariable(
 *M, CounterTy, false, GlobalValue::InternalLinkage,
 Constant::getNullValue(CounterTy), "__llvm_gcov_ctr");
+Counters->setSection("__llvm_gcov_ctr_section");

hubert-reinterpretcast wrote:

This is not coded as an AIX-only change. Please confirm if the code matches the 
intent.

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


[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -1,8 +1,14 @@
 ;; Ensure __llvm_gcov_(writeout|reset|init) have !kcfi_type with KCFI.
 ; RUN: mkdir -p %t && cd %t
-; RUN: opt < %s -S -passes=insert-gcov-profiling | FileCheck %s
+; RUN: opt < %s -S -passes=insert-gcov-profiling \
+; RUN:  -mtriple=x86_64-unknown-linux-gnu | FileCheck \
+; RUN:  --check-prefixes=CHECK,CHECK-ELF %s

hubert-reinterpretcast wrote:

Same comment re: `CHECK-ELF`.

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


[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -2962,13 +2964,34 @@ void PPCAIXAsmPrinter::emitPGORefs(Module &M) {
   }
 }
 
+void PPCAIXAsmPrinter::emitGCOVRefs() {
+  if (!OutContext.hasXCOFFSection(
+  "__llvm_gcov_ctr_section",
+  XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD)))
+return;
+
+  MCSection *CtrSection = OutContext.getXCOFFSection(
+  "__llvm_gcov_ctr_section", SectionKind::getData(),
+  XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD),
+  /*MultiSymbolsAllowed*/ true);
+
+  OutStreamer->switchSection(CtrSection);
+  if (OutContext.hasXCOFFSection(
+  "__llvm_covinit",
+  XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD))) {
+MCSymbol *S = OutContext.getOrCreateSymbol("__llvm_covinit[RW]");
+OutStreamer->emitXCOFFRefDirective(S);

hubert-reinterpretcast wrote:

Where is the unit testing for this (for assembly and for direct XCOFF 
generation)?

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


[clang] [compiler-rt] [llvm] [PGO] Initialize GOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits


@@ -781,6 +798,9 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 #define INSTR_PROF_COVNAME_COFF ".lcovn"
 #define INSTR_PROF_ORDERFILE_COFF ".lorderfile$M"
 
+// TODO: Placeholder for Windows. We need to revise when we upstream this.

hubert-reinterpretcast wrote:

Same comment as for the other copy.

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


[clang] [compiler-rt] [llvm] [PGO] Initialize GCOV Writeout and Reset Functions in the Runtime on AIX (PR #108570)

2024-10-01 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/108570
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/110638

>From 38430b6cdfc524972fbdabca6a037174eaf1549f Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 09:08:14 +
Subject: [PATCH 1/6] 110558

---
 clang/lib/Sema/SemaDecl.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ed189e02a51d22 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,6 +9085,11 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+CXXRecordDecl *RD = NewMD->getParent();
+SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
+<< RD->getName() << RD->getLocation();
+  }
 
   bool NewFDisConst = false;
   if (CXXMethodDecl *NewMD = dyn_cast(NewFD))

>From 8f37ce5dec7361b0dbc1ad6f912048fa6bbc38ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 10:19:00 +
Subject: [PATCH 2/6] fix

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed189e02a51d22..7b62b4f6d6433d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,7 +9085,8 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+  CXXMethodDecl *NewMD = dyn_cast(NewFD);
+  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();

>From c875c6cb3c0ec64d29a4b4c31ac4eb3605f43289 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 11:52:22 +
Subject: [PATCH 3/6] fix test

---
 clang/lib/Sema/SemaDecl.cpp|  7 +++
 .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp |  1 +
 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp |  1 +
 clang/test/CXX/dcl/dcl.fct/p17.cpp |  1 +
 clang/test/CXX/drs/cwg22xx.cpp |  1 +
 clang/test/CXX/drs/cwg3xx.cpp  |  7 ++-
 clang/test/CXX/special/class.inhctor/p8.cpp|  1 +
 .../temp.constr.decl/func-template-decl.cpp|  1 +
 clang/test/CXX/temp/temp.res/temp.local/p8.cpp |  8 
 .../test/CXX/temp/temp.spec/temp.expl.spec/p12.cpp |  2 ++
 .../CXX/temp/temp.spec/temp.expl.spec/p14-23.cpp   |  1 +
 .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp |  1 +
 clang/test/FixIt/member-mismatch.cpp   |  2 ++
 clang/test/Parser/cxx-class.cpp|  1 +
 clang/test/SemaCXX/attr-target-mv.cpp  |  7 ---
 clang/test/SemaCXX/attr-target-version.cpp |  7 ---
 clang/test/SemaCXX/enable_if.cpp   |  2 +-
 clang/test/SemaCXX/function-redecl.cpp | 14 --
 clang/test/SemaCXX/lambda-unevaluated.cpp  |  2 ++
 clang/test/SemaCXX/nested-name-spec.cpp|  4 
 clang/test/SemaCXX/out-of-line-def-mismatch.cpp|  6 +-
 clang/test/SemaCXX/typo-correction.cpp |  1 +
 .../test/SemaTemplate/concepts-out-of-line-def.cpp |  4 +++-
 clang/test/SemaTemplate/recovery-crash.cpp |  5 +++--
 24 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7b62b4f6d6433d..e4c45cbc09e0f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,16 +9085,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+
   CXXMethodDecl *NewMD = dyn_cast(NewFD);
-  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
+  if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();
   }
 
-  bool NewFDisConst = false;
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD))
-NewFDisConst = NewMD->isConst();
+  bool NewFDisConst = NewMD && NewMD->isConst();
 
   for (SmallVectorImpl >::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 9e890204c78bd6..f0901733f8afeb 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -170,5 +170,6 @@ namespace ImplicitConstexprDef {
 
   constexpr void A::f() { } // expected-warning {{'constexpr' non-static 
member function will n

[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/110638

>From 38430b6cdfc524972fbdabca6a037174eaf1549f Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 09:08:14 +
Subject: [PATCH 1/7] 110558

---
 clang/lib/Sema/SemaDecl.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ed189e02a51d22 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,6 +9085,11 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+CXXRecordDecl *RD = NewMD->getParent();
+SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
+<< RD->getName() << RD->getLocation();
+  }
 
   bool NewFDisConst = false;
   if (CXXMethodDecl *NewMD = dyn_cast(NewFD))

>From 8f37ce5dec7361b0dbc1ad6f912048fa6bbc38ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 10:19:00 +
Subject: [PATCH 2/7] fix

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed189e02a51d22..7b62b4f6d6433d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,7 +9085,8 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+  CXXMethodDecl *NewMD = dyn_cast(NewFD);
+  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();

>From c875c6cb3c0ec64d29a4b4c31ac4eb3605f43289 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 11:52:22 +
Subject: [PATCH 3/7] fix test

---
 clang/lib/Sema/SemaDecl.cpp|  7 +++
 .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp |  1 +
 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp |  1 +
 clang/test/CXX/dcl/dcl.fct/p17.cpp |  1 +
 clang/test/CXX/drs/cwg22xx.cpp |  1 +
 clang/test/CXX/drs/cwg3xx.cpp  |  7 ++-
 clang/test/CXX/special/class.inhctor/p8.cpp|  1 +
 .../temp.constr.decl/func-template-decl.cpp|  1 +
 clang/test/CXX/temp/temp.res/temp.local/p8.cpp |  8 
 .../test/CXX/temp/temp.spec/temp.expl.spec/p12.cpp |  2 ++
 .../CXX/temp/temp.spec/temp.expl.spec/p14-23.cpp   |  1 +
 .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp |  1 +
 clang/test/FixIt/member-mismatch.cpp   |  2 ++
 clang/test/Parser/cxx-class.cpp|  1 +
 clang/test/SemaCXX/attr-target-mv.cpp  |  7 ---
 clang/test/SemaCXX/attr-target-version.cpp |  7 ---
 clang/test/SemaCXX/enable_if.cpp   |  2 +-
 clang/test/SemaCXX/function-redecl.cpp | 14 --
 clang/test/SemaCXX/lambda-unevaluated.cpp  |  2 ++
 clang/test/SemaCXX/nested-name-spec.cpp|  4 
 clang/test/SemaCXX/out-of-line-def-mismatch.cpp|  6 +-
 clang/test/SemaCXX/typo-correction.cpp |  1 +
 .../test/SemaTemplate/concepts-out-of-line-def.cpp |  4 +++-
 clang/test/SemaTemplate/recovery-crash.cpp |  5 +++--
 24 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7b62b4f6d6433d..e4c45cbc09e0f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,16 +9085,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+
   CXXMethodDecl *NewMD = dyn_cast(NewFD);
-  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
+  if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();
   }
 
-  bool NewFDisConst = false;
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD))
-NewFDisConst = NewMD->isConst();
+  bool NewFDisConst = NewMD && NewMD->isConst();
 
   for (SmallVectorImpl >::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 9e890204c78bd6..f0901733f8afeb 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -170,5 +170,6 @@ namespace ImplicitConstexprDef {
 
   constexpr void A::f() { } // expected-warning {{'constexpr' non-static 
member function will n

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits

https://github.com/bwendling updated 
https://github.com/llvm/llvm-project/pull/110487

>From 375a71d114fffb94c16455f476364a7de9e08191 Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Mon, 30 Sep 2024 03:41:15 -0700
Subject: [PATCH 1/2] [Clang][CodeGen] Emit load of value

We were missing a load of the value after emitting the MemberExpr. This
was causing __builtin_dynamic_object_size to return 0 incorrectly.

Signed-off-by: Bill Wendling 
---
 clang/lib/CodeGen/CGExpr.cpp  |  1 +
 clang/test/CodeGen/attr-counted-by-pr110385.c | 74 +++
 2 files changed, 75 insertions(+)
 create mode 100644 clang/test/CodeGen/attr-counted-by-pr110385.c

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index df4994ba9af6e1..4e26e9f7076777 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1169,6 +1169,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfCountedByField(
 LValue LV = EmitMemberExpr(ME);
 Address Addr = LV.getAddress();
 Res = Addr.emitRawPointer(*this);
+Res = Builder.CreateAlignedLoad(Res->getType(), Res, getPointerAlign());
   } else if (StructBase->getType()->isPointerType()) {
 LValueBaseInfo BaseInfo;
 TBAAAccessInfo TBAAInfo;
diff --git a/clang/test/CodeGen/attr-counted-by-pr110385.c 
b/clang/test/CodeGen/attr-counted-by-pr110385.c
new file mode 100644
index 00..1f11bc1a04c81b
--- /dev/null
+++ b/clang/test/CodeGen/attr-counted-by-pr110385.c
@@ -0,0 +1,74 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fstrict-flex-arrays=2 
-emit-llvm -o - %s | FileCheck %s
+
+struct bch_val {
+  unsigned long int __nothing[0];
+};
+
+struct bch_xattr {
+  struct bch_val v;
+  unsigned char x_type;
+  unsigned char x_name_len;
+  unsigned char x_name[] __attribute__((__counted_by__(x_name_len)));
+};
+
+struct bkey_s_c {
+  const struct bch_val *v;
+};
+
+struct bkey_s_c_xattr {
+  union {
+const struct bch_xattr *v;
+struct bkey_s_c s_c;
+  };
+};
+
+// CHECK-LABEL: define dso_local i64 @test1(
+// CHECK-SAME: ptr [[K_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[K:%.*]] = alloca [[STRUCT_BKEY_S_C:%.*]], align 8
+// CHECK-NEXT:[[XATTR:%.*]] = alloca [[STRUCT_BKEY_S_C_XATTR:%.*]], align 8
+// CHECK-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C]], ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[K_COERCE]], ptr [[COERCE_DIVE]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[V:%.*]] = getelementptr inbounds nuw [[STRUCT_BKEY_S_C]], 
ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[V]], align 8
+// CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_VAL:%.*]], ptr [[TMP1]], i64 0
+// CHECK-NEXT:store ptr [[ADD_PTR]], ptr [[TMP0]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[TMP2]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP3]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP4:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP5:%.*]] = mul nuw i64 [[TMP4]], 1
+// CHECK-NEXT:[[TMP6:%.*]] = icmp sgt i64 [[TMP4]], -1
+// CHECK-NEXT:[[TMP7:%.*]] = select i1 [[TMP6]], i64 [[TMP5]], i64 0
+// CHECK-NEXT:ret i64 [[TMP7]]
+//
+unsigned long int test1(struct bkey_s_c k) {
+  struct bkey_s_c_xattr xattr = (struct bkey_s_c_xattr){
+  .v = (struct bch_xattr *)(k.v - __builtin_offsetof(struct bch_xattr, v))
+  };
+
+  return __builtin_dynamic_object_size(xattr.v->x_name, 0);
+}
+
+// CHECK-LABEL: define dso_local i64 @test2(
+// CHECK-SAME: ptr noundef [[XATTR:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[XATTR_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[XATTR]], ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR:%.*]], ptr [[TMP0]], i32 0, i32 0
+// CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP1]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP3:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP4:%.*]] = mul nuw i64 [[TMP3]], 1
+// CHECK-NEXT:[[TMP5:%.*]] = icmp sgt i64 [[TMP3]], -1
+// CHECK-NEXT:[[TMP6:%.*]] = select i1 [[TMP5]], i64 [[TMP4]], i64 0
+// CHECK-N

[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Lei Wang via cfe-commits

wlei-llvm wrote:

Thanks for the context! 
> Why not use the existing `-pgo-function-entry-coverage` 
> (https://discourse.llvm.org/t/instrprofiling-lightweight-instrumentation/59113/14?u=ellishg)
>  LLVM flag? It takes advantage of the `llvm.instrprof.cover` intrinsic which 
> has less size and runtime overhead than `llvm.instrprof.increment`.

We do use the  `-pgo-function-entry-coverage` in this PR, see 
[here](https://github.com/llvm/llvm-project/pull/109837/files#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228R666-R667).
 but furthermore, we skip instrumenting the functions that are covered by 
sampling PGO profile. 

> It also supports IRPGO and CSIRPGO while it seems that this PR requires a 
> sample PGO input.

Yeah, as I commented above, unfortunately currently the IRPGO main flag is 
incompatible with the Sampling PGO flag(also a bit diverged for the pipeline 
passes), that's why we have to add extra instr passes under sampling PGO 
pipeline and added a new driver flag. 


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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v5 (PR #108636)

2024-10-01 Thread via cfe-commits


@@ -522,6 +526,28 @@ let Predicates = [BPFNoALU32] in {
 }
 def STD : STOREi64;
 
+class relaxed_store
+  : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+  let IsAtomic = 1;
+  let IsAtomicOrderingReleaseOrStronger = 0;
+}
+
+class releasing_store
+  : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+  let IsAtomic = 1;
+  let IsAtomicOrderingRelease = 1;
+}

yonghong-song wrote:

I found the following in arm64:
```
// A store operation that actually needs release semantics.
class releasing_store
  : PatFrag<(ops node:$ptr, node:$val), (base node:$val, node:$ptr)> {
  let IsAtomic = 1;
  let IsAtomicOrderingReleaseOrStronger = 1;
}

// An atomic store operation that doesn't actually need to be atomic on AArch64.
class relaxed_store
  : PatFrag<(ops node:$ptr, node:$val), (base node:$val, node:$ptr)> {
  let IsAtomic = 1;
  let IsAtomicOrderingReleaseOrStronger = 0;
}
```

What is the difference between IsAtomicOrderingReleaseOrStronger = 1 vs. 
IsAtomicOrderingReleas = 1?


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


[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits

bwendling wrote:

I reverted my last commit. This leaves the original patch, which seems to work. 
@efriedma-quic, would you be okay with this patch while I work to improve the 
code in follow-up?

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Ellis Hoag via cfe-commits


@@ -649,6 +649,24 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
 }
   }
 
+  if (auto *ColdFuncCoverageArg = Args.getLastArg(
+  options::OPT_fprofile_generate_cold_function_coverage,
+  options::OPT_fprofile_generate_cold_function_coverage_EQ)) {
+SmallString<128> Path(
+ColdFuncCoverageArg->getOption().matches(
+options::OPT_fprofile_generate_cold_function_coverage_EQ)
+? ColdFuncCoverageArg->getValue()
+: "");
+llvm::sys::path::append(Path, "default_%m.profraw");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString(
+Twine("--instrument-sample-cold-function-path=") + Path));
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("--instrument-cold-function-coverage");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("--pgo-function-entry-coverage");

ellishg wrote:

You probably want to add a driver test case for this change like
https://github.com/llvm/llvm-project/blob/2f4327294dccc27fc9d5febe71196f6f854d66ff/clang/test/Driver/fcs-profile-generate.c#L1-L4

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Ellis Hoag via cfe-commits


@@ -1119,6 +1125,18 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   // removed.
   MPM.addPass(
   PGOIndirectCallPromotion(true /* IsInLTO */, true /* SamplePGO */));
+
+if (InstrumentSampleColdFuncPath.getNumOccurrences() &&
+Phase != ThinOrFullLTOPhase::ThinLTOPostLink) {
+  assert(!InstrumentSampleColdFuncPath.empty() &&
+ "File path is requeired for instrumentation generation");
+  InstrumentColdFunctionCoverage = true;
+  addPreInlinerPasses(MPM, Level, Phase);
+  addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true,
+/* IsCS */ false, /* AtomicCounterUpdate */ false,
+InstrumentSampleColdFuncPath, "",
+IntrusiveRefCntPtr());
+}

ellishg wrote:

After looking at this a bit closer, I'm not sure why it needs to be tied to 
closely to SamplePGO. Couldn't we move this out of the `LoadSampleProfile` and 
move it after `IsPGOInstrUse/IsCtxProfUse`? That way we can use IRPGO, CSIRPGO, 
and SamplePGO profile counts to block instrumentation hot functions.

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


[clang] [HLSL][clang] Add elementwise builtin for atan2 (p3) (PR #110187)

2024-10-01 Thread via cfe-commits

zeroomega wrote:

We are seeing `Clang :: Sema/aarch64-sve-vector-trig-ops.c` test failure after 
this change got landed.

```
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/s/w/ir/x/w/llvm_build/bin/clang -cc1 -internal-isystem 
/b/s/w/ir/x/w/llvm_build/lib/clang/20/include -nostdsysteminc -triple aarch64 
-target-feature +sve-disable-O0-optnone -o - -fsyntax-only 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c 
-verify
+ /b/s/w/ir/x/w/llvm_build/bin/clang -cc1 -internal-isystem 
/b/s/w/ir/x/w/llvm_build/lib/clang/20/include -nostdsysteminc -triple aarch64 
-target-feature +sve -disable-O0-optnone -o - -fsyntax-only 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c 
-verify
error: 'expected-error' diagnostics expected but not seen: 
  File 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c 
Line 27 (directive at 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c:28):
 1st argument must be a vector, integer or floating point type
error: 'expected-error' diagnostics seen but not expected: 
  File 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c 
Line 27: 1st argument must be a floating point type (was 'svfloat32_t' (aka 
'__SVFloat32_t'))
2 errors generated.

--
```

There are multiple llvm test failures going on so it is a bit difficult to 
isolate every one of them. But this patch touched the failing test file. Could 
you take a look please?

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Lei Wang via cfe-commits


@@ -1784,6 +1784,12 @@ defm debug_info_for_profiling : 
BoolFOption<"debug-info-for-profiling",
   PosFlag,
   NegFlag>;
+def fprofile_generate_cold_function_coverage : Flag<["-"], 
"fprofile-generate-cold-function-coverage">, 

wlei-llvm wrote:

Sorry if my PR description is not clear. Note that there is no use for  
`-fprofile-generate` and  `-fprofile-instr-generate` here, so a driver flag 
here is to configure the instr file path and make linker to link the 
compiler.profile object files (just similar to `-fprofile-[instr]-generate=`).

The reason for not using `-fprofile-[instr]-generate` is because those flags 
conflict with `-fprofile-sample-use`, see 
[PGOOptions](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/PGOOptions.h#L27-L43),
 `ProfileFile` is a shared file path which means the two flags are actually 
mutually exclusive. 

Another option is to make `-fprofile-generate` compatible with 
`-fprofile-samle-use`(like refactoring PGOOptions or adding another flag to 
configure the file path things), this seems to me they are more complicated 
than the current one. But I’m open to any suggestions on this. 

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-01 Thread Lei Wang via cfe-commits

wlei-llvm wrote:

> For your use case, can you use 
> [ProfileSymbolList](https://github.com/llvm/llvm-project/blob/32ffc9fdc2cd422c88c926b862adb3de726e3888/llvm/include/llvm/ProfileData/SampleProf.h#L1509-L1512)
>  to identify very cold functions (executed but unsampled) or are you indeed 
> looking for functions that are never executed?

We are indeed focusing on functions that are never executed. The 
ProfileSymbolList is already used to identify functions with a “0” entry count, 
which is the target of the instrumentation in this work. We then aim to further 
distinguish the dead functions from them.

> 
> Will this be used to guide developers with diagnostics or more aggressive 
> compiler driven optimizations?

We haven’t considered to use them for any compiler optimization. The primary 
goal is to improve the developer experience, just to take the general benefits 
from removing dead code: improving readability, good codebase maintainability, 
reducing build time, etc. Another potential use might be to verify the sampling 
PGO profile coverage/quality, say to check if we missed any functions that are 
actually hot. 


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


[clang] [clang-shlib] Add symbol versioning to all symbols (PR #110758)

2024-10-01 Thread Tom Stellard via cfe-commits

https://github.com/tstellar created 
https://github.com/llvm/llvm-project/pull/110758

We do the same thing for libLLVM.so.  This should help avoid issues when an 
applications loads two different versions of the library at the same time.

>From 59673ed97d92df34d6f662da5a51f6e28806b5af Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Thu, 26 Sep 2024 13:53:18 +
Subject: [PATCH] [clang-shlib] Add symbol versioning to all symbols

We do the same thing for libLLVM.so.  This should help avoid issues
when an applications loads two different versions of the library at
the same time.
---
 clang/tools/clang-shlib/CMakeLists.txt   | 7 +++
 clang/tools/clang-shlib/simple_version_script.map.in | 1 +
 2 files changed, 8 insertions(+)
 create mode 100644 clang/tools/clang-shlib/simple_version_script.map.in

diff --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index 298d3a9d18fec8..004ce2897960ca 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -61,3 +61,10 @@ if (MINGW OR CYGWIN)
   # make sure we export all symbols despite potential dllexports.
   target_link_options(clang-cpp PRIVATE LINKER:--export-all-symbols)
 endif()
+
+# Solaris ld does not accept global: *; so there is no way to version *all* 
global symbols
+if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+  target_link_options(clang-cpp PRIVATE 
-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+endif()
diff --git a/clang/tools/clang-shlib/simple_version_script.map.in 
b/clang/tools/clang-shlib/simple_version_script.map.in
new file mode 100644
index 00..cb2306d1f59682
--- /dev/null
+++ b/clang/tools/clang-shlib/simple_version_script.map.in
@@ -0,0 +1 @@
+@LLVM_SHLIB_SYMBOL_VERSION@ { global: *; };

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


[clang] [llvm] Revert "[Utils] Add new --update-tests flag to llvm-lit" (PR #110772)

2024-10-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Henrik G. Olsson (hnrklssn)


Changes

Reverts llvm/llvm-project#108425

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


9 Files Affected:

- (modified) clang/test/lit.cfg.py (-10) 
- (modified) llvm/docs/CommandGuide/lit.rst (-5) 
- (modified) llvm/test/lit.cfg.py (-10) 
- (modified) llvm/utils/lit/lit/LitConfig.py (-3) 
- (modified) llvm/utils/lit/lit/TestRunner.py (-12) 
- (modified) llvm/utils/lit/lit/cl_arguments.py (-6) 
- (modified) llvm/utils/lit/lit/llvm/config.py (-5) 
- (modified) llvm/utils/lit/lit/main.py (-1) 
- (modified) llvm/utils/update_any_test_checks.py (+3-51) 


``diff
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 32ed5239b90795..92a3361ce672e2 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -362,13 +362,3 @@ def calculate_arch_features(arch_string):
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
 config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)
diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index dadecef567b7c9..c9d5baba3e2f49 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -313,11 +313,6 @@ ADDITIONAL OPTIONS
 
  List all of the discovered tests and exit.
 
-.. option:: --update-tests
-
- Pass failing tests to functions in the ``lit_config.update_tests`` list to
- check whether any of them know how to update the test to make it pass.
-
 EXIT STATUS
 ---
 
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 1d5b2bcae1b766..5a03a85386e0aa 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -630,13 +630,3 @@ def have_ld64_plugin_support():
 
 if config.has_logf128:
 config.available_features.add("has_logf128")
-
-if lit_config.update_tests:
-import sys
-import os
-
-utilspath = os.path.join(config.llvm_src_root, "utils")
-sys.path.append(utilspath)
-from update_any_test_checks import utc_lit_plugin
-
-lit_config.test_updaters.append(utc_lit_plugin)
diff --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py
index 198a2bf3172330..5dc712ae28370c 100644
--- a/llvm/utils/lit/lit/LitConfig.py
+++ b/llvm/utils/lit/lit/LitConfig.py
@@ -38,7 +38,6 @@ def __init__(
 parallelism_groups={},
 per_test_coverage=False,
 gtest_sharding=True,
-update_tests=False,
 ):
 # The name of the test runner.
 self.progname = progname
@@ -90,8 +89,6 @@ def __init__(
 self.parallelism_groups = parallelism_groups
 self.per_test_coverage = per_test_coverage
 self.gtest_sharding = bool(gtest_sharding)
-self.update_tests = update_tests
-self.test_updaters = []
 
 @property
 def maxIndividualTestTime(self):
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 3a2cdc5026b0c2..a1785073547ad0 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1190,18 +1190,6 @@ def executeScriptInternal(
 str(result.timeoutReached),
 )
 
-if litConfig.update_tests:
-for test_updater in litConfig.test_updaters:
-try:
-update_output = test_updater(result, test)
-except Exception as e:
-out += f"Exception occurred in test updater: {e}"
-continue
-if update_output:
-for line in update_output.splitlines():
-out += f"# {line}\n"
-break
-
 return out, err, exitCode, timeoutInfo
 
 
diff --git a/llvm/utils/lit/lit/cl_arguments.py 
b/llvm/utils/lit/lit/cl_arguments.py
index dcbe553c6d4827..ed78256ee414b4 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -204,12 +204,6 @@ def parse_args():
 action="store_true",
 help="Exit with status zero even if some tests fail",
 )
-execution_group.add_argument(
-"--update-tests",
-dest="update_tests",
-action="store_true",
-help="Try to update regression tests to reflect current behavior, if 
possible",
-)
 execution_test_time_group = execution_group.add_mutually_exclusive_group()
 execution_test_time_group.add_argument(
 "--skip-test-time-recording",
diff --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index c05ec1664d4c45..5f762ec7f3514a 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -64,17 +64,12 @@ def __init__(self, lit_config, config):

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits

bwendling wrote:

> > I reverted my last commit. This leaves the original patch, which seems to 
> > work. @efriedma-quic, would you be okay with this patch while I work to 
> > improve the code in follow-up?
> 
> The original (and current) patch in this PR still introduces a regression. So 
> it should not be merged in my opinion.
> 
> Look at the following C file (`test.c`):
> 
> ```c
> #include 
> #include 
> #include 
> 
> struct variable {
> int a;
> int b;
> int length;
> short array[] __attribute__((counted_by(length)));
> };
> 
> struct bucket {
> int a;
> struct variable growable;
> };
> 
> int main(int argc, char *argv[])
> {
> struct bucket *p;
> 
> p = malloc(sizeof(*p) + sizeof(*p->growable.array) * 32);
> p->growable.length = 32;
> 
> printf("%zu\n", __builtin_dynamic_object_size(p->growable.array, 1));
> 
> return 0;
> }
> ```
> 
> Compiling this file with clang 19.1.0 and running it:
> 
> ```shell
> $ clang --version
> clang version 19.1.0 (Fedora 19.1.0-1.fc41)
> Target: x86_64-redhat-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin
> Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg
> 
> $ clang test.c
> 
> $ ./a.out
> 64
> ```
> 
> Correctly prints `64`.
> 
> But compiling and running it with the original (and current) patch in this PR:
> 
> ```shell
> $ clang --version
> clang version 20.0.0git (g...@github.com:llvm/llvm-project.git 
> 2de76472e0d1417b64da5aa2c1138eb365685d3a)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /home/jan/llvm-project/build2/bin
> 
> $ clang test.c
> 
> $ ./a.out
> Segmentation fault (core dumped)
> ```
> 
> Will result in a binary that crashes with a segmentation fault.
> 
> My PR #110497 adds a test case for this scenario and does not have the same 
> issue: 
> https://github.com/Cydox/llvm-project/blob/15b69329a97706ada7d5e8cbeb76508aa55b418f/clang/test/CodeGen/attr-counted-by-pr110385.c#L61

This is what I get:

```
kiff ~/llvm/llvm-project (builtin_get_counted_by) $ cat > /tmp/y.c
#include 
#include 
#include 

struct variable {
int a;
int b;
int length;
short array[] __attribute__((counted_by(length)));
};

struct bucket {
int a;
struct variable growable;
};

int main(int argc, char *argv[])
{
struct bucket *p;

p = malloc(sizeof(*p) + sizeof(*p->growable.array) * 32);
p->growable.length = 32;

printf("%zu\n", __builtin_dynamic_object_size(p->growable.array, 1));

return 0;
}
kiff ~/llvm/llvm-project (builtin_get_counted_by) $ ./build.opt/bin/clang -O2 
/tmp/y.c && ./a.out
64
```

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


[clang] [clang][DebugInfo] Revert to printing canonical typenames for template aliases (PR #110767)

2024-10-01 Thread Michael Buch via cfe-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/110767
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][DebugInfo] Revert to printing canonical typenames for template aliases (PR #110767)

2024-10-01 Thread Michael Buch via cfe-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/110767
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Jan Hendrik Farr via cfe-commits

Cydox wrote:

No worries

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


[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-01 Thread Nico Weber via cfe-commits

nico wrote:

Looks like this breaks check-clang: http://45.33.8.238/linux/149333/step_6.txt

Please take a look and revert for now if it takes a while to fix.

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


[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-01 Thread Tex Riddell via cfe-commits

tex3d wrote:

@francisvm 
This changed diagnostics, but didn't update all the affected tests.

See: https://github.com/llvm/llvm-project/pull/110187#issuecomment-2387260975

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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v5 (PR #108636)

2024-10-01 Thread via cfe-commits


@@ -522,6 +526,28 @@ let Predicates = [BPFNoALU32] in {
 }
 def STD : STOREi64;
 
+class relaxed_store
+  : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+  let IsAtomic = 1;
+  let IsAtomicOrderingReleaseOrStronger = 0;
+}
+
+class releasing_store
+  : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+  let IsAtomic = 1;
+  let IsAtomicOrderingRelease = 1;
+}

yonghong-song wrote:

Okay, I see. It is interesting that arm64 generates the same insn with release 
and seq_cst. In my thinking, we should just support __ATOMIC_ACQUIRE and 
__ATOMIC_RELEASE since currently with __ATOMIC_RELAXED, e.g. 
__atomic_load_n(ptr, __ATOMIC_RELAXED), the actually generated code should be 
'*ptr'. Is my interpretation correct or  __atomic_load_n(ptr, __ATOMIC_RELAXED) 
could have semantics beyond '*ptr'?


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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread via cfe-commits


@@ -108,6 +108,7 @@ namespace MultilevelSpecialization {
   template<> template
 void B::f(int i, int (&arr1)[a], int (&arr2)[b]) {}
 // since-cxx11-error@-1 {{out-of-line definition of 'f' does not match any 
declaration in 'cwg2233::MultilevelSpecialization::B'}}
+// expected-note@-6 {{defined here}}

c8ef wrote:

Done. The current test cases now use bookmarks to pinpoint class declarations.

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-01 Thread via cfe-commits

c8ef wrote:

> Please also add a note in the `clang/docs/ReleaseNotes.rst`

Done.

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


[clang] [llvm] [clang][llvm][SPIR-V] Explicitly encode native integer widths for SPIR-V (PR #110695)

2024-10-01 Thread Michal Paszkowski via cfe-commits


@@ -1,56 +0,0 @@
-; This test aims to check ability to support "Arithmetic with Overflow" 
intrinsics

michalpaszkowski wrote:

@AlexVlx I am not sure I follow the reasoning here. The idea behind those 
various tests in `/SPIRV/optimizations/` (including this one) is to ensure the 
backend can accept any IR. Either coming from the standard -O3 or some custom 
pipeline.

I do agree that we should not expect specific optimizations (or even more sets 
of optimizations) to do specific things when writing a test for an independent 
component. Hence, after some thinking, I believe the test could be improved by 
already containing a specific pattern that would be coming from the 
optimization. However, by the same principle, we should not expect that the 
issue will be "optimized away" by another optimization.

I would also oppose removing existing test cases. Any improvements, 
strengthening, or necessary changes are (of course) desirable.

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


[clang] [Clang][TableGen] Change NeonEmitter to use const Record * (PR #110597)

2024-10-01 Thread Kazu Hirata via cfe-commits


@@ -1161,11 +1161,9 @@ void SVEEmitter::createIntrinsic(
   uint64_t Merge = R->getValueAsInt("Merge");
   StringRef MergeSuffix = R->getValueAsString("MergeSuffix");
   uint64_t MemEltType = R->getValueAsInt("MemEltType");
-  std::vector FlagsList = R->getValueAsListOfDefs("Flags");
-  std::vector ImmCheckList = R->getValueAsListOfDefs("ImmChecks");
 
   int64_t Flags = 0;
-  for (auto FlagRec : FlagsList)
+  for (auto FlagRec : R->getValueAsListOfConstDefs("Flags"))

kazutakahirata wrote:

In `NeonEmitter.cpp`, you are replacing `const auto *` with `const Record *`.  
You might want to be consistent here with:

```suggestion
  for (const Record *FlagRec : R->getValueAsListOfConstDefs("Flags"))
```

The LLVM coding conventions are not very prescriptive regarding `auto`, so I 
tend to use the actual type name if it's short.

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


[clang] 5831eed - [Clang][TableGen] Change Opcodes Emitter to use const Record * (#110588)

2024-10-01 Thread via cfe-commits

Author: Rahul Joshi
Date: 2024-10-01T06:52:48-07:00
New Revision: 5831eed8d038951eee0f9379de001a55ce352eb0

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

LOG: [Clang][TableGen] Change Opcodes Emitter to use const Record * (#110588)

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089

Added: 


Modified: 
clang/utils/TableGen/ClangOpcodesEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangOpcodesEmitter.cpp 
b/clang/utils/TableGen/ClangOpcodesEmitter.cpp
index a18220fe23c417..94c361c7d544f5 100644
--- a/clang/utils/TableGen/ClangOpcodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpcodesEmitter.cpp
@@ -69,7 +69,7 @@ void Enumerate(const Record *R, StringRef N,
 
 if (const auto *TypeClass = dyn_cast(Types->getElement(I))) {
   for (const auto *Type :
-   TypeClass->getDef()->getValueAsListOfDefs("Types")) {
+   TypeClass->getDef()->getValueAsListOfConstDefs("Types")) {
 TypePath.push_back(Type);
 Rec(I + 1, ID + Type->getName());
 TypePath.pop_back();
@@ -117,7 +117,7 @@ void ClangOpcodesEmitter::EmitInterp(raw_ostream &OS, 
StringRef N,
 [this, R, &OS, &N](ArrayRef TS, const Twine &ID) {
   bool CanReturn = R->getValueAsBit("CanReturn");
   bool ChangesPC = R->getValueAsBit("ChangesPC");
-  const auto &Args = R->getValueAsListOfDefs("Args");
+  const auto &Args = R->getValueAsListOfConstDefs("Args");
 
   OS << "case OP_" << ID << ": {\n";
 
@@ -176,7 +176,7 @@ void ClangOpcodesEmitter::EmitDisasm(raw_ostream &OS, 
StringRef N,
 OS << "  PrintName(\"" << ID << "\");\n";
 OS << "  OS << \"\\t\"";
 
-for (const auto *Arg : R->getValueAsListOfDefs("Args")) {
+for (const auto *Arg : R->getValueAsListOfConstDefs("Args")) {
   OS << " << ReadArg<" << Arg->getValueAsString("Name") << ">(P, PC)";
   OS << " << \" \"";
 }
@@ -194,7 +194,7 @@ void ClangOpcodesEmitter::EmitEmitter(raw_ostream &OS, 
StringRef N,
 
   OS << "#ifdef GET_LINK_IMPL\n";
   Enumerate(R, N, [R, &OS](ArrayRef, const Twine &ID) {
-const auto &Args = R->getValueAsListOfDefs("Args");
+const auto &Args = R->getValueAsListOfConstDefs("Args");
 
 // Emit the list of arguments.
 OS << "bool ByteCodeEmitter::emit" << ID << "(";
@@ -227,7 +227,7 @@ void ClangOpcodesEmitter::EmitEmitter(raw_ostream &OS, 
StringRef N,
 void ClangOpcodesEmitter::EmitProto(raw_ostream &OS, StringRef N,
 const Record *R) {
   OS << "#if defined(GET_EVAL_PROTO) || defined(GET_LINK_PROTO)\n";
-  auto Args = R->getValueAsListOfDefs("Args");
+  auto Args = R->getValueAsListOfConstDefs("Args");
   Enumerate(R, N, [&OS, &Args](ArrayRef TS, const Twine &ID) {
 OS << "bool emit" << ID << "(";
 for (size_t I = 0, N = Args.size(); I < N; ++I) {
@@ -268,7 +268,7 @@ void ClangOpcodesEmitter::EmitGroup(raw_ostream &OS, 
StringRef N,
 return;
 
   const auto *Types = R->getValueAsListInit("Types");
-  const auto &Args = R->getValueAsListOfDefs("Args");
+  const auto &Args = R->getValueAsListOfConstDefs("Args");
 
   Twine EmitFuncName = "emit" + N;
 
@@ -333,7 +333,7 @@ void ClangOpcodesEmitter::EmitGroup(raw_ostream &OS, 
StringRef N,
 // Print a switch statement selecting T.
 if (auto *TypeClass = dyn_cast(Types->getElement(I))) {
   OS << "  switch (T" << I << ") {\n";
-  auto Cases = TypeClass->getDef()->getValueAsListOfDefs("Types");
+  auto Cases = TypeClass->getDef()->getValueAsListOfConstDefs("Types");
   for (auto *Case : Cases) {
 OS << "  case PT_" << Case->getName() << ":\n";
 TS.push_back(Case);
@@ -364,7 +364,7 @@ void ClangOpcodesEmitter::EmitEval(raw_ostream &OS, 
StringRef N,
   OS << "#ifdef GET_EVAL_IMPL\n";
   Enumerate(R, N,
 [this, R, &N, &OS](ArrayRef TS, const Twine &ID) {
-  auto Args = R->getValueAsListOfDefs("Args");
+  auto Args = R->getValueAsListOfConstDefs("Args");
 
   OS << "bool EvalEmitter::emit" << ID << "(";
   for (size_t I = 0, N = Args.size(); I < N; ++I) {



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


[clang-tools-extra] 7b8f7be - [clang-tidy] Add new check bugprone-tagged-union-member-count (#89925)

2024-10-01 Thread via cfe-commits

Author: tigbr
Date: 2024-10-01T13:24:32+02:00
New Revision: 7b8f7beadcf1814b1f1aa985d344ca17747531a7

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

LOG: [clang-tidy] Add new check bugprone-tagged-union-member-count (#89925)

This patch introduces a new check to find mismatches between the number
of data members in a union and the number enum values present in
variant-like structures.

Variant-like types can look something like this:

```c++
struct variant {
enum {
tag1,
tag2,
} kind;
union {
int i;
char c;
} data;
};
```

The kind data member of the variant is supposed to tell which data
member of the union is valid, however if there are fewer enum values
than union members, then it is likely a mistake.

The opposite is not that obvious, because it might be fine to have more
enum values than union data members, but for the time being I am curious
how many real bugs can be caught if we give a warning regardless.

This patch also contains a heuristic where we try to guess whether the
last enum constant is actually supposed to be a tag value for the
variant or whether it is just holding how many enum constants have been
created.

Patch by Gábor Tóthvári!

Added: 
clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-counting-enum-heuristic-bad-config.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-counting-enum-heuristic-is-disabled.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-counting-enum-heuristic-is-enabled.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-counting-enum-prefixes-and-suffixes.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-counting-enum-prefixes.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-counting-enum-suffixes.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-strictmode-is-disabled.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-strictmode-is-enabled.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.c

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.m

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.mm

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d17..642f025359b1d1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -78,6 +78,7 @@
 #include "SuspiciousStringviewDataUsageCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "SwitchMissingDefaultCaseCheck.h"
+#include "TaggedUnionMemberCountCheck.h"
 #include "TerminatingContinueCheck.h"
 #include "ThrowKeywordMissingCheck.h"
 #include "TooSmallLoopVariableCheck.h"
@@ -229,6 +230,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-suspicious-stringview-data-usage");
 CheckFactories.registerCheck(
 "bugprone-swapped-arguments");
+CheckFactories.registerCheck(
+"bugprone-tagged-union-member-count");
 CheckFactories.registerCheck(
 "bugprone-terminating-continue");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac58..9f7ecb9623c539 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -73,6 +73,7 @@ add_clang_library(clangTidyBugproneModule
   SuspiciousSemicolonCheck.cpp
   SuspiciousStringCompareCheck.cpp
   SwappedArgumentsCheck.cpp
+  TaggedUnionMemberCountCheck.cpp
   TerminatingContinueCheck.cpp
   ThrowKeywordMissingCheck.cpp
   TooSmallLoopVariableCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
new file mode 100644
index 00.

[clang] b8b036a - [HLSL] Treat `main` as any other function (#110546)

2024-10-01 Thread via cfe-commits

Author: Chris B
Date: 2024-10-01T07:36:36-05:00
New Revision: b8b036a7fe5b6e7ec306e3b80367e22d157a492b

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

LOG: [HLSL] Treat `main` as any other function (#110546)

HLSL doesn't distinguish `main` from any other function. It does treat
entry points special, but they're not required to be called `main` so we
have a different attribute annotation to mark them.

At the moment this change really just changes the mangling of functions
named `main` in the Itanium mangling.

Fixes #110517

-

Co-authored-by: Farzon Lotfi <1802579+farz...@users.noreply.github.com>

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl
clang/test/Options/enable_16bit_types_validation_spirv.hlsl

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index a14b1b33d35efc..84ef9f74582ef6 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3302,6 +3302,7 @@ bool FunctionDecl::isImmediateFunction() const {
 
 bool FunctionDecl::isMain() const {
   return isNamed(this, "main") && !getLangOpts().Freestanding &&
+ !getLangOpts().HLSL &&
  (getDeclContext()->getRedeclContext()->isTranslationUnit() ||
   isExternC());
 }

diff  --git a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl 
b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl
index 9481b0d60a2723..6b053dc6add1f2 100644
--- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_do_while.hlsl
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | 
FileCheck %s
 
-// CHECK: define spir_func void @main() [[A0:#[0-9]+]] {
+// CHECK: define spir_func void @{{.*main.*}}() [[A0:#[0-9]+]] {
 void main() {
 // CHECK: entry:
 // CHECK:   %[[CT_ENTRY:[0-9]+]] = call token 
@llvm.experimental.convergence.entry()

diff  --git a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl 
b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
index aeb7a8369f4034..aad8836db1062b 100644
--- a/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
+++ b/clang/test/Options/enable_16bit_types_validation_spirv.hlsl
@@ -4,7 +4,7 @@
 // SPIRV: error: '-fnative-half-type' option requires target HLSL Version >= 
2018, but HLSL Version is 'hlsl2016'
 
 // valid: "spirv-unknown-vulkan-library"
-// valid: define spir_func void @main() #0 {
+// valid: define spir_func void @{{.*main.*}}() #0 {
 
 [numthreads(1,1,1)]
 void main()



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


[clang] e96f778 - [clang][x86] Fix bad merge in #110581

2024-10-01 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2024-10-01T11:21:22+01:00
New Revision: e96f7788f5176dcf39c4eb53e4146f1e791adf83

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

LOG: [clang][x86] Fix bad merge in #110581

Added: 


Modified: 
clang/lib/Headers/bmiintrin.h

Removed: 




diff  --git a/clang/lib/Headers/bmiintrin.h b/clang/lib/Headers/bmiintrin.h
index c7ce96096d9714..673f043ccfb307 100644
--- a/clang/lib/Headers/bmiintrin.h
+++ b/clang/lib/Headers/bmiintrin.h
@@ -172,7 +172,6 @@ _mm_tzcnt_64(unsigned long long __X)
 #if defined(__cplusplus) && (__cplusplus >= 201103L)
 #define __DEFAULT_FN_ATTRS 
\
   __attribute__((__always_inline__, __nodebug__, __target__("bmi"))) constexpr
-constexpr
 #else
 #define __DEFAULT_FN_ATTRS 
\
   __attribute__((__always_inline__, __nodebug__, __target__("bmi")))



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


[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-01 Thread David Sherwood via cfe-commits


@@ -4072,6 +4078,30 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, 
CallBase *CI, Function *F,
   return Rep;
 }
 
+static Value *upgradeAArch64IntrinsicCall(StringRef Name, CallBase *CI,
+  Function *F, IRBuilder<> &Builder) {
+  Intrinsic::ID NewID =
+  StringSwitch(Name)
+  .Case("sve.fcvt.bf16f32", Intrinsic::aarch64_sve_fcvt_bf16f32_v2)
+  .Case("sve.fcvtnt.bf16f32", Intrinsic::aarch64_sve_fcvtnt_bf16f32_v2)
+  .Default(Intrinsic::not_intrinsic);
+  if (NewID == Intrinsic::not_intrinsic)
+llvm_unreachable("Unhandled Intrinsic!");
+
+  SmallVector Args(CI->args());
+
+  // The original intrinsics incorrectly used a predicate based on the smallest
+  // element type rather than the largest.
+  Type *PredTy = ScalableVectorType::get(Builder.getInt1Ty(), 4);
+  Args[1] = Builder.CreateIntrinsic(Intrinsic::aarch64_sve_convert_to_svbool,

david-arm wrote:

Given we won't get any IR verification of the old intrinsic, is it worth 
asserting or reporting an error if the predicate isn't  here?

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


[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-01 Thread David Sherwood via cfe-commits


@@ -5553,6 +5553,14 @@ static SDValue getSVEPredicateBitCast(EVT VT, SDValue 
Op, SelectionDAG &DAG) {
   if (InVT == VT)
 return Op;
 
+  // Look through casts to  when their input has more lanes than
+  // VT. This will increase the chances of removing casts that introduce new
+  // lanes, which have to be explicitly zero'd.
+  if (Op.getOpcode() == ISD::INTRINSIC_WO_CHAIN &&
+  Op.getConstantOperandVal(0) == Intrinsic::aarch64_sve_convert_to_svbool 
&&

david-arm wrote:

Is this something that should have been caught by the SVEIntrinsicOpts pass?

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


[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-01 Thread David Sherwood via cfe-commits


@@ -1003,6 +998,13 @@ defm SVFCVT_F32_F64   : SInstCvtMXZ<"svcvt_f32[_f64]", 
"MMPd", "MPd", "d", "aarc
 defm SVFCVT_F64_F16   : SInstCvtMXZ<"svcvt_f64[_f16]", "ddPO", "dPO", "d", 
"aarch64_sve_fcvt_f64f16">;
 defm SVFCVT_F64_F32   : SInstCvtMXZ<"svcvt_f64[_f32]", "ddPM", "dPM", "d", 
"aarch64_sve_fcvt_f64f32">;
 
+let SVETargetGuard = "sve,bf16", SMETargetGuard = "sme,bf16" in {
+defm SVCVT_BF16_F32 : SInstCvtMXZ<"svcvt_bf16[_f32]", "$$Pd", "$Pd", "f", 
"aarch64_sve_fcvt_bf16f32_v2">;
+
+def SVCVTNT_BF16: SInst<"svcvtnt_bf16[_f32]", "$$Pd", "f", MergeOp1, 
"aarch64_sve_fcvtnt_bf16f32_v2", [IsOverloadNone, VerifyRuntimeMode]>;

david-arm wrote:

Perhaps this should be `SVCVTNT_BF16_F32` for consistency with `SVCVT_BF16_F32` 
and also because it does lower to the intrinsic `aarch64_sve_fcvtnt_bf16f32_v2`?

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


[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-01 Thread David Sherwood via cfe-commits


@@ -5553,6 +5553,14 @@ static SDValue getSVEPredicateBitCast(EVT VT, SDValue 
Op, SelectionDAG &DAG) {
   if (InVT == VT)
 return Op;
 
+  // Look through casts to  when their input has more lanes than

david-arm wrote:

Perhaps better written as `casts to ` in case it's confusing?

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


[clang] [clang][bytecode] Protect ia32_{lzcnt,tzcnt} against non-integers (PR #110699)

2024-10-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

These are also called for vectors.

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


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+8) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index ebc800623f0d48..72c94e6fad3e0d 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1205,6 +1205,10 @@ static bool interp__builtin_ia32_lzcnt(InterpState &S, 
CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
+  QualType CallType = Call->getType();
+  if (!CallType->isIntegerType())
+return false;
+
   APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
   pushInteger(S, Val.countLeadingZeros(), Call->getType());
   return true;
@@ -1214,6 +1218,10 @@ static bool interp__builtin_ia32_tzcnt(InterpState &S, 
CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
+  QualType CallType = Call->getType();
+  if (!CallType->isIntegerType())
+return false;
+
   APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
   pushInteger(S, Val.countTrailingZeros(), Call->getType());
   return true;

``




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


[clang] [llvm] [clang][llvm][SPIR-V] Explicitly encode native integer widths for SPIR-V (PR #110695)

2024-10-01 Thread Alex Voicu via cfe-commits


@@ -1,56 +0,0 @@
-; This test aims to check ability to support "Arithmetic with Overflow" 
intrinsics

AlexVlx wrote:

This relies on `CodeGenPrepare::combineToUSubWithOverflow` firing, however when 
encoding the int sizes we can do loop strength reduction before, which is 
preferable, but also means one no longer gets the overflow intrinsics inserted, 
hence the test is spurious. I think you mentioned elsewhere that it's risque to 
rely on specific optimisations, and since the correct lowering of the overflow 
intrinsics is already covered, this seems spurious, hence the removal.

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


[clang] [clang][bytecode] Protect ia32_{lzcnt,tzcnt} against non-integers (PR #110699)

2024-10-01 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/110699

These are also called for vectors.

>From 4c7c6d3707e533d8300a622be6e02bf21b07e46c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 1 Oct 2024 18:39:33 +0200
Subject: [PATCH] [clang][bytecode] Protect ia32_{lzcnt,tzcnt} against
 non-integers

These are also called for vectors.
---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index ebc800623f0d48..72c94e6fad3e0d 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1205,6 +1205,10 @@ static bool interp__builtin_ia32_lzcnt(InterpState &S, 
CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
+  QualType CallType = Call->getType();
+  if (!CallType->isIntegerType())
+return false;
+
   APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
   pushInteger(S, Val.countLeadingZeros(), Call->getType());
   return true;
@@ -1214,6 +1218,10 @@ static bool interp__builtin_ia32_tzcnt(InterpState &S, 
CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
+  QualType CallType = Call->getType();
+  if (!CallType->isIntegerType())
+return false;
+
   APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
   pushInteger(S, Val.countTrailingZeros(), Call->getType());
   return true;

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


[clang] [clang-tools-extra] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)

2024-10-01 Thread Зишан Мирза via cfe-commits

https://github.com/zimirza updated 
https://github.com/llvm/llvm-project/pull/110366

From 4fb69942effb3cf34d07f33a14a95757b6ca5ee0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Sat, 28 Sep 2024 17:05:42 +0200
Subject: [PATCH 01/31] [clang-tidy] add `ctime` and `localtime` to
 `clang-tidy`

Closes #107445
---
 clang/docs/tools/clang-formatted-files.txt   | 8 
 .../StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc | 6 ++
 clang/test/Analysis/cert/env34-c.c   | 9 -
 5 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 67ff085144f4de..5223ca82a5b575 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -3058,6 +3058,14 @@ libc/src/threads/linux/thrd_join.cpp
 libc/src/threads/linux/Thread.h
 libc/src/time/asctime.cpp
 libc/src/time/asctime.h
+libc/src/time/ctime.cpp
+libc/src/time/ctime.h
+libc/src/time/ctime_r.cpp
+libc/src/time/ctime_r.h
+libc/src/time/localtime.cpp
+libc/src/time/localtime.h
+libc/src/time/localtime_r.cpp
+libc/src/time/localtime_r.h
 libc/src/time/asctime_r.cpp
 libc/src/time/asctime_r.h
 libc/src/time/gmtime.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
index fefe846b6911f7..9c34d3636c8488 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
@@ -76,6 +76,10 @@ class InvalidPtrChecker
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   {{CDM::CLibrary, {"asctime"}, 1},
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"ctime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"localtime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   };
 
   // The private members of this checker corresponding to commandline options
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672f..aca22f869b5291 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -220,6 +220,10 @@ SYMBOL(and, None, )
 SYMBOL(and_eq, None, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime_s, None, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime_s, None, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime_s, None, )
 SYMBOL(asin, None, )
 SYMBOL(asinf, None, )
 SYMBOL(asinh, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index b46bd2e4d7a4b5..8e3471e2fc5729 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -617,6 +617,12 @@ SYMBOL(as_writable_bytes, std::, )
 SYMBOL(asctime, std::, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime, None, )
+SYMBOL(ctime, std::, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime, None, )
+SYMBOL(localtime, std::, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime, None, )
 SYMBOL(asin, std::, )
 SYMBOL(asin, None, )
 SYMBOL(asin, None, )
diff --git a/clang/test/Analysis/cert/env34-c.c 
b/clang/test/Analysis/cert/env34-c.c
index d307f0d8f4bb01..66ba0be4a67bba 100644
--- a/clang/test/Analysis/cert/env34-c.c
+++ b/clang/test/Analysis/cert/env34-c.c
@@ -15,7 +15,14 @@ lconv *localeconv(void);
 
 typedef struct {
 } tm;
-char *asctime(const tm *timeptr);
+char *asctime(const tm *timeptr)
+;
+typedef struct {
+} tm;
+char *ctime(const tm *timeptr);
+typedef struct {
+} tm;
+struct tm *localtime(struct tm *tm);
 
 int strcmp(const char*, const char*);
 extern void foo(char *e);

From 5be47623b21694a8f98eb6e5de0e536fdbb4ca0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Sat, 28 Sep 2024 17:20:00 +0200
Subject: [PATCH 02/31] [clang-tidy] add times to clang-tidy

add `ctime` and `localtime` to unsafe functions check function
---
 clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index 604a7cac0e4903..f058e5ae40680f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -50,6 +50,8 @@ static StringRef getReplacementFor(StringRef FunctionName,
 StringRef AnnexKReplacementFunction =
 StringSwitch(FunctionName)
 .Cases("asctime

[clang] [llvm] [clang][llvm][SPIR-V] Explicitly encode native integer widths for SPIR-V (PR #110695)

2024-10-01 Thread Matt Arsenault via cfe-commits


@@ -1,56 +0,0 @@
-; This test aims to check ability to support "Arithmetic with Overflow" 
intrinsics

arsenm wrote:

This one is testing codegenprepare as part of the normal codegen pipeline, so 
this one is fine. The other case was a full optimization pipeline + codegen, 
which are more far removed 

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


[clang] [Clang][TableGen] Change NeonEmitter to use const Record * (PR #110597)

2024-10-01 Thread Rahul Joshi via cfe-commits


@@ -1161,11 +1161,9 @@ void SVEEmitter::createIntrinsic(
   uint64_t Merge = R->getValueAsInt("Merge");
   StringRef MergeSuffix = R->getValueAsString("MergeSuffix");
   uint64_t MemEltType = R->getValueAsInt("MemEltType");
-  std::vector FlagsList = R->getValueAsListOfDefs("Flags");
-  std::vector ImmCheckList = R->getValueAsListOfDefs("ImmChecks");
 
   int64_t Flags = 0;
-  for (auto FlagRec : FlagsList)
+  for (auto FlagRec : R->getValueAsListOfConstDefs("Flags"))

jurahul wrote:

Agreed, and done.

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


[clang] [Clang][TableGen] Change NeonEmitter to use const Record * (PR #110597)

2024-10-01 Thread Rahul Joshi via cfe-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/110597

>From 7d9e44f13483c4a801ec7895aa231e4b7e11e223 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Mon, 30 Sep 2024 15:55:03 -0700
Subject: [PATCH] [Clang][TableGen] Change NeonEmitter to use const Record *

---
 clang/utils/TableGen/NeonEmitter.cpp |  3 +--
 clang/utils/TableGen/SveEmitter.cpp  | 12 +---
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 202573e2ac740e..d4b42360e7fd32 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -410,8 +410,7 @@ class Intrinsic {
 }
 
 int ArgIdx, Kind, TypeArgIdx;
-std::vector ImmCheckList = R->getValueAsListOfDefs("ImmChecks");
-for (const auto *I : ImmCheckList) {
+for (const Record *I : R->getValueAsListOfDefs("ImmChecks")) {
   unsigned EltSizeInBits = 0, VecSizeInBits = 0;
 
   ArgIdx = I->getValueAsInt("ImmArgIdx");
diff --git a/clang/utils/TableGen/SveEmitter.cpp 
b/clang/utils/TableGen/SveEmitter.cpp
index 2f9747e7de3de2..dc035ab226e288 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -1161,11 +1161,9 @@ void SVEEmitter::createIntrinsic(
   uint64_t Merge = R->getValueAsInt("Merge");
   StringRef MergeSuffix = R->getValueAsString("MergeSuffix");
   uint64_t MemEltType = R->getValueAsInt("MemEltType");
-  std::vector FlagsList = R->getValueAsListOfDefs("Flags");
-  std::vector ImmCheckList = R->getValueAsListOfDefs("ImmChecks");
 
   int64_t Flags = 0;
-  for (auto FlagRec : FlagsList)
+  for (const record *FlagRec : R->getValueAsListOfConstDefs("Flags"))
 Flags |= FlagRec->getValueAsInt("Value");
 
   // Create a dummy TypeSpec for non-overloaded builtins.
@@ -1195,10 +1193,10 @@ void SVEEmitter::createIntrinsic(
   for (auto TS : TypeSpecs) {
 // Collate a list of range/option checks for the immediates.
 SmallVector ImmChecks;
-for (auto *R : ImmCheckList) {
-  int64_t ArgIdx = R->getValueAsInt("ImmArgIdx");
-  int64_t EltSizeArgIdx = R->getValueAsInt("TypeContextArgIdx");
-  int64_t Kind = R->getValueAsDef("Kind")->getValueAsInt("Value");
+for (const Record *ImmR : R->getValueAsListOfConstDefs("ImmChecks")) {
+  int64_t ArgIdx = ImmR->getValueAsInt("ImmArgIdx");
+  int64_t EltSizeArgIdx = ImmR->getValueAsInt("TypeContextArgIdx");
+  int64_t Kind = ImmR->getValueAsDef("Kind")->getValueAsInt("Value");
   assert(ArgIdx >= 0 && Kind >= 0 &&
  "ImmArgIdx and Kind must be nonnegative");
 

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


  1   2   3   4   5   >