[clang] 0665669 - [Sema] Mark alias/ifunc targets used and consider mangled names

2024-04-16 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2024-04-16T11:49:25-07:00
New Revision: 0665669876cd7f51f7572cff3bb97485d78f5de5

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

LOG: [Sema] Mark alias/ifunc targets used and consider mangled names

https://reviews.llvm.org/D54188 marked "alias" targets as used in C to
fix -Wunused false positives. This patch extends the approach to handle
mangled names to support global scope names in C++ and the
`overloadable` attribute in C.

(Note: we should skip `UsingShadowDecl`, which would trigger an
assertion failure in `ItaniumMangleContextImpl::mangleCXXName`.
See regression test added by commit 1c2afbae9af22b58190c10e3517242d01d89d612.)

In addition, we mark ifunc targets as used to fix #63957 (temporarily
used by xz; ifunc was removed by
https://github.com/tukaani-project/xz/commit/689ae2427342a2ea1206eb5ca08301baf410e7e0)

While our approach has false negatives for namespace scope names, the
majority of alias/ifunc C++ uses (global scope with no overloads) are
handled.

Note: The following function with internal linkage but C language
linkage type is mangled in Clang but not in GCC. This inconsistency
makes alias/ifunc difficult to use in C++ with portability (#88593).
```
extern "C" {
static void f0() {}
// GCC: void g0() __attribute__((alias("_ZL2f0v")));
// Clang: void g0() __attribute__((alias("f0")));
}
```

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

Added: 


Modified: 
clang/lib/Sema/CMakeLists.txt
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/AST/ast-dump-attr-json.cpp
clang/test/Sema/alias-unused-win.cpp
clang/test/Sema/alias-unused.cpp
utils/bazel/llvm-project-overlay/clang/BUILD.bazel

Removed: 




diff  --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index ab3b813a9ccd97..a96439df664228 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Core
+  Demangle
   FrontendHLSL
   FrontendOpenMP
   MC

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index b7b1fbc625a150..c3bf18a3f79e23 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -45,6 +45,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/Assumptions.h"
 #include "llvm/MC/MCSectionMachO.h"
 #include "llvm/Support/Error.h"
@@ -1983,6 +1984,38 @@ static void handleWeakRefAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   D->addAttr(::new (S.Context) WeakRefAttr(S.Context, AL));
 }
 
+// Mark alias/ifunc target as used. Due to name mangling, we look up the
+// demangled name ignoring parameters (not supported by microsoftDemangle
+// https://github.com/llvm/llvm-project/issues/88825). This should handle the
+// majority of use cases while leaving namespace scope names unmarked.
+static void markUsedForAliasOrIfunc(Sema &S, Decl *D, const ParsedAttr &AL,
+StringRef Str) {
+  std::unique_ptr Demangled;
+  if (S.getASTContext().getCXXABIKind() != TargetCXXABI::Microsoft)
+Demangled.reset(llvm::itaniumDemangle(Str, /*ParseParams=*/false));
+  std::unique_ptr MC(S.Context.createMangleContext());
+  SmallString<256> Name;
+
+  const DeclarationNameInfo Target(
+  &S.Context.Idents.get(Demangled ? Demangled.get() : Str), AL.getLoc());
+  LookupResult LR(S, Target, Sema::LookupOrdinaryName);
+  if (S.LookupName(LR, S.TUScope)) {
+for (NamedDecl *ND : LR) {
+  if (!isa(ND) && !isa(ND))
+continue;
+  if (MC->shouldMangleDeclName(ND)) {
+llvm::raw_svector_ostream Out(Name);
+Name.clear();
+MC->mangleName(GlobalDecl(ND), Out);
+  } else {
+Name = ND->getIdentifier()->getName();
+  }
+  if (Name == Str)
+ND->markUsed(S.Context);
+}
+  }
+}
+
 static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   StringRef Str;
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
@@ -1995,6 +2028,7 @@ static void handleIFuncAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 return;
   }
 
+  markUsedForAliasOrIfunc(S, D, AL, Str);
   D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str));
 }
 
@@ -2029,17 +2063,7 @@ static void handleAliasAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
   }
 
