[clang] [clang] Added warn-assignment-bool-context (PR #115234)

2024-11-06 Thread Philipp Rados via cfe-commits

https://github.com/PhilippRados created 
https://github.com/llvm/llvm-project/pull/115234

This is a fix for #33528 as I messed up my other PR with unsynced changes.

A couple of things make this less straightforward as initially thought, which 
is why I would like some feedback as to how these things should be handled.

This warning should get issued for both C and C++ (I'm not sure about the other 
languages). For C the tests pass. For C++ some fail because another similar 
warning is expected `warn_condition_is_assignment`. That warning can be covered 
by this new warning but it would be better to issue the existing since it is 
more specific in cases of condition.

The problem is that in C, conditions do not emit an implicit-cast to booleans 
while in C++ they do. So the original warning is  needed for C, but would 
result in double warning in C++. This requires special handling.

In the code I have left `NOTE:` comments whenever I was unsure about the 
implementation of something, which might need some clearing up since this is my 
first proper contribution.

>From e819360e6510f12f19b7df9d4eb22c0943776440 Mon Sep 17 00:00:00 2001
From: PhilippR 
Date: Thu, 7 Nov 2024 00:06:24 +0100
Subject: [PATCH] [clang] Added warn-assignment-bool-context

This warning is issued if an assignment is used in a context
where a boolean result is required.
---
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/include/clang/Sema/Sema.h   |  2 +
 clang/lib/Sema/Sema.cpp   | 53 +++
 clang/lib/Sema/SemaExpr.cpp   |  6 ++-
 .../test/Sema/warn-assignment-bool-context.c  | 35 
 .../SemaCXX/warn-assignment-bool-context.cpp  | 45 
 6 files changed, 143 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Sema/warn-assignment-bool-context.c
 create mode 100644 clang/test/SemaCXX/warn-assignment-bool-context.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ae3e243bdc58bd..4ba4327bde5cfb 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8477,6 +8477,9 @@ def err_incomplete_object_call : Error<
 def warn_condition_is_assignment : Warning<"using the result of an "
   "assignment as a condition without parentheses">,
   InGroup;
+def warn_assignment_bool_context : Warning<"suggest parentheses around 
assignment used as truth value">,
+  InGroup;
+
 def warn_free_nonheap_object
   : Warning<"attempt to call %0 on non-heap %select{object %2|object: block 
expression|object: lambda-to-function-pointer conversion}1">,
 InGroup;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 93d98e1cbb9c81..6bf73956d3f944 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7232,6 +7232,8 @@ class Sema final : public SemaBase {
   /// being used as a boolean condition, warn if it's an assignment.
   void DiagnoseAssignmentAsCondition(Expr *E);
 
+  void DiagnoseAssignmentBoolContext(Expr *E, QualType ToType);
+
   /// Redundant parentheses over an equality comparison can indicate
   /// that the user intended an assignment used as condition.
   void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE);
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 2b51765e80864a..a8e4657ac0b6ec 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -687,6 +687,48 @@ void Sema::diagnoseZeroToNullptrConversion(CastKind Kind, 
const Expr *E) {
   << FixItHint::CreateReplacement(E->getSourceRange(), "nullptr");
 }
 
+void Sema::DiagnoseAssignmentBoolContext(Expr *E, QualType Ty) {
+  // Use copy to not alter original expression.
+  Expr *ECopy = E;
+
+  if (Ty->isBooleanType()) {
+// `bool(x=0)` and if (x=0){} emit:
+// - ImplicitCastExpr bool IntegralToBoolean
+// -- ImplicitCastExpr int LValueToRValue
+// --- Assignment ...
+// But should still emit this warning (at least gcc does), even if 
bool-cast
+// is not directly followed by assignment.
+// NOTE: Is this robust enough or can there be other semantic expression
+// until the assignment?
+while (ImplicitCastExpr *ICE = dyn_cast(ECopy)) {
+  // If there is another implicit cast to bool then this warning would have
+  // been already emitted.
+  if (ICE->getType()->isBooleanType())
+return;
+  ECopy = ICE->getSubExpr();
+}
+
+if (BinaryOperator *Op = dyn_cast(ECopy)) {
+  // Should only be issued for regular assignment `=`,
+  // not for compound-assign like `+=`.
+  // NOTE: Might make sense to emit for all assignments even if gcc
+  // only does for regular assignment.
+  if (Op->getOpcode() == BO_Assign) {
+SourceLocation Loc = Op->getOperatorLoc();
+Diag(Loc, diag::warn_assignment_bool_context)
+<< ECopy->getSourceRange();
+
+Sou

[clang] [clang][serialization] Pass `ASTContext` explicitly (PR #115235)

2024-11-06 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 created 
https://github.com/llvm/llvm-project/pull/115235

This patch removes `ASTWriter::Context` and starts passing `ASTContext &` 
explicitly to functions that actually need it. This is a non-functional change 
with the end-goal of being able to write lightweight PCM files with no 
`ASTContext` at all.

>From 27985cf8df00f1edf6e74b7e50ce5be13569591c Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Wed, 6 Nov 2024 09:54:06 -0800
Subject: [PATCH] [clang][serialization] Pass `ASTContext` explicitly

---
 .../clang/Serialization/ASTRecordWriter.h |   7 +-
 clang/include/clang/Serialization/ASTWriter.h |  28 ++---
 clang/lib/Serialization/ASTWriter.cpp | 118 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  55 
 clang/lib/Serialization/ASTWriterStmt.cpp |  15 +--
 5 files changed, 110 insertions(+), 113 deletions(-)

diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h 
b/clang/include/clang/Serialization/ASTRecordWriter.h
index d6090ba1a6c690..67720a0aebc1ca 100644
--- a/clang/include/clang/Serialization/ASTRecordWriter.h
+++ b/clang/include/clang/Serialization/ASTRecordWriter.h
@@ -60,8 +60,9 @@ class ASTRecordWriter
 
 public:
   /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
-  : DataStreamBasicWriter(W.getASTContext()), Writer(&W), Record(&Record) 
{}
+  ASTRecordWriter(ASTContext &Context, ASTWriter &W,
+  ASTWriter::RecordDataImpl &Record)
+  : DataStreamBasicWriter(Context), Writer(&W), Record(&Record) {}
 
   /// Construct a ASTRecordWriter that uses the same encoding scheme as another
   /// ASTRecordWriter.
@@ -208,7 +209,7 @@ class ASTRecordWriter
 
   /// Emit a reference to a type.
   void AddTypeRef(QualType T) {
-return Writer->AddTypeRef(T, *Record);
+return Writer->AddTypeRef(getASTContext(), T, *Record);
   }
   void writeQualType(QualType T) {
 AddTypeRef(T);
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index d0e841f367c1e0..dc9fcd3c33726e 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// The PCM manager which manages memory buffers for pcm files.
   InMemoryModuleCache &ModuleCache;
 
-  /// The ASTContext we're writing.
-  ASTContext *Context = nullptr;
-
   /// The preprocessor we're writing.
   Preprocessor *PP = nullptr;
 
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getSubmoduleID(Module *Mod);
 
   /// Write the given subexpression to the bitstream.
-  void WriteSubStmt(Stmt *S);
+  void WriteSubStmt(ASTContext &Context, Stmt *S);
 
   void WriteBlockInfoBlock();
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
@@ -564,25 +561,25 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,
uint64_t MacroOffsetsBase);
-  void WriteSubmodules(Module *WritingModule);
+  void WriteSubmodules(Module *WritingModule, ASTContext &Context);
 
   void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
  bool isModule);
 
   unsigned TypeExtQualAbbrev = 0;
   void WriteTypeAbbrevs();
-  void WriteType(QualType T);
+  void WriteType(ASTContext &Context, QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
 
-  void GenerateNameLookupTable(const DeclContext *DC,
+  void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
llvm::SmallVectorImpl &LookupTable);
   uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
 const DeclContext *DC);
   uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
   void WriteTypeDeclOffsets();
   void WriteFileDeclIDsMap();
-  void WriteComments();
+  void WriteComments(ASTContext &Context);
   void WriteSelectors(Sema &SemaRef);
   void WriteReferencedSelectorsPool(Sema &SemaRef);
   void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
@@ -590,8 +587,10 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteDeclAndTypes(ASTContext &Context);
   void PrepareWritingSpecialDecls(Sema &SemaRef);
   void WriteSpecialDeclRecords(Sema &SemaRef);
-  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
-  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
+  void WriteDeclUpdatesBlocks(ASTContext &Context,
+  RecordDataImpl &OffsetsRecord);
+  void WriteDeclContextVisibleUpdate(ASTContext &Context,
+ const DeclContext *DC);
   void WriteFPPragmaOptions(const F

[clang] [clang][serialization] Pass `ASTContext` explicitly (PR #115235)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Jan Svoboda (jansvoboda11)


Changes

This patch removes `ASTWriter::Context` and starts passing `ASTContext &` 
explicitly to functions that actually need it. This is a non-functional change 
with the end-goal of being able to write lightweight PCM files with no 
`ASTContext` at all.

---

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


5 Files Affected:

- (modified) clang/include/clang/Serialization/ASTRecordWriter.h (+4-3) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+11-17) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+57-61) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+30-25) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+8-7) 


``diff
diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h 
b/clang/include/clang/Serialization/ASTRecordWriter.h
index d6090ba1a6c690..67720a0aebc1ca 100644
--- a/clang/include/clang/Serialization/ASTRecordWriter.h
+++ b/clang/include/clang/Serialization/ASTRecordWriter.h
@@ -60,8 +60,9 @@ class ASTRecordWriter
 
 public:
   /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
-  : DataStreamBasicWriter(W.getASTContext()), Writer(&W), Record(&Record) 
{}
+  ASTRecordWriter(ASTContext &Context, ASTWriter &W,
+  ASTWriter::RecordDataImpl &Record)
+  : DataStreamBasicWriter(Context), Writer(&W), Record(&Record) {}
 
   /// Construct a ASTRecordWriter that uses the same encoding scheme as another
   /// ASTRecordWriter.
@@ -208,7 +209,7 @@ class ASTRecordWriter
 
   /// Emit a reference to a type.
   void AddTypeRef(QualType T) {
-return Writer->AddTypeRef(T, *Record);
+return Writer->AddTypeRef(getASTContext(), T, *Record);
   }
   void writeQualType(QualType T) {
 AddTypeRef(T);
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index d0e841f367c1e0..dc9fcd3c33726e 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// The PCM manager which manages memory buffers for pcm files.
   InMemoryModuleCache &ModuleCache;
 
-  /// The ASTContext we're writing.
-  ASTContext *Context = nullptr;
-
   /// The preprocessor we're writing.
   Preprocessor *PP = nullptr;
 
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getSubmoduleID(Module *Mod);
 
   /// Write the given subexpression to the bitstream.
-  void WriteSubStmt(Stmt *S);
+  void WriteSubStmt(ASTContext &Context, Stmt *S);
 
   void WriteBlockInfoBlock();
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
@@ -564,25 +561,25 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,
uint64_t MacroOffsetsBase);
-  void WriteSubmodules(Module *WritingModule);
+  void WriteSubmodules(Module *WritingModule, ASTContext &Context);
 
   void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
  bool isModule);
 
   unsigned TypeExtQualAbbrev = 0;
   void WriteTypeAbbrevs();
-  void WriteType(QualType T);
+  void WriteType(ASTContext &Context, QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
 
-  void GenerateNameLookupTable(const DeclContext *DC,
+  void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
llvm::SmallVectorImpl &LookupTable);
   uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
 const DeclContext *DC);
   uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
   void WriteTypeDeclOffsets();
   void WriteFileDeclIDsMap();
-  void WriteComments();
+  void WriteComments(ASTContext &Context);
   void WriteSelectors(Sema &SemaRef);
   void WriteReferencedSelectorsPool(Sema &SemaRef);
   void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
@@ -590,8 +587,10 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteDeclAndTypes(ASTContext &Context);
   void PrepareWritingSpecialDecls(Sema &SemaRef);
   void WriteSpecialDeclRecords(Sema &SemaRef);
-  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
-  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
+  void WriteDeclUpdatesBlocks(ASTContext &Context,
+  RecordDataImpl &OffsetsRecord);
+  void WriteDeclContextVisibleUpdate(ASTContext &Context,
+ const DeclContext *DC);
   void WriteFPPragmaOptions(const FPOptionsOverride &Opts);
   void WriteOpenCLExtensions(Sema 

[clang] [clang][serialization] Pass `ASTContext` explicitly (PR #115235)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)


Changes

This patch removes `ASTWriter::Context` and starts passing `ASTContext &` 
explicitly to functions that actually need it. This is a non-functional change 
with the end-goal of being able to write lightweight PCM files with no 
`ASTContext` at all.

---

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


5 Files Affected:

- (modified) clang/include/clang/Serialization/ASTRecordWriter.h (+4-3) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+11-17) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+57-61) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+30-25) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+8-7) 


``diff
diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h 
b/clang/include/clang/Serialization/ASTRecordWriter.h
index d6090ba1a6c690..67720a0aebc1ca 100644
--- a/clang/include/clang/Serialization/ASTRecordWriter.h
+++ b/clang/include/clang/Serialization/ASTRecordWriter.h
@@ -60,8 +60,9 @@ class ASTRecordWriter
 
 public:
   /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
-  : DataStreamBasicWriter(W.getASTContext()), Writer(&W), Record(&Record) 
{}
+  ASTRecordWriter(ASTContext &Context, ASTWriter &W,
+  ASTWriter::RecordDataImpl &Record)
+  : DataStreamBasicWriter(Context), Writer(&W), Record(&Record) {}
 
   /// Construct a ASTRecordWriter that uses the same encoding scheme as another
   /// ASTRecordWriter.
@@ -208,7 +209,7 @@ class ASTRecordWriter
 
   /// Emit a reference to a type.
   void AddTypeRef(QualType T) {
-return Writer->AddTypeRef(T, *Record);
+return Writer->AddTypeRef(getASTContext(), T, *Record);
   }
   void writeQualType(QualType T) {
 AddTypeRef(T);
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index d0e841f367c1e0..dc9fcd3c33726e 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// The PCM manager which manages memory buffers for pcm files.
   InMemoryModuleCache &ModuleCache;
 
-  /// The ASTContext we're writing.
-  ASTContext *Context = nullptr;
-
   /// The preprocessor we're writing.
   Preprocessor *PP = nullptr;
 
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getSubmoduleID(Module *Mod);
 
   /// Write the given subexpression to the bitstream.
-  void WriteSubStmt(Stmt *S);
+  void WriteSubStmt(ASTContext &Context, Stmt *S);
 
   void WriteBlockInfoBlock();
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
@@ -564,25 +561,25 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,
uint64_t MacroOffsetsBase);
-  void WriteSubmodules(Module *WritingModule);
+  void WriteSubmodules(Module *WritingModule, ASTContext &Context);
 
   void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
  bool isModule);
 
   unsigned TypeExtQualAbbrev = 0;
   void WriteTypeAbbrevs();
-  void WriteType(QualType T);
+  void WriteType(ASTContext &Context, QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
 
-  void GenerateNameLookupTable(const DeclContext *DC,
+  void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
llvm::SmallVectorImpl &LookupTable);
   uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
 const DeclContext *DC);
   uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
   void WriteTypeDeclOffsets();
   void WriteFileDeclIDsMap();
-  void WriteComments();
+  void WriteComments(ASTContext &Context);
   void WriteSelectors(Sema &SemaRef);
   void WriteReferencedSelectorsPool(Sema &SemaRef);
   void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
@@ -590,8 +587,10 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteDeclAndTypes(ASTContext &Context);
   void PrepareWritingSpecialDecls(Sema &SemaRef);
   void WriteSpecialDeclRecords(Sema &SemaRef);
-  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
-  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
+  void WriteDeclUpdatesBlocks(ASTContext &Context,
+  RecordDataImpl &OffsetsRecord);
+  void WriteDeclContextVisibleUpdate(ASTContext &Context,
+ const DeclContext *DC);
   void WriteFPPragmaOptions(const FPOptionsOverride &Opts);
   void WriteOpenCLExtensions(Sema &SemaRef

[clang] [clang][serialization] Pass `ASTContext` explicitly (PR #115235)

2024-11-06 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 304c41217303ce613de8f4042e570ac6ca8757e8 
27985cf8df00f1edf6e74b7e50ce5be13569591c --extensions cpp,h -- 
clang/include/clang/Serialization/ASTRecordWriter.h 
clang/include/clang/Serialization/ASTWriter.h 
clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterDecl.cpp 
clang/lib/Serialization/ASTWriterStmt.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index d1af80b324..0bcb475cf2 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -278,7 +278,7 @@ class ASTTypeWriter {
 
 public:
   ASTTypeWriter(ASTContext &Context, ASTWriter &Writer)
-: Writer(Writer), BasicWriter(Context, Writer, Record) {}
+  : Writer(Writer), BasicWriter(Context, Writer, Record) {}
 
   uint64_t write(QualType T) {
 if (T.hasLocalNonFastQualifiers()) {

``




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


[clang] [clang][serialization] Make `ASTWriter` work with `Preprocessor` only (PR #115237)

2024-11-06 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 created 
https://github.com/llvm/llvm-project/pull/115237

This PR builds on top of https://github.com/llvm/llvm-project/pull/115235 and 
makes it possible to call `ASTWriter::WriteAST()` with `Preprocessor` only 
instead of full `Sema` object. So far, there are no clients that leverage the 
new capability - that will come in a follow-up commit.

>From 27985cf8df00f1edf6e74b7e50ce5be13569591c Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Wed, 6 Nov 2024 09:54:06 -0800
Subject: [PATCH 1/2] [clang][serialization] Pass `ASTContext` explicitly

---
 .../clang/Serialization/ASTRecordWriter.h |   7 +-
 clang/include/clang/Serialization/ASTWriter.h |  28 ++---
 clang/lib/Serialization/ASTWriter.cpp | 118 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  55 
 clang/lib/Serialization/ASTWriterStmt.cpp |  15 +--
 5 files changed, 110 insertions(+), 113 deletions(-)

diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h 
b/clang/include/clang/Serialization/ASTRecordWriter.h
index d6090ba1a6c690..67720a0aebc1ca 100644
--- a/clang/include/clang/Serialization/ASTRecordWriter.h
+++ b/clang/include/clang/Serialization/ASTRecordWriter.h
@@ -60,8 +60,9 @@ class ASTRecordWriter
 
 public:
   /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
-  : DataStreamBasicWriter(W.getASTContext()), Writer(&W), Record(&Record) 
{}
+  ASTRecordWriter(ASTContext &Context, ASTWriter &W,
+  ASTWriter::RecordDataImpl &Record)
+  : DataStreamBasicWriter(Context), Writer(&W), Record(&Record) {}
 
   /// Construct a ASTRecordWriter that uses the same encoding scheme as another
   /// ASTRecordWriter.
@@ -208,7 +209,7 @@ class ASTRecordWriter
 
   /// Emit a reference to a type.
   void AddTypeRef(QualType T) {
-return Writer->AddTypeRef(T, *Record);
+return Writer->AddTypeRef(getASTContext(), T, *Record);
   }
   void writeQualType(QualType T) {
 AddTypeRef(T);
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index d0e841f367c1e0..dc9fcd3c33726e 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// The PCM manager which manages memory buffers for pcm files.
   InMemoryModuleCache &ModuleCache;
 
-  /// The ASTContext we're writing.
-  ASTContext *Context = nullptr;
-
   /// The preprocessor we're writing.
   Preprocessor *PP = nullptr;
 
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getSubmoduleID(Module *Mod);
 
   /// Write the given subexpression to the bitstream.
-  void WriteSubStmt(Stmt *S);
+  void WriteSubStmt(ASTContext &Context, Stmt *S);
 
   void WriteBlockInfoBlock();
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
@@ -564,25 +561,25 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,
uint64_t MacroOffsetsBase);
-  void WriteSubmodules(Module *WritingModule);
+  void WriteSubmodules(Module *WritingModule, ASTContext &Context);
 
   void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
  bool isModule);
 
   unsigned TypeExtQualAbbrev = 0;
   void WriteTypeAbbrevs();
-  void WriteType(QualType T);
+  void WriteType(ASTContext &Context, QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
 
-  void GenerateNameLookupTable(const DeclContext *DC,
+  void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
llvm::SmallVectorImpl &LookupTable);
   uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
 const DeclContext *DC);
   uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
   void WriteTypeDeclOffsets();
   void WriteFileDeclIDsMap();
-  void WriteComments();
+  void WriteComments(ASTContext &Context);
   void WriteSelectors(Sema &SemaRef);
   void WriteReferencedSelectorsPool(Sema &SemaRef);
   void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
@@ -590,8 +587,10 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteDeclAndTypes(ASTContext &Context);
   void PrepareWritingSpecialDecls(Sema &SemaRef);
   void WriteSpecialDeclRecords(Sema &SemaRef);
-  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
-  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
+  void WriteDeclUpdatesBlocks(ASTContext &Context,
+  RecordDataImpl &OffsetsRecord);
+  void WriteDeclContextVisibleUpdate(ASTContext &Context,
+ const DeclConte

[clang] [clang][serialization] Make `ASTWriter` work with `Preprocessor` only (PR #115237)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)


Changes

This PR builds on top of https://github.com/llvm/llvm-project/pull/115235 and 
makes it possible to call `ASTWriter::WriteAST()` with `Preprocessor` only 
instead of full `Sema` object. So far, there are no clients that leverage the 
new capability - that will come in a follow-up commit.

---

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


7 Files Affected:

- (modified) clang/include/clang/Serialization/ASTRecordWriter.h (+4-3) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+18-23) 
- (modified) clang/lib/Frontend/ASTUnit.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+149-127) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+30-25) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+8-7) 
- (modified) clang/lib/Serialization/GeneratePCH.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h 
b/clang/include/clang/Serialization/ASTRecordWriter.h
index d6090ba1a6c690..67720a0aebc1ca 100644
--- a/clang/include/clang/Serialization/ASTRecordWriter.h
+++ b/clang/include/clang/Serialization/ASTRecordWriter.h
@@ -60,8 +60,9 @@ class ASTRecordWriter
 
 public:
   /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
-  : DataStreamBasicWriter(W.getASTContext()), Writer(&W), Record(&Record) 
{}
+  ASTRecordWriter(ASTContext &Context, ASTWriter &W,
+  ASTWriter::RecordDataImpl &Record)
+  : DataStreamBasicWriter(Context), Writer(&W), Record(&Record) {}
 
   /// Construct a ASTRecordWriter that uses the same encoding scheme as another
   /// ASTRecordWriter.
@@ -208,7 +209,7 @@ class ASTRecordWriter
 
   /// Emit a reference to a type.
   void AddTypeRef(QualType T) {
-return Writer->AddTypeRef(T, *Record);
+return Writer->AddTypeRef(getASTContext(), T, *Record);
   }
   void writeQualType(QualType T) {
 AddTypeRef(T);
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index d0e841f367c1e0..7b5b0117874d7a 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// The PCM manager which manages memory buffers for pcm files.
   InMemoryModuleCache &ModuleCache;
 
-  /// The ASTContext we're writing.
-  ASTContext *Context = nullptr;
-
   /// The preprocessor we're writing.
   Preprocessor *PP = nullptr;
 
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getSubmoduleID(Module *Mod);
 
   /// Write the given subexpression to the bitstream.
-  void WriteSubStmt(Stmt *S);
+  void WriteSubStmt(ASTContext &Context, Stmt *S);
 
   void WriteBlockInfoBlock();
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
@@ -564,34 +561,36 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,
uint64_t MacroOffsetsBase);
-  void WriteSubmodules(Module *WritingModule);
+  void WriteSubmodules(Module *WritingModule, ASTContext *Context);
 
   void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
  bool isModule);
 
   unsigned TypeExtQualAbbrev = 0;
   void WriteTypeAbbrevs();
-  void WriteType(QualType T);
+  void WriteType(ASTContext &Context, QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
 
-  void GenerateNameLookupTable(const DeclContext *DC,
+  void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
llvm::SmallVectorImpl &LookupTable);
   uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
 const DeclContext *DC);
   uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
   void WriteTypeDeclOffsets();
   void WriteFileDeclIDsMap();
-  void WriteComments();
+  void WriteComments(ASTContext &Context);
   void WriteSelectors(Sema &SemaRef);
   void WriteReferencedSelectorsPool(Sema &SemaRef);
-  void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
+  void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver *IdResolver,
 bool IsModule);
   void WriteDeclAndTypes(ASTContext &Context);
   void PrepareWritingSpecialDecls(Sema &SemaRef);
   void WriteSpecialDeclRecords(Sema &SemaRef);
-  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
-  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
+  void WriteDeclUpdatesBlocks(ASTContext &Context,
+  RecordDataImpl &OffsetsRecord);
+  void WriteDeclCo

[clang] clang/AMDGPU: Restore O3 checks in default-attributes.hip (PR #115238)

2024-11-06 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm created 
https://github.com/llvm/llvm-project/pull/115238

These were dropped in b1bcb7ca460fcd317bbc8309e14c8761bf8394e0 to
avoid some bot failures.

>From 3a5d957b5fe0d36df2273693c7c865c39715d192 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Mon, 15 Jul 2024 11:48:03 +0400
Subject: [PATCH] clang/AMDGPU: Restore O3 checks in default-attributes.hip

These were dropped in b1bcb7ca460fcd317bbc8309e14c8761bf8394e0 to
avoid some bot failures.
---
 clang/test/CodeGenHIP/default-attributes.hip | 30 
 1 file changed, 30 insertions(+)

diff --git a/clang/test/CodeGenHIP/default-attributes.hip 
b/clang/test/CodeGenHIP/default-attributes.hip
index 1b53ebec9b5821..ee16ecd134bfee 100644
--- a/clang/test/CodeGenHIP/default-attributes.hip
+++ b/clang/test/CodeGenHIP/default-attributes.hip
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -fno-ident 
-fcuda-is-device \
 // RUN:-emit-llvm -o - %s | FileCheck -check-prefix=OPTNONE %s
 
+// RUN: %clang_cc1 -O3 -triple amdgcn-amd-amdhsa -x hip -fno-ident 
-fcuda-is-device \
+// RUN:-emit-llvm -o - %s | FileCheck -check-prefix=OPT %s
+
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))
 
