[clang] [clang][Interp] Fix diagnosing uninitialized nested union fields (PR #102824)

2024-08-12 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/102824

>From d996308e8420f7735095c1118430531509e9264d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 11 Aug 2024 19:52:51 +0200
Subject: [PATCH] [clang][Interp] Fix diagnosing uninitialized nested union
 fields

We were calling initialize() unconditionally when copying the union.
---
 clang/lib/AST/Interp/Interp.cpp|  6 +-
 clang/lib/AST/Interp/InterpBuiltin.cpp | 95 --
 clang/test/AST/Interp/unions.cpp   | 26 ++-
 3 files changed, 88 insertions(+), 39 deletions(-)

diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 13390007fde33c..4a50b4487b6654 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -126,13 +126,17 @@ static bool CheckActive(InterpState &S, CodePtr OpPC, 
const Pointer &Ptr,
 return true;
 
   assert(Ptr.inUnion());
+  assert(Ptr.isField() && Ptr.getField());
 
   Pointer U = Ptr.getBase();
   Pointer C = Ptr;
   while (!U.isRoot() && U.inUnion() && !U.isActive()) {
-C = U;
+if (U.getField())
+  C = U;
 U = U.getBase();
   }
+  assert(C.isField());
+
   // Get the inactive field descriptor.
   const FieldDecl *InactiveField = C.getField();
   assert(InactiveField);
diff --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index 1841a2a4714d89..c3370e2e5286e0 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -1635,7 +1635,58 @@ bool SetThreeWayComparisonField(InterpState &S, CodePtr 
OpPC,
   return true;
 }
 
-bool DoMemcpy(InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest) 
{
+static bool copyComposite(InterpState &S, CodePtr OpPC, const Pointer &Src,
+  Pointer &Dest, bool Activate);
+static bool copyRecord(InterpState &S, CodePtr OpPC, const Pointer &Src,
+   Pointer &Dest, bool Activate = false) {
+  [[maybe_unused]] const Descriptor *SrcDesc = Src.getFieldDesc();
+  const Descriptor *DestDesc = Dest.getFieldDesc();
+
+  auto copyField = [&](const Record::Field &F, bool Activate) -> bool {
+Pointer DestField = Dest.atField(F.Offset);
+if (std::optional FT = S.Ctx.classify(F.Decl->getType())) {
+  TYPE_SWITCH(*FT, {
+DestField.deref() = Src.atField(F.Offset).deref();
+if (Src.atField(F.Offset).isInitialized())
+  DestField.initialize();
+if (Activate)
+  DestField.activate();
+  });
+  return true;
+}
+// Composite field.
+return copyComposite(S, OpPC, Src.atField(F.Offset), DestField, Activate);
+  };
+
+  assert(SrcDesc->isRecord());
+  assert(SrcDesc->ElemRecord == DestDesc->ElemRecord);
+  const Record *R = DestDesc->ElemRecord;
+  for (const Record::Field &F : R->fields()) {
+if (R->isUnion()) {
+  // For unions, only copy the active field.
+  const Pointer &SrcField = Src.atField(F.Offset);
+  if (SrcField.isActive()) {
+if (!copyField(F, /*Activate=*/true))
+  return false;
+  }
+} else {
+  if (!copyField(F, Activate))
+return false;
+}
+  }
+
+  for (const Record::Base &B : R->bases()) {
+Pointer DestBase = Dest.atField(B.Offset);
+if (!copyRecord(S, OpPC, Src.atField(B.Offset), DestBase, Activate))
+  return false;
+  }
+
+  Dest.initialize();
+  return true;
+}
+
+static bool copyComposite(InterpState &S, CodePtr OpPC, const Pointer &Src,
+  Pointer &Dest, bool Activate = false) {
   assert(Src.isLive() && Dest.isLive());
 
   [[maybe_unused]] const Descriptor *SrcDesc = Src.getFieldDesc();
@@ -1657,44 +1708,14 @@ bool DoMemcpy(InterpState &S, CodePtr OpPC, const 
Pointer &Src, Pointer &Dest) {
 return true;
   }
 
-  if (DestDesc->isRecord()) {
-auto copyField = [&](const Record::Field &F, bool Activate) -> bool {
-  Pointer DestField = Dest.atField(F.Offset);
-  if (std::optional FT = S.Ctx.classify(F.Decl->getType())) {
-TYPE_SWITCH(*FT, {
-  DestField.deref() = Src.atField(F.Offset).deref();
-  DestField.initialize();
-  if (Activate)
-DestField.activate();
-});
-return true;
-  }
-  return Invalid(S, OpPC);
-};
-
-assert(SrcDesc->isRecord());
-assert(SrcDesc->ElemRecord == DestDesc->ElemRecord);
-const Record *R = DestDesc->ElemRecord;
-for (const Record::Field &F : R->fields()) {
-  if (R->isUnion()) {
-// For unions, only copy the active field.
-const Pointer &SrcField = Src.atField(F.Offset);
-if (SrcField.isActive()) {
-  if (!copyField(F, /*Activate=*/true))
-return false;
-}
-  } else {
-if (!copyField(F, /*Activate=*/false))
-  return false;
-  }
-}
-return true;
-  }
-
-  // FIXME: Composite types.
-
+  if (DestDesc->isRecord())
+return cop

[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102850)

2024-08-12 Thread Chuanqi Xu via cfe-commits

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


[clang] [X86_64] Fix empty field error in vaarg of C++. (PR #101639)

2024-08-12 Thread Longsheng Mou via cfe-commits

https://github.com/CoTinker updated 
https://github.com/llvm/llvm-project/pull/101639

>From a1d5fffca7b8a63efa338f1aeac3a516145ca569 Mon Sep 17 00:00:00 2001
From: Longsheng Mou 
Date: Fri, 2 Aug 2024 16:36:31 +0800
Subject: [PATCH 1/2] [X86_64] Fix empty field error in vaarg of C++.

Such struct types:
```
struct {
  struct{} a;
  long long b;
};

stuct {
  struct{} a;
  double b;
};
```
For such structures, Lo is NoClass and Hi is Integer/SSE. And when
this structure argument is passed, the high part is passed at
offset 8 in memory. So we should do special handling for these types
in EmitVAArg.
---
 clang/lib/CodeGen/Targets/X86.cpp  |  38 +++--
 clang/test/CodeGenCXX/x86_64-vaarg.cpp | 211 -
 2 files changed, 231 insertions(+), 18 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 26ff4e4ac0a3b5..0347bd01f82ef3 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -3124,26 +3124,40 @@ RValue X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
 CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1));
 
 RegAddr = Tmp.withElementType(LTy);
-  } else if (neededInt) {
-RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, 
gp_offset),
-  LTy, CharUnits::fromQuantity(8));
-
+  } else if (neededInt || neededSSE == 1) {
 // Copy to a temporary if necessary to ensure the appropriate alignment.
 auto TInfo = getContext().getTypeInfoInChars(Ty);
 uint64_t TySize = TInfo.Width.getQuantity();
 CharUnits TyAlign = TInfo.Align;
 
-// Copy into a temporary if the type is more aligned than the
-// register save area.
-if (TyAlign.getQuantity() > 8) {
+llvm::Value *GpOrFpOffset = neededInt ? gp_offset : fp_offset;
+uint64_t Alignment = neededInt ? 8 : 16;
+if (auto Offset = AI.getDirectOffset()) {
   Address Tmp = CGF.CreateMemTemp(Ty);
-  CGF.Builder.CreateMemCpy(Tmp, RegAddr, TySize, false);
-  RegAddr = Tmp;
+  llvm::Type *TyHi = AI.getCoerceToType();
+  llvm::Value *Addr =
+  CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, GpOrFpOffset);
+  llvm::Value *Src = CGF.Builder.CreateAlignedLoad(TyHi, Addr, TyAlign);
+  llvm::Value *PtrOffset = llvm::ConstantInt::get(CGF.Int32Ty, Offset);
+  Address Dst = Address(
+  CGF.Builder.CreateGEP(CGF.Int8Ty, Tmp.getBasePointer(), PtrOffset),
+  LTy, TyAlign);
+  CGF.Builder.CreateStore(Src, Dst);
+  RegAddr = Tmp.withElementType(LTy);
+} else {
+  RegAddr =
+  Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, GpOrFpOffset),
+  LTy, CharUnits::fromQuantity(Alignment));
+
+  // Copy into a temporary if the type is more aligned than the
+  // register save area.
+  if (neededInt && TyAlign.getQuantity() > 8) {
+Address Tmp = CGF.CreateMemTemp(Ty);
+CGF.Builder.CreateMemCpy(Tmp, RegAddr, TySize, false);
+RegAddr = Tmp;
+  }
 }
 