-  // Mark target used to prevent unneeded-internal-declaration warnings.
-  if (!S.LangOpts.CPlusPlus) {
-// FIXME: demangle Str for C++, as the attribute refers to the mangled
-// linkage name, not the pre-mangled identifier.
-const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
-LookupResult LR(S, target, Sema::LookupOrdinaryName);
-

[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #88902)

2024-04-16 Thread via cfe-commits


@@ -1,5 +1,5 @@
-// RUN: %clang -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
-// Issue no: 41441
+// RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm 
-o - %s | FileCheck %s
+
 #include 

dyung wrote:

It does:

https://lab.llvm.org/buildbot/#/builders/280/builds/1989
```
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/SemaCXX/PR41441.cpp:3:10:
 fatal error: 'new' file not found
3 | #include 
  |  ^
1 error generated.
```

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


[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)

2024-04-16 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian created 
https://github.com/llvm/llvm-project/pull/88963

Consider the following snippet from the discussion of 
[CWG2847](https://cplusplus.github.io/CWG/issues/2847.html) on the [core 
reflector](https://lists.isocpp.org/core/2024/04/15720.php) ([godbolt 
link](https://godbolt.org/z/dvvef9xzM)):
```cpp
template
concept C = sizeof(T) <= sizeof(long);

template
struct A 
{
template
void f(U) requires C; // #1, declares a function template 

void g() requires C; // #2, declares a function

template<>
void f(char);  // #3, an explicit specialization of a function template 
that declares a function
};

template<>
template
void A::f(U) requires C; // #4, an explicit specialization of a 
function template that declares a function template

template<>
template<>
void A::f(int); // #5, an explicit specialization of a function template 
that declares a function

template<>
void A::g(); // #6, an explicit specialization of a function that 
declares a function
```

A number of problems exist:
- Clang rejects `#4` because the trailing _requires-clause_ has `U` substituted 
with the wrong template parameter depth when 
`Sema::AreConstraintExpressionsEqual` is called to determine whether it matches 
the trailing _requires-clause_ of the implicitly instantiated function template.
- Clang rejects `#5` because the function template specialization instantiated 
from `A::f` has a trailing _requires-clause_, but `#5` does not (nor can 
it have one as it isn't a templated function).
- Clang rejects `#6` for the same reasons it rejects `#5`.

This patch resolves these issues by making the following changes:
- To fix `#4`, `Sema::AreConstraintExpressionsEqual` is passed 
`FunctionTemplateDecl`s when comparing the trailing _requires-clauses_ of `#4` 
and the function template instantiated from `#1`.
- To fix `#5` and `#6`, the trailing _requires-clauses_ are not compared for 
explicit specializations that declare functions.

In addition to these changes, `CheckMemberSpecialization` now considers 
constraint satisfaction/constraint partial ordering when determining which 
member function is specialized by an explicit specialization of a member 
function for an implicit instantiation of a class template.

>From ede52d5020c12b1a3010c6637bb2fad0157da79e Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 16 Apr 2024 13:36:11 -0400
Subject: [PATCH] [Clang][Sema] Improve support for explicit specializations of
 constrained member functions & member function templates

---
 clang/lib/Sema/SemaConcept.cpp|  2 +-
 clang/lib/Sema/SemaOverload.cpp   | 11 ++-
 clang/lib/Sema/SemaTemplate.cpp   | 44 +--
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  4 +
 .../CXX/temp/temp.spec/temp.expl.spec/p8.cpp  | 74 +++
 5 files changed, 124 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p8.cpp

diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index e00c972602829e..7bfec4e11f7aab 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -811,7 +811,7 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // this may happen while we're comparing two templates' constraint
   // equivalence.
   LocalInstantiationScope ScopeForParameters(S);
-  if (auto *FD = llvm::dyn_cast(DeclInfo.getDecl()))
+  if (auto *FD = DeclInfo.getDecl()->getAsFunction())
 for (auto *PVD : FD->parameters())
   ScopeForParameters.InstantiatedLocal(PVD, PVD);
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 227ef564ba3e08..594cfc58d2226a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1303,6 +1303,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   if (New->isMSVCRTEntryPoint())
 return false;
 
+  NamedDecl *OldDecl = Old;
+  NamedDecl *NewDecl = New;
   FunctionTemplateDecl *OldTemplate = Old->getDescribedFunctionTemplate();
   FunctionTemplateDecl *NewTemplate = New->getDescribedFunctionTemplate();
 
@@ -1347,6 +1349,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   // references to non-instantiated entities during constraint substitution.
   // GH78101.
   if (NewTemplate) {
+OldDecl = OldTemplate;
+NewDecl = NewTemplate;
 // C++ [temp.over.link]p4:
 //   The signature of a function template consists of its function
 //   signature, its return type and its template parameter list. The names
@@ -1506,13 +1510,14 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
 }
   }
 
-  if (!UseOverrideRules) {
+  if (!UseOverrideRules &&
+  New->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) {
 Expr *NewRC = New->getTrailingRequiresClause(),
  *OldRC = Old->getTrailingRequiresClause();
 if ((NewRC != nullptr) != (O

[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)

2024-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)


Changes

Consider the following snippet from the discussion of 
[CWG2847](https://cplusplus.github.io/CWG/issues/2847.html) on the [core 
reflector](https://lists.isocpp.org/core/2024/04/15720.php) ([godbolt 
link](https://godbolt.org/z/dvvef9xzM)):
```cpp
template
concept C = sizeof(T) <= sizeof(long);

template
struct A 
{
template
void f(U) requires C; // #1, declares a function template 

void g() requires C; // #2, declares a function

template<>
void f(char);  // #3, an explicit specialization of a function 
template that declares a function
};

template<>
template
void A::f(U) requires C; // #4, an explicit 
specialization of a function template that declares a function template

template<>
template<>
void A::f(int); // #5, an explicit specialization of a 
function template that declares a function

template<>
void A::g(); // #6, an explicit specialization of a 
function that declares a function
```

A number of problems exist:
- Clang rejects `#4` because the trailing _requires-clause_ has `U` 
substituted with the wrong template parameter depth when 
`Sema::AreConstraintExpressionsEqual` is called to determine whether it matches 
the trailing _requires-clause_ of the implicitly instantiated function template.
- Clang rejects `#5` because the function template specialization 
instantiated from `A::f` has a trailing _requires-clause_, but 
`#5` does not (nor can it have one as it isn't a templated function).
- Clang rejects `#6` for the same reasons it rejects `#5`.

This patch resolves these issues by making the following changes:
- To fix `#4`, `Sema::AreConstraintExpressionsEqual` is passed 
`FunctionTemplateDecl`s when comparing the trailing _requires-clauses_ of 
`#4` and the function template instantiated from `#1`.
- To fix `#5` and `#6`, the trailing _requires-clauses_ are not 
compared for explicit specializations that declare functions.

In addition to these changes, `CheckMemberSpecialization` now considers 
constraint satisfaction/constraint partial ordering when determining which 
member function is specialized by an explicit specialization of a member 
function for an implicit instantiation of a class template.

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


5 Files Affected:

- (modified) clang/lib/Sema/SemaConcept.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+8-3) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+37-7) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+4) 
- (added) clang/test/CXX/temp/temp.spec/temp.expl.spec/p8.cpp (+74) 


``diff
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index e00c972602829e..7bfec4e11f7aab 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -811,7 +811,7 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // this may happen while we're comparing two templates' constraint
   // equivalence.
   LocalInstantiationScope ScopeForParameters(S);
-  if (auto *FD = llvm::dyn_cast(DeclInfo.getDecl()))
+  if (auto *FD = DeclInfo.getDecl()->getAsFunction())
 for (auto *PVD : FD->parameters())
   ScopeForParameters.InstantiatedLocal(PVD, PVD);
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 227ef564ba3e08..594cfc58d2226a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1303,6 +1303,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   if (New->isMSVCRTEntryPoint())
 return false;
 
+  NamedDecl *OldDecl = Old;
+  NamedDecl *NewDecl = New;
   FunctionTemplateDecl *OldTemplate = Old->getDescribedFunctionTemplate();
   FunctionTemplateDecl *NewTemplate = New->getDescribedFunctionTemplate();
 
@@ -1347,6 +1349,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   // references to non-instantiated entities during constraint substitution.
   // GH78101.
   if (NewTemplate) {
+OldDecl = OldTemplate;
+NewDecl = NewTemplate;
 // C++ [temp.over.link]p4:
 //   The signature of a function template consists of its function
 //   signature, its return type and its template parameter list. The names
@@ -1506,13 +1510,14 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
 }
   }
 
-  if (!UseOverrideRules) {
+  if (!UseOverrideRules &&
+  New->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) {
 Expr *NewRC = New->getTrailingRequiresClause(),
  *OldRC = Old->getTrailingRequiresClause();
 if ((NewRC != nullptr) != (OldRC != nullptr))
   return true;
-
-if (NewRC && !SemaRef.AreConstraintExpressionsEqual(Old, OldRC, New, 
NewRC))
+if (NewRC &&
+!SemaRef.AreConstraintExpressionsEqual(OldDecl, OldRC, NewDecl, NewRC

[clang] [clang] Add flag to experiment with cold function attributes (PR #88793)


david-xl wrote:

Is there a need for a small test case?

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


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #88902)



@@ -1,5 +1,5 @@
-// RUN: %clang -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
-// Issue no: 41441
+// RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm 
-o - %s | FileCheck %s
+
 #include 

erichkeane wrote:

Blarg, the buildbots i checked on were mangling differences.  I'll fix this 
locally as I suggested and get a fix merged ASAP.


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


[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)


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


[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)


https://github.com/erichkeane commented:

Approach/fix looks fine, other than release notes + tests, LGTM.

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


[clang] [clang][SPIR-V] Set AS for the SPIR-V logical triple (PR #88939)


bogner wrote:

> a) Thanks!; b) apologies for the noise; c) this was actually done on purpose, 
> I actively eschewed changing Logical SPIRV because it wasn't actually clear 
> to me if in the long run it'd have the same AS map / would use numerical 1 
> for globals. If Logical SPIRV is going to go with numerical 1 for globals, 
> LGTM (perhaps it's worth reflecting that in 
> [AutoUpgrade.cpp](https://github.com/llvm/llvm-project/blob/75054525ae58f26c86e418382164540760871186/llvm/lib/IR/AutoUpgrade.cpp#L5346)
>  & associated tests, wherein the predicate guards autoupgrades from occuring 
> on Logical SPIRV)!
> 
> As a sidenote, as far as I can tell, this flared up because in LLVM's [SPIRV 
> TargetMachine](https://github.com/llvm/llvm-project/blob/75054525ae58f26c86e418382164540760871186/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp#L56)
>  there's no segregation between Logical & Physical SPIRV. Would it be 
> worthwhile to add that?

@Keenuts Do you have thoughts here? I'm not sure there's been much discussion 
around this.

I'm going to go ahead and push this as is to get the tests passing and we 
should follow up as necessary.

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


[clang] b0ddbfb - [clang][SPIR-V] Set AS for the SPIR-V logical triple (#88939)


Author: Justin Bogner
Date: 2024-04-16T12:09:32-07:00
New Revision: b0ddbfb77d15e00e08fc36f6ccd8a4fecde465d1

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

LOG: [clang][SPIR-V] Set AS for the SPIR-V logical triple (#88939)

This was missed in #88455, causing most of the .hlsl to SPIR-V tests to
fail (such as clang\test\Driver\hlsl-lang-targets-spirv.hlsl)

Added: 


Modified: 
clang/lib/Basic/Targets/SPIR.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 9a4a8b501460b6..44265445ff004b 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -315,7 +315,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVTargetInfo : public 
BaseSPIRVTargetInfo {
 // SPIR-V IDs are represented with a single 32-bit word.
 SizeType = TargetInfo::UnsignedInt;
 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,



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


[clang] [clang][SPIR-V] Set AS for the SPIR-V logical triple (PR #88939)


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


[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)


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

As explained in https://github.com/ARM-software/acle/pull/315 we are 
deprecating features which aren't adding any value.

>From 9c2dc3240d79e4a05015bcc60a300e94971ae983 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Tue, 16 Apr 2024 19:42:07 +0100
Subject: [PATCH] [FMV] Remove useless features according the latest ACLE spec.

As explained in https://github.com/ARM-software/acle/pull/315
we are deprecating features which aren't adding any value.
---
 clang/test/CodeGen/aarch64-cpu-supports.c |  24 +-
 .../CodeGen/aarch64-mixed-target-attributes.c |  12 +-
 .../test/CodeGen/attr-target-clones-aarch64.c |  77 ++---
 clang/test/CodeGen/attr-target-version.c  | 326 +-
 .../CodeGenCXX/attr-target-clones-aarch64.cpp |  41 +--
 clang/test/CodeGenCXX/attr-target-version.cpp |  22 +-
 clang/test/Sema/aarch64-cpu-supports.c|   2 +-
 clang/test/Sema/attr-target-clones-aarch64.c  |  21 +-
 clang/test/Sema/attr-target-version.c |  18 +-
 clang/test/SemaCXX/attr-target-version.cpp|  16 +-
 compiler-rt/lib/builtins/cpu_model/aarch64.c  |  17 +-
 .../builtins/cpu_model/aarch64/fmv/apple.inc  |   6 +-
 .../cpu_model/aarch64/fmv/fuchsia.inc |   4 -
 .../builtins/cpu_model/aarch64/fmv/mrs.inc|  42 +--
 .../llvm/TargetParser/AArch64TargetParser.h   |  36 +-
 15 files changed, 287 insertions(+), 377 deletions(-)

diff --git a/clang/test/CodeGen/aarch64-cpu-supports.c 
b/clang/test/CodeGen/aarch64-cpu-supports.c
index c54b7475a3fd5f..7fad9724dfb6c5 100644
--- a/clang/test/CodeGen/aarch64-cpu-supports.c
+++ b/clang/test/CodeGen/aarch64-cpu-supports.c
@@ -1,15 +1,17 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --version 2
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
 
+//.
 // CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
+//.
 // CHECK-LABEL: define dso_local i32 @main
 // CHECK-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store i32 0, ptr [[RETVAL]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 70368744177664
-// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 70368744177664
+// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 34359738368
+// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 34359738368
 // CHECK-NEXT:[[TMP3:%.*]] = and i1 true, [[TMP2]]
 // CHECK-NEXT:br i1 [[TMP3]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
 // CHECK:   if.then:
@@ -17,8 +19,8 @@
 // CHECK-NEXT:br label [[RETURN:%.*]]
 // CHECK:   if.end:
 // CHECK-NEXT:[[TMP4:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP5:%.*]] = and i64 [[TMP4]], 9070970929152
-// CHECK-NEXT:[[TMP6:%.*]] = icmp eq i64 [[TMP5]], 9070970929152
+// CHECK-NEXT:[[TMP5:%.*]] = and i64 [[TMP4]], 17716740096
+// CHECK-NEXT:[[TMP6:%.*]] = icmp eq i64 [[TMP5]], 17716740096
 // CHECK-NEXT:[[TMP7:%.*]] = and i1 true, [[TMP6]]
 // CHECK-NEXT:br i1 [[TMP7]], label [[IF_THEN1:%.*]], label [[IF_END2:%.*]]
 // CHECK:   if.then1:
@@ -26,8 +28,8 @@
 // CHECK-NEXT:br label [[RETURN]]
 // CHECK:   if.end2:
 // CHECK-NEXT:[[TMP8:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP9:%.*]] = and i64 [[TMP8]], 166633186212708352
-// CHECK-NEXT:[[TMP10:%.*]] = icmp eq i64 [[TMP9]], 166633186212708352
+// CHECK-NEXT:[[TMP9:%.*]] = and i64 [[TMP8]], 5222680231936
+// CHECK-NEXT:[[TMP10:%.*]] = icmp eq i64 [[TMP9]], 5222680231936
 // CHECK-NEXT:[[TMP11:%.*]] = and i1 true, [[TMP10]]
 // CHECK-NEXT:br i1 [[TMP11]], label [[IF_THEN3:%.*]], label 
[[IF_END4:%.*]]
 // CHECK:   if.then3:
@@ -49,10 +51,10 @@ int main(void) {
   if (__builtin_cpu_supports("sb"))
 return 1;
 
-  if (__builtin_cpu_supports("sve2-pmull128+memtag"))
+  if (__builtin_cpu_supports("sve2-aes+memtag"))
 return 2;
 
-  if (__builtin_cpu_supports("sme2+ls64_v+wfxt"))
+  if (__builtin_cpu_supports("sme2+ls64+wfxt"))
 return 3;
 
   if (__builtin_cpu_supports("avx2"))
@@ -60,3 +62,9 @@ int main(void) {
 
   return 0;
 }
+//.
+// CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+//.
+// CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
+// CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
+//.
diff --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index aef6ce36ab1c05..be290ff9ecee67 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -69,8 +69,8 @@ __attribute__((target_version("jscvt"))) int 
d

[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)


llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alexandros Lamprineas (labrinea)


Changes

As explained in https://github.com/ARM-software/acle/pull/315 we are 
deprecating features which aren't adding any value.

---

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


15 Files Affected:

- (modified) clang/test/CodeGen/aarch64-cpu-supports.c (+16-8) 
- (modified) clang/test/CodeGen/aarch64-mixed-target-attributes.c (+6-6) 
- (modified) clang/test/CodeGen/attr-target-clones-aarch64.c (+38-39) 
- (modified) clang/test/CodeGen/attr-target-version.c (+162-164) 
- (modified) clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp (+19-22) 
- (modified) clang/test/CodeGenCXX/attr-target-version.cpp (+11-11) 
- (modified) clang/test/Sema/aarch64-cpu-supports.c (+1-1) 
- (modified) clang/test/Sema/attr-target-clones-aarch64.c (+10-11) 
- (modified) clang/test/Sema/attr-target-version.c (+9-9) 
- (modified) clang/test/SemaCXX/attr-target-version.cpp (+8-8) 
- (modified) compiler-rt/lib/builtins/cpu_model/aarch64.c (+1-16) 
- (modified) compiler-rt/lib/builtins/cpu_model/aarch64/fmv/apple.inc (+1-5) 
- (modified) compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fuchsia.inc (-4) 
- (modified) compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc (+2-40) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+3-33) 


``diff
diff --git a/clang/test/CodeGen/aarch64-cpu-supports.c 
b/clang/test/CodeGen/aarch64-cpu-supports.c
index c54b7475a3fd5f..7fad9724dfb6c5 100644
--- a/clang/test/CodeGen/aarch64-cpu-supports.c
+++ b/clang/test/CodeGen/aarch64-cpu-supports.c
@@ -1,15 +1,17 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --version 2
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
 
+//.
 // CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
+//.
 // CHECK-LABEL: define dso_local i32 @main
 // CHECK-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store i32 0, ptr [[RETVAL]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 70368744177664
-// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 70368744177664
+// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 34359738368
+// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 34359738368
 // CHECK-NEXT:[[TMP3:%.*]] = and i1 true, [[TMP2]]
 // CHECK-NEXT:br i1 [[TMP3]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
 // CHECK:   if.then:
@@ -17,8 +19,8 @@
 // CHECK-NEXT:br label [[RETURN:%.*]]
 // CHECK:   if.end:
 // CHECK-NEXT:[[TMP4:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP5:%.*]] = and i64 [[TMP4]], 9070970929152
-// CHECK-NEXT:[[TMP6:%.*]] = icmp eq i64 [[TMP5]], 9070970929152
+// CHECK-NEXT:[[TMP5:%.*]] = and i64 [[TMP4]], 17716740096
+// CHECK-NEXT:[[TMP6:%.*]] = icmp eq i64 [[TMP5]], 17716740096
 // CHECK-NEXT:[[TMP7:%.*]] = and i1 true, [[TMP6]]
 // CHECK-NEXT:br i1 [[TMP7]], label [[IF_THEN1:%.*]], label [[IF_END2:%.*]]
 // CHECK:   if.then1:
@@ -26,8 +28,8 @@
 // CHECK-NEXT:br label [[RETURN]]
 // CHECK:   if.end2:
 // CHECK-NEXT:[[TMP8:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP9:%.*]] = and i64 [[TMP8]], 166633186212708352
-// CHECK-NEXT:[[TMP10:%.*]] = icmp eq i64 [[TMP9]], 166633186212708352
+// CHECK-NEXT:[[TMP9:%.*]] = and i64 [[TMP8]], 5222680231936
+// CHECK-NEXT:[[TMP10:%.*]] = icmp eq i64 [[TMP9]], 5222680231936
 // CHECK-NEXT:[[TMP11:%.*]] = and i1 true, [[TMP10]]
 // CHECK-NEXT:br i1 [[TMP11]], label [[IF_THEN3:%.*]], label 
[[IF_END4:%.*]]
 // CHECK:   if.then3:
@@ -49,10 +51,10 @@ int main(void) {
   if (__builtin_cpu_supports("sb"))
 return 1;
 
-  if (__builtin_cpu_supports("sve2-pmull128+memtag"))
+  if (__builtin_cpu_supports("sve2-aes+memtag"))
 return 2;
 
-  if (__builtin_cpu_supports("sme2+ls64_v+wfxt"))
+  if (__builtin_cpu_supports("sme2+ls64+wfxt"))
 return 3;
 
   if (__builtin_cpu_supports("avx2"))
@@ -60,3 +62,9 @@ int main(void) {
 
   return 0;
 }
+//.
+// CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+//.
+// CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
+// CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
+//.
diff --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index aef6ce36ab1c05..be290ff9ecee67 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -69,8 +69,8 @@ __attribute__((target_version("jscvt"))) int 
default_def_with_version_decls(void
 //

[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)


labrinea wrote:

In a follow up patch I will be sorting out inconsistencies in TargetParser 
regarding:
* features without corresponding ArchExtKind
* features without (Neg)Feature string
* features with incorrect DependentFeatures string

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


[clang] 0a789ea - Fix test from #83124 and #88902


Author: erichkeane
Date: 2024-04-16T12:13:50-07:00
New Revision: 0a789ea8a829da345e46d8224d73b2ddaba6969f

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

LOG: Fix test from #83124 and #88902

This just replaces an '#include' with a declaration of array
placement new.

Added: 


Modified: 
clang/test/SemaCXX/PR41441.cpp

Removed: 




diff  --git a/clang/test/SemaCXX/PR41441.cpp b/clang/test/SemaCXX/PR41441.cpp
index 0b012b33fce343..d0f2917e52f211 100644
--- a/clang/test/SemaCXX/PR41441.cpp
+++ b/clang/test/SemaCXX/PR41441.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm 
-o - %s | FileCheck %s
 
-#include 
+namespace std {
+  using size_t = decltype(sizeof(int));
+};
+void* operator new[](std::size_t, void*) noexcept;
 
 // CHECK: call void @llvm.memset.p0.i64(ptr align 1 %x, i8 0, i64 8, i1 false)
 // CHECK: call void @llvm.memset.p0.i64(ptr align 16 %x, i8 0, i64 32, i1 
false)



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


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #88902)



@@ -1,5 +1,5 @@
-// RUN: %clang -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
-// Issue no: 41441
+// RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm 
-o - %s | FileCheck %s
+
 #include 

erichkeane wrote:

Should be good as of 0a789ea8a

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


[clang] [clang] Fix high memory consumption during pack deduction (PR #88637)


cor3ntin wrote:

@mizvekov are you able to take a look at this? Thanks!

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


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)


estewart08 wrote:

> > Is it expected now that `clang --print-runtime-dir` will always have the 
> > clang host triple appended even if `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is 
> > off? I guess I was expecting to see `lib/linux` instead of 
> > `lib/x86_64-unknown-linux-gnu`.
> 
> https://reviews.llvm.org/D98868 introduced `--print-runtime-dir`. The 
> question is whether `--print-runtime-dir` should print the legacy `lib/linux` 
> when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is off. Personally I'd hope that 
> `--print-runtime-dir` does not try to be smart and users should be able to 
> expect that it always prints the new hierarchy.
> 
> With the old hierarchy, the user is expected to know how to derive 
> `libclang_rt.builtins-aarch64.a` from `libclang_rt.builtins.a`. In this case, 
> they can extract the directory name from `clang 
> --print-file-name=libclang_rt.builtins-aarch64.a`.

Just odd that a legitimate configuration 
`LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF`, unless this configuration is no 
longer valid, will result in a non-existent path being returned for the runtime 
directory.

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


[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)


jroelofs wrote:

Mind listing which ones are affected in the commit summary?

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


[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)


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


[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)


https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/88965

>From 22dffaef7a1f8e3cd8efdbf51536e38986d622ea Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Tue, 16 Apr 2024 19:42:07 +0100
Subject: [PATCH] [FMV] Remove useless features according the latest ACLE spec.

As explained in https://github.com/ARM-software/acle/pull/315 we
are deprecating features which aren't adding any value. These are:

sha1, pmull, dit, dgh, ebf16, sve-bf16, sve-ebf16, sve-i8mm,
sve2-pmull128, memtag2, memtag3, ssbs2, bti, ls64_v, ls64_accdata
---
 clang/test/CodeGen/aarch64-cpu-supports.c |  24 +-
 .../CodeGen/aarch64-mixed-target-attributes.c |  12 +-
 .../test/CodeGen/attr-target-clones-aarch64.c |  77 ++---
 clang/test/CodeGen/attr-target-version.c  | 326 +-
 .../CodeGenCXX/attr-target-clones-aarch64.cpp |  41 +--
 clang/test/CodeGenCXX/attr-target-version.cpp |  22 +-
 clang/test/Sema/aarch64-cpu-supports.c|   2 +-
 clang/test/Sema/attr-target-clones-aarch64.c  |  21 +-
 clang/test/Sema/attr-target-version.c |  18 +-
 clang/test/SemaCXX/attr-target-version.cpp|  16 +-
 compiler-rt/lib/builtins/cpu_model/aarch64.c  |  17 +-
 .../builtins/cpu_model/aarch64/fmv/apple.inc  |   6 +-
 .../cpu_model/aarch64/fmv/fuchsia.inc |   4 -
 .../builtins/cpu_model/aarch64/fmv/mrs.inc|  42 +--
 .../llvm/TargetParser/AArch64TargetParser.h   |  36 +-
 15 files changed, 287 insertions(+), 377 deletions(-)

diff --git a/clang/test/CodeGen/aarch64-cpu-supports.c 
b/clang/test/CodeGen/aarch64-cpu-supports.c
index c54b7475a3fd5f..7fad9724dfb6c5 100644
--- a/clang/test/CodeGen/aarch64-cpu-supports.c
+++ b/clang/test/CodeGen/aarch64-cpu-supports.c
@@ -1,15 +1,17 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --version 2
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
 
+//.
 // CHECK: @__aarch64_cpu_features = external dso_local global { i64 }
+//.
 // CHECK-LABEL: define dso_local i32 @main
 // CHECK-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store i32 0, ptr [[RETVAL]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 70368744177664
-// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 70368744177664
+// CHECK-NEXT:[[TMP1:%.*]] = and i64 [[TMP0]], 34359738368
+// CHECK-NEXT:[[TMP2:%.*]] = icmp eq i64 [[TMP1]], 34359738368
 // CHECK-NEXT:[[TMP3:%.*]] = and i1 true, [[TMP2]]
 // CHECK-NEXT:br i1 [[TMP3]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
 // CHECK:   if.then:
@@ -17,8 +19,8 @@
 // CHECK-NEXT:br label [[RETURN:%.*]]
 // CHECK:   if.end:
 // CHECK-NEXT:[[TMP4:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP5:%.*]] = and i64 [[TMP4]], 9070970929152
-// CHECK-NEXT:[[TMP6:%.*]] = icmp eq i64 [[TMP5]], 9070970929152
+// CHECK-NEXT:[[TMP5:%.*]] = and i64 [[TMP4]], 17716740096
+// CHECK-NEXT:[[TMP6:%.*]] = icmp eq i64 [[TMP5]], 17716740096
 // CHECK-NEXT:[[TMP7:%.*]] = and i1 true, [[TMP6]]
 // CHECK-NEXT:br i1 [[TMP7]], label [[IF_THEN1:%.*]], label [[IF_END2:%.*]]
 // CHECK:   if.then1:
@@ -26,8 +28,8 @@
 // CHECK-NEXT:br label [[RETURN]]
 // CHECK:   if.end2:
 // CHECK-NEXT:[[TMP8:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
-// CHECK-NEXT:[[TMP9:%.*]] = and i64 [[TMP8]], 166633186212708352
-// CHECK-NEXT:[[TMP10:%.*]] = icmp eq i64 [[TMP9]], 166633186212708352
+// CHECK-NEXT:[[TMP9:%.*]] = and i64 [[TMP8]], 5222680231936
+// CHECK-NEXT:[[TMP10:%.*]] = icmp eq i64 [[TMP9]], 5222680231936
 // CHECK-NEXT:[[TMP11:%.*]] = and i1 true, [[TMP10]]
 // CHECK-NEXT:br i1 [[TMP11]], label [[IF_THEN3:%.*]], label 
[[IF_END4:%.*]]
 // CHECK:   if.then3:
@@ -49,10 +51,10 @@ int main(void) {
   if (__builtin_cpu_supports("sb"))
 return 1;
 
-  if (__builtin_cpu_supports("sve2-pmull128+memtag"))
+  if (__builtin_cpu_supports("sve2-aes+memtag"))
 return 2;
 
-  if (__builtin_cpu_supports("sme2+ls64_v+wfxt"))
+  if (__builtin_cpu_supports("sme2+ls64+wfxt"))
 return 3;
 
   if (__builtin_cpu_supports("avx2"))
@@ -60,3 +62,9 @@ int main(void) {
 
   return 0;
 }
+//.
+// CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+//.
+// CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
+// CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
+//.
diff --git a/clang/test/CodeGen/aarch64-mixed-target-attributes.c 
b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
index aef6ce36ab1c05..be290ff9ecee67 100644
--- a/clang/test/CodeGen/aarch64-mixed-target-attributes.c
+++ b/clang/test/CodeGen/aarch64-mixed-target-attributes.c
@@ -69,8 +69,8 @@ __attribute__((target_version("

[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)


labrinea wrote:

> Mind listing which ones are affected in the commit summary?

Done

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


[clang] Allow struct q{int q;~q();} (#88597) (PR #88673)


https://github.com/nabijaczleweli updated 
https://github.com/llvm/llvm-project/pull/88673

From 05545c8cc2ef2751128f1906933151fb09e37b65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= 
Date: Mon, 15 Apr 2024 03:52:50 +0200
Subject: [PATCH] Allow struct q{int q;~q();} (#88597)

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 --
 clang/lib/Sema/SemaExprCXX.cpp   | 5 ++---
 clang/test/CXX/class/class.mem/p13.cpp   | 1 -
 clang/test/SemaCXX/GH59446.cpp   | 1 -
 clang/test/SemaCXX/constructor.cpp   | 5 ++---
 5 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5ec0218aedfe86..c8c3f2de81f82a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2187,8 +2187,6 @@ def err_undeclared_destructor_name : Error<
   "undeclared identifier %0 in destructor name">;
 def err_destructor_name : Error<
   "expected the class name after '~' to name the enclosing class">;
-def err_destructor_name_nontype : Error<
-  "identifier %0 after '~' in destructor name does not name a type">;
 def err_destructor_expr_mismatch : Error<
   "identifier %0 in object destruction expression does not name the type "
   "%1 of the object being destroyed">;
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 25f23a3abf1718..69d4a6d51ecafb 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -448,9 +448,8 @@ ParsedType Sema::getDestructorName(const IdentifierInfo &II,
   Diag(NameLoc, diag::err_destructor_expr_nontype)
   << &II << MakeFixItHint();
 }
-  } else {
-Diag(NameLoc, SearchType.isNull() ? diag::err_destructor_name_nontype
-  : diag::err_destructor_expr_mismatch)
+  } else if (!SearchType.isNull()) {
+Diag(NameLoc, diag::err_destructor_expr_mismatch)
 << &II << SearchType << MakeFixItHint();
   }
 
diff --git a/clang/test/CXX/class/class.mem/p13.cpp 
b/clang/test/CXX/class/class.mem/p13.cpp
index d947586c419400..1a3173ddfa474c 100644
--- a/clang/test/CXX/class/class.mem/p13.cpp
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -112,5 +112,4 @@ template struct Dtemplate_with_ctors : B {
 template struct CtorDtorName : B {
   using B::CtorDtorName; // expected-error {{member 'CtorDtorName' has the 
same name as its class}} expected-note {{non-type declaration found by 
destructor name lookup}}
   CtorDtorName();
-  ~CtorDtorName(); // expected-error {{identifier 'CtorDtorName' after '~' in 
destructor name does not name a type}}
 };
diff --git a/clang/test/SemaCXX/GH59446.cpp b/clang/test/SemaCXX/GH59446.cpp
index b85a57abb9fa57..c0c1c40265f8be 100644
--- a/clang/test/SemaCXX/GH59446.cpp
+++ b/clang/test/SemaCXX/GH59446.cpp
@@ -8,5 +8,4 @@ namespace N {
   }
   void f(X *x) { // expected-error {{no template named 'X'; did you mean 
'N::X'}}
 x->N::X::~X(); // expected-error 2 {{implicit instantiation of 
undefined template 'GH59446::N::X'}}
-// expected-error@-1 {{identifier 'X' after '~' in 
destructor name does not name a type}}
 } // expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/constructor.cpp 
b/clang/test/SemaCXX/constructor.cpp
index abd7dbe18a0e6a..64683675805924 100644
--- a/clang/test/SemaCXX/constructor.cpp
+++ b/clang/test/SemaCXX/constructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 typedef int INT;
 
 class Foo {
@@ -14,7 +14,7 @@ class Foo {
   static Foo(short, short); // expected-error{{constructor cannot be declared 
'static'}}
   virtual Foo(double); // expected-error{{constructor cannot be declared 
'virtual'}}
   Foo(long) const; // expected-error{{'const' qualifier is not allowed on a 
constructor}}
-  
+
   int Foo(int, int); // expected-error{{constructor cannot have a return type}}
 
   volatile Foo(float); // expected-error{{constructor cannot have a return 
type}}
@@ -94,5 +94,4 @@ namespace PR38286 {
   template struct B;
   template void B::f() {} // expected-error {{out-of-line 
definition of 'f' from class 'B'}}
   template struct C; // expected-note {{non-type declaration found}}
-  template C::~C() {} // expected-error {{identifier 'C' after 
'~' in destructor name does not name a type}}
 }

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


[clang] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)


sdkrystian wrote:

@erichkeane Perhaps the release note should go under "Attribute Changes in 
Clang"?

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


[clang] [clang-tools-extra] [clang analysis] ExprMutationAnalyzer support recursive forwarding reference (PR #88843)


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

LGTM

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


[clang] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)


erichkeane wrote:

> @erichkeane Perhaps the release note should go under "Attribute Changes in 
> Clang"?

That would be fine for me as well.

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


[clang] 13ea36d - Fix UPCAddressofArraySubscriptGadget::getClaimedVarUseSites() (#88406)


Author: juan.vazquez
Date: 2024-04-16T12:42:59-07:00
New Revision: 13ea36db166b7007f8b1e84e0827faaf24eb448e

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

LOG: Fix UPCAddressofArraySubscriptGadget::getClaimedVarUseSites() (#88406)

UPCAddressofArraySubscriptGadget::getClaimedVarUseSites should skip
parentheses when accessing the DeclRefExpr, otherwise a crash happens
with parenthesized references.

Added: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-suggestions-crashes.cpp

Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index e03fe1b6830043..c42e70d5b95ac1 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1114,7 +1114,7 @@ class UPCAddressofArraySubscriptGadget : public 
FixableGadget {
   virtual DeclUseList getClaimedVarUseSites() const override {
 const auto *ArraySubst = cast(Node->getSubExpr());
 const auto *DRE =
-cast(ArraySubst->getBase()->IgnoreImpCasts());
+cast(ArraySubst->getBase()->IgnoreParenImpCasts());
 return {DRE};
   }
 };

diff  --git 
a/clang/test/SemaCXX/warn-unsafe-buffer-usage-suggestions-crashes.cpp 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-suggestions-crashes.cpp
new file mode 100644
index 00..bf4faec184ee17
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-suggestions-crashes.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-fsafe-buffer-usage-suggestions \
+// RUN:%s -verify %s
+
+char * unsafe_pointer; // expected-warning{{'unsafe_pointer' is an unsafe 
pointer used for buffer access}}
+
+void test(char * param) {
+}
+
+void dre_parenthesized() {
+  test(&(unsafe_pointer)[1]); // no-crash // expected-note{{used in buffer 
access here}}
+}



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


[clang] Fix UPCAddressofArraySubscriptGadget::getClaimedVarUseSites() (PR #88406)


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


[clang-tools-extra] [clang-tidy NFC] Fix a typo in docs for sizeof-expression (PR #88912)


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


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


[clang] Fix UPCAddressofArraySubscriptGadget::getClaimedVarUseSites() (PR #88406)


github-actions[bot] wrote:



@juanvazquez Congratulations on having your first Pull Request (PR) merged into 
the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[clang] [llvm] [SPIRV][HLSL] map lerp to Fmix (PR #88976)


https://github.com/farzonl created 
https://github.com/llvm/llvm-project/pull/88976

- `clang/lib/CodeGen/CGBuiltin.cpp` - switch to using `getLerpIntrinsic()` to 
abstract backend intrinsic
- `clang/lib/CodeGen/CGHLSLRuntime.h` - add `getLerpIntrinsic()` 
- `llvm/include/llvm/IR/IntrinsicsSPIRV.td` - add SPIRV intrinsic for lerp 
- `llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp` - add mapping of HLSL's 
lerp to GLSL's Fmix.

resolves #88940

>From 6d5a126dd2d6c88ab61549a2ac8f5879642393e5 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Tue, 16 Apr 2024 15:28:25 -0400
Subject: [PATCH] [SPIRV][HLSL] map lerp to Fmix

---
 clang/lib/CodeGen/CGBuiltin.cpp   |  4 +-
 clang/lib/CodeGen/CGHLSLRuntime.h |  1 +
 clang/test/CodeGenHLSL/builtins/lerp.hlsl | 96 ---
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  2 +
 .../Target/SPIRV/SPIRVInstructionSelector.cpp | 26 +
 .../CodeGen/SPIRV/hlsl-intrinsics/lerp.ll | 56 +++
 6 files changed, 147 insertions(+), 38 deletions(-)
 create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/lerp.ll

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9f95697f284c40..c7f63f71fbfcf7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18256,8 +18256,8 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 if (!E->getArg(0)->getType()->hasFloatingRepresentation())
   llvm_unreachable("lerp operand must have a float representation");
 return Builder.CreateIntrinsic(
-/*ReturnType=*/X->getType(), Intrinsic::dx_lerp,
-ArrayRef{X, Y, S}, nullptr, "dx.lerp");
+/*ReturnType=*/X->getType(), CGM.getHLSLRuntime().getLerpIntrinsic(),
+ArrayRef{X, Y, S}, nullptr, "hlsl.lerp");
   }
   case Builtin::BI__builtin_hlsl_elementwise_frac: {
 Value *Op0 = EmitScalarExpr(E->getArg(0));
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 506b364f5b2ec7..0abe39dedcb96f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -74,6 +74,7 @@ class CGHLSLRuntime {
 
   GENERATE_HLSL_INTRINSIC_FUNCTION(All, all)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Any, any)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Lerp, lerp)
   GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
 
   
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/lerp.hlsl 
b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
index 49cd04a10115ae..634b20be3a28d6 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
@@ -1,69 +1,92 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF
+// RUN:   --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
 
 
-// NATIVE_HALF: %dx.lerp = call half @llvm.dx.lerp.f16(half %0, half %1, half 
%2)
-// NATIVE_HALF: ret half %dx.lerp
-// NO_HALF: %dx.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, float 
%2)
-// NO_HALF: ret float %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call half @llvm.dx.lerp.f16(half %0, half 
%1, half %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp = call half @llvm.spv.lerp.f16(half %0, half 
%1, half %2)
+// NATIVE_HALF: ret half %hlsl.lerp
+// DXIL_NO_HALF: %hlsl.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, 
float %2)
+// SPIR_NO_HALF: %hlsl.lerp = call float @llvm.spv.lerp.f32(float %0, float 
%1, float %2)
+// NO_HALF: ret float %hlsl.lerp
 half test_lerp_half(half p0) { return lerp(p0, p0, p0); }
 
-// NATIVE_HALF: %dx.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x half> %0, 
<2 x half> %1, <2 x half> %2)
-// NATIVE_HALF: ret <2 x half> %dx.lerp
-// NO_HALF: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 
x float> %1, <2 x float> %2)
-// NO_HALF: ret <2 x float> %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x 
half> %0, <2 x half> %1, <2 x half> %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp

[clang] [llvm] [SPIRV][HLSL] map lerp to Fmix (PR #88976)


llvmbot wrote:



@llvm/pr-subscribers-backend-spir-v
@llvm/pr-subscribers-hlsl

@llvm/pr-subscribers-llvm-ir

Author: Farzon Lotfi (farzonl)


Changes

- `clang/lib/CodeGen/CGBuiltin.cpp` - switch to using `getLerpIntrinsic()` to 
abstract backend intrinsic
- `clang/lib/CodeGen/CGHLSLRuntime.h` - add `getLerpIntrinsic()` 
- `llvm/include/llvm/IR/IntrinsicsSPIRV.td` - add SPIRV intrinsic for lerp 
- `llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp` - add mapping of HLSL's 
lerp to GLSL's Fmix.

resolves #88940

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


6 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.h (+1) 
- (modified) clang/test/CodeGenHLSL/builtins/lerp.hlsl (+60-36) 
- (modified) llvm/include/llvm/IR/IntrinsicsSPIRV.td (+2) 
- (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (+26) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/lerp.ll (+56) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9f95697f284c40..c7f63f71fbfcf7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18256,8 +18256,8 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 if (!E->getArg(0)->getType()->hasFloatingRepresentation())
   llvm_unreachable("lerp operand must have a float representation");
 return Builder.CreateIntrinsic(
-/*ReturnType=*/X->getType(), Intrinsic::dx_lerp,
-ArrayRef{X, Y, S}, nullptr, "dx.lerp");
+/*ReturnType=*/X->getType(), CGM.getHLSLRuntime().getLerpIntrinsic(),
+ArrayRef{X, Y, S}, nullptr, "hlsl.lerp");
   }
   case Builtin::BI__builtin_hlsl_elementwise_frac: {
 Value *Op0 = EmitScalarExpr(E->getArg(0));
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 506b364f5b2ec7..0abe39dedcb96f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -74,6 +74,7 @@ class CGHLSLRuntime {
 
   GENERATE_HLSL_INTRINSIC_FUNCTION(All, all)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Any, any)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Lerp, lerp)
   GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
 
   
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/lerp.hlsl 
b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
index 49cd04a10115ae..634b20be3a28d6 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
@@ -1,69 +1,92 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF
+// RUN:   --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
 
 
-// NATIVE_HALF: %dx.lerp = call half @llvm.dx.lerp.f16(half %0, half %1, half 
%2)
-// NATIVE_HALF: ret half %dx.lerp
-// NO_HALF: %dx.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, float 
%2)
-// NO_HALF: ret float %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call half @llvm.dx.lerp.f16(half %0, half 
%1, half %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp = call half @llvm.spv.lerp.f16(half %0, half 
%1, half %2)
+// NATIVE_HALF: ret half %hlsl.lerp
+// DXIL_NO_HALF: %hlsl.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, 
float %2)
+// SPIR_NO_HALF: %hlsl.lerp = call float @llvm.spv.lerp.f32(float %0, float 
%1, float %2)
+// NO_HALF: ret float %hlsl.lerp
 half test_lerp_half(half p0) { return lerp(p0, p0, p0); }
 
-// NATIVE_HALF: %dx.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x half> %0, 
<2 x half> %1, <2 x half> %2)
-// NATIVE_HALF: ret <2 x half> %dx.lerp
-// NO_HALF: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 
x float> %1, <2 x float> %2)
-// NO_HALF: ret <2 x float> %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x 
half> %0, <2 x half> %1, <2 x half> %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp = call <2 x half> @llvm.spv.lerp.v2f16(<2 x 
half> %0, <2 x half> %1, <2 x half> %2)
+// NATIVE_HALF: ret <2 x half> %hls

[clang] [llvm] [SPIRV][HLSL] map lerp to Fmix (PR #88976)


llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Farzon Lotfi (farzonl)


Changes

- `clang/lib/CodeGen/CGBuiltin.cpp` - switch to using `getLerpIntrinsic()` to 
abstract backend intrinsic
- `clang/lib/CodeGen/CGHLSLRuntime.h` - add `getLerpIntrinsic()` 
- `llvm/include/llvm/IR/IntrinsicsSPIRV.td` - add SPIRV intrinsic for lerp 
- `llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp` - add mapping of HLSL's 
lerp to GLSL's Fmix.

resolves #88940

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


6 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.h (+1) 
- (modified) clang/test/CodeGenHLSL/builtins/lerp.hlsl (+60-36) 
- (modified) llvm/include/llvm/IR/IntrinsicsSPIRV.td (+2) 
- (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (+26) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/lerp.ll (+56) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9f95697f284c40..c7f63f71fbfcf7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18256,8 +18256,8 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 if (!E->getArg(0)->getType()->hasFloatingRepresentation())
   llvm_unreachable("lerp operand must have a float representation");
 return Builder.CreateIntrinsic(
-/*ReturnType=*/X->getType(), Intrinsic::dx_lerp,
-ArrayRef{X, Y, S}, nullptr, "dx.lerp");
+/*ReturnType=*/X->getType(), CGM.getHLSLRuntime().getLerpIntrinsic(),
+ArrayRef{X, Y, S}, nullptr, "hlsl.lerp");
   }
   case Builtin::BI__builtin_hlsl_elementwise_frac: {
 Value *Op0 = EmitScalarExpr(E->getArg(0));
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 506b364f5b2ec7..0abe39dedcb96f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -74,6 +74,7 @@ class CGHLSLRuntime {
 
   GENERATE_HLSL_INTRINSIC_FUNCTION(All, all)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Any, any)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Lerp, lerp)
   GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
 
   
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/lerp.hlsl 
b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
index 49cd04a10115ae..634b20be3a28d6 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
@@ -1,69 +1,92 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF
+// RUN:   --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
 
 
-// NATIVE_HALF: %dx.lerp = call half @llvm.dx.lerp.f16(half %0, half %1, half 
%2)
-// NATIVE_HALF: ret half %dx.lerp
-// NO_HALF: %dx.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, float 
%2)
-// NO_HALF: ret float %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call half @llvm.dx.lerp.f16(half %0, half 
%1, half %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp = call half @llvm.spv.lerp.f16(half %0, half 
%1, half %2)
+// NATIVE_HALF: ret half %hlsl.lerp
+// DXIL_NO_HALF: %hlsl.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, 
float %2)
+// SPIR_NO_HALF: %hlsl.lerp = call float @llvm.spv.lerp.f32(float %0, float 
%1, float %2)
+// NO_HALF: ret float %hlsl.lerp
 half test_lerp_half(half p0) { return lerp(p0, p0, p0); }
 
-// NATIVE_HALF: %dx.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x half> %0, 
<2 x half> %1, <2 x half> %2)
-// NATIVE_HALF: ret <2 x half> %dx.lerp
-// NO_HALF: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 
x float> %1, <2 x float> %2)
-// NO_HALF: ret <2 x float> %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x 
half> %0, <2 x half> %1, <2 x half> %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp = call <2 x half> @llvm.spv.lerp.v2f16(<2 x 
half> %0, <2 x half> %1, <2 x half> %2)
+// NATIVE_HALF: ret <2 x half> %hlsl.lerp
+// DXIL_NO_HALF: %hlsl.lerp = call <2 x float> @

[clang] [BitInt] Expose a _BitInt literal suffix in C++ (PR #86586)


https://github.com/js324 updated https://github.com/llvm/llvm-project/pull/86586

>From c822eaf87526567825e9c4403ae9f01dd4ff58a3 Mon Sep 17 00:00:00 2001
From: Jin S 
Date: Mon, 25 Mar 2024 17:19:41 -0400
Subject: [PATCH] [BitInt] Expose a _BitInt literal suffix in C++

---
 clang/docs/ReleaseNotes.rst   |   1 +
 .../clang/Basic/DiagnosticCommonKinds.td  |   3 +
 clang/include/clang/Basic/DiagnosticGroups.td |   2 +
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +-
 clang/include/clang/Lex/LiteralSupport.h  |   5 +-
 clang/lib/Lex/LiteralSupport.cpp  |  36 +++-
 clang/lib/Lex/PPExpressions.cpp   |   8 +-
 clang/lib/Sema/SemaExpr.cpp   |  12 +-
 clang/test/AST/bitint-suffix.cpp  |  32 
 clang/test/Lexer/bitint-constants-compat.c|  11 +-
 clang/test/Lexer/bitint-constants.cpp | 178 ++
 11 files changed, 274 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/AST/bitint-suffix.cpp
 create mode 100644 clang/test/Lexer/bitint-constants.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7fbe2fec6ca065..d40c86a15ac2da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -88,6 +88,7 @@ sections with improvements to Clang's support for those 
languages.
 
 C++ Language Changes
 
+- Implemented ``_BitInt`` literal suffixes ``__wb`` or ``__WB`` as a Clang 
extension with ``unsigned`` modifiers also allowed. (#GH85223).
 
 C++20 Feature Support
 ^
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index a52bf62e24202c..0738f43ca555c8 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -234,6 +234,9 @@ def err_cxx23_size_t_suffix: Error<
 def err_size_t_literal_too_large: Error<
   "%select{signed |}0'size_t' literal is out of range of possible "
   "%select{signed |}0'size_t' values">;
+def ext_cxx_bitint_suffix : Extension<
+  "'_BitInt' suffix for literals is a Clang extension">,
+  InGroup;
 def ext_c23_bitint_suffix : ExtWarn<
   "'_BitInt' suffix for literals is a C23 extension">,
   InGroup;
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 44035e2fd16f2e..37f56ed6289d27 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1516,3 +1516,5 @@ def UnsafeBufferUsage : DiagGroup<"unsafe-buffer-usage", 
[UnsafeBufferUsageInCon
 // Warnings and notes InstallAPI verification.
 def InstallAPIViolation : DiagGroup<"installapi-violation">;
 
+// Warnings related to _BitInt extension
+def BitIntExtension : DiagGroup<"bit-int-extension">;
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 46a44418a3153b..6759f923564adf 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1646,7 +1646,7 @@ def warn_ext_int_deprecated : Warning<
   "'_ExtInt' is deprecated; use '_BitInt' instead">, InGroup;
 def ext_bit_int : Extension<
   "'_BitInt' in %select{C17 and earlier|C++}0 is a Clang extension">,
-  InGroup>;
+  InGroup;
 } // end of Parse Issue category.
 
 let CategoryName = "Modules Issue" in {
diff --git a/clang/include/clang/Lex/LiteralSupport.h 
b/clang/include/clang/Lex/LiteralSupport.h
index 643ddbdad8c87d..e7c3aaae9fc35e 100644
--- a/clang/include/clang/Lex/LiteralSupport.h
+++ b/clang/include/clang/Lex/LiteralSupport.h
@@ -80,7 +80,10 @@ class NumericLiteralParser {
   bool isFloat128 : 1;  // 1.0q
   bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr
   bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk
-  bool isBitInt : 1;// 1wb, 1uwb (C23)
+  // clang-format off
+  bool isBitInt : 1;// 1wb, 1uwb (C23) or 1__wb, 1__uwb (Clang 
extension in C++
+// mode)
+  // clang-format on
   uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, or i64.
 
 
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 438c6d772e6e04..9c0cbea5052cb2 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -974,6 +974,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
   bool isFixedPointConstant = isFixedPointLiteral();
   bool isFPConstant = isFloatingLiteral();
   bool HasSize = false;
+  bool DoubleUnderscore = false;
 
   // Loop over all of the characters of the suffix.  If we see something bad,
   // we break out of the loop.
@@ -1117,6 +1118,31 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
   if (isImaginary) break;   // Cannot be repeated.
   isImaginary = true;
   continue;  // Success.
+case '_':
+  if (isFPConstant)
+brea

[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)


https://github.com/artemcm created 
https://github.com/llvm/llvm-project/pull/88977

A client's Clang instance may require to perform type-checking against one OS 
version and compilation/code-generation against an earlier version. This change 
allows such clients to configure their built-in Clang code-generator with a 
custom `TargetInfo`.

>From c86ee8d6fc2b0d3995f0dee4e7bc206ef6e05c8b Mon Sep 17 00:00:00 2001
From: Artem Chikin 
Date: Wed, 20 Dec 2023 10:56:42 -0800
Subject: [PATCH] [NFC] Parameterize Initialization of 'clang::CodeGenerator'
 on a TargetInfo instance which may differ from the one in the ASTContext

As per https://github.com/apple/swift/pull/65930, Swift compiler's built-in 
Clang instance may require to perform type-checking against one OS version and 
compilation/code-generation against an earlier version. This change allows 
Swift to configure it's built-in Clang code-generator with a custom 
'TargetInfo'.
---
 clang/include/clang/AST/ASTConsumer.h |  5 
 clang/lib/CodeGen/CodeGenModule.cpp   | 23 +++
 clang/lib/CodeGen/CodeGenModule.h |  4 +++-
 clang/lib/CodeGen/ModuleBuilder.cpp   | 17 +-
 .../ObjectFilePCHContainerOperations.cpp  |  3 ++-
 5 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/clang/include/clang/AST/ASTConsumer.h 
b/clang/include/clang/AST/ASTConsumer.h
index ebcd8059284d8d..774d19565e57b0 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -26,6 +26,7 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
+  class TargetInfo;
 
 /// ASTConsumer - This is an abstract interface that should be implemented by
 /// clients that read ASTs.  This abstraction layer allows the client to be
@@ -46,6 +47,10 @@ class ASTConsumer {
   /// ASTContext.
   virtual void Initialize(ASTContext &Context) {}
 
+  /// Initialize - This is called to initialize the consumer, providing the
+  /// ASTContext.
+  virtual void Initialize(ASTContext &Context, const TargetInfo 
&CodeGenTargetInfo) {}
+
   /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
   /// called by the parser to process every top-level Decl*.
   ///
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0c447b20cef40d..52ff65c0986931 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -333,12 +333,14 @@ CodeGenModule::CodeGenModule(ASTContext &C,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions &HSO,
  const PreprocessorOptions &PPO,
- const CodeGenOptions &CGO, llvm::Module &M,
+ const CodeGenOptions &CGO,
+ const TargetInfo &CGTI,
+ llvm::Module &M,
  DiagnosticsEngine &diags,
  CoverageSourceInfo *CoverageInfo)
 : Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
   PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
-  Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
+  Target(CGTI), ABI(createCXXABI(*this)),
   VMContext(M.getContext()), Types(*this), VTables(*this),
   SanitizerMD(new SanitizerMetadata(*this)) {
 
@@ -353,20 +355,21 @@ CodeGenModule::CodeGenModule(ASTContext &C,
   BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
   FloatTy = llvm::Type::getFloatTy(LLVMContext);
   DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
-  PointerWidthInBits = C.getTargetInfo().getPointerWidth(LangAS::Default);
+  PointerWidthInBits = Target.getPointerWidth(LangAS::Default);
   PointerAlignInBytes =
-  C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(LangAS::Default))
+  C.toCharUnitsFromBits(Target.getPointerAlign(LangAS::Default))
   .getQuantity();
   SizeSizeInBytes =
-
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
+C.toCharUnitsFromBits(Target.getMaxPointerWidth()).getQuantity();
   IntAlignInBytes =
-C.toCharUnitsFromBits(C.getTargetInfo().getIntAlign()).getQuantity();
+C.toCharUnitsFromBits(Target.getIntAlign()).getQuantity();
   CharTy =
-llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getCharWidth());
-  IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
+llvm::IntegerType::get(LLVMContext, Target.getCharWidth());
+  IntTy = llvm::IntegerType::get(LLVMContext, Target.getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
-C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+Target.getMaxPointerWidth());
+  Int8PtrTy = Int8Ty->getPointerTo(0);
+  Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
   const llvm::DataLayout &DL = M.getDataLayout();
   AllocaInt8PtrTy =
  

[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)


llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Artem Chikin (artemcm)


Changes

A client's Clang instance may require to perform type-checking against one OS 
version and compilation/code-generation against an earlier version. This change 
allows such clients to configure their built-in Clang code-generator with a 
custom `TargetInfo`.

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


5 Files Affected:

- (modified) clang/include/clang/AST/ASTConsumer.h (+5) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+13-10) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+3-1) 
- (modified) clang/lib/CodeGen/ModuleBuilder.cpp (+11-6) 
- (modified) clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (+2-1) 


``diff
diff --git a/clang/include/clang/AST/ASTConsumer.h 
b/clang/include/clang/AST/ASTConsumer.h
index ebcd8059284d8d..774d19565e57b0 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -26,6 +26,7 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
+  class TargetInfo;
 
 /// ASTConsumer - This is an abstract interface that should be implemented by
 /// clients that read ASTs.  This abstraction layer allows the client to be
@@ -46,6 +47,10 @@ class ASTConsumer {
   /// ASTContext.
   virtual void Initialize(ASTContext &Context) {}
 
+  /// Initialize - This is called to initialize the consumer, providing the
+  /// ASTContext.
+  virtual void Initialize(ASTContext &Context, const TargetInfo 
&CodeGenTargetInfo) {}
+
   /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
   /// called by the parser to process every top-level Decl*.
   ///
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0c447b20cef40d..52ff65c0986931 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -333,12 +333,14 @@ CodeGenModule::CodeGenModule(ASTContext &C,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions &HSO,
  const PreprocessorOptions &PPO,
- const CodeGenOptions &CGO, llvm::Module &M,
+ const CodeGenOptions &CGO,
+ const TargetInfo &CGTI,
+ llvm::Module &M,
  DiagnosticsEngine &diags,
  CoverageSourceInfo *CoverageInfo)
 : Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
   PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
-  Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
+  Target(CGTI), ABI(createCXXABI(*this)),
   VMContext(M.getContext()), Types(*this), VTables(*this),
   SanitizerMD(new SanitizerMetadata(*this)) {
 
@@ -353,20 +355,21 @@ CodeGenModule::CodeGenModule(ASTContext &C,
   BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
   FloatTy = llvm::Type::getFloatTy(LLVMContext);
   DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
-  PointerWidthInBits = C.getTargetInfo().getPointerWidth(LangAS::Default);
+  PointerWidthInBits = Target.getPointerWidth(LangAS::Default);
   PointerAlignInBytes =
-  C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(LangAS::Default))
+  C.toCharUnitsFromBits(Target.getPointerAlign(LangAS::Default))
   .getQuantity();
   SizeSizeInBytes =
-
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
+C.toCharUnitsFromBits(Target.getMaxPointerWidth()).getQuantity();
   IntAlignInBytes =
-C.toCharUnitsFromBits(C.getTargetInfo().getIntAlign()).getQuantity();
+C.toCharUnitsFromBits(Target.getIntAlign()).getQuantity();
   CharTy =
-llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getCharWidth());
-  IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
+llvm::IntegerType::get(LLVMContext, Target.getCharWidth());
+  IntTy = llvm::IntegerType::get(LLVMContext, Target.getIntWidth());
   IntPtrTy = llvm::IntegerType::get(LLVMContext,
-C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+Target.getMaxPointerWidth());
+  Int8PtrTy = Int8Ty->getPointerTo(0);
+  Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
   const llvm::DataLayout &DL = M.getDataLayout();
   AllocaInt8PtrTy =
   llvm::PointerType::get(LLVMContext, DL.getAllocaAddrSpace());
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 1cc447765e2c97..7721941ce370af 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -613,7 +613,9 @@ class CodeGenModule : public CodeGenTypeCache {
   CodeGenModule(ASTContext &C, IntrusiveRefCntPtr FS,
 const HeaderSearchOptions &headersearchopts,
 const PreprocessorOptions &ppopts,
-const CodeGenOptions &Co

[clang] [llvm] [SPIRV][HLSL] map lerp to Fmix (PR #88976)


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

Looks good to me.

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


[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)


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 281d71604f418eb952e967d9dc4b26241b7f96aa 
c86ee8d6fc2b0d3995f0dee4e7bc206ef6e05c8b -- 
clang/include/clang/AST/ASTConsumer.h clang/lib/CodeGen/CodeGenModule.cpp 
clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ModuleBuilder.cpp 
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/AST/ASTConsumer.h 
b/clang/include/clang/AST/ASTConsumer.h
index 774d19565e..eeac3ea001 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -28,126 +28,130 @@ namespace clang {
   class ImportDecl;
   class TargetInfo;
 
-/// ASTConsumer - This is an abstract interface that should be implemented by
-/// clients that read ASTs.  This abstraction layer allows the client to be
-/// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
-class ASTConsumer {
-  /// Whether this AST consumer also requires information about
-  /// semantic analysis.
-  bool SemaConsumer = false;
-
-  friend class SemaConsumer;
-
-public:
-  ASTConsumer() = default;
-
-  virtual ~ASTConsumer() {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext &Context) {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext &Context, const TargetInfo 
&CodeGenTargetInfo) {}
-
-  /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
-  /// called by the parser to process every top-level Decl*.
-  ///
-  /// \returns true to continue parsing, or false to abort parsing.
-  virtual bool HandleTopLevelDecl(DeclGroupRef D);
-
-  /// This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
-
-  /// HandleInterestingDecl - Handle the specified interesting declaration. 
This
-  /// is called by the AST reader when deserializing things that might interest
-  /// the consumer. The default implementation forwards to HandleTopLevelDecl.
-  virtual void HandleInterestingDecl(DeclGroupRef D);
-
-  /// HandleTranslationUnit - This method is called when the ASTs for entire
-  /// translation unit have been parsed.
-  virtual void HandleTranslationUnit(ASTContext &Ctx) {}
-
-  /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
-  /// (e.g. struct, union, enum, class) is completed.  This allows the client 
to
-  /// hack on the type, which can occur at any point in the file (because these
-  /// can be defined in declspecs).
-  virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
-  /// This callback is invoked the first time each TagDecl is required to
-  /// be complete.
-  virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
-
-  /// Invoked when a function is implicitly instantiated.
-  /// Note that at this point it does not have a body, its body is
-  /// instantiated at the end of the translation unit and passed to
-  /// HandleTopLevelDecl.
-  virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
-
-  /// Handle the specified top-level declaration that occurred inside
-  /// and ObjC container.
-  /// The default implementation ignored them.
-  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
-
-  /// Handle an ImportDecl that was implicitly created due to an
-  /// inclusion directive.
-  /// The default implementation passes it to HandleTopLevelDecl.
-  virtual void HandleImplicitImportDecl(ImportDecl *D);
-
-  /// CompleteTentativeDefinition - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given tentative definition should be
-  /// completed.
-  ///
-  /// The variable declaration itself will be a tentative
-  /// definition. If it had an incomplete array type, its type will
-  /// have already been changed to an array of size 1. However, the
-  /// declaration remains a tentative definition and has not been
-  /// modified by the introduction of an implicit zero initializer.
-  virtual void CompleteTentativeDefinition(VarDecl *D) {}
-
-  /// CompleteExternalDeclaration - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given external declaration should be
-  /// completed.
-  virtual void CompleteExternalDeclaration(VarDecl *D) {}
-
-  /// Callback invoked when an MSInheritanceAttr has been attached to a
-  /// CXXRecordDecl.
-  virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
-
-  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
-  // variable has been instantiated.
-  virtual void HandleCXXSta

[clang] [clang][SPIR-V] Set AS for the SPIR-V logical triple (PR #88939)


https://github.com/coopp commented:

Looks good

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


[clang] Adding C23 constexpr math functions fmin and frexp. (PR #88978)


https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/88978

None

>From 3acc848f4fcc68445dfc849f9c6f8d384d3692af Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 16 Apr 2024 13:09:58 -0700
Subject: [PATCH] Adding C23 constexpr math functions fmin and frexp.

---
 clang/include/clang/Basic/Builtins.td |  4 +--
 clang/lib/AST/ExprConstant.cpp| 16 -
 clang/test/CodeGen/constexpr-math.cpp | 51 +++
 3 files changed, 68 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/CodeGen/constexpr-math.cpp

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 52c0dd52c28b11..a35c77286229ff 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -3440,7 +3440,7 @@ def Fmod : FPMathTemplate, LibBuiltin<"math.h"> {
 
 def Frexp : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["frexp"];
-  let Attributes = [NoThrow];
+  let Attributes = [NoThrow, Constexpr];
   let Prototype = "T(T, int*)";
   let AddBuiltinPrefixedAlias = 1;
 }
@@ -3618,7 +3618,7 @@ def Fmax : FPMathTemplate, LibBuiltin<"math.h"> {
 
 def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["fmin"];
-  let Attributes = [NoThrow, Const];
+  let Attributes = [NoThrow, Const, Constexpr];
   let Prototype = "T(T, T)";
   let AddBuiltinPrefixedAlias = 1;
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5a36621dc5cce2..506621ac7e9c1b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const 
BinaryOperator *E,
   //   If during the evaluation of an expression, the result is not
   //   mathematically defined [...], the behavior is undefined.
   // FIXME: C++ rules require us to not conform to IEEE 754 here.
-  if (LHS.isNaN()) {
+  if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) {
 Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << LHS.isNaN();
 return Info.noteUndefinedBehavior();
   }
@@ -14547,6 +14547,18 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   default:
 return false;
 
+  case Builtin::BI__builtin_frexpf:
+  case Builtin::BI__builtin_frexp: {
+LValue Pointer;
+if (!EvaluateFloat(E->getArg(0), Result, Info) ||
+!EvaluatePointer(E->getArg(1), Pointer, Info))
+  return false;
+llvm::RoundingMode RM =
+E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).getRoundingMode();
+int FrexpExp;
+Result = llvm::frexp(Result, FrexpExp, RM);
+return true;
+  }
   case Builtin::BI__builtin_huge_val:
   case Builtin::BI__builtin_huge_valf:
   case Builtin::BI__builtin_huge_vall:
@@ -14638,6 +14650,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
 return true;
   }
 
+  case Builtin::BIfmin:
+  case Builtin::BIfminf:
   case Builtin::BI__builtin_fmin:
   case Builtin::BI__builtin_fminf:
   case Builtin::BI__builtin_fminl:
diff --git a/clang/test/CodeGen/constexpr-math.cpp 
b/clang/test/CodeGen/constexpr-math.cpp
new file mode 100644
index 00..446bf3f4f7a504
--- /dev/null
+++ b/clang/test/CodeGen/constexpr-math.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -std=c++23 \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
+// RUN %clang_cc1 -x c++ -triple x86_64-linux-gnu -emit-llvm -o - %s \
+// RUN -std=c++23
+
+#define INFINITY ((float)(1e+300 * 1e+300))
+#define NAN  (-(float)(INFINITY * 0.0F))
+
+//constexpr double frexp ( double num, int* exp );
+//constexpr float foo ( float num, int* exp );
+
+int func()
+{
+  int i;
+
+  // fmin
+  constexpr double f1 = __builtin_fmin(15.24, 1.3);
+  constexpr double f2 = __builtin_fmin(-0.0, +0.0);
+  constexpr double f3 = __builtin_fmin(+0.0, -0.0);
+  constexpr float f4 = __builtin_fminf(NAN, NAN);
+  constexpr float f5 = __builtin_fminf(NAN, -1);
+  constexpr float f6 = __builtin_fminf(-INFINITY, 0);
+  constexpr float f7 = __builtin_fminf(INFINITY, 0);
+
+  // frexp
+  constexpr double f8 = __builtin_frexp(123.45, &i);
+  constexpr double f9 = __builtin_frexp(0.0, &i);
+  constexpr double f10 = __builtin_frexp(-0.0, &i);
+  constexpr double f11 = __builtin_frexpf(NAN, &i);
+  constexpr double f12 = __builtin_frexpf(-NAN, &i);
+  constexpr double f13 = __builtin_frexpf(INFINITY, &i);
+  constexpr double f14 = __builtin_frexpf(INFINITY, &i);
+
+  return 0;
+}
+
+// CHECK: store double 1.30e+00, ptr {{.*}}
+// CHECK: store double -0.00e+00, ptr {{.*}}
+// CHECK: store double -0.00e+00, ptr {{.*}}
+// CHECK: store float 0xFFF8, ptr {{.*}}
+// CHECK: store float -1.00e+00, ptr {{.*}}
+// CHECK: store float 0xFFF0, ptr {{.*}}
+
+// CHECK: store double 0x3FEEDCCD, ptr {{.*}}
+// CHECK: store double 0.00e+00, ptr {{.*}}
+// CHECK: store double -0.00e+00, pt

[clang] [C23] [CALNG] Adding C23 constexpr math functions fmin and frexp. (PR #88978)


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


[clang] [clang-tools-extra] [clang-tidy] Add new check `modernize-use-designated-initializers` (PR #80541)

Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= 
Message-ID:
In-Reply-To: 


PiotrZSL wrote:

> It would have been appropriate to have a clangd reviewer on this.

That's a more a problem of why group pr-subscribers-clangd were not auto-added.

> As a shared library, this would also need unit tests distinct from the 
> integration tests in tidy+clangd.

This were main reason, why it were avoided, as there were no unit tests for 
this code on clangd side.

> I'd plan to revert next week

No reverts on 1.5 month old (clang-tidy) code, specially that this doesn't 
block anything else.
But fell free to revert clangd part alone. As for library extraction, that can 
happen in separate pull-request.




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


[clang] b6bd41d - [InstCombine] Add canonicalization of `sitofp` -> `uitofp nneg`


Author: Noah Goldstein
Date: 2024-04-16T15:26:25-05:00
New Revision: b6bd41db31c798f3fc82368381fad6d42795f512

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

LOG: [InstCombine] Add canonicalization of `sitofp` -> `uitofp nneg`

This is essentially the same as #82404 but has the `nneg` flag which
allows the backend to reliably undo the transform.

Closes #88299

Added: 


Modified: 
clang/test/Headers/__clang_hip_math.hip
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/add-sitofp.ll
llvm/test/Transforms/InstCombine/binop-itofp.ll
llvm/test/Transforms/InstCombine/clamp-to-minmax.ll
llvm/test/Transforms/InstCombine/fpcast.ll
llvm/test/Transforms/InstCombine/minmax-fold.ll
llvm/test/Transforms/InstCombine/minmax-fp.ll
llvm/test/Transforms/InstCombine/pr27236.ll
llvm/test/Transforms/InstCombine/sitofp.ll
llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll
llvm/test/Transforms/LoopVectorize/float-induction.ll

Removed: 




diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index 2e5f521a5feaed..1271868a53b866 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -1685,7 +1685,7 @@ extern "C" __device__ double test_j1(double x) {
 // DEFAULT-NEXT:[[__X1_0_I3:%.*]] = phi float [ [[SUB_I:%.*]], 
[[FOR_BODY_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ]
 // DEFAULT-NEXT:[[__X0_0_I2:%.*]] = phi float [ [[__X1_0_I3]], 
[[FOR_BODY_I]] ], [ [[CALL_I_I]], [[IF_END4_I]] ]
 // DEFAULT-NEXT:[[MUL_I:%.*]] = shl nuw nsw i32 [[__I_0_I4]], 1
-// DEFAULT-NEXT:[[CONV_I:%.*]] = sitofp i32 [[MUL_I]] to float
+// DEFAULT-NEXT:[[CONV_I:%.*]] = uitofp nneg i32 [[MUL_I]] to float
 // DEFAULT-NEXT:[[DIV_I:%.*]] = fdiv contract float [[CONV_I]], [[Y]]
 // DEFAULT-NEXT:[[MUL8_I:%.*]] = fmul contract float [[__X1_0_I3]], 
[[DIV_I]]
 // DEFAULT-NEXT:[[SUB_I]] = fsub contract float [[MUL8_I]], [[__X0_0_I2]]
@@ -1718,7 +1718,7 @@ extern "C" __device__ double test_j1(double x) {
 // FINITEONLY-NEXT:[[__X1_0_I3:%.*]] = phi float [ [[SUB_I:%.*]], 
[[FOR_BODY_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ]
 // FINITEONLY-NEXT:[[__X0_0_I2:%.*]] = phi float [ [[__X1_0_I3]], 
[[FOR_BODY_I]] ], [ [[CALL_I_I]], [[IF_END4_I]] ]
 // FINITEONLY-NEXT:[[MUL_I:%.*]] = shl nuw nsw i32 [[__I_0_I4]], 1
-// FINITEONLY-NEXT:[[CONV_I:%.*]] = sitofp i32 [[MUL_I]] to float
+// FINITEONLY-NEXT:[[CONV_I:%.*]] = uitofp nneg i32 [[MUL_I]] to float
 // FINITEONLY-NEXT:[[DIV_I:%.*]] = fdiv nnan ninf contract float 
[[CONV_I]], [[Y]]
 // FINITEONLY-NEXT:[[MUL8_I:%.*]] = fmul nnan ninf contract float 
[[__X1_0_I3]], [[DIV_I]]
 // FINITEONLY-NEXT:[[SUB_I]] = fsub nnan ninf contract float [[MUL8_I]], 
[[__X0_0_I2]]
@@ -1751,7 +1751,7 @@ extern "C" __device__ double test_j1(double x) {
 // APPROX-NEXT:[[__X1_0_I3:%.*]] = phi float [ [[SUB_I:%.*]], 
[[FOR_BODY_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ]
 // APPROX-NEXT:[[__X0_0_I2:%.*]] = phi float [ [[__X1_0_I3]], 
[[FOR_BODY_I]] ], [ [[CALL_I_I]], [[IF_END4_I]] ]
 // APPROX-NEXT:[[MUL_I:%.*]] = shl nuw nsw i32 [[__I_0_I4]], 1
-// APPROX-NEXT:[[CONV_I:%.*]] = sitofp i32 [[MUL_I]] to float
+// APPROX-NEXT:[[CONV_I:%.*]] = uitofp nneg i32 [[MUL_I]] to float
 // APPROX-NEXT:[[DIV_I:%.*]] = fdiv contract float [[CONV_I]], [[Y]]
 // APPROX-NEXT:[[MUL8_I:%.*]] = fmul contract float [[__X1_0_I3]], 
[[DIV_I]]
 // APPROX-NEXT:[[SUB_I]] = fsub contract float [[MUL8_I]], [[__X0_0_I2]]
@@ -1788,7 +1788,7 @@ extern "C" __device__ float test_jnf(int x, float y) {
 // DEFAULT-NEXT:[[__X1_0_I3:%.*]] = phi double [ [[SUB_I:%.*]], 
[[FOR_BODY_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ]
 // DEFAULT-NEXT:[[__X0_0_I2:%.*]] = phi double [ [[__X1_0_I3]], 
[[FOR_BODY_I]] ], [ [[CALL_I_I]], [[IF_END4_I]] ]
 // DEFAULT-NEXT:[[MUL_I:%.*]] = shl nuw nsw i32 [[__I_0_I4]], 1
-// DEFAULT-NEXT:[[CONV_I:%.*]] = sitofp i32 [[MUL_I]] to double
+// DEFAULT-NEXT:[[CONV_I:%.*]] = uitofp nneg i32 [[MUL_I]] to double
 // DEFAULT-NEXT:[[DIV_I:%.*]] = fdiv contract double [[CONV_I]], [[Y]]
 // DEFAULT-NEXT:[[MUL8_I:%.*]] = fmul contract double [[__X1_0_I3]], 
[[DIV_I]]
 // DEFAULT-NEXT:[[SUB_I]] = fsub contract double [[MUL8_I]], [[__X0_0_I2]]
@@ -1821,7 +1821,7 @@ extern "C" __device__ float test_jnf(int x, float y) {
 // FINITEONLY-NEXT:[[__X1_0_I3:%.*]] = phi double [ [[SUB_I:%.*]], 
[[FOR_BODY_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ]
 // FINITEONLY-NEXT:[[__X0_0_I2:%.*]] = phi double [ [[__X1_0_I3]], 
[[FOR_BODY_I]] ], [ [[CALL_I_I]], [[IF_END4_I]] ]
 // FINITEONLY-NEXT:[[MUL_I:%.*]] = shl nuw nsw i32 [[__I_0_I4]], 1
-// FINITEONL

[clang] [llvm] [InstCombine] Add canonicalization of `sitofp` -> `uitofp nneg` (PR #88299)


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


[clang] [llvm] [RISCV] Re-separate unaligned scalar and vector memory features in the backend. (PR #88954)


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

LGTM

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


[clang] [llvm] [arm] Support reserving r4 and r5 alongside r9 (PR #88981)


https://github.com/benisxdxd created 
https://github.com/llvm/llvm-project/pull/88981

I tried doing it like 
[this](https://github.com/llvm/llvm-project/commit/fcbec02ea6fb2a76352b64790cd9ae300f6a9943)

I'm not really an expert in LLVM and such so I don't really know where to add 
tests if needed.

>From 24453d337187e43a5901337681098d2e7520b740 Mon Sep 17 00:00:00 2001
From: benisxdxd <164242179+benisx...@users.noreply.github.com>
Date: Tue, 16 Apr 2024 23:38:26 +0300
Subject: [PATCH] [arm] Support reserving r4 and r5 alongside r9

---
 clang/include/clang/Driver/Options.td   |  4 
 clang/lib/Driver/ToolChains/Arch/ARM.cpp|  8 +++-
 llvm/lib/Target/ARM/ARM.td  | 10 ++
 llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp |  7 ++-
 llvm/lib/Target/ARM/ARMSubtarget.h  |  8 
 5 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..bc7f51d72a3c72 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4754,6 +4754,10 @@ def mrestrict_it: Flag<["-"], "mrestrict-it">, 
Group,
 def mno_restrict_it: Flag<["-"], "mno-restrict-it">, 
Group,
   HelpText<"Allow generation of complex IT blocks.">;
 def marm : Flag<["-"], "marm">, Alias;
+def ffixed_r4 : Flag<["-"], "ffixed-r4">, Group,
+  HelpText<"Reserve the r4 register (ARM only)">;
+def ffixed_r5 : Flag<["-"], "ffixed-r5">, Group,
+  HelpText<"Reserve the r5 register (ARM only)">;
 def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group,
   HelpText<"Reserve the r9 register (ARM only)">;
 def mno_movt : Flag<["-"], "mno-movt">, Group,
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index a68368c4758651..4c5d1fd55d1f82 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -915,8 +915,14 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
   }
 
   // llvm does not support reserving registers in general. There is support
-  // for reserving r9 on ARM though (defined as a platform-specific register
+  // for reserving r4,r5 and r9 on ARM though (defined as a platform-specific 
register
   // in ARM EABI).
+  if (Args.hasArg(options::OPT_ffixed_r4))
+Features.push_back("+reserve-r4");
+
+  if (Args.hasArg(options::OPT_ffixed_r5))
+Features.push_back("+reserve-r5");
+
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
diff --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td
index 66596dbda83c95..782e6c5dfc091a 100644
--- a/llvm/lib/Target/ARM/ARM.td
+++ b/llvm/lib/Target/ARM/ARM.td
@@ -477,6 +477,16 @@ def FeatureReserveR9  : SubtargetFeature<"reserve-r9", 
"ReserveR9", "true",
  "Reserve R9, making it 
unavailable"
  " as GPR">;
 
+// True if R4 is not available as a general purpose register.
+def FeatureReserveR4  : SubtargetFeature<"reserve-r4", "ReserveR4", "true",
+ "Reserve R4, making it 
unavailable"
+ " as GPR">;
+
+// True if R5 is not available as a general purpose register.
+def FeatureReserveR5  : SubtargetFeature<"reserve-r5", "ReserveR5", "true",
+ "Reserve R5, making it 
unavailable"
+ " as GPR">;
+
 // True if MOVT / MOVW pairs are not used for materialization of
 // 32-bit imms (including global addresses).
 def FeatureNoMovt : SubtargetFeature<"no-movt", "NoMovt", "true",
diff --git a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp 
b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
index 9adf758b46c481..81e16239d94008 100644
--- a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
@@ -211,7 +211,12 @@ getReservedRegs(const MachineFunction &MF) const {
 markSuperRegs(Reserved, STI.getFramePointerReg());
   if (hasBasePointer(MF))
 markSuperRegs(Reserved, BasePtr);
-  // Some targets reserve R9.
+
+  // Some targets reserve R4, R5 or R9.
+  if (STI.isReserveR4()) 
+markSuperRegs(Reserved, ARM::R4);
+  if (STI.isReserveR5()) 
+markSuperRegs(Reserved, ARM::R5);
   if (STI.isR9Reserved())
 markSuperRegs(Reserved, ARM::R9);
   // Reserve D16-D31 if the subtarget doesn't support them.
diff --git a/llvm/lib/Target/ARM/ARMSubtarget.h 
b/llvm/lib/Target/ARM/ARMSubtarget.h
index 497ae160fde281..04f6abeba82f91 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.h
+++ b/llvm/lib/Target/ARM/ARMSubtarget.h
@@ -441,6 +441,14 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
 return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9;
   }
 
+  bool isR4Reserved() const {
+return ReserveR4;
+  }
+
+  bool isR5Reserved() const {
+return ReserveR5;
+  }
+
   MCPhysReg

[clang] [llvm] [arm] Support reserving r4 and r5 alongside r9 (PR #88981)


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


[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)


efriedma-quic wrote:

I don't understand the scenario you're envisioning here.  If, for example, 
`sizeof(long)` is different in the AST vs. CodeGen, everything will very likely 
explode.  And I don't want to make an open-ended commitment to support 
modifying properties of the target based on whatever happens to work at the 
moment.

What properties of the target can you safely manipulate?  Would it make sense 
to store those properties in a separate datastructure?

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


[clang] [llvm] [arm] Support reserving r4 and r5 alongside r9 (PR #88981)


llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-arm

Author: None (benisxdxd)


Changes

I tried doing it like 
[this](https://github.com/llvm/llvm-project/commit/fcbec02ea6fb2a76352b64790cd9ae300f6a9943)

I'm not really an expert in LLVM and such so I don't really know where to add 
tests if needed.

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


5 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+4) 
- (modified) clang/lib/Driver/ToolChains/Arch/ARM.cpp (+7-1) 
- (modified) llvm/lib/Target/ARM/ARM.td (+10) 
- (modified) llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp (+6-1) 
- (modified) llvm/lib/Target/ARM/ARMSubtarget.h (+8) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..bc7f51d72a3c72 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4754,6 +4754,10 @@ def mrestrict_it: Flag<["-"], "mrestrict-it">, 
Group,
 def mno_restrict_it: Flag<["-"], "mno-restrict-it">, 
Group,
   HelpText<"Allow generation of complex IT blocks.">;
 def marm : Flag<["-"], "marm">, Alias;
+def ffixed_r4 : Flag<["-"], "ffixed-r4">, Group,
+  HelpText<"Reserve the r4 register (ARM only)">;
+def ffixed_r5 : Flag<["-"], "ffixed-r5">, Group,
+  HelpText<"Reserve the r5 register (ARM only)">;
 def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group,
   HelpText<"Reserve the r9 register (ARM only)">;
 def mno_movt : Flag<["-"], "mno-movt">, Group,
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index a68368c4758651..4c5d1fd55d1f82 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -915,8 +915,14 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
   }
 
   // llvm does not support reserving registers in general. There is support
-  // for reserving r9 on ARM though (defined as a platform-specific register
+  // for reserving r4,r5 and r9 on ARM though (defined as a platform-specific 
register
   // in ARM EABI).
+  if (Args.hasArg(options::OPT_ffixed_r4))
+Features.push_back("+reserve-r4");
+
+  if (Args.hasArg(options::OPT_ffixed_r5))
+Features.push_back("+reserve-r5");
+
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
diff --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td
index 66596dbda83c95..782e6c5dfc091a 100644
--- a/llvm/lib/Target/ARM/ARM.td
+++ b/llvm/lib/Target/ARM/ARM.td
@@ -477,6 +477,16 @@ def FeatureReserveR9  : SubtargetFeature<"reserve-r9", 
"ReserveR9", "true",
  "Reserve R9, making it 
unavailable"
  " as GPR">;
 
+// True if R4 is not available as a general purpose register.
+def FeatureReserveR4  : SubtargetFeature<"reserve-r4", "ReserveR4", "true",
+ "Reserve R4, making it 
unavailable"
+ " as GPR">;
+
+// True if R5 is not available as a general purpose register.
+def FeatureReserveR5  : SubtargetFeature<"reserve-r5", "ReserveR5", "true",
+ "Reserve R5, making it 
unavailable"
+ " as GPR">;
+
 // True if MOVT / MOVW pairs are not used for materialization of
 // 32-bit imms (including global addresses).
 def FeatureNoMovt : SubtargetFeature<"no-movt", "NoMovt", "true",
diff --git a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp 
b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
index 9adf758b46c481..81e16239d94008 100644
--- a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
@@ -211,7 +211,12 @@ getReservedRegs(const MachineFunction &MF) const {
 markSuperRegs(Reserved, STI.getFramePointerReg());
   if (hasBasePointer(MF))
 markSuperRegs(Reserved, BasePtr);
-  // Some targets reserve R9.
+
+  // Some targets reserve R4, R5 or R9.
+  if (STI.isReserveR4()) 
+markSuperRegs(Reserved, ARM::R4);
+  if (STI.isReserveR5()) 
+markSuperRegs(Reserved, ARM::R5);
   if (STI.isR9Reserved())
 markSuperRegs(Reserved, ARM::R9);
   // Reserve D16-D31 if the subtarget doesn't support them.
diff --git a/llvm/lib/Target/ARM/ARMSubtarget.h 
b/llvm/lib/Target/ARM/ARMSubtarget.h
index 497ae160fde281..04f6abeba82f91 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.h
+++ b/llvm/lib/Target/ARM/ARMSubtarget.h
@@ -441,6 +441,14 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
 return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9;
   }
 
+  bool isR4Reserved() const {
+return ReserveR4;
+  }
+
+  bool isR5Reserved() const {
+return ReserveR5;
+  }
+
   MCPhysReg getFramePointerReg() const {
 if (isTargetDarwin() ||
 (!isTargetWindows() && isThumb() && !createAAPCSFrameChain()))

``




https://github.com/

[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)


https://github.com/pogo59 commented:

The flag situation is good. Tuning influences the default for the new option, 
which is how we want that to work.

I'm happy, a couple of nits left. I'll leave it to others to do the final 
approval.

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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)



@@ -1332,6 +1332,54 @@ llvm::DIType *CGDebugInfo::CreateType(const 
TemplateSpecializationType *Ty,
   auto PP = getPrintingPolicy();
   Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
 
+  SourceLocation Loc = AliasDecl->getLocation();
+
+  if (CGM.getCodeGenOpts().DebugTemplateAlias) {
+// TemplateSpecializationType doesn't know if its template args are
+// being substitued into a parameter pack. We can find out if that's

pogo59 wrote:

substituted

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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)


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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)



@@ -465,3 +465,15 @@
 // MANGLED_TEMP_NAMES: error: unknown argument 
'-gsimple-template-names=mangled'; did you mean '-Xclang 
-gsimple-template-names=mangled'
 // RUN: %clang -### -target x86_64 -c -g %s 2>&1 | FileCheck 
--check-prefix=FULL_TEMP_NAMES 
--implicit-check-not=debug-forward-template-params %s
 // FULL_TEMP_NAMES-NOT: -gsimple-template-names
+
+ Test -g[no-]template-alias (enabled by default with SCE debugger tuning). 
Requires DWARFv5.
+// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce %s 2>&1 | FileCheck %s 
--check-prefixes=TEMPLATE-ALIAS

pogo59 wrote:

Huh Coulda sworn that was changed... okay.

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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)



@@ -310,6 +310,24 @@ namespace llvm {
  DINode::DIFlags Flags = DINode::FlagZero,
  DINodeArray Annotations = nullptr);
 
+/// Create debugging information entry for a template alias.
+/// \param Ty  Original type.
+/// \param NameAlias name.
+/// \param FileFile where this type is defined.
+/// \param LineNo  Line number.
+/// \param Context The surrounding context for the alias.
+/// \param TParams The template arguments.
+/// \param AlignInBits Alignment. (optional)
+/// \param Flags   Flags to describe inheritance attribute (optional),
+///e.g. private.

pogo59 wrote:

Flags is also (optional)

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


[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)



@@ -26,123 +26,132 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
-
-/// ASTConsumer - This is an abstract interface that should be implemented by
-/// clients that read ASTs.  This abstraction layer allows the client to be
-/// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
-class ASTConsumer {
-  /// Whether this AST consumer also requires information about
-  /// semantic analysis.
-  bool SemaConsumer = false;
-
-  friend class SemaConsumer;
-
-public:
-  ASTConsumer() = default;
-
-  virtual ~ASTConsumer() {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext &Context) {}
-
-  /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
-  /// called by the parser to process every top-level Decl*.
-  ///
-  /// \returns true to continue parsing, or false to abort parsing.
-  virtual bool HandleTopLevelDecl(DeclGroupRef D);
-
-  /// This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
-
-  /// HandleInterestingDecl - Handle the specified interesting declaration. 
This
-  /// is called by the AST reader when deserializing things that might interest
-  /// the consumer. The default implementation forwards to HandleTopLevelDecl.
-  virtual void HandleInterestingDecl(DeclGroupRef D);
-
-  /// HandleTranslationUnit - This method is called when the ASTs for entire
-  /// translation unit have been parsed.
-  virtual void HandleTranslationUnit(ASTContext &Ctx) {}
-
-  /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
-  /// (e.g. struct, union, enum, class) is completed.  This allows the client 
to
-  /// hack on the type, which can occur at any point in the file (because these
-  /// can be defined in declspecs).
-  virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
-  /// This callback is invoked the first time each TagDecl is required to
-  /// be complete.
-  virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
-
-  /// Invoked when a function is implicitly instantiated.
-  /// Note that at this point it does not have a body, its body is
-  /// instantiated at the end of the translation unit and passed to
-  /// HandleTopLevelDecl.
-  virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
-
-  /// Handle the specified top-level declaration that occurred inside
-  /// and ObjC container.
-  /// The default implementation ignored them.
-  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
-
-  /// Handle an ImportDecl that was implicitly created due to an
-  /// inclusion directive.
-  /// The default implementation passes it to HandleTopLevelDecl.
-  virtual void HandleImplicitImportDecl(ImportDecl *D);
-
-  /// CompleteTentativeDefinition - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given tentative definition should be
-  /// completed.
-  ///
-  /// The variable declaration itself will be a tentative
-  /// definition. If it had an incomplete array type, its type will
-  /// have already been changed to an array of size 1. However, the
-  /// declaration remains a tentative definition and has not been
-  /// modified by the introduction of an implicit zero initializer.
-  virtual void CompleteTentativeDefinition(VarDecl *D) {}
-
-  /// CompleteExternalDeclaration - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given external declaration should be
-  /// completed.
-  virtual void CompleteExternalDeclaration(VarDecl *D) {}
-
-  /// Callback invoked when an MSInheritanceAttr has been attached to a
-  /// CXXRecordDecl.
-  virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
-
-  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
-  // variable has been instantiated.
-  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
-
-  /// Callback involved at the end of a translation unit to
-  /// notify the consumer that a vtable for the given C++ class is
-  /// required.
-  ///
-  /// \param RD The class whose vtable was used.
-  virtual void HandleVTable(CXXRecordDecl *RD) {}
-
-  /// If the consumer is interested in entities getting modified after
-  /// their initial creation, it should return a pointer to
-  /// an ASTMutationListener here.
-  virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
-
-  /// If the consumer is interested in entities being deserialized from
-  /// AST files, it should return a pointer to a ASTDeserializationListener 
here
-  virtual ASTDeserializationListener *GetASTDeserializationListener() {
-return nullptr;
-  }
-
-  /// PrintStats - If desired, print any statistics.
-  virtual void PrintStats() {}
-
-  /// This callback is called for each funct

[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)



@@ -26,123 +26,132 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
-
-/// ASTConsumer - This is an abstract interface that should be implemented by
-/// clients that read ASTs.  This abstraction layer allows the client to be
-/// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
-class ASTConsumer {
-  /// Whether this AST consumer also requires information about
-  /// semantic analysis.
-  bool SemaConsumer = false;
-
-  friend class SemaConsumer;
-
-public:
-  ASTConsumer() = default;
-
-  virtual ~ASTConsumer() {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext &Context) {}
-
-  /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
-  /// called by the parser to process every top-level Decl*.
-  ///
-  /// \returns true to continue parsing, or false to abort parsing.
-  virtual bool HandleTopLevelDecl(DeclGroupRef D);
-
-  /// This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
-
-  /// HandleInterestingDecl - Handle the specified interesting declaration. 
This
-  /// is called by the AST reader when deserializing things that might interest
-  /// the consumer. The default implementation forwards to HandleTopLevelDecl.
-  virtual void HandleInterestingDecl(DeclGroupRef D);
-
-  /// HandleTranslationUnit - This method is called when the ASTs for entire
-  /// translation unit have been parsed.
-  virtual void HandleTranslationUnit(ASTContext &Ctx) {}
-
-  /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
-  /// (e.g. struct, union, enum, class) is completed.  This allows the client 
to
-  /// hack on the type, which can occur at any point in the file (because these
-  /// can be defined in declspecs).
-  virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
-  /// This callback is invoked the first time each TagDecl is required to
-  /// be complete.
-  virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
-
-  /// Invoked when a function is implicitly instantiated.
-  /// Note that at this point it does not have a body, its body is
-  /// instantiated at the end of the translation unit and passed to
-  /// HandleTopLevelDecl.
-  virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
-
-  /// Handle the specified top-level declaration that occurred inside
-  /// and ObjC container.
-  /// The default implementation ignored them.
-  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
-
-  /// Handle an ImportDecl that was implicitly created due to an
-  /// inclusion directive.
-  /// The default implementation passes it to HandleTopLevelDecl.
-  virtual void HandleImplicitImportDecl(ImportDecl *D);
-
-  /// CompleteTentativeDefinition - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given tentative definition should be
-  /// completed.
-  ///
-  /// The variable declaration itself will be a tentative
-  /// definition. If it had an incomplete array type, its type will
-  /// have already been changed to an array of size 1. However, the
-  /// declaration remains a tentative definition and has not been
-  /// modified by the introduction of an implicit zero initializer.
-  virtual void CompleteTentativeDefinition(VarDecl *D) {}
-
-  /// CompleteExternalDeclaration - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given external declaration should be
-  /// completed.
-  virtual void CompleteExternalDeclaration(VarDecl *D) {}
-
-  /// Callback invoked when an MSInheritanceAttr has been attached to a
-  /// CXXRecordDecl.
-  virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
-
-  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
-  // variable has been instantiated.
-  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
-
-  /// Callback involved at the end of a translation unit to
-  /// notify the consumer that a vtable for the given C++ class is
-  /// required.
-  ///
-  /// \param RD The class whose vtable was used.
-  virtual void HandleVTable(CXXRecordDecl *RD) {}
-
-  /// If the consumer is interested in entities getting modified after
-  /// their initial creation, it should return a pointer to
-  /// an ASTMutationListener here.
-  virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
-
-  /// If the consumer is interested in entities being deserialized from
-  /// AST files, it should return a pointer to a ASTDeserializationListener 
here
-  virtual ASTDeserializationListener *GetASTDeserializationListener() {
-return nullptr;
-  }
-
-  /// PrintStats - If desired, print any statistics.
-  virtual void PrintStats() {}
-
-  /// This callback is called for each funct

[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)


https://github.com/efriedma-quic approved this pull request.

LGTM

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


[clang] [Coverage] Handle array decomposition correctly (PR #88881)


efriedma-quic wrote:

I don't think this works correctly?  You need to evaluate both the 
getCommonExpr(), and the getSubExpr().

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


[clang] d19bd05 - Clang Release Notes: Fix reST formatting


Author: Hubert Tong
Date: 2024-04-16T17:26:55-04:00
New Revision: d19bd05c79ad3b1a2c3cb439c3fc60825f66bed7

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

LOG: Clang Release Notes: Fix reST formatting

Fix a use of inline code markup to have a non-word character after the ending 
delimiter as required by reST.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e6c345a2f5c0f5..4aedfafcb26aea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -68,7 +68,7 @@ AST Dumping Potentially Breaking Changes
 
 Clang Frontend Potentially Breaking Changes
 ---
-- Removed support for constructing on-stack ``TemplateArgumentList``s; 
interfaces should instead
+- Removed support for constructing on-stack ``TemplateArgumentList``\ s; 
interfaces should instead
   use ``ArrayRef`` to pass template arguments. Transitioning 
internal uses to
   ``ArrayRef`` reduces AST memory usage by 0.4% when 
compiling clang, and is
   expected to show similar improvements on other workloads.



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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)



@@ -1332,6 +1332,54 @@ llvm::DIType *CGDebugInfo::CreateType(const 
TemplateSpecializationType *Ty,
   auto PP = getPrintingPolicy();
   Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
 
+  SourceLocation Loc = AliasDecl->getLocation();
+
+  if (CGM.getCodeGenOpts().DebugTemplateAlias) {
+// TemplateSpecializationType doesn't know if its template args are
+// being substituted into a parameter pack. We can find out if that's
+// the case now by inspecting the TypeAliasTemplateDecl template
+// parameters. Insert Ty's template args into SpecArgs, bundling args
+// passed to a parameter pack into a TemplateArgument::Pack.
+SmallVector SpecArgs;
+{
+  ArrayRef SubstArgs = Ty->template_arguments();
+  for (const NamedDecl *P : TD->getTemplateParameters()->asArray()) {
+if (P->isParameterPack()) {
+  SpecArgs.push_back(TemplateArgument(SubstArgs));
+  break;
+}
+// Skip defaulted args.
+if (SubstArgs.empty()) {
+  // If SubstArgs is now empty (we're taking from it each iteration) 
and
+  // this template parameter isn't a pack, then that should mean we're
+  // using default values for the remaining template parameters.
+  break;

Michael137 wrote:

Does this mean we won't be emitting the defaulted template arguments as part of 
the `DW_TAG_template_alias`? Would be good to add a test case for defaulted 
arguments, so this logic is exercised (if you haven't already)

Also minor nit, is this logic getting sufficiently long to warrant a separate 
helper function?

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


[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)


zygoloid wrote:

Have you tried changing the behavior of the existing `-fmodule-map-file=` to 
load the file after we load module files? If so, what kinds of things do you 
see breaking or changing? If we can avoid it, I think it would be better to 
only have a single mode here, and loading the module files first seems to make 
a lot of sense given that they can make it unnecessary to load the module map 
files at all.

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)


ian-twilightcoder wrote:

Wall of text incoming... Sorry but our documentation in this area is poor, so I 
feel like I need to spell out the assumptions behind this change.

First of all, this _should_ be a relatively minor change that should affect a 
very limited set of circumstances.
1. Only `#import` should be affected, not `#include`.
2. Only headers marked `textual header` in a module map should be affected, 
nothing else.
3. Headers that use `#pragma once` or have header guards should not be affected.
4. Module map reading should not be affected.

That should end up being a rather narrow change, and if something else got 
affected I'd like to know what and fix it.


`#import` is already treated differently if modules are enabled. This adds 
another case to the special treatment, but doesn't introduce that fact that 
sometimes `#import`ed headers will be re-entered when building with modules. We 
can say we don't like `#import` behaving differently when modules are enabled. 
However, it's not going to be any harder to undo this special treatment than it 
will to undo the other ones, if we ever care enough to try, so I don't think 
this is such an egregious change.

`textual header`s are already treated differently as well. To better define 
that, there are 4 different types of headers in a clang modules world.

1. Headers covered by a `header` statement in a module map - ye olde standard 
include-once header.
2. Headers covered by a `textual header` statement in a module map - usually 
headers that are intended to be included multiple times. Generally these are X 
macro generator headers, or special headers like  or clang's 
 and  which are designed to have different behavior based 
on the preprocessor environment of the includer.
3. Headers covered by an `exclude header` statement in a module map - headers 
that can't be used in a module. Sometimes these are just obsolete headers, and 
sometimes it's headers that have dependencies that can't be used in a module.
4. Headers that are not listed in any module map. These are essentially the 
same thing as excluded headers.

There's a semantic difference between textual and excluded headers. Textual 
headers are anointed to be safe to use in modules, and excluded headers are not 
supposed to be included from any modular header. (If I had my way, 
`-Wnon-modular-include-in-module` would default to an error much like 
`-Wmodule-import-in-extern-c` does, but that can be a soap box for another 
day.) Textual headers are already treated differently from excluded headers in 
a few ways, such as they respect `[no_undeclared_includes]`/`use`, while 
excluded headers don't.

All this to say that `#import`ed headers are already treated different when 
modules are enabled, and textual headers are already treated different than 
excluded headers. I think it's fine to tweak this different treatment, 
especially since it's solving a real world problem that occurs in a fully 
modularized system. I also think it's preferable to focus the change down to 
the very specific problem, which is `#import`ed textual headers, instead of 
trying to fix all of the submodule visibility problems we can think of.

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)


ian-twilightcoder wrote:

> To get back to my previous point about the semantics implemented by this 
> patch being unfortunate -- the upshot is that, now:
> 
> ```
> #include 
> #define NDEBUG
> #import 
> ```

It would be nice if we could make this work without modules too. `#pragma many` 
or something would do that, but I fear we'd have compatibility issues if we 
added a pragma that's only supported by clang to a bunch of system headers.

> This doesn't make sense: with modules disabled, everything is textual -- to 
> say that "textual header" in a modulemap should make a header somehow "more" 
> textual than the default non-modular behavior is weird.

With modules disabled, everything isn't textual - it's effectively excluded. 
`textual` was probably not the best name for that keyword in the module map.

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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)


Michael137 wrote:

Btw, as a follow-up to this patch should we check that this is compatible with 
dsymutil (i.e., running `dsymutil --verify`)? I suspect it might need a fixup 
(given LLDB doesn't even support this tag)

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


[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)


ian-twilightcoder wrote:

+ @Bigcheese and @jansvoboda11 as I think they know this area of the code better

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


[clang] [Coverage] Handle array decomposition correctly (PR #88881)


bolshakov-a wrote:

Honestly, I'm not very familiar with code coverage technique, but it seems to 
me that only explicitly written code is relevant for that. "Common expression" 
is exactly the explicitly written part. "Subexpression" is an implicitly 
generated per-element initializer which refers to the "common expression" 
(hence, without this patch, the counters for the conditional operator from the 
test are duplicated despite it is executed only once per function call). Which 
observable drawbacks do you expect from not visiting the implicit parts of the 
initializer?

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


[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)


bolshakov-a wrote:

Could you merge it please?

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


[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)


https://github.com/artemcm updated 
https://github.com/llvm/llvm-project/pull/88977

>From 04e826688a504e141f3407567616bcf5cce9e2cc Mon Sep 17 00:00:00 2001
From: Artem Chikin 
Date: Wed, 20 Dec 2023 10:56:42 -0800
Subject: [PATCH] [NFC] Parameterize Initialization of 'clang::CodeGenerator'
 on a TargetInfo instance which may differ from the one in the ASTContext

As per https://github.com/apple/swift/pull/65930, Swift compiler's built-in 
Clang instance may require to perform type-checking against one OS version and 
compilation/code-generation against an earlier version. This change allows 
Swift to configure it's built-in Clang code-generator with a custom 
'TargetInfo'.
---
 clang/include/clang/AST/ASTConsumer.h |  5 
 clang/lib/CodeGen/CodeGenModule.cpp   | 29 +--
 clang/lib/CodeGen/CodeGenModule.h |  3 +-
 clang/lib/CodeGen/ModuleBuilder.cpp   | 21 +-
 .../ObjectFilePCHContainerOperations.cpp  |  5 ++--
 5 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/clang/include/clang/AST/ASTConsumer.h 
b/clang/include/clang/AST/ASTConsumer.h
index ebcd8059284d8d..774d19565e57b0 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -26,6 +26,7 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
+  class TargetInfo;
 
 /// ASTConsumer - This is an abstract interface that should be implemented by
 /// clients that read ASTs.  This abstraction layer allows the client to be
@@ -46,6 +47,10 @@ class ASTConsumer {
   /// ASTContext.
   virtual void Initialize(ASTContext &Context) {}
 
+  /// Initialize - This is called to initialize the consumer, providing the
+  /// ASTContext.
+  virtual void Initialize(ASTContext &Context, const TargetInfo 
&CodeGenTargetInfo) {}
+
   /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
   /// called by the parser to process every top-level Decl*.
   ///
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0c447b20cef40d..8380b71ababe5b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -333,14 +333,13 @@ CodeGenModule::CodeGenModule(ASTContext &C,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions &HSO,
  const PreprocessorOptions &PPO,
- const CodeGenOptions &CGO, llvm::Module &M,
- DiagnosticsEngine &diags,
+ const CodeGenOptions &CGO, const TargetInfo &CGTI,
+ llvm::Module &M, DiagnosticsEngine &diags,
  CoverageSourceInfo *CoverageInfo)
 : Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
   PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
-  Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
-  VMContext(M.getContext()), Types(*this), VTables(*this),
-  SanitizerMD(new SanitizerMetadata(*this)) {
+  Target(CGTI), ABI(createCXXABI(*this)), VMContext(M.getContext()),
+  Types(*this), VTables(*this), SanitizerMD(new SanitizerMetadata(*this)) {
 
   // Initialize the type cache.
   llvm::LLVMContext &LLVMContext = M.getContext();
@@ -353,20 +352,18 @@ CodeGenModule::CodeGenModule(ASTContext &C,
   BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
   FloatTy = llvm::Type::getFloatTy(LLVMContext);
   DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
-  PointerWidthInBits = C.getTargetInfo().getPointerWidth(LangAS::Default);
+  PointerWidthInBits = Target.getPointerWidth(LangAS::Default);
   PointerAlignInBytes =
-  C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(LangAS::Default))
+  C.toCharUnitsFromBits(Target.getPointerAlign(LangAS::Default))
   .getQuantity();
   SizeSizeInBytes =
-
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
-  IntAlignInBytes =
-C.toCharUnitsFromBits(C.getTargetInfo().getIntAlign()).getQuantity();
-  CharTy =
-llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getCharWidth());
-  IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
-  IntPtrTy = llvm::IntegerType::get(LLVMContext,
-C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  C.toCharUnitsFromBits(Target.getMaxPointerWidth()).getQuantity();
+  IntAlignInBytes = C.toCharUnitsFromBits(Target.getIntAlign()).getQuantity();
+  CharTy = llvm::IntegerType::get(LLVMContext, Target.getCharWidth());
+  IntTy = llvm::IntegerType::get(LLVMContext, Target.getIntWidth());
+  IntPtrTy = llvm::IntegerType::get(LLVMContext, Target.getMaxPointerWidth());
+  Int8PtrTy = Int8Ty->getPointerTo(0);
+  Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
   const llvm::DataLayout &DL = M.getDataLayout();
   AllocaInt8PtrTy =
   

[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)



@@ -67,57 +67,42 @@ enum CPUFeatures {
   FEAT_FP,
   FEAT_SIMD,
   FEAT_CRC,
-  FEAT_SHA1,
   FEAT_SHA2,
   FEAT_SHA3,
   FEAT_AES,
-  FEAT_PMULL,
   FEAT_FP16,
-  FEAT_DIT,
   FEAT_DPB,
   FEAT_DPB2,
   FEAT_JSCVT,
   FEAT_FCMA,
   FEAT_RCPC,
   FEAT_RCPC2,
   FEAT_FRINTTS,
-  FEAT_DGH,
   FEAT_I8MM,
   FEAT_BF16,
-  FEAT_EBF16,
   FEAT_RPRES,
   FEAT_SVE,
-  FEAT_SVE_BF16,
-  FEAT_SVE_EBF16,
-  FEAT_SVE_I8MM,
   FEAT_SVE_F32MM,
   FEAT_SVE_F64MM,
   FEAT_SVE2,
   FEAT_SVE_AES,
-  FEAT_SVE_PMULL128,
   FEAT_SVE_BITPERM,
   FEAT_SVE_SHA3,
   FEAT_SVE_SM4,
   FEAT_SME,
   FEAT_MEMTAG,
-  FEAT_MEMTAG2,
-  FEAT_MEMTAG3,
   FEAT_SB,
   FEAT_PREDRES,
   FEAT_SSBS,
-  FEAT_SSBS2,
-  FEAT_BTI,
   FEAT_LS64,
-  FEAT_LS64_V,
-  FEAT_LS64_ACCDATA,
   FEAT_WFXT,
   FEAT_SME_F64,
   FEAT_SME_I64,
   FEAT_SME2,
   FEAT_RCPC3,
   FEAT_MOPS,
   FEAT_MAX,
-  FEAT_EXT = 62, // Reserved to indicate presence of additional features field

jroelofs wrote:

Did any implementation ship `__aarch64_cpu_features` in a way that would make 
this an ABI break? We (Apple) talked about putting these in libSystem, and now 
I am glad we did not. It's okay to change/reorder them if it is a private 
implementation detail between the compiler and compiler-rt that is shipped with 
it, but as soon as they're part of an ABI, this list must become append only.

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


[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)


https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/88595

>From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 1/2] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
 clang/test/Sema/format-strings-scanf.c   | 2 +-
 clang/test/Sema/format-strings-signedness.c  | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 774d2b53a38252..4ba27d62208da4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9827,7 +9827,7 @@ def warn_scanf_nonzero_width : Warning<
 def warn_format_conversion_argument_type_mismatch : Warning<
   "format specifies type %0 but the argument has "
   "%select{type|underlying type}2 %1">,
-  InGroup;
+  InGroup;
 def warn_format_conversion_argument_type_mismatch_pedantic : Extension<
   warn_format_conversion_argument_type_mismatch.Summary>,
   InGroup;
@@ -9840,7 +9840,7 @@ def 
warn_format_conversion_argument_type_mismatch_confusion : Warning<
 def warn_format_argument_needs_cast : Warning<
   "%select{values of type|enum values with underlying type}2 '%0' should not "
   "be used as format arguments; add an explicit cast to %1 instead">,
-  InGroup;
+  InGroup;
 def warn_format_argument_needs_cast_pedantic : Warning<
   warn_format_argument_needs_cast.Summary>,
   InGroup, DefaultIgnore;
diff --git a/clang/test/Sema/format-strings-scanf.c 
b/clang/test/Sema/format-strings-scanf.c
index eb5b8ec36bf7a4..9bdc46bfeebc3b 100644
--- a/clang/test/Sema/format-strings-scanf.c
+++ b/clang/test/Sema/format-strings-scanf.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 
 // Test that -Wformat=0 works:
-// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 
-Wno-format-pedantic %s
 
 #include 
 typedef __SIZE_TYPE__ size_t;
diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index d5a8140d9ef8a0..ccd4d72c2d2635 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -12,8 +12,8 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
 // Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify=okay %s
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify=okay %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
 
 int printf(const char *restrict format, ...);
@@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) {
 void test_suppress(int x)
 {
 #pragma GCC diagnostic ignored "-Wformat"
-printf("%u", x);
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}
 }

>From 46e8d902d92b71e9bad2321321eed3de489e837f Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 2/2] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.

Fixes #81647
---
 clang/test/Sema/format-strings-signedness.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index ccd4d72c2d2635..a06884cb9fe090 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -11,7 +11,7 @@
 // (gcc compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
-// Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
+// Verify that -Wformat-signedness with -Wno-format are still reported (gcc 
compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
@@ -213,7 +213,7 @@ void test_printf_unsigned_priX16(uint16_t x) {
   printf("PRIX16: %" "X" /*PRIX16*/ "\n", x); // no-warning
 }
 
-// Verify that we can suppress a -Wformat-signedness warning by ignoring
+// Verify that we can not suppress a -Wformat-signedness warning by ignoring
 // -Wformat (gcc compat).
 void test_suppres

[clang] Allow struct q{int q;~q();} (#88597) (PR #88673)


https://github.com/nabijaczleweli updated 
https://github.com/llvm/llvm-project/pull/88673

From 05545c8cc2ef2751128f1906933151fb09e37b65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= 
Date: Mon, 15 Apr 2024 03:52:50 +0200
Subject: [PATCH 1/2] Allow struct q{int q;~q();} (#88597)

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 --
 clang/lib/Sema/SemaExprCXX.cpp   | 5 ++---
 clang/test/CXX/class/class.mem/p13.cpp   | 1 -
 clang/test/SemaCXX/GH59446.cpp   | 1 -
 clang/test/SemaCXX/constructor.cpp   | 5 ++---
 5 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5ec0218aedfe86..c8c3f2de81f82a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2187,8 +2187,6 @@ def err_undeclared_destructor_name : Error<
   "undeclared identifier %0 in destructor name">;
 def err_destructor_name : Error<
   "expected the class name after '~' to name the enclosing class">;
-def err_destructor_name_nontype : Error<
-  "identifier %0 after '~' in destructor name does not name a type">;
 def err_destructor_expr_mismatch : Error<
   "identifier %0 in object destruction expression does not name the type "
   "%1 of the object being destroyed">;
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 25f23a3abf1718..69d4a6d51ecafb 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -448,9 +448,8 @@ ParsedType Sema::getDestructorName(const IdentifierInfo &II,
   Diag(NameLoc, diag::err_destructor_expr_nontype)
   << &II << MakeFixItHint();
 }
-  } else {
-Diag(NameLoc, SearchType.isNull() ? diag::err_destructor_name_nontype
-  : diag::err_destructor_expr_mismatch)
+  } else if (!SearchType.isNull()) {
+Diag(NameLoc, diag::err_destructor_expr_mismatch)
 << &II << SearchType << MakeFixItHint();
   }
 
diff --git a/clang/test/CXX/class/class.mem/p13.cpp 
b/clang/test/CXX/class/class.mem/p13.cpp
index d947586c419400..1a3173ddfa474c 100644
--- a/clang/test/CXX/class/class.mem/p13.cpp
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -112,5 +112,4 @@ template struct Dtemplate_with_ctors : B {
 template struct CtorDtorName : B {
   using B::CtorDtorName; // expected-error {{member 'CtorDtorName' has the 
same name as its class}} expected-note {{non-type declaration found by 
destructor name lookup}}
   CtorDtorName();
-  ~CtorDtorName(); // expected-error {{identifier 'CtorDtorName' after '~' in 
destructor name does not name a type}}
 };
diff --git a/clang/test/SemaCXX/GH59446.cpp b/clang/test/SemaCXX/GH59446.cpp
index b85a57abb9fa57..c0c1c40265f8be 100644
--- a/clang/test/SemaCXX/GH59446.cpp
+++ b/clang/test/SemaCXX/GH59446.cpp
@@ -8,5 +8,4 @@ namespace N {
   }
   void f(X *x) { // expected-error {{no template named 'X'; did you mean 
'N::X'}}
 x->N::X::~X(); // expected-error 2 {{implicit instantiation of 
undefined template 'GH59446::N::X'}}
-// expected-error@-1 {{identifier 'X' after '~' in 
destructor name does not name a type}}
 } // expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/constructor.cpp 
b/clang/test/SemaCXX/constructor.cpp
index abd7dbe18a0e6a..64683675805924 100644
--- a/clang/test/SemaCXX/constructor.cpp
+++ b/clang/test/SemaCXX/constructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 typedef int INT;
 
 class Foo {
@@ -14,7 +14,7 @@ class Foo {
   static Foo(short, short); // expected-error{{constructor cannot be declared 
'static'}}
   virtual Foo(double); // expected-error{{constructor cannot be declared 
'virtual'}}
   Foo(long) const; // expected-error{{'const' qualifier is not allowed on a 
constructor}}
-  
+
   int Foo(int, int); // expected-error{{constructor cannot have a return type}}
 
   volatile Foo(float); // expected-error{{constructor cannot have a return 
type}}
@@ -94,5 +94,4 @@ namespace PR38286 {
   template struct B;
   template void B::f() {} // expected-error {{out-of-line 
definition of 'f' from class 'B'}}
   template struct C; // expected-note {{non-type declaration found}}