@@ -10,6 +13,10 @@
 // OPTNONE: @llvm.compiler.used = appending addrspace(1) global [1 x ptr] [ptr 
addrspacecast (ptr addrspace(1) @__hip_cuid_ to ptr)], section "llvm.metadata"
 // OPTNONE: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr 
addrspace(4) constant i32 500
 //.
+// OPT: @__hip_cuid_ = addrspace(1) global i8 0
+// OPT: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr addrspace(4) 
constant i32 500
+// OPT: @llvm.compiler.used = appending addrspace(1) global [1 x ptr] [ptr 
addrspacecast (ptr addrspace(1) @__hip_cuid_ to ptr)], section "llvm.metadata"
+//.
 __device__ void extern_func();
 
 // OPTNONE: Function Attrs: convergent mustprogress noinline nounwind optnone
@@ -19,6 +26,13 @@ __device__ void extern_func();
 // OPTNONE-NEXT:call void @_Z11extern_funcv() #[[ATTR3:[0-9]+]]
 // OPTNONE-NEXT:ret void
 //
+// OPT: Function Attrs: convergent mustprogress nounwind
+// OPT-LABEL: define {{[^@]+}}@_Z4funcv
+// OPT-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// OPT-NEXT:  entry:
+// OPT-NEXT:tail call void @_Z11extern_funcv() #[[ATTR3:[0-9]+]]
+// OPT-NEXT:ret void
+//
 __device__ void func() {
  extern_func();
 }
@@ -30,6 +44,13 @@ __device__ void func() {
 // OPTNONE-NEXT:call void @_Z11extern_funcv() #[[ATTR3]]
 // OPTNONE-NEXT:ret void
 //
+// OPT: Function Attrs: convergent mustprogress norecurse nounwind
+// OPT-LABEL: define {{[^@]+}}@_Z6kernelv
+// OPT-SAME: () local_unnamed_addr #[[ATTR2:[0-9]+]] {
+// OPT-NEXT:  entry:
+// OPT-NEXT:tail call void @_Z11extern_funcv() #[[ATTR3]]
+// OPT-NEXT:ret void
+//
 __global__ void kernel() {
  extern_func();
 }
@@ -39,7 +60,16 @@ __global__ void kernel() {
 // OPTNONE: attributes #[[ATTR2]] = { convergent mustprogress noinline 
norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,1024" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="true" }
 // OPTNONE: attributes #[[ATTR3]] = { convergent nounwind }
 //.
+// OPT: attributes #[[ATTR0]] = { convergent mustprogress nounwind 
"amdgpu-waves-per-eu"="4,10" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="false" }
+// OPT: attributes #[[ATTR1:[0-9]+]] = { convergent nounwind 
"amdgpu-waves-per-eu"="4,10" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="false" }
+// OPT: attributes #[[ATTR2]] = { convergent mustprogress norecurse nounwind 
"amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
+// OPT: attributes #[[ATTR3]] = { convergent nounwind }
+//.
 // OPTNONE: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 
500}
 // OPTNONE: [[META1:![0-9]+]] = !{i32 1, !"amdgpu_printf_kind", !"hostcall"}
 // OPTNONE: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 //.
+// OPT: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 500}
+// OPT: [[META1:![0-9]+]] = !{i32 1, !"amdgpu_printf_kind", !"hostcall"}
+// OPT: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
+//.

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


[clang] [llvm] [RISCV] Add TT-Ascalon-d8 processor (PR #115100)

2024-11-06 Thread Michael Maitland via cfe-commits


@@ -407,6 +407,54 @@ def SYNTACORE_SCR7 : RISCVProcessorModel<"syntacore-scr7",
FeatureStdExtZkn],
   [TuneNoDefaultUnroll, 
FeaturePostRAScheduler]>;
 
+def TENSTORRENT_ASCALON_D8 : RISCVProcessorModel<"tt-ascalon-d8",
+  NoSchedModel,

michaelmaitland wrote:

I he means NoSchedModel needs to be indented more.

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


[clang] [llvm] [RISCV] Add TT-Ascalon-d8 processor (PR #115100)

2024-11-06 Thread Petr Penzin via cfe-commits


@@ -407,6 +407,54 @@ def SYNTACORE_SCR7 : RISCVProcessorModel<"syntacore-scr7",
FeatureStdExtZkn],
   [TuneNoDefaultUnroll, 
FeaturePostRAScheduler]>;
 
+def TENSTORRENT_ASCALON_D8 : RISCVProcessorModel<"tt-ascalon-d8",
+  NoSchedModel,

ppenzin wrote:

Do you mean between the name and feature flags?

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


[clang] [llvm] [HLSL] Adding HLSL `clip` function. (PR #114588)

2024-11-06 Thread via cfe-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/114588

>From a92e64d9a769d3d7b58d5f028fc157e56b879282 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Tue, 29 Oct 2024 19:39:31 +
Subject: [PATCH 1/4] adding llvm intrinsic

---
 clang/include/clang/Basic/Builtins.td |  6 ++
 clang/lib/CodeGen/CGBuiltin.cpp   | 10 ++
 clang/lib/CodeGen/CGHLSLRuntime.h |  2 +-
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 17 +
 clang/lib/Sema/SemaHLSL.cpp   |  8 
 clang/test/CodeGenHLSL/builtins/clip.hlsl | 14 ++
 llvm/include/llvm/IR/IntrinsicsDirectX.td |  1 +
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  1 +
 8 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGenHLSL/builtins/clip.hlsl

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 9bd67e0cefebc3..1b8697b209bd70 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4877,6 +4877,12 @@ def HLSLSplitDouble: LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLClip: LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_elementwise_clip"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void(bool)";
+}
+
 // Builtins for XRay.
 def XRayCustomEvent : Builtin {
   let Spellings = ["__xray_customevent"];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 34fedd67114751..1588c4917abbfb 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19093,6 +19093,16 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
"asuint operands types mismatch");
 return handleHlslSplitdouble(E, this);
   }
+  case Builtin::BI__builtin_hlsl_elementwise_clip:
+
+assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
+   "clip operands types mismatch");
+
+Value *Op0 = EmitScalarExpr(E->getArg(0));
+auto *CMP =
+Builder.CreateFCmpOLT(Op0, ConstantFP::get(Builder.getFloatTy(), 0.0));
+return Builder.CreateIntrinsic(
+VoidTy, CGM.getHLSLRuntime().getClipIntrinsic(), {CMP}, nullptr);
   }
   return nullptr;
 }
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index cd533cad84e9fb..06abc95bdb734f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -91,7 +91,7 @@ class CGHLSLRuntime {
   GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
   GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_readlane)
-
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Clip, clip)
   GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromBinding, handle_fromBinding)
 
   
//===--===//
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index d9f3a17ea23d8e..424c2f7e7c23ee 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -655,6 +655,23 @@ double3 clamp(double3, double3, double3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
 double4 clamp(double4, double4, double4);
 
+//===--===//
+// clip builtins
+//===--===//
+
+/// \fn void clip(T Val)
+/// \brief Discards the current pixel if the specified value is less than zero.
+/// \param Val The input value.
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float4);
+
 
//===--===//
 // cos builtins
 
//===--===//
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index a472538236e2d9..e360c54dc0760e 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -2110,6 +2110,14 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 break;
   }
+  case Builtin::BI__builtin_hlsl_elementwise_clip: {
+if (SemaRef.checkArgCount(TheCall, 1))
+  return true;
+
+if (CheckScalarOrVector(&SemaRef, TheCall, SemaRef.Context.FloatTy, 0))
+  return true;
+break;
+  }
   case Builtin::BI__builtin_elementwise_acos:
   case Builtin::BI__builtin_elementwise_asin:
   case Builtin::BI__builtin_elementwise_atan:
diff --git a/clang/test/CodeGenHLSL/builtins/clip.hlsl 
b/clang/test/CodeGenHLSL/builtins/clip.hlsl
new file mode 100644
index 00..426ec8f128436a
--- /dev/null
+++ 

[clang] [llvm] [RISCV] Add TT-Ascalon-d8 processor (PR #115100)

2024-11-06 Thread Petr Penzin via cfe-commits


@@ -407,6 +407,54 @@ def SYNTACORE_SCR7 : RISCVProcessorModel<"syntacore-scr7",
FeatureStdExtZkn],
   [TuneNoDefaultUnroll, 
FeaturePostRAScheduler]>;
 
+def TENSTORRENT_ASCALON_D8 : RISCVProcessorModel<"tt-ascalon-d8",
+  NoSchedModel,
+  [Feature64Bit,
+   FeatureStdExtI,
+   FeatureStdExtZifencei,
+   FeatureStdExtZicsr,
+   FeatureStdExtZicntr,
+   FeatureStdExtZihpm,
+   FeatureStdExtZihintpause,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtV,
+   FeatureStdExtZvl256b,
+   FeatureStdExtZfh,
+   FeatureStdExtZvfh,
+   FeatureStdExtZba,
+   FeatureStdExtZbb,
+   FeatureStdExtZbs,
+   FeatureStdExtZicbom,
+   FeatureStdExtZicbop,
+   FeatureStdExtZicboz,
+   FeatureStdExtH,
+   FeatureStdExtZihintntl,
+   FeatureStdExtZfhmin,
+   FeatureStdExtZfa,
+   FeatureStdExtZkt,
+   FeatureStdExtZcb,
+   FeatureStdExtZvbb,
+   FeatureStdExtZvbc,
+   FeatureStdExtZawrs,
+   FeatureStdExtZvkng,
+   FeatureStdExtZicond,
+   FeatureUnalignedScalarMem,
+   FeatureUnalignedVectorMem,
+   FeatureStdExtSvnapot,
+   FeatureStdExtSvpbmt,
+   FeatureStdExtSvinval,
+   FeatureStdExtZfbfmin,
+   FeatureStdExtZvfbfmin,
+   FeatureStdExtZvfbfwma],

ppenzin wrote:

Good point, and we do support Zimop.

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


[clang] clang/AMDGPU: Restore O3 checks in default-attributes.hip (PR #115238)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matt Arsenault (arsenm)


Changes

These were dropped in b1bcb7ca460fcd317bbc8309e14c8761bf8394e0 to
avoid some bot failures.

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


1 Files Affected:

- (modified) clang/test/CodeGenHIP/default-attributes.hip (+30) 


``diff
diff --git a/clang/test/CodeGenHIP/default-attributes.hip 
b/clang/test/CodeGenHIP/default-attributes.hip
index 1b53ebec9b5821..ee16ecd134bfee 100644
--- a/clang/test/CodeGenHIP/default-attributes.hip
+++ b/clang/test/CodeGenHIP/default-attributes.hip
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -fno-ident 
-fcuda-is-device \
 // RUN:-emit-llvm -o - %s | FileCheck -check-prefix=OPTNONE %s
 
+// RUN: %clang_cc1 -O3 -triple amdgcn-amd-amdhsa -x hip -fno-ident 
-fcuda-is-device \
+// RUN:-emit-llvm -o - %s | FileCheck -check-prefix=OPT %s
+
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))
 
@@ -10,6 +13,10 @@
 // OPTNONE: @llvm.compiler.used = appending addrspace(1) global [1 x ptr] [ptr 
addrspacecast (ptr addrspace(1) @__hip_cuid_ to ptr)], section "llvm.metadata"
 // OPTNONE: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr 
addrspace(4) constant i32 500
 //.
+// OPT: @__hip_cuid_ = addrspace(1) global i8 0
+// OPT: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr addrspace(4) 
constant i32 500
+// OPT: @llvm.compiler.used = appending addrspace(1) global [1 x ptr] [ptr 
addrspacecast (ptr addrspace(1) @__hip_cuid_ to ptr)], section "llvm.metadata"
+//.
 __device__ void extern_func();
 
 // OPTNONE: Function Attrs: convergent mustprogress noinline nounwind optnone
@@ -19,6 +26,13 @@ __device__ void extern_func();
 // OPTNONE-NEXT:call void @_Z11extern_funcv() #[[ATTR3:[0-9]+]]
 // OPTNONE-NEXT:ret void
 //
+// OPT: Function Attrs: convergent mustprogress nounwind
+// OPT-LABEL: define {{[^@]+}}@_Z4funcv
+// OPT-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// OPT-NEXT:  entry:
+// OPT-NEXT:tail call void @_Z11extern_funcv() #[[ATTR3:[0-9]+]]
+// OPT-NEXT:ret void
+//
 __device__ void func() {
  extern_func();
 }
@@ -30,6 +44,13 @@ __device__ void func() {
 // OPTNONE-NEXT:call void @_Z11extern_funcv() #[[ATTR3]]
 // OPTNONE-NEXT:ret void
 //
+// OPT: Function Attrs: convergent mustprogress norecurse nounwind
+// OPT-LABEL: define {{[^@]+}}@_Z6kernelv
+// OPT-SAME: () local_unnamed_addr #[[ATTR2:[0-9]+]] {
+// OPT-NEXT:  entry:
+// OPT-NEXT:tail call void @_Z11extern_funcv() #[[ATTR3]]
+// OPT-NEXT:ret void
+//
 __global__ void kernel() {
  extern_func();
 }
@@ -39,7 +60,16 @@ __global__ void kernel() {
 // OPTNONE: attributes #[[ATTR2]] = { convergent mustprogress noinline 
norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,1024" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="true" }
 // OPTNONE: attributes #[[ATTR3]] = { convergent nounwind }
 //.
+// OPT: attributes #[[ATTR0]] = { convergent mustprogress nounwind 
"amdgpu-waves-per-eu"="4,10" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="false" }
+// OPT: attributes #[[ATTR1:[0-9]+]] = { convergent nounwind 
"amdgpu-waves-per-eu"="4,10" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="false" }
+// OPT: attributes #[[ATTR2]] = { convergent mustprogress norecurse nounwind 
"amdgpu-flat-work-group-size"="1,1024" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
+// OPT: attributes #[[ATTR3]] = { convergent nounwind }
+//.
 // OPTNONE: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 
500}
 // OPTNONE: [[META1:![0-9]+]] = !{i32 1, !"amdgpu_printf_kind", !"hostcall"}
 // OPTNONE: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 //.
+// OPT: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 500}
+// OPT: [[META1:![0-9]+]] = !{i32 1, !"amdgpu_printf_kind", !"hostcall"}
+// OPT: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
+//.

``




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


