[clang] [llvm] Implement operand bundles for floating-point operations (PR #109798)

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

arsenm wrote:

> WRT eliminating the constrained intrinsics completely, I thought that operand 
> bundles could only be attached to function calls and not regular 
> instructions? If I'm wrong, we _still_ have a problem because there are so 
> many uses of the regular FP instructions that we can't be safe-by-default and 
> still use those instructions. We'd need to keep some kind of the constrained 
> intrinsics (or new intrinsics) that give us replacements for the regular FP 
> instructions.

Right, we would need to introduce new llvm.fadd etc. to carry bundles. If there 
are no bundles these could fold back to the regular instruction 

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


[clang] [clang] Allow `ConditionalOperator` fast-math flags to be overridden by `pragma float_control` (PR #105912)

2024-10-07 Thread John McCall via cfe-commits

rjmccall wrote:

Yeah, the conditional operator doesn't do any floating-path math itself.  If 
the first operand is a floating-point expression, we should always be modeling 
that with a float-to-boolean conversion, and the flags should go there.

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


[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread Richard Smith via cfe-commits

zygoloid wrote:

Specifically: we do perform address comparisons between these strings, so the 
address is significant. And we can have identical string content but different 
types:

- for types whose name involves anything with internal linkage
- for types with hidden visibility
- when loading a DSO using `RTLD_LOCAL`

so in a few cases allowing merging could be bad. Most of that only applies 
during dynamic linking. Do we have a guarantee that `unnamed_addr` is dropped 
before dynamic linking?

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


[clang] [llvm] [clang][LLVM Demangler] Add an assertion that validates that all mang… (PR #111391)

2024-10-07 Thread Erich Keane via cfe-commits


@@ -1967,6 +1967,10 @@ def fclang_abi_compat_EQ : Joined<["-"], 
"fclang-abi-compat=">, Group,
   MetaVarName<"">, Values<".,latest">,
   HelpText<"Attempt to match the ABI of Clang ">;
+def fno_demangling_failures: Flag<["-"], "fno-demangling-failures">, 
Group,

erichkeane wrote:

I don't recall how it works, but I think we want an on & off flag type, not 
just the off.

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


[clang] [llvm] [clang][LLVM Demangler] Add an assertion that validates that all mang… (PR #111391)

2024-10-07 Thread Erich Keane via cfe-commits

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


[clang] [llvm] [clang][LLVM Demangler] Add an assertion that validates that all mang… (PR #111391)

2024-10-07 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

Since this is being done as an assert, this is something that really only 
applies during debug mode.  I dont think this compiler flag makes sense because 
of it.

IMO, this should either be a preprocessor macro to enable (so it is a build 
config), or a diagnostic that happens all the time (perhaps whose default 
changes?).

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


[clang] [llvm] [clang][LLVM Demangler] Add an assertion that validates that all mang… (PR #111391)

2024-10-07 Thread Erich Keane via cfe-commits


@@ -462,6 +462,9 @@ ENUM_CODEGENOPT(ZeroCallUsedRegs, 
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
 /// non-deleting destructors. (No effect on Microsoft ABI.)
 CODEGENOPT(CtorDtorReturnThis, 1, 0)
 
+/// Whether to validate if a produced mangled name can be demangled with LLVM 
demangler.
+CODEGENOPT(NoDemanglingFailures, 1, 0)

erichkeane wrote:

This is probably inverted.

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


[clang] [clang] Fix std::tm etc. mangling on Solaris (PR #106353)

2024-10-07 Thread Rainer Orth via cfe-commits

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


[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread Richard Smith via cfe-commits

zygoloid wrote:

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-rtti and 
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#typeid in the ABI require 
the type name string to be globally unique, and some `std::type_info` 
implementations rely on that. You might be able to do this for some specific 
targets that choose a different ABI rule, but not in general.

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


[clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-07 Thread Abhina Sree via cfe-commits

abhina-sree wrote:

> https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/PPDirectives.cpp#L3964-L3990

Yes I think we still require specifying the Text/Binary parameter based on the 
context of where it is called.  I will look into adding the new virtual 
functions as an alternative solution

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


[libclc] [libclc] Update build instructions in readme (PR #111369)

2024-10-07 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/111369

The configure Python script was removed by
d6e0e6d255a7d54a3873b7a5d048eee00ef6bb6d / https://reviews.llvm.org/D69966.

The readme was never updated with the cmake way to do it. I couldn't find any 
dedicated buildbots for this so I'm making an educated guess. This is what 
built locally for me.

>From a2dd2330359ecd3c04e01b6f9121481e6784014a Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 7 Oct 2024 12:29:41 +
Subject: [PATCH] [libclc] Update build instructions in readme

The configure Python script was removed by
d6e0e6d255a7d54a3873b7a5d048eee00ef6bb6d / https://reviews.llvm.org/D69966.

The readme was never updated with the cmake way to do it.
I couldn't find any dedicated buildbots for this so I'm making
an educated guess. This is what built locally for me.
---
 libclc/README.TXT | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libclc/README.TXT b/libclc/README.TXT
index 57b5242b9bbecb..f64f0e05a742f2 100644
--- a/libclc/README.TXT
+++ b/libclc/README.TXT
@@ -23,29 +23,41 @@ generic implementations of most library requirements, 
allowing the target
 to override the generic implementation at the granularity of individual
 functions.
 
-libclc currently only supports the PTX target, but support for more
+libclc currently supports NVPTX, AMDGPU and SPIRV targets, but support for more
 targets is welcome.
 
-Compiling and installing with Make
---
+Compiling and installing
+
 
-$ ./configure.py --with-llvm-config=/path/to/llvm-config && make
-$ make install
+(in the following instructions you can use make or ninja)
 
-Note you can use the DESTDIR Makefile variable to do staged installs.
+For an in-tree build, Clang must also be built at the same time:
 
-$ make install DESTDIR=/path/for/staged/install
+$ cmake /llvm-project/llvm/CMakeLists.txt 
-DLLVM_ENABLE_PROJECTS="libclc;clang" \
+-DCMAKE_BUILD_TYPE=Release -G Ninja
+$ ninja
 
-Compiling and installing with Ninja

+Then install:
 
-$ ./configure.py -g ninja --with-llvm-config=/path/to/llvm-config && ninja
 $ ninja install
 
-Note you can use the DESTDIR environment variable to do staged installs.
+Note you can use the DESTDIR Makefile variable to do staged installs.
 
 $ DESTDIR=/path/for/staged/install ninja install
 
+To build against an existing LLVM build or install:
+
+$ cmake /llvm-project/libclc/CMakeLists.txt 
-DCMAKE_BUILD_TYPE=Release \
+  -G Ninja -DLLVM_DIR=$(/llvm-config --cmakedir)
+$ ninja
+
+Then install as before.
+
+In both cases, the LLVM used must include the targets you want libclc support 
for.
+AMDGPU and NVPTX are enabled in LLVM by default, but SPIRV must be enabled by
+passing `-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=SPIRV` to CMake when configuring
+LLVM.
+
 Website
 ---
 

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


[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-10-07 Thread via cfe-commits

https://github.com/ivanaivanovska updated 
https://github.com/llvm/llvm-project/pull/103039

>From 6d3e4470dfe21f8f3832a2d38b4c4327aa7422a3 Mon Sep 17 00:00:00 2001
From: Ivana Ivanovska 
Date: Tue, 13 Aug 2024 10:30:34 +
Subject: [PATCH 1/6] Added instant events and marking defered templated
 instantiation.

---
 clang/lib/Sema/SemaExpr.cpp   | 18 ++
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  | 17 +
 clang/unittests/Support/TimeProfilerTest.cpp  | 51 ++-
 llvm/include/llvm/Support/TimeProfiler.h  | 19 +-
 llvm/lib/Support/TimeProfiler.cpp | 64 +--
 5 files changed, 145 insertions(+), 24 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 95f53dfefbcc52..9e88fe5a94289d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -64,6 +65,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/SaveAndRestore.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/TypeSize.h"
 #include 
 
@@ -18046,6 +18048,22 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, 
FunctionDecl *Func,
 std::make_pair(Func, PointOfInstantiation));
 // Notify the consumer that a function was implicitly instantiated.
 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
+
+llvm::TimeTraceScope TimeScope(
+"DeferInstantiation",
+[&]() {
+  llvm::TimeTraceMetadata M;
+  llvm::raw_string_ostream OS(M.Detail);
+  Func->getNameForDiagnostic(OS, getPrintingPolicy(),
+ /*Qualified=*/true);
+  if (llvm::isTimeTraceVerbose()) {
+auto Loc = SourceMgr.getExpansionLoc(Func->getLocation());
+M.File = SourceMgr.getFilename(Loc);
+M.Line = SourceMgr.getExpansionLineNumber(Loc);
+  }
+  return M;
+},
+llvm::TimeTraceEventType::InstantEvent);
   }
 }
   } else {
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 0e064be2391838..191f46ed00b7cc 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4983,6 +4983,23 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
   Function->setInstantiationIsPending(true);
   PendingInstantiations.push_back(
 std::make_pair(Function, PointOfInstantiation));
+
+  llvm::TimeTraceScope TimeScope(
+  "DeferInstantiation",
+  [&]() {
+llvm::TimeTraceMetadata M;
+llvm::raw_string_ostream OS(M.Detail);
+Function->getNameForDiagnostic(OS, getPrintingPolicy(),
+   /*Qualified=*/true);
+if (llvm::isTimeTraceVerbose()) {
+  auto Loc = SourceMgr.getExpansionLoc(Function->getLocation());
+  M.File = SourceMgr.getFilename(Loc);
+  M.Line = SourceMgr.getExpansionLineNumber(Loc);
+}
+return M;
+  },
+  llvm::TimeTraceEventType::InstantEvent);
+
 } else if (TSK == TSK_ImplicitInstantiation) {
   if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
   !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc())) {
diff --git a/clang/unittests/Support/TimeProfilerTest.cpp 
b/clang/unittests/Support/TimeProfilerTest.cpp
index f53fe71d630bf5..ccda12e943dd73 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -238,13 +238,55 @@ Frontend (test.cc)
 buildTraceGraph(Json));
 }
 
+TEST(TimeProfilerTest, ClassTemplateInstantiations) {
+  std::string Code = R"(
+template
+struct S
+{
+  void foo() {}
+  void bar();
+};
+
+template struct S; // explicit instantiation of S
+
+void user() {
+  S a; // implicit instantiation of S
+  S* b;
+  b->foo(); // implicit instatiation of S and S::foo()
+}
+  )";
+
+  setupProfiler();
+  ASSERT_TRUE(compileFromString(Code, "-std=c++20", "test.cc"));
+  std::string Json = teardownProfiler();
+  ASSERT_EQ(R"(
+Frontend (test.cc)
+| ParseClass (S)
+| InstantiateClass (S, test.cc:9)
+| InstantiateFunction (S::foo, test.cc:5)
+| ParseDeclarationOrFunctionDefinition (test.cc:11:5)
+| | ParseFunctionDefinition (user)
+| | | InstantiateClass (S, test.cc:3)
+| | | InstantiateClass (S, test.cc:3)
+| | | DeferInstantiatio

[libclc] [libclc] Update build instructions in readme (PR #111369)

2024-10-07 Thread David Spickett via cfe-commits

DavidSpickett wrote:

One "andrew-podko" did request this get updated but that was in October 2020, 
so I expect they're not around anymore.

https://github.com/llvm/llvm-project/pull/111369
___
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-07 Thread via cfe-commits

vient wrote:

Will this be backported to 19.x afterwards?

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


[clang] [clang][analyzer] Introduce MutexModeling checker (PR #111381)

2024-10-07 Thread Balazs Benics via cfe-commits

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


[clang] [FMV][AArch64][NFC] Cleanup attribute metadata from test files. (PR #111386)

2024-10-07 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea created 
https://github.com/llvm/llvm-project/pull/111386

We have a dedicated test to check the target-features for FMV 
(clang/test/CodeGen/aarch64-fmv-dependencies.c) therefore I am removing the 
autogenerated checks from irrelevant tests since the noise is making it harder 
to review actual codegen changes.

>From 80a03753f0d626b94e0f8559fc217ed7908302e1 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Mon, 7 Oct 2024 15:32:05 +0100
Subject: [PATCH] [FMV][AArch64][NFC] Cleanup attribute metadata from test
 files.

We have a dedicated test to check the target-features for FMV
(clang/test/CodeGen/aarch64-fmv-dependencies.c) therefore I am
removing the autogenerated checks from irrelevant tests since
the noise is making it harder to review actual codegen changes.
---
 .../CodeGen/aarch64-mixed-target-attributes.c |  14 +-
 .../test/CodeGen/attr-target-clones-aarch64.c | 252 ++
 clang/test/CodeGen/attr-target-version.c  |  45 +---
 .../CodeGenCXX/attr-target-clones-aarch64.cpp |   7 +-
 clang/test/CodeGenCXX/attr-target-version.cpp |  15 +-
 clang/test/CodeGenCXX/fmv-namespace.cpp   |   7 +-
 6 files changed, 146 insertions(+), 194 deletions(-)

diff --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index d779abd395b5fb..f9c1ae5b75a724 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -v9.5a 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
 
@@ -255,18 +255,6 @@ __attribute__((target_version("jscvt"))) int 
default_def_with_version_decls(void
 // CHECK-NOFMV-NEXT:ret i32 0
 //
 //.
-// CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-v9.5a" }
-// CHECK: attributes #[[ATTR1]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR2]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+lse,-v9.5a" }
-// CHECK: attributes #[[ATTR4]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+neon,+rdm,-v9.5a" }
-// CHECK: attributes #[[ATTR5:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR6:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="-v9.5a" }
-// CHECK: attributes #[[ATTR7:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+lse,-v9.5a" }
-// CHECK: attributes #[[ATTR8:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" }
-//.
-// CHECK-NOFMV: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-fmv" }
-//.
 // CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 // CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 //.
diff --git a/clang/test/CodeGen/attr-target-clones-aarch64.c 
b/clang/test/CodeGen/attr-target-clones-aarch64.c
index 274e05de594b8e..292e544139e3ff 100644
--- a/clang/test/CodeGen/attr-target-clones-aarch64.c
+++ b/clang/test/CodeGen/attr-target-clones-aarch64.c
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-attributes --check-globals --include-generated-funcs
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +mte 
-target-feature +bti -emit-llvm -o - %s | FileChec

[clang] [FMV][AArch64][NFC] Cleanup attribute metadata from test files. (PR #111386)

2024-10-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alexandros Lamprineas (labrinea)


Changes

We have a dedicated test to check the target-features for FMV 
(clang/test/CodeGen/aarch64-fmv-dependencies.c) therefore I am removing the 
autogenerated checks from irrelevant tests since the noise is making it harder 
to review actual codegen changes.

---

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


6 Files Affected:

- (modified) clang/test/CodeGen/aarch64-mixed-target-attributes.c (+1-13) 
- (modified) clang/test/CodeGen/attr-target-clones-aarch64.c (+141-111) 
- (modified) clang/test/CodeGen/attr-target-version.c (+1-44) 
- (modified) clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp (+1-6) 
- (modified) clang/test/CodeGenCXX/attr-target-version.cpp (+1-14) 
- (modified) clang/test/CodeGenCXX/fmv-namespace.cpp (+1-6) 


``diff
diff --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index d779abd395b5fb..f9c1ae5b75a724 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -v9.5a 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
 
@@ -255,18 +255,6 @@ __attribute__((target_version("jscvt"))) int 
default_def_with_version_decls(void
 // CHECK-NOFMV-NEXT:ret i32 0
 //
 //.
-// CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-v9.5a" }
-// CHECK: attributes #[[ATTR1]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR2]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+lse,-v9.5a" }
-// CHECK: attributes #[[ATTR4]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+neon,+rdm,-v9.5a" }
-// CHECK: attributes #[[ATTR5:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR6:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="-v9.5a" }
-// CHECK: attributes #[[ATTR7:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+lse,-v9.5a" }
-// CHECK: attributes #[[ATTR8:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" }
-//.
-// CHECK-NOFMV: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-fmv" }
-//.
 // CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 // CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 //.
diff --git a/clang/test/CodeGen/attr-target-clones-aarch64.c 
b/clang/test/CodeGen/attr-target-clones-aarch64.c
index 274e05de594b8e..292e544139e3ff 100644
--- a/clang/test/CodeGen/attr-target-clones-aarch64.c
+++ b/clang/test/CodeGen/attr-target-clones-aarch64.c
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-attributes --check-globals --include-generated-funcs
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +mte 
-target-feature +bti -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-MTE-BTI
@@ -47,18 +47,20 @@ inline int __attribute__((target_clones("fp16", 
"sve2-bitperm+fcma", "default"))
 // CHECK-MTE-BTI: @ftc_inline3 = weak_odr ifunc i32 (), ptr 
@ftc_inline3.resolver
 //.
 // CHECK: Function Attrs: noinline nounwind optnone
-// CHECK-LABEL: @f

[clang] [FMV][AArch64][NFC] Cleanup attribute metadata from test files. (PR #111386)

2024-10-07 Thread Tomas Matheson via cfe-commits

https://github.com/tmatheson-arm approved this pull request.


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


[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

2024-10-07 Thread Sarah Spall via cfe-commits

spall wrote:

> It is not correct to limit firstbithigh to 32 bit integers. There are a 
> couple of reasons that might make one think that it is, but we do in fact 
> want/need to support int16 and int64 here.
> 
> 1. The [HLSL 
> docs](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/firstbithigh)
>  only mention integer. Unfortunately that's true for most of these functions, 
> as many of these docs were not updated as 64 and 16 bit types gained support 
> in the language.
> 
> 2. DXC's SPIR-V implementation doesn't handle 16- and 64-bit for these 
> functions. As noted in [Incorrect SPIR-V generated when `firstbithigh` is 
> used on a `uint64_t` 
> microsoft/DirectXShaderCompiler#4702](https://github.com/microsoft/DirectXShaderCompiler/issues/4702)
>  we decided not to implement those overloads in DXC, but should reconsider 
> this for clang.
> 
> 
> Despite all of this, DXC does indeed support 16- and 64-bit overloads, as 
> seen here: https://hlsl.godbolt.org/z/qbc17xz35
> 
> Note that the return type of the operation is not overloaded - all of the 
> overloads of this function return uint.

Why is the return type not overloaded? It is overloaded for countbits which is 
a similar function.

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


[clang] [clang][analyzer] Introduce MutexModeling checker (PR #111381)

2024-10-07 Thread Endre Fülöp via cfe-commits

https://github.com/gamesh411 updated 
https://github.com/llvm/llvm-project/pull/111381

From 4af2c63e4e65b1a8dd9947afdd09fe18362f5cfe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Endre=20F=C3=BCl=C3=B6p?= 
Date: Thu, 3 Oct 2024 18:24:17 +0200
Subject: [PATCH 1/2] [clang][analyzer] Introduce MutexModeling checker

This patch introduces the basic structure for the MutexModeling checker.
It adds the checker definition, creates the MutexModeling.cpp file,
supporting header files, and updates the necessary build files. The
MutexModeling checker will be responsible for modeling mutexlock and
unlock events, removing duplication in BlockInCriticalSectionChecker and
PthreadLockChecker.
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |   5 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|   1 +
 .../StaticAnalyzer/Checkers/MutexModeling.cpp | 773 ++
 .../Checkers/MutexModeling/MutexModelingAPI.h | 244 ++
 .../MutexModeling/MutexModelingDomain.h   | 126 +++
 .../Checkers/MutexModeling/MutexModelingGDM.h | 169 
 .../MutexModeling/MutexRegionExtractor.h  | 139 
 7 files changed, 1457 insertions(+)
 create mode 100644 clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDomain.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingGDM.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexRegionExtractor.h

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 349040c15eeb83..fb31011dde84ff 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -219,6 +219,11 @@ def DereferenceChecker : Checker<"NullDereference">,
   ]>,
   Documentation;
 
+def MutexModeling : Checker<"MutexModeling">,
+  HelpText<"Model mutexes lock and unlock events">,
+  Documentation,
+  Hidden;
+
 def NonNullParamChecker : Checker<"NonNullParamChecker">,
   HelpText<"Check for null pointers passed as arguments to a function whose "
"arguments are references or marked with the 'nonnull' attribute">,
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 6da3665ab9a4df..c3987ba76529db 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -68,6 +68,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   MmapWriteExecChecker.cpp
   MIGChecker.cpp
   MoveChecker.cpp
+  MutexModeling.cpp
   MPI-Checker/MPIBugReporter.cpp
   MPI-Checker/MPIChecker.cpp
   MPI-Checker/MPIFunctionClassifier.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
new file mode 100644
index 00..f0e13c5c95e432
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
@@ -0,0 +1,773 @@
+//===--- MutexModeling.cpp - Modeling of mutexes 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Defines modeling checker for tracking mutex states.
+//
+//===--===//
+
+#include "MutexModeling/MutexModelingAPI.h"
+#include "MutexModeling/MutexModelingDomain.h"
+#include "MutexModeling/MutexRegionExtractor.h"
+
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include 
+
+using namespace clang;
+using namespace ento;
+using namespace mutex_modeling;
+
+namespace {
+
+// When a lock is destroyed, in some semantics(like PthreadSemantics) we are 
not
+// sure if the destroy call has succeeded or failed, and the lock enters one of
+// the 'possibly destroyed' state. There is a short time frame for the
+// programmer to check the return value to see if the lock was successfully
+// destroyed. Before we model the next operation over that lock, we call this
+// function to see if the return value was checked by now and set the lock 
state
+// - either to destroyed state or back to its previous state.
+
+// In PthreadSemantics, pthread_mutex_destroy() returns zero if the lock is
+// successfully destroyed and it returns a non-zero value otherwise.
+ProgramStateRef resolvePossiblyDestroyedMutex(ProgramStateRef State,
+  const MemRegion *LockReg,
+  

[clang-tools-extra] [clang-tools-extra] Fix add_clang_library usage (PR #109321)

2024-10-07 Thread Vassil Vassilev via cfe-commits

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


[clang-tools-extra] [clang-tools-extra] Fix add_clang_library usage (PR #109321)

2024-10-07 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/109321

>From 6dd09dc7c40780615ce662676188a1005d4d72cc Mon Sep 17 00:00:00 2001
From: Thomas Fransham 
Date: Thu, 19 Sep 2024 16:53:20 +0100
Subject: [PATCH] [clang-tools-extra] Fix add_clang_library usage

If a add_clang_library call doesn't specify building as STATIC or SHARED 
library they are
implicitly added to the list static libraries that is linked in to clang-cpp 
shared library.
Because the clang-tools-extra libraries targets were declared after clang-cpp 
they
by luck never got linked to clang-cpp.
This change is required for clang symbol visibility macros on windows to work
correctly for clang tools since we need to distinguish if a target being built
will be importing or exporting clang symbols from the clang-cpp DLL.
---
 clang-tools-extra/clang-apply-replacements/CMakeLists.txt | 2 +-
 clang-tools-extra/clang-change-namespace/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-doc/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-include-fixer/CMakeLists.txt  | 2 +-
 .../clang-include-fixer/find-all-symbols/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-include-fixer/plugin/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-move/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-query/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-reorder-fields/CMakeLists.txt | 2 +-
 clang-tools-extra/clang-tidy/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/abseil/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-tidy/altera/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-tidy/android/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/boost/CMakeLists.txt | 2 +-
 clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-tidy/cert/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt | 2 +-
 clang-tools-extra/clang-tidy/darwin/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/google/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt | 2 +-
 clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/llvm/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-tidy/misc/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-tidy/modernize/CMakeLists.txt | 2 +-
 clang-tools-extra/clang-tidy/mpi/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/objc/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-tidy/openmp/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-tidy/performance/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/plugin/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-tidy/portability/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/readability/CMakeLists.txt   | 2 +-
 clang-tools-extra/clang-tidy/tool/CMakeLists.txt  | 2 +-
 clang-tools-extra/clang-tidy/utils/CMakeLists.txt | 2 +-
 clang-tools-extra/clang-tidy/zircon/CMakeLists.txt| 2 +-
 clang-tools-extra/clangd/CMakeLists.txt   | 2 +-
 clang-tools-extra/clangd/index/remote/CMakeLists.txt  | 2 +-
 .../clangd/index/remote/marshalling/CMakeLists.txt| 2 +-
 .../clangd/index/remote/unimplemented/CMakeLists.txt  | 2 +-
 clang-tools-extra/clangd/support/CMakeLists.txt   | 2 +-
 clang-tools-extra/clangd/tool/CMakeLists.txt  | 2 +-
 clang-tools-extra/clangd/xpc/CMakeLists.txt   | 4 ++--
 clang-tools-extra/include-cleaner/lib/CMakeLists.txt  | 2 +-
 45 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/clang-tools-extra/clang-apply-replacements/CMakeLists.txt 
b/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
index 93198ccbfc406f..551ded903e88a6 100644
--- a/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
+++ b/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-add_clang_library(clangApplyReplacements
+add_clang_library(clangApplyReplacements STATIC
   lib/Tooling/ApplyReplacements.cpp
 
   DEPENDS
diff --git a/clang-tools-extra/clang-change-namespace/CMakeLists.txt 
b/clang-tools-extra/clang-change-namespace/CMakeLists.txt
index ded91edb8e34f0..62289ad031cfd6 100644
--- a/clang-tools-extra/clang-change-namespace/CMakeLists.txt
+++ b/clang-tools-extra/clang-change-namespace/CMakeLists.txt
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-add_clang_library(clangChangeNamespace
+add_clang_library(clangChangeNamespace STATIC
   ChangeNamespace.c

[clang] [clang] Code owners -> Maintainers transition (PR #108997)

2024-10-07 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/108997

>From 10f74046b87f67a6efba1ee30806e73eea14007e Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Mon, 16 Sep 2024 08:59:45 -0400
Subject: [PATCH 1/2] [clang] Code owners -> Maintainers transition

This is the initial transition from using "code owners" to using
"maintainers". It presumes that every current code owner is willing to
continue as a maintainer.
---
 clang/{CodeOwners.rst => Maintainers.rst} | 32 +++
 clang/docs/CMakeLists.txt |  2 +-
 clang/docs/CodeOwners.rst |  1 -
 clang/docs/Maintainers.rst|  1 +
 clang/docs/index.rst  |  2 +-
 5 files changed, 19 insertions(+), 19 deletions(-)
 rename clang/{CodeOwners.rst => Maintainers.rst} (92%)
 delete mode 100644 clang/docs/CodeOwners.rst
 create mode 100644 clang/docs/Maintainers.rst

diff --git a/clang/CodeOwners.rst b/clang/Maintainers.rst
similarity index 92%
rename from clang/CodeOwners.rst
rename to clang/Maintainers.rst
index 2ae04c129eb765..766161dbbfc614 100644
--- a/clang/CodeOwners.rst
+++ b/clang/Maintainers.rst
@@ -1,30 +1,30 @@
 =
-Clang Code Owners
+Clang Maintainers
 =
 
 This file is a list of the
-`code owners `_ for
+`maintainers `_ for
 Clang.
 
 .. contents::
:depth: 2
:local:
 
-Current Code Owners
-===
-The following people are the active code owners for the project. Please reach
+Active Maintainers
+==
+The following people are the active maintainers for the project. Please reach
 out to them for code reviews, questions about their area of expertise, or other
 assistance.
 
-All parts of Clang not covered by someone else
---
+Lead Maintainer
+---
 | Aaron Ballman
 | aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman 
(GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
 
 
 Contained Components
 
-These code owners are responsible for particular high-level components within
+These maintainers are responsible for particular high-level components within
 Clang that are typically contained to one area of the compiler.
 
 AST matchers
@@ -125,7 +125,7 @@ Driver parts not covered by someone else
 
 Tools
 -
-These code owners are responsible for user-facing tools under the Clang
+These maintainers are responsible for user-facing tools under the Clang
 umbrella or components used to support such tools.
 
 Tooling library
@@ -255,19 +255,19 @@ SYCL conformance
 | alexey.bader\@intel.com (email), bader (Phabricator), bader (GitHub)
 
 
-Former Code Owners
-==
-The following people have graciously spent time performing code ownership
+Inactive Maintainers
+
+The following people have graciously spent time performing maintainership
 responsibilities but are no longer active in that role. Thank you for all your
 help with the success of the project!
 
-Emeritus owners

+Emeritus Lead Maintainers
+-
 | Doug Gregor (dgregor\@apple.com)
 | Richard Smith (richard\@metafoo.co.uk)
 
 
-Former component owners

+Inactive component maintainers
+--
 | Chandler Carruth (chandlerc\@gmail.com, chandlerc\@google.com) -- CMake, 
library layering
 | Devin Coughlin (dcoughlin\@apple.com) -- Clang static analyzer
diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 51e9db29f887f3..4fecc007f59954 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -117,7 +117,7 @@ if (LLVM_ENABLE_SPHINX)
   "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
 
   COMMAND "${CMAKE_COMMAND}" -E copy_if_different
-  "${CMAKE_CURRENT_SOURCE_DIR}/../CodeOwners.rst"
+  "${CMAKE_CURRENT_SOURCE_DIR}/../Maintainers.rst"
   "${CMAKE_CURRENT_BINARY_DIR}"
 )
 
diff --git a/clang/docs/CodeOwners.rst b/clang/docs/CodeOwners.rst
deleted file mode 100644
index 48128fbc5d909b..00
--- a/clang/docs/CodeOwners.rst
+++ /dev/null
@@ -1 +0,0 @@
-.. include:: ../CodeOwners.rst
diff --git a/clang/docs/Maintainers.rst b/clang/docs/Maintainers.rst
new file mode 100644
index 00..7e69c1165d2f54
--- /dev/null
+++ b/clang/docs/Maintainers.rst
@@ -0,0 +1 @@
+.. include:: ../Maintainers.rst
diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4a497f4d9bcc3c..f4fdc93290a0d9 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -104,7 +104,7 @@ Design Documents
 .. toctree::
:maxdepth: 1
 
-   CodeOwners
+   Maintainers
InternalsManual
DriverInternals
Multilib

>From f32840fee0c577138151991bfaca1814f1273329 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 

[clang] [clang] Code owners -> Maintainers transition (PR #108997)

2024-10-07 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

I heard back from Michael while I was out for WG14 meetings and he still 
intends to actively maintain modules and serialization, so I'm moving him back 
off the inactive maintainers list.

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


[clang] [clang] Code owners -> Maintainers transition (PR #108997)

2024-10-07 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/108997

>From 10f74046b87f67a6efba1ee30806e73eea14007e Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Mon, 16 Sep 2024 08:59:45 -0400
Subject: [PATCH 1/3] [clang] Code owners -> Maintainers transition

This is the initial transition from using "code owners" to using
"maintainers". It presumes that every current code owner is willing to
continue as a maintainer.
---
 clang/{CodeOwners.rst => Maintainers.rst} | 32 +++
 clang/docs/CMakeLists.txt |  2 +-
 clang/docs/CodeOwners.rst |  1 -
 clang/docs/Maintainers.rst|  1 +
 clang/docs/index.rst  |  2 +-
 5 files changed, 19 insertions(+), 19 deletions(-)
 rename clang/{CodeOwners.rst => Maintainers.rst} (92%)
 delete mode 100644 clang/docs/CodeOwners.rst
 create mode 100644 clang/docs/Maintainers.rst

diff --git a/clang/CodeOwners.rst b/clang/Maintainers.rst
similarity index 92%
rename from clang/CodeOwners.rst
rename to clang/Maintainers.rst
index 2ae04c129eb765..766161dbbfc614 100644
--- a/clang/CodeOwners.rst
+++ b/clang/Maintainers.rst
@@ -1,30 +1,30 @@
 =
-Clang Code Owners
+Clang Maintainers
 =
 
 This file is a list of the
-`code owners `_ for
+`maintainers `_ for
 Clang.
 
 .. contents::
:depth: 2
:local:
 
-Current Code Owners
-===
-The following people are the active code owners for the project. Please reach
+Active Maintainers
+==
+The following people are the active maintainers for the project. Please reach
 out to them for code reviews, questions about their area of expertise, or other
 assistance.
 
-All parts of Clang not covered by someone else
---
+Lead Maintainer
+---
 | Aaron Ballman
 | aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman 
(GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
 
 
 Contained Components
 
-These code owners are responsible for particular high-level components within
+These maintainers are responsible for particular high-level components within
 Clang that are typically contained to one area of the compiler.
 
 AST matchers
@@ -125,7 +125,7 @@ Driver parts not covered by someone else
 
 Tools
 -
-These code owners are responsible for user-facing tools under the Clang
+These maintainers are responsible for user-facing tools under the Clang
 umbrella or components used to support such tools.
 
 Tooling library
@@ -255,19 +255,19 @@ SYCL conformance
 | alexey.bader\@intel.com (email), bader (Phabricator), bader (GitHub)
 
 
-Former Code Owners
-==
-The following people have graciously spent time performing code ownership
+Inactive Maintainers
+
+The following people have graciously spent time performing maintainership
 responsibilities but are no longer active in that role. Thank you for all your
 help with the success of the project!
 
-Emeritus owners

+Emeritus Lead Maintainers
+-
 | Doug Gregor (dgregor\@apple.com)
 | Richard Smith (richard\@metafoo.co.uk)
 
 
-Former component owners

+Inactive component maintainers
+--
 | Chandler Carruth (chandlerc\@gmail.com, chandlerc\@google.com) -- CMake, 
library layering
 | Devin Coughlin (dcoughlin\@apple.com) -- Clang static analyzer
diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 51e9db29f887f3..4fecc007f59954 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -117,7 +117,7 @@ if (LLVM_ENABLE_SPHINX)
   "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
 
   COMMAND "${CMAKE_COMMAND}" -E copy_if_different
-  "${CMAKE_CURRENT_SOURCE_DIR}/../CodeOwners.rst"
+  "${CMAKE_CURRENT_SOURCE_DIR}/../Maintainers.rst"
   "${CMAKE_CURRENT_BINARY_DIR}"
 )
 
diff --git a/clang/docs/CodeOwners.rst b/clang/docs/CodeOwners.rst
deleted file mode 100644
index 48128fbc5d909b..00
--- a/clang/docs/CodeOwners.rst
+++ /dev/null
@@ -1 +0,0 @@
-.. include:: ../CodeOwners.rst
diff --git a/clang/docs/Maintainers.rst b/clang/docs/Maintainers.rst
new file mode 100644
index 00..7e69c1165d2f54
--- /dev/null
+++ b/clang/docs/Maintainers.rst
@@ -0,0 +1 @@
+.. include:: ../Maintainers.rst
diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4a497f4d9bcc3c..f4fdc93290a0d9 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -104,7 +104,7 @@ Design Documents
 .. toctree::
:maxdepth: 1
 
-   CodeOwners
+   Maintainers
InternalsManual
DriverInternals
Multilib

>From f32840fee0c577138151991bfaca1814f1273329 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 

[clang] [clang] Code owners -> Maintainers transition (PR #108997)

2024-10-07 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/108997

>From 10f74046b87f67a6efba1ee30806e73eea14007e Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Mon, 16 Sep 2024 08:59:45 -0400
Subject: [PATCH 1/4] [clang] Code owners -> Maintainers transition

This is the initial transition from using "code owners" to using
"maintainers". It presumes that every current code owner is willing to
continue as a maintainer.
---
 clang/{CodeOwners.rst => Maintainers.rst} | 32 +++
 clang/docs/CMakeLists.txt |  2 +-
 clang/docs/CodeOwners.rst |  1 -
 clang/docs/Maintainers.rst|  1 +
 clang/docs/index.rst  |  2 +-
 5 files changed, 19 insertions(+), 19 deletions(-)
 rename clang/{CodeOwners.rst => Maintainers.rst} (92%)
 delete mode 100644 clang/docs/CodeOwners.rst
 create mode 100644 clang/docs/Maintainers.rst

diff --git a/clang/CodeOwners.rst b/clang/Maintainers.rst
similarity index 92%
rename from clang/CodeOwners.rst
rename to clang/Maintainers.rst
index 2ae04c129eb765..766161dbbfc614 100644
--- a/clang/CodeOwners.rst
+++ b/clang/Maintainers.rst
@@ -1,30 +1,30 @@
 =
-Clang Code Owners
+Clang Maintainers
 =
 
 This file is a list of the
-`code owners `_ for
+`maintainers `_ for
 Clang.
 
 .. contents::
:depth: 2
:local:
 
-Current Code Owners
-===
-The following people are the active code owners for the project. Please reach
+Active Maintainers
+==
+The following people are the active maintainers for the project. Please reach
 out to them for code reviews, questions about their area of expertise, or other
 assistance.
 
-All parts of Clang not covered by someone else
---
+Lead Maintainer
+---
 | Aaron Ballman
 | aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman 
(GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
 
 
 Contained Components
 
-These code owners are responsible for particular high-level components within
+These maintainers are responsible for particular high-level components within
 Clang that are typically contained to one area of the compiler.
 
 AST matchers
@@ -125,7 +125,7 @@ Driver parts not covered by someone else
 
 Tools
 -
-These code owners are responsible for user-facing tools under the Clang
+These maintainers are responsible for user-facing tools under the Clang
 umbrella or components used to support such tools.
 
 Tooling library
@@ -255,19 +255,19 @@ SYCL conformance
 | alexey.bader\@intel.com (email), bader (Phabricator), bader (GitHub)
 
 
-Former Code Owners
-==
-The following people have graciously spent time performing code ownership
+Inactive Maintainers
+
+The following people have graciously spent time performing maintainership
 responsibilities but are no longer active in that role. Thank you for all your
 help with the success of the project!
 
-Emeritus owners

+Emeritus Lead Maintainers
+-
 | Doug Gregor (dgregor\@apple.com)
 | Richard Smith (richard\@metafoo.co.uk)
 
 
-Former component owners

+Inactive component maintainers
+--
 | Chandler Carruth (chandlerc\@gmail.com, chandlerc\@google.com) -- CMake, 
library layering
 | Devin Coughlin (dcoughlin\@apple.com) -- Clang static analyzer
diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 51e9db29f887f3..4fecc007f59954 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -117,7 +117,7 @@ if (LLVM_ENABLE_SPHINX)
   "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
 
   COMMAND "${CMAKE_COMMAND}" -E copy_if_different
-  "${CMAKE_CURRENT_SOURCE_DIR}/../CodeOwners.rst"
+  "${CMAKE_CURRENT_SOURCE_DIR}/../Maintainers.rst"
   "${CMAKE_CURRENT_BINARY_DIR}"
 )
 
diff --git a/clang/docs/CodeOwners.rst b/clang/docs/CodeOwners.rst
deleted file mode 100644
index 48128fbc5d909b..00
--- a/clang/docs/CodeOwners.rst
+++ /dev/null
@@ -1 +0,0 @@
-.. include:: ../CodeOwners.rst
diff --git a/clang/docs/Maintainers.rst b/clang/docs/Maintainers.rst
new file mode 100644
index 00..7e69c1165d2f54
--- /dev/null
+++ b/clang/docs/Maintainers.rst
@@ -0,0 +1 @@
+.. include:: ../Maintainers.rst
diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4a497f4d9bcc3c..f4fdc93290a0d9 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -104,7 +104,7 @@ Design Documents
 .. toctree::
:maxdepth: 1
 
-   CodeOwners
+   Maintainers
InternalsManual
DriverInternals
Multilib

>From f32840fee0c577138151991bfaca1814f1273329 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 

[clang] [clang][Driver] Support simplified triple versions for config files (PR #111387)

2024-10-07 Thread Bo Anderson via cfe-commits

https://github.com/Bo98 created https://github.com/llvm/llvm-project/pull/111387

Currently, the config file system loads the full target triple, e.g. 
`arm64-apple-darwin23.6.0.cfg`.

This is however not very useful as this is a moving target. In the case of 
macOS, that target moves every 2 months.

We can improve this by adding fallbacks that simplify the version component of 
the triple. This pull request adds support for loading 
`arm64-apple-darwin23.cfg` and `arm64-apple-darwin.cfg`. See the included test 
for a demonstration on how it works.

>From 88dd0d33147a7f46a3c9df4aed28ad4e47ef597c Mon Sep 17 00:00:00 2001
From: Bo Anderson 
Date: Mon, 7 Oct 2024 15:44:23 +0100
Subject: [PATCH] [clang][Driver] Support simplified triple versions for config
 files

---
 clang/lib/Driver/Driver.cpp  | 53 +++-
 clang/test/Driver/config-file3.c | 23 ++
 2 files changed, 62 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a5d43bdac23735..26aa7f67842ce9 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1147,6 +1147,34 @@ bool Driver::loadConfigFiles() {
   return false;
 }
 
+static bool findTripleConfigFile(llvm::cl::ExpansionContext &ExpCtx,
+ SmallString<128> &ConfigFilePath,
+ llvm::Triple Triple, std::string Suffix) {
+  // First, try the full unmodified triple.
+  if (ExpCtx.findConfigFile(Triple.str() + Suffix, ConfigFilePath))
+return true;
+
+  // Don't continue if we didn't find a parsable version in the triple.
+  VersionTuple OSVersion = Triple.getOSVersion();
+  if (!OSVersion.getMinor().has_value())
+return false;
+
+  std::string BaseOSName = Triple.getOSTypeName(Triple.getOS()).str();
+
+  // Next try strip the version to only include the major component.
+  // e.g. arm64-apple-darwin23.6.0 -> arm64-apple-darwin23
+  if (OSVersion.getMajor() != 0) {
+Triple.setOSName(BaseOSName + llvm::utostr(OSVersion.getMajor()));
+if (ExpCtx.findConfigFile(Triple.str() + Suffix, ConfigFilePath))
+  return true;
+  }
+
+  // Finally, try without any version suffix at all.
+  // e.g. arm64-apple-darwin23.6.0 -> arm64-apple-darwin
+  Triple.setOSName(BaseOSName);
+  return ExpCtx.findConfigFile(Triple.str() + Suffix, ConfigFilePath);
+}
+
 bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
   // Disable default config if CLANG_NO_DEFAULT_CONFIG is set to a non-empty
   // value.
@@ -1158,7 +1186,7 @@ bool 
Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
 return false;
 
   std::string RealMode = getExecutableForDriverMode(Mode);
-  std::string Triple;
+  llvm::Triple Triple;
 
   // If name prefix is present, no --target= override was passed via CLOptions
   // and the name prefix is not a valid triple, force it for backwards
@@ -1169,15 +1197,13 @@ bool 
Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
 llvm::Triple PrefixTriple{ClangNameParts.TargetPrefix};
 if (PrefixTriple.getArch() == llvm::Triple::UnknownArch ||
 PrefixTriple.isOSUnknown())
-  Triple = PrefixTriple.str();
+  Triple = PrefixTriple;
   }
 
   // Otherwise, use the real triple as used by the driver.
-  if (Triple.empty()) {
-llvm::Triple RealTriple =
-computeTargetTriple(*this, TargetTriple, *CLOptions);
-Triple = RealTriple.str();
-assert(!Triple.empty());
+  if (Triple.str().empty()) {
+Triple = computeTargetTriple(*this, TargetTriple, *CLOptions);
+assert(!Triple.str().empty());
   }
 
   // Search for config files in the following order:
@@ -1192,21 +1218,21 @@ bool 
Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
 
   // Try loading -.cfg, and return if we find a match.
   SmallString<128> CfgFilePath;
-  std::string CfgFileName = Triple + '-' + RealMode + ".cfg";
-  if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath))
+  if (findTripleConfigFile(ExpCtx, CfgFilePath, Triple,
+   "-" + RealMode + ".cfg"))
 return readConfigFile(CfgFilePath, ExpCtx);
 
   bool TryModeSuffix = !ClangNameParts.ModeSuffix.empty() &&
ClangNameParts.ModeSuffix != RealMode;
   if (TryModeSuffix) {
-CfgFileName = Triple + '-' + ClangNameParts.ModeSuffix + ".cfg";
-if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath))
+if (findTripleConfigFile(ExpCtx, CfgFilePath, Triple,
+ "-" + ClangNameParts.ModeSuffix + ".cfg"))
   return readConfigFile(CfgFilePath, ExpCtx);
   }
 
   // Try loading .cfg, and return if loading failed.  If a matching file
   // was not found, still proceed on to try .cfg.
-  CfgFileName = RealMode + ".cfg";
+  std::string CfgFileName = RealMode + ".cfg";
   if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) {
 if (readConfigFile(CfgFilePath, ExpCtx))
   return true;
@@ -1218,8 +1244,7 @@ bool 

[clang] [clang][Driver] Support simplified triple versions for config files (PR #111387)

2024-10-07 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [HLSL] Collect explicit resource binding information (part 1) (PR #111203)

2024-10-07 Thread Helena Kotas via cfe-commits

https://github.com/hekota converted_to_draft 
https://github.com/llvm/llvm-project/pull/111203
___
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-07 Thread Matt Arsenault via cfe-commits


@@ -1,12 +1,14 @@
 ; This test aims to check ability to support "Arithmetic with Overflow" 
intrinsics
 ; in the special case when those intrinsics are being generated by the 
CodeGenPrepare;
-; pass during translations with optimization (note -O3 in llc arguments).
+; pass during translations with optimization (note -disable-lsr, to inhibit
+; strength reduction pre-empting with a more preferable match for this pattern
+; in llc arguments).
 
-; RUN: llc -O3 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
-; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv32-unknown-unknown %s -o - 
-filetype=obj | spirv-val %}
+; RUN: llc -O3 -disable-lsr -mtriple=spirv32-unknown-unknown %s -o - | 
FileCheck %s

arsenm wrote:

 If the intent is to specifically check codegenprepare, should have an IR->IR 
test in test/Transforms/CodeGenPrepare.

I don't know whether the -disable-lsr output is the best or not, but based on 
the name of the test I would assume this would try to document the actual 
result, not with the special flag. 

Also this test shouldn't have been using -O3 (it barely does anything and -O2 
is the default) 


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] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-07 Thread Helena Kotas via cfe-commits

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


[clang] [clang-tools-extra] [flang] [lld] [lldb] [llvm] [NFC] Rename Option parsing related files from OptXYZ -> OptionXYZ (PR #110692)

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

jurahul wrote:

@JDevlieghere or @dwblaikie one last ping to comment if consistency of file 
names is a strong enough motivation. If not, I will drop this.

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


[clang] 1297ff1 - [FMV][AArch64][NFC] Cleanup attribute metadata from test files. (#111386)

2024-10-07 Thread via cfe-commits

Author: Alexandros Lamprineas
Date: 2024-10-07T18:54:53+01:00
New Revision: 1297ff176580b8a1cb82128208349002652e5a83

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

LOG: [FMV][AArch64][NFC] Cleanup attribute metadata from test files. (#111386)

We have a dedicated test to check the target-features for FMV
(clang/test/CodeGen/aarch64-fmv-dependencies.c) therefore I am removing
the autogenerated checks from irrelevant tests since the noise is making
it harder to review actual codegen changes.

Added: 


Modified: 
clang/test/CodeGen/aarch64-mixed-target-attributes.c
clang/test/CodeGen/attr-target-clones-aarch64.c
clang/test/CodeGen/attr-target-version.c
clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp
clang/test/CodeGenCXX/attr-target-version.cpp
clang/test/CodeGenCXX/fmv-namespace.cpp

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index d779abd395b5fb..f9c1ae5b75a724 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -v9.5a 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
 
@@ -255,18 +255,6 @@ __attribute__((target_version("jscvt"))) int 
default_def_with_version_decls(void
 // CHECK-NOFMV-NEXT:ret i32 0
 //
 //.
-// CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-v9.5a" }
-// CHECK: attributes #[[ATTR1]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR2]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+lse,-v9.5a" }
-// CHECK: attributes #[[ATTR4]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+neon,+rdm,-v9.5a" }
-// CHECK: attributes #[[ATTR5:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon,-v9.5a" }
-// CHECK: attributes #[[ATTR6:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="-v9.5a" }
-// CHECK: attributes #[[ATTR7:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+lse,-v9.5a" }
-// CHECK: attributes #[[ATTR8:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" }
-//.
-// CHECK-NOFMV: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-fmv" }
-//.
 // CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 // CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 //.

diff  --git a/clang/test/CodeGen/attr-target-clones-aarch64.c 
b/clang/test/CodeGen/attr-target-clones-aarch64.c
index 274e05de594b8e..292e544139e3ff 100644
--- a/clang/test/CodeGen/attr-target-clones-aarch64.c
+++ b/clang/test/CodeGen/attr-target-clones-aarch64.c
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-attributes --check-globals --include-generated-funcs
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +mte 
-target-feature +bti -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-MTE-BTI
@@ -47,18 +47,20 @@ inline int __attribute__((target_clones("fp16", 
"sve2-bitperm+fcma", "default"))
 // CHECK-MTE-BTI: @

[clang] [FMV][AArch64][NFC] Cleanup attribute metadata from test files. (PR #111386)

2024-10-07 Thread Alexandros Lamprineas via cfe-commits

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


[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

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

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


[clang] [Clang][Parser] Don't evaluate concept when its definition is invalid (PR #111179)

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

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


[clang] Introduce MutexModeling checker (PR #111381)

2024-10-07 Thread Endre Fülöp via cfe-commits

gamesh411 wrote:

This commit is NFC, and the intention is to allow the integration of this 
checker into BlockInCriticalSectionChecker and PthreadLockChecker to also be 
NFC (or very close to that).

This patch introduces a new data model for the threading-related information in 
the static analyzer and a checker that updates this information for APIs 
currently modelled in those two threading-related checkers.
The raw trace of the mutex events and some derived information (the state of 
the mutexes and the currently active crit sections). This is redundant, but 
IMO, the raw trace of events is also beneficial for extensibility.

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


[libclc] [libclc] Update build instructions in readme (PR #111369)

2024-10-07 Thread David Spickett via cfe-commits


@@ -23,29 +23,41 @@ generic implementations of most library requirements, 
allowing the target
 to override the generic implementation at the granularity of individual
 functions.
 
-libclc currently only supports the PTX target, but support for more
+libclc currently supports NVPTX, AMDGPU and SPIRV targets, but support for more
 targets is welcome.
 
-Compiling and installing with Make
---
+Compiling and installing
+
 
-$ ./configure.py --with-llvm-config=/path/to/llvm-config && make
-$ make install
+(in the following instructions you can use make or ninja)
 
-Note you can use the DESTDIR Makefile variable to do staged installs.
+For an in-tree build, Clang must also be built at the same time:
 
-$ make install DESTDIR=/path/for/staged/install
+$ cmake /llvm-project/llvm/CMakeLists.txt 
-DLLVM_ENABLE_PROJECTS="libclc;clang" \
+-DCMAKE_BUILD_TYPE=Release -G Ninja
+$ ninja
 
-Compiling and installing with Ninja

+Then install:
 
-$ ./configure.py -g ninja --with-llvm-config=/path/to/llvm-config && ninja
 $ ninja install
 
-Note you can use the DESTDIR environment variable to do staged installs.
+Note you can use the DESTDIR Makefile variable to do staged installs.
 
 $ DESTDIR=/path/for/staged/install ninja install
 
+To build against an existing LLVM build or install:
+
+$ cmake /llvm-project/libclc/CMakeLists.txt 
-DCMAKE_BUILD_TYPE=Release \
+  -G Ninja -DLLVM_DIR=$(/llvm-config --cmakedir)
+$ ninja
+
+Then install as before.
+
+In both cases, the LLVM used must include the targets you want libclc support 
for.

DavidSpickett wrote:

I was going off a few of the 'unknown target spirv-...' messages the build 
produced. Though it did complete but I thought maybe that's just a bug too.

I'll update this bit.

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


[clang] [clang][analyzer] Introduce MutexModeling checker (PR #111381)

2024-10-07 Thread Endre Fülöp via cfe-commits

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


[libclc] [libclc] Update build instructions in readme (PR #111369)

2024-10-07 Thread David Spickett via cfe-commits


@@ -23,29 +23,41 @@ generic implementations of most library requirements, 
allowing the target
 to override the generic implementation at the granularity of individual
 functions.
 
-libclc currently only supports the PTX target, but support for more
+libclc currently supports NVPTX, AMDGPU and SPIRV targets, but support for more
 targets is welcome.
 
-Compiling and installing with Make
---
+Compiling and installing

DavidSpickett wrote:

I didn't know there was such a variable so, yes I'll mention that.

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


[clang] [clang][analyzer] Introduce MutexModeling checker (PR #111381)

2024-10-07 Thread Endre Fülöp via cfe-commits

https://github.com/gamesh411 updated 
https://github.com/llvm/llvm-project/pull/111381

From 4af2c63e4e65b1a8dd9947afdd09fe18362f5cfe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Endre=20F=C3=BCl=C3=B6p?= 
Date: Thu, 3 Oct 2024 18:24:17 +0200
Subject: [PATCH] [clang][analyzer] Introduce MutexModeling checker

This patch introduces the basic structure for the MutexModeling checker.
It adds the checker definition, creates the MutexModeling.cpp file,
supporting header files, and updates the necessary build files. The
MutexModeling checker will be responsible for modeling mutexlock and
unlock events, removing duplication in BlockInCriticalSectionChecker and
PthreadLockChecker.
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |   5 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|   1 +
 .../StaticAnalyzer/Checkers/MutexModeling.cpp | 773 ++
 .../Checkers/MutexModeling/MutexModelingAPI.h | 244 ++
 .../MutexModeling/MutexModelingDomain.h   | 126 +++
 .../Checkers/MutexModeling/MutexModelingGDM.h | 169 
 .../MutexModeling/MutexRegionExtractor.h  | 139 
 7 files changed, 1457 insertions(+)
 create mode 100644 clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDomain.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingGDM.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexRegionExtractor.h

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 349040c15eeb83..fb31011dde84ff 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -219,6 +219,11 @@ def DereferenceChecker : Checker<"NullDereference">,
   ]>,
   Documentation;
 
+def MutexModeling : Checker<"MutexModeling">,
+  HelpText<"Model mutexes lock and unlock events">,
+  Documentation,
+  Hidden;
+
 def NonNullParamChecker : Checker<"NonNullParamChecker">,
   HelpText<"Check for null pointers passed as arguments to a function whose "
"arguments are references or marked with the 'nonnull' attribute">,
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 6da3665ab9a4df..c3987ba76529db 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -68,6 +68,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   MmapWriteExecChecker.cpp
   MIGChecker.cpp
   MoveChecker.cpp
+  MutexModeling.cpp
   MPI-Checker/MPIBugReporter.cpp
   MPI-Checker/MPIChecker.cpp
   MPI-Checker/MPIFunctionClassifier.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
new file mode 100644
index 00..f0e13c5c95e432
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
@@ -0,0 +1,773 @@
+//===--- MutexModeling.cpp - Modeling of mutexes 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Defines modeling checker for tracking mutex states.
+//
+//===--===//
+
+#include "MutexModeling/MutexModelingAPI.h"
+#include "MutexModeling/MutexModelingDomain.h"
+#include "MutexModeling/MutexRegionExtractor.h"
+
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include 
+
+using namespace clang;
+using namespace ento;
+using namespace mutex_modeling;
+
+namespace {
+
+// When a lock is destroyed, in some semantics(like PthreadSemantics) we are 
not
+// sure if the destroy call has succeeded or failed, and the lock enters one of
+// the 'possibly destroyed' state. There is a short time frame for the
+// programmer to check the return value to see if the lock was successfully
+// destroyed. Before we model the next operation over that lock, we call this
+// function to see if the return value was checked by now and set the lock 
state
+// - either to destroyed state or back to its previous state.
+
+// In PthreadSemantics, pthread_mutex_destroy() returns zero if the lock is
+// successfully destroyed and it returns a non-zero value otherwise.
+ProgramStateRef resolvePossiblyDestroyedMutex(ProgramStateRef State,
+  const MemRegion *LockReg,
+  

[libclc] [libclc] Update build instructions in readme (PR #111369)

2024-10-07 Thread David Spickett via cfe-commits


@@ -23,29 +23,41 @@ generic implementations of most library requirements, 
allowing the target
 to override the generic implementation at the granularity of individual
 functions.
 
-libclc currently only supports the PTX target, but support for more
+libclc currently supports NVPTX, AMDGPU and SPIRV targets, but support for more

DavidSpickett wrote:

I didn't add those mostly because I've got 0 idea what they are :)

Do you mean that someone may read this list and think that if libclc supports X 
then LLVM must have a target for X also? I wouldn't myself, but I'm far too 
biased to be useful here.

Perhaps instead of using the backend names (NVPTX) I should use ones from the 
folder names? amdgcn, ptx, spirv etc.

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


[libclc] 0e8555d - [libclc] Remove mention of BSD license in readme (#111371)

2024-10-07 Thread via cfe-commits

Author: David Spickett
Date: 2024-10-07T15:26:04+01:00
New Revision: 0e8555d4dbfdfeddc01dc2ecf9a9b6e804f7b645

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

LOG: [libclc] Remove mention of BSD license in readme (#111371)

This seems to be an artifact from the intial import in 2012, but even if
not, folks are better off reading the LICENSE.TXT file for the full
details if they need them.

Fixes #109968

Added: 


Modified: 
libclc/README.TXT

Removed: 




diff  --git a/libclc/README.TXT b/libclc/README.TXT
index 57b5242b9bbecb..c55a3e441638da 100644
--- a/libclc/README.TXT
+++ b/libclc/README.TXT
@@ -1,7 +1,7 @@
 libclc
 --
 
-libclc is an open source, BSD licensed implementation of the library
+libclc is an open source implementation of the library
 requirements of the OpenCL C programming language, as specified by the
 OpenCL 1.1 Specification. The following sections of the specification
 impose library requirements:



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


[libclc] [libclc] Remove mention of BSD license in readme (PR #111371)

2024-10-07 Thread David Spickett via cfe-commits

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


[libclc] [libclc] Update build instructions in readme (PR #111369)

2024-10-07 Thread David Spickett via cfe-commits


@@ -23,29 +23,41 @@ generic implementations of most library requirements, 
allowing the target
 to override the generic implementation at the granularity of individual
 functions.
 
-libclc currently only supports the PTX target, but support for more
+libclc currently supports NVPTX, AMDGPU and SPIRV targets, but support for more

DavidSpickett wrote:

(Especially if those names are what GPU folks are more likely to refer to them 
by)

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


[clang] [clang][analyzer][NFC] Introduce MutexModeling checker (PR #111381)

2024-10-07 Thread Balazs Benics via cfe-commits

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


[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)

2024-10-07 Thread Yuta Saito via cfe-commits

https://github.com/kateinoigakukun updated 
https://github.com/llvm/llvm-project/pull/111332

>From 605e1ad180c9f75fd59d8b783ae2041cbaf34e50 Mon Sep 17 00:00:00 2001
From: Yuta Saito 
Date: Sat, 5 Oct 2024 16:54:57 +
Subject: [PATCH 1/7] [compiler-rt][profile] Add initial support for
 WebAssembly/WASI

This patch adds initial support for WebAssembly/WASI to the profile
runtime library on the top of wasi-libc. This is a part of the ongoing
patch series to add coverage support for WebAssembly/WASI.

The patch includes the following changes:
* Add wasm32-wasi to the list of supported architectures/OSes.
* Exclude unsupported features for WASI: flock, madvise, uname.
* Enable some user-space emulation provided by wasi-libc: mmap, getpid
---
 .../cmake/Modules/AllSupportedArchDefs.cmake  |  2 +-
 compiler-rt/cmake/config-ix.cmake |  2 +-
 compiler-rt/lib/profile/CMakeLists.txt| 24 +++
 compiler-rt/lib/profile/GCDAProfiling.c   |  2 +-
 compiler-rt/lib/profile/InstrProfilingPort.h  |  2 +-
 compiler-rt/lib/profile/InstrProfilingUtil.c  | 12 ++
 6 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 809e9277156912..d00d39518104bf 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64})
+${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a93a88a9205001..a494e0532a50bc 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ef23492514898b..a6402f80b890a2 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,6 +38,17 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
+CHECK_CXX_SOURCE_COMPILES("
+#include 
+
+int fd;
+int main() {
+  flock(fd, LOCK_EX);
+  return 0;
+}
+
+" COMPILER_RT_TARGET_HAS_FLOCK)
+
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -93,6 +104,13 @@ if(FUCHSIA OR UNIX)
  -Wno-pedantic)
 endif()
 
+if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
+  set(EXTRA_FLAGS
+  ${EXTRA_FLAGS}
+  -D_WASI_EMULATED_MMAN
+  -D_WASI_EMULATED_GETPID)
+endif()
+
 if(COMPILER_RT_TARGET_HAS_ATOMICS)
  set(EXTRA_FLAGS
  ${EXTRA_FLAGS}
@@ -105,6 +123,12 @@ if(COMPILER_RT_TARGET_HAS_FCNTL_LCK)
  -DCOMPILER_RT_HAS_FCNTL_LCK=1)
 endif()
 
+if(COMPILER_RT_TARGET_HAS_FLOCK)
+  set(EXTRA_FLAGS
+  ${EXTRA_FLAGS}
+  -DCOMPILER_RT_HAS_FLOCK=1)
+endif()
+
 if(COMPILER_RT_TARGET_HAS_UNAME)
  set(EXTRA_FLAGS
  ${EXTRA_FLAGS}
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c 
b/compiler-rt/lib/profile/GCDAProfiling.c
index d6e2175169e4a5..a207ddf97c8831 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -584,7 +584,7 @@ void llvm_reset_counters(void) {
   }
 }
 
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__wasi__)
 COMPILER_RT_VISIBILITY
 pid_t __gcov_fork() {
   pid_t parent_pid = getpid();
diff --git a/compiler-rt/lib/profile/InstrProfilingPort.h 
b/compiler-rt/lib/profile/InstrProfilingPort.h
index ed0905cc5f2022..8715a3b0d2a6f0 100644
--- a/compiler-rt/lib/profile/InstrProfilingPort.h
+++ b/compiler-rt/lib/profile/InstrProfilingPort.h
@@ -54,7 +54,7 @@
 #endif
 
 #define COMPILER_RT_MAX_HOSTLEN 128
-#ifdef __ORBIS__
+#if defined(__ORBIS__) || defined(__wasi__)
 #define COMPILER_RT_GETHOSTNAME(Name, Len) ((void)(Name), (void)(Len), (-1))
 #else
 #define COMPILER_RT_GETHOSTNAME(Name, Len) lprofGetHostName(Name, Len)
diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c 
b/compiler-rt/lib/profile/InstrProfilingUtil.c
index 642393d432d7ea..95ec4080ba2504 100644
--- a/compiler-rt/lib/profile/InstrProfilingUtil.c
+++ b/compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -152,9 +152,11 @@ COMPILER_RT_VISIBILITY int lprofLockFd(int fd) {
 }
   }
   return 0;
-#else
+#elif defined(COMPILER_RT_HAS_FLOCK)
   flock(fd, LOCK

[clang] [modules][test] Bump maximum size for embed-files-compressed.cpp for the sake of RISC-V (PR #111360)

2024-10-07 Thread Alex Bradbury via cfe-commits

asb wrote:

In terms of why it's larger on RISC-V and has got bigger, I don't know enough 
about C++ modules to investigate much. `-module-file-info` wasn't very 
informative. The last commit that bumped up the maximum size was 
fa45f81ff7ea9fc2a2a40fea8dd7626ecc3a8dbb suggesting it may be increasing as new 
types are added to the RISC-V vector extension.

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


[clang] [clang] Allow `ConditionalOperator` fast-math flags to be overridden by `pragma float_control` (PR #105912)

2024-10-07 Thread Serge Pavlov via cfe-commits

spavloff wrote:

I don't think think setting FPOptions in `ConditionalOperator` is a good idea. 
This operator does not represent any floating-point operation so setting FP 
properties on it does not look reasonable.

Instead, I would like to propose you using FPOptions from CompoundStmt, you 
could use the same code as in this PR: 
https://github.com/llvm/llvm-project/pull/89617/files#diff-6ddbe6b52b91cf337ee1b7c1ce6ced7d81882f749ac36c81d12714cb298319d6R568-R573
It was added just for similar cases.

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


[clang] [clang][x86] Add constexpr support for some basic SSE1 intrinsics (PR #111001)

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

https://github.com/RKSimon updated 
https://github.com/llvm/llvm-project/pull/111001

>From b57d4529615383767bce3714f8924355ff6924ac Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Thu, 3 Oct 2024 15:19:44 +0100
Subject: [PATCH] [clang][x86] Add constexpr support for some basic SSE1
 intrinsics

This is an initial patch to enable constexpr support on the more basic SSE1 
intrinsics - such as initialization, arithmetic, logic and fixed shuffles.

The plan is to incrementally extend this for SSE2/AVX etc. - initially for the 
equivalent basic intrinsics, but we can add support for some of the ia32 
builtins as well we the need arises.
---
 clang/lib/Headers/xmmintrin.h | 130 --
 clang/test/CodeGen/X86/sse-builtins.c |  83 
 2 files changed, 141 insertions(+), 72 deletions(-)

diff --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h
index 9958e91bfceaa9..2aa688adefc25a 100644
--- a/clang/lib/Headers/xmmintrin.h
+++ b/clang/lib/Headers/xmmintrin.h
@@ -48,6 +48,14 @@ typedef unsigned int __v4su 
__attribute__((__vector_size__(16)));
  __min_vector_width__(128)))
 #endif
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#define __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR __DEFAULT_FN_ATTRS_SSE2 constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#define __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR __DEFAULT_FN_ATTRS_SSE2
+#endif
+
 #define __trunc64(x)   
\
   (__m64) __builtin_shufflevector((__v2di)(x), __extension__(__v2di){}, 0)
 #define __zext128(x)   
\
@@ -75,9 +83,8 @@ typedef unsigned int __v4su 
__attribute__((__vector_size__(16)));
 /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the 
sum
 ///of the lower 32 bits of both operands. The upper 96 bits are copied from
 ///the upper 96 bits of the first source operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_add_ss(__m128 __a, __m128 __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_add_ss(__m128 __a, __m128 __b) {
   __a[0] += __b[0];
   return __a;
 }
@@ -95,9 +102,8 @@ _mm_add_ss(__m128 __a, __m128 __b)
 ///A 128-bit vector of [4 x float] containing one of the source operands.
 /// \returns A 128-bit vector of [4 x float] containing the sums of both
 ///operands.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_add_ps(__m128 __a, __m128 __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_add_ps(__m128 __a, __m128 __b) {
   return (__m128)((__v4sf)__a + (__v4sf)__b);
 }
 
@@ -117,9 +123,8 @@ _mm_add_ps(__m128 __a, __m128 __b)
 /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
 ///difference of the lower 32 bits of both operands. The upper 96 bits are
 ///copied from the upper 96 bits of the first source operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_sub_ss(__m128 __a, __m128 __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_sub_ss(__m128 __a, __m128 __b) {
   __a[0] -= __b[0];
   return __a;
 }
@@ -138,9 +143,8 @@ _mm_sub_ss(__m128 __a, __m128 __b)
 ///A 128-bit vector of [4 x float] containing the subtrahend.
 /// \returns A 128-bit vector of [4 x float] containing the differences between
 ///both operands.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_sub_ps(__m128 __a, __m128 __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_sub_ps(__m128 __a, __m128 __b) {
   return (__m128)((__v4sf)__a - (__v4sf)__b);
 }
 
@@ -160,9 +164,8 @@ _mm_sub_ps(__m128 __a, __m128 __b)
 /// \returns A 128-bit vector of [4 x float] containing the product of the 
lower
 ///32 bits of both operands. The upper 96 bits are copied from the upper 96
 ///bits of the first source operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_mul_ss(__m128 __a, __m128 __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_mul_ss(__m128 __a, __m128 __b) {
   __a[0] *= __b[0];
   return __a;
 }
@@ -180,9 +183,8 @@ _mm_mul_ss(__m128 __a, __m128 __b)
 ///A 128-bit vector of [4 x float] containing one of the source operands.
 /// \returns A 128-bit vector of [4 x float] containing the products of both
 ///operands.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_mul_ps(__m128 __a, __m128 __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_mul_ps(__m128 __a, __m128 __b) {
   return (__m128)((__v4sf)__a * (__v4sf)__b);
 }
 
@@ -202,9 +204,8 @@ _mm_mul_ps(__m128 __a, __m128 __b)
 /// \returns A 128-bit vector of [4 x float] containing the quotients of the
 ///lower 32 bits of both operands. The upper 96 bits are copied from the
 ///upper 96 bits of the first source operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_div_ss(__m128 __a, __m128 __b)
-{
+static __inline__ __m128 __DEFAULT_FN_A

[clang] [Driver] Use empty multilib file in another test (PR #111352)

2024-10-07 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `clang` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/18/builds/5023


Here is the relevant piece of the build log for the reference

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: lang/cpp/function_refs/TestFunctionRefs.py (785 of 2810)
UNSUPPORTED: lldb-api :: lang/cpp/gmodules/alignment/TestPchAlignment.py (786 
of 2810)
UNSUPPORTED: lldb-api :: lang/cpp/gmodules/basic/TestWithModuleDebugging.py 
(787 of 2810)
PASS: lldb-api :: lang/cpp/global_operators/TestCppGlobalOperators.py (788 of 
2810)
UNSUPPORTED: lldb-api :: lang/cpp/gmodules/pch-chain/TestPchChain.py (789 of 
2810)
PASS: lldb-api :: lang/cpp/global_variables/TestCPPGlobalVariables.py (790 of 
2810)
UNSUPPORTED: lldb-api :: 
lang/cpp/gmodules/template-with-same-arg/TestTemplateWithSameArg.py (791 of 
2810)
UNSUPPORTED: lldb-api :: lang/cpp/gmodules/templates/TestGModules.py (792 of 
2810)
PASS: lldb-api :: 
lang/cpp/incompatible-class-templates/TestCppIncompatibleClassTemplates.py (793 
of 2810)
PASS: lldb-api :: lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py (794 
of 2810)
FAIL: lldb-api :: 
lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py (795 of 2810)
 TEST 'lldb-api :: 
lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py' FAILED 

Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/lang/c/shared_lib_stripped_symbols
 -p TestSharedLibStrippedSymbols.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision 
f1ec45a0b0b14d9eb41d32be98f1437b8d1d322d)
  clang revision f1ec45a0b0b14d9eb41d32be98f1437b8d1d322d
  llvm revision f1ec45a0b0b14d9eb41d32be98f1437b8d1d322d
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_expr_dsym (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase) (test 
case does not fall in any category of interest for this run) 
FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_expr_dwarf (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_expr_dwo (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_frame_variable_dsym 
(TestSharedLibStrippedSymbols.SharedLibStrippedTestCase) (test case does not 
fall in any category of interest for this run) 
XFAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_frame_variable_dwarf 
(TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
XFAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_frame_variable_dwo (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
==
FAIL: test_expr_dwarf (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
   Test that types work when defined in a shared library and forwa/d-declared 
in the main executable
--
Traceback (most recent call last):
  File 
"/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1769, in test_method
return attrvalue(self)
  File 
"/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/l

[libclc] [libclc] Remove mention of BSD license in readme (PR #111371)

2024-10-07 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/111371

This seems to be an artifact from the intial import in 2012, but even if not, 
folks are better off reading the LICENSE.TXT file for the full details if they 
need them.

Fixes #109968

>From 34f7c9c40cac397af6041ef89ce001891244f799 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 7 Oct 2024 12:38:32 +
Subject: [PATCH] [libclc] Remove mention of BSD license in readme

This seems to be an artifact from the intial import in 2012,
but even if not, folks are better off reading the LICENSE.TXT
file for the full details if they need them.

Fixes #109968
---
 libclc/README.TXT | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libclc/README.TXT b/libclc/README.TXT
index 57b5242b9bbecb..c55a3e441638da 100644
--- a/libclc/README.TXT
+++ b/libclc/README.TXT
@@ -1,7 +1,7 @@
 libclc
 --
 
-libclc is an open source, BSD licensed implementation of the library
+libclc is an open source implementation of the library
 requirements of the OpenCL C programming language, as specified by the
 OpenCL 1.1 Specification. The following sections of the specification
 impose library requirements:

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


[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

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

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/79

>From fc3e60d2c1d038ae3f3ef2e4ec3e86605cfb0f69 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 4 Oct 2024 23:42:30 +0800
Subject: [PATCH 1/3] [Clang][Parser] Remove the concept from the DeclContext
 if the definition is invalid

---
 clang/include/clang/Sema/Sema.h  |  2 +-
 clang/lib/Parse/ParseTemplate.cpp| 10 +-
 clang/lib/Sema/SemaTemplate.cpp  |  6 --
 clang/test/SemaTemplate/concepts.cpp | 14 ++
 4 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index bede971ce0191b..eea3cf4e43cde8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11995,7 +11995,7 @@ class Sema final : public SemaBase {
 
   ConceptDecl *ActOnStartConceptDefinition(
   Scope *S, MultiTemplateParamsArg TemplateParameterLists,
-  const IdentifierInfo *Name, SourceLocation NameLoc);
+  const IdentifierInfo *Name, SourceLocation NameLoc, bool &AddedToScope);
 
   ConceptDecl *ActOnFinishConceptDefinition(Scope *S, ConceptDecl *C,
 Expr *ConstraintExpr,
diff --git a/clang/lib/Parse/ParseTemplate.cpp 
b/clang/lib/Parse/ParseTemplate.cpp
index de29652abbfd95..9ddabdf5172e41 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -322,13 +322,19 @@ Parser::ParseConceptDefinition(const ParsedTemplateInfo 
&TemplateInfo,
 
   // [C++26][basic.scope.pdecl]/p13
   // The locus of a concept-definition is immediately after its concept-name.
+  bool AddedToScope = false;
   ConceptDecl *D = Actions.ActOnStartConceptDefinition(
-  getCurScope(), *TemplateInfo.TemplateParams, Id, IdLoc);
+  getCurScope(), *TemplateInfo.TemplateParams, Id, IdLoc, AddedToScope);
 
   ParsedAttributes Attrs(AttrFactory);
   MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
 
   if (!TryConsumeToken(tok::equal)) {
+// The expression is unset until ActOnFinishConceptDefinition(), so remove
+// the invalid declaration from the future lookup such that the evaluation
+// wouldn't have to handle empty expressions.
+if (AddedToScope)
+  Actions.CurContext->removeDecl(D);
 Diag(Tok.getLocation(), diag::err_expected) << tok::equal;
 SkipUntil(tok::semi);
 return nullptr;
@@ -337,6 +343,8 @@ Parser::ParseConceptDefinition(const ParsedTemplateInfo 
&TemplateInfo,
   ExprResult ConstraintExprResult =
   Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression());
   if (ConstraintExprResult.isInvalid()) {
+if (AddedToScope)
+  Actions.CurContext->removeDecl(D);
 SkipUntil(tok::semi);
 return nullptr;
   }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index eeaa1ebd7ba83a..2d8b47ea2474be 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8632,7 +8632,7 @@ Decl *Sema::ActOnTemplateDeclarator(Scope *S,
 
 ConceptDecl *Sema::ActOnStartConceptDefinition(
 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
-const IdentifierInfo *Name, SourceLocation NameLoc) {
+const IdentifierInfo *Name, SourceLocation NameLoc, bool &AddedToScope) {
   DeclContext *DC = CurContext;
 
   if (!DC->getRedeclContext()->isFileContext()) {
@@ -8688,8 +8688,10 @@ ConceptDecl *Sema::ActOnStartConceptDefinition(
   // We cannot properly handle redeclarations until we parse the constraint
   // expression, so only inject the name if we are sure we are not redeclaring 
a
   // symbol
-  if (Previous.empty())
+  if (Previous.empty()) {
 PushOnScopeChains(NewDecl, S, true);
+AddedToScope = true;
+  }
 
   return NewDecl;
 }
diff --git a/clang/test/SemaTemplate/concepts.cpp 
b/clang/test/SemaTemplate/concepts.cpp
index a98ca3939222bd..9d29cc59d3ab96 100644
--- a/clang/test/SemaTemplate/concepts.cpp
+++ b/clang/test/SemaTemplate/concepts.cpp
@@ -1151,3 +1151,17 @@ int test() {
 }
 
 }
+
+namespace GH109780 {
+
+template 
+concept Concept; // expected-error {{expected '='}}
+
+bool val = Concept; // expected-error {{use of undeclared identifier 
'Concept'}}
+
+template 
+concept C = invalid; // expected-error {{use of undeclared identifier 
'invalid'}}
+
+bool val2 = C; // expected-error {{use of undeclared identifier 'C'}}
+
+} // namespace GH109780

>From 3c2edaf8be00adf87808b24d1d1e66adbada446b Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Mon, 7 Oct 2024 20:42:12 +0800
Subject: [PATCH 2/3] Revert "[Clang][Parser] Remove the concept from the
 DeclContext if the definition is invalid"

This reverts commit fc3e60d2c1d038ae3f3ef2e4ec3e86605cfb0f69.
---
 clang/include/clang/Sema/Sema.h  |  2 +-
 clang/lib/Parse/ParseTemplate.cpp| 10 +-
 clang/lib/Sema/SemaTemplate.cpp  |  6 ++
 clang/test/SemaTemplate/concepts.cpp | 14 --
 4 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/clang

[clang] Introduce MutexModeling checker (PR #111381)

2024-10-07 Thread Endre Fülöp via cfe-commits

https://github.com/gamesh411 updated 
https://github.com/llvm/llvm-project/pull/111381

From 1f0ec8231830bb15199300060b428aa97fb4a35d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Endre=20F=C3=BCl=C3=B6p?= 
Date: Thu, 3 Oct 2024 18:24:17 +0200
Subject: [PATCH] Introduce MutexModeling checker

This patch introduces the basic structure for the MutexModeling checker.
It adds the checker definition, creates the MutexModeling.cpp file,
supporting header files, and updates the necessary build files. The
MutexModeling checker will be responsible for modeling mutexlock and
unlock events, removing duplication in BlockInCriticalSectionChecker and
PthreadLockChecker.
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |   5 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|   1 +
 .../StaticAnalyzer/Checkers/MutexModeling.cpp | 773 ++
 .../Checkers/MutexModeling/MutexModelingAPI.h | 244 ++
 .../MutexModeling/MutexModelingDomain.h   | 126 +++
 .../Checkers/MutexModeling/MutexModelingGDM.h | 169 
 .../MutexModeling/MutexRegionExtractor.h  | 139 
 7 files changed, 1457 insertions(+)
 create mode 100644 clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDomain.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingGDM.h
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexRegionExtractor.h

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 349040c15eeb83..fb31011dde84ff 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -219,6 +219,11 @@ def DereferenceChecker : Checker<"NullDereference">,
   ]>,
   Documentation;
 
+def MutexModeling : Checker<"MutexModeling">,
+  HelpText<"Model mutexes lock and unlock events">,
+  Documentation,
+  Hidden;
+
 def NonNullParamChecker : Checker<"NonNullParamChecker">,
   HelpText<"Check for null pointers passed as arguments to a function whose "
"arguments are references or marked with the 'nonnull' attribute">,
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 6da3665ab9a4df..c3987ba76529db 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -68,6 +68,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   MmapWriteExecChecker.cpp
   MIGChecker.cpp
   MoveChecker.cpp
+  MutexModeling.cpp
   MPI-Checker/MPIBugReporter.cpp
   MPI-Checker/MPIChecker.cpp
   MPI-Checker/MPIFunctionClassifier.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
new file mode 100644
index 00..f0e13c5c95e432
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp
@@ -0,0 +1,773 @@
+//===--- MutexModeling.cpp - Modeling of mutexes 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Defines modeling checker for tracking mutex states.
+//
+//===--===//
+
+#include "MutexModeling/MutexModelingAPI.h"
+#include "MutexModeling/MutexModelingDomain.h"
+#include "MutexModeling/MutexRegionExtractor.h"
+
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include 
+
+using namespace clang;
+using namespace ento;
+using namespace mutex_modeling;
+
+namespace {
+
+// When a lock is destroyed, in some semantics(like PthreadSemantics) we are 
not
+// sure if the destroy call has succeeded or failed, and the lock enters one of
+// the 'possibly destroyed' state. There is a short time frame for the
+// programmer to check the return value to see if the lock was successfully
+// destroyed. Before we model the next operation over that lock, we call this
+// function to see if the return value was checked by now and set the lock 
state
+// - either to destroyed state or back to its previous state.
+
+// In PthreadSemantics, pthread_mutex_destroy() returns zero if the lock is
+// successfully destroyed and it returns a non-zero value otherwise.
+ProgramStateRef resolvePossiblyDestroyedMutex(ProgramStateRef State,
+  const MemRegion *LockReg,
+  const Symb

[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)

2024-10-07 Thread Yuta Saito via cfe-commits


@@ -584,7 +584,7 @@ void llvm_reset_counters(void) {
   }
 }
 
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__wasi__)

kateinoigakukun wrote:

It makes sense to me, thanks!

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


[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)

2024-10-07 Thread Yuta Saito via cfe-commits

https://github.com/kateinoigakukun updated 
https://github.com/llvm/llvm-project/pull/111332

>From 605e1ad180c9f75fd59d8b783ae2041cbaf34e50 Mon Sep 17 00:00:00 2001
From: Yuta Saito 
Date: Sat, 5 Oct 2024 16:54:57 +
Subject: [PATCH 1/8] [compiler-rt][profile] Add initial support for
 WebAssembly/WASI

This patch adds initial support for WebAssembly/WASI to the profile
runtime library on the top of wasi-libc. This is a part of the ongoing
patch series to add coverage support for WebAssembly/WASI.

The patch includes the following changes:
* Add wasm32-wasi to the list of supported architectures/OSes.
* Exclude unsupported features for WASI: flock, madvise, uname.
* Enable some user-space emulation provided by wasi-libc: mmap, getpid
---
 .../cmake/Modules/AllSupportedArchDefs.cmake  |  2 +-
 compiler-rt/cmake/config-ix.cmake |  2 +-
 compiler-rt/lib/profile/CMakeLists.txt| 24 +++
 compiler-rt/lib/profile/GCDAProfiling.c   |  2 +-
 compiler-rt/lib/profile/InstrProfilingPort.h  |  2 +-
 compiler-rt/lib/profile/InstrProfilingUtil.c  | 12 ++
 6 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 809e9277156912..d00d39518104bf 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64})
+${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a93a88a9205001..a494e0532a50bc 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ef23492514898b..a6402f80b890a2 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,6 +38,17 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
+CHECK_CXX_SOURCE_COMPILES("
+#include 
+
+int fd;
+int main() {
+  flock(fd, LOCK_EX);
+  return 0;
+}
+
+" COMPILER_RT_TARGET_HAS_FLOCK)
+
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -93,6 +104,13 @@ if(FUCHSIA OR UNIX)
  -Wno-pedantic)
 endif()
 
+if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
+  set(EXTRA_FLAGS
+  ${EXTRA_FLAGS}
+  -D_WASI_EMULATED_MMAN
+  -D_WASI_EMULATED_GETPID)
+endif()
+
 if(COMPILER_RT_TARGET_HAS_ATOMICS)
  set(EXTRA_FLAGS
  ${EXTRA_FLAGS}
@@ -105,6 +123,12 @@ if(COMPILER_RT_TARGET_HAS_FCNTL_LCK)
  -DCOMPILER_RT_HAS_FCNTL_LCK=1)
 endif()
 
+if(COMPILER_RT_TARGET_HAS_FLOCK)
+  set(EXTRA_FLAGS
+  ${EXTRA_FLAGS}
+  -DCOMPILER_RT_HAS_FLOCK=1)
+endif()
+
 if(COMPILER_RT_TARGET_HAS_UNAME)
  set(EXTRA_FLAGS
  ${EXTRA_FLAGS}
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c 
b/compiler-rt/lib/profile/GCDAProfiling.c
index d6e2175169e4a5..a207ddf97c8831 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -584,7 +584,7 @@ void llvm_reset_counters(void) {
   }
 }
 
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__wasi__)
 COMPILER_RT_VISIBILITY
 pid_t __gcov_fork() {
   pid_t parent_pid = getpid();
diff --git a/compiler-rt/lib/profile/InstrProfilingPort.h 
b/compiler-rt/lib/profile/InstrProfilingPort.h
index ed0905cc5f2022..8715a3b0d2a6f0 100644
--- a/compiler-rt/lib/profile/InstrProfilingPort.h
+++ b/compiler-rt/lib/profile/InstrProfilingPort.h
@@ -54,7 +54,7 @@
 #endif
 
 #define COMPILER_RT_MAX_HOSTLEN 128
-#ifdef __ORBIS__
+#if defined(__ORBIS__) || defined(__wasi__)
 #define COMPILER_RT_GETHOSTNAME(Name, Len) ((void)(Name), (void)(Len), (-1))
 #else
 #define COMPILER_RT_GETHOSTNAME(Name, Len) lprofGetHostName(Name, Len)
diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c 
b/compiler-rt/lib/profile/InstrProfilingUtil.c
index 642393d432d7ea..95ec4080ba2504 100644
--- a/compiler-rt/lib/profile/InstrProfilingUtil.c
+++ b/compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -152,9 +152,11 @@ COMPILER_RT_VISIBILITY int lprofLockFd(int fd) {
 }
   }
   return 0;
-#else
+#elif defined(COMPILER_RT_HAS_FLOCK)
   flock(fd, LOCK

[clang-tools-extra] [clang-tidy] Fix incorrect command-line option in docs (PR #111405)

2024-10-07 Thread via cfe-commits

https://github.com/float3 created 
https://github.com/llvm/llvm-project/pull/111405

Updated the `HeaderFilterRegex` description to reference `--header-filter` 
instead of the incorrect `--header-filter-regex` in the clang-tidy 
documentation.

>From 1f8eb0e986d6733af726915c1a83433c2cc56fbf Mon Sep 17 00:00:00 2001
From: hill 
Date: Mon, 7 Oct 2024 17:21:57 +0200
Subject: [PATCH] [clang-tidy] Fix incorrect command-line option in docs

Updated the `HeaderFilterRegex` description to reference `--header-filter` 
instead of the incorrect `--header-filter-regex` in the clang-tidy 
documentation.
---
 clang-tools-extra/docs/clang-tidy/index.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/clang-tidy/index.rst 
b/clang-tools-extra/docs/clang-tidy/index.rst
index e38141bdb8be1f..a4233d5d8e2694 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -287,7 +287,7 @@ An overview of all the command-line options:
 FormatStyle  - Same as '--format-style'.
 HeaderFileExtensions - File extensions to consider to determine if 
a
given diagnostic is located in a header 
file.
-HeaderFilterRegex- Same as '--header-filter-regex'.
+HeaderFilterRegex- Same as '--header-filter'.
 ImplementationFileExtensions - File extensions to consider to determine if 
a
given diagnostic is located in an
implementation file.

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


[clang-tools-extra] [clang-tidy] Fix incorrect command-line option in docs (PR #111405)

2024-10-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: hill (float3)


Changes

Updated the `HeaderFilterRegex` description to reference `--header-filter` 
instead of the incorrect `--header-filter-regex` in the clang-tidy 
documentation.

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


1 Files Affected:

- (modified) clang-tools-extra/docs/clang-tidy/index.rst (+1-1) 


``diff
diff --git a/clang-tools-extra/docs/clang-tidy/index.rst 
b/clang-tools-extra/docs/clang-tidy/index.rst
index e38141bdb8be1f..a4233d5d8e2694 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -287,7 +287,7 @@ An overview of all the command-line options:
 FormatStyle  - Same as '--format-style'.
 HeaderFileExtensions - File extensions to consider to determine if 
a
given diagnostic is located in a header 
file.
-HeaderFilterRegex- Same as '--header-filter-regex'.
+HeaderFilterRegex- Same as '--header-filter'.
 ImplementationFileExtensions - File extensions to consider to determine if 
a
given diagnostic is located in an
implementation file.

``




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


[clang-tools-extra] [clang-tidy] Fix incorrect command-line option in docs (PR #111405)

2024-10-07 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang-tools-extra] [clang-tidy] Fix incorrect command-line option in docs (PR #111405)

2024-10-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: hill (float3)


Changes

Updated the `HeaderFilterRegex` description to reference `--header-filter` 
instead of the incorrect `--header-filter-regex` in the clang-tidy 
documentation.

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


1 Files Affected:

- (modified) clang-tools-extra/docs/clang-tidy/index.rst (+1-1) 


``diff
diff --git a/clang-tools-extra/docs/clang-tidy/index.rst 
b/clang-tools-extra/docs/clang-tidy/index.rst
index e38141bdb8be1f..a4233d5d8e2694 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -287,7 +287,7 @@ An overview of all the command-line options:
 FormatStyle  - Same as '--format-style'.
 HeaderFileExtensions - File extensions to consider to determine if 
a
given diagnostic is located in a header 
file.
-HeaderFilterRegex- Same as '--header-filter-regex'.
+HeaderFilterRegex- Same as '--header-filter'.
 ImplementationFileExtensions - File extensions to consider to determine if 
a
given diagnostic is located in an
implementation file.

``




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


[clang] [Clang] omit parentheses in fold expressions with a single expansion (PR #110761)

2024-10-07 Thread Oleksandr T. via cfe-commits

a-tarasyuk wrote:

If no further review is needed, could @cor3ntin @erichkeane merge these 
changes, since I don’t have access? Thanks

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


[clang] b3c1403 - [clang] Fix std::tm etc. mangling on Solaris (#106353)

2024-10-07 Thread via cfe-commits

Author: Rainer Orth
Date: 2024-10-07T19:05:23+02:00
New Revision: b3c1403dc00a41c8222d4b1dd82cbb7c56fd61ae

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

LOG: [clang] Fix std::tm etc. mangling on Solaris (#106353)

Recently, Solaris bootstrap got broken because Solaris uses a
non-standard mangling of `std::tm` and a few others. This was fixed with
a hack in PR #100724. The Solaris ABI requires mangling `std::tm` as
`tm` and similarly for `std::div_t`, `std::ldiv_t`, and `std::lconv`,
which is what this patch implements. The hack needs to stay in place to
allow building with older versions of `clang`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11` (2-stage
builds with both `clang-19` and `gcc-14` as build compiler), and
`x86_64-pc-linux-gnu`.

Added: 
clang/test/AST/solaris-tm.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ItaniumMangle.cpp
clang/lib/Lex/PPMacroExpansion.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5cc9c8047a70ef..3d03766d55a8aa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -510,6 +510,10 @@ OpenACC Specific Changes
 Target Specific Changes
 ---
 
+- Clang now implements the Solaris-specific mangling of ``std::tm`` as
+  ``tm``, same for ``std::div_t``, ``std::ldiv_t``, and
+  ``std::lconv``, for Solaris ABI compatibility. (#GH33114)
+
 AMDGPU Support
 ^^
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 769a863c2b6764..777cdca1a0c0d7 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -1164,8 +1164,25 @@ void CXXNameMangler::mangleUnscopedName(GlobalDecl GD, 
const DeclContext *DC,
   //  ::= St# ::std::
 
   assert(!isa(DC) && "unskipped LinkageSpecDecl");
-  if (isStdNamespace(DC))
+  if (isStdNamespace(DC)) {
+if (getASTContext().getTargetInfo().getTriple().isOSSolaris()) {
+  const NamedDecl *ND = cast(GD.getDecl());
+  if (const RecordDecl *RD = dyn_cast(ND)) {
+// Issue #33114: Need non-standard mangling of std::tm etc. for
+// Solaris ABI compatibility.
+//
+//  ::= tm # ::std::tm, same for the others
+if (const IdentifierInfo *II = RD->getIdentifier()) {
+  StringRef type = II->getName();
+  if (llvm::is_contained({"div_t", "ldiv_t", "lconv", "tm"}, type)) {
+Out << type.size() << type;
+return;
+  }
+}
+  }
+}
 Out << "St";
+  }
 
   mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
 }

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 2b62f573857ee8..27d09b4c8ee744 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1604,10 +1604,12 @@ static bool isTargetVariantEnvironment(const TargetInfo 
&TI,
   return false;
 }
 
-#if defined(__sun__) && defined(__svr4__)
+#if defined(__sun__) && defined(__svr4__) && defined(__clang__) && 
\
+__clang__ < 20
 // GCC mangles std::tm as tm for binary compatibility on Solaris (Issue
 // #33114).  We need to match this to allow the std::put_time calls to link
-// (PR #99075).
+// (PR #99075).  clang 20 contains a fix, but the workaround is still needed
+// with older versions.
 asm("_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"
 "RSt8ios_basecPKSt2tmPKcSB_ = "
 "_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"

diff  --git a/clang/test/AST/solaris-tm.cpp b/clang/test/AST/solaris-tm.cpp
new file mode 100644
index 00..e559ece1429af8
--- /dev/null
+++ b/clang/test/AST/solaris-tm.cpp
@@ -0,0 +1,34 @@
+/// Check that std::tm and a few others are mangled as tm on Solaris only.
+/// Issue #33114.
+///
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple amd64-pc-solaris2.11 | FileCheck 
--check-prefix=CHECK-SOLARIS %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-unknown-linux-gnu  | 
FileCheck --check-prefix=CHECK-LINUX %s
+//
+// REQUIRES: x86-registered-target
+
+namespace std {
+  extern "C" {
+struct tm {
+  int tm_sec;
+};
+struct ldiv_t {
+  long quot;
+};
+  }
+}
+
+// CHECK-SOLARIS: @_Z6tmfunc2tm
+// CHECK-SOLARIS: @_Z9tmccpfunc2tmPKcS1_
+// CHECK-SOLARIS: @_Z7tm2func2tmS_
+// CHECK-LINUX:   @_Z6tmfuncSt2tm
+// CHECK-LINUX:   @_Z9tmccpfuncSt2tmPKcS1_
+// CHECK-LINUX:   @_Z7tm2funcSt2tmS_
+
+void tmfunc (std::tm tm) {}
+void tmccpfunc (std::tm tm, const char *ccp, const char *ccp2) {}
+void tm2func (std::tm tm, std::tm tm2) {}
+
+// CHECK-SOLARIS: @_Z7ldtfunc6ldiv_t
+// CHECK-LINUX:   @_Z7ldtfuncSt6ldiv_t
+
+void ldtfunc (std::ldiv_t ldt) {}



___

[clang] [Clang] prevent recovery call expression from proceeding with explicit attributes and undeclared templates (PR #107786)

2024-10-07 Thread Oleksandr T. via cfe-commits

a-tarasyuk wrote:

@AaronBallman could you review these changes? thanks

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


[clang] Recommit "[RISCV][FMV] Support target_version" (#111096)" (PR #111333)

2024-10-07 Thread Craig Topper via cfe-commits

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

LGTM

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


[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #111427)

2024-10-07 Thread via cfe-commits

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


[clang-tools-extra] [clang-tidy] Improved readability redundant casting with enums (PR #111424)

2024-10-07 Thread Félix-Antoine Constantin via cfe-commits

https://github.com/felix642 updated 
https://github.com/llvm/llvm-project/pull/111424

From a786f626beb418cf6b8847c6250f0490b60affdb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?F=C3=A9lix-Antoine=20Constantin?=
 
Date: Mon, 7 Oct 2024 15:27:36 -0400
Subject: [PATCH] [clang-tidy] Improved readability redundant casting with
 enums

Fixed false negatives with readability-redundant-casting when the underlying
types are the same and the option IgnoreTypeAliases is set to true.

Fixes #37
---
 .../readability/RedundantCastingCheck.cpp |  9 -
 clang-tools-extra/docs/ReleaseNotes.rst   |  6 ++
 .../readability/redundant-casting.cpp | 20 +++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
index b9ff0e81cbc522..612a5a91593359 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
@@ -40,8 +40,15 @@ static bool areTypesEqual(QualType S, QualType D) {
 
 static bool areTypesEqual(QualType TypeS, QualType TypeD,
   bool IgnoreTypeAliases) {
-  const QualType CTypeS = TypeS.getCanonicalType();
   const QualType CTypeD = TypeD.getCanonicalType();
+
+  QualType CTypeS;
+  const auto *const EnumTypeS = TypeS->getAs();
+  if (EnumTypeS != nullptr && !EnumTypeS->getDecl()->isScoped())
+CTypeS = EnumTypeS->getDecl()->getIntegerType();
+  else
+CTypeS = TypeS.getCanonicalType();
+
   if (CTypeS != CTypeD)
 return false;
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 3e051c7db6adcc..32bae30821092f 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -222,6 +222,12 @@ Changes in existing checks
   by adding the option `UseUpperCaseLiteralSuffix` to select the
   case of the literal suffix in fixes.
 
+- Improved :doc:`readability-redundant-casting
+  ` check by fixing
+  false negatives related to ``enum`` when setting ``IgnoreTypeAliases``
+  to true.
+
+
 - Improved :doc:`readability-redundant-smartptr-get
   ` check to
   remove `->`, when redundant `get()` is removed.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp
index 30cac6bd5cca06..ed49f32364cba8 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp
@@ -221,3 +221,23 @@ void testRedundantDependentNTTPCasting() {
   // CHECK-MESSAGES: :[[@LINE-4]]:25: note: source type originates from 
referencing this non-type template parameter
   // CHECK-FIXES: {{^}}  T a = V;
 }
+
+enum E1 : char {};
+enum class E2 : char {};
+enum E3 {};
+
+void testEnum(E1 e1, E2 e2, E3 e3){
+  char a = static_cast(e1);
+  // CHECK-MESSAGES-ALIASES: :[[@LINE-1]]:12: warning: redundant explicit 
casting to the same type 'char' as the sub-expression, remove this casting 
[readability-redundant-casting]
+  // CHECK-MESSAGES-ALIASES: :[[@LINE-3]]:18: note: source type originates 
from referencing this parameter
+  // CHECK-FIXES-ALIASES: {{^}}  char a = e1;
+
+  unsigned int d = static_cast(e3);
+  // CHECK-MESSAGES-ALIASES: :[[@LINE-1]]:20: warning: redundant explicit 
casting to the same type 'unsigned int' as the sub-expression, remove this 
casting [readability-redundant-casting]
+  // CHECK-MESSAGES-ALIASES: :[[@LINE-8]]:32: note: source type originates 
from referencing this parameter
+  // CHECK-FIXES-ALIASES: {{^}}  unsigned int d = e3;
+
+  char b = static_cast(e2);
+  char c = static_cast(e3);
+  E1 e = static_cast('0');
+}

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


[clang] dd0fe4f - [CIR] Add .clang-tidy files for ClangIR specific coding style rules

2024-10-07 Thread via cfe-commits

Author: Nathan Lanza
Date: 2024-10-07T15:55:03-04:00
New Revision: dd0fe4fb7440182d8101135bfd694b2d84893c2e

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

LOG: [CIR] Add .clang-tidy files for ClangIR specific coding style rules

https://llvm.github.io/clangir/GettingStarted/coding-guideline.html

Reviewers: dkolsen-pgi, bcardosolopes, erichkeane

Reviewed By: erichkeane, dkolsen-pgi

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

Added: 
clang/include/clang/CIR/.clang-tidy
clang/include/clang/CIRFrontendAction/.clang-tidy
clang/lib/CIR/.clang-tidy

Modified: 


Removed: 




diff  --git a/clang/include/clang/CIR/.clang-tidy 
b/clang/include/clang/CIR/.clang-tidy
new file mode 100644
index 00..aaba4585494d66
--- /dev/null
+++ b/clang/include/clang/CIR/.clang-tidy
@@ -0,0 +1,62 @@
+InheritParentConfig: true
+Checks: >
+-misc-const-correctness,
+-llvm-header-guard,
+bugprone-argument-comment,
+bugprone-assert-side-effect,
+bugprone-branch-clone,
+bugprone-copy-constructor-init,
+bugprone-dangling-handle,
+bugprone-dynamic-static-initializers,
+bugprone-macro-parentheses,
+bugprone-macro-repeated-side-effects,
+bugprone-misplaced-widening-cast,
+bugprone-move-forwarding-reference,
+bugprone-multiple-statement-macro,
+bugprone-suspicious-semicolon,
+bugprone-swapped-arguments,
+bugprone-terminating-continue,
+bugprone-unused-raii,
+bugprone-unused-return-value,
+misc-redundant-expression,
+misc-static-assert,
+misc-unused-using-decls,
+modernize-use-bool-literals,
+modernize-loop-convert,
+modernize-make-unique,
+modernize-raw-string-literal,
+modernize-use-equals-default,
+modernize-use-default-member-init,
+modernize-use-emplace,
+modernize-use-nullptr,
+modernize-use-override,
+modernize-use-using,
+performance-for-range-copy,
+performance-implicit-conversion-in-loop,
+performance-inefficient-algorithm,
+performance-inefficient-vector-operation,
+performance-move-const-arg,
+performance-no-automatic-move,
+performance-trivially-destructible,
+performance-unnecessary-copy-initialization,
+performance-unnecessary-value-param,
+readability-avoid-const-params-in-decls,
+readability-const-return-type,
+readability-container-size-empty,
+readability-identifier-naming,
+readability-inconsistent-declaration-parameter-name,
+readability-misleading-indentation,
+readability-redundant-control-flow,
+readability-redundant-smartptr-get,
+readability-simplify-boolean-expr,
+readability-simplify-subscript-expr,
+readability-use-anyofallof
+
+
+CheckOptions:
+  - key: readability-identifier-naming.MemberCase
+value:   camelBack
+  - key: readability-identifier-naming.ParameterCase
+value:   camelBack
+  - key: readability-identifier-naming.VariableCase
+value:   camelBack

diff  --git a/clang/include/clang/CIRFrontendAction/.clang-tidy 
b/clang/include/clang/CIRFrontendAction/.clang-tidy
new file mode 100644
index 00..ef88dbcec488c8
--- /dev/null
+++ b/clang/include/clang/CIRFrontendAction/.clang-tidy
@@ -0,0 +1,53 @@
+InheritParentConfig: true
+Checks: >
+-misc-const-correctness,
+-llvm-header-guard,
+bugprone-argument-comment,
+bugprone-assert-side-effect,
+bugprone-branch-clone,
+bugprone-copy-constructor-init,
+bugprone-dangling-handle,
+bugprone-dynamic-static-initializers,
+bugprone-macro-parentheses,
+bugprone-macro-repeated-side-effects,
+bugprone-misplaced-widening-cast,
+bugprone-move-forwarding-reference,
+bugprone-multiple-statement-macro,
+bugprone-suspicious-semicolon,
+bugprone-swapped-arguments,
+bugprone-terminating-continue,
+bugprone-unused-raii,
+bugprone-unused-return-value,
+misc-redundant-expression,
+misc-static-assert,
+misc-unused-using-decls,
+modernize-use-bool-literals,
+modernize-loop-convert,
+modernize-make-unique,
+modernize-raw-string-literal,
+modernize-use-equals-default,
+modernize-use-default-member-init,
+modernize-use-emplace,
+modernize-use-nullptr,
+modernize-use-override,
+modernize-use-using,
+performance-for-range-copy,
+performance-implicit-conversion-in-loop,
+

[clang] [CIR] Add .clang-tidy files for ClangIR specific coding style rules (PR #111417)

2024-10-07 Thread Nathan Lanza via cfe-commits

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


[clang] [CIR] Add .clang-tidy files for ClangIR specific coding style rules (PR #111417)

2024-10-07 Thread Nathan Lanza via cfe-commits

lanza wrote:

> I am not familiar with how clang-tidy works. (I expect that will have to 
> change and I should start using it.) So I can't meaningfully review this.

If you use clangd then the clang-tidy based warnings will just show up in your 
editor. These files are just enforcing the ClangIR specific rules. 

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


[clang] [clang][x86] Missing `AVX512VP2INTERSECT` flag (PR #111435)

2024-10-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Ash Vardanian (ashvardanian)


Changes

This patch adds support for detecting the `AVX512VP2INTERSECT` ISA extension.
It's useful for Intel Tiger Lake mobile CPUs and any Zen 5 AMD CPUs.
No functional changes yet, just defining the feature flag.

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


1 Files Affected:

- (modified) clang/lib/Headers/cpuid.h (+12-11) 


``diff
diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index 82d995f1b966a3..2601aa5724f056 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -187,17 +187,18 @@
 #define bit_ENQCMD   0x2000
 
 /* Features in %edx for leaf 7 sub-leaf 0 */
-#define bit_AVX5124VNNIW  0x0004
-#define bit_AVX5124FMAPS  0x0008
-#define bit_UINTR 0x0020
-#define bit_SERIALIZE 0x4000
-#define bit_TSXLDTRK  0x0001
-#define bit_PCONFIG   0x0004
-#define bit_IBT   0x0010
-#define bit_AMXBF16   0x0040
-#define bit_AVX512FP160x0080
-#define bit_AMXTILE   0x0100
-#define bit_AMXINT8   0x0200
+#define bit_AVX5124VNNIW0x0004
+#define bit_AVX5124FMAPS0x0008
+#define bit_UINTR   0x0020
+#define bit_AVX512VP2INTERSECT  0x0100
+#define bit_SERIALIZE   0x4000
+#define bit_TSXLDTRK0x0001
+#define bit_PCONFIG 0x0004
+#define bit_IBT 0x0010
+#define bit_AMXBF16 0x0040
+#define bit_AVX512FP16  0x0080
+#define bit_AMXTILE 0x0100
+#define bit_AMXINT8 0x0200
 
 /* Features in %eax for leaf 7 sub-leaf 1 */
 #define bit_SHA5120x0001

``




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


[clang] Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (PR #111173)

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

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


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


[clang] Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (PR #111173)

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


@@ -4159,7 +4159,7 @@ FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() 
const {
   if (FunctionTemplateSpecializationInfo *Info
 = TemplateOrSpecialization
 .dyn_cast()) {
-return Info->getTemplate();
+return Info->getTemplate()->getMostRecentDecl();

mizvekov wrote:

Thanks!

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


[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #111427)

2024-10-07 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 62ae01201fc7185aca61d040c4f2df5303bae0ad 
278abd2cde54be013c09d2c35b976f7985ddead4 --extensions cpp,h -- 
llvm/include/llvm/Support/Mustache.h llvm/lib/Support/Mustache.cpp 
llvm/tools/mustache/mustache.cpp llvm/unittests/Support/MustacheTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/include/llvm/Support/Mustache.h 
b/llvm/include/llvm/Support/Mustache.h
index 641bcafc22..105e518c24 100644
--- a/llvm/include/llvm/Support/Mustache.h
+++ b/llvm/include/llvm/Support/Mustache.h
@@ -126,16 +126,16 @@ public:
 InvertSection,
   };
 
-  ASTNode() : T(Type::Root), LocalContext(nullptr){};
+  ASTNode() : T(Type::Root), LocalContext(nullptr) {};
 
   ASTNode(StringRef Body, ASTNode *Parent)
   : T(Type::Text), Body(Body), Parent(Parent), LocalContext(nullptr),
-Indentation(0){};
+Indentation(0) {};
 
   // Constructor for Section/InvertSection/Variable/UnescapeVariable
   ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
   : T(T), Parent(Parent), Children({}), Accessor(Accessor),
-LocalContext(nullptr), Indentation(0){};
+LocalContext(nullptr), Indentation(0) {};
 
   void addChild(ASTNode *Child) { Children.emplace_back(Child); };
 

``




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


[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

2024-10-07 Thread Chris B via cfe-commits


@@ -2249,6 +2235,25 @@ static bool IsStandardConversion(Sema &S, Expr* From, 
QualType ToType,
 
 SCS.setAllToTypes(ToType);
 return true;
+  } else if (argIsLValue && !FromType->canDecayToPointerType() &&
+ S.Context.getCanonicalType(FromType) != S.Context.OverloadTy) {
+// Lvalue-to-rvalue conversion (C++11 4.1):
+//   A glvalue (3.10) of a non-function, non-array type T can
+//   be converted to a prvalue.
+
+SCS.First = ICK_Lvalue_To_Rvalue;
+
+// C11 6.3.2.1p2:
+//   ... if the lvalue has atomic type, the value has the non-atomic 
version
+//   of the type of the lvalue ...
+if (const AtomicType *Atomic = FromType->getAs())
+  FromType = Atomic->getValueType();
+
+// If T is a non-class type, the type of the rvalue is the
+// cv-unqualified version of T. Otherwise, the type of the rvalue
+// is T (C++ 4.1p1). C++ can't get here with class types; in C, we
+// just strip the qualifiers because they don't matter.
+FromType = FromType.getUnqualifiedType();

llvm-beanz wrote:

It looks like you moved this block down from above. I assume this is because 
the ordering of these checks matters, could you add a comment above the 
HLSL-specific `if` block explaining why?

https://github.com/llvm/llvm-project/pull/111047
___
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-07 Thread Alex Voicu via cfe-commits

AlexVlx wrote:

> So we both agree, that the compiler must compile the OpenCL code from above 
> to SPIR-V without erroring out. We can do it in 2 ways:
> 
> 1. Regularize types in the backend (since the backend is based on top of 
> global isel we should have here better luck then in the translator);
> 2. Or since this patch modifies datalayout - adjust LLVM pipeline to consider 
> datalayout in optimization passes. The reasoning you have provided in the PR 
> description: "`This is problematic as it leads to optimisation passes, such 
> as InstCombine, getting ideas and e.g. shrinking to non byte-multiple integer 
> types, which is not desirable and can lead to breakage further down in the 
> toolchain.`" totally makes sense to me. So I'm asking if you have plans to go 
> through the passes and modify them, or you only intend to modify InstCombine 
> and/or AMD-specific passes?

Wel, the issue the example illustrates is pre-existing and not influenced / 
triggered by this patch; stepping back, if the question is “are you going to 
try / would you like to fix this other issue” the answer is yes, but sadly I 
don't have an immediate intuition as to the right solution (1 is ~approx~ what 
we do on the AMDGPU side, where we e.g. handle accesses to i128 as the 
corresponding vec4 access).

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


[compiler-rt] [libunwind] [AArch64] Fix nofp regressions in compiler-rt and libunwind (PR #111235)

2024-10-07 Thread Keith Packard via cfe-commits


@@ -6,7 +6,7 @@
 
 #include "../assembly.h"
 
-#ifdef __aarch64__
+#if defined(__aarch64__) && __ARM_FP != 0

keith-packard wrote:

Yeah, I've updated the patch after adapting some tests to make sure these all 
work on non-FPU hardware. That leaves only `__arm_sc_memset`.

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


[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)

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

bwendling wrote:

> After looking at the assembly produced by gcc more, it actually looks like 
> it's using the allocation size if it's known in the current context (for 
> example if the struct was just malloced in the same function) and otherwise 
> returns INT_MAX for the __bdos of a struct containing a flexible array 
> member. It's only returning the size based on the __counted_by attribute of 
> you ask it for the __bdos of the flexible array member itself.
> 
> ```c
> int test(struct posix_acl *acl) {
> return __builtin_dynamic_object_size(acl, 0);
> }
> ```
> 
> actually compiles to
> 
> ```
> test:
> mov eax, -1
> ret
> ```
> 
> using gcc (trunk) on compiler explorer.

I think this is because GCC hasn't (yet) modified their version of 
`__builtin_dynamic_object_size` to use the `counted_by` attribute. If you were 
to write code that intentionally modified beyond the FAM element, does GCC's 
sanitizer catch it?


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


[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)

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

bwendling wrote:

> So, we would actually get gcc's behavior with this patch:
> 
> ```
> diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
> index c864714182e0..21ffe7b46a6e 100644
> --- a/clang/lib/CodeGen/CGBuiltin.cpp
> +++ b/clang/lib/CodeGen/CGBuiltin.cpp
> @@ -1049,25 +1049,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const 
> Expr *E, unsigned Type,
>Value *Res = FAMSize;
>  
>if (isa(Base)) {
> -// The whole struct is specificed in the __bdos.
> -const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(OuterRD);
> -
> -// Get the offset of the FAM.
> -llvm::Constant *FAMOffset = ConstantInt::get(ResType, Offset, IsSigned);
> -Value *OffsetAndFAMSize =
> -Builder.CreateAdd(FAMOffset, Res, "", !IsSigned, IsSigned);
> -
> -// Get the full size of the struct.
> -llvm::Constant *SizeofStruct =
> -ConstantInt::get(ResType, Layout.getSize().getQuantity(), IsSigned);
> -
> -// max(sizeof(struct s),
> -// offsetof(struct s, array) + p->count * sizeof(*p->array))
> -Res = IsSigned
> -  ? Builder.CreateBinaryIntrinsic(llvm::Intrinsic::smax,
> -  OffsetAndFAMSize, SizeofStruct)
> -  : Builder.CreateBinaryIntrinsic(llvm::Intrinsic::umax,
> -  OffsetAndFAMSize, 
> SizeofStruct);
> +return nullptr;
>}
>  
>// A negative \p IdxInst or \p CountedByInst means that the index lands
> ```

This just turns off `__builtin_dynamic_object_size(ptr, 0)`, which I'm not in 
favor of.

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


[clang] [clang] Finish implementation of P0522 (PR #96023)

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

mizvekov wrote:

This will be fixed by https://github.com/llvm/llvm-project/pull/111457

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


[clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-07 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

Sorry for not responding here for a while.

> These change mirror interface to getFileOrSTDIN() which has a IsText 
> parameter. This does touch a number of places but I feel the changes are in 
> line with the rest of the file I/O functions in llvm.

I think there's a huge difference between `getFileOrSTDIN` and 
`llvm::vfs::FileSystem` interfaces. The former has a single implementation 
that's meant to always work with a physical filesytem. The latter has many 
implementations and is meant to decouple physical filesystem, we're now leaking 
that abstraction solely because physical system is trying to receive some 
information.

> Thanks, I've tested the #embed lit tests with this fix and did not see any 
> regressions

I am still wary of this. Logic that handles #embed directives lives in 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/PPDirectives.cpp#L3964-L3990.
 As you can see, all of them use the default filemanager/filesystem interfaces, 
which will read this file with `IsText = true` after this patch.

---

All of that being said;

If you folks are in alignment with this being required, I think we should still 
make it as least intrusive to rest of the users of this interface as possible.

Looks like this only has affects on `RealFileSystem` implementation (and 
probably isn't really useful for the rest anyways).

Can we at least change the implementation here to:
- Introduce a new virtual methods called `openFileForReadBinary` and 
`getBufferForFileBinary` into `llvm::vfs::Filesystem`. Make default 
implementations just delegate to `openFileForRead` and `getBufferForFile`. 
Explain when the binary specific overloads should be preferred and how the 
default versions assume operating on text files in the comments for these 
methods.
- Override these new methods in `RealFileSystem` to pass different flags to 
underlying calls
- Make sure place like #embed handling and astreader calls the `read-binary` 
versions of these methods.

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


[clang] [CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

2024-10-07 Thread via cfe-commits


@@ -2218,6 +2219,12 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) 
const {
 Width = 0; 
\
 Align = 16;
\
 break;
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls,
\
+ElBits, NF)

CarolineConcatto wrote:

This cannot be removed, because it is not listing SVE_TYPE, so the compiler 
complains about AArCH64

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


[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (luxufan)


Changes

The RTTI type name global variable should be marked as global unnamed_addr 
since the address of RTTI type name global variable
 is not significant.

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


7 Files Affected:

- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1) 
- (modified) clang/test/CodeGen/split-lto-unit-input.cpp (+2-2) 
- (modified) 
clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/anonymous-namespaces.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/arm64.cpp (+6-6) 
- (modified) clang/test/CodeGenCXX/armv7k.cpp (+4-10) 
- (modified) clang/test/CodeGenCXX/windows-itanium-type-info.cpp (+4-10) 


``diff
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 965e09a7a760ec..4b9cd70ce4d55d 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3532,6 +3532,7 @@ llvm::GlobalVariable 
*ItaniumRTTIBuilder::GetAddrOfTypeName(
   Name, Init->getType(), Linkage, Align.getAsAlign());
 
   GV->setInitializer(Init);
+  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
   return GV;
 }
diff --git a/clang/test/CodeGen/split-lto-unit-input.cpp 
b/clang/test/CodeGen/split-lto-unit-input.cpp
index adfc9ac3e0f446..99de0f68f84978 100644
--- a/clang/test/CodeGen/split-lto-unit-input.cpp
+++ b/clang/test/CodeGen/split-lto-unit-input.cpp
@@ -12,8 +12,8 @@
 // CHECK-NEXT: V _ZTV1A
 // CHECK-NEXT: V _ZTV1B
 
-// CHECK-IR-DAG: _ZTS1B = linkonce_odr constant
-// CHECK-IR-DAG: _ZTS1A = linkonce_odr constant
+// CHECK-IR-DAG: _ZTS1B = linkonce_odr unnamed_addr constant
+// CHECK-IR-DAG: _ZTS1A = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTV1B = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTI1A = linkonce_odr constant
 // CHECK-IR-DAG: _ZTI1B = linkonce_odr constant
diff --git 
a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
index 341c53146d476d..6a833cf3884546 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
@@ -16,7 +16,7 @@
 // The VTable for A is emitted here and in a comdat section since it has no 
key function, and is used in this module when creating an instance of A.
 // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x 
i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr 
@_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x 
i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc 
(i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 
ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, 
i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
-// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
+// CHECK: @_ZTS1A = linkonce_odr unnamed_addr constant [3 x i8] c"1A\00", 
comdat, align 1
 // CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr 
inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A 
}, comdat, align 8
 // CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr 
@_ZTI1A, comdat
 // CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr 
@_ZTV1A.local
diff --git a/clang/test/CodeGenCXX/anonymous-namespaces.cpp 
b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
index f40039c2a4f400..eb185be52c15a4 100644
--- a/clang/test/CodeGenCXX/anonymous-namespaces.cpp
+++ b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
@@ -29,7 +29,7 @@ namespace {
   int D::d = f();
 
   // Check for generation of a VTT with internal linkage
-  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
+  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal unnamed_addr constant
   struct X { 
 struct EBase { };
 struct E : public virtual EBase { virtual ~E() {} };
diff --git a/clang/test/CodeGenCXX/arm64.cpp b/clang/test/CodeGenCXX/arm64.cpp
index 338b7db9e001f2..f452cf9a8b5072 100644
--- a/clang/test/CodeGenCXX/arm64.cpp
+++ b/clang/test/CodeGenCXX/arm64.cpp
@@ -48,20 +48,20 @@ namespace test2 {
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden unnamed_addr 
constant
   // CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden constant { 
{{.*}}, ptr @_ZTSN5test21BE }
 
   const std::type_info &b1 = typeid(B*);
-  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden unnamed_add

[clang] [clang] Catch missing format attributes (PR #105479)

2024-10-07 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovichtec updated 
https://github.com/llvm/llvm-project/pull/105479

From 503b85ca47e69ca0620da56282c948cfd6b22b4b Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Fri, 5 Apr 2024 15:20:37 +0200
Subject: [PATCH] [clang] Catch missing format attributes

---
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 -
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/include/clang/Sema/Attr.h   |   7 +
 clang/include/clang/Sema/Sema.h   |   2 +
 clang/lib/Sema/SemaDecl.cpp   |   2 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 219 +-
 clang/test/Sema/attr-format-missing.c | 217 +
 clang/test/Sema/attr-format-missing.cpp   | 180 ++
 9 files changed, 631 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/attr-format-missing.c
 create mode 100644 clang/test/Sema/attr-format-missing.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5cc9c8047a70ef..e8c3d3073ba2b6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -378,6 +378,9 @@ Improvements to Clang's diagnostics
 
 - Clang now emits a diagnostic note at the class declaration when the method 
definition does not match any declaration (#GH110638).
 
+- Clang now diagnoses missing format attributes for non-template functions and
+  class/struct/union members. Fixes #GH60718
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 41e719d4d57816..850823ee7c48e3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -529,7 +529,6 @@ def MainReturnType : DiagGroup<"main-return-type">;
 def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
-def : DiagGroup<"missing-format-attribute">;
 def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 583475327c5227..f1d12a389d827f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1046,6 +1046,9 @@ def err_opencl_invalid_param : Error<
   "declaring function parameter of type %0 is not allowed%select{; did you 
forget * ?|}1">;
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
+def warn_missing_format_attribute : Warning<
+  "diagnostic behavior may be improved by adding the %0 format attribute to 
the declaration of %1">,
+  InGroup>, DefaultIgnore;
 def warn_pragma_options_align_reset_failed : Warning<
   "#pragma options align=reset failed: %0">,
   InGroup;
diff --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h
index 3f0b10212789a4..37c124ca7b454a 100644
--- a/clang/include/clang/Sema/Attr.h
+++ b/clang/include/clang/Sema/Attr.h
@@ -123,6 +123,13 @@ inline bool isInstanceMethod(const Decl *D) {
   return false;
 }
 
+inline bool checkIfMethodHasImplicitObjectParameter(const Decl *D) {
+  if (const auto *MethodDecl = dyn_cast(D))
+return MethodDecl->isInstance() &&
+   !MethodDecl->hasCXXExplicitFunctionObjectParameter();
+  return false;
+}
+
 /// Diagnose mutually exclusive attributes when present on a given
 /// declaration. Returns true if diagnosed.
 template 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index bede971ce0191b..7129fa8c8f1359 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4574,6 +4574,8 @@ class Sema final : public SemaBase {
 
   enum class RetainOwnershipKind { NS, CF, OS };
 
+  void DiagnoseMissingFormatAttributes(Stmt *Body, const FunctionDecl *FDecl);
+
   UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
   StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
 
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2bf610746bc317..0ec29cfeb728bf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16020,6 +16020,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
 }
   }
 
+  DiagnoseMissingFormatAttributes(Body, FD);
+
   // We might not have found a prototype because we didn't wish to warn on
   // the lack of a missing prototype. Try again without the checks for
   // whether we want to warn on the missing prototype.
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c9b9f3a0007daa..813a5

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: None (luxufan)


Changes

The RTTI type name global variable should be marked as global unnamed_addr 
since the address of RTTI type name global variable
 is not significant.

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


7 Files Affected:

- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1) 
- (modified) clang/test/CodeGen/split-lto-unit-input.cpp (+2-2) 
- (modified) 
clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/anonymous-namespaces.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/arm64.cpp (+6-6) 
- (modified) clang/test/CodeGenCXX/armv7k.cpp (+4-10) 
- (modified) clang/test/CodeGenCXX/windows-itanium-type-info.cpp (+4-10) 


``diff
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 965e09a7a760ec..4b9cd70ce4d55d 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3532,6 +3532,7 @@ llvm::GlobalVariable 
*ItaniumRTTIBuilder::GetAddrOfTypeName(
   Name, Init->getType(), Linkage, Align.getAsAlign());
 
   GV->setInitializer(Init);
+  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
   return GV;
 }
diff --git a/clang/test/CodeGen/split-lto-unit-input.cpp 
b/clang/test/CodeGen/split-lto-unit-input.cpp
index adfc9ac3e0f446..99de0f68f84978 100644
--- a/clang/test/CodeGen/split-lto-unit-input.cpp
+++ b/clang/test/CodeGen/split-lto-unit-input.cpp
@@ -12,8 +12,8 @@
 // CHECK-NEXT: V _ZTV1A
 // CHECK-NEXT: V _ZTV1B
 
-// CHECK-IR-DAG: _ZTS1B = linkonce_odr constant
-// CHECK-IR-DAG: _ZTS1A = linkonce_odr constant
+// CHECK-IR-DAG: _ZTS1B = linkonce_odr unnamed_addr constant
+// CHECK-IR-DAG: _ZTS1A = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTV1B = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTI1A = linkonce_odr constant
 // CHECK-IR-DAG: _ZTI1B = linkonce_odr constant
diff --git 
a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
index 341c53146d476d..6a833cf3884546 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
@@ -16,7 +16,7 @@
 // The VTable for A is emitted here and in a comdat section since it has no 
key function, and is used in this module when creating an instance of A.
 // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x 
i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr 
@_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x 
i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc 
(i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 
ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, 
i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
-// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
+// CHECK: @_ZTS1A = linkonce_odr unnamed_addr constant [3 x i8] c"1A\00", 
comdat, align 1
 // CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr 
inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A 
}, comdat, align 8
 // CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr 
@_ZTI1A, comdat
 // CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr 
@_ZTV1A.local
diff --git a/clang/test/CodeGenCXX/anonymous-namespaces.cpp 
b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
index f40039c2a4f400..eb185be52c15a4 100644
--- a/clang/test/CodeGenCXX/anonymous-namespaces.cpp
+++ b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
@@ -29,7 +29,7 @@ namespace {
   int D::d = f();
 
   // Check for generation of a VTT with internal linkage
-  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
+  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal unnamed_addr constant
   struct X { 
 struct EBase { };
 struct E : public virtual EBase { virtual ~E() {} };
diff --git a/clang/test/CodeGenCXX/arm64.cpp b/clang/test/CodeGenCXX/arm64.cpp
index 338b7db9e001f2..f452cf9a8b5072 100644
--- a/clang/test/CodeGenCXX/arm64.cpp
+++ b/clang/test/CodeGenCXX/arm64.cpp
@@ -48,20 +48,20 @@ namespace test2 {
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden unnamed_addr 
constant
   // CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden constant { 
{{.*}}, ptr @_ZTSN5test21BE }
 
   const std::type_info &b1 = typeid(B*);
-  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden unn

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread via cfe-commits

https://github.com/luxufan created 
https://github.com/llvm/llvm-project/pull/111343

The RTTI type name global variable should be marked as global unnamed_addr 
since the address of RTTI type name global variable
 is not significant.

>From cabe9e1ac1305d970d944183ebf10effe783f5fc Mon Sep 17 00:00:00 2001
From: luxufan 
Date: Mon, 7 Oct 2024 07:14:06 +
Subject: [PATCH] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr

The RTTI type name global variable should be marked as global
unnamed_addr since the address of RTTI type name global variable
 is not significant.
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp|  1 +
 clang/test/CodeGen/split-lto-unit-input.cpp|  4 ++--
 .../RelativeVTablesABI/parent-vtable-in-comdat.cpp |  2 +-
 clang/test/CodeGenCXX/anonymous-namespaces.cpp |  2 +-
 clang/test/CodeGenCXX/arm64.cpp| 12 ++--
 clang/test/CodeGenCXX/armv7k.cpp   | 14 --
 .../test/CodeGenCXX/windows-itanium-type-info.cpp  | 14 --
 7 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 965e09a7a760ec..4b9cd70ce4d55d 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3532,6 +3532,7 @@ llvm::GlobalVariable 
*ItaniumRTTIBuilder::GetAddrOfTypeName(
   Name, Init->getType(), Linkage, Align.getAsAlign());
 
   GV->setInitializer(Init);
+  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
   return GV;
 }
diff --git a/clang/test/CodeGen/split-lto-unit-input.cpp 
b/clang/test/CodeGen/split-lto-unit-input.cpp
index adfc9ac3e0f446..99de0f68f84978 100644
--- a/clang/test/CodeGen/split-lto-unit-input.cpp
+++ b/clang/test/CodeGen/split-lto-unit-input.cpp
@@ -12,8 +12,8 @@
 // CHECK-NEXT: V _ZTV1A
 // CHECK-NEXT: V _ZTV1B
 
-// CHECK-IR-DAG: _ZTS1B = linkonce_odr constant
-// CHECK-IR-DAG: _ZTS1A = linkonce_odr constant
+// CHECK-IR-DAG: _ZTS1B = linkonce_odr unnamed_addr constant
+// CHECK-IR-DAG: _ZTS1A = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTV1B = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTI1A = linkonce_odr constant
 // CHECK-IR-DAG: _ZTI1B = linkonce_odr constant
diff --git 
a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
index 341c53146d476d..6a833cf3884546 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
@@ -16,7 +16,7 @@
 // The VTable for A is emitted here and in a comdat section since it has no 
key function, and is used in this module when creating an instance of A.
 // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x 
i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr 
@_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x 
i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc 
(i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 
ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, 
i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
-// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
+// CHECK: @_ZTS1A = linkonce_odr unnamed_addr constant [3 x i8] c"1A\00", 
comdat, align 1
 // CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr 
inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A 
}, comdat, align 8
 // CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr 
@_ZTI1A, comdat
 // CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr 
@_ZTV1A.local
diff --git a/clang/test/CodeGenCXX/anonymous-namespaces.cpp 
b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
index f40039c2a4f400..eb185be52c15a4 100644
--- a/clang/test/CodeGenCXX/anonymous-namespaces.cpp
+++ b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
@@ -29,7 +29,7 @@ namespace {
   int D::d = f();
 
   // Check for generation of a VTT with internal linkage
-  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
+  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal unnamed_addr constant
   struct X { 
 struct EBase { };
 struct E : public virtual EBase { virtual ~E() {} };
diff --git a/clang/test/CodeGenCXX/arm64.cpp b/clang/test/CodeGenCXX/arm64.cpp
index 338b7db9e001f2..f452cf9a8b5072 100644
--- a/clang/test/CodeGenCXX/arm64.cpp
+++ b/clang/test/CodeGenCXX/arm64.cpp
@@ -48,20 +48,20 @@ namespace test2 {
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden unnamed_addr 
constant

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread via cfe-commits

luxufan wrote:

The failed test files have not been addressed for all. I will update them once 
this change can be approved.

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


[clang] [AST] Avoid repeated hash lookups (NFC) (PR #111327)

2024-10-07 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [llvm] [ARM] Emit an error when the hard-float ABI is enabled but can't be used. (PR #111334)

2024-10-07 Thread Chris Copeland via cfe-commits

chrisnc wrote:

> It looks like there is already a warning for this in clang, it only triggers 
> from -mfloat-abi=hard though: https://godbolt.org/z/dcaz8had4. Could it be 
> made to work with any hard-float env? And maybe be made an error 
> down-gradable to a warning?
> 
> Generally clang-level warnings/errors are more user friendly then the 
> llvm-level errors (but both may be useful for other frontends).

That seems like a decent improvement to the clang warning, but the backend 
behavior of still emitting the VFP ABI tag in this case seems like a bug, 
regardless of the frontend, so IMO codegen should be aborted in this situation.

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


[clang] da759dd - [Clang][Driver] Add option to provide path for multilib's YAML config file (#109640)

2024-10-07 Thread via cfe-commits

Author: Lucas Duarte Prates
Date: 2024-10-07T08:56:17+01:00
New Revision: da759dda58a7a1cbdaace26c381e1c3c5c5491ce

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

LOG: [Clang][Driver] Add option to provide path for multilib's YAML config file 
(#109640)

Since the introduction of the use of a YAML file to configure the
selection of multilibs for baremetal, the path for that file has been
hardcoded into the clang driver code. This makes it difficult to provide
any alternative configurations for multilib and, by consequence, impacts
the tetability of any changes related to it - e.g. the existing multilib
YAML tests currently rely on creating fake toolchain directories to
inject their own configuration files.

This change introduces a new command line option to the clang driver,
`--multi-lib-config=`, to enable the use of a custom path to be used
when loading the multilib YAML config file. It also updates the existing
multilib YAML tests to use the new option.

Added: 
clang/test/Driver/Inputs/multilib/empty.yaml

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h
clang/test/Driver/baremetal-multilib-custom-error.yaml
clang/test/Driver/baremetal-multilib-exclusive-group.yaml
clang/test/Driver/baremetal-multilib-group-error.yaml
clang/test/Driver/baremetal-multilib-layered.yaml
clang/test/Driver/baremetal-multilib.yaml
clang/test/Driver/print-multi-selection-flags.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 445e681313eba7..90f0c4f2df2130 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5558,6 +5558,9 @@ def mthumb : Flag<["-"], "mthumb">, Group;
 def mtune_EQ : Joined<["-"], "mtune=">, Group,
   Visibility<[ClangOption, FlangOption]>,
   HelpText<"Only supported on AArch64, PowerPC, RISC-V, SPARC, SystemZ, and 
X86">;
+def multi_lib_config : Joined<["-", "--"], "multi-lib-config=">,
+  HelpText<"Path to the YAML configuration file to be used for multilib 
selection">,
+  MetaVarName<"">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 8aed9ed6e18817..92b52e792478b5 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -97,9 +97,23 @@ static bool findRISCVMultilibs(const Driver &D,
   return false;
 }
 
+static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) {
+  if (!D.SysRoot.empty())
+return D.SysRoot;
+
+  SmallString<128> SysRootDir(D.Dir);
+  llvm::sys::path::append(SysRootDir, "..", "lib", "clang-runtimes");
+
+  if (IncludeTriple)
+llvm::sys::path::append(SysRootDir, D.getTargetTriple());
+
+  return std::string(SysRootDir);
+}
+
 BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
  const ArgList &Args)
-: ToolChain(D, Triple, Args) {
+: ToolChain(D, Triple, Args),
+  SysRoot(computeBaseSysRoot(D, /*IncludeTriple=*/true)) {
   getProgramPaths().push_back(getDriver().Dir);
 
   findMultilibs(D, Triple, Args);
@@ -194,26 +208,21 @@ static void findMultilibsFromYAML(const ToolChain &TC, 
const Driver &D,
 
 static constexpr llvm::StringLiteral MultilibFilename = "multilib.yaml";
 
-// Get the sysroot, before multilib takes effect.
-static std::string computeBaseSysRoot(const Driver &D,
-  const llvm::Triple &Triple) {
-  if (!D.SysRoot.empty())
-return D.SysRoot;
-
-  SmallString<128> SysRootDir(D.Dir);
-  llvm::sys::path::append(SysRootDir, "..", "lib", "clang-runtimes");
-
-  SmallString<128> MultilibPath(SysRootDir);
-  llvm::sys::path::append(MultilibPath, MultilibFilename);
-
-  // New behaviour: if multilib.yaml is found then use clang-runtimes as the
-  // sysroot.
-  if (D.getVFS().exists(MultilibPath))
-return std::string(SysRootDir);
-
-  // Otherwise fall back to the old behaviour of appending the target triple.
-  llvm::sys::path::append(SysRootDir, D.getTargetTriple());
-  return std::string(SysRootDir);
+static std::optional>
+getMultilibConfigPath(const Driver &D, const llvm::Triple &Triple,
+  const ArgList &Args) {
+  llvm::SmallString<128> MultilibPath;
+  if (Arg *ConfigFileArg = Args.getLastArg(options::OPT_multi_lib_config)) {
+MultilibPath = ConfigFileArg->getValue();
+if (!D.getVFS().exists(MultilibPath)) {
+  D.Diag(clang::diag::err_drv_no_such_file) << MultilibPath.str();
+ 

[clang] [Clang][Driver] Add option to provide path for multilib's YAML config file (PR #109640)

2024-10-07 Thread Lucas Duarte Prates via cfe-commits

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


[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)

2024-10-07 Thread Yuta Saito via cfe-commits

https://github.com/kateinoigakukun updated 
https://github.com/llvm/llvm-project/pull/111332

>From 605e1ad180c9f75fd59d8b783ae2041cbaf34e50 Mon Sep 17 00:00:00 2001
From: Yuta Saito 
Date: Sat, 5 Oct 2024 16:54:57 +
Subject: [PATCH 1/7] [compiler-rt][profile] Add initial support for
 WebAssembly/WASI

This patch adds initial support for WebAssembly/WASI to the profile
runtime library on the top of wasi-libc. This is a part of the ongoing
patch series to add coverage support for WebAssembly/WASI.

The patch includes the following changes:
* Add wasm32-wasi to the list of supported architectures/OSes.
* Exclude unsupported features for WASI: flock, madvise, uname.
* Enable some user-space emulation provided by wasi-libc: mmap, getpid
---
 .../cmake/Modules/AllSupportedArchDefs.cmake  |  2 +-
 compiler-rt/cmake/config-ix.cmake |  2 +-
 compiler-rt/lib/profile/CMakeLists.txt| 24 +++
 compiler-rt/lib/profile/GCDAProfiling.c   |  2 +-
 compiler-rt/lib/profile/InstrProfilingPort.h  |  2 +-
 compiler-rt/lib/profile/InstrProfilingUtil.c  | 12 ++
 6 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 809e9277156912..d00d39518104bf 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64})
+${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a93a88a9205001..a494e0532a50bc 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ef23492514898b..a6402f80b890a2 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,6 +38,17 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
+CHECK_CXX_SOURCE_COMPILES("
+#include 
+
+int fd;
+int main() {
+  flock(fd, LOCK_EX);
+  return 0;
+}
+
+" COMPILER_RT_TARGET_HAS_FLOCK)
+
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -93,6 +104,13 @@ if(FUCHSIA OR UNIX)
  -Wno-pedantic)
 endif()
 
+if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
+  set(EXTRA_FLAGS
+  ${EXTRA_FLAGS}
+  -D_WASI_EMULATED_MMAN
+  -D_WASI_EMULATED_GETPID)
+endif()
+
 if(COMPILER_RT_TARGET_HAS_ATOMICS)
  set(EXTRA_FLAGS
  ${EXTRA_FLAGS}
@@ -105,6 +123,12 @@ if(COMPILER_RT_TARGET_HAS_FCNTL_LCK)
  -DCOMPILER_RT_HAS_FCNTL_LCK=1)
 endif()
 
+if(COMPILER_RT_TARGET_HAS_FLOCK)
+  set(EXTRA_FLAGS
+  ${EXTRA_FLAGS}
+  -DCOMPILER_RT_HAS_FLOCK=1)
+endif()
+
 if(COMPILER_RT_TARGET_HAS_UNAME)
  set(EXTRA_FLAGS
  ${EXTRA_FLAGS}
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c 
b/compiler-rt/lib/profile/GCDAProfiling.c
index d6e2175169e4a5..a207ddf97c8831 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -584,7 +584,7 @@ void llvm_reset_counters(void) {
   }
 }
 
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__wasi__)
 COMPILER_RT_VISIBILITY
 pid_t __gcov_fork() {
   pid_t parent_pid = getpid();
diff --git a/compiler-rt/lib/profile/InstrProfilingPort.h 
b/compiler-rt/lib/profile/InstrProfilingPort.h
index ed0905cc5f2022..8715a3b0d2a6f0 100644
--- a/compiler-rt/lib/profile/InstrProfilingPort.h
+++ b/compiler-rt/lib/profile/InstrProfilingPort.h
@@ -54,7 +54,7 @@
 #endif
 
 #define COMPILER_RT_MAX_HOSTLEN 128
-#ifdef __ORBIS__
+#if defined(__ORBIS__) || defined(__wasi__)
 #define COMPILER_RT_GETHOSTNAME(Name, Len) ((void)(Name), (void)(Len), (-1))
 #else
 #define COMPILER_RT_GETHOSTNAME(Name, Len) lprofGetHostName(Name, Len)
diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c 
b/compiler-rt/lib/profile/InstrProfilingUtil.c
index 642393d432d7ea..95ec4080ba2504 100644
--- a/compiler-rt/lib/profile/InstrProfilingUtil.c
+++ b/compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -152,9 +152,11 @@ COMPILER_RT_VISIBILITY int lprofLockFd(int fd) {
 }
   }
   return 0;
-#else
+#elif defined(COMPILER_RT_HAS_FLOCK)
   flock(fd, LOCK

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread via cfe-commits

https://github.com/luxufan updated 
https://github.com/llvm/llvm-project/pull/111343

>From cabe9e1ac1305d970d944183ebf10effe783f5fc Mon Sep 17 00:00:00 2001
From: luxufan 
Date: Mon, 7 Oct 2024 07:14:06 +
Subject: [PATCH 1/3] [ItaniumCXXABI] Mark RTTI type name as global
 unnamed_addr

The RTTI type name global variable should be marked as global
unnamed_addr since the address of RTTI type name global variable
 is not significant.
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp|  1 +
 clang/test/CodeGen/split-lto-unit-input.cpp|  4 ++--
 .../RelativeVTablesABI/parent-vtable-in-comdat.cpp |  2 +-
 clang/test/CodeGenCXX/anonymous-namespaces.cpp |  2 +-
 clang/test/CodeGenCXX/arm64.cpp| 12 ++--
 clang/test/CodeGenCXX/armv7k.cpp   | 14 --
 .../test/CodeGenCXX/windows-itanium-type-info.cpp  | 14 --
 7 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 965e09a7a760ec..4b9cd70ce4d55d 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3532,6 +3532,7 @@ llvm::GlobalVariable 
*ItaniumRTTIBuilder::GetAddrOfTypeName(
   Name, Init->getType(), Linkage, Align.getAsAlign());
 
   GV->setInitializer(Init);
+  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
   return GV;
 }
diff --git a/clang/test/CodeGen/split-lto-unit-input.cpp 
b/clang/test/CodeGen/split-lto-unit-input.cpp
index adfc9ac3e0f446..99de0f68f84978 100644
--- a/clang/test/CodeGen/split-lto-unit-input.cpp
+++ b/clang/test/CodeGen/split-lto-unit-input.cpp
@@ -12,8 +12,8 @@
 // CHECK-NEXT: V _ZTV1A
 // CHECK-NEXT: V _ZTV1B
 
-// CHECK-IR-DAG: _ZTS1B = linkonce_odr constant
-// CHECK-IR-DAG: _ZTS1A = linkonce_odr constant
+// CHECK-IR-DAG: _ZTS1B = linkonce_odr unnamed_addr constant
+// CHECK-IR-DAG: _ZTS1A = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTV1B = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTI1A = linkonce_odr constant
 // CHECK-IR-DAG: _ZTI1B = linkonce_odr constant
diff --git 
a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp 
b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
index 341c53146d476d..6a833cf3884546 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
@@ -16,7 +16,7 @@
 // The VTable for A is emitted here and in a comdat section since it has no 
key function, and is used in this module when creating an instance of A.
 // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x 
i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr 
@_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x 
i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc 
(i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 
ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, 
i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
-// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
+// CHECK: @_ZTS1A = linkonce_odr unnamed_addr constant [3 x i8] c"1A\00", 
comdat, align 1
 // CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr 
inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A 
}, comdat, align 8
 // CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr 
@_ZTI1A, comdat
 // CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr 
@_ZTV1A.local
diff --git a/clang/test/CodeGenCXX/anonymous-namespaces.cpp 
b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
index f40039c2a4f400..eb185be52c15a4 100644
--- a/clang/test/CodeGenCXX/anonymous-namespaces.cpp
+++ b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
@@ -29,7 +29,7 @@ namespace {
   int D::d = f();
 
   // Check for generation of a VTT with internal linkage
-  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
+  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal unnamed_addr constant
   struct X { 
 struct EBase { };
 struct E : public virtual EBase { virtual ~E() {} };
diff --git a/clang/test/CodeGenCXX/arm64.cpp b/clang/test/CodeGenCXX/arm64.cpp
index 338b7db9e001f2..f452cf9a8b5072 100644
--- a/clang/test/CodeGenCXX/arm64.cpp
+++ b/clang/test/CodeGenCXX/arm64.cpp
@@ -48,20 +48,20 @@ namespace test2 {
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden unnamed_addr 
constant
   // CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden constant { 
{{.*}}, ptr @_ZTSN5test21BE }
 
   const std::type_info &b1 = typeid(

[clang] [Clang][Driver] Add option to provide path for multilib's YAML config file (PR #109640)

2024-10-07 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `clang` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/18/builds/5012


Here is the relevant piece of the build log for the reference

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: lang/cpp/incomplete-types/TestCppIncompleteTypes.py (795 of 
2809)
PASS: lldb-api :: lang/cpp/keywords_enabled/TestCppKeywordsEnabled.py (796 of 
2809)
PASS: lldb-api :: lang/cpp/inlines/TestInlines.py (797 of 2809)
PASS: lldb-api :: lang/cpp/lambdas/TestLambdas.py (798 of 2809)
PASS: lldb-api :: lang/cpp/llvm-style/TestLLVMStyle.py (799 of 2809)
UNSUPPORTED: lldb-api :: lang/cpp/modules-import/TestCXXModulesImport.py (800 
of 2809)
PASS: lldb-api :: lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py (801 of 
2809)
PASS: lldb-api :: 
lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
 (802 of 2809)
PASS: lldb-api :: lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py 
(803 of 2809)
PASS: lldb-api :: lang/cpp/namespace_conflicts/TestNamespaceConflicts.py (804 
of 2809)
FAIL: lldb-api :: 
lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py (805 of 2809)
 TEST 'lldb-api :: 
lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py' FAILED 

Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/lang/c/shared_lib_stripped_symbols
 -p TestSharedLibStrippedSymbols.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision 
da759dda58a7a1cbdaace26c381e1c3c5c5491ce)
  clang revision da759dda58a7a1cbdaace26c381e1c3c5c5491ce
  llvm revision da759dda58a7a1cbdaace26c381e1c3c5c5491ce
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_expr_dsym (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase) (test 
case does not fall in any category of interest for this run) 
FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_expr_dwarf (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_expr_dwo (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_frame_variable_dsym 
(TestSharedLibStrippedSymbols.SharedLibStrippedTestCase) (test case does not 
fall in any category of interest for this run) 
XFAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_frame_variable_dwarf 
(TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
XFAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: 
test_frame_variable_dwo (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
==
FAIL: test_expr_dwarf (TestSharedLibStrippedSymbols.SharedLibStrippedTestCase)
   Test that types work when defined in a shared library and forwa/d-declared 
in the main executable
--
Traceback (most recent call last):
  File 
"/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1769, in test_method
return attrvalue(self)
  File 
"/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols

[clang] Multilib error fixes (PR #110804)

2024-10-07 Thread Simon Tatham via cfe-commits

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


[clang] [analyzer] Fix wrong `builtin_*_overflow` return type (PR #111253)

2024-10-07 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

@pskrgag Thanks for fixing this issue quickly! :smile: 

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


[clang] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

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


@@ -0,0 +1,201 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z16 | FileCheck %s
+;
+; Tests for 16-bit floating point (half).
+
+; Incoming half arguments added together and returned.
+define half @fun0(half %Op0, half %Op1) {
+; CHECK-LABEL: fun0:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r13, %r15, 104(%r15)
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -168
+; CHECK-NEXT:.cfi_def_cfa_offset 328
+; CHECK-NEXT:std %f8, 160(%r15) # 8-byte Folded Spill
+; CHECK-NEXT:.cfi_offset %f8, -168
+; CHECK-NEXT:vlgvf %r0, %v2, 0
+; CHECK-NEXT:llghr %r2, %r0
+; CHECK-NEXT:vlgvf %r13, %v0, 0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r13
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:aebr %f0, %f8
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:ld %f8, 160(%r15) # 8-byte Folded Reload
+; CHECK-NEXT:vlvgf %v0, %r2, 0
+; CHECK-NEXT:lmg %r13, %r15, 272(%r15)
+; CHECK-NEXT:br %r14
+entry:
+  %Res = fadd half %Op0, %Op1
+  ret half %Res
+}
+
+; The half values are loaded and stored instead.
+define void @fun1(ptr %Op0, ptr %Op1, ptr %Dst) {
+; CHECK-LABEL: fun1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r12, %r15, 96(%r15)
+; CHECK-NEXT:.cfi_offset %r12, -64
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -168
+; CHECK-NEXT:.cfi_def_cfa_offset 328
+; CHECK-NEXT:std %f8, 160(%r15) # 8-byte Folded Spill
+; CHECK-NEXT:.cfi_offset %f8, -168
+; CHECK-NEXT:llgh %r12, 0(%r2)
+; CHECK-NEXT:llgh %r2, 0(%r3)
+; CHECK-NEXT:lgr %r13, %r4
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:lgr %r2, %r12
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:aebr %f0, %f8
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:ld %f8, 160(%r15) # 8-byte Folded Reload
+; CHECK-NEXT:sth %r2, 0(%r13)
+; CHECK-NEXT:lmg %r12, %r15, 264(%r15)
+; CHECK-NEXT:br %r14
+entry:
+  %0 = load half, ptr %Op0, align 2
+  %1 = load half, ptr %Op1, align 2
+  %add = fadd half %0, %1
+  store half %add, ptr %Dst, align 2
+  ret void
+}
+
+; Test a chain of half operations which should have each operation surrounded
+; by conversions to/from fp32 for proper emulation.
+define half @fun2(half %Op0, half %Op1, half %Op2) {
+; CHECK-LABEL: fun2:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r12, %r15, 96(%r15)
+; CHECK-NEXT:.cfi_offset %r12, -64
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -168
+; CHECK-NEXT:.cfi_def_cfa_offset 328
+; CHECK-NEXT:std %f8, 160(%r15) # 8-byte Folded Spill
+; CHECK-NEXT:.cfi_offset %f8, -168
+; CHECK-NEXT:vlgvf %r0, %v2, 0
+; CHECK-NEXT:llghr %r2, %r0
+; CHECK-NEXT:vlgvf %r13, %v4, 0
+; CHECK-NEXT:vlgvf %r12, %v0, 0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r12
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:aebr %f0, %f8
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r2
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r13
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:wfasb %f0, %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:ld %f8, 160(%r15) # 8-byte Folded Reload
+; CHECK-NEXT:vlvgf %v0, %r2, 0
+; CHECK-NEXT:lmg %r12, %r15, 264(%r15)
+; CHECK-NEXT:br %r14
+entry:
+  %A0 = fadd half %Op0, %Op1
+  %Res = fadd half %A0, %Op2
+  ret half %Res
+}
+
+; Store an incoming half argument and return a loaded one.
+define half @fun3(half %Op0, ptr %Dst, ptr %Src) {
+; CHECK-LABEL: fun3:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vlgvf %r0, %v0, 0
+; CHECK-NEXT:sth %r0, 0(%r2)
+; CHECK-NEXT:lh %r0, 0(%r3)
+; CHECK-NEXT:vlvgf %v0, %r0, 0
+; CHECK-NEXT:br %r14
+entry:
+  store half %Op0, ptr %Dst
+
+  %Res = load half, ptr %Src
+  ret half %Res
+}
+
+; Call a function with half argument and return values.
+declare half @foo(half)
+define void @fun4(ptr %Src, ptr %Dst) {
+; CHECK-LABEL: fun4:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r13, %r15, 104(%r15)
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -160
+; CHECK-NEXT:.cfi_def_cfa_offset 320
+; CHECK-NEXT:lh %r0, 0(%r2)
+; CHECK-NEXT:vlvgf %v0, %r0, 0
+; CHEC

[clang] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

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


@@ -0,0 +1,201 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z16 | FileCheck %s
+;
+; Tests for 16-bit floating point (half).
+
+; Incoming half arguments added together and returned.
+define half @fun0(half %Op0, half %Op1) {
+; CHECK-LABEL: fun0:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r13, %r15, 104(%r15)
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -168
+; CHECK-NEXT:.cfi_def_cfa_offset 328
+; CHECK-NEXT:std %f8, 160(%r15) # 8-byte Folded Spill
+; CHECK-NEXT:.cfi_offset %f8, -168
+; CHECK-NEXT:vlgvf %r0, %v2, 0
+; CHECK-NEXT:llghr %r2, %r0
+; CHECK-NEXT:vlgvf %r13, %v0, 0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r13
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:aebr %f0, %f8
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:ld %f8, 160(%r15) # 8-byte Folded Reload
+; CHECK-NEXT:vlvgf %v0, %r2, 0
+; CHECK-NEXT:lmg %r13, %r15, 272(%r15)
+; CHECK-NEXT:br %r14
+entry:
+  %Res = fadd half %Op0, %Op1
+  ret half %Res
+}
+
+; The half values are loaded and stored instead.
+define void @fun1(ptr %Op0, ptr %Op1, ptr %Dst) {
+; CHECK-LABEL: fun1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r12, %r15, 96(%r15)
+; CHECK-NEXT:.cfi_offset %r12, -64
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -168
+; CHECK-NEXT:.cfi_def_cfa_offset 328
+; CHECK-NEXT:std %f8, 160(%r15) # 8-byte Folded Spill
+; CHECK-NEXT:.cfi_offset %f8, -168
+; CHECK-NEXT:llgh %r12, 0(%r2)
+; CHECK-NEXT:llgh %r2, 0(%r3)
+; CHECK-NEXT:lgr %r13, %r4
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:lgr %r2, %r12
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:aebr %f0, %f8
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:ld %f8, 160(%r15) # 8-byte Folded Reload
+; CHECK-NEXT:sth %r2, 0(%r13)
+; CHECK-NEXT:lmg %r12, %r15, 264(%r15)
+; CHECK-NEXT:br %r14
+entry:
+  %0 = load half, ptr %Op0, align 2
+  %1 = load half, ptr %Op1, align 2
+  %add = fadd half %0, %1
+  store half %add, ptr %Dst, align 2
+  ret void
+}
+
+; Test a chain of half operations which should have each operation surrounded
+; by conversions to/from fp32 for proper emulation.
+define half @fun2(half %Op0, half %Op1, half %Op2) {
+; CHECK-LABEL: fun2:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r12, %r15, 96(%r15)
+; CHECK-NEXT:.cfi_offset %r12, -64
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -168
+; CHECK-NEXT:.cfi_def_cfa_offset 328
+; CHECK-NEXT:std %f8, 160(%r15) # 8-byte Folded Spill
+; CHECK-NEXT:.cfi_offset %f8, -168
+; CHECK-NEXT:vlgvf %r0, %v2, 0
+; CHECK-NEXT:llghr %r2, %r0
+; CHECK-NEXT:vlgvf %r13, %v4, 0
+; CHECK-NEXT:vlgvf %r12, %v0, 0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r12
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:aebr %f0, %f8
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r2
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:llghr %r2, %r13
+; CHECK-NEXT:ldr %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_h2f_ieee@PLT
+; CHECK-NEXT:wfasb %f0, %f8, %f0
+; CHECK-NEXT:brasl %r14, __gnu_f2h_ieee@PLT
+; CHECK-NEXT:ld %f8, 160(%r15) # 8-byte Folded Reload
+; CHECK-NEXT:vlvgf %v0, %r2, 0
+; CHECK-NEXT:lmg %r12, %r15, 264(%r15)
+; CHECK-NEXT:br %r14
+entry:
+  %A0 = fadd half %Op0, %Op1
+  %Res = fadd half %A0, %Op2
+  ret half %Res
+}
+
+; Store an incoming half argument and return a loaded one.
+define half @fun3(half %Op0, ptr %Dst, ptr %Src) {
+; CHECK-LABEL: fun3:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vlgvf %r0, %v0, 0
+; CHECK-NEXT:sth %r0, 0(%r2)
+; CHECK-NEXT:lh %r0, 0(%r3)
+; CHECK-NEXT:vlvgf %v0, %r0, 0
+; CHECK-NEXT:br %r14
+entry:
+  store half %Op0, ptr %Dst
+
+  %Res = load half, ptr %Src
+  ret half %Res
+}
+
+; Call a function with half argument and return values.
+declare half @foo(half)
+define void @fun4(ptr %Src, ptr %Dst) {
+; CHECK-LABEL: fun4:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stmg %r13, %r15, 104(%r15)
+; CHECK-NEXT:.cfi_offset %r13, -56
+; CHECK-NEXT:.cfi_offset %r14, -48
+; CHECK-NEXT:.cfi_offset %r15, -40
+; CHECK-NEXT:aghi %r15, -160
+; CHECK-NEXT:.cfi_def_cfa_offset 320
+; CHECK-NEXT:lh %r0, 0(%r2)
+; CHECK-NEXT:vlvgf %v0, %r0, 0
+; CHEC

[clang] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

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


@@ -1597,6 +1618,15 @@ bool SystemZTargetLowering::splitValueIntoRegisterParts(
 return true;
   }
 
+  // Convert f16 to f32 (Out-arg).
+  if (PartVT == MVT::f16) {
+assert(NumParts == 1 && "");

arsenm wrote:

Remove && "" or make it a meaningful message 

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


[clang] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

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


@@ -784,6 +791,20 @@ bool SystemZTargetLowering::useSoftFloat() const {
   return Subtarget.hasSoftFloat();
 }
 
+MVT SystemZTargetLowering::getRegisterTypeForCallingConv(
+  LLVMContext &Context, CallingConv::ID CC,
+  EVT VT) const {
+  // 128-bit single-element vector types are passed like other vectors,
+  // not like their element type.
+  if (VT.isVector() && VT.getSizeInBits() == 128 &&
+  VT.getVectorNumElements() == 1)
+return MVT::v16i8;
+  // Keep f16 so that they can be recognized and handled.
+  if (VT == MVT::f16)

arsenm wrote:

I assume this is because it's an illegal type. It would be much nicer if 
calling convention code just always worked on the original types to begin with 

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


[clang] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

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


@@ -784,6 +791,20 @@ bool SystemZTargetLowering::useSoftFloat() const {
   return Subtarget.hasSoftFloat();
 }
 
+MVT SystemZTargetLowering::getRegisterTypeForCallingConv(
+  LLVMContext &Context, CallingConv::ID CC,
+  EVT VT) const {
+  // 128-bit single-element vector types are passed like other vectors,
+  // not like their element type.
+  if (VT.isVector() && VT.getSizeInBits() == 128 &&
+  VT.getVectorNumElements() == 1)
+return MVT::v16i8;

arsenm wrote:

Seems unrelated? 

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


  1   2   3   4   5   >