-  template C::~C() {} // expected-error {{identifier 'C' after 
'~' in destructor name does not name a type}}
 }

From 0d8b4fe52595db3c43d3fbc4039c7965c05f3ac3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= 
Date: Wed, 17 Apr 2024 00:37:35 +0200
Subject: [PATCH 2/2] ?

---
 clang/test/CXX/class/class.mem/p13.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CXX/class/class.mem/p13.cpp 
b/clang/test/CXX/class/class.mem/p13.cpp
index 1a3173ddfa474c..afccdc57114a12 100644
--- a/clang/test/CXX/class/class.mem/p13.cpp
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -110,6 +110,6 @@ temp

[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)


https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/88595

>From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 1/3] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
 clang/test/Sema/format-strings-scanf.c   | 2 +-
 clang/test/Sema/format-strings-signedness.c  | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 774d2b53a38252..4ba27d62208da4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9827,7 +9827,7 @@ def warn_scanf_nonzero_width : Warning<
 def warn_format_conversion_argument_type_mismatch : Warning<
   "format specifies type %0 but the argument has "
   "%select{type|underlying type}2 %1">,
-  InGroup;
+  InGroup;
 def warn_format_conversion_argument_type_mismatch_pedantic : Extension<
   warn_format_conversion_argument_type_mismatch.Summary>,
   InGroup;