[clang] clang/AMDGPU: Restore O3 checks in default-attributes.hip (PR #115238)

2024-11-06 Thread Matt Arsenault via cfe-commits

arsenm wrote:

* **#115238** https://app.graphite.dev/github/pr/llvm/llvm-project/115238?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈
* `main`

This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about 
stacking.


 Join @arsenm and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="11px" height="11px"/> Graphite
  

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


[clang] clang/AMDGPU: Restore O3 checks in default-attributes.hip (PR #115238)

2024-11-06 Thread Matt Arsenault via cfe-commits

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


[clang] [clang][serialization] Make `ASTWriter` work with `Preprocessor` only (PR #115237)

2024-11-06 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 304c41217303ce613de8f4042e570ac6ca8757e8 
5e66ce95bfb7cb401b5757f8491a89d369ad2010 --extensions h,cpp -- 
clang/include/clang/Serialization/ASTRecordWriter.h 
clang/include/clang/Serialization/ASTWriter.h clang/lib/Frontend/ASTUnit.cpp 
clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterDecl.cpp 
clang/lib/Serialization/ASTWriterStmt.cpp 
clang/lib/Serialization/GeneratePCH.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 7b5b011787..e8e7a23e45 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -673,7 +673,7 @@ public:
   ///
   /// \return the module signature, which eventually will be a hash of
   /// the module but currently is merely a random 32-bit number.
-  ASTFileSignature WriteAST(llvm::PointerUnion Subject,
+  ASTFileSignature WriteAST(llvm::PointerUnion Subject,
 StringRef OutputFile, Module *WritingModule,
 StringRef isysroot,
 bool ShouldCacheASTInMemory = false);
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 43fac29f32..9a45582eb3 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -278,7 +278,7 @@ class ASTTypeWriter {
 
 public:
   ASTTypeWriter(ASTContext &Context, ASTWriter &Writer)
-: Writer(Writer), BasicWriter(Context, Writer, Record) {}
+  : Writer(Writer), BasicWriter(Context, Writer, Record) {}
 
   uint64_t write(QualType T) {
 if (T.hasLocalNonFastQualifiers()) {

``




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


[clang] [clang][serialization] Pass `ASTContext` explicitly (PR #115235)

2024-11-06 Thread Jan Svoboda via cfe-commits

jansvoboda11 wrote:

To clarify, the main reason for this patch is that I find passing a reference 
much less error-prone than having an omnipresent pointer that will only be null 
during dependency scanning.

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


[clang] [clang][deps] Only write preprocessor info into PCMs (PR #115239)

2024-11-06 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 created 
https://github.com/llvm/llvm-project/pull/115239

This patch builds on top of https://github.com/llvm/llvm-project/pull/115237 
and https://github.com/llvm/llvm-project/pull/115235, only passing the 
`Preprocessor` object to `ASTWriter`. This reduces the size of scanning PCM 
files by 1/3 and speeds up scans by 16%.

>From 27985cf8df00f1edf6e74b7e50ce5be13569591c Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Wed, 6 Nov 2024 09:54:06 -0800
Subject: [PATCH 1/4] [clang][serialization] Pass `ASTContext` explicitly

---
 .../clang/Serialization/ASTRecordWriter.h |   7 +-
 clang/include/clang/Serialization/ASTWriter.h |  28 ++---
 clang/lib/Serialization/ASTWriter.cpp | 118 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  55 
 clang/lib/Serialization/ASTWriterStmt.cpp |  15 +--
 5 files changed, 110 insertions(+), 113 deletions(-)

diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h 
b/clang/include/clang/Serialization/ASTRecordWriter.h
index d6090ba1a6c690..67720a0aebc1ca 100644
--- a/clang/include/clang/Serialization/ASTRecordWriter.h
+++ b/clang/include/clang/Serialization/ASTRecordWriter.h
@@ -60,8 +60,9 @@ class ASTRecordWriter
 
 public:
   /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
-  : DataStreamBasicWriter(W.getASTContext()), Writer(&W), Record(&Record) 
{}
+  ASTRecordWriter(ASTContext &Context, ASTWriter &W,
+  ASTWriter::RecordDataImpl &Record)
+  : DataStreamBasicWriter(Context), Writer(&W), Record(&Record) {}
 
   /// Construct a ASTRecordWriter that uses the same encoding scheme as another
   /// ASTRecordWriter.
@@ -208,7 +209,7 @@ class ASTRecordWriter
 
   /// Emit a reference to a type.
   void AddTypeRef(QualType T) {
-return Writer->AddTypeRef(T, *Record);
+return Writer->AddTypeRef(getASTContext(), T, *Record);
   }
   void writeQualType(QualType T) {
 AddTypeRef(T);
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index d0e841f367c1e0..dc9fcd3c33726e 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// The PCM manager which manages memory buffers for pcm files.
   InMemoryModuleCache &ModuleCache;
 
-  /// The ASTContext we're writing.
-  ASTContext *Context = nullptr;
-
   /// The preprocessor we're writing.
   Preprocessor *PP = nullptr;
 
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getSubmoduleID(Module *Mod);
 
   /// Write the given subexpression to the bitstream.
-  void WriteSubStmt(Stmt *S);
+  void WriteSubStmt(ASTContext &Context, Stmt *S);
 
   void WriteBlockInfoBlock();
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
@@ -564,25 +561,25 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,
uint64_t MacroOffsetsBase);
-  void WriteSubmodules(Module *WritingModule);
+  void WriteSubmodules(Module *WritingModule, ASTContext &Context);
 
   void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
  bool isModule);
 
   unsigned TypeExtQualAbbrev = 0;
   void WriteTypeAbbrevs();
-  void WriteType(QualType T);
+  void WriteType(ASTContext &Context, QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
 
-  void GenerateNameLookupTable(const DeclContext *DC,
+  void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
llvm::SmallVectorImpl &LookupTable);
   uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
 const DeclContext *DC);
   uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
   void WriteTypeDeclOffsets();
   void WriteFileDeclIDsMap();
-  void WriteComments();
+  void WriteComments(ASTContext &Context);
   void WriteSelectors(Sema &SemaRef);
   void WriteReferencedSelectorsPool(Sema &SemaRef);
   void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
@@ -590,8 +587,10 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteDeclAndTypes(ASTContext &Context);
   void PrepareWritingSpecialDecls(Sema &SemaRef);
   void WriteSpecialDeclRecords(Sema &SemaRef);
-  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
-  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
+  void WriteDeclUpdatesBlocks(ASTContext &Context,
+  RecordDataImpl &OffsetsRecord);
+  void WriteDeclContextVisibleUpdate(ASTContext &Context,
+ const DeclContext *DC);
   void Writ

[clang] [HLSL] Add Append/ConsumeStructuredBuffer definitions to HLSLExternalSemaSource (PR #113643)

2024-11-06 Thread Helena Kotas via cfe-commits

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


[clang] [clang][deps] Only write preprocessor info into PCMs (PR #115239)

2024-11-06 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 304c41217303ce613de8f4042e570ac6ca8757e8 
446f239b8080e22403fa8c648e25c61b2d76bf9c --extensions cpp,h -- 
clang/include/clang/Lex/HeaderSearchOptions.h 
clang/include/clang/Serialization/ASTRecordWriter.h 
clang/include/clang/Serialization/ASTWriter.h clang/lib/Frontend/ASTUnit.cpp 
clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp 
clang/lib/Serialization/ASTWriterDecl.cpp 
clang/lib/Serialization/ASTWriterStmt.cpp 
clang/lib/Serialization/GeneratePCH.cpp 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 51253ea3c6..bc44ee4e25 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -673,7 +673,7 @@ public:
   ///
   /// \return the module signature, which eventually will be a hash of
   /// the module but currently is merely a random 32-bit number.
-  ASTFileSignature WriteAST(llvm::PointerUnion Subject,
+  ASTFileSignature WriteAST(llvm::PointerUnion Subject,
 StringRef OutputFile, Module *WritingModule,
 StringRef isysroot,
 bool ShouldCacheASTInMemory = false);
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 43fac29f32..9a45582eb3 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -278,7 +278,7 @@ class ASTTypeWriter {
 
 public:
   ASTTypeWriter(ASTContext &Context, ASTWriter &Writer)
-: Writer(Writer), BasicWriter(Context, Writer, Record) {}
+  : Writer(Writer), BasicWriter(Context, Writer, Record) {}
 
   uint64_t write(QualType T) {
 if (T.hasLocalNonFastQualifiers()) {

``




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


[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)

2024-11-06 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/113777

>From 78019b9d9dc138f38bb5b32576b621351ae6427c Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 27 Oct 2024 01:07:57 +0300
Subject: [PATCH 1/7] [Clang] prevent assertion failure from an invalid
 template instantiation pattern when adding instantiated params to the scope
 in friend functions with defaulted params

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 
 clang/test/CXX/temp/temp.res/p4.cpp| 7 +++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a95337815174b..428ec8c87a432e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Bug Fixes to C++ Support
   const-default-constructible even if a union member has a default member 
initializer.
   (#GH95854).
 - Fixed an assertion failure when evaluating an invalid expression in an array 
initializer (#GH112140)
+- Fixed an assertion failure caused by an invalid template instantiation 
pattern
+  for adding instantiated parameters to the scope in friend functions with 
defaulted parameters. (#GH113324).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 6a55861fe5af3b..cddfcc48312042 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3435,10 +3435,10 @@ bool Sema::SubstDefaultArgument(
   //   template void f(T a, int = decltype(a)());
   //   void g() { f(0); }
   LIS = std::make_unique(*this);
-  FunctionDecl *PatternFD = FD->getTemplateInstantiationPattern(
-  /*ForDefinition*/ false);
-  if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
-return true;
+  if (FunctionDecl *PatternFD =
+  FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
+if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, 
TemplateArgs))
+  return true;
 }
 
 runWithSufficientStackSpace(Loc, [&] {
diff --git a/clang/test/CXX/temp/temp.res/p4.cpp 
b/clang/test/CXX/temp/temp.res/p4.cpp
index f54d8649f5da88..62bd766e7e1140 100644
--- a/clang/test/CXX/temp/temp.res/p4.cpp
+++ b/clang/test/CXX/temp/temp.res/p4.cpp
@@ -185,3 +185,10 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f(ct, int = 0); // expected-error {{friend declaration 
specifying a default argument must be a definition}}
+};
+void test() { f(ct<>{}); }
+}

>From 89bbd61af02e7bada9bf9482f3fba8e28a475cbe Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Fri, 1 Nov 2024 18:22:34 +0200
Subject: [PATCH 2/7] eliminate nested conditions

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index cddfcc48312042..046ca63e26dbc0 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3428,17 +3428,19 @@ bool Sema::SubstDefaultArgument(
 ContextRAII SavedContext(*this, FD);
 std::unique_ptr LIS;
 
-if (ForCallExpr) {
+FunctionDecl *PatternFD =
+ForCallExpr
+? FD->getTemplateInstantiationPattern(/*ForDefinition*/ false)
+: nullptr;
+if (PatternFD) {
   // When instantiating a default argument due to use in a call expression,
   // an instantiation scope that includes the parameters of the callee is
   // required to satisfy references from the default argument. For example:
   //   template void f(T a, int = decltype(a)());
   //   void g() { f(0); }
   LIS = std::make_unique(*this);
-  if (FunctionDecl *PatternFD =
-  FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
-if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, 
TemplateArgs))
-  return true;
+  if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
+return true;
 }
 
 runWithSufficientStackSpace(Loc, [&] {

>From c1c985e1b32908813c1f1c236b7f807b33ea427b Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 6 Nov 2024 15:53:22 +0200
Subject: [PATCH 3/7] [Clang] Ensure default arguments in friend declarations
 are only allowed in defining declarations to prevent multiple reachable
 declarations

---
 clang/docs/ReleaseNotes.rst| 4 ++--
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 +++-
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 9 +
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 979f043eb7ee5c..4d706d552e256e 100644
--- a/clang/docs/Relea

[clang] [clang][deps] Only write preprocessor info into PCMs (PR #115239)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Jan Svoboda (jansvoboda11)


Changes

This patch builds on top of https://github.com/llvm/llvm-project/pull/115237 
and https://github.com/llvm/llvm-project/pull/115235, only passing the 
`Preprocessor` object to `ASTWriter`. This reduces the size of scanning PCM 
files by 1/3 and speeds up scans by 16%.

---

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


10 Files Affected:

- (modified) clang/include/clang/Lex/HeaderSearchOptions.h (+5) 
- (modified) clang/include/clang/Serialization/ASTRecordWriter.h (+4-3) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+21-28) 
- (modified) clang/lib/Frontend/ASTUnit.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+3) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+149-127) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+30-25) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+8-7) 
- (modified) clang/lib/Serialization/GeneratePCH.cpp (+14-5) 
- (modified) clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
(+1) 


``diff
diff --git a/clang/include/clang/Lex/HeaderSearchOptions.h 
b/clang/include/clang/Lex/HeaderSearchOptions.h
index c85e3d27281701..7a16926c186d2c 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -255,6 +255,10 @@ class HeaderSearchOptions {
   LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesHashContent : 1;
 
+  /// Whether AST files should only contain the preprocessor information.
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned ModulesSerializeOnlyPreprocessor : 1;
+
   /// Whether we should include all things that could impact the module in the
   /// hash.
   ///
@@ -288,6 +292,7 @@ class HeaderSearchOptions {
 ModulesSkipHeaderSearchPaths(false),
 ModulesSkipPragmaDiagnosticMappings(false),
 ModulesPruneNonAffectingModuleMaps(true), ModulesHashContent(false),
+ModulesSerializeOnlyPreprocessor(false),
 ModulesStrictContextHash(false), ModulesIncludeVFSUsage(false),
 AllowModuleMapSubdirectorySearch(true) {}
 
diff --git a/clang/include/clang/Serialization/ASTRecordWriter.h 
b/clang/include/clang/Serialization/ASTRecordWriter.h
index d6090ba1a6c690..67720a0aebc1ca 100644
--- a/clang/include/clang/Serialization/ASTRecordWriter.h
+++ b/clang/include/clang/Serialization/ASTRecordWriter.h
@@ -60,8 +60,9 @@ class ASTRecordWriter
 
 public:
   /// Construct a ASTRecordWriter that uses the default encoding scheme.
-  ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
-  : DataStreamBasicWriter(W.getASTContext()), Writer(&W), Record(&Record) 
{}
+  ASTRecordWriter(ASTContext &Context, ASTWriter &W,
+  ASTWriter::RecordDataImpl &Record)
+  : DataStreamBasicWriter(Context), Writer(&W), Record(&Record) {}
 
   /// Construct a ASTRecordWriter that uses the same encoding scheme as another
   /// ASTRecordWriter.
@@ -208,7 +209,7 @@ class ASTRecordWriter
 
   /// Emit a reference to a type.
   void AddTypeRef(QualType T) {
-return Writer->AddTypeRef(T, *Record);
+return Writer->AddTypeRef(getASTContext(), T, *Record);
   }
   void writeQualType(QualType T) {
 AddTypeRef(T);
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index d0e841f367c1e0..51253ea3c63ec7 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// The PCM manager which manages memory buffers for pcm files.
   InMemoryModuleCache &ModuleCache;
 
-  /// The ASTContext we're writing.
-  ASTContext *Context = nullptr;
-
   /// The preprocessor we're writing.
   Preprocessor *PP = nullptr;
 
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getSubmoduleID(Module *Mod);
 
   /// Write the given subexpression to the bitstream.
-  void WriteSubStmt(Stmt *S);
+  void WriteSubStmt(ASTContext &Context, Stmt *S);
 
   void WriteBlockInfoBlock();
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
@@ -564,34 +561,36 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,
uint64_t MacroOffsetsBase);
-  void WriteSubmodules(Module *WritingModule);
+  void WriteSubmodules(Module *WritingModule, ASTContext *Context);
 
   void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
  bool isModule);
 
   unsigned TypeExtQualAbbrev = 0;
   void WriteTypeAbbrevs();
-  void WriteType(QualType T);
+  void WriteType(ASTContext &Context, QualType T);
 
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
 
-  void Genera

[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -185,3 +185,21 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f1(ct, int = 0);   // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+  friend void f2(ct a, ct = decltype(a){ }); // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+};
+
+template using alias = int;
+template struct C {
+  friend void f3(C, int a = alias(1)); // expected-error {{friend 
declaration specifying a default argument must be a definition}}

mizvekov wrote:

(It's missing this change by the way)

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


[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-06 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/114148

>From 8c76f28c8a0ba3d087361141366968071fa3af6e Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Tue, 29 Oct 2024 16:02:26 -0700
Subject: [PATCH 1/6] [HLSL] Add Increment/DecrementCounter methods to
 structured buffers

Introduces `__builtin_hlsl_buffer_update_counter` clang buildin that is used to 
implement IncrementCounter and DecrementCounter methods on RWStructuredBuffer 
and RasterizerOrderedStructuredBuffer. The builtin is translated to LLVM 
intrisics llvm.dx.bufferUpdateCounter/llvm.spv.bufferUpdateCounter.

Introduces `BuiltinTypeMethodBuilder` helper in `HLSLExternalSemaSource` that 
allows adding methods to builtin types
using the builder pattern like this:

   BuiltinTypeMethodBuilder(Sema, RecordBuilder, "MethodName", ReturnType)
   .addParam("param_name", Type, InOutModifier)
   .callBuiltin("buildin_name", { BuiltinParams })
   .finalizeMethod();

Fixes #113513
---
 clang/include/clang/Basic/Builtins.td |   7 +-
 .../clang/Basic/DiagnosticSemaKinds.td|   4 +
 clang/lib/CodeGen/CGBuiltin.cpp   |   8 +
 clang/lib/CodeGen/CGHLSLRuntime.h |   1 +
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 278 --
 clang/lib/Sema/SemaExpr.cpp   |   4 +
 clang/lib/Sema/SemaHLSL.cpp   |  41 +++
 .../StructuredBuffers-methods-lib.hlsl|  25 ++
 .../StructuredBuffers-methods-ps.hlsl |  29 ++
 .../buffer_update_counter-errors.hlsl |  22 ++
 llvm/include/llvm/IR/IntrinsicsDirectX.td |   3 +
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |   3 +
 12 files changed, 393 insertions(+), 32 deletions(-)
 create mode 100644 
clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-lib.hlsl
 create mode 100644 
clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl
 create mode 100644 
clang/test/SemaHLSL/BuiltIns/buffer_update_counter-errors.hlsl

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 90475a361bb8f8..72bc2d5e7df23e 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4846,7 +4846,6 @@ def HLSLSaturate : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
-
 def HLSLSelect : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_select"];
   let Attributes = [NoThrow, Const];
@@ -4871,6 +4870,12 @@ def HLSLRadians : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLBufferUpdateCounter : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_buffer_update_counter"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "uint32_t(...)";
+}
+
 // Builtins for XRay.
 def XRayCustomEvent : Builtin {
   let Spellings = ["__xray_customevent"];
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8e4718008ece72..2aea6bb657578a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7256,6 +7256,8 @@ def err_typecheck_illegal_increment_decrement : Error<
   "cannot %select{decrement|increment}1 value of type %0">;
 def err_typecheck_expect_int : Error<
   "used type %0 where integer is required">;
+def err_typecheck_expect_hlsl_resource : Error<
+  "used type %0 where __hlsl_resource_t is required">;
 def err_typecheck_arithmetic_incomplete_or_sizeless_type : Error<
   "arithmetic on a pointer to %select{an incomplete|sizeless}0 type %1">;
 def err_typecheck_pointer_arith_function_type : Error<
@@ -12485,6 +12487,8 @@ def warn_attr_min_eq_max:  Warning<
 
 def err_hlsl_attribute_number_arguments_insufficient_shader_model: Error<
   "attribute %0 with %1 arguments requires shader model %2 or greater">;
+def err_hlsl_expect_arg_const_int_one_or_neg_one: Error<
+  "argument %0 must be constant integer 1 or -1">;
 
 // Layout randomization diagnostics.
 def err_non_designated_init_used : Error<
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e2d03eff8ab4a0..71273de3400b17 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18959,6 +18959,14 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
 CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0},
 nullptr, "hlsl.radians");
   }
+  case Builtin::BI__builtin_hlsl_buffer_update_counter: {
+Value *ResHandle = EmitScalarExpr(E->getArg(0));
+Value *Offset = EmitScalarExpr(E->getArg(1));
+return Builder.CreateIntrinsic(
+/*ReturnType=*/Offset->getType(),
+CGM.getHLSLRuntime().getBufferUpdateCounterIntrinsic(),
+ArrayRef{ResHandle, Offset}, nullptr);
+  }
   }
   return nullptr;
 }
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index ff7df41b5c62e7..aac93dfc373ed4 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/cl

[clang] [PS5][Driver] Restore whole-archive state when `-fjmc` (PR #115181)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Edd Dawson (playstation-edd)


Changes

`--whole-archive` is passed to the linker to have it consume all objects within 
the SIE Just My Code library, rather than just those that fulfil outstanding 
references.

Prior to this change, `--no-whole-archive` was used to reset the associated 
archive handling state in the linker, under the assumption that 
`--whole-archive` wasn't already in effect. But that assumption may be 
incorrect. So use `--push/pop-state` to restore the previous state, whatever 
that may be.

Given the position of these switches on the link line, the problem described 
with the outgoing code is unlikely to cause an issue in practice. But push/pop 
protect against accidents due to future additions to and reorderings of 
arguments.

PS5 only. The proprietary PS4 linker doesn't support `--push/pop-state`, or an 
equivalent.

SIE tracker: TOOLCHAIN-16704.

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+2-1) 
- (modified) clang/test/Driver/ps5-linker.c (+1-1) 


``diff
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 261c136de782e7..df43da93d77555 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -375,9 +375,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (UseJMC) {
+CmdArgs.push_back("--push-state");
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lSceJmc_nosubmission");
-CmdArgs.push_back("--no-whole-archive");
+CmdArgs.push_back("--pop-state");
   }
 
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 8a0ade91871295..fb5f8a9ec5cee5 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -95,7 +95,7 @@
 // CHECK: -plugin-opt=-enable-jmc-instrument
 
 // Check the default library name.
-// CHECK-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
+// CHECK-LIB: "--push-state" "--whole-archive" "-lSceJmc_nosubmission" 
"--pop-state"
 
 // Test the driver's control over the -fcrash-diagnostics-dir behavior with 
linker flags.
 

``




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


[clang] [PS5][Driver] Restore whole-archive state when `-fjmc` (PR #115181)

2024-11-06 Thread Edd Dawson via cfe-commits

https://github.com/playstation-edd created 
https://github.com/llvm/llvm-project/pull/115181

`--whole-archive` is passed to the linker to have it consume all objects within 
the SIE Just My Code library, rather than just those that fulfil outstanding 
references.

Prior to this change, `--no-whole-archive` was used to reset the associated 
archive handling state in the linker, under the assumption that 
`--whole-archive` wasn't already in effect. But that assumption may be 
incorrect. So use `--push/pop-state` to restore the previous state, whatever 
that may be.

Given the position of these switches on the link line, the problem described 
with the outgoing code is unlikely to cause an issue in practice. But push/pop 
protect against accidents due to future additions to and reorderings of 
arguments.

PS5 only. The proprietary PS4 linker doesn't support `--push/pop-state`, or an 
equivalent.

SIE tracker: TOOLCHAIN-16704.

>From c2eec3d06ad920ef2b7826fe9b76f1b45574e036 Mon Sep 17 00:00:00 2001
From: Edd Dawson 
Date: Wed, 6 Nov 2024 16:24:46 +
Subject: [PATCH] [PS5][Driver] Restore whole-archive state when `-fjmc`

`--whole-archive` is passed to the linker to have it consume all objects
within the SIE Just My Code library, rather than just those that fulfil
outstanding references.

Prior to this change, `--no-whole-archive` was used to reset the
associated archive handling state in the linker, under the assumption
that `--whole-archive` wasn't already in effect. But that assumption may
be incorrect. So use `--push/pop-state` to restore the previous state,
whatever that may be.

Given the position of these switches on the link line, the problem
described with the outgoing code is unlikely to cause an issue in
practice. But push/pop protect against accidents due to future additions
to and reorderings of arguments.

PS5 only. The proprietary PS4 linker doesn't support `--push/pop-state`,
or an equivalent.

SIE tracker: TOOLCHAIN-16704.
---
 clang/lib/Driver/ToolChains/PS4CPU.cpp | 3 ++-
 clang/test/Driver/ps5-linker.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 261c136de782e7..df43da93d77555 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -375,9 +375,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (UseJMC) {
+CmdArgs.push_back("--push-state");
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lSceJmc_nosubmission");
-CmdArgs.push_back("--no-whole-archive");
+CmdArgs.push_back("--pop-state");
   }
 
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 8a0ade91871295..fb5f8a9ec5cee5 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -95,7 +95,7 @@
 // CHECK: -plugin-opt=-enable-jmc-instrument
 
 // Check the default library name.
-// CHECK-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
+// CHECK-LIB: "--push-state" "--whole-archive" "-lSceJmc_nosubmission" 
"--pop-state"
 
 // Test the driver's control over the -fcrash-diagnostics-dir behavior with 
linker flags.
 

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


[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)

2024-11-06 Thread via cfe-commits


@@ -6,7 +6,7 @@
 #include

SpencerAbson wrote:

I think `#include ` is redundant here.

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


[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)

2024-11-06 Thread via cfe-commits


@@ -3,9 +3,9 @@
 // REQUIRES: aarch64-registered-target
 #include

SpencerAbson wrote:

I think `#include ` is redundant here.

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


[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)

2024-11-06 Thread via cfe-commits

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


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


[clang] [flang] [clang][Driver] Add the ability to specify that RPATH should be added by default (PR #115163)

2024-11-06 Thread Paul Osmialowski via cfe-commits

https://github.com/pawosm-arm updated 
https://github.com/llvm/llvm-project/pull/115163

>From 2c4b767437c55245391eb15da94a97b34a63f834 Mon Sep 17 00:00:00 2001
From: Paul Osmialowski 
Date: Tue, 5 Nov 2024 16:38:22 +
Subject: [PATCH] [clang][Driver] Add the ability to specify that RPATH should
 be added by default

The `-frtlib-add-rpath` is very convenient when linking against
various runtimes (OpenMP, Fortran, sanitizers), so much so we
could argue that this should be a default behavior.

This patch adds the ability to specify (at CMake level) that RPATH
should be added by default.
---
 clang/CMakeLists.txt  |   2 +
 clang/include/clang/Config/config.h.cmake |   3 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   4 +
 clang/test/CMakeLists.txt |   1 +
 .../arch-specific-libdir-rpath-by-default.c   | 105 ++
 .../test/Driver/arch-specific-libdir-rpath.c  |   2 +
 clang/test/lit.cfg.py |   3 +
 clang/test/lit.site.cfg.py.in |   1 +
 flang/test/CMakeLists.txt |   1 +
 .../arch-specific-libdir-rpath-by-default.f95 |  40 +++
 .../Driver/arch-specific-libdir-rpath.f95 |   3 +-
 flang/test/Driver/linker-flags.f90|   3 +-
 flang/test/lit.cfg.py |   4 +
 flang/test/lit.site.cfg.py.in |   1 +
 14 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/arch-specific-libdir-rpath-by-default.c
 create mode 100644 flang/test/Driver/arch-specific-libdir-rpath-by-default.f95

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 27e8095534a65c..fb902cd65a31da 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -216,6 +216,8 @@ endif()
 
 set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
 
+set(ENABLE_LINKER_RPATH_BY_DEFAULT OFF CACHE BOOL "pass -rpath to the linker 
by default")
+
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
 "enable x86 relax relocations by default")
 
diff --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 27ed69e21562bf..a7f185d88c68cc 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -69,6 +69,9 @@
 /* pass --build-id to ld */
 #cmakedefine ENABLE_LINKER_BUILD_ID
 
+/* pass -rpath to the linker by default */
+#cmakedefine ENABLE_LINKER_RPATH_BY_DEFAULT
+
 /* enable x86 relax relocations by default */
 #cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS
 
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index ca06fb115dfa11..e62f59f56241cd 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1183,7 +1183,11 @@ void tools::addOpenMPRuntimeLibraryPath(const ToolChain 
&TC,
 void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
  ArgStringList &CmdArgs) {
   if (!Args.hasFlag(options::OPT_frtlib_add_rpath,
+#ifdef ENABLE_LINKER_RPATH_BY_DEFAULT
+options::OPT_fno_rtlib_add_rpath, true))
+#else
 options::OPT_fno_rtlib_add_rpath, false))
+#endif
 return;
 
   SmallVector CandidateRPaths(TC.getArchSpecificLibPaths());
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5369dc92f69e8a..e439e973ce6f81 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -11,6 +11,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   CLANG_ENABLE_CIR
   ENABLE_BACKTRACES
+  ENABLE_LINKER_RPATH_BY_DEFAULT
   LLVM_BUILD_EXAMPLES
   LLVM_BYE_LINK_INTO_TOOLS
   LLVM_ENABLE_PLUGINS
diff --git a/clang/test/Driver/arch-specific-libdir-rpath-by-default.c 
b/clang/test/Driver/arch-specific-libdir-rpath-by-default.c
new file mode 100644
index 00..20c3f2fa560905
--- /dev/null
+++ b/clang/test/Driver/arch-specific-libdir-rpath-by-default.c
@@ -0,0 +1,105 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
+//
+// REQUIRES: enable_rpath_by_default
+//
+// Test the default behavior when neither -frtlib-add-rpath nor
+// -fno-rtlib-add-rpath is specified, which is to add -rpath
+// RUN: %clang %s -### --target=x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+//
+// Test that -rpath is not added under -fno-rtlib-add-rpath even if other
+// conditions are met.
+// RUN: %clang %s -### --target=x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -fno-rtlib-add-rpath 2>&1 \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is ad

[clang] [llvm] [Clang] Match MSVC handling of duplicate header search paths in Microsoft compatibility modes. (PR #105738)

2024-11-06 Thread Tom Honermann via cfe-commits

tahonermann wrote:

Thanks, @AaronBallman,

> > Ideally, I think we would do the following at some point to improve 
> > compatibility with MSVC.
> 
> I'm not opposed, but I am concerned about the potential to subtly break user 
> code that's relying on our current search path behavior. We may need to find 
> some clever diagnostics for cases where lookup would have previously 
> succeeded or found a different file.

The changes I was suggesting in that comment would not change what files are 
found; it would only affect whether the file was to be treated as a user or 
system header. That being said, the changes in this PR do affect file 
resolution, but only in cases where the same path is specified multiple times.

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


[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -4694,6 +4694,15 @@ bool Sema::InstantiateDefaultArgument(SourceLocation 
CallLoc, FunctionDecl *FD,
   ParmVarDecl *Param) {
   assert(Param->hasUninstantiatedDefaultArg());
 
+  // C++ [dcl.fct.default]p4
+  //   If a friend declaration D specifies a default argument expression, that
+  //   declaration shall be a definition and there shall be no other 
declaration
+  //   of the function or function template which is reachable from D or from
+  //   which D is reachable.
+  if (FD->getFriendObjectKind() != Decl::FOK_None &&
+  FD->getTemplateInstantiationPattern() == nullptr)
+return true;

mizvekov wrote:

I think the `FD->getTemplateInstantiationPattern() == nullptr` check is a bit 
of a roundabout way of going about doing what the wording says. It doesn't mean 
the function has no reachable definition per se, that's only currently true for 
friend functions, and the consequence of a trick which we could improve in the 
future.

I am not saying necessarily to change that aspect of the fix, but it's worth 
calling it out.
Though in this case, the `FD->getFriendObjectKind() != Decl::FOK_None` check 
seems unnecessary.
By the way, `getTemplateInstantiationPattern` is not exactly trivial cost, so 
it might be worth moving this check to where the non-null return value would be 
used anyway.

Also, with this approach, we stop diagnosing substitution failures in the 
default argument, in these cases where the friend function decl has no 
definition. Since that was already an error, this is just worse error recovery, 
but it might be worth adding a test for it.

I think it's also worth calling this out in a comment with a FIXME so that we 
are aware this can be improved in the future.

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


[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -4694,6 +4694,15 @@ bool Sema::InstantiateDefaultArgument(SourceLocation 
CallLoc, FunctionDecl *FD,
   ParmVarDecl *Param) {
   assert(Param->hasUninstantiatedDefaultArg());
 
+  // C++ [dcl.fct.default]p4
+  //   If a friend declaration D specifies a default argument expression, that
+  //   declaration shall be a definition and there shall be no other 
declaration
+  //   of the function or function template which is reachable from D or from
+  //   which D is reachable.

mizvekov wrote:

```suggestion
  //   declaration shall be a definition ...
```
This only concerns that first part of the rules. Though it's not exactly 
enforcing it, that's implemented somewhere else. So it might be worth pointing 
out that we are avoiding error recovery in this case due to implementation 
difficulties.

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


[clang] [llvm] [Clang-Repl] Add support for out-of-process execution. (PR #110418)

2024-11-06 Thread Lang Hames via cfe-commits


@@ -697,15 +718,20 @@ llvm::Error Interpreter::Undo(unsigned N) {
   return llvm::Error::success();
 }
 
-llvm::Error Interpreter::LoadDynamicLibrary(const char *name) {
+llvm::Error Interpreter::LoadDynamicLibrary(const char *name, bool UseEPC) {
   auto EE = getExecutionEngine();
   if (!EE)
 return EE.takeError();
 
   auto &DL = EE->getDataLayout();
-
-  if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
-  name, DL.getGlobalPrefix()))
+  if (UseEPC) {
+if (auto DLSG = llvm::orc::EPCDynamicLibrarySearchGenerator::Load(
+EE->getExecutionSession(), name))
+  EE->getMainJITDylib().addGenerator(std::move(*DLSG));
+else
+  return DLSG.takeError();
+  } else if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
+ name, DL.getGlobalPrefix()))
 EE->getMainJITDylib().addGenerator(std::move(*DLSG));
   else
 return DLSG.takeError();

lhames wrote:

Have you tried using the EPC generator unconditionally here? That should always 
work now.

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


[clang] [flang] [clang][Driver] Add the ability to specify that RPATH should be added by default (PR #115163)

2024-11-06 Thread Paul Osmialowski via cfe-commits

pawosm-arm wrote:

We worked out this patch just because we dropped the idea of adding 
configuration file to our toolchain and for no other reason...

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


[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)

2024-11-06 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/113777

>From 78019b9d9dc138f38bb5b32576b621351ae6427c Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 27 Oct 2024 01:07:57 +0300
Subject: [PATCH 1/5] [Clang] prevent assertion failure from an invalid
 template instantiation pattern when adding instantiated params to the scope
 in friend functions with defaulted params

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 
 clang/test/CXX/temp/temp.res/p4.cpp| 7 +++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a95337815174b..428ec8c87a432e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Bug Fixes to C++ Support
   const-default-constructible even if a union member has a default member 
initializer.
   (#GH95854).
 - Fixed an assertion failure when evaluating an invalid expression in an array 
initializer (#GH112140)
+- Fixed an assertion failure caused by an invalid template instantiation 
pattern
+  for adding instantiated parameters to the scope in friend functions with 
defaulted parameters. (#GH113324).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 6a55861fe5af3b..cddfcc48312042 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3435,10 +3435,10 @@ bool Sema::SubstDefaultArgument(
   //   template void f(T a, int = decltype(a)());
   //   void g() { f(0); }
   LIS = std::make_unique(*this);
-  FunctionDecl *PatternFD = FD->getTemplateInstantiationPattern(
-  /*ForDefinition*/ false);
-  if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
-return true;
+  if (FunctionDecl *PatternFD =
+  FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
+if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, 
TemplateArgs))
+  return true;
 }
 
 runWithSufficientStackSpace(Loc, [&] {
diff --git a/clang/test/CXX/temp/temp.res/p4.cpp 
b/clang/test/CXX/temp/temp.res/p4.cpp
index f54d8649f5da88..62bd766e7e1140 100644
--- a/clang/test/CXX/temp/temp.res/p4.cpp
+++ b/clang/test/CXX/temp/temp.res/p4.cpp
@@ -185,3 +185,10 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f(ct, int = 0); // expected-error {{friend declaration 
specifying a default argument must be a definition}}
+};
+void test() { f(ct<>{}); }
+}

>From 89bbd61af02e7bada9bf9482f3fba8e28a475cbe Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Fri, 1 Nov 2024 18:22:34 +0200
Subject: [PATCH 2/5] eliminate nested conditions

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index cddfcc48312042..046ca63e26dbc0 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3428,17 +3428,19 @@ bool Sema::SubstDefaultArgument(
 ContextRAII SavedContext(*this, FD);
 std::unique_ptr LIS;
 
-if (ForCallExpr) {
+FunctionDecl *PatternFD =
+ForCallExpr
+? FD->getTemplateInstantiationPattern(/*ForDefinition*/ false)
+: nullptr;
+if (PatternFD) {
   // When instantiating a default argument due to use in a call expression,
   // an instantiation scope that includes the parameters of the callee is
   // required to satisfy references from the default argument. For example:
   //   template void f(T a, int = decltype(a)());
   //   void g() { f(0); }
   LIS = std::make_unique(*this);
-  if (FunctionDecl *PatternFD =
-  FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
-if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, 
TemplateArgs))
-  return true;
+  if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
+return true;
 }
 
 runWithSufficientStackSpace(Loc, [&] {

>From c1c985e1b32908813c1f1c236b7f807b33ea427b Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 6 Nov 2024 15:53:22 +0200
Subject: [PATCH 3/5] [Clang] Ensure default arguments in friend declarations
 are only allowed in defining declarations to prevent multiple reachable
 declarations

---
 clang/docs/ReleaseNotes.rst| 4 ++--
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 +++-
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 9 +
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 979f043eb7ee5c..4d706d552e256e 100644
--- a/clang/docs/Relea

[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread Shilei Tian via cfe-commits


@@ -156,6 +157,8 @@ StringRef llvm::AMDGPU::getArchFamilyNameAMDGCN(GPUKind AK) 
{
   switch (AK) {
   case AMDGPU::GK_GFX9_GENERIC:
 return "gfx9";
+  case AMDGPU::GK_GFX9_4_GENERIC:
+return "gfx9";

shiltian wrote:

I suppose the family name is still `gfx9` here instead of `gfx94` right?

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


[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2024-11-06 Thread Balazs Benics via cfe-commits

steakhal wrote:

> > However, what should we do if multiple (N) classes implement Base? Trying 
> > each N, and basically splitting the state to (N+1) ways is not going to 
> > scale. Unless N is of course really small, like 2 or 3 at most.
> 
> That's kind of what I imagined - try them all. The Analyzer has a built-in 
> timeout mechanism that will come into play.
> 
> If you wanted to be fancy, there could be an obscure config option, with a 
> default of N=3. If config value is not set, and N>3 it asserts, alerting the 
> user to the situation. If config value is set, it limits to analyzing the 
> first N.

I re-read the thread, and I think the most promising approach would be to to 
split the path N ways to see the outcome.

An alternative workaround would be to somehow annotate the code to force it to 
split into N ways and then inject a static cast to each way doing the relevant 
base->derived cast that this PR already instrument and do the desired behavior.
Something like this:
```c++
template  void clang_analyzer_try_cast(const T *base) {
extern bool analyzer_internal_coin();
if (analyzer_internal_coin())
  (void)static_cast(base);
}

template 
void clang_analyzer_split_n_ways(const T *base) {
  static_assert(sizeof...(Ts) > 0);
  (clang_analyzer_try_cast(base), ...);
}

struct Base {};
struct A : Base {};
struct B : Base {};
struct C : Base {};

void test(const Base *p) {
  clang_analyzer_split_n_ways(p);  // <--- This is how the no-op 
static casts would split into A, B, C.
  // We should have like 3 paths here, plus the conservatively eval called path.
}


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


[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)

2024-11-06 Thread Oleksandr T. via cfe-commits


@@ -185,3 +185,27 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f1(ct, int = 0);   // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+  friend void f2(ct a, ct = decltype(a){ }); // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+};
+
+template
+class C {
+public:
+  friend void foo(T a = 1); // expected-error {{friend declaration specifying 
a default argument must be a definition}}
+};
+
+template
+void foo(T a) { } // expected-note {{candidate function template not viable: 
requires single argument 'a', but no arguments were provided}}
+
+void test() {
+  f1(ct<>{});
+  f2(ct<>{});
+
+  C c;
+  foo(); // expected-error {{no matching function for call to 'foo'}}

a-tarasyuk wrote:

Should the previous changes be reverted?

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


[clang] Revert "[Clang][Sema] Use the correct injected template arguments for partial specializations when collecting multi-level template argument lists (#112381)" (PR #115157)

2024-11-06 Thread Krystian Stasiowski via cfe-commits

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

This reverts commit 9381c6fd04cc16a7606633f57c96c11e58181ddb.

>From 026f442bd600bd50921bdcfe550b5ff4c376066e Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 6 Nov 2024 08:28:50 -0500
Subject: [PATCH 1/2] Revert "Reapply "[Clang][Sema] Always use latest
 redeclaration of primary template" (#114569)"

This reverts commit b24650e814e55d90acfc40acf045456c98f32b9c.
---
 clang/include/clang/AST/DeclTemplate.h| 52 +--
 clang/lib/AST/ASTImporter.cpp |  3 +-
 clang/lib/AST/Decl.cpp| 10 +--
 clang/lib/AST/DeclCXX.cpp |  4 +-
 clang/lib/AST/DeclTemplate.cpp| 56 +---
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaInit.cpp   |  2 +-
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 14 +--
 clang/test/AST/ast-dump-decl.cpp  |  2 +-
 .../Inputs/class-template-spec.cpp| 47 --
 .../ASTMerge/class-template-spec/test.cpp |  8 --
 .../CXX/temp/temp.spec/temp.expl.spec/p7.cpp  | 87 ---
 12 files changed, 67 insertions(+), 222 deletions(-)
 delete mode 100644 
clang/test/ASTMerge/class-template-spec/Inputs/class-template-spec.cpp
 delete mode 100644 clang/test/ASTMerge/class-template-spec/test.cpp

diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 0ca3fd48e81cf4..a572e3380f1655 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -857,6 +857,16 @@ class RedeclarableTemplateDecl : public TemplateDecl,
   /// \endcode
   bool isMemberSpecialization() const { return Common.getInt(); }
 
+  /// Determines whether any redeclaration of this template was
+  /// a specialization of a member template.
+  bool hasMemberSpecialization() const {
+for (const auto *D : redecls()) {
+  if (D->isMemberSpecialization())
+return true;
+}
+return false;
+  }
+
   /// Note that this member template is a specialization.
   void setMemberSpecialization() {
 assert(!isMemberSpecialization() && "already a member specialization");
@@ -1955,7 +1965,13 @@ class ClassTemplateSpecializationDecl : public 
CXXRecordDecl,
   /// specialization which was specialized by this.
   llvm::PointerUnion
-  getSpecializedTemplateOrPartial() const;
+  getSpecializedTemplateOrPartial() const {
+if (const auto *PartialSpec =
+SpecializedTemplate.dyn_cast())
+  return PartialSpec->PartialSpecialization;
+
+return SpecializedTemplate.get();
+  }
 
   /// Retrieve the set of template arguments that should be used
   /// to instantiate members of the class template or class template partial
@@ -2192,6 +2208,17 @@ class ClassTemplatePartialSpecializationDecl
 return InstantiatedFromMember.getInt();
   }
 
+  /// Determines whether any redeclaration of this this class template partial
+  /// specialization was a specialization of a member partial specialization.
+  bool hasMemberSpecialization() const {
+for (const auto *D : redecls()) {
+  if (cast(D)
+  ->isMemberSpecialization())
+return true;
+}
+return false;
+  }
+
   /// Note that this member template is a specialization.
   void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); 
}
 
@@ -2713,7 +2740,13 @@ class VarTemplateSpecializationDecl : public VarDecl,
   /// Retrieve the variable template or variable template partial
   /// specialization which was specialized by this.
   llvm::PointerUnion
-  getSpecializedTemplateOrPartial() const;
+  getSpecializedTemplateOrPartial() const {
+if (const auto *PartialSpec =
+SpecializedTemplate.dyn_cast())
+  return PartialSpec->PartialSpecialization;
+
+return SpecializedTemplate.get();
+  }
 
   /// Retrieve the set of template arguments that should be used
   /// to instantiate the initializer of the variable template or variable
@@ -2947,6 +2980,18 @@ class VarTemplatePartialSpecializationDecl
 return InstantiatedFromMember.getInt();
   }
 
+  /// Determines whether any redeclaration of this this variable template
+  /// partial specialization was a specialization of a member partial
+  /// specialization.
+  bool hasMemberSpecialization() const {
+for (const auto *D : redecls()) {
+  if (cast(D)
+  ->isMemberSpecialization())
+return true;
+}
+return false;
+  }
+
   /// Note that this member template is a specialization.
   void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); 
}
 
@@ -3119,9 +3164,6 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
 return makeSpecIterator(getSpecializations(), true);
   }
 
-  /// Merge \p Prev with our RedeclarableTemplateDecl::Common.
-  void mergePrevDecl(VarTemplateDecl *Prev);
-
   // Implement isa/cast/dyncast support
   static 

[clang] [clang][deps][modules] Allocate input file paths lazily (PR #114457)

2024-11-06 Thread Ben Langmuir via cfe-commits

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


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


[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

2024-11-06 Thread Saleem Abdulrasool via cfe-commits


@@ -730,7 +731,9 @@ class YAMLConverter {
 }
   }
 
-  void convertParams(const ParamsSeq &Params, FunctionInfo &OutInfo) {
+  std::optional convertParams(const ParamsSeq &Params,
+ FunctionInfo &OutInfo) {

compnerd wrote:

I suppose that is fine. I was suggesting that we keep the return type `void` 
and instead take an out parameter that is filled in. That would still keep the 
call site concise (IMO) and still make it easier to extend in the future (at 
least because there will be a design in place already which can be extended).

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


[clang] [llvm] [Clang] Match MSVC handling of duplicate header search paths in Microsoft compatibility modes. (PR #105738)

2024-11-06 Thread Tom Honermann via cfe-commits

tahonermann wrote:

Friendly ping for additional code review. @rnk, @nico, @zmodem, @majnemer, 
@zygoloid.

The Windows build is failing spuriously. I've rebased and force pushed multiple 
times to try to get a clean build, but it keeps failing during git checkout.

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


[clang] [HLSL] Add RasterizerOrderedStructuredBuffer definition to HLSLExternalSemaSource (PR #113648)

2024-11-06 Thread Joshua Batista via cfe-commits


@@ -5,17 +5,22 @@
 
 StructuredBuffer Buf : register(t10);
 RWStructuredBuffer Buf2 : register(u5, space1);
+RasterizerOrderedStructuredBuffer Buf5 : register(u1, space2);
 
 // CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", 
float, 0, 0), float }
 // CHECK: %"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", 
float, 1, 0), float }
+// CHECK: %"class.hlsl::RasterizerOrderedStructuredBuffer" = type { 
target("dx.RawBuffer", float, 1, 1), float }
 
 // CHECK: @Buf = global %"class.hlsl::StructuredBuffer" zeroinitializer, align 
4
 // CHECK: @Buf2 = global %"class.hlsl::RWStructuredBuffer" zeroinitializer, 
align 4
+// CHECK: @Buf5 = global %"class.hlsl::RasterizerOrderedStructuredBuffer" 
zeroinitializer, align 4

bob80905 wrote:

I see it's because of Append/Consume, which you'll add later.

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


[clang] [HLSL] Add RasterizerOrderedStructuredBuffer definition to HLSLExternalSemaSource (PR #113648)

2024-11-06 Thread Joshua Batista via cfe-commits

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


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


[clang] [Clang] Ensure default arguments in friend declarations are only allowed in defining declarations to prevent multiple reachable declarations (PR #113777)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -185,3 +185,27 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f1(ct, int = 0);   // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+  friend void f2(ct a, ct = decltype(a){ }); // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+};
+
+template
+class C {
+public:
+  friend void foo(T a = 1); // expected-error {{friend declaration specifying 
a default argument must be a definition}}
+};
+
+template
+void foo(T a) { } // expected-note {{candidate function template not viable: 
requires single argument 'a', but no arguments were provided}}
+
+void test() {
+  f1(ct<>{});
+  f2(ct<>{});
+
+  C c;
+  foo(); // expected-error {{no matching function for call to 'foo'}}

mizvekov wrote:

The test I had in mind was something like:
```C++
template using alias = int;

template struct C {
  friend void foo(C, int a = alias(1));
};

void test() {
  foo(C());
}
```

With your previous patch, we would be able to diagnose the instantiation 
failure here (forming reference to void), while the current version of the 
patch doesn't, since it skips instantiation of the default argument.

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


[clang] [PS5][Driver] Restore whole-archive state when `-fjmc` (PR #115181)

2024-11-06 Thread Edd Dawson via cfe-commits

https://github.com/playstation-edd updated 
https://github.com/llvm/llvm-project/pull/115181

>From c2eec3d06ad920ef2b7826fe9b76f1b45574e036 Mon Sep 17 00:00:00 2001
From: Edd Dawson 
Date: Wed, 6 Nov 2024 16:24:46 +
Subject: [PATCH 1/2] [PS5][Driver] Restore whole-archive state when `-fjmc`

`--whole-archive` is passed to the linker to have it consume all objects
within the SIE Just My Code library, rather than just those that fulfil
outstanding references.

Prior to this change, `--no-whole-archive` was used to reset the
associated archive handling state in the linker, under the assumption
that `--whole-archive` wasn't already in effect. But that assumption may
be incorrect. So use `--push/pop-state` to restore the previous state,
whatever that may be.

Given the position of these switches on the link line, the problem
described with the outgoing code is unlikely to cause an issue in
practice. But push/pop protect against accidents due to future additions
to and reorderings of arguments.

PS5 only. The proprietary PS4 linker doesn't support `--push/pop-state`,
or an equivalent.

SIE tracker: TOOLCHAIN-16704.
---
 clang/lib/Driver/ToolChains/PS4CPU.cpp | 3 ++-
 clang/test/Driver/ps5-linker.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 261c136de782e7..df43da93d77555 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -375,9 +375,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (UseJMC) {
+CmdArgs.push_back("--push-state");
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lSceJmc_nosubmission");
-CmdArgs.push_back("--no-whole-archive");
+CmdArgs.push_back("--pop-state");
   }
 
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 8a0ade91871295..fb5f8a9ec5cee5 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -95,7 +95,7 @@
 // CHECK: -plugin-opt=-enable-jmc-instrument
 
 // Check the default library name.
-// CHECK-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
+// CHECK-LIB: "--push-state" "--whole-archive" "-lSceJmc_nosubmission" 
"--pop-state"
 
 // Test the driver's control over the -fcrash-diagnostics-dir behavior with 
linker flags.
 

>From e8f465066edc9f7230f6751b94de90b71a2eb56a Mon Sep 17 00:00:00 2001
From: Edd Dawson 
Date: Wed, 6 Nov 2024 18:17:57 +
Subject: [PATCH 2/2] CHECK-LIB -> CHECK-JMC

---
 clang/test/Driver/ps5-linker.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index fb5f8a9ec5cee5..95267942edc172 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -89,13 +89,13 @@
 
 // Test the driver's control over the JustMyCode behavior with linker flags.
 
-// RUN: %clang --target=x86_64-sie-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-LIB %s
-// RUN: %clang --target=x86_64-sie-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-LIB %s
+// RUN: %clang --target=x86_64-sie-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-JMC %s
+// RUN: %clang --target=x86_64-sie-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-JMC %s
 
 // CHECK: -plugin-opt=-enable-jmc-instrument
 
 // Check the default library name.
-// CHECK-LIB: "--push-state" "--whole-archive" "-lSceJmc_nosubmission" 
"--pop-state"
+// CHECK-JMC: "--push-state" "--whole-archive" "-lSceJmc_nosubmission" 
"--pop-state"
 
 // Test the driver's control over the -fcrash-diagnostics-dir behavior with 
linker flags.
 

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


[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Shilei Tian (shiltian)


Changes



---

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


33 Files Affected:

- (modified) clang/include/clang/Basic/Cuda.h (+1) 
- (modified) clang/lib/Basic/Cuda.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-features.cl (+3) 
- (modified) clang/test/Driver/amdgpu-macros.cl (+1) 
- (modified) clang/test/Driver/amdgpu-mcpu.cl (+2) 
- (modified) clang/test/Misc/target-invalid-cpu-note/amdgcn.c (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note/nvptx.c (+1) 
- (modified) llvm/docs/AMDGPUUsage.rst (+5) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+2-1) 
- (modified) llvm/include/llvm/TargetParser/TargetParser.h (+2-1) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+2) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+4) 
- (modified) llvm/lib/Target/AMDGPU/GCNProcessors.td (+5) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+5) 
- (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h (+1) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+5) 
- (modified) llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll (+4) 
- (modified) llvm/test/CodeGen/AMDGPU/div-rem-by-constant-64.ll (+443) 
- (modified) llvm/test/CodeGen/AMDGPU/dst-sel-hazard.mir (+1) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/generic-targets-require-v6.ll (+3) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.iglp.opt.exp.large.mir 
(+1144) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.iglp.opt.exp.small.mir (+496) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx940.ll (+4) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.update.dpp.gfx90a.ll (+1) 
- (modified) llvm/test/CodeGen/AMDGPU/no-corresponding-integer-type.ll (+1) 
- (modified) llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml (+7) 
- (modified) llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll (+6) 
- (modified) llvm/test/tools/llvm-readobj/ELF/AMDGPU/elf-headers.test (+3) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 


``diff
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 7b4f435dc39f29..721e8981af6ffc 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -103,6 +103,7 @@ enum class OffloadArch {
   GFX909,
   GFX90a,
   GFX90c,
+  GFX9_4_GENERIC,
   GFX940,
   GFX941,
   GFX942,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index d765baef913e2f..59c932468cd891 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -121,6 +121,7 @@ static const OffloadArchToStringMap arch_names[] = {
 GFX(909),  // gfx909
 GFX(90a),  // gfx90a
 GFX(90c),  // gfx90c
+{OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
 GFX(940),  // gfx940
 GFX(941),  // gfx941
 GFX(942),  // gfx942
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index e0bd0b096324d8..0897032c4b8546 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -205,6 +205,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::GFX909:
   case OffloadArch::GFX90a:
   case OffloadArch::GFX90c:
+  case OffloadArch::GFX9_4_GENERIC:
   case OffloadArch::GFX940:
   case OffloadArch::GFX941:
   case OffloadArch::GFX942:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 598b946ad88dbb..43dc0e62284602 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2301,6 +2301,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::GFX909:
   case OffloadArch::GFX90a:
   case OffloadArch::GFX90c:
+  case OffloadArch::GFX9_4_GENERIC:
   case OffloadArch::GFX940:
   case OffloadArch::GFX941:
   case OffloadArch::GFX942:
diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index f3473346baae5a..692f5103724342 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -56,6 +56,8 @@
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature 
+wavefrontsize64 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103-W64 %s
 
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx9-4-generic -emit-llvm -o - 
%s | FileCheck --check-prefix=GFX9_4_Generic %s
+
 // NOCPU-NOT: "target-features"
 // NOCPU-WAVE32: "target-features"="+wavefrontsize32"
 // NOCPU-WAVE64: "target-features"="+wavefrontsize64"
@@ -85,6 +87,7 @@

[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Shilei Tian (shiltian)


Changes



---

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


33 Files Affected:

- (modified) clang/include/clang/Basic/Cuda.h (+1) 
- (modified) clang/lib/Basic/Cuda.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-features.cl (+3) 
- (modified) clang/test/Driver/amdgpu-macros.cl (+1) 
- (modified) clang/test/Driver/amdgpu-mcpu.cl (+2) 
- (modified) clang/test/Misc/target-invalid-cpu-note/amdgcn.c (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note/nvptx.c (+1) 
- (modified) llvm/docs/AMDGPUUsage.rst (+5) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+2-1) 
- (modified) llvm/include/llvm/TargetParser/TargetParser.h (+2-1) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+2) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+4) 
- (modified) llvm/lib/Target/AMDGPU/GCNProcessors.td (+5) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+5) 
- (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h (+1) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+5) 
- (modified) llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll (+4) 
- (modified) llvm/test/CodeGen/AMDGPU/div-rem-by-constant-64.ll (+443) 
- (modified) llvm/test/CodeGen/AMDGPU/dst-sel-hazard.mir (+1) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/generic-targets-require-v6.ll (+3) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.iglp.opt.exp.large.mir 
(+1144) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.iglp.opt.exp.small.mir (+496) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx940.ll (+4) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.update.dpp.gfx90a.ll (+1) 
- (modified) llvm/test/CodeGen/AMDGPU/no-corresponding-integer-type.ll (+1) 
- (modified) llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml (+7) 
- (modified) llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll (+6) 
- (modified) llvm/test/tools/llvm-readobj/ELF/AMDGPU/elf-headers.test (+3) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 


``diff
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 7b4f435dc39f29..721e8981af6ffc 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -103,6 +103,7 @@ enum class OffloadArch {
   GFX909,
   GFX90a,
   GFX90c,
+  GFX9_4_GENERIC,
   GFX940,
   GFX941,
   GFX942,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index d765baef913e2f..59c932468cd891 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -121,6 +121,7 @@ static const OffloadArchToStringMap arch_names[] = {
 GFX(909),  // gfx909
 GFX(90a),  // gfx90a
 GFX(90c),  // gfx90c
+{OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
 GFX(940),  // gfx940
 GFX(941),  // gfx941
 GFX(942),  // gfx942
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index e0bd0b096324d8..0897032c4b8546 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -205,6 +205,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::GFX909:
   case OffloadArch::GFX90a:
   case OffloadArch::GFX90c:
+  case OffloadArch::GFX9_4_GENERIC:
   case OffloadArch::GFX940:
   case OffloadArch::GFX941:
   case OffloadArch::GFX942:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 598b946ad88dbb..43dc0e62284602 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2301,6 +2301,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::GFX909:
   case OffloadArch::GFX90a:
   case OffloadArch::GFX90c:
+  case OffloadArch::GFX9_4_GENERIC:
   case OffloadArch::GFX940:
   case OffloadArch::GFX941:
   case OffloadArch::GFX942:
diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index f3473346baae5a..692f5103724342 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -56,6 +56,8 @@
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature 
+wavefrontsize64 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103-W64 %s
 
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx9-4-generic -emit-llvm -o - 
%s | FileCheck --check-prefix=GFX9_4_Generic %s
+
 // NOCPU-NOT: "target-features"
 // NOCPU-WAVE32: "target-features"="+wavefrontsize32"
 // NOCPU-WAVE64: "target-features"="+wavefrontsize64"
@@ -85,6 +87,7 

[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-binary-utilities

Author: Shilei Tian (shiltian)


Changes



---

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


33 Files Affected:

- (modified) clang/include/clang/Basic/Cuda.h (+1) 
- (modified) clang/lib/Basic/Cuda.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-features.cl (+3) 
- (modified) clang/test/Driver/amdgpu-macros.cl (+1) 
- (modified) clang/test/Driver/amdgpu-mcpu.cl (+2) 
- (modified) clang/test/Misc/target-invalid-cpu-note/amdgcn.c (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note/nvptx.c (+1) 
- (modified) llvm/docs/AMDGPUUsage.rst (+5) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+2-1) 
- (modified) llvm/include/llvm/TargetParser/TargetParser.h (+2-1) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+2) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+4) 
- (modified) llvm/lib/Target/AMDGPU/GCNProcessors.td (+5) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+5) 
- (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h (+1) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+5) 
- (modified) llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll (+4) 
- (modified) llvm/test/CodeGen/AMDGPU/div-rem-by-constant-64.ll (+443) 
- (modified) llvm/test/CodeGen/AMDGPU/dst-sel-hazard.mir (+1) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/generic-targets-require-v6.ll (+3) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.iglp.opt.exp.large.mir 
(+1144) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.iglp.opt.exp.small.mir (+496) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx940.ll (+4) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.update.dpp.gfx90a.ll (+1) 
- (modified) llvm/test/CodeGen/AMDGPU/no-corresponding-integer-type.ll (+1) 
- (modified) llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml (+7) 
- (modified) llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll (+6) 
- (modified) llvm/test/tools/llvm-readobj/ELF/AMDGPU/elf-headers.test (+3) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 


``diff
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 7b4f435dc39f29..721e8981af6ffc 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -103,6 +103,7 @@ enum class OffloadArch {
   GFX909,
   GFX90a,
   GFX90c,
+  GFX9_4_GENERIC,
   GFX940,
   GFX941,
   GFX942,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index d765baef913e2f..59c932468cd891 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -121,6 +121,7 @@ static const OffloadArchToStringMap arch_names[] = {
 GFX(909),  // gfx909
 GFX(90a),  // gfx90a
 GFX(90c),  // gfx90c
+{OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
 GFX(940),  // gfx940
 GFX(941),  // gfx941
 GFX(942),  // gfx942
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index e0bd0b096324d8..0897032c4b8546 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -205,6 +205,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::GFX909:
   case OffloadArch::GFX90a:
   case OffloadArch::GFX90c:
+  case OffloadArch::GFX9_4_GENERIC:
   case OffloadArch::GFX940:
   case OffloadArch::GFX941:
   case OffloadArch::GFX942:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 598b946ad88dbb..43dc0e62284602 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2301,6 +2301,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::GFX909:
   case OffloadArch::GFX90a:
   case OffloadArch::GFX90c:
+  case OffloadArch::GFX9_4_GENERIC:
   case OffloadArch::GFX940:
   case OffloadArch::GFX941:
   case OffloadArch::GFX942:
diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index f3473346baae5a..692f5103724342 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -56,6 +56,8 @@
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature 
+wavefrontsize64 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103-W64 %s
 
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx9-4-generic -emit-llvm -o - 
%s | FileCheck --check-prefix=GFX9_4_Generic %s
+
 // NOCPU-NOT: "target-features"
 // NOCPU-WAVE32: "target-features"="+wavefrontsize32"
 // NOCPU-WAVE64: "target-features"="+wavefrontsize64"
@@ -85,6

[clang] [PS5][Driver] Restore whole-archive state when `-fjmc` (PR #115181)

2024-11-06 Thread Edd Dawson via cfe-commits

playstation-edd wrote:

> LGTM, although maybe CHECK_JMC instead of CHECK_LIB as it seems very JMC 
> specific? No strong opinion.

Done - thanks.

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


[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread Shilei Tian via cfe-commits

shiltian wrote:

* **#115190** https://app.graphite.dev/github/pr/llvm/llvm-project/115190?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈
* `main`

This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about 
stacking.


 Join @shiltian and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="11px" height="11px"/> Graphite
  

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


[clang] 38cc03f - [PS5][Driver] Restore whole-archive state when `-fjmc` (#115181)

2024-11-06 Thread via cfe-commits

Author: Edd Dawson
Date: 2024-11-06T18:20:09Z
New Revision: 38cc03f78e3046837d8fc29d729bc2cee0c31e89

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

LOG: [PS5][Driver] Restore whole-archive state when `-fjmc` (#115181)

`--whole-archive` is passed to the linker to have it consume all objects
within the SIE Just My Code library, rather than just those that fulfil
outstanding references.

Prior to this change, `--no-whole-archive` was used to reset the
associated archive handling state in the linker, under the assumption
that `--whole-archive` wasn't already in effect. But that assumption may
be incorrect. So use `--push/pop-state` to restore the previous state,
whatever that may be.

Given the position of these switches on the link line, the problem
described with the outgoing code is unlikely to cause an issue in
practice. But push/pop protect against accidents due to future additions
to and reorderings of arguments.

PS5 only. The proprietary PS4 linker doesn't support `--push/pop-state`,
or an equivalent.

SIE tracker: TOOLCHAIN-16704.

Added: 


Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/ps5-linker.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 261c136de782e7..df43da93d77555 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -375,9 +375,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (UseJMC) {
+CmdArgs.push_back("--push-state");
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lSceJmc_nosubmission");
-CmdArgs.push_back("--no-whole-archive");
+CmdArgs.push_back("--pop-state");
   }
 
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {

diff  --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 8a0ade91871295..95267942edc172 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -89,13 +89,13 @@
 
 // Test the driver's control over the JustMyCode behavior with linker flags.
 
-// RUN: %clang --target=x86_64-sie-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-LIB %s
-// RUN: %clang --target=x86_64-sie-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-LIB %s
+// RUN: %clang --target=x86_64-sie-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-JMC %s
+// RUN: %clang --target=x86_64-sie-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK,CHECK-JMC %s
 
 // CHECK: -plugin-opt=-enable-jmc-instrument
 
 // Check the default library name.
-// CHECK-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
+// CHECK-JMC: "--push-state" "--whole-archive" "-lSceJmc_nosubmission" 
"--pop-state"
 
 // Test the driver's control over the -fcrash-diagnostics-dir behavior with 
linker flags.
 



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


[clang] [PS5][Driver] Restore whole-archive state when `-fjmc` (PR #115181)

2024-11-06 Thread Edd Dawson via cfe-commits

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


[clang] 304c412 - [clang][serialization] Reduce `ASTWriter::writeUnhashedControlBlock()` scope

2024-11-06 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2024-11-06T12:54:01-08:00
New Revision: 304c41217303ce613de8f4042e570ac6ca8757e8

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

LOG: [clang][serialization] Reduce `ASTWriter::writeUnhashedControlBlock()` 
scope

Added: 


Modified: 
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 83684443ca948e..d0e841f367c1e0 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -551,7 +551,7 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
 
   /// Write out the signature and diagnostic options, and return the signature.
-  void writeUnhashedControlBlock(Preprocessor &PP, ASTContext &Context);
+  void writeUnhashedControlBlock(Preprocessor &PP);
   ASTFileSignature backpatchSignature();
 
   /// Calculate hash of the pcm content.

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 13ee9904b29fd3..b95e29cbc02515 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1269,8 +1269,7 @@ ASTFileSignature ASTWriter::backpatchSignature() {
   return Signature;
 }
 
-void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
-  ASTContext &Context) {
+void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP) {
   using namespace llvm;
 
   // Flush first to prepare the PCM hash (signature).
@@ -1323,7 +1322,7 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor 
&PP,
   const auto &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
 
   // Diagnostic options.
-  const auto &Diags = Context.getDiagnostics();
+  const auto &Diags = PP.getDiagnostics();
   const DiagnosticOptions &DiagOpts = Diags.getDiagnosticOptions();
   if (!HSOpts.ModulesSkipDiagnosticOptions) {
 #define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
@@ -5368,7 +5367,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, 
StringRef isysroot,
   // SourceLocations or FileIDs depends on it.
   computeNonAffectingInputFiles();
 
-  writeUnhashedControlBlock(PP, Context);
+  writeUnhashedControlBlock(PP);
 
   // Don't reuse type ID and Identifier ID from readers for C++ standard named
   // modules since we want to support no-transitive-change model for named



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


[clang] bcb64e1 - [clang][serialization] Reduce `ASTWriter::WriteSourceManagerBlock()` scope

2024-11-06 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2024-11-06T12:34:24-08:00
New Revision: bcb64e13172c9b894be03ccefcf967e99949b32a

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

LOG: [clang][serialization] Reduce `ASTWriter::WriteSourceManagerBlock()` scope

Added: 


Modified: 
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 198dd01b8d07a0..918a9a635185b2 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -560,8 +560,7 @@ class ASTWriter : public ASTDeserializationListener,
   ASTFileSignature createSignatureForNamedModule() const;
 
   void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts);
-  void WriteSourceManagerBlock(SourceManager &SourceMgr,
-   const Preprocessor &PP);
+  void WriteSourceManagerBlock(SourceManager &SourceMgr);
   void WritePreprocessor(const Preprocessor &PP, bool IsModule);
   void WriteHeaderSearch(const HeaderSearch &HS);
   void WritePreprocessorDetail(PreprocessingRecord &PPRec,

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 3b174cb539ebdb..0c244e73b30895 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2234,8 +2234,7 @@ static void emitBlob(llvm::BitstreamWriter &Stream, 
StringRef Blob,
 /// entries for files that we actually need. In the common case (no
 /// errors), we probably won't have to create file entries for any of
 /// the files in the AST.
-void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
-const Preprocessor &PP) {
+void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
   RecordData Record;
 
   // Enter the source manager block.
@@ -2323,8 +2322,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager 
&SourceMgr,
 // We add one to the size so that we capture the trailing NULL
 // that is required by llvm::MemoryBuffer::getMemBuffer (on
 // the reader side).
-std::optional Buffer =
-Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
+std::optional Buffer = Content->getBufferOrNone(
+SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
 StringRef Name = Buffer ? Buffer->getBufferIdentifier() : "";
 Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
   StringRef(Name.data(), Name.size() + 1));
@@ -2334,8 +2333,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager 
&SourceMgr,
   if (EmitBlob) {
 // Include the implicit terminating null character in the on-disk 
buffer
 // if we're writing it uncompressed.
-std::optional Buffer =
-Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
+std::optional Buffer = Content->getBufferOrNone(
+SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
 if (!Buffer)
   Buffer = llvm::MemoryBufferRef("<<>>", "");
 StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
@@ -5526,7 +5525,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, 
StringRef isysroot,
   WriteDeclAndTypes(Context);
 
   WriteFileDeclIDsMap();
-  WriteSourceManagerBlock(Context.getSourceManager(), PP);
+  WriteSourceManagerBlock(PP.getSourceManager());
   WriteComments();
   WritePreprocessor(PP, isModule);
   WriteHeaderSearch(PP.getHeaderSearchInfo());



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


[clang] [flang] [clang][Driver] Add the ability to specify that RPATH should be added by default (PR #115163)

2024-11-06 Thread David Truby via cfe-commits

DavidTruby wrote:

For what it’s worth, as a user I’m always surprised that this _isn’t_ the 
default. It’s quite annoying to eg have to set LD_LIBRARY_PATH when using 
openmp with clang when they’re built alongside each other. Is there a specific 
reason this isn’t the default or is it just historical?

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


[clang] 0276621 - [clang][serialization] Reduce `ASTWriter::WriteControlBlock()` scope

2024-11-06 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2024-11-06T12:36:46-08:00
New Revision: 0276621f8f5ae489fbe9343cb4cca07579a244a4

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

LOG: [clang][serialization] Reduce `ASTWriter::WriteControlBlock()` scope

Added: 


Modified: 
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 918a9a635185b2..83684443ca948e 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -548,8 +548,7 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteSubStmt(Stmt *S);
 
   void WriteBlockInfoBlock();
-  void WriteControlBlock(Preprocessor &PP, ASTContext &Context,
- StringRef isysroot);
+  void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
 
   /// Write out the signature and diagnostic options, and return the signature.
   void writeUnhashedControlBlock(Preprocessor &PP, ASTContext &Context);

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 0c244e73b30895..13ee9904b29fd3 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1403,10 +1403,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor 
&PP,
 }
 
 /// Write the control block.
-void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
-  StringRef isysroot) {
+void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
   using namespace llvm;
 
+  SourceManager &SourceMgr = PP.getSourceManager();
+  FileManager &FileMgr = PP.getFileManager();
+
   Stream.EnterSubblock(CONTROL_BLOCK_ID, 5);
   RecordData Record;
 
@@ -1454,14 +1456,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, 
ASTContext &Context,
 SmallString<128> BaseDir;
 if (PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) {
   // Use the current working directory as the base path for all inputs.
-  auto CWD =
-  Context.getSourceManager().getFileManager().getOptionalDirectoryRef(
-  ".");
+  auto CWD = FileMgr.getOptionalDirectoryRef(".");
   BaseDir.assign(CWD->getName());
 } else {
   BaseDir.assign(WritingModule->Directory->getName());
 }
-cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
+cleanPathForOutput(FileMgr, BaseDir);
 
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
@@ -1554,7 +1554,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, 
ASTContext &Context,
 
   // Language options.
   Record.clear();
-  const LangOptions &LangOpts = Context.getLangOpts();
+  const LangOptions &LangOpts = PP.getLangOpts();
 #define LANGOPT(Name, Bits, Default, Description) \
   Record.push_back(LangOpts.Name);
 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
@@ -1591,7 +1591,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, 
ASTContext &Context,
 
   // Target options.
   Record.clear();
-  const TargetInfo &Target = Context.getTargetInfo();
+  const TargetInfo &Target = PP.getTargetInfo();
   const TargetOptions &TargetOpts = Target.getTargetOpts();
   AddString(TargetOpts.Triple, Record);
   AddString(TargetOpts.CPU, Record);
@@ -1609,8 +1609,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, 
ASTContext &Context,
 
   // File system options.
   Record.clear();
-  const FileSystemOptions &FSOpts =
-  Context.getSourceManager().getFileManager().getFileSystemOpts();
+  const FileSystemOptions &FSOpts = FileMgr.getFileSystemOpts();
   AddString(FSOpts.WorkingDir, Record);
   Stream.EmitRecord(FILE_SYSTEM_OPTIONS, Record);
 
@@ -1675,8 +1674,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, 
ASTContext &Context,
   Stream.ExitBlock();
 
   // Original file name and file ID
-  SourceManager &SM = Context.getSourceManager();
-  if (auto MainFile = SM.getFileEntryRefForID(SM.getMainFileID())) {
+  if (auto MainFile =
+  SourceMgr.getFileEntryRefForID(SourceMgr.getMainFileID())) {
 auto FileAbbrev = std::make_shared();
 FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
@@ -1685,16 +1684,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, 
ASTContext &Context,
 
 Record.clear();
 Record.push_back(ORIGINAL_FILE);
-AddFileID(SM.getMainFileID(), Record);
+AddFileID(SourceMgr.getMainFileID(), Record);
 EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
   }
 

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

2024-11-06 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang` at step 7 
"test-build-unified-tree-check-all".

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: 
CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -std=c++20 -fsyntax-only -verify 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -std=c++20 -fsyntax-only -verify 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp
 Line 73: static assertion failed due to requirement 'A::B::y == 4'
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp
 Line 77: static assertion failed due to requirement 'A::x == 4'
error: 'expected-note' diagnostics seen but not expected: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp
 Line 73: expression evaluates to '3 == 4'
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CXX/temp/temp.decls/temp.spec.partial/temp.spec.partial.member/p2.cpp
 Line 77: expression evaluates to '3 == 4'
4 errors generated.

--




```



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


[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread Shilei Tian via cfe-commits

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


[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread Shilei Tian via cfe-commits


@@ -1468,15 +1471,36 @@ def FeatureISAVersion9_4_Common : FeatureSet<
 
 def FeatureISAVersion9_4_0 : FeatureSet<
   !listconcat(FeatureISAVersion9_4_Common.Features,
-[FeatureForceStoreSC0SC1])>;
+[
+  FeatureForceStoreSC0SC1,
+  FeatureFP8Insts,
+  FeatureFP8ConversionInsts,
+  FeatureCvtFP8VOP1Bug,
+  FeatureXF32Insts
+])>;
 
 def FeatureISAVersion9_4_1 : FeatureSet<
   !listconcat(FeatureISAVersion9_4_Common.Features,
-[FeatureForceStoreSC0SC1])>;
+[

shiltian wrote:

I'll move these changes to another PR(s) to make this one cleaner.

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


[clang] [NFC][Clang] Refactor ClangDiagnosticEmitter to use more StringRef (PR #115212)

2024-11-06 Thread Rahul Joshi via cfe-commits

https://github.com/jurahul created 
https://github.com/llvm/llvm-project/pull/115212

Refactor ClangDiagnosticEmitter to use more StringRefs. Also use more range for 
loops.

Verified that .inc files generated by clang build are identical with and 
without the change.

>From b6c2a0777313c3f378c4bc4915a550c532c4d6c6 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Wed, 6 Nov 2024 11:22:55 -0800
Subject: [PATCH] [Clang] Refactor ClangDiagnosticEmitter to use more StringRef

Refactor ClangDiagnosticEmitter to use more StringRefs. Also use
more range for loops.

Verified that .inc files generated by clang build are identical
with and without the change.
---
 .../TableGen/ClangDiagnosticsEmitter.cpp  | 294 +++---
 1 file changed, 115 insertions(+), 179 deletions(-)

diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 34e2e8f47ae71a..3892c622fc916a 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -18,6 +18,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Casting.h"
@@ -44,35 +45,28 @@ class DiagGroupParentMap {
 
 public:
   DiagGroupParentMap(const RecordKeeper &records) : Records(records) {
-ArrayRef DiagGroups =
-Records.getAllDerivedDefinitions("DiagGroup");
-for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) {
-  std::vector SubGroups =
-  DiagGroups[i]->getValueAsListOfDefs("SubGroups");
-  for (unsigned j = 0, e = SubGroups.size(); j != e; ++j)
-Mapping[SubGroups[j]].push_back(DiagGroups[i]);
-}
+for (const Record *Group : Records.getAllDerivedDefinitions("DiagGroup"))
+  for (const Record *SubGroup : Group->getValueAsListOfDefs("SubGroups"))
+Mapping[SubGroup].push_back(Group);
   }
 
-  const std::vector &getParents(const Record *Group) {
-return Mapping[Group];
+  ArrayRef getParents(const Record *SubGroup) {
+return Mapping[SubGroup];
   }
 };
 } // end anonymous namespace.
 
-static std::string
+static StringRef
 getCategoryFromDiagGroup(const Record *Group,
  DiagGroupParentMap &DiagGroupParents) {
   // If the DiagGroup has a category, return it.
-  std::string CatName = std::string(Group->getValueAsString("CategoryName"));
+  StringRef CatName = Group->getValueAsString("CategoryName");
   if (!CatName.empty()) return CatName;
 
   // The diag group may the subgroup of one or more other diagnostic groups,
   // check these for a category as well.
-  const std::vector &Parents =
-  DiagGroupParents.getParents(Group);
-  for (unsigned i = 0, e = Parents.size(); i != e; ++i) {
-CatName = getCategoryFromDiagGroup(Parents[i], DiagGroupParents);
+  for (const Record *Parent : DiagGroupParents.getParents(Group)) {
+CatName = getCategoryFromDiagGroup(Parent, DiagGroupParents);
 if (!CatName.empty()) return CatName;
   }
   return "";
@@ -80,25 +74,26 @@ getCategoryFromDiagGroup(const Record *Group,
 
 /// getDiagnosticCategory - Return the category that the specified diagnostic
 /// lives in.
-static std::string getDiagnosticCategory(const Record *R,
- DiagGroupParentMap &DiagGroupParents) 
{
+static StringRef getDiagnosticCategory(const Record *R,
+   DiagGroupParentMap &DiagGroupParents) {
   // If the diagnostic is in a group, and that group has a category, use it.
   if (const auto *Group = dyn_cast(R->getValueInit("Group"))) {
 // Check the diagnostic's diag group for a category.
-std::string CatName = getCategoryFromDiagGroup(Group->getDef(),
-   DiagGroupParents);
+StringRef CatName =
+getCategoryFromDiagGroup(Group->getDef(), DiagGroupParents);
 if (!CatName.empty()) return CatName;
   }
 
   // If the diagnostic itself has a category, get it.
-  return std::string(R->getValueAsString("CategoryName"));
+  return R->getValueAsString("CategoryName");
 }
 
 namespace {
   class DiagCategoryIDMap {
 const RecordKeeper &Records;
 StringMap CategoryIDs;
-std::vector CategoryStrings;
+std::vector CategoryStrings;
+
   public:
 DiagCategoryIDMap(const RecordKeeper &records) : Records(records) {
   DiagGroupParentMap ParentInfo(Records);
@@ -107,10 +102,9 @@ namespace {
   CategoryStrings.push_back("");
   CategoryIDs[""] = 0;
 
-  ArrayRef Diags =
-  Records.getAllDerivedDefinitions("Diagnostic");
-  for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
-std::string Category = getDiagnosticCategory(Diags[i], ParentInfo);
+  for (const Record *Diag :
+   Records.getAllDerivedDefinitions("Diagnostic")) {
+StringRef Category = getDiagnosticCatego

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-06 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

> we're not (fully) understanding the content

My thinking was that we don't even need to understand the content, we simply 
exclude code that is contained within any of the problematic public macros. 
This sounds like it should be possible to do? Unfortunately I don't know the 
details on how this could be implemented, hopefully other reviewers know better?

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


[libclc] [libclc] Move relational functions to the CLC library (PR #115171)

2024-11-06 Thread Fraser Cormack via cfe-commits

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


[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-11-06 Thread Joshua Batista via cfe-commits


@@ -323,30 +324,127 @@ struct TemplateParameterListBuilder {
 S.Context, Builder.Record->getDeclContext(), SourceLocation(),
 SourceLocation(), /* TemplateDepth */ 0, Position,
 &S.Context.Idents.get(Name, tok::TokenKind::identifier),
-/* Typename */ false,
-/* ParameterPack */ false);
+/* Typename */ true,
+/* ParameterPack */ false,
+/* HasTypeConstraint*/ false);
 if (!DefaultValue.isNull())
   Decl->setDefaultArgument(
   S.Context, S.getTrivialTemplateArgumentLoc(DefaultValue, QualType(),
  SourceLocation()));
-
 Params.emplace_back(Decl);
 return *this;
   }
 
-  BuiltinTypeDeclBuilder &finalizeTemplateArgs() {
+  /*
+  The concept specialization expression (CSE) constructed below is constructed
+  so that it matches the CSE that is constructed when parsing
+  the below C++ code:
+
+  template
+  concept is_valid_line_vector =sizeof(T) <= 16;
+
+  template requires is_valid_line_vector
+
+  struct RWBuffer {
+  element_type Val;
+  };
+
+  int fn() {
+  RWBuffer Buf;
+  }
+
+  When dumping the AST and filtering for "RWBuffer", the resulting AST
+  structure is what we're trying to construct below, specifically the
+  CSE portion.
+  */
+  ConceptSpecializationExpr *
+  constructConceptSpecializationExpr(Sema &S, ConceptDecl *CD) {
+ASTContext &Context = S.getASTContext();
+SourceLocation Loc = Builder.Record->getBeginLoc();
+DeclarationNameInfo DNI(CD->getDeclName(), Loc);
+NestedNameSpecifierLoc NNSLoc;
+DeclContext *DC = Builder.Record->getDeclContext();
+TemplateArgumentListInfo TALI(Loc, Loc);
+
+// Assume that the concept decl has just one template parameter
+// This parameter should have been added when CD was constructed
+// in getTypedBufferConceptDecl
+assert(CD->getTemplateParameters()->size() == 1 &&
+   "unexpected concept decl parameter count");
+TemplateTypeParmDecl *ConceptTTPD = dyn_cast(
+CD->getTemplateParameters()->getParam(0));
+
+// this fake TemplateTypeParmDecl is used to construct a template argument
+// that will be used to construct the ImplicitConceptSpecializationDecl
+TemplateTypeParmDecl *T = TemplateTypeParmDecl::Create(
+Context,  // AST context
+Context.getTranslationUnitDecl(), // DeclContext
+SourceLocation(), SourceLocation(),
+/*depth=*/0,// Depth in the template parameter list
+/*position=*/0, // Position in the template parameter list
+/*id=*/nullptr, // Identifier for 'T'
+/*Typename=*/true,  // Indicates this is a 'typename' or 
'class'
+/*ParameterPack=*/false,// Not a parameter pack
+/*HasTypeConstraint=*/false // Has no type constraint
+);
+
+T->setDeclContext(DC);
+T->setReferenced();

bob80905 wrote:

Setting the decl context is necessary because it puts the decl into the right 
indentation in the AST dump. Otherwise, I believe the decl would be placed at 
the same scope as one indentation below the translation unit decl, which is not 
where the decl belongs.
I'll see if I can get away with removing setReferenced here.

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


[clang] WIP: [clang] MicrosoftCXXABI: Fix exception copy constructor LUT after loading AST (PR #114075)

2024-11-06 Thread Andrey Glebov via cfe-commits

glebov-andrey wrote:

Tagging @rnk because this has to do with the MS ABI

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


[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread Shilei Tian via cfe-commits

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


[clang] [llvm] [AMDGPU] Introduce a new generic target `gfx9-4-generic` (PR #115190)

2024-11-06 Thread Shilei Tian via cfe-commits


@@ -1468,15 +1471,36 @@ def FeatureISAVersion9_4_Common : FeatureSet<
 
 def FeatureISAVersion9_4_0 : FeatureSet<
   !listconcat(FeatureISAVersion9_4_Common.Features,
-[FeatureForceStoreSC0SC1])>;
+[
+  FeatureForceStoreSC0SC1,
+  FeatureFP8Insts,

shiltian wrote:

IIUC, we don't use `FeatureFP8Insts` anywhere else. We don't guard anything 
with `HasFP8Insts`. Not sure if that is there just for conventions.

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


[clang] [Clang] Fix name lookup for dependent bases (PR #114978)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -265,8 +268,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 BaseRecord = nullptr;
 }
   } else {
-BaseRecord = cast(
-BaseSpec.getType()->castAs()->getDecl());
+if (auto *RT = BaseSpec.getType()->getAs())
+  BaseRecord = cast(RT->getDecl());

mizvekov wrote:

This should be equivalent to:
```suggestion
BaseRecord = BaseSpec.getType()->getAsRecordDecl();
```

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


[clang] [Clang] Fix name lookup for dependent bases (PR #114978)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -169,14 +169,18 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 // Find the record of the base class subobjects for this type.
 QualType BaseType =
 Context.getCanonicalType(BaseSpec.getType()).getUnqualifiedType();
+bool isCurrentInstantiation = false;
+if (auto *TST = BaseSpec.getType()->getAs())
+  isCurrentInstantiation = TST->isCurrentInstantiation();

mizvekov wrote:

This relies on a TemplateSpecializationType which is a type sugar to make this 
determination, and type sugar could be lost, for example with template 
instantiation.

Might be worth double checking and adding a test case where the base type is 
formed from instantiation.

This test would be equivalent to checking if the type is canonically an 
InjectedClassNameType:
```suggestion
bool isCurrentInstantiation = isa(BaseType);
```
This is reliable as it only depends on the canonical type.

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


[clang] [Clang] add wraps and no_wraps attributes (PR #115094)

2024-11-06 Thread Justin Stitt via cfe-commits

https://github.com/JustinStitt updated 
https://github.com/llvm/llvm-project/pull/115094

>From f58e6481650f8cda6089b2a0637c94596a45370e Mon Sep 17 00:00:00 2001
From: Justin Stitt 
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/5] add wraps, no_wraps attributes

---
 clang/docs/ReleaseNotes.rst   |  20 
 clang/docs/SanitizerSpecialCaseList.rst   |   2 +
 clang/include/clang/AST/Expr.h|   6 ++
 clang/include/clang/AST/Type.h|   3 +
 clang/include/clang/Basic/Attr.td |  15 +++
 clang/include/clang/Basic/AttrDocs.td | 100 ++
 clang/include/clang/Basic/DiagnosticGroups.td |   6 ++
 .../clang/Basic/DiagnosticSemaKinds.td|   7 ++
 clang/lib/AST/Expr.cpp|  20 
 clang/lib/AST/ExprConstant.cpp|   4 +-
 clang/lib/AST/Type.cpp|   9 ++
 clang/lib/AST/TypePrinter.cpp |   6 ++
 clang/lib/CodeGen/CGExprScalar.cpp|  48 ++---
 clang/lib/Sema/Sema.cpp   |   3 +
 clang/lib/Sema/SemaChecking.cpp   |  35 +-
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  16 ++-
 clang/lib/Sema/SemaType.cpp   |  25 +
 clang/test/CodeGen/integer-overflow.c |  66 
 clang/test/CodeGen/unsigned-overflow.c|  63 +--
 clang/test/CodeGen/wraps-attribute-scl.test   |  78 ++
 ...a-attribute-supported-attributes-list.test |   2 +
 clang/test/Sema/attr-wraps.c  |  48 +
 23 files changed, 556 insertions(+), 28 deletions(-)
 create mode 100644 clang/test/CodeGen/wraps-attribute-scl.test
 create mode 100644 clang/test/Sema/attr-wraps.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dc45202f6b2e86..5457d802d820f3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -386,6 +386,26 @@ Attribute Changes in Clang
 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
   ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
 
+- Introduced ``__attribute__((wraps))`` which can be added to type or variable
+  declarations. Using an attributed type or variable in an arithmetic
+  expression will define the overflow behavior for that expression as having
+  two's complement wrap-around. These expressions will not be instrumented by
+  overflow sanitizers nor will they cause integer overflow warnings. They also
+  cannot be optimized away by some eager UB optimizations as the behavior of
+  the arithmetic is no longer "undefined".
+
+  There is also ``__attribute__((no_wraps))`` which can be added to types or
+  variable declarations. Types or variables with this attribute may be
+  instrumented by overflow sanitizers, if enabled. Note that this matches the
+  default behavior of integer types. So, in most cases, ``no_wraps`` serves
+  purely as an annotation to readers of code that a type or variable really
+  shouldn't wrap-around. ``__attribute__((no_wraps))`` has the most function
+  when paired with `Sanitizer Special Case Lists (SSCL)
+  `_.
+
+  These attributes are only valid for C, as there are built-in language
+  alternatives for other languages.
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/docs/SanitizerSpecialCaseList.rst 
b/clang/docs/SanitizerSpecialCaseList.rst
index 96a7b2fba4ae43..10462643b69c7f 100644
--- a/clang/docs/SanitizerSpecialCaseList.rst
+++ b/clang/docs/SanitizerSpecialCaseList.rst
@@ -67,9 +67,11 @@ types specified within an ignorelist.
 int a = 2147483647; // INT_MAX
 ++a;// Normally, an overflow with 
-fsanitize=signed-integer-overflow
   }
+
   $ cat ignorelist.txt
   [signed-integer-overflow]
   type:int
+
   $ clang -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=ignorelist.txt foo.c ; ./a.out
   # no signed-integer-overflow error
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 466c65a9685ad3..4472c941ed5c79 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4142,6 +4142,12 @@ class BinaryOperator : public Expr {
 return getFPFeaturesInEffect(LO).getAllowFEnvAccess();
   }
 
+  /// Does one of the subexpressions have the wraps attribute?
+  bool hasWrappingOperand(const ASTContext &Ctx) const;
+
+  /// How about the no_wraps attribute?
+  bool hasNonWrappingOperand(const ASTContext &Ctx) const;
+
 protected:
   BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs, Opcode opc,
  QualType ResTy, ExprValueKind VK, ExprObjectKind OK,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1bcc7ee0b70dee..c7f368c0193664 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/

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

2024-11-06 Thread Jonas Paulsson via cfe-commits

JonPsson1 wrote:

Patch improved further:

- Atomic memops handled.

- Spill/reload
  Handled in loadRegFromStackSlot() and storeRegToStackSlot(). VRegs can be 
used here which
  makes it straightforward, but special sequences needed (without using 
VSTE/VLE).

- __fp16:
  HalfArgsAndReturns=true => __fp16 arguments allowed.
  Tests added.

- f16 vectors:
  Tests added. All seems to work.

- strict fp:
  Again the question of conversion functions:
  IDS::STRICT_FP_ROUND/STRICT_FP_EXTEND needs to be lowered to something, but 
not sure
  if that requires special treatment, or if the same conversion functions can 
be used.
  Maybe wait with strict fp16?


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


[clang] [Clang] Remove the wrong assumption when rebuilding SizeOfPackExprs for constraint normalization (PR #115120)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -1736,23 +1736,13 @@ namespace {
  SourceLocation RParenLoc,
  std::optional Length,
  ArrayRef PartialArgs) {
-  if (SemaRef.CodeSynthesisContexts.back().Kind !=
-  Sema::CodeSynthesisContext::ConstraintNormalization)
-return inherited::RebuildSizeOfPackExpr(OperatorLoc, Pack, PackLoc,
-RParenLoc, Length, 
PartialArgs);
-
-#ifndef NDEBUG
-  for (auto *Iter = TemplateArgs.begin(); Iter != TemplateArgs.end();
-   ++Iter)
-for (const TemplateArgument &TA : Iter->Args)
-  assert(TA.getKind() != TemplateArgument::Pack || TA.pack_size() == 
1);
-#endif
-  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(
-  SemaRef, /*NewSubstitutionIndex=*/0);
-  Decl *NewPack = TransformDecl(PackLoc, Pack);
-  if (!NewPack)
-return ExprError();
-
+  Decl *NewPack = Pack;
+  if (SemaRef.CodeSynthesisContexts.back().Kind ==
+  Sema::CodeSynthesisContext::ConstraintNormalization) {
+NewPack = TransformDecl(PackLoc, Pack);
+if (!NewPack)
+  return ExprError();
+  }
   return inherited::RebuildSizeOfPackExpr(OperatorLoc,
   cast(NewPack), 
PackLoc,
   RParenLoc, Length, PartialArgs);

mizvekov wrote:

I missed this on the original review, but it's a layering violation to call 
Transform inside of a Rebuild function.
Can we move this into a Transform* function?

Also, is the `ConstraintNormalization` check necessary for correctness, or is 
this done for performance reasons?

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


[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `dot4add_u8packed` intrinsic (PR #115068)

2024-11-06 Thread Greg Roth via cfe-commits

https://github.com/pow2clk commented:

A nitpick, a comment, and a question.

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


[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `dot4add_u8packed` intrinsic (PR #115068)

2024-11-06 Thread Greg Roth via cfe-commits


@@ -0,0 +1,65 @@
+; RUN: llc -O0 -mtriple=spirv1.5-unknown-unknown %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-EXP
+; RUN: llc -O0 -mtriple=spirv1.6-unknown-unknown %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-DOT
+; RUN: llc -O0 -mtriple=spirv-unknown-unknown 
-spirv-ext=+SPV_KHR_integer_dot_product %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-DOT,CHECK-EXT

pow2clk wrote:

I see this in the existing test as well. Perhaps you can remind me why we can 
expect both the integer dot product operations as well as the expansion in this 
case? 

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


[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `dot4add_u8packed` intrinsic (PR #115068)

2024-11-06 Thread Greg Roth via cfe-commits


@@ -942,7 +942,13 @@ uint64_t dot(uint64_t4, uint64_t4);
 
 _HLSL_AVAILABILITY(shadermodel, 6.4)
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot4add_i8packed)
-int dot4add_i8packed(unsigned int, unsigned int, int);
+int dot4add_i8packed(uint, uint, int);

pow2clk wrote:

It's not really a bug fix. It's really minor and we do have some tolerance for 
incidental clean ups even if we moved the select instruction return fixes to 
their own PR.

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


[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `dot4add_u8packed` intrinsic (PR #115068)

2024-11-06 Thread Greg Roth via cfe-commits


@@ -0,0 +1,18 @@
+
+// RUN: %clang_cc1 -finclude-default-header -triple \
+// RUN:   dxil-pc-shadermodel6.3-compute %s -emit-llvm -disable-llvm-passes -o 
- | \
+// RUN:   FileCheck %s -DTARGET=dx
+// RUN: %clang_cc1 -finclude-default-header -triple \
+// RUN:   spirv-pc-vulkan-compute %s -emit-llvm -disable-llvm-passes -o - | \
+// RUN:   FileCheck %s -DTARGET=spv
+
+// Test basic lowering to runtime function call.
+
+// CHECK-LABEL: test

pow2clk wrote:

It would be slightly tighter to make this a check for `define {{.*}}test` as it 
could match the function declaration at present.

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


[clang] [Clang] Remove the wrong assumption when rebuilding SizeOfPackExprs for constraint normalization (PR #115120)

2024-11-06 Thread Matheus Izvekov via cfe-commits


@@ -1881,6 +1871,15 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation 
Loc, Decl *D) {
   TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
 
   if (TTP->isParameterPack()) {
+// We might not have an index for pack expansion when normalizing
+// constraint expressions. In that case, resort to instantiation scopes
+// for the transformed declarations.
+if (SemaRef.ArgumentPackSubstitutionIndex == -1 &&
+SemaRef.CodeSynthesisContexts.back().Kind ==
+Sema::CodeSynthesisContext::ConstraintNormalization) {
+  return SemaRef.FindInstantiatedDecl(Loc, cast(D),
+  TemplateArgs);

mizvekov wrote:

Why don't we have an index in these cases? Is this something we could fix in 
the future?

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


[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `dot4add_u8packed` intrinsic (PR #115068)

2024-11-06 Thread Greg Roth via cfe-commits

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Joseph Huber (jhuber6)


Changes

Summary:
The cache line size on AMDGPU varies between 64 and 128 (The lowest L2
cache also goes to 256 on some architectures.) This macro is intended to
present a size that will not cause destructive interference, so we
choose the larger of those values.


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


1 Files Affected:

- (modified) clang/lib/Basic/Targets/AMDGPU.h (+4) 


``diff
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 6edd3474d4edae..81e96ed65c47bf 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -462,6 +462,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   }
 
   bool hasHIPImageSupport() const override { return HasImage; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(128, 128);
+  }
 };
 
 } // namespace targets

``




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


[clang] [llvm] [HLSL] Adding HLSL `clip` function. (PR #114588)

2024-11-06 Thread via cfe-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/114588

>From a92e64d9a769d3d7b58d5f028fc157e56b879282 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Tue, 29 Oct 2024 19:39:31 +
Subject: [PATCH 1/4] adding llvm intrinsic

---
 clang/include/clang/Basic/Builtins.td |  6 ++
 clang/lib/CodeGen/CGBuiltin.cpp   | 10 ++
 clang/lib/CodeGen/CGHLSLRuntime.h |  2 +-
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 17 +
 clang/lib/Sema/SemaHLSL.cpp   |  8 
 clang/test/CodeGenHLSL/builtins/clip.hlsl | 14 ++
 llvm/include/llvm/IR/IntrinsicsDirectX.td |  1 +
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  1 +
 8 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGenHLSL/builtins/clip.hlsl

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 9bd67e0cefebc3..1b8697b209bd70 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4877,6 +4877,12 @@ def HLSLSplitDouble: LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLClip: LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_elementwise_clip"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void(bool)";
+}
+
 // Builtins for XRay.
 def XRayCustomEvent : Builtin {
   let Spellings = ["__xray_customevent"];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 34fedd67114751..1588c4917abbfb 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19093,6 +19093,16 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
"asuint operands types mismatch");
 return handleHlslSplitdouble(E, this);
   }
+  case Builtin::BI__builtin_hlsl_elementwise_clip:
+
+assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
+   "clip operands types mismatch");
+
+Value *Op0 = EmitScalarExpr(E->getArg(0));
+auto *CMP =
+Builder.CreateFCmpOLT(Op0, ConstantFP::get(Builder.getFloatTy(), 0.0));
+return Builder.CreateIntrinsic(
+VoidTy, CGM.getHLSLRuntime().getClipIntrinsic(), {CMP}, nullptr);
   }
   return nullptr;
 }
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index cd533cad84e9fb..06abc95bdb734f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -91,7 +91,7 @@ class CGHLSLRuntime {
   GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
   GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_readlane)
-
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Clip, clip)
   GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromBinding, handle_fromBinding)
 
   
//===--===//
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index d9f3a17ea23d8e..424c2f7e7c23ee 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -655,6 +655,23 @@ double3 clamp(double3, double3, double3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
 double4 clamp(double4, double4, double4);
 
+//===--===//
+// clip builtins
+//===--===//
+
+/// \fn void clip(T Val)
+/// \brief Discards the current pixel if the specified value is less than zero.
+/// \param Val The input value.
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
+void clip(float4);
+
 
//===--===//
 // cos builtins
 
//===--===//
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index a472538236e2d9..e360c54dc0760e 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -2110,6 +2110,14 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
   return true;
 break;
   }
+  case Builtin::BI__builtin_hlsl_elementwise_clip: {
+if (SemaRef.checkArgCount(TheCall, 1))
+  return true;
+
+if (CheckScalarOrVector(&SemaRef, TheCall, SemaRef.Context.FloatTy, 0))
+  return true;
+break;
+  }
   case Builtin::BI__builtin_elementwise_acos:
   case Builtin::BI__builtin_elementwise_asin:
   case Builtin::BI__builtin_elementwise_atan:
diff --git a/clang/test/CodeGenHLSL/builtins/clip.hlsl 
b/clang/test/CodeGenHLSL/builtins/clip.hlsl
new file mode 100644
index 00..426ec8f128436a
--- /dev/null
+++ 

[clang] [llvm] [HLSL][SPIRV] Added clamp intrinsic (PR #113394)

2024-11-06 Thread via cfe-commits

https://github.com/joaosaffran commented:

LGTM

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 created 
https://github.com/llvm/llvm-project/pull/115241

Summary:
The cache line size on AMDGPU varies between 64 and 128 (The lowest L2
cache also goes to 256 on some architectures.) This macro is intended to
present a size that will not cause destructive interference, so we
choose the larger of those values.


>From 3feb2a194bd7e6078ad6e7618878411782828e12 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Wed, 6 Nov 2024 18:27:07 -0600
Subject: [PATCH] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU

Summary:
The cache line size on AMDGPU varies between 64 and 128 (The lowest L2
cache also goes to 256 on some architectures.) This macro is intended to
present a size that will not cause destructive interference, so we
choose the larger of those values.
---
 clang/lib/Basic/Targets/AMDGPU.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 6edd3474d4edae..81e96ed65c47bf 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -462,6 +462,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   }
 
   bool hasHIPImageSupport() const override { return HasImage; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(128, 128);
+  }
 };
 
 } // namespace targets

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)


Changes

Summary:
The cache line size on AMDGPU varies between 64 and 128 (The lowest L2
cache also goes to 256 on some architectures.) This macro is intended to
present a size that will not cause destructive interference, so we
choose the larger of those values.


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


1 Files Affected:

- (modified) clang/lib/Basic/Targets/AMDGPU.h (+4) 


``diff
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 6edd3474d4edae..81e96ed65c47bf 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -462,6 +462,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   }
 
   bool hasHIPImageSupport() const override { return HasImage; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(128, 128);
+  }
 };
 
 } // namespace targets

``




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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread Shilei Tian via cfe-commits

https://github.com/shiltian commented:

Test

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread Matt Arsenault via cfe-commits


@@ -462,6 +462,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   }
 
   bool hasHIPImageSupport() const override { return HasImage; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(128, 128);

arsenm wrote:

What's the first one? Check both values? 

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread Shilei Tian via cfe-commits

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/115241

>From fcb8bcfba329b6ad9f33ace70c22ca4b542d2117 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Wed, 6 Nov 2024 18:27:07 -0600
Subject: [PATCH] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU

Summary:
The cache line size on AMDGPU varies between 64 and 128 (The lowest L2
cache also goes to 256 on some architectures.) This macro is intended to
present a size that will not cause destructive interference, so we
choose the larger of those values.
---
 clang/lib/Basic/Targets/AMDGPU.h   | 4 
 clang/test/Driver/amdgpu-macros.cl | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 6edd3474d4edae..81e96ed65c47bf 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -462,6 +462,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   }
 
   bool hasHIPImageSupport() const override { return HasImage; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(128, 128);
+  }
 };
 
 } // namespace targets
diff --git a/clang/test/Driver/amdgpu-macros.cl 
b/clang/test/Driver/amdgpu-macros.cl
index dd5a4483e4d607..2fedd10bb53445 100644
--- a/clang/test/Driver/amdgpu-macros.cl
+++ b/clang/test/Driver/amdgpu-macros.cl
@@ -153,6 +153,8 @@
 // ARCH-GCN-DAG: #define __[[FAMILY]]__ 1
 // ARCH-GCN-DAG: #define __amdgcn_processor__ "[[CPU]]"
 // ARCH-GCN-DAG: #define __AMDGCN_WAVEFRONT_SIZE [[WAVEFRONT_SIZE]]
+// ARCH-GCN-DAG: #define __GCC_DESTRUCTIVE_SIZE 128
+// ARCH-GCN-DAG: #define __GCC_CONSTRUCTIVE_SIZE 128
 // UNSAFEFPATOMIC-DAG: #define __AMDGCN_UNSAFE_FP_ATOMICS__ 1
 
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx906 -mwavefrontsize64 \

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/115241

>From 451f37016c5bd4cbd0bb08cc172995e8af4e7482 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Wed, 6 Nov 2024 18:27:07 -0600
Subject: [PATCH] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU

Summary:
The cache line size on AMDGPU varies between 64 and 128 (The lowest L2
cache also goes to 256 on some architectures.) This macro is intended to
present a size that will not cause destructive interference, so we
choose the larger of those values.
---
 clang/lib/Basic/Targets/AMDGPU.h   | 4 
 clang/test/Driver/amdgpu-macros.cl | 1 +
 2 files changed, 5 insertions(+)

diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 6edd3474d4edae..81e96ed65c47bf 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -462,6 +462,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   }
 
   bool hasHIPImageSupport() const override { return HasImage; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(128, 128);
+  }
 };
 
 } // namespace targets
diff --git a/clang/test/Driver/amdgpu-macros.cl 
b/clang/test/Driver/amdgpu-macros.cl
index dd5a4483e4d607..5ce9d339d4c050 100644
--- a/clang/test/Driver/amdgpu-macros.cl
+++ b/clang/test/Driver/amdgpu-macros.cl
@@ -153,6 +153,7 @@
 // ARCH-GCN-DAG: #define __[[FAMILY]]__ 1
 // ARCH-GCN-DAG: #define __amdgcn_processor__ "[[CPU]]"
 // ARCH-GCN-DAG: #define __AMDGCN_WAVEFRONT_SIZE [[WAVEFRONT_SIZE]]
+// ARCH-GCN-DAG: #define __GCC_DESTRUCTIVE_SIZE 128
 // UNSAFEFPATOMIC-DAG: #define __AMDGCN_UNSAFE_FP_ATOMICS__ 1
 
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx906 -mwavefrontsize64 \

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


[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

2024-11-06 Thread Shilei Tian via cfe-commits

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


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


[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

2024-11-06 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/114070

>From 587d0105e7724db0f35fc5c8179519fa6319e5c8 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Tue, 29 Oct 2024 22:29:25 +0800
Subject: [PATCH 1/2] [X86][AMX] Support AMX-AVX512

---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/include/clang/Basic/BuiltinsX86_64.def  |  13 +
 clang/include/clang/Driver/Options.td |   2 +
 clang/lib/Basic/Targets/X86.cpp   |   6 +
 clang/lib/Basic/Targets/X86.h |   1 +
 clang/lib/Headers/CMakeLists.txt  |   1 +
 clang/lib/Headers/amxavx512intrin.h   | 381 ++
 clang/lib/Headers/immintrin.h |   4 +
 clang/lib/Sema/SemaX86.cpp|   6 +
 clang/test/CodeGen/X86/amx_avx512_api.c   |  52 +++
 clang/test/CodeGen/X86/amxavx512-builtins.c   |  41 ++
 clang/test/CodeGen/attr-target-x86.c  |   8 +-
 clang/test/Driver/x86-target-features.c   |   7 +
 clang/test/Preprocessor/x86_target_features.c |   7 +
 llvm/include/llvm/IR/IntrinsicsX86.td |  50 +++
 .../llvm/TargetParser/X86TargetParser.def |   1 +
 llvm/lib/Target/X86/X86.td|   4 +
 llvm/lib/Target/X86/X86ExpandPseudo.cpp   |  64 ++-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  76 
 llvm/lib/Target/X86/X86InstrAMX.td| 147 +++
 llvm/lib/Target/X86/X86InstrPredicates.td |   1 +
 llvm/lib/Target/X86/X86LowerAMXType.cpp   |  11 +
 llvm/lib/Target/X86/X86PreTileConfig.cpp  |  19 +-
 llvm/lib/TargetParser/Host.cpp|   4 +
 llvm/lib/TargetParser/X86TargetParser.cpp |   2 +
 .../CodeGen/X86/amx-across-func-tilemovrow.ll | 171 
 .../test/CodeGen/X86/amx-avx512-intrinsics.ll | 116 ++
 .../CodeGen/X86/amx-tile-avx512-internals.ll  |  61 +++
 llvm/test/MC/Disassembler/X86/amx-avx512.txt  | 106 +
 llvm/test/MC/X86/amx-avx512-att.s | 105 +
 llvm/test/MC/X86/amx-avx512-intel.s   | 105 +
 31 files changed, 1564 insertions(+), 10 deletions(-)
 create mode 100644 clang/lib/Headers/amxavx512intrin.h
 create mode 100644 clang/test/CodeGen/X86/amx_avx512_api.c
 create mode 100644 clang/test/CodeGen/X86/amxavx512-builtins.c
 create mode 100644 llvm/test/CodeGen/X86/amx-across-func-tilemovrow.ll
 create mode 100644 llvm/test/CodeGen/X86/amx-avx512-intrinsics.ll
 create mode 100644 llvm/test/CodeGen/X86/amx-tile-avx512-internals.ll
 create mode 100644 llvm/test/MC/Disassembler/X86/amx-avx512.txt
 create mode 100644 llvm/test/MC/X86/amx-avx512-att.s
 create mode 100644 llvm/test/MC/X86/amx-avx512-intel.s

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce046a305c89b6..d45bd1240dd173 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -611,6 +611,8 @@ X86 Support
   * Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
   ``*_(mask(z)))_minmax_s[s|d|h]``.
 
+- Support ISA of ``AMX-AVX512``.
+
 - All intrinsics in adcintrin.h can now be used in constant expressions.
 
 - All intrinsics in adxintrin.h can now be used in constant expressions.
diff --git a/clang/include/clang/Basic/BuiltinsX86_64.def 
b/clang/include/clang/Basic/BuiltinsX86_64.def
index 2c591edb2835cd..70644f3f6b6054 100644
--- a/clang/include/clang/Basic/BuiltinsX86_64.def
+++ b/clang/include/clang/Basic/BuiltinsX86_64.def
@@ -128,6 +128,12 @@ TARGET_BUILTIN(__builtin_ia32_tdpbf16ps_internal, 
"V256iUsUsUsV256iV256iV256i",
 TARGET_BUILTIN(__builtin_ia32_tdpfp16ps_internal, 
"V256iUsUsUsV256iV256iV256i", "n", "amx-fp16")
 TARGET_BUILTIN(__builtin_ia32_tcmmimfp16ps_internal, 
"V256iUsUsUsV256iV256iV256i", "n", "amx-complex")
 TARGET_BUILTIN(__builtin_ia32_tcmmrlfp16ps_internal, 
"V256iUsUsUsV256iV256iV256i", "n", "amx-complex")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowd2ps_internal, "V16fUsUsV256iUi", "n", 
"amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2pbf16h_internal, "V32yUsUsV256iUi", 
"n", "amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2pbf16l_internal, "V32yUsUsV256iUi", 
"n", "amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2phh_internal, "V32xUsUsV256iUi", "n", 
"amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2phl_internal, "V32xUsUsV256iUi", "n", 
"amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tilemovrow_internal, "V16iUsUsV256iUi", "n", 
"amx-avx512")
 // AMX
 TARGET_BUILTIN(__builtin_ia32_tile_loadconfig, "vvC*", "n", "amx-tile")
 TARGET_BUILTIN(__builtin_ia32_tile_storeconfig, "vvC*", "n", "amx-tile")
@@ -148,6 +154,13 @@ TARGET_BUILTIN(__builtin_ia32_ptwrite64, "vUOi", "n", 
"ptwrite")
 TARGET_BUILTIN(__builtin_ia32_tcmmimfp16ps, "vIUcIUcIUc", "n", "amx-complex")
 TARGET_BUILTIN(__builtin_ia32_tcmmrlfp16ps, "vIUcIUcIUc", "n", "amx-complex")
 
+TARGET_BUILTIN(__builtin_ia32_tcvtrowd2ps, "V16fIUcUi", "n", "amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2pbf16h, "V32yIUcUi", "n", "amx-avx512")
+TARGET_BUILTIN(__builtin_i

[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

2024-11-06 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,381 @@
+/*===- amxavx512intrin.h - AMXAVX512 
===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ 
*======
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif // __IMMINTRIN_H
+
+#ifndef __AMX_AVX512INTRIN_H
+#define __AMX_AVX512INTRIN_H
+#ifdef __x86_64__
+
+#define __DEFAULT_FN_ATTRS_AVX512  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("amx-avx512")))
+
+/// Moves a row from a tile register to a zmm destination register, converting
+///the int32 source elements to fp32. The row of the tile is selected by an

phoebewang wrote:

Done.

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


[clang] [ASTWriter] Detect more non-affecting FileIDs to reduce source location duplication (PR #112015)

2024-11-06 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov updated 
https://github.com/llvm/llvm-project/pull/112015

>From b6508a13d1a115bb3acb54590833674f4158814c Mon Sep 17 00:00:00 2001
From: Ilya Biryukov 
Date: Thu, 19 Sep 2024 20:18:36 +0200
Subject: [PATCH 1/3] [ASTWriter] Detect more non-affecting FileIDs to reduce
 duplication of source locations

Currently, any FileID that references a module map file that was
required for a compilation is considered as affecting. This misses an
important opportunity to reduce the source location space taken by the
resulting PCM.

In particular, consider the situation where the same module map file is
passed multiple times in the dependency chain:

```shell
$ clang -fmodule-map-file=foo.modulemap ... -o mod1.pcm
$ clang -fmodule-map-file=foo.modulemap -fmodule-file=mod1.pcm ... -o mod2.pcm
...
$ clang -fmodule-map-file=foo.modulemap -fmodule-file=mod$((N-1)).pcm ... -o 
mod$N.pcm
```

Because `foo.modulemap` is read before reading any of the `.pcm` files,
we have to create a unique `FileID` for it when creating each module.
However, when reading the `.pcm` files, we will reuse the `FileID`
loaded from it for the same module map file and the `FileID` we created
can never be used again, but we will still not mark it as affecting and
it will take the source location space in the output PCM.

For a chain of N dependencies, this results in the file taking
`N * (size of file)` source location space, which could be significant.
For examples, we observer internally that some targets that run out of
2GB of source location space end up wasting up to 20% of that space in
module maps as described above.

I take extra care to still write the InputFile entries for those files,
which has not been done before. It is required for ClangScanDeps to properly
function.

The change in the output of one of the ClangScanDeps tests is attributed
to that: we now add a bit more module maps to the output in some tricky
cases. E.g. in the test case the module map file is required and is
referenced by another top-level module map, adding it is redundant, but
should not be breaking.
---
 clang/include/clang/Serialization/ASTWriter.h |  3 +
 clang/lib/Serialization/ASTReader.cpp |  6 ++
 clang/lib/Serialization/ASTWriter.cpp | 41 ++---
 .../ClangScanDeps/modules-extern-submodule.c  |  2 +-
 ...rune-non-affecting-module-map-repeated.cpp | 85 +++
 5 files changed, 126 insertions(+), 11 deletions(-)
 create mode 100644 
clang/test/Modules/prune-non-affecting-module-map-repeated.cpp

diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 10a50b711043a8..6b03300d59adda 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -491,6 +491,9 @@ class ASTWriter : public ASTDeserializationListener,
 
   /// Mapping from a source location entry to whether it is affecting or not.
   llvm::BitVector IsSLocAffecting;
+  /// Mapping from a source location entry to whether it must be included as
+  /// input file.
+  llvm::BitVector IsSLocFileEntryAffecting;
 
   /// Mapping from \c FileID to an index into the FileID adjustment table.
   std::vector NonAffectingFileIDs;
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index e5a1e20a265616..a4ce57c6b2d9c5 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5862,6 +5862,12 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
   }
 
   CurrentModule->Kind = Kind;
+  // Note that we may be rewriting an existing location and it is important
+  // to keep doing that. In particular, we would like to prefer a
+  // `DefinitionLoc` loaded from the module file instead of the location
+  // created in the current source manager, because it allows the new
+  // location to be marked as "unaffecting" when writing and avoid creating
+  // duplicate locations for the same module map file.
   CurrentModule->DefinitionLoc = DefinitionLoc;
   CurrentModule->Signature = F.Signature;
   CurrentModule->IsFromModuleFile = true;
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index c6289493fce1de..135e6308b36390 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -38,6 +38,7 @@
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileEntry.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/IdentifierTable.h"
@@ -81,6 +82,7 @@
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/STLExtras.h"
@@ -166,7 +168,12 @@ static TypeCode 

[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

2024-11-06 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/114070

>From 587d0105e7724db0f35fc5c8179519fa6319e5c8 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Tue, 29 Oct 2024 22:29:25 +0800
Subject: [PATCH] [X86][AMX] Support AMX-AVX512

---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/include/clang/Basic/BuiltinsX86_64.def  |  13 +
 clang/include/clang/Driver/Options.td |   2 +
 clang/lib/Basic/Targets/X86.cpp   |   6 +
 clang/lib/Basic/Targets/X86.h |   1 +
 clang/lib/Headers/CMakeLists.txt  |   1 +
 clang/lib/Headers/amxavx512intrin.h   | 381 ++
 clang/lib/Headers/immintrin.h |   4 +
 clang/lib/Sema/SemaX86.cpp|   6 +
 clang/test/CodeGen/X86/amx_avx512_api.c   |  52 +++
 clang/test/CodeGen/X86/amxavx512-builtins.c   |  41 ++
 clang/test/CodeGen/attr-target-x86.c  |   8 +-
 clang/test/Driver/x86-target-features.c   |   7 +
 clang/test/Preprocessor/x86_target_features.c |   7 +
 llvm/include/llvm/IR/IntrinsicsX86.td |  50 +++
 .../llvm/TargetParser/X86TargetParser.def |   1 +
 llvm/lib/Target/X86/X86.td|   4 +
 llvm/lib/Target/X86/X86ExpandPseudo.cpp   |  64 ++-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  76 
 llvm/lib/Target/X86/X86InstrAMX.td| 147 +++
 llvm/lib/Target/X86/X86InstrPredicates.td |   1 +
 llvm/lib/Target/X86/X86LowerAMXType.cpp   |  11 +
 llvm/lib/Target/X86/X86PreTileConfig.cpp  |  19 +-
 llvm/lib/TargetParser/Host.cpp|   4 +
 llvm/lib/TargetParser/X86TargetParser.cpp |   2 +
 .../CodeGen/X86/amx-across-func-tilemovrow.ll | 171 
 .../test/CodeGen/X86/amx-avx512-intrinsics.ll | 116 ++
 .../CodeGen/X86/amx-tile-avx512-internals.ll  |  61 +++
 llvm/test/MC/Disassembler/X86/amx-avx512.txt  | 106 +
 llvm/test/MC/X86/amx-avx512-att.s | 105 +
 llvm/test/MC/X86/amx-avx512-intel.s   | 105 +
 31 files changed, 1564 insertions(+), 10 deletions(-)
 create mode 100644 clang/lib/Headers/amxavx512intrin.h
 create mode 100644 clang/test/CodeGen/X86/amx_avx512_api.c
 create mode 100644 clang/test/CodeGen/X86/amxavx512-builtins.c
 create mode 100644 llvm/test/CodeGen/X86/amx-across-func-tilemovrow.ll
 create mode 100644 llvm/test/CodeGen/X86/amx-avx512-intrinsics.ll
 create mode 100644 llvm/test/CodeGen/X86/amx-tile-avx512-internals.ll
 create mode 100644 llvm/test/MC/Disassembler/X86/amx-avx512.txt
 create mode 100644 llvm/test/MC/X86/amx-avx512-att.s
 create mode 100644 llvm/test/MC/X86/amx-avx512-intel.s

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce046a305c89b6..d45bd1240dd173 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -611,6 +611,8 @@ X86 Support
   * Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
   ``*_(mask(z)))_minmax_s[s|d|h]``.
 
+- Support ISA of ``AMX-AVX512``.
+
 - All intrinsics in adcintrin.h can now be used in constant expressions.
 
 - All intrinsics in adxintrin.h can now be used in constant expressions.
diff --git a/clang/include/clang/Basic/BuiltinsX86_64.def 
b/clang/include/clang/Basic/BuiltinsX86_64.def
index 2c591edb2835cd..70644f3f6b6054 100644
--- a/clang/include/clang/Basic/BuiltinsX86_64.def
+++ b/clang/include/clang/Basic/BuiltinsX86_64.def
@@ -128,6 +128,12 @@ TARGET_BUILTIN(__builtin_ia32_tdpbf16ps_internal, 
"V256iUsUsUsV256iV256iV256i",
 TARGET_BUILTIN(__builtin_ia32_tdpfp16ps_internal, 
"V256iUsUsUsV256iV256iV256i", "n", "amx-fp16")
 TARGET_BUILTIN(__builtin_ia32_tcmmimfp16ps_internal, 
"V256iUsUsUsV256iV256iV256i", "n", "amx-complex")
 TARGET_BUILTIN(__builtin_ia32_tcmmrlfp16ps_internal, 
"V256iUsUsUsV256iV256iV256i", "n", "amx-complex")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowd2ps_internal, "V16fUsUsV256iUi", "n", 
"amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2pbf16h_internal, "V32yUsUsV256iUi", 
"n", "amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2pbf16l_internal, "V32yUsUsV256iUi", 
"n", "amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2phh_internal, "V32xUsUsV256iUi", "n", 
"amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2phl_internal, "V32xUsUsV256iUi", "n", 
"amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tilemovrow_internal, "V16iUsUsV256iUi", "n", 
"amx-avx512")
 // AMX
 TARGET_BUILTIN(__builtin_ia32_tile_loadconfig, "vvC*", "n", "amx-tile")
 TARGET_BUILTIN(__builtin_ia32_tile_storeconfig, "vvC*", "n", "amx-tile")
@@ -148,6 +154,13 @@ TARGET_BUILTIN(__builtin_ia32_ptwrite64, "vUOi", "n", 
"ptwrite")
 TARGET_BUILTIN(__builtin_ia32_tcmmimfp16ps, "vIUcIUcIUc", "n", "amx-complex")
 TARGET_BUILTIN(__builtin_ia32_tcmmrlfp16ps, "vIUcIUcIUc", "n", "amx-complex")
 
+TARGET_BUILTIN(__builtin_ia32_tcvtrowd2ps, "V16fIUcUi", "n", "amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_tcvtrowps2pbf16h, "V32yIUcUi", "n", "amx-avx512")
+TARGET_BUILTIN(__builtin_ia32_

[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

2024-11-06 Thread Phoebe Wang via cfe-commits


@@ -559,12 +559,68 @@ bool X86ExpandPseudo::expandMI(MachineBasicBlock &MBB,
 return true;
   }
   case X86::PTILELOADDV:
-  case X86::PTILELOADDT1V: {
+  case X86::PTILELOADDT1V:
+  case X86::PTCVTROWD2PSrreV:
+  case X86::PTCVTROWD2PSrriV:
+  case X86::PTCVTROWPS2PBF16HrreV:
+  case X86::PTCVTROWPS2PBF16HrriV:
+  case X86::PTCVTROWPS2PBF16LrreV:
+  case X86::PTCVTROWPS2PBF16LrriV:
+  case X86::PTCVTROWPS2PHHrreV:
+  case X86::PTCVTROWPS2PHHrriV:
+  case X86::PTCVTROWPS2PHLrreV:
+  case X86::PTCVTROWPS2PHLrriV:
+  case X86::PTILEMOVROWrreV:
+  case X86::PTILEMOVROWrriV: {
 for (unsigned i = 2; i > 0; --i)
   MI.removeOperand(i);
-unsigned Opc = Opcode == X86::PTILELOADDV
-   ? GET_EGPR_IF_ENABLED(X86::TILELOADD)
-   : GET_EGPR_IF_ENABLED(X86::TILELOADDT1);
+unsigned Opc;
+switch (Opcode) {
+case X86::PTILELOADDV:
+  Opc = GET_EGPR_IF_ENABLED(X86::TILELOADD);
+  break;
+case X86::PTILELOADDT1V:
+  Opc = GET_EGPR_IF_ENABLED(X86::TILELOADDT1);
+  break;
+case X86::PTCVTROWD2PSrreV:
+  Opc = X86::TCVTROWD2PSrre;
+  break;
+case X86::PTCVTROWD2PSrriV:
+  Opc = X86::TCVTROWD2PSrri;
+  break;
+case X86::PTCVTROWPS2PBF16HrreV:
+  Opc = X86::TCVTROWPS2PBF16Hrre;
+  break;
+case X86::PTCVTROWPS2PBF16HrriV:
+  Opc = X86::TCVTROWPS2PBF16Hrri;
+  break;
+case X86::PTCVTROWPS2PBF16LrreV:
+  Opc = X86::TCVTROWPS2PBF16Lrre;
+  break;
+case X86::PTCVTROWPS2PBF16LrriV:
+  Opc = X86::TCVTROWPS2PBF16Lrri;
+  break;
+case X86::PTCVTROWPS2PHHrreV:
+  Opc = X86::TCVTROWPS2PHHrre;
+  break;
+case X86::PTCVTROWPS2PHHrriV:
+  Opc = X86::TCVTROWPS2PHHrri;
+  break;
+case X86::PTCVTROWPS2PHLrreV:
+  Opc = X86::TCVTROWPS2PHLrre;
+  break;
+case X86::PTCVTROWPS2PHLrriV:
+  Opc = X86::TCVTROWPS2PHLrri;
+  break;
+case X86::PTILEMOVROWrreV:
+  Opc = X86::TILEMOVROWrre;
+  break;
+case X86::PTILEMOVROWrriV:
+  Opc = X86::TILEMOVROWrri;
+  break;
+default:
+  llvm_unreachable("Impossible Opcode!");

phoebewang wrote:

Done.

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


[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

2024-11-06 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,381 @@
+/*===- amxavx512intrin.h - AMXAVX512 
===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ 
*======
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif // __IMMINTRIN_H
+
+#ifndef __AMX_AVX512INTRIN_H
+#define __AMX_AVX512INTRIN_H
+#ifdef __x86_64__
+
+#define __DEFAULT_FN_ATTRS_AVX512  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("amx-avx512")))
+
+/// Moves a row from a tile register to a zmm destination register, converting
+///the int32 source elements to fp32. The row of the tile is selected by an
+///32b GPR.
+///
+/// \headerfile 
+///
+/// \code
+/// __m512i _tile_cvtrowd2ps(__tile tsrc, unsigned int row);
+/// \endcode
+///
+/// \code{.operation}
+/// VL := 512
+/// VL_bytes := VL >> 3
+/// row_index := row & 0x
+/// row_chunk := ((row >> 16) & 0x) * VL_bytes
+/// FOR i := 0 TO (VL_bytes / 4) - 1
+/// IF i + row_chunk / 4 >= tsrc.colsb / 4
+/// dst.dword[i] := 0
+/// ELSE
+/// dst.f32[i] := 
CONVERT_INT32_TO_FP32(tsrc.row[row_index].dword[row_chunk/4+i], RNE)
+/// FI
+/// ENDFOR
+/// dst[MAX_VL-1:VL] := 0
+/// zero_tileconfig_start()
+/// \endcode
+///
+/// This intrinsic corresponds to the \c TCVTROWD2PS instruction.
+///
+/// \param tsrc
+///The 1st source tile. Max size is 1024 Bytes.
+/// \param row
+///The row of the source tile
+#define _tile_cvtrowd2ps(tsrc, row) __builtin_ia32_tcvtrowd2ps(tsrc, row)
+
+/// Moves a row from a tile register to a zmm destination register, converting
+///the fp32 source elements to bf16. It places the resulting bf16 elements
+///in the high 16 bits within each dword. The row of the tile is selected
+///by an 32b GPR.

phoebewang wrote:

Done.

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


[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

2024-11-06 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,381 @@
+/*===- amxavx512intrin.h - AMXAVX512 
===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ 
*======
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif // __IMMINTRIN_H
+
+#ifndef __AMX_AVX512INTRIN_H
+#define __AMX_AVX512INTRIN_H
+#ifdef __x86_64__
+
+#define __DEFAULT_FN_ATTRS_AVX512  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("amx-avx512")))
+
+/// Moves a row from a tile register to a zmm destination register, converting
+///the int32 source elements to fp32. The row of the tile is selected by an
+///32b GPR.
+///
+/// \headerfile 
+///
+/// \code
+/// __m512i _tile_cvtrowd2ps(__tile tsrc, unsigned int row);
+/// \endcode
+///
+/// \code{.operation}
+/// VL := 512
+/// VL_bytes := VL >> 3
+/// row_index := row & 0x
+/// row_chunk := ((row >> 16) & 0x) * VL_bytes
+/// FOR i := 0 TO (VL_bytes / 4) - 1
+/// IF i + row_chunk / 4 >= tsrc.colsb / 4
+/// dst.dword[i] := 0
+/// ELSE
+/// dst.f32[i] := 
CONVERT_INT32_TO_FP32(tsrc.row[row_index].dword[row_chunk/4+i], RNE)
+/// FI
+/// ENDFOR
+/// dst[MAX_VL-1:VL] := 0
+/// zero_tileconfig_start()
+/// \endcode
+///
+/// This intrinsic corresponds to the \c TCVTROWD2PS instruction.
+///
+/// \param tsrc
+///The 1st source tile. Max size is 1024 Bytes.

phoebewang wrote:

Done.

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


[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)

2024-11-06 Thread Nikita Popov via cfe-commits

nikic wrote:

@yingopq As you regularly do MIPS work, I'd recommend to request commit access, 
as described at 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.

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


[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

2024-11-06 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 37ce18951fded6be1de319b05b968918cb45c00b 
c38da4e614434b02158444f31f50aee61f9879f6 --extensions cpp,c,h -- 
clang/lib/Headers/amxavx512intrin.h clang/test/CodeGen/X86/amx_avx512_api.c 
clang/test/CodeGen/X86/amxavx512-builtins.c clang/lib/Basic/Targets/X86.cpp 
clang/lib/Basic/Targets/X86.h clang/lib/Headers/immintrin.h 
clang/lib/Sema/SemaX86.cpp clang/test/CodeGen/attr-target-x86.c 
clang/test/Driver/x86-target-features.c 
clang/test/Preprocessor/x86_target_features.c 
llvm/lib/Target/X86/X86ExpandPseudo.cpp llvm/lib/Target/X86/X86ISelLowering.cpp 
llvm/lib/Target/X86/X86LowerAMXType.cpp 
llvm/lib/Target/X86/X86PreTileConfig.cpp llvm/lib/TargetParser/Host.cpp 
llvm/lib/TargetParser/X86TargetParser.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Headers/amxavx512intrin.h 
b/clang/lib/Headers/amxavx512intrin.h
index 9bfa868cf4..1e6ee35dea 100644
--- a/clang/lib/Headers/amxavx512intrin.h
+++ b/clang/lib/Headers/amxavx512intrin.h
@@ -36,7 +36,8 @@
 /// IF i + row_chunk / 4 >= tsrc.colsb / 4
 /// dst.dword[i] := 0
 /// ELSE
-/// dst.f32[i] := 
CONVERT_INT32_TO_FP32(tsrc.row[row_index].dword[row_chunk/4+i], RNE)
+/// dst.f32[i] :=
+/// CONVERT_INT32_TO_FP32(tsrc.row[row_index].dword[row_chunk/4+i], 
RNE)
 /// FI
 /// ENDFOR
 /// dst[MAX_VL-1:VL] := 0
@@ -72,7 +73,8 @@
 /// dst.dword[i] := 0
 /// ELSE
 /// dst.word[2*i+0] := 0
-/// dst.bf16[2*i+1] := 
CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
+/// dst.bf16[2*i+1] :=
+/// CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
 /// FI
 /// ENDFOR
 /// dst[MAX_VL-1:VL] := 0
@@ -109,7 +111,8 @@
 /// dst.dword[i] := 0
 /// ELSE
 /// dst.word[2*i+1] := 0
-/// dst.bf16[2*i+0] := 
CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
+/// dst.bf16[2*i+0] :=
+/// CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
 /// FI
 /// ENDFOR
 /// dst[MAX_VL-1:VL] := 0
@@ -146,7 +149,8 @@
 /// dst.dword[i] := 0
 /// ELSE
 /// dst.word[2*i+0] := 0
-/// dst.fp16[2*i+1] := 
CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
+/// dst.fp16[2*i+1] :=
+/// CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
 /// FI
 /// ENDFOR
 /// dst[MAX_VL-1:VL] := 0
@@ -182,7 +186,8 @@
 /// dst.dword[i] := 0
 /// ELSE
 /// dst.word[2*i+1] := 0
-/// dst.fp16[2*i+0] := 
CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
+/// dst.fp16[2*i+0] :=
+/// CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)
 /// FI
 /// ENDFOR
 /// dst[MAX_VL-1:VL] := 0
diff --git a/llvm/lib/Target/X86/X86ExpandPseudo.cpp 
b/llvm/lib/Target/X86/X86ExpandPseudo.cpp
index 52519f49e7..9511a82f0e 100644
--- a/llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ b/llvm/lib/Target/X86/X86ExpandPseudo.cpp
@@ -770,7 +770,8 @@ bool X86ExpandPseudo::expandMI(MachineBasicBlock &MBB,
 case X86::PTDPBUUDV:   Opc = X86::TDPBUUD; break;
 case X86::PTDPBF16PSV: Opc = X86::TDPBF16PS; break;
 case X86::PTDPFP16PSV: Opc = X86::TDPFP16PS; break;
-default: llvm_unreachable("Unexpected Opcode");
+default:
+  llvm_unreachable("Unexpected Opcode");
 }
 MI.setDesc(TII->get(Opc));
 MI.tieOperands(0, 1);

``




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


[clang] [Clang][HIP] Deprecate the AMDGCN_WAVEFRONT_SIZE macros (PR #112849)

2024-11-06 Thread Fabian Ritter via cfe-commits

ritter-x2a wrote:

@AlexVlx @jhuber6 @arsenm  is there a dependence between this deprecation PR 
and #114481, or can we already go ahead with the deprecation of the macro via 
this PR?

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


  1   2   3   4   5   >