-  } else if (neededSSE == 1) {
-RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, 
fp_offset),
-  LTy, CharUnits::fromQuantity(16));
   } else {
 assert(neededSSE == 2 && "Invalid number of needed registers!");
 // SSE registers are spaced 16 bytes apart in the register save
diff --git a/clang/test/CodeGenCXX/x86_64-vaarg.cpp 
b/clang/test/CodeGenCXX/x86_64-vaarg.cpp
index 439a66deb4fde7..0925d3fe81e139 100644
--- a/clang/test/CodeGenCXX/x86_64-vaarg.cpp
+++ b/clang/test/CodeGenCXX/x86_64-vaarg.cpp
@@ -29,6 +29,7 @@ typedef struct {
 // CHECK-NEXT:[[RETVAL:%.*]] = alloca [[STRUCT_S1:%.*]], align 8
 // CHECK-NEXT:[[Z_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:[[LIST:%.*]] = alloca [1 x %struct.__va_list_tag], align 16
+// CHECK-NEXT:[[TMP:%.*]] = alloca [[STRUCT_S1]], align 8
 // CHECK-NEXT:store i32 [[Z:%.*]], ptr [[Z_ADDR]], align 4
 // CHECK-NEXT:[[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x 
%struct.__va_list_tag], ptr [[LIST]], i64 0, i64 0
 // CHECK-NEXT:call void @llvm.va_start.p0(ptr [[ARRAYDECAY]])
@@ -41,8 +42,11 @@ typedef struct {
 // CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds nuw 
[[STRUCT___VA_LIST_TAG]], ptr [[ARRAYDECAY1]], i32 0, i32 3
 // CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load ptr, ptr [[TMP0]], align 16
 // CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[REG_SAVE_AREA]], i32 
[[FP_OFFSET]]
-// CHECK-NEXT:[[TMP2:%.*]] = add i32 [[FP_OFFSET]], 16
-// CHECK-NEXT:store i32 [[TMP2]], ptr [[FP_OFFSET_P]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = load double, ptr [[TMP1]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr i8, ptr [[TMP]], i32 8
+// CHECK-NEXT:store double [[TMP2]], ptr [[TMP3]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = add i32 [[FP_OFFSET]], 16
+// CHECK-NEXT:store i32 [[TMP4]], ptr [[FP_OFFSET_P]], align 4
 // CHECK-NEXT:br label [[VAARG_

[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102850)

2024-08-12 Thread Chuanqi Xu via cfe-commits

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


[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102850)

2024-08-12 Thread Chuanqi Xu via cfe-commits

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


[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102850)

2024-08-12 Thread Chuanqi Xu via cfe-commits

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


[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102850)

2024-08-12 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/102850

>From 598ce1867b5ac36aa6da48be0556bb637ce1ddb0 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Mon, 12 Aug 2024 13:31:35 +0800
Subject: [PATCH] [Serialization] Add a callback to register new created
 predefined decls for DeserializationListener

Close https://github.com/llvm/llvm-project/issues/102684

The root cause of the issue is, it is possible that the predefined decl
is not registered at the beginning of writing a module file but got
created during the process of writing from reading.

This is incorrect. The predefined decls should always be predefined
decls.

Another deep thought about the issue is, we shouldn't read any new
things after we start to write the module file. But this is another
deeper question.
---
 .../clang/Frontend/MultiplexConsumer.h|  1 +
 .../ASTDeserializationListener.h  |  2 +
 clang/include/clang/Serialization/ASTReader.h |  3 +
 clang/include/clang/Serialization/ASTWriter.h |  1 +
 clang/lib/Frontend/MultiplexConsumer.cpp  |  5 +
 clang/lib/Serialization/ASTReader.cpp | 91 +++
 clang/lib/Serialization/ASTWriter.cpp |  6 ++
 clang/test/Modules/pr102684.cppm  | 38 
 8 files changed, 129 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/Modules/pr102684.cppm

diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index e49e3392d1f317..3a7670d7a51aa6 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -36,6 +36,7 @@ class MultiplexASTDeserializationListener : public 
ASTDeserializationListener {
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
   void DeclRead(GlobalDeclID ID, const Decl *D) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h 
b/clang/include/clang/Serialization/ASTDeserializationListener.h
index 1d81a9ae3fe2eb..ea96faa07c1917 100644
--- a/clang/include/clang/Serialization/ASTDeserializationListener.h
+++ b/clang/include/clang/Serialization/ASTDeserializationListener.h
@@ -45,6 +45,8 @@ class ASTDeserializationListener {
   virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { }
   /// A decl was deserialized from the AST file.
   virtual void DeclRead(GlobalDeclID ID, const Decl *D) {}
+  /// A predefined decl was built during the serialization.
+  virtual void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {}
   /// A selector was read from the AST file.
   virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
   /// A macro definition was read from the AST file.
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 549396a3b6b387..a0e90e62bd60ec 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1559,6 +1559,9 @@ class ASTReader
   std::pair
   translateTypeIDToIndex(serialization::TypeID ID) const;
 
+  /// Get a predefined Decl from ASTContext.
+  Decl *getPredefinedDecl(PredefinedDeclIDs ID);
+
 public:
   /// Load the AST file and validate its contents against the given
   /// Preprocessor.
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 71a7c28047e318..a4cc95cd1373fa 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -869,6 +869,7 @@ class ASTWriter : public ASTDeserializationListener,
   void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) 
override;
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/lib/Frontend/MultiplexConsumer.cpp 
b/clang/lib/Frontend/MultiplexConsumer.cpp
index 651c55aeed5408..2158d176d18929 100644
--- a/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -58,6 +58,11 @@ void 
MultiplexASTDeserializationListener::DeclRead(GlobalDeclID ID,
 Listeners[i]->DeclRead(ID, D);
 }
 
+void 
MultiplexASTDeserializationListener::PredefinedDeclBuilt(PredefinedDeclIDs ID, 
const Decl *D) {
+  for (size_t i = 0, e = Listene

[clang] [llvm] [DataLayout] Remove constructor accepting a pointer to Module (PR #102841)

2024-08-12 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102850)

2024-08-12 Thread Chuanqi Xu via cfe-commits

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


[clang] d469794 - [clang] Avoid triggering vtable instantiation for C++23 constexpr dtor (#102605)

2024-08-12 Thread via cfe-commits

Author: Mariya Podchishchaeva
Date: 2024-08-12T09:08:46+02:00
New Revision: d469794d0cdfd2fea50a6ce0c0e33abb242d744c

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

LOG: [clang] Avoid triggering vtable instantiation for C++23 constexpr dtor 
(#102605)

In C++23 anything can be constexpr, including a dtor of a class whose
members and bases don't have constexpr dtors. Avoid early triggering of
vtable instantiation int this case.

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

Added: 
clang/test/SemaCXX/gh102293.cpp

Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index b07e555afcaccf..c87edf41f35cee 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -7042,11 +7042,38 @@ void Sema::CheckCompletedCXXClass(Scope *S, 
CXXRecordDecl *Record) {
   }
 }
 
+bool EffectivelyConstexprDestructor = true;
+// Avoid triggering vtable instantiation due to a dtor that is not
+// "effectively constexpr" for better compatibility.
+// See https://github.com/llvm/llvm-project/issues/102293 for more info.
+if (isa(M)) {
+  auto Check = [](QualType T, auto &&Check) -> bool {
+const CXXRecordDecl *RD =
+T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
+if (!RD || !RD->isCompleteDefinition())
+  return true;
+
+if (!RD->hasConstexprDestructor())
+  return false;
+
+for (const CXXBaseSpecifier &B : RD->bases())
+  if (!Check(B.getType(), Check))
+return false;
+for (const FieldDecl *FD : RD->fields())
+  if (!Check(FD->getType(), Check))
+return false;
+return true;
+  };
+  EffectivelyConstexprDestructor =
+  Check(QualType(Record->getTypeForDecl(), 0), Check);
+}
+
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
 if (CSM != CXXSpecialMemberKind::Invalid && !M->isDeleted() &&
-M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods())
+M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods() &&
+EffectivelyConstexprDestructor)
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)

diff  --git a/clang/test/SemaCXX/gh102293.cpp b/clang/test/SemaCXX/gh102293.cpp
new file mode 100644
index 00..30629fc03bf6a9
--- /dev/null
+++ b/clang/test/SemaCXX/gh102293.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  static void destroy() {
+T t;
+++t;
+}
+
+struct Incomplete;
+
+template  struct HasD {
+  ~HasD() { destroy(); }
+};
+
+struct HasVT {
+  virtual ~HasVT();
+};
+
+struct S : HasVT {
+  HasD<> v;
+};
+



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


[clang] [clang] Avoid triggering vtable instantiation for C++23 constexpr dtor (PR #102605)

2024-08-12 Thread Mariya Podchishchaeva via cfe-commits

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


[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102855)

2024-08-12 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 created 
https://github.com/llvm/llvm-project/pull/102855

Close https://github.com/llvm/llvm-project/issues/102684

The root cause of the issue is, it is possible that the predefined decl is not 
registered at the beginning of writing a module file but got created during the 
process of writing from reading.

This is incorrect. The predefined decls should always be predefined decls.

Another deep thought about the issue is, we shouldn't read any new things after 
we start to write the module file. But this is another deeper question.

>From 598ce1867b5ac36aa6da48be0556bb637ce1ddb0 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Mon, 12 Aug 2024 13:31:35 +0800
Subject: [PATCH] [Serialization] Add a callback to register new created
 predefined decls for DeserializationListener

Close https://github.com/llvm/llvm-project/issues/102684

The root cause of the issue is, it is possible that the predefined decl
is not registered at the beginning of writing a module file but got
created during the process of writing from reading.

This is incorrect. The predefined decls should always be predefined
decls.

Another deep thought about the issue is, we shouldn't read any new
things after we start to write the module file. But this is another
deeper question.
---
 .../clang/Frontend/MultiplexConsumer.h|  1 +
 .../ASTDeserializationListener.h  |  2 +
 clang/include/clang/Serialization/ASTReader.h |  3 +
 clang/include/clang/Serialization/ASTWriter.h |  1 +
 clang/lib/Frontend/MultiplexConsumer.cpp  |  5 +
 clang/lib/Serialization/ASTReader.cpp | 91 +++
 clang/lib/Serialization/ASTWriter.cpp |  6 ++
 clang/test/Modules/pr102684.cppm  | 38 
 8 files changed, 129 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/Modules/pr102684.cppm

diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index e49e3392d1f317..3a7670d7a51aa6 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -36,6 +36,7 @@ class MultiplexASTDeserializationListener : public 
ASTDeserializationListener {
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
   void DeclRead(GlobalDeclID ID, const Decl *D) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h 
b/clang/include/clang/Serialization/ASTDeserializationListener.h
index 1d81a9ae3fe2eb..ea96faa07c1917 100644
--- a/clang/include/clang/Serialization/ASTDeserializationListener.h
+++ b/clang/include/clang/Serialization/ASTDeserializationListener.h
@@ -45,6 +45,8 @@ class ASTDeserializationListener {
   virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { }
   /// A decl was deserialized from the AST file.
   virtual void DeclRead(GlobalDeclID ID, const Decl *D) {}
+  /// A predefined decl was built during the serialization.
+  virtual void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {}
   /// A selector was read from the AST file.
   virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
   /// A macro definition was read from the AST file.
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 549396a3b6b387..a0e90e62bd60ec 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1559,6 +1559,9 @@ class ASTReader
   std::pair
   translateTypeIDToIndex(serialization::TypeID ID) const;
 
+  /// Get a predefined Decl from ASTContext.
+  Decl *getPredefinedDecl(PredefinedDeclIDs ID);
+
 public:
   /// Load the AST file and validate its contents against the given
   /// Preprocessor.
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 71a7c28047e318..a4cc95cd1373fa 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -869,6 +869,7 @@ class ASTWriter : public ASTDeserializationListener,
   void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) 
override;
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/

[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102855)

2024-08-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)


Changes

Close https://github.com/llvm/llvm-project/issues/102684

The root cause of the issue is, it is possible that the predefined decl is not 
registered at the beginning of writing a module file but got created during the 
process of writing from reading.

This is incorrect. The predefined decls should always be predefined decls.

Another deep thought about the issue is, we shouldn't read any new things after 
we start to write the module file. But this is another deeper question.

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


8 Files Affected:

- (modified) clang/include/clang/Frontend/MultiplexConsumer.h (+1) 
- (modified) clang/include/clang/Serialization/ASTDeserializationListener.h 
(+2) 
- (modified) clang/include/clang/Serialization/ASTReader.h (+3) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+1) 
- (modified) clang/lib/Frontend/MultiplexConsumer.cpp (+5) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+73-18) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+6) 
- (added) clang/test/Modules/pr102684.cppm (+38) 


``diff
diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index e49e3392d1f317..3a7670d7a51aa6 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -36,6 +36,7 @@ class MultiplexASTDeserializationListener : public 
ASTDeserializationListener {
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
   void DeclRead(GlobalDeclID ID, const Decl *D) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h 
b/clang/include/clang/Serialization/ASTDeserializationListener.h
index 1d81a9ae3fe2eb..ea96faa07c1917 100644
--- a/clang/include/clang/Serialization/ASTDeserializationListener.h
+++ b/clang/include/clang/Serialization/ASTDeserializationListener.h
@@ -45,6 +45,8 @@ class ASTDeserializationListener {
   virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { }
   /// A decl was deserialized from the AST file.
   virtual void DeclRead(GlobalDeclID ID, const Decl *D) {}
+  /// A predefined decl was built during the serialization.
+  virtual void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {}
   /// A selector was read from the AST file.
   virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
   /// A macro definition was read from the AST file.
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 549396a3b6b387..a0e90e62bd60ec 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1559,6 +1559,9 @@ class ASTReader
   std::pair
   translateTypeIDToIndex(serialization::TypeID ID) const;
 
+  /// Get a predefined Decl from ASTContext.
+  Decl *getPredefinedDecl(PredefinedDeclIDs ID);
+
 public:
   /// Load the AST file and validate its contents against the given
   /// Preprocessor.
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 71a7c28047e318..a4cc95cd1373fa 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -869,6 +869,7 @@ class ASTWriter : public ASTDeserializationListener,
   void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) 
override;
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/lib/Frontend/MultiplexConsumer.cpp 
b/clang/lib/Frontend/MultiplexConsumer.cpp
index 651c55aeed5408..2158d176d18929 100644
--- a/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -58,6 +58,11 @@ void 
MultiplexASTDeserializationListener::DeclRead(GlobalDeclID ID,
 Listeners[i]->DeclRead(ID, D);
 }
 
+void 
MultiplexASTDeserializationListener::PredefinedDeclBuilt(PredefinedDeclIDs ID, 
const Decl *D) {
+  for (size_t i = 0, e = Listeners.size(); i != e; ++i)
+Listeners[i]->PredefinedDeclBuilt(ID, D);
+}
+
 void MultiplexASTDeserializationListener::SelectorRead(
 serialization::SelectorID ID, Selector Sel) {
   

[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102855)

2024-08-12 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 cb372bd5e789a7d5f1945b476e643d4abfd18f35 
598ce1867b5ac36aa6da48be0556bb637ce1ddb0 --extensions cpp,h,cppm -- 
clang/test/Modules/pr102684.cppm 
clang/include/clang/Frontend/MultiplexConsumer.h 
clang/include/clang/Serialization/ASTDeserializationListener.h 
clang/include/clang/Serialization/ASTReader.h 
clang/include/clang/Serialization/ASTWriter.h 
clang/lib/Frontend/MultiplexConsumer.cpp clang/lib/Serialization/ASTReader.cpp 
clang/lib/Serialization/ASTWriter.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Frontend/MultiplexConsumer.cpp 
b/clang/lib/Frontend/MultiplexConsumer.cpp
index 2158d176d1..8c3effbd00 100644
--- a/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -58,7 +58,8 @@ void 
MultiplexASTDeserializationListener::DeclRead(GlobalDeclID ID,
 Listeners[i]->DeclRead(ID, D);
 }
 
-void 
MultiplexASTDeserializationListener::PredefinedDeclBuilt(PredefinedDeclIDs ID, 
const Decl *D) {
+void MultiplexASTDeserializationListener::PredefinedDeclBuilt(
+PredefinedDeclIDs ID, const Decl *D) {
   for (size_t i = 0, e = Listeners.size(); i != e; ++i)
 Listeners[i]->PredefinedDeclBuilt(ID, D);
 }

``




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


[clang] [llvm] [X86][AVX10.2] Support saturated converts (PR #102592)

2024-08-12 Thread Phoebe Wang via cfe-commits


@@ -2122,6 +2122,36 @@ TARGET_BUILTIN(__builtin_ia32_vpdpwuud256, 
"V8iV8iV8iV8i", "nV:256:", "avxvnniin
 TARGET_BUILTIN(__builtin_ia32_vpdpwuuds128, "V4iV4iV4iV4i", "nV:128:", 
"avxvnniint16|avx10.2-256")
 TARGET_BUILTIN(__builtin_ia32_vpdpwuuds256, "V8iV8iV8iV8i", "nV:256:", 
"avxvnniint16|avx10.2-256")
 
+// AVX10.2 SATCVT-DS
+TARGET_BUILTIN(__builtin_ia32_vcvttssd2si32, "iV2dIi", "ncV:128:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vcvttssd2usi32, "UiV2dIi", "ncV:128:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vcvttsss2si32, "iV4fIi", "ncV:128:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vcvttsss2usi32, "UiV4fIi", "ncV:128:", 
"avx10.2-256")
+TARGET_BUILTIN(__builtin_ia32_vcvttpd2dqs128_mask, "V4iV2dV4iUc", "nV:128:", 
"avx10.2-256")

phoebewang wrote:

Why don't use `sis32/usis32`?

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


[clang] [llvm] [X86][AVX10.2] Support saturated converts (PR #102592)

2024-08-12 Thread Phoebe Wang via cfe-commits

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


[clang] [llvm] [DataLayout] Remove constructor accepting a pointer to Module (PR #102841)

2024-08-12 Thread Sergei Barannikov via cfe-commits

https://github.com/s-barannikov updated 
https://github.com/llvm/llvm-project/pull/102841

>From 8382e3ed0a5546fff4ed662a7abbaa39e2f0c22a Mon Sep 17 00:00:00 2001
From: Sergei Barannikov 
Date: Mon, 12 Aug 2024 04:08:54 +0300
Subject: [PATCH] [DataLayout] Remove constructor accepting a pointer to Module

The constructor initializes `*this` with `M->getDataLayout()`, which
is effectively the same as calling the copy constructor.
There does not seem to be a case where a copy would be necessary.
---
 clang/lib/CodeGen/CGObjCGNU.cpp   | 31 +--
 clang/lib/CodeGen/CodeGenTBAA.cpp |  2 +-
 llvm/include/llvm/IR/DataLayout.h |  6 
 llvm/lib/Analysis/InlineCost.cpp  |  3 +-
 .../CodeGen/AssignmentTrackingAnalysis.cpp|  3 +-
 llvm/lib/FuzzMutate/RandomIRBuilder.cpp   |  4 +--
 llvm/lib/IR/DataLayout.cpp|  7 -
 llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp  |  2 +-
 llvm/lib/Transforms/Utils/InlineFunction.cpp  |  4 +--
 llvm/unittests/IR/IRBuilderTest.cpp   |  7 ++---
 llvm/unittests/SandboxIR/SandboxIRTest.cpp|  4 +--
 11 files changed, 28 insertions(+), 45 deletions(-)

diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index ca5804018227ea..adc7cdbfded880 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -278,9 +278,9 @@ class CGObjCGNU : public CGObjCRuntime {
   Fields.addInt(IntTy, count);
   // int size; (only in GNUstep v2 ABI.
   if (isRuntime(ObjCRuntime::GNUstep, 2)) {
-llvm::DataLayout td(&TheModule);
-Fields.addInt(IntTy, td.getTypeSizeInBits(PropertyMetadataTy) /
-CGM.getContext().getCharWidth());
+const llvm::DataLayout &DL = TheModule.getDataLayout();
+Fields.addInt(IntTy, DL.getTypeSizeInBits(PropertyMetadataTy) /
+ CGM.getContext().getCharWidth());
   }
   // struct objc_property_list *next;
   Fields.add(NULLPtr);
@@ -1190,9 +1190,9 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 // int count;
 MethodList.addInt(IntTy, Methods.size());
 // int size; // sizeof(struct objc_method_description)
-llvm::DataLayout td(&TheModule);
-MethodList.addInt(IntTy, td.getTypeSizeInBits(ObjCMethodDescTy) /
-CGM.getContext().getCharWidth());
+const llvm::DataLayout &DL = TheModule.getDataLayout();
+MethodList.addInt(IntTy, DL.getTypeSizeInBits(ObjCMethodDescTy) /
+ CGM.getContext().getCharWidth());
 // struct objc_method_description[]
 auto MethodArray = MethodList.beginArray(ObjCMethodDescTy);
 for (auto *M : Methods) {
@@ -1828,7 +1828,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   int ivar_count = 0;
   for (const ObjCIvarDecl *IVD = classDecl->all_declared_ivar_begin(); IVD;
IVD = IVD->getNextIvar()) ivar_count++;
-  llvm::DataLayout td(&TheModule);
+  const llvm::DataLayout &DL = TheModule.getDataLayout();
   // struct objc_ivar_list *ivars;
   ConstantInitBuilder b(CGM);
   auto ivarListBuilder = b.beginStruct();
@@ -1841,8 +1841,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 PtrToInt8Ty,
 Int32Ty,
 Int32Ty);
-  ivarListBuilder.addInt(SizeTy, td.getTypeSizeInBits(ObjCIvarTy) /
-  CGM.getContext().getCharWidth());
+  ivarListBuilder.addInt(SizeTy, DL.getTypeSizeInBits(ObjCIvarTy) /
+ CGM.getContext().getCharWidth());
   // struct objc_ivar ivars[]
   auto ivarArrayBuilder = ivarListBuilder.beginArray();
   for (const ObjCIvarDecl *IVD = classDecl->all_declared_ivar_begin(); IVD;
@@ -3019,9 +3019,9 @@ GenerateMethodList(StringRef ClassName,
   bool isV2ABI = isRuntime(ObjCRuntime::GNUstep, 2);
   if (isV2ABI) {
 // size_t size;
-llvm::DataLayout td(&TheModule);
-MethodList.addInt(SizeTy, td.getTypeSizeInBits(ObjCMethodTy) /
-CGM.getContext().getCharWidth());
+const llvm::DataLayout &DL = TheModule.getDataLayout();
+MethodList.addInt(SizeTy, DL.getTypeSizeInBits(ObjCMethodTy) /
+  CGM.getContext().getCharWidth());
 ObjCMethodTy =
   llvm::StructType::get(CGM.getLLVMContext(), {
 IMPTy,   // Method pointer
@@ -3161,10 +3161,9 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
   Elements.addInt(LongTy, info);
   // instance_size
   if (isMeta) {
-llvm::DataLayout td(&TheModule);
-Elements.addInt(LongTy,
-td.getTypeSizeInBits(ClassTy) /
-  CGM.getContext().getCharWidth());
+const llvm::DataLayout &DL = TheModule.getDataLayout();
+Elements.addInt(LongTy, DL.getTypeSizeInBits(ClassTy) /
+CGM.getContext().getCharWidth());
   } else
 Elements.add(InstanceSize);
   // ivars
diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp 
b/clang/lib/CodeGen/CodeGenTBAA.cpp

[clang] Revert "Revert "[clang][Interp] Improve "in call to" call argument printing"" (PR #102786)

2024-08-12 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> I am not sure what is going on there, maybe it needs // UNSUPPORTED: asan
> 
> I am not going to reland, it's just a notice, to make sure you noticed the 
> revert.

Looks like it some kind of flakiness in the test.  It returned 
https://lab.llvm.org/buildbot/#/builders/52/builds/1526/steps/10/logs/stdio 
without [Interp] patches.
Please reland this patch at your convenience. Fill free to merge this PR if you 
like.
Sorry for inconvenience. 

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


[clang] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2024-08-12 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/102857

Some things are not completed yet:

- [ ] CWG2369 for lambdas. We currently don't perform the concept checking 
before the substitution into lambdas because that requires us to 
put/instantiate captures to the scope, which is much more arduous than we 
should've done for ordinary functions. So constraints checking for lambdas are 
left as-is for now.
- [ ] Code cleanups, refactoring.
- [ ] Instantiate "used" parameters that a type constraint references to. 
Currently this patch instantiates all function parameters before checking the 
constraint.

Closes https://github.com/llvm/llvm-project/issues/54440

>From de90a38cd1e8c1ea9316a05e0f68a56fd5a7240b Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 11 Aug 2024 16:51:34 +0800
Subject: [PATCH 1/2] CWG 2369

---
 clang/include/clang/Sema/Sema.h   |  3 +-
 clang/lib/Sema/SemaConcept.cpp|  2 +-
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 94 ---
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  5 +-
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  | 48 +++---
 5 files changed, 122 insertions(+), 30 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ec6367eccea01..bd7b4c2d9b97ec 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13058,7 +13058,8 @@ class Sema final : public SemaBase {
   std::optional> Innermost = std::nullopt,
   bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
   bool ForConstraintInstantiation = false,
-  bool SkipForSpecialization = false);
+  bool SkipForSpecialization = false,
+  MultiLevelTemplateArgumentList *Merged = nullptr);
 
   /// RAII object to handle the state changes required to synthesize
   /// a function body.
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index d4c9d044985e34..45318109d47963 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -842,7 +842,7 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
 bool ForOverloadResolution) {
   // Don't check constraints if the function is dependent. Also don't check if
   // this is a function template specialization, as the call to
-  // CheckinstantiatedFunctionTemplateConstraints after this will check it
+  // CheckInstantiatedFunctionTemplateConstraints after this will check it
   // better.
   if (FD->isDependentContext() ||
   FD->getTemplatedKind() ==
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 978f1a9dc1a933..1880104625e4cb 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3834,18 +3834,6 @@ TemplateDeductionResult 
Sema::FinishTemplateArgumentDeduction(
   Result != TemplateDeductionResult::Success)
 return Result;
 
-  // C++ [temp.deduct.call]p10: [DR1391]
-  //   If deduction succeeds for all parameters that contain
-  //   template-parameters that participate in template argument deduction,
-  //   and all template arguments are explicitly specified, deduced, or
-  //   obtained from default template arguments, remaining parameters are then
-  //   compared with the corresponding arguments. For each remaining parameter
-  //   P with a type that was non-dependent before substitution of any
-  //   explicitly-specified template arguments, if the corresponding argument
-  //   A cannot be implicitly converted to P, deduction fails.
-  if (CheckNonDependent())
-return TemplateDeductionResult::NonDependentConversionFailure;
-
   // Form the template argument list from the deduced template arguments.
   TemplateArgumentList *SugaredDeducedArgumentList =
   TemplateArgumentList::CreateCopy(Context, SugaredBuilder);
@@ -3875,6 +3863,76 @@ TemplateDeductionResult 
Sema::FinishTemplateArgumentDeduction(
 FD = const_cast(FDFriend);
 Owner = FD->getLexicalDeclContext();
   }
+#if 1
+  // FIXME: We have to partially instantiate lambda's captures for constraint
+  // evaluation.
+  if (!isLambdaCallOperator(FD) && !isLambdaConversionOperator(FD) &&
+  (!PartialOverloading ||
+   (CanonicalBuilder.size() ==
+FunctionTemplate->getTemplateParameters()->size( {
+FunctionTemplateDecl *Template = FunctionTemplate->getCanonicalDecl();
+FunctionDecl *FD = Template->getTemplatedDecl();
+SmallVector TemplateAC;
+Template->getAssociatedConstraints(TemplateAC);
+if (!TemplateAC.empty()) {
+
+  // Enter the scope of this instantiation. We don't use
+  // PushDeclContext because we don't have a scope.
+  LocalInstantiationScope Scope(*this);
+
+  // Collect the list of template arguments relative to the 'primary'
+  // template. We need the entire list, since the constraint is completely
+  // uninstantiated at 

[clang] [Interp] Mark the test unsupported with Asan (PR #102859)

2024-08-12 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/102859

It's very flaky recently.

Issue #102858


>From fcf5476d8e8ef543a50d33b379c79e761374b9ee Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Mon, 12 Aug 2024 00:42:28 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/test/Interpreter/const.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/test/Interpreter/const.cpp b/clang/test/Interpreter/const.cpp
index 57fd880400e6a1..6cafc777c626e7 100644
--- a/clang/test/Interpreter/const.cpp
+++ b/clang/test/Interpreter/const.cpp
@@ -2,6 +2,9 @@
 // see https://github.com/llvm/llvm-project/issues/68092
 // XFAIL: host={{.*}}-windows-msvc
 
+// The test is flaky with asan.
+// UNSUPPORTED: asan
+
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
 

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


[clang] [Interp] Mark the test unsupported with Asan (PR #102859)

2024-08-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)


Changes

It's very flaky recently.

Issue #102858


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


1 Files Affected:

- (modified) clang/test/Interpreter/const.cpp (+3) 


``diff
diff --git a/clang/test/Interpreter/const.cpp b/clang/test/Interpreter/const.cpp
index 57fd880400e6a1..6cafc777c626e7 100644
--- a/clang/test/Interpreter/const.cpp
+++ b/clang/test/Interpreter/const.cpp
@@ -2,6 +2,9 @@
 // see https://github.com/llvm/llvm-project/issues/68092
 // XFAIL: host={{.*}}-windows-msvc
 
+// The test is flaky with asan.
+// UNSUPPORTED: asan
+
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
 

``




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


[clang] [clang-format] Fix a serious bug in `git clang-format -f` (PR #102629)

2024-08-12 Thread Stefan Pantic via cfe-commits

stefanpantic-pdftools wrote:

FYI: this breaks the tool:

```bash
git clang-format --binary /usr/bin/clang-format --extensions $INPUT_EXTENSIONS 
--diff origin/$INPUT_TARGET_BRANCH origin/$INPUT_SOURCE_BRANCH
`/usr/bin/clang-format -list-ignored` returned 1
clang-format: Unknown command line argument '-list-ignored'.  Try: 
'/usr/bin/clang-format --help'
clang-format: Did you mean '--lines'?
```

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


[clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-12 Thread via cfe-commits

https://github.com/Dhruv-Srivastava-IBM converted_to_draft 
https://github.com/llvm/llvm-project/pull/102601
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a serious bug in `git clang-format -f` (PR #102629)

2024-08-12 Thread Owen Pan via cfe-commits

owenca wrote:

You need to use the clang-format built from this patch, which adds the new 
clang-format `-list-ignored` option.

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


[clang] [clang-format] Fix a serious bug in `git clang-format -f` (PR #102629)

2024-08-12 Thread Stefan Pantic via cfe-commits

stefanpantic-pdftools wrote:

Gotcha, thanks!

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


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-08-12 Thread via cfe-commits

zmodem wrote:

> no. I do not want that complicated file structure. I just want normal GNU 
> style's sysroot.
>
> x86_64-windows-msvc sysroot should have exact the same file struct as 
> x86_64-windows-gnu.

The -msvc triples are designed to work with libraries from MSVC and the Windows 
SDK. We can't change how those are organized.

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


[clang] [clang][analyzer] Remove array bounds check from PointerSubChecker (PR #102580)

2024-08-12 Thread Balázs Kéri via cfe-commits

https://github.com/balazske updated 
https://github.com/llvm/llvm-project/pull/102580

From 08367f06167d8b12ee4de06a37915decd1e754e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Fri, 9 Aug 2024 09:31:55 +0200
Subject: [PATCH 1/3] [clang][analyzer] Remove array bounds check from
 PointerSubChecker

At pointer subtraction only pointers are allowed that point into
an array (or one after the end), this fact was checker by the checker.
This check is now removed because it is a special case of array
indexing error that is handled by a different checker (ArrayBoundsV2).
At least theoretically the array bounds checker (when finalized)
should find the same cases that were detected by the PointerSubChecker.
---
 clang/docs/analyzer/checkers.rst  | 17 ++--
 .../Checkers/PointerSubChecker.cpp| 93 +--
 clang/test/Analysis/pointer-sub.c |  9 --
 3 files changed, 12 insertions(+), 107 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 55832d20bd27a1..df3a013ce269c7 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2501,7 +2501,14 @@ alpha.core.PointerSub (C)
 Check for pointer subtractions on two pointers pointing to different memory
 chunks. According to the C standard §6.5.6 only subtraction of pointers that
 point into (or one past the end) the same array object is valid (for this
-purpose non-array variables are like arrays of size 1).
+purpose non-array variables are like arrays of size 1). This checker only
+searches for different memory objects at subtraction, but does not check if the
+array index is correct (
+:ref:`alpha.security.ArrayBoundsV2 ` checks the
+index to some extent).
+
+Furthermore, only cases are reported where stack-allocated objects are involved
+(no warnings on pointers to memory allocated by `malloc`).
 
 .. code-block:: c
 
@@ -2511,11 +2518,6 @@ purpose non-array variables are like arrays of size 1).
x = &d[4] - &c[1]; // warn: 'c' and 'd' are different arrays
x = (&a + 1) - &a;
x = &b - &a; // warn: 'a' and 'b' are different variables
-   x = (&a + 2) - &a; // warn: for a variable it is only valid to have a 
pointer
-  // to one past the address of it
-   x = &c[10] - &c[0];
-   x = &c[11] - &c[0]; // warn: index larger than one past the end
-   x = &c[-1] - &c[0]; // warn: negative index
  }
 
  struct S {
@@ -2538,9 +2540,6 @@ offsets of members in a structure, using pointer 
subtractions. This is still
 undefined behavior according to the standard and code like this can be replaced
 with the `offsetof` macro.
 
-The checker only reports cases where stack-allocated objects are involved (no
-warnings on pointers to memory allocated by `malloc`).
-
 .. _alpha-core-StackAddressAsyncEscape:
 
 alpha.core.StackAddressAsyncEscape (C)
diff --git a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
index b856b0edc61514..f0dc5efd75f7d6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
@@ -31,99 +31,12 @@ class PointerSubChecker
   const llvm::StringLiteral Msg_MemRegionDifferent =
   "Subtraction of two pointers that do not point into the same array "
   "is undefined behavior.";
-  const llvm::StringLiteral Msg_LargeArrayIndex =
-  "Using an array index greater than the array size at pointer subtraction 
"
-  "is undefined behavior.";
-  const llvm::StringLiteral Msg_NegativeArrayIndex =
-  "Using a negative array index at pointer subtraction "
-  "is undefined behavior.";
-  const llvm::StringLiteral Msg_BadVarIndex =
-  "Indexing the address of a variable with other than 1 at this place "
-  "is undefined behavior.";
-
-  /// Check that an array is indexed in the allowed range that is 0 to "one
-  /// after the end". The "array" can be address of a non-array variable.
-  /// @param E Expression of the pointer subtraction.
-  /// @param ElemReg An indexed region in the subtraction expression.
-  /// @param Reg Region of the other side of the expression.
-  bool checkArrayBounds(CheckerContext &C, const Expr *E,
-const ElementRegion *ElemReg,
-const MemRegion *Reg) const;
 
 public:
   void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const;
 };
 }
 
-static bool isArrayVar(const MemRegion *R) {
-  while (R) {
-if (isa(R))
-  return true;
-if (const auto *ER = dyn_cast(R))
-  R = ER->getSuperRegion();
-else
-  return false;
-  }
-  return false;
-}
-
-bool PointerSubChecker::checkArrayBounds(CheckerContext &C, const Expr *E,
- const ElementRegion *ElemReg,
- const MemRegion *Reg) const {
-  if (!ElemReg)
-return true;
-
-  const MemRegion *SuperReg = ElemReg-

[clang] [clang] Fixing Clang HIP inconsistent order for template functions (PR #101627)

2024-08-12 Thread via cfe-commits

Ritanya-B-Bharadwaj wrote:

ping

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


[clang] [Interp] Mark the test unsupported with Asan (PR #102859)

2024-08-12 Thread Jonas Hahnfeld via cfe-commits

hahnjo wrote:

Quick question for my understanding: With `spr` we don't get meaningful commit 
messages anymore? That's quite unfortunate...

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


[clang] b680862 - [analyzer][NFC] Trivial refactoring of region invalidation (#102456)

2024-08-12 Thread via cfe-commits

Author: Donát Nagy
Date: 2024-08-12T10:34:54+02:00
New Revision: b68086241b2f386fc5cc53af2b3ee90624104dc4

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

LOG: [analyzer][NFC] Trivial refactoring of region invalidation (#102456)

This commit removes `invalidateRegionsImpl()`, moving its body to
`invalidateRegions(ValueList Values, ...)`, because it was a completely
useless layer of indirection.

Moreover I'm fixing some strange indentation within this function body
and renaming two variables to the proper `UpperCamelCase` format.

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
clang/lib/StaticAnalyzer/Core/ProgramState.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
index 51d76dc257ee94..9889d2604a890e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -484,17 +484,6 @@ class ProgramState : public llvm::FoldingSetNode {
   friend void ProgramStateRetain(const ProgramState *state);
   friend void ProgramStateRelease(const ProgramState *state);
 
-  /// \sa invalidateValues()
-  /// \sa invalidateRegions()
-  ProgramStateRef
-  invalidateRegionsImpl(ArrayRef Values,
-const Expr *E, unsigned BlockCount,
-const LocationContext *LCtx,
-bool ResultsInSymbolEscape,
-InvalidatedSymbols *IS,
-RegionAndSymbolInvalidationTraits *HTraits,
-const CallEvent *Call) const;
-
   SVal wrapSymbolicRegion(SVal Base) const;
 };
 

diff  --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp 
b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
index f82cd944750a3c..e6d3399a219424 100644
--- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -159,8 +159,8 @@ ProgramState::invalidateRegions(RegionList Regions,
   for (const MemRegion *Reg : Regions)
 Values.push_back(loc::MemRegionVal(Reg));
 
-  return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
-   IS, ITraits, Call);
+  return invalidateRegions(Values, E, Count, LCtx, CausedByPointerEscape, IS,
+   Call, ITraits);
 }
 
 ProgramStateRef
@@ -172,18 +172,6 @@ ProgramState::invalidateRegions(ValueList Values,
  const CallEvent *Call,
  RegionAndSymbolInvalidationTraits *ITraits) const 
{
 
-  return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
-   IS, ITraits, Call);
-}
-
-ProgramStateRef
-ProgramState::invalidateRegionsImpl(ValueList Values,
-const Expr *E, unsigned Count,
-const LocationContext *LCtx,
-bool CausedByPointerEscape,
-InvalidatedSymbols *IS,
-RegionAndSymbolInvalidationTraits *ITraits,
-const CallEvent *Call) const {
   ProgramStateManager &Mgr = getStateManager();
   ExprEngine &Eng = Mgr.getOwningEngine();
 
@@ -197,21 +185,18 @@ ProgramState::invalidateRegionsImpl(ValueList Values,
 
   StoreManager::InvalidatedRegions TopLevelInvalidated;
   StoreManager::InvalidatedRegions Invalidated;
-  const StoreRef &newStore
-  = Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call,
-*IS, *ITraits, &TopLevelInvalidated,
-&Invalidated);
+  const StoreRef &NewStore = Mgr.StoreMgr->invalidateRegions(
+  getStore(), Values, E, Count, LCtx, Call, *IS, *ITraits,
+  &TopLevelInvalidated, &Invalidated);
 
-  ProgramStateRef newState = makeWithStore(newStore);
+  ProgramStateRef NewState = makeWithStore(NewStore);
 
   if (CausedByPointerEscape) {
-newState = Eng.notifyCheckersOfPointerEscape(newState, IS,
- TopLevelInvalidated,
- Call,
- *ITraits);
+NewState = Eng.notifyCheckersOfPointerEscape(
+NewState, IS, TopLevelInvalidated, Call, *ITraits);
   }
 
-  return Eng.processRegionChanges(newState, IS, TopLevelInvalidated,
+  return Eng.processRegionChanges(NewState, IS, TopLevelInvalidated,
   Invalidated, LCtx, Call);
 }
 



___
cfe-commits maili

[clang] [analyzer][NFC] Trivial refactoring of region invalidation (PR #102456)

2024-08-12 Thread Donát Nagy via cfe-commits

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


[clang] [analyzer] Model overflow builtins (PR #102602)

2024-08-12 Thread Donát Nagy via cfe-commits


@@ -50,6 +101,44 @@ class BuiltinFunctionChecker : public Checker {
 
 } // namespace
 
+void BuiltinFunctionChecker::HandleOverflowBuiltin(const CallEvent &Call,
+   CheckerContext &C,
+   BinaryOperator::Opcode Op,
+   QualType ResultType) const {
+  // All __builtin_*_overflow functions take 3 argumets.
+  assert(Call.getNumArgs() == 3);

NagyDonat wrote:

> I've tried to catch this assert locally by calling __builtin_*_overflow with 
> 2 arguments, but clang just rejects it.

Oh, I see. Perhaps add a comment saying that "Calling a builtin with an 
incorrect argument count produces compiler error (...)", because e.g. I didn't 
know that this is the case.

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


[clang] [analyzer] Model overflow builtins (PR #102602)

2024-08-12 Thread Donát Nagy via cfe-commits

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


[clang] [clang] Implement `__builtin_is_implicit_lifetime()` (PR #101807)

2024-08-12 Thread Vlad Serebrennikov via cfe-commits


@@ -5637,6 +5638,27 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait 
UTT,
 return false;
   case UTT_IsTriviallyEqualityComparable:
 return isTriviallyEqualityComparableType(Self, T, KeyLoc);
+  case UTT_IsImplicitLifetime: {
+DiagnoseVLAInCXXTypeTrait(Self, TInfo,
+  tok::kw___builtin_is_implicit_lifetime);
+QualType UnqualT = T->getCanonicalTypeUnqualified();
+if (UnqualT->isScalarType())
+  return true;
+if (UnqualT->isArrayType())
+  return true;
+
+const CXXRecordDecl *RD = UnqualT->getAsCXXRecordDecl();
+if (!RD)
+  return false;
+if (UnqualT->isAggregateType())
+  if (!RD->getDestructor()->isUserProvided())
+return true;
+if (RD->hasTrivialDestructor())

Endilll wrote:

> but X and Y are not aggregates because they have user-declared constructors

I'm sorry, but they only thing I see there are user-declared _destructors_, not 
constructors.

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


[clang] [clang] Implement `__builtin_is_implicit_lifetime()` (PR #101807)

2024-08-12 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [clang] Implement `__builtin_is_implicit_lifetime()` (PR #101807)

2024-08-12 Thread Mital Ashok via cfe-commits

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


[clang] [clang] Implement `__builtin_is_implicit_lifetime()` (PR #101807)

2024-08-12 Thread Mital Ashok via cfe-commits

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


[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-08-12 Thread via cfe-commits

https://github.com/yingopq updated 
https://github.com/llvm/llvm-project/pull/99615

>From f8a34c8015269cfc53666e9e28a2cb1290e96e70 Mon Sep 17 00:00:00 2001
From: Ying Huang 
Date: Fri, 19 Jul 2024 04:19:09 -0400
Subject: [PATCH] [clang] Support -Wa, options -mmsa and -mno-msa

---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 .../clang/Basic/DiagnosticDriverKinds.td  |  3 +++
 clang/include/clang/Driver/Options.td |  4 +++-
 clang/lib/Driver/ToolChains/Clang.cpp | 16 +++
 clang/test/Driver/mips-msa.c  | 20 +++
 5 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Driver/mips-msa.c

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index f671b780bcbeb1..898fbcd8e47fde 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -178,6 +178,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical 
constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
+CODEGENOPT(MipsMsa   , 1, 0) ///< Set when -Wa,-mmsa is enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
 CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled.
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 26a9792e6a6087..04d128d8272955 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -827,4 +827,7 @@ def err_drv_triple_version_invalid : Error<
 
 def warn_missing_include_dirs : Warning<
   "no such include directory: '%0'">, InGroup, 
DefaultIgnore;
+
+def err_drv_msa_and_nomsa : Error<
+  "-Wa,-mmsa,-mno-msa is meaningless">;
 }
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 12b20fe04675bf..c96338264dc82e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5337,7 +5337,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, 
Group,
 def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
   HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
-  HelpText<"Enable MSA ASE (MIPS only)">;
+  Visibility<[ClangOption, CC1Option, CC1AsOption]>,
+  HelpText<"Enable MSA ASE (MIPS only)">,
+  MarshallingInfoFlag>;
 def mno_msa : Flag<["-"], "mno-msa">, Group,
   HelpText<"Disable MSA ASE (MIPS only)">;
 def mmt : Flag<["-"], "mmt">, Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1fd6fba2100426..277fce65a6799d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2507,6 +2507,8 @@ static void CollectArgsForIntegratedAssembler(Compilation 
&C,
   bool Crel = false, ExperimentalCrel = false;
   bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
   bool UseNoExecStack = false;
+  bool Msa = false;
+  bool NoMsa = false;
   const char *MipsTargetFeature = nullptr;
   StringRef ImplicitIt;
   for (const Arg *A :
@@ -2630,6 +2632,10 @@ static void 
CollectArgsForIntegratedAssembler(Compilation &C,
 CmdArgs.push_back("-massembler-no-warn");
   } else if (Value == "--noexecstack") {
 UseNoExecStack = true;
+  } else if (Value == "-mmsa") {
+Msa = true;
+  } else if (Value == "-mno-msa") {
+NoMsa = true;
   } else if (Value.starts_with("-compress-debug-sections") ||
  Value.starts_with("--compress-debug-sections") ||
  Value == "-nocompress-debug-sections" ||
@@ -2716,6 +2722,16 @@ static void 
CollectArgsForIntegratedAssembler(Compilation &C,
   << "-Wa,--crel" << D.getTargetTriple();
 }
   }
+  if (Msa) {
+if (NoMsa)
+  D.Diag(diag::err_drv_msa_and_nomsa);
+else if (Triple.isMIPS())
+  CmdArgs.push_back("-mmsa");
+else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << "-Wa,-mmsa" << D.getTargetTriple();
+}
+  }
   if (!UseRelaxRelocations)
 CmdArgs.push_back("-mrelax-relocations=no");
   if (UseNoExecStack)
diff --git a/clang/test/Driver/mips-msa.c b/clang/test/Driver/mips-msa.c
new file mode 100644
index 00..7d803e8a9fab2c
--- /dev/null
+++ b/clang/test/Driver/mips-msa.c
@@ -0,0 +1,20 @@
+// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
+// RUN: -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA
+// CHECK-MMSA: "-cc1" {{.*}}"-mmsa"
+
+// RUN: not %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
+// RUN: -Wa,-mmsa,-mno-ms

[clang] [clang] Avoid triggering vtable instantiation for C++23 constexpr dtor (PR #102605)

2024-08-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` 
running on `sanitizer-buildbot2` while building `clang` at step 2 "annotate".

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

Here is the relevant piece of the build log for the reference:
```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[373/378] Generating Fuzzer-x86_64-Test
[374/378] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[375/378] Generating Msan-x86_64-with-call-Test
[376/378] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o
[377/378] Generating Msan-x86_64-Test
[377/378] Running compiler_rt regression tests
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276:
 warning: input 
'/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/rtsan/X86_64LinuxConfig'
 contained no tests
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 4496 of 10176 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60
FAIL: SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp (2820 
of 4496)
 TEST 'SanitizerCommon-lsan-i386-Linux :: 
Linux/soft_rss_limit_mb_test.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  
--driver-mode=g++ -gline-tables-only -fsanitize=leak  -m32 -funwind-tables  
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang 
--driver-mode=g++ -gline-tables-only -fsanitize=leak -m32 -funwind-tables 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
RUN: at line 5: env 
LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1
  
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
 2>&1 | FileCheck 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -check-prefix=CHECK_MAY_RETURN_1
+ env 
LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1
 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ FileCheck 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -check-prefix=CHECK_MAY_RETURN_1
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp:68:24:
 error: CHECK_MAY_RETURN_1: expected string not found in input
// CHECK_MAY_RETURN_1: allocating 512 times
   ^
:52:44: note: scanning from here
Some of the malloc calls returned non-null: 256
   ^
:53:14: note: possible intended match here
==1986183==LeakSanitizer: soft rss limit unexhausted (220Mb vs 10Mb)
 ^

Input file: 
Check file: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp

-dump-input=help explains the following input dump.

Input was:
<<
.
.
.
   47:  [256] 
   48:  [320] 
   49:  [384] 
   50:  [448] 
   51: Some of the malloc calls returned null: 256 
   52: Some of the malloc calls returned non-null: 256 
check:68'0X error: no match 
found
   53: ==1986183==LeakSanitizer: soft rss limit unexhausted (220Mb vs 
10Mb) 
Step 11 (test compiler-rt debug) failure: test compiler-rt debug (failure)
...
[373/378] Generating Fuzzer-x86_64-Test
[374/378] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[375/378] Generat

[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-08-12 Thread via cfe-commits


@@ -2507,6 +2507,7 @@ static void CollectArgsForIntegratedAssembler(Compilation 
&C,
   bool Crel = false, ExperimentalCrel = false;
   bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
   bool UseNoExecStack = false;
+  bool Msa = false;

yingopq wrote:

OK, I updated.

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


[clang] d12250c - [NFC][Clang] clang-format a function declaration

2024-08-12 Thread Jeremy Morse via cfe-commits

Author: Jeremy Morse
Date: 2024-08-12T09:49:55+01:00
New Revision: d12250ca7bea22ed12caf44fe80b203d83db75bb

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

LOG: [NFC][Clang] clang-format a function declaration

Added: 


Modified: 
clang/lib/CodeGen/CGCleanup.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index b1af4a0a97884b..5d253c92a38a81 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -299,9 +299,10 @@ static void createStoreInstBefore(llvm::Value *value, 
Address addr,
   store->setAlignment(addr.getAlignment().getAsAlign());
 }
 
-static llvm::LoadInst *createLoadInstBefore(Address addr, const Twine &name,
-llvm::BasicBlock::iterator 
beforeInst,
-CodeGenFunction &CGF) {
+static llvm::LoadInst *
+createLoadInstBefore(Address addr, const Twine &name,
+ llvm::BasicBlock::iterator beforeInst,
+ CodeGenFunction &CGF) {
   return new llvm::LoadInst(addr.getElementType(), addr.emitRawPointer(CGF),
 name, false, addr.getAlignment().getAsAlign(),
 beforeInst);



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


[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)

2024-08-12 Thread via cfe-commits

https://github.com/yingopq updated 
https://github.com/llvm/llvm-project/pull/99615

>From f8a34c8015269cfc53666e9e28a2cb1290e96e70 Mon Sep 17 00:00:00 2001
From: Ying Huang 
Date: Fri, 19 Jul 2024 04:19:09 -0400
Subject: [PATCH] [clang] Support -Wa, options -mmsa and -mno-msa

---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 .../clang/Basic/DiagnosticDriverKinds.td  |  3 +++
 clang/include/clang/Driver/Options.td |  4 +++-
 clang/lib/Driver/ToolChains/Clang.cpp | 16 +++
 clang/test/Driver/mips-msa.c  | 20 +++
 5 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Driver/mips-msa.c

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index f671b780bcbeb1..898fbcd8e47fde 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -178,6 +178,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical 
constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
+CODEGENOPT(MipsMsa   , 1, 0) ///< Set when -Wa,-mmsa is enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
 CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled.
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 26a9792e6a6087..04d128d8272955 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -827,4 +827,7 @@ def err_drv_triple_version_invalid : Error<
 
 def warn_missing_include_dirs : Warning<
   "no such include directory: '%0'">, InGroup, 
DefaultIgnore;
+
+def err_drv_msa_and_nomsa : Error<
+  "-Wa,-mmsa,-mno-msa is meaningless">;
 }
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 12b20fe04675bf..c96338264dc82e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5337,7 +5337,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, 
Group,
 def mno_madd4 : Flag<["-"], "mno-madd4">, Group,
   HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group,
-  HelpText<"Enable MSA ASE (MIPS only)">;
+  Visibility<[ClangOption, CC1Option, CC1AsOption]>,
+  HelpText<"Enable MSA ASE (MIPS only)">,
+  MarshallingInfoFlag>;
 def mno_msa : Flag<["-"], "mno-msa">, Group,
   HelpText<"Disable MSA ASE (MIPS only)">;
 def mmt : Flag<["-"], "mmt">, Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1fd6fba2100426..277fce65a6799d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2507,6 +2507,8 @@ static void CollectArgsForIntegratedAssembler(Compilation 
&C,
   bool Crel = false, ExperimentalCrel = false;
   bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
   bool UseNoExecStack = false;
+  bool Msa = false;
+  bool NoMsa = false;
   const char *MipsTargetFeature = nullptr;
   StringRef ImplicitIt;
   for (const Arg *A :
@@ -2630,6 +2632,10 @@ static void 
CollectArgsForIntegratedAssembler(Compilation &C,
 CmdArgs.push_back("-massembler-no-warn");
   } else if (Value == "--noexecstack") {
 UseNoExecStack = true;
+  } else if (Value == "-mmsa") {
+Msa = true;
+  } else if (Value == "-mno-msa") {
+NoMsa = true;
   } else if (Value.starts_with("-compress-debug-sections") ||
  Value.starts_with("--compress-debug-sections") ||
  Value == "-nocompress-debug-sections" ||
@@ -2716,6 +2722,16 @@ static void 
CollectArgsForIntegratedAssembler(Compilation &C,
   << "-Wa,--crel" << D.getTargetTriple();
 }
   }
+  if (Msa) {
+if (NoMsa)
+  D.Diag(diag::err_drv_msa_and_nomsa);
+else if (Triple.isMIPS())
+  CmdArgs.push_back("-mmsa");
+else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << "-Wa,-mmsa" << D.getTargetTriple();
+}
+  }
   if (!UseRelaxRelocations)
 CmdArgs.push_back("-mrelax-relocations=no");
   if (UseNoExecStack)
diff --git a/clang/test/Driver/mips-msa.c b/clang/test/Driver/mips-msa.c
new file mode 100644
index 00..7d803e8a9fab2c
--- /dev/null
+++ b/clang/test/Driver/mips-msa.c
@@ -0,0 +1,20 @@
+// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
+// RUN: -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA
+// CHECK-MMSA: "-cc1" {{.*}}"-mmsa"
+
+// RUN: not %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \
+// RUN: -Wa,-mmsa,-mno-ms

[clang] [Clang] [AST] Fix placeholder return type name mangling for MSVC 1920+ / VS2019+ (PR #102848)

2024-08-12 Thread via cfe-commits

https://github.com/zmodem commented:

Thanks! Just some nits from me.

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


[clang] [Clang] [AST] Fix placeholder return type name mangling for MSVC 1920+ / VS2019+ (PR #102848)

2024-08-12 Thread via cfe-commits


@@ -2494,6 +2506,58 @@ void 
MicrosoftCXXNameMangler::mangleAddressSpaceType(QualType T,
   mangleArtificialTagType(TagTypeKind::Struct, ASMangling, {"__clang"});
 }
 
+void MicrosoftCXXNameMangler::mangleAutoReturnType(QualType T,
+   SourceRange Range,
+   QualifierMangleMode QMM) {
+  assert(getASTContext().getLangOpts().isCompatibleWithMSVC(

zmodem wrote:

I'm not sure asserting here is right. Wouldn't this break users targeting 
VS2017, whereas before they just got incorrect manglings (but most probably 
didn't notice)?

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


[clang] [Clang] [AST] Fix placeholder return type name mangling for MSVC 1920+ / VS2019+ (PR #102848)

2024-08-12 Thread via cfe-commits


@@ -408,6 +408,9 @@ class MicrosoftCXXNameMangler {
   void mangleSourceName(StringRef Name);
   void mangleNestedName(GlobalDecl GD);
 
+  void mangleAutoReturnType(QualType T, SourceRange Range,

zmodem wrote:

Is the SourceRange actually needed? I see it getting passed around to the 
`mangleAutoReturnType` methods, but I didn't find any actual use in the end?

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


[clang] [Clang] [AST] Fix placeholder return type name mangling for MSVC 1920+ / VS2019+ (PR #102848)

2024-08-12 Thread via cfe-commits

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


[clang] [Clang] handle both gnu and cpp11 attributes to ensure correct parsing inside extern block (PR #102864)

2024-08-12 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk created 
https://github.com/llvm/llvm-project/pull/102864

Fixes #101990

>From d08d3f318ff64b1c7ff06ac3183c8b83de4021ed Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 12 Aug 2024 11:55:52 +0300
Subject: [PATCH] [Clang] handle both gnu and cpp11 attributes to ensure
 correct parsing inside extern block

---
 clang/docs/ReleaseNotes.rst  | 1 +
 clang/lib/Parse/ParseDeclCXX.cpp | 5 -
 clang/test/Parser/attr-order.cpp | 8 
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6796a619ba97f8..00a663fdd23454 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,7 @@ Bug Fixes to C++ Support
 - Clang now preserves the unexpanded flag in a lambda transform used for pack 
expansion. (#GH56852), (#GH85667),
   (#GH99877).
 - Fixed a bug when diagnosing ambiguous explicit specializations of 
constrained member functions.
+- Clang now properly handles the order of attributes in `extern` blocks. 
(#GH101990).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index aac89d910bbc83..d45a738fe4c596 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -425,7 +425,10 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, 
DeclaratorContext Context) {
   [[fallthrough]];
 default:
   ParsedAttributes DeclAttrs(AttrFactory);
-  MaybeParseCXX11Attributes(DeclAttrs);
+  ParsedAttributes DeclSpecAttrs(AttrFactory);
+  while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+;
   ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
   continue;
 }
diff --git a/clang/test/Parser/attr-order.cpp b/clang/test/Parser/attr-order.cpp
index 10bad38cac6447..369941ab24ee69 100644
--- a/clang/test/Parser/attr-order.cpp
+++ b/clang/test/Parser/attr-order.cpp
@@ -31,3 +31,11 @@ template 
 
 template 
 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void k(); // ok
+
+extern "C" {
+  __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int l(int); // 
ok
+  [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int m(int); // 
ok
+}
+
+extern "C" __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int 
n(int); // ok
+extern "C" [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int 
o(int); // ok

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


[clang] [Clang] handle both gnu and cpp11 attributes to ensure correct parsing inside extern block (PR #102864)

2024-08-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)


Changes

Fixes #101990

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+4-1) 
- (modified) clang/test/Parser/attr-order.cpp (+8) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6796a619ba97f8..00a663fdd23454 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,7 @@ Bug Fixes to C++ Support
 - Clang now preserves the unexpanded flag in a lambda transform used for pack 
expansion. (#GH56852), (#GH85667),
   (#GH99877).
 - Fixed a bug when diagnosing ambiguous explicit specializations of 
constrained member functions.
+- Clang now properly handles the order of attributes in `extern` blocks. 
(#GH101990).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index aac89d910bbc83..d45a738fe4c596 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -425,7 +425,10 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, 
DeclaratorContext Context) {
   [[fallthrough]];
 default:
   ParsedAttributes DeclAttrs(AttrFactory);
-  MaybeParseCXX11Attributes(DeclAttrs);
+  ParsedAttributes DeclSpecAttrs(AttrFactory);
+  while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+;
   ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
   continue;
 }
diff --git a/clang/test/Parser/attr-order.cpp b/clang/test/Parser/attr-order.cpp
index 10bad38cac6447..369941ab24ee69 100644
--- a/clang/test/Parser/attr-order.cpp
+++ b/clang/test/Parser/attr-order.cpp
@@ -31,3 +31,11 @@ template 
 
 template 
 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void k(); // ok
+
+extern "C" {
+  __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int l(int); // 
ok
+  [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int m(int); // 
ok
+}
+
+extern "C" __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int 
n(int); // ok
+extern "C" [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int 
o(int); // ok

``




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


[clang] [Clang] handle both gnu and cpp11 attributes to ensure correct parsing inside extern block (PR #102864)

2024-08-12 Thread Oleksandr T. via cfe-commits

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

>From 08f2cc1cadfe81798ea2b07b1e601e6ea67ecf9a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 12 Aug 2024 12:00:05 +0300
Subject: [PATCH] [Clang] handle both gnu and cpp11 attributes to ensure
 correct parsing inside extern block

---
 clang/docs/ReleaseNotes.rst  | 1 +
 clang/lib/Parse/ParseDeclCXX.cpp | 5 -
 clang/test/Parser/attr-order.cpp | 8 
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6796a619ba97f8..00a663fdd23454 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,7 @@ Bug Fixes to C++ Support
 - Clang now preserves the unexpanded flag in a lambda transform used for pack 
expansion. (#GH56852), (#GH85667),
   (#GH99877).
 - Fixed a bug when diagnosing ambiguous explicit specializations of 
constrained member functions.
+- Clang now properly handles the order of attributes in `extern` blocks. 
(#GH101990).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index aac89d910bbc83..d45a738fe4c596 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -425,7 +425,10 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, 
DeclaratorContext Context) {
   [[fallthrough]];
 default:
   ParsedAttributes DeclAttrs(AttrFactory);
-  MaybeParseCXX11Attributes(DeclAttrs);
+  ParsedAttributes DeclSpecAttrs(AttrFactory);
+  while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+;
   ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
   continue;
 }
diff --git a/clang/test/Parser/attr-order.cpp b/clang/test/Parser/attr-order.cpp
index 10bad38cac6447..369941ab24ee69 100644
--- a/clang/test/Parser/attr-order.cpp
+++ b/clang/test/Parser/attr-order.cpp
@@ -31,3 +31,11 @@ template 
 
 template 
 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void k(); // ok
+
+extern "C" {
+  __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int l(int); // 
ok
+  [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int m(int); // 
ok
+}
+
+extern "C" __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int 
n(int); // ok
+extern "C" [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int 
o(int); // ok

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


[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2024-08-12 Thread Kishan Parmar via cfe-commits

https://github.com/Long5hot updated 
https://github.com/llvm/llvm-project/pull/77732

>From f463f28b76c3cf9ff4d8a3b7a5522c322258b5a3 Mon Sep 17 00:00:00 2001
From: Kishan Parmar 
Date: Mon, 12 Aug 2024 14:27:25 +0530
Subject: [PATCH] [clang][PowerPC] Add flag to enable compatibility with GNU
 for complex arguments

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

https://godbolt.org/z/1bsW1sKMs

newFlag : -fcomplex-ppc-gnu-abi

GNU uses GPRs for complex parameters and return values storing for 
PowerPC-32bit,
which can be enabled which above flag.
Intent of this patch is to make clang compatible with GNU libraries of complex.

Following up with this patch : https://reviews.llvm.org/D146942
---
 clang/docs/ReleaseNotes.rst   |   5 +
 clang/include/clang/Basic/CodeGenOptions.def  |   2 +
 clang/include/clang/Basic/CodeGenOptions.h|   6 +
 clang/include/clang/Driver/Options.td |   4 +
 clang/lib/CodeGen/Targets/PPC.cpp |  85 +++-
 clang/lib/Driver/ToolChains/Clang.cpp |   9 +
 clang/lib/Frontend/CompilerInvocation.cpp |   6 +
 .../CodeGen/PowerPC/ppc32-complex-gnu-abi.c   | 394 ++
 .../ppc32-complex-soft-float-gnu-abi.c|  95 +
 .../test/Driver/ppc32-fcomplex-ppc-gnu-abi.c  |   9 +
 10 files changed, 610 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/CodeGen/PowerPC/ppc32-complex-gnu-abi.c
 create mode 100644 
clang/test/CodeGen/PowerPC/ppc32-complex-soft-float-gnu-abi.c
 create mode 100644 clang/test/Driver/ppc32-fcomplex-ppc-gnu-abi.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6796a619ba97f8..1ccf5ef64d239b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,11 @@ Non-comprehensive list of changes in this release
 New Compiler Flags
 --
 
+* ``-fcomplex-ppc-gnu-abi`` follow ABI ATR-PASS-COMPLEX-IN-GPRS for ppc32 and 
pass
+  complex parameters on GPRs instead of stack.
+  For more info check `Power Architecture™ 32-bit ABI Supplement 1.0 - Embedded
+  
`_
+
 Deprecated Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 5728ab8d86702b..733fb7257c94bb 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -231,6 +231,8 @@ VALUE_CODEGENOPT(MCDCMaxTVs, 32, 0x7FFE) ///< MC/DC 
Maximum test vectors.
 
   /// If -fpcc-struct-return or -freg-struct-return is specified.
 ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default)
+  /// If -fcomplex-ppc-gnu-abi is specified on ppc32.
+ENUM_CODEGENOPT(ComplexInRegABI, ComplexArgumentConventionKind, 2, 
CMPLX_OnStack)
 
 CODEGENOPT(RelaxAll  , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is 
enabled.
diff --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index f2a707a8ba8d76..6a53c2b72949eb 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -79,6 +79,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
 SRCK_InRegs// Small structs in registers (-freg-struct-return).
   };
 
+  enum ComplexArgumentConventionKind {
+CMPLX_OnStack,
+CMPLX_InGPR, // If -fcomplex-ppc-gnu-abi is specified on ppc32
+CMPLX_InFPR
+  };
+
   enum ProfileInstrKind {
 ProfileNone,   // Profile instrumentation is turned off.
 ProfileClangInstr, // Clang instrumentation to generate execution counts
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e196c3dc5cb3be..e0ccf36206254e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2655,6 +2655,10 @@ def ffp_contract : Joined<["-"], "ffp-contract=">, 
Group,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;
 
+def fcomplex_ppc_gnu_abi : Flag<["-"], "fcomplex-ppc-gnu-abi">, 
Group, Visibility<[ClangOption, CC1Option]>,
+  DocBrief<"Follow the GNU ABI, pass Complex values in GPRs instead of the 
stack for PowerPC-32">,
+  HelpText<"Pass Complex values in GPR instead of stack for PowerPC-32">;
+
 defm strict_float_cast_overflow : BoolFOption<"strict-float-cast-overflow",
   CodeGenOpts<"StrictFloatCastOverflow">, DefaultTrue,
   NegFlaghttps://reviews.llvm.org/D146942 and the related LLVM pull
+  // request: #77732
+
+  if (TypeSize == 64) {
+ElemTy = llvm::Type::getInt64Ty(getVMContext());
+RegsNeeded = 1;
+  } else {
+ElemTy = llvm::Type::getInt32Ty(getVMContext());
+RegsNeeded = TypeSize >> 5;
+  }
+  return ABIArgInfo::getDirect(llvm::ArrayType::get(ElemTy, RegsNeeded));
+}
+
+ABIArgInfo PPC32_SVR4_ABIInfo::classi

[clang] e607360 - [clang][analyzer] Remove array bounds check from PointerSubChecker (#102580)

2024-08-12 Thread via cfe-commits

Author: Balázs Kéri
Date: 2024-08-12T11:22:30+02:00
New Revision: e607360fcde2994080bb8cec9d4be3a4091fe9a9

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

LOG: [clang][analyzer] Remove array bounds check from PointerSubChecker 
(#102580)

At pointer subtraction only pointers are allowed that point into an
array (or one after the end), this fact was checker by the checker. This
check is now removed because it is a special case of array indexing
error that is handled by different checkers (like ArrayBoundsV2).

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
clang/test/Analysis/pointer-sub-notes.c
clang/test/Analysis/pointer-sub.c

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 55832d20bd27a1..46b0b7b9c82376 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2501,7 +2501,11 @@ alpha.core.PointerSub (C)
 Check for pointer subtractions on two pointers pointing to 
diff erent memory
 chunks. According to the C standard §6.5.6 only subtraction of pointers that
 point into (or one past the end) the same array object is valid (for this
-purpose non-array variables are like arrays of size 1).
+purpose non-array variables are like arrays of size 1). This checker only
+searches for 
diff erent memory objects at subtraction, but does not check if the
+array index is correct. Furthermore, only cases are reported where
+stack-allocated objects are involved (no warnings on pointers to memory
+allocated by `malloc`).
 
 .. code-block:: c
 
@@ -2511,11 +2515,6 @@ purpose non-array variables are like arrays of size 1).
x = &d[4] - &c[1]; // warn: 'c' and 'd' are 
diff erent arrays
x = (&a + 1) - &a;
x = &b - &a; // warn: 'a' and 'b' are 
diff erent variables
-   x = (&a + 2) - &a; // warn: for a variable it is only valid to have a 
pointer
-  // to one past the address of it
-   x = &c[10] - &c[0];
-   x = &c[11] - &c[0]; // warn: index larger than one past the end
-   x = &c[-1] - &c[0]; // warn: negative index
  }
 
  struct S {
@@ -2538,9 +2537,6 @@ offsets of members in a structure, using pointer 
subtractions. This is still
 undefined behavior according to the standard and code like this can be replaced
 with the `offsetof` macro.
 
-The checker only reports cases where stack-allocated objects are involved (no
-warnings on pointers to memory allocated by `malloc`).
-
 .. _alpha-core-StackAddressAsyncEscape:
 
 alpha.core.StackAddressAsyncEscape (C)

diff  --git a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
index b856b0edc61514..f0dc5efd75f7d6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
@@ -31,99 +31,12 @@ class PointerSubChecker
   const llvm::StringLiteral Msg_MemRegionDifferent =
   "Subtraction of two pointers that do not point into the same array "
   "is undefined behavior.";
-  const llvm::StringLiteral Msg_LargeArrayIndex =
-  "Using an array index greater than the array size at pointer subtraction 
"
-  "is undefined behavior.";
-  const llvm::StringLiteral Msg_NegativeArrayIndex =
-  "Using a negative array index at pointer subtraction "
-  "is undefined behavior.";
-  const llvm::StringLiteral Msg_BadVarIndex =
-  "Indexing the address of a variable with other than 1 at this place "
-  "is undefined behavior.";
-
-  /// Check that an array is indexed in the allowed range that is 0 to "one
-  /// after the end". The "array" can be address of a non-array variable.
-  /// @param E Expression of the pointer subtraction.
-  /// @param ElemReg An indexed region in the subtraction expression.
-  /// @param Reg Region of the other side of the expression.
-  bool checkArrayBounds(CheckerContext &C, const Expr *E,
-const ElementRegion *ElemReg,
-const MemRegion *Reg) const;
 
 public:
   void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const;
 };
 }
 
-static bool isArrayVar(const MemRegion *R) {
-  while (R) {
-if (isa(R))
-  return true;
-if (const auto *ER = dyn_cast(R))
-  R = ER->getSuperRegion();
-else
-  return false;
-  }
-  return false;
-}
-
-bool PointerSubChecker::checkArrayBounds(CheckerContext &C, const Expr *E,
- const ElementRegion *ElemReg,
- const MemRegion *Reg) const {
-  if (!ElemReg)
-return true;
-
-  const MemRegion *SuperReg = ElemReg->getSuperRegion();
-  if (!isArrayVar(SuperReg))
-return true;
-
-  auto Repor

[clang] [clang][analyzer] Remove array bounds check from PointerSubChecker (PR #102580)

2024-08-12 Thread Balázs Kéri via cfe-commits

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


[clang] [DebugInfo][RemoveDIs] Use iterator-inserters in clang (PR #102006)

2024-08-12 Thread Jeremy Morse via cfe-commits

jmorse wrote:

Clang-formatted the declaration I touched in d12250ca7be, the other matters 
were already present in the code so I've shied away from addressing them.

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


[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102855)

2024-08-12 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/102855

>From 598ce1867b5ac36aa6da48be0556bb637ce1ddb0 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Mon, 12 Aug 2024 13:31:35 +0800
Subject: [PATCH] [Serialization] Add a callback to register new created
 predefined decls for DeserializationListener

Close https://github.com/llvm/llvm-project/issues/102684

The root cause of the issue is, it is possible that the predefined decl
is not registered at the beginning of writing a module file but got
created during the process of writing from reading.

This is incorrect. The predefined decls should always be predefined
decls.

Another deep thought about the issue is, we shouldn't read any new
things after we start to write the module file. But this is another
deeper question.
---
 .../clang/Frontend/MultiplexConsumer.h|  1 +
 .../ASTDeserializationListener.h  |  2 +
 clang/include/clang/Serialization/ASTReader.h |  3 +
 clang/include/clang/Serialization/ASTWriter.h |  1 +
 clang/lib/Frontend/MultiplexConsumer.cpp  |  5 +
 clang/lib/Serialization/ASTReader.cpp | 91 +++
 clang/lib/Serialization/ASTWriter.cpp |  6 ++
 clang/test/Modules/pr102684.cppm  | 38 
 8 files changed, 129 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/Modules/pr102684.cppm

diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index e49e3392d1f317..3a7670d7a51aa6 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -36,6 +36,7 @@ class MultiplexASTDeserializationListener : public 
ASTDeserializationListener {
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
   void DeclRead(GlobalDeclID ID, const Decl *D) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h 
b/clang/include/clang/Serialization/ASTDeserializationListener.h
index 1d81a9ae3fe2eb..ea96faa07c1917 100644
--- a/clang/include/clang/Serialization/ASTDeserializationListener.h
+++ b/clang/include/clang/Serialization/ASTDeserializationListener.h
@@ -45,6 +45,8 @@ class ASTDeserializationListener {
   virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { }
   /// A decl was deserialized from the AST file.
   virtual void DeclRead(GlobalDeclID ID, const Decl *D) {}
+  /// A predefined decl was built during the serialization.
+  virtual void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {}
   /// A selector was read from the AST file.
   virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
   /// A macro definition was read from the AST file.
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 549396a3b6b387..a0e90e62bd60ec 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1559,6 +1559,9 @@ class ASTReader
   std::pair
   translateTypeIDToIndex(serialization::TypeID ID) const;
 
+  /// Get a predefined Decl from ASTContext.
+  Decl *getPredefinedDecl(PredefinedDeclIDs ID);
+
 public:
   /// Load the AST file and validate its contents against the given
   /// Preprocessor.
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 71a7c28047e318..a4cc95cd1373fa 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -869,6 +869,7 @@ class ASTWriter : public ASTDeserializationListener,
   void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) 
override;
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/lib/Frontend/MultiplexConsumer.cpp 
b/clang/lib/Frontend/MultiplexConsumer.cpp
index 651c55aeed5408..2158d176d18929 100644
--- a/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -58,6 +58,11 @@ void 
MultiplexASTDeserializationListener::DeclRead(GlobalDeclID ID,
 Listeners[i]->DeclRead(ID, D);
 }
 
+void 
MultiplexASTDeserializationListener::PredefinedDeclBuilt(PredefinedDeclIDs ID, 
const Decl *D) {
+  for (size_t i = 0, e = Listene

[clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-12 Thread via cfe-commits

https://github.com/Dhruv-Srivastava-IBM edited 
https://github.com/llvm/llvm-project/pull/102601
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Compile field+base destruction into class dtor func (PR #102871)

2024-08-12 Thread Timm Baeder via cfe-commits

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

None

>From 1f04d85c024520ed0399ce3a363211f77c69d68f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 12 Aug 2024 11:45:27 +0200
Subject: [PATCH] [clang][Interp] Compile field+base destruction into class
 dtor func

---
 clang/lib/AST/Interp/Compiler.cpp| 97 +---
 clang/lib/AST/Interp/Compiler.h  |  1 +
 clang/lib/AST/Interp/Interp.cpp  | 24 ---
 clang/test/AST/Interp/cxx20.cpp  |  3 +-
 clang/test/AST/Interp/new-delete.cpp |  5 +-
 5 files changed, 62 insertions(+), 68 deletions(-)

diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index dd24cff1bab46e..7be15921384f1f 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -4856,6 +4856,50 @@ bool Compiler::compileConstructor(const 
CXXConstructorDecl *Ctor) {
   return this->emitRetVoid(SourceInfo{});
 }
 
+template 
+bool Compiler::compileDestructor(const CXXDestructorDecl *Dtor) {
+  const RecordDecl *RD = Dtor->getParent();
+  const Record *R = this->getRecord(RD);
+  if (!R)
+return false;
+
+  if (!this->emitThis(Dtor))
+return false;
+
+  assert(R);
+  if (!R->isUnion()) {
+// First, destroy all fields.
+for (const Record::Field &Field : llvm::reverse(R->fields())) {
+  const Descriptor *D = Field.Desc;
+  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
+if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
+  return false;
+if (!this->emitDestruction(D))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+}
+  }
+
+  if (!Dtor->isTrivial()) {
+if (!this->visitStmt(Dtor->getBody()))
+  return false;
+  }
+
+  for (const Record::Base &Base : llvm::reverse(R->bases())) {
+if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
+  return false;
+if (!this->emitRecordDestruction(Base.R))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+
+  // FIXME: Virtual bases.
+  return this->emitPopPtr(Dtor) && this->emitRetVoid(Dtor);
+}
+
 template 
 bool Compiler::visitFunc(const FunctionDecl *F) {
   // Classify the return type.
@@ -4863,6 +4907,8 @@ bool Compiler::visitFunc(const FunctionDecl *F) {
 
   if (const auto *Ctor = dyn_cast(F))
 return this->compileConstructor(Ctor);
+  if (const auto *Dtor = dyn_cast(F))
+return this->compileDestructor(Dtor);
 
   // Emit custom code if this is a lambda static invoker.
   if (const auto *MD = dyn_cast(F);
@@ -5573,46 +5619,19 @@ bool Compiler::emitComplexComparison(const 
Expr *LHS, const Expr *RHS,
 template 
 bool Compiler::emitRecordDestruction(const Record *R) {
   assert(R);
-  if (!R->isUnion()) {
-// First, destroy all fields.
-for (const Record::Field &Field : llvm::reverse(R->fields())) {
-  const Descriptor *D = Field.Desc;
-  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
-if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
-  return false;
-if (!this->emitDestruction(D))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
-}
-  }
-
-  // Now emit the destructor and recurse into base classes.
-  if (const CXXDestructorDecl *Dtor = R->getDestructor();
-  Dtor && !Dtor->isTrivial()) {
-const Function *DtorFunc = getFunction(Dtor);
-if (!DtorFunc)
-  return false;
-assert(DtorFunc->hasThisPointer());
-assert(DtorFunc->getNumParams() == 1);
-if (!this->emitDupPtr(SourceInfo{}))
-  return false;
-if (!this->emitCall(DtorFunc, 0, SourceInfo{}))
-  return false;
-  }
-
-  for (const Record::Base &Base : llvm::reverse(R->bases())) {
-if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
-  return false;
-if (!this->emitRecordDestruction(Base.R))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
+  const CXXDestructorDecl *Dtor = R->getDestructor();
+  if (!Dtor || Dtor->isTrivial())
+return true;
 
-  // FIXME: Virtual bases.
-  return true;
+  assert(Dtor);
+  const Function *DtorFunc = getFunction(Dtor);
+  if (!DtorFunc)
+return false;
+  assert(DtorFunc->hasThisPointer());
+  assert(DtorFunc->getNumParams() == 1);
+  if (!this->emitDupPtr(SourceInfo{}))
+return false;
+  return this->emitCall(DtorFunc, 0, SourceInfo{});
 }
 /// When calling this, we have a pointer of the local-to-destroy
 /// on the stack.
diff --git a/clang/lib/AST/Interp/Compiler.h b/clang/lib/AST/Interp/Compiler.h
index d94d3613775a19..112219c49e8bdd 100644
--- a/clang/lib/AST/Interp/Compiler.h
+++ b/clang/lib/AST/Interp/Compiler.h
@@ -358,6 +358,7 @@ class Compiler : public ConstStmtVisitor, 
bool>,
  const QualType DerivedType);
   bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
   bool compileConst

[clang] [analyzer][NFC] Improve documentation of `invalidateRegion` methods (PR #102477)

2024-08-12 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

> Do you plan to apply more refactors to invalidation and Store?

These were opportunistic unplanned refactors, I was just familiarizing myself 
with the invalidation logic (because I'll need to use it in loop widening), and 
I quickly fixed some minor issues that I spotted.

However, I'll probably need one change to make more features of the 
invalidation logic accessible without a `CallEvent`. (Currently the `CallEvent` 
is passed down even to `RegionStoreManager::invalidateRegions` where it's only 
used to calculate an `enum GlobalsFilterKind` value; while I'd  like to have a 
variant of `ProgramState::invalidateRegions` that directly takes a 
`GlobalFiltersKind` instead of a `CallEvent`.)

However I'm not planning any functional/algorithmic changes in the invalidation 
logic, and I think and hope that I won't need to touch other parts of the 
`State`.

What can I do to help you avoid merge conflicts?



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


[clang] [clang][Interp] Compile field+base destruction into class dtor func (PR #102871)

2024-08-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


5 Files Affected:

- (modified) clang/lib/AST/Interp/Compiler.cpp (+58-39) 
- (modified) clang/lib/AST/Interp/Compiler.h (+1) 
- (modified) clang/lib/AST/Interp/Interp.cpp (-24) 
- (modified) clang/test/AST/Interp/cxx20.cpp (+1-2) 
- (modified) clang/test/AST/Interp/new-delete.cpp (+2-3) 


``diff
diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index dd24cff1bab46e..7be15921384f1f 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -4856,6 +4856,50 @@ bool Compiler::compileConstructor(const 
CXXConstructorDecl *Ctor) {
   return this->emitRetVoid(SourceInfo{});
 }
 
+template 
+bool Compiler::compileDestructor(const CXXDestructorDecl *Dtor) {
+  const RecordDecl *RD = Dtor->getParent();
+  const Record *R = this->getRecord(RD);
+  if (!R)
+return false;
+
+  if (!this->emitThis(Dtor))
+return false;
+
+  assert(R);
+  if (!R->isUnion()) {
+// First, destroy all fields.
+for (const Record::Field &Field : llvm::reverse(R->fields())) {
+  const Descriptor *D = Field.Desc;
+  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
+if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
+  return false;
+if (!this->emitDestruction(D))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+}
+  }
+
+  if (!Dtor->isTrivial()) {
+if (!this->visitStmt(Dtor->getBody()))
+  return false;
+  }
+
+  for (const Record::Base &Base : llvm::reverse(R->bases())) {
+if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
+  return false;
+if (!this->emitRecordDestruction(Base.R))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+
+  // FIXME: Virtual bases.
+  return this->emitPopPtr(Dtor) && this->emitRetVoid(Dtor);
+}
+
 template 
 bool Compiler::visitFunc(const FunctionDecl *F) {
   // Classify the return type.
@@ -4863,6 +4907,8 @@ bool Compiler::visitFunc(const FunctionDecl *F) {
 
   if (const auto *Ctor = dyn_cast(F))
 return this->compileConstructor(Ctor);
+  if (const auto *Dtor = dyn_cast(F))
+return this->compileDestructor(Dtor);
 
   // Emit custom code if this is a lambda static invoker.
   if (const auto *MD = dyn_cast(F);
@@ -5573,46 +5619,19 @@ bool Compiler::emitComplexComparison(const 
Expr *LHS, const Expr *RHS,
 template 
 bool Compiler::emitRecordDestruction(const Record *R) {
   assert(R);
-  if (!R->isUnion()) {
-// First, destroy all fields.
-for (const Record::Field &Field : llvm::reverse(R->fields())) {
-  const Descriptor *D = Field.Desc;
-  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
-if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
-  return false;
-if (!this->emitDestruction(D))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
-}
-  }
-
-  // Now emit the destructor and recurse into base classes.
-  if (const CXXDestructorDecl *Dtor = R->getDestructor();
-  Dtor && !Dtor->isTrivial()) {
-const Function *DtorFunc = getFunction(Dtor);
-if (!DtorFunc)
-  return false;
-assert(DtorFunc->hasThisPointer());
-assert(DtorFunc->getNumParams() == 1);
-if (!this->emitDupPtr(SourceInfo{}))
-  return false;
-if (!this->emitCall(DtorFunc, 0, SourceInfo{}))
-  return false;
-  }
-
-  for (const Record::Base &Base : llvm::reverse(R->bases())) {
-if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
-  return false;
-if (!this->emitRecordDestruction(Base.R))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
+  const CXXDestructorDecl *Dtor = R->getDestructor();
+  if (!Dtor || Dtor->isTrivial())
+return true;
 
-  // FIXME: Virtual bases.
-  return true;
+  assert(Dtor);
+  const Function *DtorFunc = getFunction(Dtor);
+  if (!DtorFunc)
+return false;
+  assert(DtorFunc->hasThisPointer());
+  assert(DtorFunc->getNumParams() == 1);
+  if (!this->emitDupPtr(SourceInfo{}))
+return false;
+  return this->emitCall(DtorFunc, 0, SourceInfo{});
 }
 /// When calling this, we have a pointer of the local-to-destroy
 /// on the stack.
diff --git a/clang/lib/AST/Interp/Compiler.h b/clang/lib/AST/Interp/Compiler.h
index d94d3613775a19..112219c49e8bdd 100644
--- a/clang/lib/AST/Interp/Compiler.h
+++ b/clang/lib/AST/Interp/Compiler.h
@@ -358,6 +358,7 @@ class Compiler : public ConstStmtVisitor, 
bool>,
  const QualType DerivedType);
   bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
   bool compileConstructor(const CXXConstructorDecl *Ctor);
+  bool compileDestructor(const CXXDestructorDecl *Dtor);
 
   bool checkLiteralType(const Expr *E);
 
diff --git a/clang/lib/AST/Inter

[clang] 908c89e - [analyzer][NFC] Improve documentation of `invalidateRegion` methods (#102477)

2024-08-12 Thread via cfe-commits

Author: Donát Nagy
Date: 2024-08-12T11:48:13+02:00
New Revision: 908c89e04b6019bdb08bb5f1c861af42046db623

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

LOG: [analyzer][NFC] Improve documentation of `invalidateRegion` methods 
(#102477)

... within the classes `StoreManager` and `ProgramState` and describe
the connection between the two methods.

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
index 9889d2604a890e..2f6cd481fd6362 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -304,24 +304,27 @@ class ProgramState : public llvm::FoldingSetNode {
 
   [[nodiscard]] ProgramStateRef killBinding(Loc LV) const;
 
-  /// Returns the state with bindings for the given regions
-  ///  cleared from the store.
+  /// Returns the state with bindings for the given regions cleared from the
+  /// store. If \p Call is non-null, also invalidates global regions (but if
+  /// \p Call is from a system header, then this is limited to globals declared
+  /// in system headers).
   ///
-  /// Optionally invalidates global regions as well.
+  /// This calls the lower-level method \c StoreManager::invalidateRegions to
+  /// do the actual invalidation, then calls the checker callbacks which should
+  /// be triggered by this event.
   ///
   /// \param Regions the set of regions to be invalidated.
   /// \param E the expression that caused the invalidation.
   /// \param BlockCount The number of times the current basic block has been
-  // visited.
-  /// \param CausesPointerEscape the flag is set to true when
-  ///the invalidation entails escape of a symbol (representing a
-  ///pointer). For example, due to it being passed as an argument in a
-  ///call.
+  ///visited.
+  /// \param CausesPointerEscape the flag is set to true when the invalidation
+  ///entails escape of a symbol (representing a pointer). For example,
+  ///due to it being passed as an argument in a call.
   /// \param IS the set of invalidated symbols.
   /// \param Call if non-null, the invalidated regions represent parameters to
   ///the call and should be considered directly invalidated.
-  /// \param ITraits information about special handling for a particular
-  ///region/symbol.
+  /// \param ITraits information about special handling for particular regions
+  ///or symbols.
   [[nodiscard]] ProgramStateRef
   invalidateRegions(ArrayRef Regions, const Expr *E,
 unsigned BlockCount, const LocationContext *LCtx,
@@ -330,7 +333,7 @@ class ProgramState : public llvm::FoldingSetNode {
 RegionAndSymbolInvalidationTraits *ITraits = nullptr) 
const;
 
   [[nodiscard]] ProgramStateRef
-  invalidateRegions(ArrayRef Regions, const Expr *E, unsigned BlockCount,
+  invalidateRegions(ArrayRef Values, const Expr *E, unsigned BlockCount,
 const LocationContext *LCtx, bool CausesPointerEscape,
 InvalidatedSymbols *IS = nullptr,
 const CallEvent *Call = nullptr,

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
index ef23b160a3c032..e08d5e104e9c0a 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -205,8 +205,15 @@ class StoreManager {
   /// invalidateRegions - Clears out the specified regions from the store,
   ///  marking their values as unknown. Depending on the store, this may also
   ///  invalidate additional regions that may have changed based on accessing
-  ///  the given regions. Optionally, invalidates non-static globals as well.
-  /// \param[in] store The initial store
+  ///  the given regions. If \p Call is non-null, then this also invalidates
+  ///  non-static globals (but if \p Call is from a system header, then this is
+  ///  limited to globals declared in system headers).
+  ///
+  /// Instead of calling this method directly, you should probably use
+  /// \c ProgramState::invalidateRegions, which calls this and then ensures 
that
+  /// the relevant checker callbacks are triggered.
+  ///
+  /// \param[in] store The initial store.
   /// \param[in] Values The values to invalidate.
   /// \param[in] E The current statement being evaluated. Used to conjure
   ///   symbols 

[clang] [analyzer][NFC] Improve documentation of `invalidateRegion` methods (PR #102477)

2024-08-12 Thread Donát Nagy via cfe-commits

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


[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-12 Thread Timm Baeder via cfe-commits

tbaederr wrote:

LGTM from my side but I added some other reviewers in case they have more 
comments.

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


[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits

https://github.com/pow2clk created 
https://github.com/llvm/llvm-project/pull/102872

Per https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
`dot` should be an LLVM intrinsic. This adds the llvm intrinsics
and updates HLSL builtin codegen to emit them.

Removed some stale comments that gave the obsolete impression that
type conversions should be expected to match overloads.

With dot moving into an LLVM intrinsic, the lowering to dx-specific
operations doesn't take place until DXIL intrinsic expansion. This
moves the introduction of arity-specific DX opcodes to DXIL
intrinsic expansion.

The new LLVM integer intrinsics replace the previous dx intrinsics.
This updates the DXIL intrinsic expansion code and tests to use and
expect the new integer intrinsics and the flattened DX floating
vector size variants only after op lowering.

Use the new LLVM dot intrinsics to build SPIRV instructions.
This involves generating multiply and add operations for integers
and the existing OpDot operation for floating point. This includes
adding some generic opcodes for signed, unsigned and floats.
These require updating an existing test for all such opcodes.

New tests for generating SPIRV float and integer dot intrinsics are
added as well.

Fixes #88056

>From 6fde4bc98d0156024cf7acc27e2e986b9bec3993 Mon Sep 17 00:00:00 2001
From: Greg Roth 
Date: Fri, 2 Aug 2024 20:10:04 -0600
Subject: [PATCH 1/3] Create llvm dot intrinsic

Per https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
`dot` should be an LLVM intrinsic. This adds the llvm intrinsics
and updates HLSL builtin codegen to emit them.

Removed some stale comments that gave the obsolete impression that
type conversions should be expected to match overloads.

With dot moving into an LLVM intrinsic, the lowering to dx-specific
operations doesn't take place until DXIL intrinsic expansion. This
moves the introduction of arity-specific DX opcodes to DXIL
intrinsic expansion.

Part of #88056
---
 clang/lib/CodeGen/CGBuiltin.cpp   |  47 +++--
 .../CodeGenHLSL/builtins/dot-builtin.hlsl |  12 +-
 clang/test/CodeGenHLSL/builtins/dot.hlsl  | 160 +-
 llvm/include/llvm/IR/Intrinsics.td|   9 +
 .../Target/DirectX/DXILIntrinsicExpansion.cpp |  61 +--
 5 files changed, 159 insertions(+), 130 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7fe80b0cbdfbfa..67148e32014ed2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18470,22 +18470,14 @@ llvm::Value 
*CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
   return Arg;
 }
 
-Intrinsic::ID getDotProductIntrinsic(QualType QT, int elementCount) {
-  if (QT->hasFloatingRepresentation()) {
-switch (elementCount) {
-case 2:
-  return Intrinsic::dx_dot2;
-case 3:
-  return Intrinsic::dx_dot3;
-case 4:
-  return Intrinsic::dx_dot4;
-}
-  }
-  if (QT->hasSignedIntegerRepresentation())
-return Intrinsic::dx_sdot;
-
-  assert(QT->hasUnsignedIntegerRepresentation());
-  return Intrinsic::dx_udot;
+// Return dot product intrinsic that corresponds to the QT scalar type
+Intrinsic::ID getDotProductIntrinsic(QualType QT) {
+  if (QT->isFloatingType())
+return Intrinsic::fdot;
+  if (QT->isSignedIntegerType())
+return Intrinsic::sdot;
+  assert(QT->isUnsignedIntegerType());
+  return Intrinsic::udot;
 }
 
 Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
@@ -18528,37 +18520,38 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 Value *Op1 = EmitScalarExpr(E->getArg(1));
 llvm::Type *T0 = Op0->getType();
 llvm::Type *T1 = Op1->getType();
+
+// If the arguments are scalars, just emit a multiply
 if (!T0->isVectorTy() && !T1->isVectorTy()) {
   if (T0->isFloatingPointTy())
-return Builder.CreateFMul(Op0, Op1, "dx.dot");
+return Builder.CreateFMul(Op0, Op1, "dot");
 
   if (T0->isIntegerTy())
-return Builder.CreateMul(Op0, Op1, "dx.dot");
+return Builder.CreateMul(Op0, Op1, "dot");
 
-  // Bools should have been promoted
   llvm_unreachable(
   "Scalar dot product is only supported on ints and floats.");
 }
+// For vectors, validate types and emit the appropriate intrinsic
+
 // A VectorSplat should have happened
 assert(T0->isVectorTy() && T1->isVectorTy() &&
"Dot product of vector and scalar is not supported.");
 
-// A vector sext or sitofp should have happened
-assert(T0->getScalarType() == T1->getScalarType() &&
-   "Dot product of vectors need the same element types.");
-
 auto *VecTy0 = E->getArg(0)->getType()->getAs();
 [[maybe_unused]] auto *VecTy1 =
 E->getArg(1)->getType()->getAs();
-// A HLSLVectorTruncation should have happend
+
+assert(VecTy0->getElementType() == VecTy1->getElementType() &&
+   "Dot product of vectors need the same element ty

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-directx

Author: Greg Roth (pow2clk)


Changes

Per https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
`dot` should be an LLVM intrinsic. This adds the llvm intrinsics
and updates HLSL builtin codegen to emit them.

Removed some stale comments that gave the obsolete impression that
type conversions should be expected to match overloads.

With dot moving into an LLVM intrinsic, the lowering to dx-specific
operations doesn't take place until DXIL intrinsic expansion. This
moves the introduction of arity-specific DX opcodes to DXIL
intrinsic expansion.

The new LLVM integer intrinsics replace the previous dx intrinsics.
This updates the DXIL intrinsic expansion code and tests to use and
expect the new integer intrinsics and the flattened DX floating
vector size variants only after op lowering.

Use the new LLVM dot intrinsics to build SPIRV instructions.
This involves generating multiply and add operations for integers
and the existing OpDot operation for floating point. This includes
adding some generic opcodes for signed, unsigned and floats.
These require updating an existing test for all such opcodes.

New tests for generating SPIRV float and integer dot intrinsics are
added as well.

Fixes #88056

---

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


17 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+20-27) 
- (modified) clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl (+6-6) 
- (modified) clang/test/CodeGenHLSL/builtins/dot.hlsl (+80-80) 
- (modified) llvm/include/llvm/IR/Intrinsics.td (+9) 
- (modified) llvm/include/llvm/IR/IntrinsicsDirectX.td (+6-14) 
- (modified) llvm/include/llvm/Support/TargetOpcodes.def (+9) 
- (modified) llvm/include/llvm/Target/GenericOpcodes.td (+21) 
- (modified) llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp (+6) 
- (modified) llvm/lib/Target/DirectX/DXIL.td (+3-3) 
- (modified) llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp (+50-22) 
- (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (+69) 
- (modified) llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp (+3) 
- (modified) llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir 
(+9) 
- (modified) llvm/test/CodeGen/DirectX/fdot.ll (+62-55) 
- (modified) llvm/test/CodeGen/DirectX/idot.ll (+17-17) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fdot.ll (+75) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/idot.ll (+88) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7fe80b0cbdfbfa..67148e32014ed2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18470,22 +18470,14 @@ llvm::Value 
*CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
   return Arg;
 }
 
-Intrinsic::ID getDotProductIntrinsic(QualType QT, int elementCount) {
-  if (QT->hasFloatingRepresentation()) {
-switch (elementCount) {
-case 2:
-  return Intrinsic::dx_dot2;
-case 3:
-  return Intrinsic::dx_dot3;
-case 4:
-  return Intrinsic::dx_dot4;
-}
-  }
-  if (QT->hasSignedIntegerRepresentation())
-return Intrinsic::dx_sdot;
-
-  assert(QT->hasUnsignedIntegerRepresentation());
-  return Intrinsic::dx_udot;
+// Return dot product intrinsic that corresponds to the QT scalar type
+Intrinsic::ID getDotProductIntrinsic(QualType QT) {
+  if (QT->isFloatingType())
+return Intrinsic::fdot;
+  if (QT->isSignedIntegerType())
+return Intrinsic::sdot;
+  assert(QT->isUnsignedIntegerType());
+  return Intrinsic::udot;
 }
 
 Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
@@ -18528,37 +18520,38 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 Value *Op1 = EmitScalarExpr(E->getArg(1));
 llvm::Type *T0 = Op0->getType();
 llvm::Type *T1 = Op1->getType();
+
+// If the arguments are scalars, just emit a multiply
 if (!T0->isVectorTy() && !T1->isVectorTy()) {
   if (T0->isFloatingPointTy())
-return Builder.CreateFMul(Op0, Op1, "dx.dot");
+return Builder.CreateFMul(Op0, Op1, "dot");
 
   if (T0->isIntegerTy())
-return Builder.CreateMul(Op0, Op1, "dx.dot");
+return Builder.CreateMul(Op0, Op1, "dot");
 
-  // Bools should have been promoted
   llvm_unreachable(
   "Scalar dot product is only supported on ints and floats.");
 }
+// For vectors, validate types and emit the appropriate intrinsic
+
 // A VectorSplat should have happened
 assert(T0->isVectorTy() && T1->isVectorTy() &&
"Dot product of vector and scalar is not supported.");
 
-// A vector sext or sitofp should have happened
-assert(T0->getScalarType() == T1->getScalarType() &&
-   "Dot product of vectors need the same element types.");
-
 auto *VecTy0 = E->getArg(0)->getType()->getAs();
 [[maybe_unused]] auto *VecTy1 =
 E->getArg(1)->getType()-

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-globalisel

Author: Greg Roth (pow2clk)


Changes

Per https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
`dot` should be an LLVM intrinsic. This adds the llvm intrinsics
and updates HLSL builtin codegen to emit them.

Removed some stale comments that gave the obsolete impression that
type conversions should be expected to match overloads.

With dot moving into an LLVM intrinsic, the lowering to dx-specific
operations doesn't take place until DXIL intrinsic expansion. This
moves the introduction of arity-specific DX opcodes to DXIL
intrinsic expansion.

The new LLVM integer intrinsics replace the previous dx intrinsics.
This updates the DXIL intrinsic expansion code and tests to use and
expect the new integer intrinsics and the flattened DX floating
vector size variants only after op lowering.

Use the new LLVM dot intrinsics to build SPIRV instructions.
This involves generating multiply and add operations for integers
and the existing OpDot operation for floating point. This includes
adding some generic opcodes for signed, unsigned and floats.
These require updating an existing test for all such opcodes.

New tests for generating SPIRV float and integer dot intrinsics are
added as well.

Fixes #88056

---

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


17 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+20-27) 
- (modified) clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl (+6-6) 
- (modified) clang/test/CodeGenHLSL/builtins/dot.hlsl (+80-80) 
- (modified) llvm/include/llvm/IR/Intrinsics.td (+9) 
- (modified) llvm/include/llvm/IR/IntrinsicsDirectX.td (+6-14) 
- (modified) llvm/include/llvm/Support/TargetOpcodes.def (+9) 
- (modified) llvm/include/llvm/Target/GenericOpcodes.td (+21) 
- (modified) llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp (+6) 
- (modified) llvm/lib/Target/DirectX/DXIL.td (+3-3) 
- (modified) llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp (+50-22) 
- (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (+69) 
- (modified) llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp (+3) 
- (modified) llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir 
(+9) 
- (modified) llvm/test/CodeGen/DirectX/fdot.ll (+62-55) 
- (modified) llvm/test/CodeGen/DirectX/idot.ll (+17-17) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fdot.ll (+75) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/idot.ll (+88) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7fe80b0cbdfbfa..67148e32014ed2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18470,22 +18470,14 @@ llvm::Value 
*CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
   return Arg;
 }
 
-Intrinsic::ID getDotProductIntrinsic(QualType QT, int elementCount) {
-  if (QT->hasFloatingRepresentation()) {
-switch (elementCount) {
-case 2:
-  return Intrinsic::dx_dot2;
-case 3:
-  return Intrinsic::dx_dot3;
-case 4:
-  return Intrinsic::dx_dot4;
-}
-  }
-  if (QT->hasSignedIntegerRepresentation())
-return Intrinsic::dx_sdot;
-
-  assert(QT->hasUnsignedIntegerRepresentation());
-  return Intrinsic::dx_udot;
+// Return dot product intrinsic that corresponds to the QT scalar type
+Intrinsic::ID getDotProductIntrinsic(QualType QT) {
+  if (QT->isFloatingType())
+return Intrinsic::fdot;
+  if (QT->isSignedIntegerType())
+return Intrinsic::sdot;
+  assert(QT->isUnsignedIntegerType());
+  return Intrinsic::udot;
 }
 
 Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
@@ -18528,37 +18520,38 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 Value *Op1 = EmitScalarExpr(E->getArg(1));
 llvm::Type *T0 = Op0->getType();
 llvm::Type *T1 = Op1->getType();
+
+// If the arguments are scalars, just emit a multiply
 if (!T0->isVectorTy() && !T1->isVectorTy()) {
   if (T0->isFloatingPointTy())
-return Builder.CreateFMul(Op0, Op1, "dx.dot");
+return Builder.CreateFMul(Op0, Op1, "dot");
 
   if (T0->isIntegerTy())
-return Builder.CreateMul(Op0, Op1, "dx.dot");
+return Builder.CreateMul(Op0, Op1, "dot");
 
-  // Bools should have been promoted
   llvm_unreachable(
   "Scalar dot product is only supported on ints and floats.");
 }
+// For vectors, validate types and emit the appropriate intrinsic
+
 // A VectorSplat should have happened
 assert(T0->isVectorTy() && T1->isVectorTy() &&
"Dot product of vector and scalar is not supported.");
 
-// A vector sext or sitofp should have happened
-assert(T0->getScalarType() == T1->getScalarType() &&
-   "Dot product of vectors need the same element types.");
-
 auto *VecTy0 = E->getArg(0)->getType()->getAs();
 [[maybe_unused]] auto *VecTy1 =
 E->getArg(1)->getType()-

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-hlsl

@llvm/pr-subscribers-clang

Author: Greg Roth (pow2clk)


Changes

Per https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
`dot` should be an LLVM intrinsic. This adds the llvm intrinsics
and updates HLSL builtin codegen to emit them.

Removed some stale comments that gave the obsolete impression that
type conversions should be expected to match overloads.

With dot moving into an LLVM intrinsic, the lowering to dx-specific
operations doesn't take place until DXIL intrinsic expansion. This
moves the introduction of arity-specific DX opcodes to DXIL
intrinsic expansion.

The new LLVM integer intrinsics replace the previous dx intrinsics.
This updates the DXIL intrinsic expansion code and tests to use and
expect the new integer intrinsics and the flattened DX floating
vector size variants only after op lowering.

Use the new LLVM dot intrinsics to build SPIRV instructions.
This involves generating multiply and add operations for integers
and the existing OpDot operation for floating point. This includes
adding some generic opcodes for signed, unsigned and floats.
These require updating an existing test for all such opcodes.

New tests for generating SPIRV float and integer dot intrinsics are
added as well.

Fixes #88056

---

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


17 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+20-27) 
- (modified) clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl (+6-6) 
- (modified) clang/test/CodeGenHLSL/builtins/dot.hlsl (+80-80) 
- (modified) llvm/include/llvm/IR/Intrinsics.td (+9) 
- (modified) llvm/include/llvm/IR/IntrinsicsDirectX.td (+6-14) 
- (modified) llvm/include/llvm/Support/TargetOpcodes.def (+9) 
- (modified) llvm/include/llvm/Target/GenericOpcodes.td (+21) 
- (modified) llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp (+6) 
- (modified) llvm/lib/Target/DirectX/DXIL.td (+3-3) 
- (modified) llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp (+50-22) 
- (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (+69) 
- (modified) llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp (+3) 
- (modified) llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir 
(+9) 
- (modified) llvm/test/CodeGen/DirectX/fdot.ll (+62-55) 
- (modified) llvm/test/CodeGen/DirectX/idot.ll (+17-17) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fdot.ll (+75) 
- (added) llvm/test/CodeGen/SPIRV/hlsl-intrinsics/idot.ll (+88) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7fe80b0cbdfbfa..67148e32014ed2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18470,22 +18470,14 @@ llvm::Value 
*CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
   return Arg;
 }
 
-Intrinsic::ID getDotProductIntrinsic(QualType QT, int elementCount) {
-  if (QT->hasFloatingRepresentation()) {
-switch (elementCount) {
-case 2:
-  return Intrinsic::dx_dot2;
-case 3:
-  return Intrinsic::dx_dot3;
-case 4:
-  return Intrinsic::dx_dot4;
-}
-  }
-  if (QT->hasSignedIntegerRepresentation())
-return Intrinsic::dx_sdot;
-
-  assert(QT->hasUnsignedIntegerRepresentation());
-  return Intrinsic::dx_udot;
+// Return dot product intrinsic that corresponds to the QT scalar type
+Intrinsic::ID getDotProductIntrinsic(QualType QT) {
+  if (QT->isFloatingType())
+return Intrinsic::fdot;
+  if (QT->isSignedIntegerType())
+return Intrinsic::sdot;
+  assert(QT->isUnsignedIntegerType());
+  return Intrinsic::udot;
 }
 
 Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
@@ -18528,37 +18520,38 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 Value *Op1 = EmitScalarExpr(E->getArg(1));
 llvm::Type *T0 = Op0->getType();
 llvm::Type *T1 = Op1->getType();
+
+// If the arguments are scalars, just emit a multiply
 if (!T0->isVectorTy() && !T1->isVectorTy()) {
   if (T0->isFloatingPointTy())
-return Builder.CreateFMul(Op0, Op1, "dx.dot");
+return Builder.CreateFMul(Op0, Op1, "dot");
 
   if (T0->isIntegerTy())
-return Builder.CreateMul(Op0, Op1, "dx.dot");
+return Builder.CreateMul(Op0, Op1, "dot");
 
-  // Bools should have been promoted
   llvm_unreachable(
   "Scalar dot product is only supported on ints and floats.");
 }
+// For vectors, validate types and emit the appropriate intrinsic
+
 // A VectorSplat should have happened
 assert(T0->isVectorTy() && T1->isVectorTy() &&
"Dot product of vector and scalar is not supported.");
 
-// A vector sext or sitofp should have happened
-assert(T0->getScalarType() == T1->getScalarType() &&
-   "Dot product of vectors need the same element types.");
-
 auto *VecTy0 = E->getArg(0)->getType()->getAs();
 [[maybe_unused]] auto *VecTy1 =
 E->getAr

[clang] [llvm] [MC] Emit a jump table size section (PR #101962)

2024-08-12 Thread Nabeel Omer via cfe-commits

omern1 wrote:

> Conventionally, .debug_* sections are reserved for DWARF, even without 
> official standards.
GNU strip's default behavior --strip-all, emulated by llvm-objcopy's 
--strip-all-gnu option, is roughly to remove non-SHF_ALLOC sections that are 
not debug.
> The .llvm prefix holds no special meaning.
>
> When designing new sections, we should not adapt to the --strip-all-gnu 
> behavior.

Thanks, it appears that you're suggesting removing the `.debug_` bit from the 
name of the section, is that correct?

> Jump tables exhibit diverse structures. For instance, consider 
> llvm/test/CodeGen/ARM/jump-table-tbh.ll and Mach-O's .data_region.

Jump tables of type `EK_Inline` aren't handled in ASM printer so I think they 
should be kept out of the scope of this patch. I'll look into the Macho-O data 
region stuff.


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


[clang] [clang][Interp] Compile field+base destruction into class dtor func (PR #102871)

2024-08-12 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/102871

>From c906a9932b68485e40b368cecd7f4b5c83fb47d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 12 Aug 2024 11:45:27 +0200
Subject: [PATCH] [clang][Interp] Compile field+base destruction into class
 dtor func

---
 clang/lib/AST/Interp/Compiler.cpp| 97 +---
 clang/lib/AST/Interp/Compiler.h  |  1 +
 clang/lib/AST/Interp/Interp.cpp  | 24 ---
 clang/test/AST/Interp/cxx20.cpp  |  3 +-
 clang/test/AST/Interp/new-delete.cpp |  5 +-
 5 files changed, 62 insertions(+), 68 deletions(-)

diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index dd24cff1bab46e..aeede9cf42e569 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -4856,6 +4856,50 @@ bool Compiler::compileConstructor(const 
CXXConstructorDecl *Ctor) {
   return this->emitRetVoid(SourceInfo{});
 }
 
+template 
+bool Compiler::compileDestructor(const CXXDestructorDecl *Dtor) {
+  const RecordDecl *RD = Dtor->getParent();
+  const Record *R = this->getRecord(RD);
+  if (!R)
+return false;
+
+  if (!this->emitThis(Dtor))
+return false;
+
+  assert(R);
+  if (!R->isUnion()) {
+// First, destroy all fields.
+for (const Record::Field &Field : llvm::reverse(R->fields())) {
+  const Descriptor *D = Field.Desc;
+  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
+if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
+  return false;
+if (!this->emitDestruction(D))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+}
+  }
+
+  if (!Dtor->isTrivial() && Dtor->getBody()) {
+if (!this->visitStmt(Dtor->getBody()))
+  return false;
+  }
+
+  for (const Record::Base &Base : llvm::reverse(R->bases())) {
+if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
+  return false;
+if (!this->emitRecordDestruction(Base.R))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+
+  // FIXME: Virtual bases.
+  return this->emitPopPtr(Dtor) && this->emitRetVoid(Dtor);
+}
+
 template 
 bool Compiler::visitFunc(const FunctionDecl *F) {
   // Classify the return type.
@@ -4863,6 +4907,8 @@ bool Compiler::visitFunc(const FunctionDecl *F) {
 
   if (const auto *Ctor = dyn_cast(F))
 return this->compileConstructor(Ctor);
+  if (const auto *Dtor = dyn_cast(F))
+return this->compileDestructor(Dtor);
 
   // Emit custom code if this is a lambda static invoker.
   if (const auto *MD = dyn_cast(F);
@@ -5573,46 +5619,19 @@ bool Compiler::emitComplexComparison(const 
Expr *LHS, const Expr *RHS,
 template 
 bool Compiler::emitRecordDestruction(const Record *R) {
   assert(R);
-  if (!R->isUnion()) {
-// First, destroy all fields.
-for (const Record::Field &Field : llvm::reverse(R->fields())) {
-  const Descriptor *D = Field.Desc;
-  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
-if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
-  return false;
-if (!this->emitDestruction(D))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
-}
-  }
-
-  // Now emit the destructor and recurse into base classes.
-  if (const CXXDestructorDecl *Dtor = R->getDestructor();
-  Dtor && !Dtor->isTrivial()) {
-const Function *DtorFunc = getFunction(Dtor);
-if (!DtorFunc)
-  return false;
-assert(DtorFunc->hasThisPointer());
-assert(DtorFunc->getNumParams() == 1);
-if (!this->emitDupPtr(SourceInfo{}))
-  return false;
-if (!this->emitCall(DtorFunc, 0, SourceInfo{}))
-  return false;
-  }
-
-  for (const Record::Base &Base : llvm::reverse(R->bases())) {
-if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
-  return false;
-if (!this->emitRecordDestruction(Base.R))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
+  const CXXDestructorDecl *Dtor = R->getDestructor();
+  if (!Dtor || Dtor->isTrivial())
+return true;
 
-  // FIXME: Virtual bases.
-  return true;
+  assert(Dtor);
+  const Function *DtorFunc = getFunction(Dtor);
+  if (!DtorFunc)
+return false;
+  assert(DtorFunc->hasThisPointer());
+  assert(DtorFunc->getNumParams() == 1);
+  if (!this->emitDupPtr(SourceInfo{}))
+return false;
+  return this->emitCall(DtorFunc, 0, SourceInfo{});
 }
 /// When calling this, we have a pointer of the local-to-destroy
 /// on the stack.
diff --git a/clang/lib/AST/Interp/Compiler.h b/clang/lib/AST/Interp/Compiler.h
index d94d3613775a19..112219c49e8bdd 100644
--- a/clang/lib/AST/Interp/Compiler.h
+++ b/clang/lib/AST/Interp/Compiler.h
@@ -358,6 +358,7 @@ class Compiler : public ConstStmtVisitor, 
bool>,
  const QualType DerivedType);
   bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
   bool

[libunwind] [libunwind] Add GCS support for AArch64 (PR #99335)

2024-08-12 Thread John Brawn via cfe-commits

john-brawn-arm wrote:

/cherry-pick b32aac4 c649194 3952910

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


[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits

https://github.com/pow2clk commented:

The three commits are independently committable, but this is the grouping 
@farzonl and I agreed on. Reviewing them individually still might make this 
easier: 

1. Create llvm dot intrinsic (6fde4bc98d0156024cf7acc27e2e986b9bec3993)
2. Update DX intrinsic expansion for new llvm intrinsics 
(7ca6bc5940321c18f5634bb960fa795366097e45)
3. Add SPIRV generation for HLSL dot (490c0c05c5762a622d037b472c85234ce3f39c96)

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


[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits

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


[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits


@@ -18528,37 +18520,38 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 Value *Op1 = EmitScalarExpr(E->getArg(1));
 llvm::Type *T0 = Op0->getType();
 llvm::Type *T1 = Op1->getType();
+
+// If the arguments are scalars, just emit a multiply
 if (!T0->isVectorTy() && !T1->isVectorTy()) {
   if (T0->isFloatingPointTy())
-return Builder.CreateFMul(Op0, Op1, "dx.dot");
+return Builder.CreateFMul(Op0, Op1, "dot");
 
   if (T0->isIntegerTy())
-return Builder.CreateMul(Op0, Op1, "dx.dot");
+return Builder.CreateMul(Op0, Op1, "dot");
 
-  // Bools should have been promoted
   llvm_unreachable(
   "Scalar dot product is only supported on ints and floats.");
 }
+// For vectors, validate types and emit the appropriate intrinsic
+
 // A VectorSplat should have happened
 assert(T0->isVectorTy() && T1->isVectorTy() &&
"Dot product of vector and scalar is not supported.");
 
-// A vector sext or sitofp should have happened
-assert(T0->getScalarType() == T1->getScalarType() &&
-   "Dot product of vectors need the same element types.");
-
 auto *VecTy0 = E->getArg(0)->getType()->getAs();
 [[maybe_unused]] auto *VecTy1 =
 E->getArg(1)->getType()->getAs();
-// A HLSLVectorTruncation should have happend
+
+assert(VecTy0->getElementType() == VecTy1->getElementType() &&

pow2clk wrote:

Switched to clang types to match signedness of integers

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


[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits


@@ -659,7 +659,7 @@ def Dot3 :  DXILOp<55, dot3> {
 
 def Dot4 :  DXILOp<56, dot4> {
   let Doc = "dot product of two float vectors Dot(a,b) = a[0]*b[0] + ... + "
-"a[n]*b[n] where n is between 0 and 3";
+"a[n]*b[n] where n is 0 to 3 inclusive";

pow2clk wrote:

Just something incidental as I found these descriptions misleading since the 
only numbers "between" 0 and 3 are 1 and 2.

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


[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits


@@ -7,155 +7,155 @@
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
 
 #ifdef __HLSL_ENABLE_16_BIT
-// NATIVE_HALF: %dx.dot = mul i16 %0, %1
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = mul i16 %0, %1
+// NATIVE_HALF: ret i16 %dot
 int16_t test_dot_short(int16_t p0, int16_t p1) { return dot(p0, p1); }
 
-// NATIVE_HALF: %dx.dot = call i16 @llvm.dx.sdot.v2i16(<2 x i16> %0, <2 x i16> 
%1)
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = call i16 @llvm.sdot.v2i16(<2 x i16> %0, <2 x i16> %1)
+// NATIVE_HALF: ret i16 %dot
 int16_t test_dot_short2(int16_t2 p0, int16_t2 p1) { return dot(p0, p1); }
 
-// NATIVE_HALF: %dx.dot = call i16 @llvm.dx.sdot.v3i16(<3 x i16> %0, <3 x i16> 
%1)
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = call i16 @llvm.sdot.v3i16(<3 x i16> %0, <3 x i16> %1)
+// NATIVE_HALF: ret i16 %dot
 int16_t test_dot_short3(int16_t3 p0, int16_t3 p1) { return dot(p0, p1); }
 
-// NATIVE_HALF: %dx.dot = call i16 @llvm.dx.sdot.v4i16(<4 x i16> %0, <4 x i16> 
%1)
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = call i16 @llvm.sdot.v4i16(<4 x i16> %0, <4 x i16> %1)
+// NATIVE_HALF: ret i16 %dot
 int16_t test_dot_short4(int16_t4 p0, int16_t4 p1) { return dot(p0, p1); }
 
-// NATIVE_HALF: %dx.dot = mul i16 %0, %1
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = mul i16 %0, %1
+// NATIVE_HALF: ret i16 %dot
 uint16_t test_dot_ushort(uint16_t p0, uint16_t p1) { return dot(p0, p1); }
 
-// NATIVE_HALF: %dx.dot = call i16 @llvm.dx.udot.v2i16(<2 x i16> %0, <2 x i16> 
%1)
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = call i16 @llvm.udot.v2i16(<2 x i16> %0, <2 x i16> %1)
+// NATIVE_HALF: ret i16 %dot
 uint16_t test_dot_ushort2(uint16_t2 p0, uint16_t2 p1) { return dot(p0, p1); }
 
-// NATIVE_HALF: %dx.dot = call i16 @llvm.dx.udot.v3i16(<3 x i16> %0, <3 x i16> 
%1)
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = call i16 @llvm.udot.v3i16(<3 x i16> %0, <3 x i16> %1)
+// NATIVE_HALF: ret i16 %dot
 uint16_t test_dot_ushort3(uint16_t3 p0, uint16_t3 p1) { return dot(p0, p1); }
 
-// NATIVE_HALF: %dx.dot = call i16 @llvm.dx.udot.v4i16(<4 x i16> %0, <4 x i16> 
%1)
-// NATIVE_HALF: ret i16 %dx.dot
+// NATIVE_HALF: %dot = call i16 @llvm.udot.v4i16(<4 x i16> %0, <4 x i16> %1)
+// NATIVE_HALF: ret i16 %dot
 uint16_t test_dot_ushort4(uint16_t4 p0, uint16_t4 p1) { return dot(p0, p1); }
 #endif
 
-// CHECK: %dx.dot = mul i32 %0, %1
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = mul i32 %0, %1
+// CHECK: ret i32 %dot
 int test_dot_int(int p0, int p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i32 @llvm.dx.sdot.v2i32(<2 x i32> %0, <2 x i32> %1)
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = call i32 @llvm.sdot.v2i32(<2 x i32> %0, <2 x i32> %1)
+// CHECK: ret i32 %dot
 int test_dot_int2(int2 p0, int2 p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i32 @llvm.dx.sdot.v3i32(<3 x i32> %0, <3 x i32> %1)
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = call i32 @llvm.sdot.v3i32(<3 x i32> %0, <3 x i32> %1)
+// CHECK: ret i32 %dot
 int test_dot_int3(int3 p0, int3 p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i32 @llvm.dx.sdot.v4i32(<4 x i32> %0, <4 x i32> %1)
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = call i32 @llvm.sdot.v4i32(<4 x i32> %0, <4 x i32> %1)
+// CHECK: ret i32 %dot
 int test_dot_int4(int4 p0, int4 p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = mul i32 %0, %1
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = mul i32 %0, %1
+// CHECK: ret i32 %dot
 uint test_dot_uint(uint p0, uint p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i32 @llvm.dx.udot.v2i32(<2 x i32> %0, <2 x i32> %1)
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = call i32 @llvm.udot.v2i32(<2 x i32> %0, <2 x i32> %1)
+// CHECK: ret i32 %dot
 uint test_dot_uint2(uint2 p0, uint2 p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i32 @llvm.dx.udot.v3i32(<3 x i32> %0, <3 x i32> %1)
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = call i32 @llvm.udot.v3i32(<3 x i32> %0, <3 x i32> %1)
+// CHECK: ret i32 %dot
 uint test_dot_uint3(uint3 p0, uint3 p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i32 @llvm.dx.udot.v4i32(<4 x i32> %0, <4 x i32> %1)
-// CHECK: ret i32 %dx.dot
+// CHECK: %dot = call i32 @llvm.udot.v4i32(<4 x i32> %0, <4 x i32> %1)
+// CHECK: ret i32 %dot
 uint test_dot_uint4(uint4 p0, uint4 p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = mul i64 %0, %1
-// CHECK: ret i64 %dx.dot
+// CHECK: %dot = mul i64 %0, %1
+// CHECK: ret i64 %dot
 int64_t test_dot_long(int64_t p0, int64_t p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i64 @llvm.dx.sdot.v2i64(<2 x i64> %0, <2 x i64> %1)
-// CHECK: ret i64 %dx.dot
+// CHECK: %dot = call i64 @llvm.sdot.v2i64(<2 x i64> %0, <2 x i64> %1)
+// CHECK: ret i64 %dot
 int64_t test_dot_long2(int64_t2 p0, int64_t2 p1) { return dot(p0, p1); }
 
-// CHECK: %dx.dot = call i64 @llvm.dx.sdot.v3i64(<3 x i64> %0, <3 x i64> %1)
-// CHECK: ret i64 %dx.dot
+// CHECK: %dot = call i64 @llvm.sdot.v3i64(<3 x i64> %

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits


@@ -380,6 +383,20 @@ bool SPIRVInstructionSelector::spvSelect(Register ResVReg,
   MIB.addImm(V);
 return MIB.constrainAllUses(TII, TRI, RBI);
   }
+
+  case TargetOpcode::G_FDOTPROD: {
+MachineBasicBlock &BB = *I.getParent();
+return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpDot))
+.addDef(ResVReg)
+.addUse(GR.getSPIRVTypeID(ResType))
+.addUse(I.getOperand(1).getReg())
+.addUse(I.getOperand(2).getReg())
+.constrainAllUses(TII, TRI, RBI);
+  }

pow2clk wrote:

There is a similar implementation here: 
https://github.com/llvm/llvm-project/blob/a0241e710fcae9f439e57d3a294b1ace97c6906c/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp#L1524
 , but I'm not sure if they are mergeable and this is what was discussed.

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


[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits


@@ -1057,6 +1057,27 @@ def G_FTANH : GenericInstruction {
   let hasSideEffects = false;
 }
 
+/// Floating point vector dot product
+def G_FDOTPROD : GenericInstruction {
+  let OutOperandList = (outs type0:$dst);
+  let InOperandList = (ins type0:$src1, type0:$src2);
+  let hasSideEffects = false;
+}
+
+/// Signed integer vector dot product
+def G_SDOTPROD : GenericInstruction {
+  let OutOperandList = (outs type0:$dst);
+  let InOperandList = (ins type0:$src1, type0:$src2);
+  let hasSideEffects = false;
+}
+
+/// Unsigned integer vector dot product
+def G_UDOTPROD : GenericInstruction {

pow2clk wrote:

The unweildy names are because G_UDOT and G_SDOT clashed with existing AArch64 
intrinsics that take three arguments as one is an accumulated inout parameter. 
https://github.com/llvm/llvm-project/blob/908c89e04b6019bdb08bb5f1c861af42046db623/llvm/lib/Target/AArch64/AArch64InstrGISel.td#L254

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


[clang] 4915fdd - [Serialization] Add a callback to register new created predefined decls for DeserializationListener (#102855)

2024-08-12 Thread via cfe-commits

Author: Chuanqi Xu
Date: 2024-08-12T18:27:37+08:00
New Revision: 4915fddbb2d79b5d67794b88c23da8d296968d0e

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

LOG: [Serialization] Add a callback to register new created predefined decls 
for DeserializationListener (#102855)

Close https://github.com/llvm/llvm-project/issues/102684

The root cause of the issue is, it is possible that the predefined decl
is not registered at the beginning of writing a module file but got
created during the process of writing from reading.

This is incorrect. The predefined decls should always be predefined
decls.

Another deep thought about the issue is, we shouldn't read any new
things after we start to write the module file. But this is another
deeper question.

Added: 
clang/test/Modules/pr102684.cppm

Modified: 
clang/include/clang/Frontend/MultiplexConsumer.h
clang/include/clang/Serialization/ASTDeserializationListener.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Frontend/MultiplexConsumer.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/MultiplexConsumer.h 
b/clang/include/clang/Frontend/MultiplexConsumer.h
index e49e3392d1f317..3a7670d7a51aa6 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -36,6 +36,7 @@ class MultiplexASTDeserializationListener : public 
ASTDeserializationListener {
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
   void DeclRead(GlobalDeclID ID, const Decl *D) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinitionRecord *MD) override;

diff  --git a/clang/include/clang/Serialization/ASTDeserializationListener.h 
b/clang/include/clang/Serialization/ASTDeserializationListener.h
index 1d81a9ae3fe2eb..ea96faa07c1917 100644
--- a/clang/include/clang/Serialization/ASTDeserializationListener.h
+++ b/clang/include/clang/Serialization/ASTDeserializationListener.h
@@ -45,6 +45,8 @@ class ASTDeserializationListener {
   virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { }
   /// A decl was deserialized from the AST file.
   virtual void DeclRead(GlobalDeclID ID, const Decl *D) {}
+  /// A predefined decl was built during the serialization.
+  virtual void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {}
   /// A selector was read from the AST file.
   virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
   /// A macro definition was read from the AST file.

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 549396a3b6b387..a0e90e62bd60ec 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1559,6 +1559,9 @@ class ASTReader
   std::pair
   translateTypeIDToIndex(serialization::TypeID ID) const;
 
+  /// Get a predefined Decl from ASTContext.
+  Decl *getPredefinedDecl(PredefinedDeclIDs ID);
+
 public:
   /// Load the AST file and validate its contents against the given
   /// Preprocessor.

diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 71a7c28047e318..a4cc95cd1373fa 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -869,6 +869,7 @@ class ASTWriter : public ASTDeserializationListener,
   void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) 
override;
   void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
   void TypeRead(serialization::TypeIdx Idx, QualType T) override;
+  void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
   void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
   void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinitionRecord *MD) override;

diff  --git a/clang/lib/Frontend/MultiplexConsumer.cpp 
b/clang/lib/Frontend/MultiplexConsumer.cpp
index 651c55aeed5408..2158d176d18929 100644
--- a/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -58,6 +58,11 @@ void 
MultiplexASTDeserializationListener::DeclRead(GlobalDeclID ID,
 Listeners[i]->DeclRead(ID, D);
 }
 
+void 
MultiplexASTDeserializationListener::PredefinedDeclBuilt(PredefinedDeclIDs ID, 
const Decl *D) {
+  for (si

[clang] [Serialization] Add a callback to register new created predefined decls for DeserializationListener (PR #102855)

2024-08-12 Thread Chuanqi Xu via cfe-commits

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-12 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti requested changes to this pull request.

> maintaining the name of the matched classes in a vector and checking for 
> every other class if it inherits from `::std::enable_shared_from_this` or 
> classes in the vector.

You wouldn't want to save the name, because then you would do a lot of string 
comparisons when you could do pointer comparisons (which would require using 
`RDecl->getCanonical()` to ensure you get the same record decl, I believe).
Instead of a vector, you could use a set. Then checking the base classes would 
simply be a call to `contains` (`llvm::SmallPtrSet`?).

> Wouldn't this necessitate changing the matchers and the check to instead 
> allow RecursiveASTVisitor to handle the context instead?

Kind of. In this case, you would match the translation unit and call 
`TraverseTranslationUnitDecl` on it.
Then you implement `bool VisitCXXRecordDecl(CXXRecordDecl* RDecl)` and check if 
`RDecl` is of type `std::enable_shared_from_this` and adding that to the set if 
it is. Otherwise, checking if it publicly inherits from any class that is 
contained in the set, and adding it to the set if it is. If the inheritance is 
not public, then you can issue a diagnostic. You can save a pointer to the 
check (`ClangTidyCheck* Check`) to do that (`Check->diag(...)`).

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-12 Thread Julian Schmidt via cfe-commits

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-12 Thread Julian Schmidt via cfe-commits


@@ -0,0 +1,34 @@
+.. title:: clang-tidy - bugprone-incorrect-enable-shared-from-this
+
+bugprone-incorrect-enable-shared-from-this
+===
+
+Checks if class/struct publicly derives from ``std::enable_shared_from_this``,
+because otherwise when ``shared_from_this`` is called it will throw 
+``std::bad_weak_ptr``.
+
+Consider the following code:
+
+.. code-block:: c++
+#include 
+
+class BadExample : std::enable_shared_from_this {
+// warning: inheritance from std::enable_shared_from_this 
+// should be public inheritance,
+// otherwise the internal weak_ptr won't be initialized 
+// [bugprone-incorrect-enable-shared-from-this]

5chmidti wrote:

The diagnostics of a check are normally not copy-pasted to the documentation. 
Maybe: 
> privately inheriting from `std::enable_shared_from_this` results in an 
> uninitialized `weak_ptr` when calling `shared_from_this`

Or add smaller comments:

```
 #include 

// private inheritance
class BadExample : std::enable_shared_from_this {
public:

// `shared_from_this` returns uninitialized `weak_ptr`
BadExample* foo() { return shared_from_this().get(); }
void bar() { return; }
};

void using_not_public() {
auto bad_example = std::make_shared();
auto* b_ex = bad_example->foo();
b_ex->bar();
}
```

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-12 Thread Julian Schmidt via cfe-commits


@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s bugprone-incorrect-enable-shared-from-this %t -- 
--
+
+namespace std {
+template  class enable_shared_from_this {};
+} //namespace std
+
+class BadClassExample : std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: inheritance from 
std::enable_shared_from_this should be public inheritance, otherwise the 
internal weak_ptr won't be initialized 
[bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+class BadClass2Example : private 
std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: inheritance from 
std::enable_shared_from_this should be public inheritance, otherwise the 
internal weak_ptr won't be initialized 
[bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+struct BadStructExample : private 
std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inheritance from 
std::enable_shared_from_this should be public inheritance, otherwise the 
internal weak_ptr won't be initialized 
[bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+class GoodClassExample : public std::enable_shared_from_this 
{};
+
+struct GoodStructExample : public 
std::enable_shared_from_this {};
+
+struct GoodStruct2Example : std::enable_shared_from_this 
{};
+
+class dummy_class1 {};
+class dummy_class2 {};
+
+class BadMultiClassExample : 
std::enable_shared_from_this, dummy_class1 {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: inheritance from 
std::enable_shared_from_this should be public inheritance, otherwise the 
internal weak_ptr won't be initialized 
[bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this, 
dummy_class1
+
+class BadMultiClass2Example : dummy_class1, 
std::enable_shared_from_this, dummy_class2 {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: inheritance from 
std::enable_shared_from_this should be public inheritance, otherwise the 
internal weak_ptr won't be initialized 
[bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: dummy_class1, public 
std::enable_shared_from_this, dummy_class2
+
+class BadMultiClass3Example : dummy_class1, dummy_class2, 
std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: inheritance from 
std::enable_shared_from_this should be public inheritance, otherwise the 
internal weak_ptr won't be initialized 
[bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: dummy_class1, dummy_class2, public 
std::enable_shared_from_this
+
+template  class enable_shared_from_this {};
+
+class NoStdClassExample : public enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Should be 
std::enable_shared_from_this [bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+struct NoStdStructExample : enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Should be 
std::enable_shared_from_this [bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: std::enable_shared_from_this
+
+class BadMixedProblemExample : enable_shared_from_this 
{};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Should be 
std::enable_shared_from_this and inheritance from std::enable_shared_from_this 
should be public inheritance, otherwise the internal weak_ptr won't be 
initialized [bugprone-incorrect-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+//FIXME: can't do anything about this, clang-check -ast-dump doesn't show A's 
internals in class B's AST
+class A : public std::enable_shared_from_this {};
+class B : private A{};

5chmidti wrote:

Missing newline

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-12 Thread Julian Schmidt via cfe-commits


@@ -53,6 +53,7 @@
 #include "ParentVirtualCallCheck.h"
 #include "PointerArithmeticOnPolymorphicObjectCheck.h"
 #include "PosixReturnCheck.h"
+#include "IncorrectEnableSharedFromThisCheck.h"

5chmidti wrote:

Please sort this include correctly

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


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-12 Thread Julian Schmidt via cfe-commits


@@ -0,0 +1,33 @@
+//===--- IncorrectEnableSharedFromThisCheck.h - clang-tidy --*- C++ 
-*-===//
+//
+// 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 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_INCORRECTENABLESHAREDFROMTHISCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_INCORRECTENABLESHAREDFROMTHISCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::bugprone {
+
+/// Checks if a class deriving from enable_shared_from_this has public access 
specifiers, because otherwise the program will crash when shared_from_this is 
called.

5chmidti wrote:

Please wrap on 80 columns

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


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-12 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti requested changes to this pull request.

Please add tests, a release notes entry, and document the option in the 
documentation of the check.

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


[clang] [Clang][OpenMP] Fix the wrong transform of `num_teams` claused introduced in #99732 (PR #102716)

2024-08-12 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev approved this pull request.

LG

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


[clang] [Clang][AST] Add Test Cases for Reference Qualifiers in Opr Overload (PR #102878)

2024-08-12 Thread Muhammad Abdul via cfe-commits

https://github.com/0xzre created 
https://github.com/llvm/llvm-project/pull/102878

Follow up of issue #102422 


>From 11b625354ff05c4384603932e6acca347df2132b Mon Sep 17 00:00:00 2001
From: 0xzre 
Date: Mon, 12 Aug 2024 17:42:37 +0700
Subject: [PATCH] [Clang][AST] Add Test Cases for Reference Qualifiers in
 Operator Overloads

---
 clang/test/SemaCXX/function-type-qual.cpp | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/clang/test/SemaCXX/function-type-qual.cpp 
b/clang/test/SemaCXX/function-type-qual.cpp
index f4906f58abbae0..a46b774dc57e69 100644
--- a/clang/test/SemaCXX/function-type-qual.cpp
+++ b/clang/test/SemaCXX/function-type-qual.cpp
@@ -54,4 +54,18 @@ struct B {
   void operator delete(void*) volatile; //expected-error {{static member 
function cannot have 'volatile' qualifier}}
   void operator delete[](void*) volatile; //expected-error {{static member 
function cannot have 'volatile' qualifier}}
 };
+
+struct C {
+  void* operator new(size_t bytes) &;  //expected-error {{static member 
function cannot have '&' qualifier}}
+  void* operator new[](size_t bytes) &;  //expected-error {{static member 
function cannot have '&' qualifier}}
+
+  void* operator new(size_t bytes) &&;  //expected-error {{static member 
function cannot have '&&' qualifier}}
+  void* operator new[](size_t bytes) &&;  //expected-error {{static member 
function cannot have '&&' qualifier}}
+
+  void operator delete(void*) &;  //expected-error {{static member function 
cannot have '&' qualifier}}
+  void operator delete[](void*) &;  //expected-error {{static member function 
cannot have '&' qualifier}}
+
+  void operator delete(void*) &&;  //expected-error {{static member function 
cannot have '&&' qualifier}}
+  void operator delete[](void*) &&;  //expected-error {{static member function 
cannot have '&&' qualifier}}
+};
 }

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


[clang] [Clang][AST] Add Test Cases for Reference Qualifiers in Opr Overload (PR #102878)

2024-08-12 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [Clang][AST] Add Test Cases for Reference Qualifiers in Opr Overload (PR #102878)

2024-08-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Muhammad Abdul  (0xzre)


Changes

Follow up of issue #102422 


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


1 Files Affected:

- (modified) clang/test/SemaCXX/function-type-qual.cpp (+14) 


``diff
diff --git a/clang/test/SemaCXX/function-type-qual.cpp 
b/clang/test/SemaCXX/function-type-qual.cpp
index f4906f58abbae0..a46b774dc57e69 100644
--- a/clang/test/SemaCXX/function-type-qual.cpp
+++ b/clang/test/SemaCXX/function-type-qual.cpp
@@ -54,4 +54,18 @@ struct B {
   void operator delete(void*) volatile; //expected-error {{static member 
function cannot have 'volatile' qualifier}}
   void operator delete[](void*) volatile; //expected-error {{static member 
function cannot have 'volatile' qualifier}}
 };
+
+struct C {
+  void* operator new(size_t bytes) &;  //expected-error {{static member 
function cannot have '&' qualifier}}
+  void* operator new[](size_t bytes) &;  //expected-error {{static member 
function cannot have '&' qualifier}}
+
+  void* operator new(size_t bytes) &&;  //expected-error {{static member 
function cannot have '&&' qualifier}}
+  void* operator new[](size_t bytes) &&;  //expected-error {{static member 
function cannot have '&&' qualifier}}
+
+  void operator delete(void*) &;  //expected-error {{static member function 
cannot have '&' qualifier}}
+  void operator delete[](void*) &;  //expected-error {{static member function 
cannot have '&' qualifier}}
+
+  void operator delete(void*) &&;  //expected-error {{static member function 
cannot have '&&' qualifier}}
+  void operator delete[](void*) &&;  //expected-error {{static member function 
cannot have '&&' qualifier}}
+};
 }

``




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


[clang] Fix assertion failure during conversion function overload resolution. (PR #98671)

2024-08-12 Thread Daniel M. Katz via cfe-commits

katzdm wrote:

@AaronBallman @cor3ntin Would you mind taking another look?

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


[clang] [Clang] handle both gnu and cpp11 attributes to ensure correct parsing inside extern block (PR #102864)

2024-08-12 Thread Oleksandr T. via cfe-commits

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

>From b0e53b1c8a687165fa28bd21200f83bf1b1a9234 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 12 Aug 2024 13:56:30 +0300
Subject: [PATCH] [Clang] handle both gnu and cpp11 attributes to ensure
 correct parsing inside extern block

---
 clang/docs/ReleaseNotes.rst  | 1 +
 clang/lib/Parse/ParseDeclCXX.cpp | 5 -
 clang/test/Parser/attr-order.cpp | 8 
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6796a619ba97f8..00a663fdd23454 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -217,6 +217,7 @@ Bug Fixes to C++ Support
 - Clang now preserves the unexpanded flag in a lambda transform used for pack 
expansion. (#GH56852), (#GH85667),
   (#GH99877).
 - Fixed a bug when diagnosing ambiguous explicit specializations of 
constrained member functions.
+- Clang now properly handles the order of attributes in `extern` blocks. 
(#GH101990).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index aac89d910bbc83..d45a738fe4c596 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -425,7 +425,10 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, 
DeclaratorContext Context) {
   [[fallthrough]];
 default:
   ParsedAttributes DeclAttrs(AttrFactory);
-  MaybeParseCXX11Attributes(DeclAttrs);
+  ParsedAttributes DeclSpecAttrs(AttrFactory);
+  while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+;
   ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
   continue;
 }
diff --git a/clang/test/Parser/attr-order.cpp b/clang/test/Parser/attr-order.cpp
index 10bad38cac6447..369941ab24ee69 100644
--- a/clang/test/Parser/attr-order.cpp
+++ b/clang/test/Parser/attr-order.cpp
@@ -31,3 +31,11 @@ template 
 
 template 
 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void k(); // ok
+
+extern "C" {
+  __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int l(int); // 
ok
+  [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int m(int); // 
ok
+}
+
+extern "C" __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int 
n(int); // ok
+extern "C" [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int 
o(int); // ok

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


[clang] [clang] Fixing Clang HIP inconsistent order for template functions (PR #101627)

2024-08-12 Thread Shivam Gupta via cfe-commits

xgupta wrote:

First CI is failing with error - 

```
clang: error: cannot find ROCm device library; provide its path via 
'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without 
ROCm device library
clang: error: cannot find HIP runtime; provide its path via '--rocm-path', or 
pass '-nogpuinc' to build without HIP runtime
clang: error: cannot find HIP runtime; provide its path via '--rocm-path', or 
pass '-nogpuinc' to build without HIP runtime
```

I think the test run line is not following convention. You can not include 
hip_runtime.h, instead have to use cuda.h 
so probably you need to add cuda.h in . I have tried replacing #include 
"hip/hip_runtime.h" with #include "../CodeGenCUDA/Inputs/cuda.h" and using run 
line like this way  -

```// RUN: x=$( %clang_cc1  -x hip -triple amdgcn  -target-cpu gfx908  
-emit-llvm -fcuda-is-device %s -o - | md5sum | awk '{ print $1 }') && echo $x > 
%t.md5``` to pass the test case. 


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


[clang] [Doc] [C++20] [Modules] Clarify the reachability of internal partition units (PR #102572)

2024-08-12 Thread Aaron Ballman via cfe-commits


@@ -1230,6 +1230,57 @@ parsing their headers, those should be included after 
the import. If the
 imported modules don't provide such a header, one can be made manually for
 improved compile time performance.
 
+Reachability of internal partition units
+
+
+The internal partition units are called as implementation partition unit 
somewhere else.
+But the name may be confusing since implementation partition units are not 
implementation
+units.
+
+According to [module.reach]p1,2:

AaronBallman wrote:

Links only sort of help -- because they're live links, they get out of date 
very quickly. Putting a standard version number there helps the reader to 
understand which standard the quote was true for and they can hunt for the 
wording in the latest draft from there.

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


[clang] [Doc] [C++20] [Modules] Clarify the reachability of internal partition units (PR #102572)

2024-08-12 Thread Aaron Ballman via cfe-commits

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

LGTM

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


[clang] Add flag to suppress overflow errors in C++ constant expressions. (PR #102390)

2024-08-12 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

Thank you for putting together the experiment @efriedma-quic, it's greatly 
appreciated! I agree with closing it for now; we can resurrect it later if 
necessary.

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


[clang] [clang][Interp] Compile field+base destruction into class dtor func (PR #102871)

2024-08-12 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/102871

>From 01849578372cc922562a97f1cfa034b30c0ac6d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 12 Aug 2024 11:45:27 +0200
Subject: [PATCH] [clang][Interp] Compile field+base destruction into class
 dtor func

---
 clang/lib/AST/Interp/Compiler.cpp| 97 +---
 clang/lib/AST/Interp/Compiler.h  |  1 +
 clang/lib/AST/Interp/Interp.cpp  | 24 ---
 clang/test/AST/Interp/cxx20.cpp  |  3 +-
 clang/test/AST/Interp/new-delete.cpp |  5 +-
 5 files changed, 62 insertions(+), 68 deletions(-)

diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index dd24cff1bab46e..aeede9cf42e569 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -4856,6 +4856,50 @@ bool Compiler::compileConstructor(const 
CXXConstructorDecl *Ctor) {
   return this->emitRetVoid(SourceInfo{});
 }
 
+template 
+bool Compiler::compileDestructor(const CXXDestructorDecl *Dtor) {
+  const RecordDecl *RD = Dtor->getParent();
+  const Record *R = this->getRecord(RD);
+  if (!R)
+return false;
+
+  if (!this->emitThis(Dtor))
+return false;
+
+  assert(R);
+  if (!R->isUnion()) {
+// First, destroy all fields.
+for (const Record::Field &Field : llvm::reverse(R->fields())) {
+  const Descriptor *D = Field.Desc;
+  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
+if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
+  return false;
+if (!this->emitDestruction(D))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+}
+  }
+
+  if (!Dtor->isTrivial() && Dtor->getBody()) {
+if (!this->visitStmt(Dtor->getBody()))
+  return false;
+  }
+
+  for (const Record::Base &Base : llvm::reverse(R->bases())) {
+if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
+  return false;
+if (!this->emitRecordDestruction(Base.R))
+  return false;
+if (!this->emitPopPtr(SourceInfo{}))
+  return false;
+  }
+
+  // FIXME: Virtual bases.
+  return this->emitPopPtr(Dtor) && this->emitRetVoid(Dtor);
+}
+
 template 
 bool Compiler::visitFunc(const FunctionDecl *F) {
   // Classify the return type.
@@ -4863,6 +4907,8 @@ bool Compiler::visitFunc(const FunctionDecl *F) {
 
   if (const auto *Ctor = dyn_cast(F))
 return this->compileConstructor(Ctor);
+  if (const auto *Dtor = dyn_cast(F))
+return this->compileDestructor(Dtor);
 
   // Emit custom code if this is a lambda static invoker.
   if (const auto *MD = dyn_cast(F);
@@ -5573,46 +5619,19 @@ bool Compiler::emitComplexComparison(const 
Expr *LHS, const Expr *RHS,
 template 
 bool Compiler::emitRecordDestruction(const Record *R) {
   assert(R);
-  if (!R->isUnion()) {
-// First, destroy all fields.
-for (const Record::Field &Field : llvm::reverse(R->fields())) {
-  const Descriptor *D = Field.Desc;
-  if (!D->isPrimitive() && !D->isPrimitiveArray()) {
-if (!this->emitGetPtrField(Field.Offset, SourceInfo{}))
-  return false;
-if (!this->emitDestruction(D))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
-}
-  }
-
-  // Now emit the destructor and recurse into base classes.
-  if (const CXXDestructorDecl *Dtor = R->getDestructor();
-  Dtor && !Dtor->isTrivial()) {
-const Function *DtorFunc = getFunction(Dtor);
-if (!DtorFunc)
-  return false;
-assert(DtorFunc->hasThisPointer());
-assert(DtorFunc->getNumParams() == 1);
-if (!this->emitDupPtr(SourceInfo{}))
-  return false;
-if (!this->emitCall(DtorFunc, 0, SourceInfo{}))
-  return false;
-  }
-
-  for (const Record::Base &Base : llvm::reverse(R->bases())) {
-if (!this->emitGetPtrBase(Base.Offset, SourceInfo{}))
-  return false;
-if (!this->emitRecordDestruction(Base.R))
-  return false;
-if (!this->emitPopPtr(SourceInfo{}))
-  return false;
-  }
+  const CXXDestructorDecl *Dtor = R->getDestructor();
+  if (!Dtor || Dtor->isTrivial())
+return true;
 
-  // FIXME: Virtual bases.
-  return true;
+  assert(Dtor);
+  const Function *DtorFunc = getFunction(Dtor);
+  if (!DtorFunc)
+return false;
+  assert(DtorFunc->hasThisPointer());
+  assert(DtorFunc->getNumParams() == 1);
+  if (!this->emitDupPtr(SourceInfo{}))
+return false;
+  return this->emitCall(DtorFunc, 0, SourceInfo{});
 }
 /// When calling this, we have a pointer of the local-to-destroy
 /// on the stack.
diff --git a/clang/lib/AST/Interp/Compiler.h b/clang/lib/AST/Interp/Compiler.h
index d94d3613775a19..112219c49e8bdd 100644
--- a/clang/lib/AST/Interp/Compiler.h
+++ b/clang/lib/AST/Interp/Compiler.h
@@ -358,6 +358,7 @@ class Compiler : public ConstStmtVisitor, 
bool>,
  const QualType DerivedType);
   bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
   bool

[clang] [Clang][AST] Add Test Cases for Reference Qualifiers in Opr Overload (PR #102878)

2024-08-12 Thread Yanzuo Liu via cfe-commits


@@ -54,4 +54,18 @@ struct B {
   void operator delete(void*) volatile; //expected-error {{static member 
function cannot have 'volatile' qualifier}}
   void operator delete[](void*) volatile; //expected-error {{static member 
function cannot have 'volatile' qualifier}}
 };
+
+struct C {

zwuis wrote:

```suggestion
struct GH102422 {
```

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


[clang] [Clang] [Sema] Error on reference types inside a union with msvc 1910+ (PR #102851)

2024-08-12 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> I definitely remember this being an extension in older versions of VS around 
> VS 2012 but don't know when MSVC no longer exactly removed support for this 
> extension wholesale.

This was definitely required for MFC headers; I remember implementing this 
horrible nonsense ages ago, see 
https://github.com/llvm/llvm-project/issues/14109 -- I can verify that 
`CComControlBase` no longer has the terrible union in it, but I'm not certain 
when it lost it.

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


[clang] [X86_64] Fix empty field error in vaarg of C++. (PR #101639)

2024-08-12 Thread Longsheng Mou via cfe-commits

https://github.com/CoTinker updated 
https://github.com/llvm/llvm-project/pull/101639

>From 3ff5909e6c0cc7acff96ed4e8524a3b5949b209f Mon Sep 17 00:00:00 2001
From: Longsheng Mou 
Date: Fri, 2 Aug 2024 16:36:31 +0800
Subject: [PATCH 1/2] [X86_64] Fix empty field error in vaarg of C++.

Such struct types:
```
struct {
  struct{} a;
  long long b;
};

stuct {
  struct{} a;
  double b;
};
```
For such structures, Lo is NoClass and Hi is Integer/SSE. And when
this structure argument is passed, the high part is passed at
offset 8 in memory. So we should do special handling for these types
in EmitVAArg.
---
 clang/lib/CodeGen/Targets/X86.cpp  |  38 +++--
 clang/test/CodeGenCXX/x86_64-vaarg.cpp | 211 -
 2 files changed, 231 insertions(+), 18 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 26ff4e4ac0a3b5..0347bd01f82ef3 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -3124,26 +3124,40 @@ RValue X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
 CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1));
 
 RegAddr = Tmp.withElementType(LTy);
-  } else if (neededInt) {
-RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, 
gp_offset),
-  LTy, CharUnits::fromQuantity(8));
-
+  } else if (neededInt || neededSSE == 1) {
 // Copy to a temporary if necessary to ensure the appropriate alignment.
 auto TInfo = getContext().getTypeInfoInChars(Ty);
 uint64_t TySize = TInfo.Width.getQuantity();
 CharUnits TyAlign = TInfo.Align;
 
-// Copy into a temporary if the type is more aligned than the
-// register save area.
-if (TyAlign.getQuantity() > 8) {
+llvm::Value *GpOrFpOffset = neededInt ? gp_offset : fp_offset;
+uint64_t Alignment = neededInt ? 8 : 16;
+if (auto Offset = AI.getDirectOffset()) {
   Address Tmp = CGF.CreateMemTemp(Ty);
-  CGF.Builder.CreateMemCpy(Tmp, RegAddr, TySize, false);
-  RegAddr = Tmp;
+  llvm::Type *TyHi = AI.getCoerceToType();
+  llvm::Value *Addr =
+  CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, GpOrFpOffset);
+  llvm::Value *Src = CGF.Builder.CreateAlignedLoad(TyHi, Addr, TyAlign);
+  llvm::Value *PtrOffset = llvm::ConstantInt::get(CGF.Int32Ty, Offset);
+  Address Dst = Address(
+  CGF.Builder.CreateGEP(CGF.Int8Ty, Tmp.getBasePointer(), PtrOffset),
+  LTy, TyAlign);
+  CGF.Builder.CreateStore(Src, Dst);
+  RegAddr = Tmp.withElementType(LTy);
+} else {
+  RegAddr =
+  Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, GpOrFpOffset),
+  LTy, CharUnits::fromQuantity(Alignment));
+
+  // Copy into a temporary if the type is more aligned than the
+  // register save area.
+  if (neededInt && TyAlign.getQuantity() > 8) {
+Address Tmp = CGF.CreateMemTemp(Ty);
+CGF.Builder.CreateMemCpy(Tmp, RegAddr, TySize, false);
+RegAddr = Tmp;
+  }
 }
 
-  } else if (neededSSE == 1) {
-RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, 
fp_offset),
-  LTy, CharUnits::fromQuantity(16));
   } else {
 assert(neededSSE == 2 && "Invalid number of needed registers!");
 // SSE registers are spaced 16 bytes apart in the register save
diff --git a/clang/test/CodeGenCXX/x86_64-vaarg.cpp 
b/clang/test/CodeGenCXX/x86_64-vaarg.cpp
index 439a66deb4fde7..0925d3fe81e139 100644
--- a/clang/test/CodeGenCXX/x86_64-vaarg.cpp
+++ b/clang/test/CodeGenCXX/x86_64-vaarg.cpp
@@ -29,6 +29,7 @@ typedef struct {
 // CHECK-NEXT:[[RETVAL:%.*]] = alloca [[STRUCT_S1:%.*]], align 8
 // CHECK-NEXT:[[Z_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:[[LIST:%.*]] = alloca [1 x %struct.__va_list_tag], align 16
+// CHECK-NEXT:[[TMP:%.*]] = alloca [[STRUCT_S1]], align 8
 // CHECK-NEXT:store i32 [[Z:%.*]], ptr [[Z_ADDR]], align 4
 // CHECK-NEXT:[[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x 
%struct.__va_list_tag], ptr [[LIST]], i64 0, i64 0
 // CHECK-NEXT:call void @llvm.va_start.p0(ptr [[ARRAYDECAY]])
@@ -41,8 +42,11 @@ typedef struct {
 // CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds nuw 
[[STRUCT___VA_LIST_TAG]], ptr [[ARRAYDECAY1]], i32 0, i32 3
 // CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load ptr, ptr [[TMP0]], align 16
 // CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, ptr [[REG_SAVE_AREA]], i32 
[[FP_OFFSET]]
-// CHECK-NEXT:[[TMP2:%.*]] = add i32 [[FP_OFFSET]], 16
-// CHECK-NEXT:store i32 [[TMP2]], ptr [[FP_OFFSET_P]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = load double, ptr [[TMP1]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr i8, ptr [[TMP]], i32 8
+// CHECK-NEXT:store double [[TMP2]], ptr [[TMP3]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = add i32 [[FP_OFFSET]], 16
+// CHECK-NEXT:store i32 [[TMP4]], ptr [[FP_OFFSET_P]], align 4
 // CHECK-NEXT:br label [[VAARG_

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits

https://github.com/pow2clk updated 
https://github.com/llvm/llvm-project/pull/102872

>From 6fde4bc98d0156024cf7acc27e2e986b9bec3993 Mon Sep 17 00:00:00 2001
From: Greg Roth 
Date: Fri, 2 Aug 2024 20:10:04 -0600
Subject: [PATCH 1/3] Create llvm dot intrinsic

Per https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
`dot` should be an LLVM intrinsic. This adds the llvm intrinsics
and updates HLSL builtin codegen to emit them.

Removed some stale comments that gave the obsolete impression that
type conversions should be expected to match overloads.

With dot moving into an LLVM intrinsic, the lowering to dx-specific
operations doesn't take place until DXIL intrinsic expansion. This
moves the introduction of arity-specific DX opcodes to DXIL
intrinsic expansion.

Part of #88056
---
 clang/lib/CodeGen/CGBuiltin.cpp   |  47 +++--
 .../CodeGenHLSL/builtins/dot-builtin.hlsl |  12 +-
 clang/test/CodeGenHLSL/builtins/dot.hlsl  | 160 +-
 llvm/include/llvm/IR/Intrinsics.td|   9 +
 .../Target/DirectX/DXILIntrinsicExpansion.cpp |  61 +--
 5 files changed, 159 insertions(+), 130 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7fe80b0cbdfbfa..67148e32014ed2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18470,22 +18470,14 @@ llvm::Value 
*CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
   return Arg;
 }
 
-Intrinsic::ID getDotProductIntrinsic(QualType QT, int elementCount) {
-  if (QT->hasFloatingRepresentation()) {
-switch (elementCount) {
-case 2:
-  return Intrinsic::dx_dot2;
-case 3:
-  return Intrinsic::dx_dot3;
-case 4:
-  return Intrinsic::dx_dot4;
-}
-  }
-  if (QT->hasSignedIntegerRepresentation())
-return Intrinsic::dx_sdot;
-
-  assert(QT->hasUnsignedIntegerRepresentation());
-  return Intrinsic::dx_udot;
+// Return dot product intrinsic that corresponds to the QT scalar type
+Intrinsic::ID getDotProductIntrinsic(QualType QT) {
+  if (QT->isFloatingType())
+return Intrinsic::fdot;
+  if (QT->isSignedIntegerType())
+return Intrinsic::sdot;
+  assert(QT->isUnsignedIntegerType());
+  return Intrinsic::udot;
 }
 
 Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
@@ -18528,37 +18520,38 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 Value *Op1 = EmitScalarExpr(E->getArg(1));
 llvm::Type *T0 = Op0->getType();
 llvm::Type *T1 = Op1->getType();
+
+// If the arguments are scalars, just emit a multiply
 if (!T0->isVectorTy() && !T1->isVectorTy()) {
   if (T0->isFloatingPointTy())
-return Builder.CreateFMul(Op0, Op1, "dx.dot");
+return Builder.CreateFMul(Op0, Op1, "dot");
 
   if (T0->isIntegerTy())
-return Builder.CreateMul(Op0, Op1, "dx.dot");
+return Builder.CreateMul(Op0, Op1, "dot");
 
-  // Bools should have been promoted
   llvm_unreachable(
   "Scalar dot product is only supported on ints and floats.");
 }
+// For vectors, validate types and emit the appropriate intrinsic
+
 // A VectorSplat should have happened
 assert(T0->isVectorTy() && T1->isVectorTy() &&
"Dot product of vector and scalar is not supported.");
 
-// A vector sext or sitofp should have happened
-assert(T0->getScalarType() == T1->getScalarType() &&
-   "Dot product of vectors need the same element types.");
-
 auto *VecTy0 = E->getArg(0)->getType()->getAs();
 [[maybe_unused]] auto *VecTy1 =
 E->getArg(1)->getType()->getAs();
-// A HLSLVectorTruncation should have happend
+
+assert(VecTy0->getElementType() == VecTy1->getElementType() &&
+   "Dot product of vectors need the same element types.");
+
 assert(VecTy0->getNumElements() == VecTy1->getNumElements() &&
"Dot product requires vectors to be of the same size.");
 
 return Builder.CreateIntrinsic(
 /*ReturnType=*/T0->getScalarType(),
-getDotProductIntrinsic(E->getArg(0)->getType(),
-   VecTy0->getNumElements()),
-ArrayRef{Op0, Op1}, nullptr, "dx.dot");
+getDotProductIntrinsic(VecTy0->getElementType()),
+ArrayRef{Op0, Op1}, nullptr, "dot");
   } break;
   case Builtin::BI__builtin_hlsl_lerp: {
 Value *X = EmitScalarExpr(E->getArg(0));
diff --git a/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl 
b/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
index b0b95074c972d5..6036f9430db4f0 100644
--- a/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
@@ -2,8 +2,8 @@
 
 // CHECK-LABEL: builtin_bool_to_float_type_promotion
 // CHECK: %conv1 = uitofp i1 %loadedv to double
-// CHECK: %dx.dot = fmul double %conv, %conv1
-// CHECK: %conv2 = fptrunc double %dx.dot to float
+// CHECK: %dot = fmul double %conv, %conv1
+// CHECK: %conv2 = fptrunc double %dot to float
 

[clang] [PS4/PS5][Driver] Allow -static in PlayStation drivers (PR #102020)

2024-08-12 Thread Jeremy Morse via cfe-commits

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

In lieu of Paul for a bit of time, LGTM.

I feel like the check for matching the linker-line could be made even stronger 
(one wonders how many options end with 'ld"', but it's probably good enough.

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


  1   2   3   4   5   >