@@ -9840,7 +9840,7 @@ def 
warn_format_conversion_argument_type_mismatch_confusion : Warning<
 def warn_format_argument_needs_cast : Warning<
   "%select{values of type|enum values with underlying type}2 '%0' should not "
   "be used as format arguments; add an explicit cast to %1 instead">,
-  InGroup;
+  InGroup;
 def warn_format_argument_needs_cast_pedantic : Warning<
   warn_format_argument_needs_cast.Summary>,
   InGroup, DefaultIgnore;
diff --git a/clang/test/Sema/format-strings-scanf.c 
b/clang/test/Sema/format-strings-scanf.c
index eb5b8ec36bf7a4..9bdc46bfeebc3b 100644
--- a/clang/test/Sema/format-strings-scanf.c
+++ b/clang/test/Sema/format-strings-scanf.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 
 // Test that -Wformat=0 works:
-// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 
-Wno-format-pedantic %s
 
 #include 
 typedef __SIZE_TYPE__ size_t;
diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index d5a8140d9ef8a0..ccd4d72c2d2635 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -12,8 +12,8 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
 // Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify=okay %s
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify=okay %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
 
 int printf(const char *restrict format, ...);
@@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) {
 void test_suppress(int x)
 {
 #pragma GCC diagnostic ignored "-Wformat"
-printf("%u", x);
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}
 }

>From 46e8d902d92b71e9bad2321321eed3de489e837f Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 2/3] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.

Fixes #81647
---
 clang/test/Sema/format-strings-signedness.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index ccd4d72c2d2635..a06884cb9fe090 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -11,7 +11,7 @@
 // (gcc compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
-// Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
+// Verify that -Wformat-signedness with -Wno-format are still reported (gcc 
compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
@@ -213,7 +213,7 @@ void test_printf_unsigned_priX16(uint16_t x) {
   printf("PRIX16: %" "X" /*PRIX16*/ "\n", x); // no-warning
 }
 
-// Verify that we can suppress a -Wformat-signedness warning by ignoring
+// Verify that we can not suppress a -Wformat-signedness warning by ignoring
 // -Wformat (gcc compat).
 void test_suppres

[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)


https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/88595

>From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 1/4] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
 clang/test/Sema/format-strings-scanf.c   | 2 +-
 clang/test/Sema/format-strings-signedness.c  | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 774d2b53a38252..4ba27d62208da4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9827,7 +9827,7 @@ def warn_scanf_nonzero_width : Warning<
 def warn_format_conversion_argument_type_mismatch : Warning<
   "format specifies type %0 but the argument has "
   "%select{type|underlying type}2 %1">,
-  InGroup;
+  InGroup;
 def warn_format_conversion_argument_type_mismatch_pedantic : Extension<
   warn_format_conversion_argument_type_mismatch.Summary>,
   InGroup;
@@ -9840,7 +9840,7 @@ def 
warn_format_conversion_argument_type_mismatch_confusion : Warning<
 def warn_format_argument_needs_cast : Warning<
   "%select{values of type|enum values with underlying type}2 '%0' should not "
   "be used as format arguments; add an explicit cast to %1 instead">,
-  InGroup;
+  InGroup;
 def warn_format_argument_needs_cast_pedantic : Warning<
   warn_format_argument_needs_cast.Summary>,
   InGroup, DefaultIgnore;
diff --git a/clang/test/Sema/format-strings-scanf.c 
b/clang/test/Sema/format-strings-scanf.c
index eb5b8ec36bf7a4..9bdc46bfeebc3b 100644
--- a/clang/test/Sema/format-strings-scanf.c
+++ b/clang/test/Sema/format-strings-scanf.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 
 // Test that -Wformat=0 works:
-// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 
-Wno-format-pedantic %s
 
 #include 
 typedef __SIZE_TYPE__ size_t;
diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index d5a8140d9ef8a0..ccd4d72c2d2635 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -12,8 +12,8 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
 // Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify=okay %s
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify=okay %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
 
 int printf(const char *restrict format, ...);
@@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) {
 void test_suppress(int x)
 {
 #pragma GCC diagnostic ignored "-Wformat"
-printf("%u", x);
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}
 }

>From 46e8d902d92b71e9bad2321321eed3de489e837f Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 2/4] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.

Fixes #81647
---
 clang/test/Sema/format-strings-signedness.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index ccd4d72c2d2635..a06884cb9fe090 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -11,7 +11,7 @@
 // (gcc compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
-// Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
+// Verify that -Wformat-signedness with -Wno-format are still reported (gcc 
compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
@@ -213,7 +213,7 @@ void test_printf_unsigned_priX16(uint16_t x) {
   printf("PRIX16: %" "X" /*PRIX16*/ "\n", x); // no-warning
 }
 
-// Verify that we can suppress a -Wformat-signedness warning by ignoring
+// Verify that we can not suppress a -Wformat-signedness warning by ignoring
 // -Wformat (gcc compat).
 void test_suppres

[clang] [clang-tools-extra] [clang-tidy] Add new check `modernize-use-designated-initializers` (PR #80541)

Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= 
Message-ID:
In-Reply-To: 


sam-mccall wrote:

TL;DR: sounds like I should revert the removals/deps in clangd, and let you 
decide how to structure clang-tidy's copy of the code?

`tidy::utils` as a dep has a conceptual layering problem, and a few practical 
ones: it brings in a pile of dependencies that aren't otherwise in the no-tidy 
build (effect: much longer build times), and it sets the wrong expectations 
around performance: that meeting the batch-latency requirements of clang-tidy 
is sufficient, rather than the interactive-latency requirements of clangd. (Not 
a theoretical concern: clangd's *deliberate* deps on clang-tidy have had 
multiple unacceptable performance regressions in the past, which is the cost of 
taking the dep, but not one that needs paying here).

> This were main reason, why it were avoided, as there were no unit tests for 
> this code on clangd side.

This wasn't a library in its own right on the clangd side. If it's a library 
with multiple clients, it needs tests so problems with the library can be 
distinguished from problems with the clients. (I think it would have been nice 
to have fine-grained unittests anyway, but we didn't).

> Why is it such a big deal that a revert needs to be considered?

It's not a big deal, but I thought the most likely fix was to move this into a 
separate library with tests, I wasn't sure if anyone wanted to take that on in 
a hurry, and wanted to get back to a good state.

If tidy owners are happier with just cloning the code, I can revert just the 
changes to clangd.

I would suggest moving the code out out tidy/utils and into the check if that's 
the only place it's going to be tested, but that's up to you.

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


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #88902)



@@ -1,5 +1,5 @@
-// RUN: %clang -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
-// Issue no: 41441
+// RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm 
-o - %s | FileCheck %s
+
 #include 

nico wrote:

Thanks!

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)



@@ -1403,94 +1421,146 @@ bool 
HeaderSearch::isFileMultipleIncludeGuarded(FileEntryRef File) const {
 void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 ModuleMap::ModuleHeaderRole Role,
 bool isCompilingModuleHeader) {
-  bool isModularHeader = ModuleMap::isModular(Role);
-
   // Don't mark the file info as non-external if there's nothing to change.
   if (!isCompilingModuleHeader) {
-if (!isModularHeader)
+if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
 if (HFI && HFI->isModuleHeader)
   return;
   }
 
   auto &HFI = getFileInfo(FE);
-  HFI.isModuleHeader |= isModularHeader;
+  HFI.mergeModuleMembership(Role);
   HFI.isCompilingModuleHeader |= isCompilingModuleHeader;

zygoloid wrote:

It looks to me like we're now calling `getFileInfo(FE)` even in cases where the 
info doesn't change, for a textual header. I think that's what's causing the 
regression we're seeing -- we're now considering a repeatedly-used module map 
file to be affecting, even though it isn't, because we end up with a local 
`HeaderFileInfo` instead of an imported one.

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


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)



@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor &PP,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor &PP, Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;

zygoloid wrote:

I don't think this is correct -- we can know about non-affecting module map 
files because they were specified on the command line using 
`-fmodule-map-file=` and either weren't actually used or (as happens in our 
case) we got the same information from a PCM file and so didn't need the module 
map file.

I think this check is a regression; can it be removed?

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


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)



@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor &PP,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor &PP, Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;

zygoloid wrote:

Hm, I see that adding this check was the whole point of the patch. I don't 
think this works -- it's not feasible for the build system to know whether a 
module map file would affect a compilation or not.

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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)


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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)



@@ -3362,6 +3362,64 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue 
Op,
   return LowerGlobalTLSAddressLinux(Op, DAG);
 }
 
+/// updateForAIXShLibTLSModelOpt - Helper to initialize TLS model opt settings,
+/// and then apply the update.
+static void updateForAIXShLibTLSModelOpt(TLSModel::Model &Model,
+ SelectionDAG &DAG,
+ const TargetMachine &TM) {
+  // Initialize TLS model opt setting lazily:
+  // (1) Use initial-exec for single TLS var references within current 
function.
+  // (2) Use local-dynamic for multiple TLS var references within current
+  // function.
+  PPCFunctionInfo *FuncInfo =
+  DAG.getMachineFunction().getInfo();
+  if (!FuncInfo->isAIXFuncUseInitDone()) {
+SmallPtrSet TLSGV;
+// Iterate over all instructions within current function, collect all TLS
+// global variables (global variables taken as the first parameter to
+// Intrinsic::threadlocal_address).
+const Function &Func = DAG.getMachineFunction().getFunction();
+for (Function::const_iterator BI = Func.begin(), BE = Func.end(); BI != BE;
+ ++BI)
+  for (BasicBlock::const_iterator II = BI->begin(), IE = BI->end();
+   II != IE; ++II)
+if (II->getOpcode() == Instruction::Call)
+  if (const CallInst *CI = dyn_cast(&*II))
+if (Function *CF = CI->getCalledFunction())
+  if (CF->isDeclaration() &&
+  CF->getIntrinsicID() == Intrinsic::threadlocal_address)
+if (const GlobalValue *GV =
+dyn_cast(II->getOperand(0))) {
+  TLSModel::Model GVModel = TM.getTLSModel(GV);
+  if (GVModel == TLSModel::InitialExec ||
+  GVModel == TLSModel::LocalDynamic)
+TLSGV.insert(GV);
+}
+
+unsigned TLSGVCnt = TLSGV.size();
+LLVM_DEBUG(dbgs() << format("TLSGV count:%d\n", TLSGVCnt));
+if (TLSGVCnt == 1)
+  FuncInfo->setAIXFuncUseTLSIE();
+else if (TLSGVCnt > 1)
+  FuncInfo->setAIXFuncUseTLSLD();

hubert-reinterpretcast wrote:

We should need to set only one thing (to represent "use IE instead of LD"). The 
threshold number should not be repeated in more than one place.

Additionally, the threshold number may need to be increased (tests via 
experiments).

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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)



@@ -3362,6 +3362,64 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue 
Op,
   return LowerGlobalTLSAddressLinux(Op, DAG);
 }
 
+/// updateForAIXShLibTLSModelOpt - Helper to initialize TLS model opt settings,
+/// and then apply the update.
+static void updateForAIXShLibTLSModelOpt(TLSModel::Model &Model,
+ SelectionDAG &DAG,
+ const TargetMachine &TM) {
+  // Initialize TLS model opt setting lazily:
+  // (1) Use initial-exec for single TLS var references within current 
function.
+  // (2) Use local-dynamic for multiple TLS var references within current
+  // function.
+  PPCFunctionInfo *FuncInfo =
+  DAG.getMachineFunction().getInfo();
+  if (!FuncInfo->isAIXFuncUseInitDone()) {
+SmallPtrSet TLSGV;
+// Iterate over all instructions within current function, collect all TLS
+// global variables (global variables taken as the first parameter to
+// Intrinsic::threadlocal_address).
+const Function &Func = DAG.getMachineFunction().getFunction();
+for (Function::const_iterator BI = Func.begin(), BE = Func.end(); BI != BE;
+ ++BI)
+  for (BasicBlock::const_iterator II = BI->begin(), IE = BI->end();
+   II != IE; ++II)
+if (II->getOpcode() == Instruction::Call)
+  if (const CallInst *CI = dyn_cast(&*II))
+if (Function *CF = CI->getCalledFunction())
+  if (CF->isDeclaration() &&
+  CF->getIntrinsicID() == Intrinsic::threadlocal_address)
+if (const GlobalValue *GV =
+dyn_cast(II->getOperand(0))) {
+  TLSModel::Model GVModel = TM.getTLSModel(GV);
+  if (GVModel == TLSModel::InitialExec ||

hubert-reinterpretcast wrote:

We should only count the number of `local-dynamic` accesses.

Rationale:
The option can be taken as providing the information that the shared object is 
loaded with the executable (not `dlopen`ed later). In that case, all variables 
accessed using the `local-dynamic` model can be accessed using `initial-exec`; 
however, there would still be variables accessed using `initial-exec` that 
cannot be accessed using `local-dynamic`.

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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)


https://github.com/hubert-reinterpretcast commented:

See inline comments for rationale re: scoping to LD -> IE only (and not 
performing IE -> LD).

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


[clang] [clang-cl] [Driver] Fix clang-cl driver supported colon options (PR #88216)


MaxEW707 wrote:

> Thank you for polishing this corner of the driver interface! It's interesting 
> that they have an alternative separate spelling. I always felt like the 
> /Fopath.cpp pattern was a bit unreadable.

Thanks for the review. I will need you to commit on my behalf. I think its 
about time I figure out what conditions I need to meet in-order to get commit 
after approval rights.

`/Fopath.cpp` is super unreadable. Unfortunately, I don't remember when the 
colon spelling came into existence but anything from VS2017 definitely has the 
colon alternative spelling.

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


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)



@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor &PP,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor &PP, Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;

jansvoboda11 wrote:

I wasn't aware that you're passing unused module map files to the compiler. In 
that case I can introduce a separate flag to control this functionality and 
only disable the computation of affecting module maps for our flavor of 
explicit modules where this is a no-op. Sounds good?

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


[clang] [Coverage] Handle array decomposition correctly (PR #88881)


efriedma-quic wrote:

Say you have:

```
int foo();
struct A { A(); A(const A&, int = foo()); };
struct B { A a[10]; };
void f(const B& b) { B bb = b; }
```

We want to visit the call to foo(), I think?

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)



@@ -1403,94 +1421,146 @@ bool 
HeaderSearch::isFileMultipleIncludeGuarded(FileEntryRef File) const {
 void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 ModuleMap::ModuleHeaderRole Role,
 bool isCompilingModuleHeader) {
-  bool isModularHeader = ModuleMap::isModular(Role);
-
   // Don't mark the file info as non-external if there's nothing to change.
   if (!isCompilingModuleHeader) {
-if (!isModularHeader)
+if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
 if (HFI && HFI->isModuleHeader)
   return;
   }
 
   auto &HFI = getFileInfo(FE);
-  HFI.isModuleHeader |= isModularHeader;
+  HFI.mergeModuleMembership(Role);
   HFI.isCompilingModuleHeader |= isCompilingModuleHeader;

ian-twilightcoder wrote:

Ohhh. So I need to be checking the `getExistingFileInfo` to see if 
`isModuleHeader` and `isTextualModuleHeader` match the given `ModuleHeaderRole`?

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


[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)


efriedma-quic wrote:

Looks like automation didn't trigger for some reason... but quoting the 
automated message that's supposed to trigger:

> ⚠️ We detected that you are using a GitHub private e-mail address to 
> contribute to the repo.
> Please turn off [Keep my email addresses 
> private](https://github.com/settings/emails) setting in your account.
> See [LLVM 
> Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
>  for more information.

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


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #83124)


Sterling-Augustine wrote:

Unless the original test was subtly broken, the forward fix in 
0a789ea8a829da345e46d8224d73b2ddaba6969f seems erroneous.

The forward fix changes the test to have a different declaration of `new`. But 
I would not expect this original change to require source-code level changes. 
Or was that intended?

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)


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

LGTM

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


[clang] Improve stack usage to increase recursive initialization depth (PR #88546)


vitalybuka wrote:

A new memory leak https://lab.llvm.org/buildbot/#/builders/5/builds/42694

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


[clang] 8c9f45e - [ARM64EC] Fix arm_neon.h on ARM64EC. (#88572)


Author: Eli Friedman
Date: 2024-04-16T17:08:02-07:00
New Revision: 8c9f45e2decbb68dbf83794f98291b53f59390f8

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

LOG: [ARM64EC] Fix arm_neon.h on ARM64EC. (#88572)

Since 97fe519d, in ARM64EC mode, we don't define `__aarch64__`. Fix
various preprocessor guards to account for this.

Added: 


Modified: 
clang/include/clang/Basic/arm_fp16.td
clang/include/clang/Basic/arm_neon.td
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_fp16.td 
b/clang/include/clang/Basic/arm_fp16.td
index cb2a09303e8e12..d36b4617bef5d2 100644
--- a/clang/include/clang/Basic/arm_fp16.td
+++ b/clang/include/clang/Basic/arm_fp16.td
@@ -14,7 +14,7 @@
 include "arm_neon_incl.td"
 
 // ARMv8.2-A FP16 intrinsics.
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "fullfp16" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"fullfp16" in {
 
   // Negate
   def VNEGSH  : SInst<"vneg", "11", "Sh">;

diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 7edac5afafaa99..6d655c39360d3b 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -605,11 +605,11 @@ def VQDMULL_LANE  : SOpInst<"vqdmull_lane", "(>Q)..I", 
"si", OP_QDMULL_LN>;
 def VQDMULH_N : SOpInst<"vqdmulh_n", "..1", "siQsQi", OP_QDMULH_N>;
 def VQRDMULH_N: SOpInst<"vqrdmulh_n", "..1", "siQsQi", OP_QRDMULH_N>;
 
-let ArchGuard = "!defined(__aarch64__)" in {
+let ArchGuard = "!defined(__aarch64__) && !defined(__arm64ec__)" in {
 def VQDMULH_LANE  : SOpInst<"vqdmulh_lane", "..qI", "siQsQi", OP_QDMULH_LN>;
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
 }
-let ArchGuard = "defined(__aarch64__)" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)" in {
 def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..(!q)I", "siQsQi">;
 def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..(!q)I", "siQsQi">;
 }
@@ -686,7 +686,7 @@ multiclass REINTERPRET_CROSS_TYPES {
 
 // E.3.31 Vector reinterpret cast operations
 def VREINTERPRET : 
REINTERPRET_CROSS_SELF<"csilUcUsUiUlhfPcPsQcQsQiQlQUcQUsQUiQUlQhQfQPcQPs"> {
-  let ArchGuard = "!defined(__aarch64__)";
+  let ArchGuard = "!defined(__aarch64__) && !defined(__arm64ec__)";
   let BigEndianSafe = 1;
 }
 
@@ -714,7 +714,7 @@ def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPl">;
 

 // AArch64 Intrinsics
 
-let ArchGuard = "defined(__aarch64__)" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)" in {
 
 

 // Load/Store
@@ -1091,14 +1091,14 @@ let isLaneQ = 1 in {
 def VQDMULH_LANEQ  : SInst<"vqdmulh_laneq", "..QI", "siQsQi">;
 def VQRDMULH_LANEQ : SInst<"vqrdmulh_laneq", "..QI", "siQsQi">;
 }
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "v8.1a" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"v8.1a" in {
 def VQRDMLAH_LANEQ : SOpInst<"vqrdmlah_laneq", "...QI", "siQsQi", 
OP_QRDMLAH_LN> {
   let isLaneQ = 1;
 }
 def VQRDMLSH_LANEQ : SOpInst<"vqrdmlsh_laneq", "...QI", "siQsQi", 
OP_QRDMLSH_LN> {
   let isLaneQ = 1;
 }
-} // ArchGuard = "defined(__aarch64__)", TargetGuard = "v8.1a"
+} // ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"v8.1a"
 
 // Note: d type implemented by SCALAR_VMULX_LANE
 def VMULX_LANE : IOpInst<"vmulx_lane", "..qI", "fQfQd", OP_MULX_LN>;
@@ -1143,7 +1143,7 @@ def SHA256H2 : SInst<"vsha256h2", "", "QUi">;
 def SHA256SU1 : SInst<"vsha256su1", "", "QUi">;
 }
 
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "sha3" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"sha3" in {
 def BCAX : SInst<"vbcax", "", "QUcQUsQUiQUlQcQsQiQl">;
 def EOR3 : SInst<"veor3", "", "QUcQUsQUiQUlQcQsQiQl">;
 def RAX1 : SInst<"vrax1", "...", "QUl">;
@@ -1153,14 +1153,14 @@ def XAR :  SInst<"vxar", "...I", "QUl">;
 }
 }
 
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "sha3" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"sha3" in {
 def SHA512SU0 : SInst<"vsha512su0", "...", "QUl">;
 def SHA512su1 : SInst<"vsha512su1", "", "QUl">;
 def SHA512H : SInst<"vsha512h", "", "QUl">;
 def SHA512H2 : SInst<"vsha512h2", "", "QUl">;
 }
 
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "sm4" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"sm4" in {
 def SM3SS1 : SInst<"vsm3ss1", "", "QUi">;
 def SM3TT1A : SInst<"vsm3tt1a", "I", "QUi">;
 def SM3TT1B :

[clang] [ARM64EC] Fix arm_neon.h on ARM64EC. (PR #88572)


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


[clang] [CMake][Release] Disable PGO (PR #88465)


tstellar wrote:

PR is here: https://github.com/llvm/llvm-project/pull/89000

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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)


https://github.com/ian-twilightcoder created 
https://github.com/llvm/llvm-project/pull/89005

HeaderSearch::MarkFileModuleHeader is no longer properly checking for 
no-changes, and so creates a new HeaderFileInfo for every `textual header`, 
causes PCM use to go ballistic.

>From f45cb72cb9c70d714bdc071ac51dff1a5e11502b Mon Sep 17 00:00:00 2001
From: Ian Anderson 
Date: Tue, 16 Apr 2024 17:08:28 -0700
Subject: [PATCH] [clang][modules] HeaderSearch::MarkFileModuleHeader creates
 extra HeaderFileInfo, breaks PCM reuse

HeaderSearch::MarkFileModuleHeader is no longer properly checking for 
no-changes, and so creates a new HeaderFileInfo for every `textual header`, 
causes PCM use to go ballistic.
---
 clang/lib/Lex/HeaderSearch.cpp | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 0632882b296146..9409b97ba0e64a 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1313,6 +1313,14 @@ OptionalFileEntryRef 
HeaderSearch::LookupSubframeworkHeader(
 // File Info Management.
 
//===--===//
 
+static bool
+headerFileInfoModuleBitsMatchRole(const HeaderFileInfo *HFI,
+  ModuleMap::ModuleHeaderRole Role) {
+  return (HFI->isModuleHeader == ModuleMap::isModular(Role)) &&
+ (HFI->isTextualModuleHeader ==
+  ((Role & ModuleMap::TextualHeader) != 0));
+}
+
 static void mergeHeaderFileInfoModuleBits(HeaderFileInfo &HFI,
   bool isModuleHeader,
   bool isTextualModuleHeader) {
@@ -1432,7 +1440,7 @@ void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
-if (HFI && HFI->isModuleHeader)
+if (HFI && headerFileInfoModuleBitsMatchRole(HFI, Role))
   return;
   }
 

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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)


llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ian Anderson (ian-twilightcoder)


Changes

HeaderSearch::MarkFileModuleHeader is no longer properly checking for 
no-changes, and so creates a new HeaderFileInfo for every `textual header`, 
causes PCM use to go ballistic.

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


1 Files Affected:

- (modified) clang/lib/Lex/HeaderSearch.cpp (+9-1) 


``diff
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 0632882b296146..9409b97ba0e64a 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1313,6 +1313,14 @@ OptionalFileEntryRef 
HeaderSearch::LookupSubframeworkHeader(
 // File Info Management.
 
//===--===//
 
+static bool
+headerFileInfoModuleBitsMatchRole(const HeaderFileInfo *HFI,
+  ModuleMap::ModuleHeaderRole Role) {
+  return (HFI->isModuleHeader == ModuleMap::isModular(Role)) &&
+ (HFI->isTextualModuleHeader ==
+  ((Role & ModuleMap::TextualHeader) != 0));
+}
+
 static void mergeHeaderFileInfoModuleBits(HeaderFileInfo &HFI,
   bool isModuleHeader,
   bool isTextualModuleHeader) {
@@ -1432,7 +1440,7 @@ void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
-if (HFI && HFI->isModuleHeader)
+if (HFI && headerFileInfoModuleBitsMatchRole(HFI, Role))
   return;
   }
 

``




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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)



@@ -1403,94 +1421,146 @@ bool 
HeaderSearch::isFileMultipleIncludeGuarded(FileEntryRef File) const {
 void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 ModuleMap::ModuleHeaderRole Role,
 bool isCompilingModuleHeader) {
-  bool isModularHeader = ModuleMap::isModular(Role);
-
   // Don't mark the file info as non-external if there's nothing to change.
   if (!isCompilingModuleHeader) {
-if (!isModularHeader)
+if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
 if (HFI && HFI->isModuleHeader)
   return;
   }
 
   auto &HFI = getFileInfo(FE);
-  HFI.isModuleHeader |= isModularHeader;
+  HFI.mergeModuleMembership(Role);
   HFI.isCompilingModuleHeader |= isCompilingModuleHeader;

ian-twilightcoder wrote:

https://github.com/llvm/llvm-project/pull/89005 and thank you!!

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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)


ian-twilightcoder wrote:

I don't really know a great way to write a test for this. If someone could 
point me at a similar existing test or has an idea how to write a new test that 
would be much appreciated.

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)


kito-cheng wrote:

`llvm/docs/RISCVUsage.rst` need update 

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


[clang] [clang][deps] Support single-file mode for all formats (PR #88764)


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


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


[clang] Improve stack usage to increase recursive initialization depth (PR #88546)


nikic wrote:

This change seems to cause significant compile-time regressions for C++ code 
(https://llvm-compile-time-tracker.com/compare.php?from=184ba038ac1d444980b3e554b0057f3f30c516ab&to=4082a7554521572a65a5a0008c4661a534df659d&stat=instructions%3Au).

Probably most damning are the times for the clang build itself 
(https://llvm-compile-time-tracker.com/compare_clang.php?from=184ba038ac1d444980b3e554b0057f3f30c516ab&to=4082a7554521572a65a5a0008c4661a534df659d&stat=instructions%3Au&sortBy=interestingness)
 where files like X86ISelDAGToDAG.cpp regress by >3% even in an optimized build.

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


<    1   2   3   4   5   >