[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-04-29 Thread Yeting Kuo via cfe-commits

https://github.com/yetingk updated 
https://github.com/llvm/llvm-project/pull/89727

>From a43014cf3daa1b0fd9092bfe41da979205ba64aa Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 23 Apr 2024 02:16:04 -0700
Subject: [PATCH 1/4] [RISCV] Teach .option arch to support experimental
 extensions.

Previously .option arch denied extenions are not belongs to RISC-V features. But
experimental features have experimental- prefix, so .option arch can not
serve for experimental extension.
This patch uses the features of extensions to identify extension
existance.
---
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 7 ---
 llvm/test/MC/RISCV/option-arch.s   | 9 -
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 3f4a73ad89bf8a..80ff70f1095f4c 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2824,8 +2824,9 @@ bool RISCVAsmParser::parseDirectiveOption() {
 break;
   }
 
-  auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch);
-  if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch ||
+  std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch);
+  auto Ext = llvm::lower_bound(RISCVFeatureKV, Feature);
+  if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Feature ||
   !RISCVISAInfo::isSupportedExtension(Arch)) {
 if (isDigit(Arch.back()))
   return Error(
@@ -2834,7 +2835,7 @@ bool RISCVAsmParser::parseDirectiveOption() {
 return Error(Loc, "unknown extension feature");
   }
 
-  Args.emplace_back(Type, Ext->Key);
+  Args.emplace_back(Type, Arch.str());
 
   if (Type == RISCVOptionArchArgType::Plus) {
 FeatureBitset OldFeatureBits = STI->getFeatureBits();
diff --git a/llvm/test/MC/RISCV/option-arch.s b/llvm/test/MC/RISCV/option-arch.s
index 6ee133c7159a27..40675f9e4b434b 100644
--- a/llvm/test/MC/RISCV/option-arch.s
+++ b/llvm/test/MC/RISCV/option-arch.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple riscv32 -show-encoding < %s \
 # RUN:   | FileCheck -check-prefixes=CHECK %s
 # RUN: llvm-mc -triple riscv32 -filetype=obj < %s \
-# RUN:   | llvm-objdump  --triple=riscv32 --mattr=+c,+m,+a,+f,+zba -d -M 
no-aliases - \
+# RUN:   | llvm-objdump  --triple=riscv32 
--mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \
 # RUN:   | FileCheck -check-prefixes=CHECK-INST %s
 
 # Test '.option arch, +' and '.option arch, -' directive
@@ -78,6 +78,13 @@ lr.w t0, (t1)
 # CHECK: encoding: [0xb3,0x22,0x73,0x20]
 sh1add t0, t1, t2
 
+# Test experimental extension
+# CHECK: .option arch, +zicfiss
+.option arch, +zicfiss
+# CHECK-INST: sspopchk ra
+# CHECK: encoding: [0x73,0xc0,0xc0,0xcd]
+sspopchk ra
+
 # Test '.option arch, ' directive
 # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
 .option arch, rv32i2p1_m2p0_a2p1_c2p0

>From 471abce617a9d18ef91370303eef90bab228d9d3 Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 23 Apr 2024 21:55:12 -0700
Subject: [PATCH 2/4] Make this pr obey menable-experimental-extensions.

---
 clang/lib/Driver/ToolChains/Clang.cpp  | 5 +
 clang/test/Driver/riscv-option-arch.s  | 5 +
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 6 ++
 3 files changed, 16 insertions(+)
 create mode 100644 clang/test/Driver/riscv-option-arch.s

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5894a48e0e378b..8b0f523763486f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8449,6 +8449,11 @@ void ClangAs::AddRISCVTargetArgs(const ArgList &Args,
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-riscv-add-build-attributes");
   }
+
+  if (!Args.hasArg(options::OPT_menable_experimental_extensions)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-riscv-disable-experimental-ext");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
diff --git a/clang/test/Driver/riscv-option-arch.s 
b/clang/test/Driver/riscv-option-arch.s
new file mode 100644
index 00..8ce84dd8ffe79d
--- /dev/null
+++ b/clang/test/Driver/riscv-option-arch.s
@@ -0,0 +1,5 @@
+# RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o 
/dev/null %s
+# RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck 
-check-prefixes=CHECK-ERR %s
+
+.option arch, +zicfiss
+# CHECK-ERR: Unexpected experimental extensions.
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 80ff70f1095f4c..6225e0707015fe 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed,
 
 static cl::opt AddBuildAttributes("riscv-add-

[clang] [Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior (PR #90066)

2024-04-29 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/90066

>From a89ed3064119d110da2289e78bb85630342a2b18 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Thu, 25 Apr 2024 16:34:29 +0200
Subject: [PATCH 1/2] [Clang] Implement P2809: Trivial infinite loops are not
 Undefined Behavior

https://wg21.link/P2809R3
---
 clang/docs/ReleaseNotes.rst |  4 +-
 clang/lib/CodeGen/CGStmt.cpp| 81 ++---
 clang/lib/CodeGen/CodeGenFunction.cpp   |  1 +
 clang/lib/CodeGen/CodeGenFunction.h | 23 +-
 clang/test/CodeGenCXX/attr-mustprogress.cpp | 70 --
 clang/www/cxx_status.html   |  2 +-
 6 files changed, 107 insertions(+), 74 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..f5906c2dd4eb52 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -122,7 +122,7 @@ C++23 Feature Support
   materialize temporary object which is a prvalue in discarded-value 
expression.
 - Implemented `P1774R8: Portable assumptions `_.
 
-- Implemented `P2448R2: Relaxing some constexpr restrictions 
`_.
+- Implemented `P2809R3: Trivial infinite loops are not Undefined Behavior 
`_.
 
 C++2c Feature Support
 ^
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P2573R2: = delete("should have a reason"); 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 576fe2f7a2d46f..7a0ad8a73b9fce 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -908,6 +908,73 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
 incrementProfileCounter(&S);
 }
 
+bool CodeGenFunction::checkIfLoopMustProgress(const Expr 
*ControllingExpression,
+  bool IsTrivialCXXLoop) {
+  if (CGM.getCodeGenOpts().getFiniteLoops() ==
+  CodeGenOptions::FiniteLoopsKind::Always)
+return true;
+  if (CGM.getCodeGenOpts().getFiniteLoops() ==
+  CodeGenOptions::FiniteLoopsKind::Never)
+return false;
+
+  // Now apply rules for plain C (see  6.8.5.6 in C11).
+  // Loops with constant conditions do not have to make progress in any C
+  // version.
+  // As an extension, we consisider loops whose constant expression
+  // can be constant-folded.
+  Expr::EvalResult Result;
+  bool CondIsConstInt =
+  !ControllingExpression ||
+  (ControllingExpression->EvaluateAsInt(Result, getContext()) &&
+   Result.Val.isInt());
+  bool IsTrue = CondIsConstInt &&
+(!ControllingExpression || Result.Val.getInt().getBoolValue());
+
+  if (getLangOpts().C99 && CondIsConstInt)
+return false;
+
+  // Loops with non-constant conditions must make progress in C11 and later.
+  if (getLangOpts().C11)
+return true;
+
+  // [C++26][intro.progress] (DR)
+  // The implementation may assume that any thread will eventually do one of 
the
+  // following:
+  // [...]
+  // - continue execution of a trivial infinite loop ([stmt.iter.general]).
+  if (getLangOpts().CPlusPlus11) {
+if (IsTrivialCXXLoop && IsTrue) {
+  CurFn->removeFnAttr(llvm::Attribute::MustProgress);
+  return false;
+}
+return true;
+  }
+
+  return false;
+}
+
+// [C++26][stmt.iter.general] (DR)
+// A trivially empty iteration statement is an iteration statement matching one
+// of the following forms:
+//  - while ( expression ) ;
+//  - while ( expression ) { }
+//  - do ; while ( expression ) ;
+//  - do { } while ( expression ) ;
+//  - for ( init-statement expression(opt); ) ;
+//  - for ( init-statement expression(opt); ) { }
+template  static bool hasEmptyLoopBody(const LoopStmt &S) {
+  if constexpr (std::is_same_v) {
+if (S.getInc())
+  return false;
+  }
+  const Stmt *Body = S.getBody();
+  if (!Body || isa(Body))
+return true;
+  if (const CompoundStmt *Compound = dyn_cast(Body))
+return Compound->body_empty();
+  return false;
+}
+
 void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
 ArrayRef WhileAttrs) {
   // Emit the header for the loop, which will also become
@@ -942,13 +1009,12 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
   // while(1) is common, avoid extra exit blocks.  Be sure
   // to correctly handle break/continue though.
   llvm::ConstantInt *C = dyn_cast(BoolCondVal);
-  bool CondIsConstInt = C != nullptr;
-  bool EmitBoolCondBranch = !CondIsConstInt || !C->isOne();
+  bool EmitBoolCondBranch = !C || !C->isOne();
   const SourceRange &R = S.getSourceRange();
   LoopStack.push(LoopHeader.getBlock(), CGM.getContext(), CGM.getCodeGenOpts(),
  WhileAttrs, SourceLocToDebugLoc

[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)

2024-04-29 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/89828

>From b5422012a65165f27bb31be7e9490892f663acfe Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Tue, 23 Apr 2024 22:45:29 +0200
Subject: [PATCH 1/3] [Clang] [CodeGen] Perform derived-to-base conversion on
 explicit object parameter in lambda

---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/lib/CodeGen/CGExpr.cpp  | 23 +++
 clang/test/CodeGenCXX/cxx2b-deducing-this.cpp | 63 +++
 3 files changed, 89 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d1f7293a842bb6..34aad4abf39619 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -562,6 +562,9 @@ Bug Fixes to C++ Support
 - Fixed a crash when trying to evaluate a user-defined ``static_assert`` 
message whose ``size()``
   function returns a large or negative value. Fixes (#GH89407).
 - Fixed a use-after-free bug in parsing of type constraints with default 
arguments that involve lambdas. (#GH67235)
+- Fixed a crash when trying to emit captures in a lambda call operator with an 
explicit object
+  parameter that is called on a derived type of the lambda.
+  Fixes (#GH87210), (GH89541).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 931cb391342ea2..33795d7d4d1921 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const 
FieldDecl *Field,
 else
   LambdaLV = MakeAddrLValue(AddrOfExplicitObject,
 D->getType().getNonReferenceType());
+
+// Make sure we have an lvalue to the lambda itself and not a derived 
class.
+auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl();
+auto *LambdaTy = cast(Field->getParent());
+if (ThisTy != LambdaTy) {
+  CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true,
+ /*DetectVirtual=*/false);
+
+  [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths);
+  assert(Derived && "Type not derived from lambda type?");
+
+  const CXXBasePath *Path = &Paths.front();
+  CXXCastPath BasePathArray;
+  for (unsigned I = 0, E = Path->size(); I != E; ++I)
+BasePathArray.push_back(
+const_cast((*Path)[I].Base));
+
+  Address Base = GetAddressOfBaseClass(
+  LambdaLV.getAddress(*this), ThisTy, BasePathArray.begin(),
+  BasePathArray.end(), /*NullCheckValue=*/false, SourceLocation());
+
+  LambdaLV = MakeAddrLValue(Base, QualType{LambdaTy->getTypeForDecl(), 0});
+}
   } else {
 QualType LambdaTagType = getContext().getTagDeclType(Field->getParent());
 LambdaLV = MakeNaturalAlignAddrLValue(ThisValue, LambdaTagType);
diff --git a/clang/test/CodeGenCXX/cxx2b-deducing-this.cpp 
b/clang/test/CodeGenCXX/cxx2b-deducing-this.cpp
index b755e80db35a12..649fe2afbf4e91 100644
--- a/clang/test/CodeGenCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/CodeGenCXX/cxx2b-deducing-this.cpp
@@ -182,3 +182,66 @@ auto dothing(int num)
   fun();
 }
 }
+
+namespace GH87210 {
+template 
+struct Overloaded : Ts... {
+  using Ts::operator()...;
+};
+
+template 
+Overloaded(Ts...) -> Overloaded;
+
+// CHECK-LABEL: define dso_local void @_ZN7GH872101fEv()
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X:%.*]] = alloca i32
+// CHECK-NEXT:[[Over:%.*]] = alloca %"{{.*}}Overloaded"
+// CHECK: call noundef ptr 
@"_ZZN7GH872101fEvENH3$_0clINS_10OverloadedIJS0_EDaRT_"(ptr {{.*}} [[Over]])
+void f() {
+  int x;
+  Overloaded o {
+// CHECK: define internal noundef ptr 
@"_ZZN7GH872101fEvENH3$_0clINS_10OverloadedIJS0_EDaRT_"(ptr {{.*}} 
[[Self:%.*]])
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[SelfAddr:%.*]] = alloca ptr
+// CHECK-NEXT:store ptr [[Self]], ptr [[SelfAddr]]
+// CHECK-NEXT:[[SelfPtr:%.*]] = load ptr, ptr [[SelfAddr]]
+// CHECK-NEXT:[[XRef:%.*]] = getelementptr inbounds %{{.*}}, ptr 
[[SelfPtr]], i32 0, i32 0
+// CHECK-NEXT:[[X:%.*]] = load ptr, ptr [[XRef]]
+// CHECK-NEXT:ret ptr [[X]]
+[&](this auto& self) {
+  return &x;
+}
+  };
+  o();
+}
+
+void g() {
+  int x;
+  Overloaded o {
+[=](this auto& self) {
+  return x;
+}
+  };
+  o();
+}
+}
+
+namespace GH89541 {
+// Same as above; just check that this doesn't crash.
+int one = 1;
+auto factory(int& x = one) {
+  return [&](this auto self) {
+x;
+  };
+};
+
+using Base = decltype(factory());
+struct Derived : Base {
+  Derived() : Base(factory()) {}
+};
+
+void f() {
+  Derived d;
+  d();
+}
+}

>From 90d73ea88016307532bb38c4b2e8fa8f082bea75 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Thu, 25 Apr 2024 01:01:18 +0200
Subject: [PATCH 2/3] [Clang] Tentative implementation of CWG 2881

---
 clang/include/clang/AST/ASTContext.h  |  9 +++

[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)

2024-04-29 Thread via cfe-commits

Sirraide wrote:

@cor3ntin There already was a FIXME to consider moving this check to where the 
call operator is first instantiated; should I look into that as well or is it 
fine to leave this here? Asking because I’m assuming there’s a reason why it 
wasn’t done that way.

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


[clang] [libclc] [llvm] [openmp] [Clang] `__attribute__((assume))` refactor (PR #84934)

2024-04-29 Thread via cfe-commits

Sirraide wrote:

@AnastasiaStulova ping

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


[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-29 Thread Haojian Wu via cfe-commits

hokein wrote:

Friendly ping, it is ready for the second round of review. 

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


[clang] [clang][dataflow] Don't propagate result objects inside `decltype`. (PR #90438)

2024-04-29 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/90438

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.

We're starting to see a repeating pattern here: We're getting crashes because
`ResultObjectVisitor` and `getReferencedDecls()` don't agree on which parts of
the AST to visit and, hence, which fields should be modeled.

I think we should ensure consistency between these two parts of the code by
using a `RecursiveASTVisitor` in `getReferencedDecls()`[^1]; the
`Traverse...()` functions that control which parts of the AST we visit would go
in a common base class that would be used for both `ResultObjectVisitor` and
`getReferencedDecls()`.

I'd like to focus this PR, however, on a targeted fix for the current crash and
postpone the refactoring to a later PR (which will be easier to revert if there
are unintended side-effects).

[^1]: As an added bonus, this would make the code better structured and more
efficient than the current sequence of `if (dyn_cast(...))` statements).


>From 75a1198172f8e9fac6f83ec7e786fa108dbbfa3d Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Mon, 29 Apr 2024 08:02:26 +
Subject: [PATCH] [clang][dataflow] Don't propagate result objects inside
 `decltype`.

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.

We're starting to see a repeating pattern here: We're getting crashes because
`ResultObjectVisitor` and `getReferencedDecls()` don't agree on which parts of
the AST to visit and, hence, which fields should be modeled.

I think we should ensure consistency between these two parts of the code by
using a `RecursiveASTVisitor` in `getReferencedDecls()`[^1]; the
`Traverse...()` functions that control which parts of the AST we visit would go
in a common base class that would be used for both `ResultObjectVisitor` and
`getReferencedDecls()`.

I'd like to focus this PR, however, on a targeted fix for the current crash and
postpone the refactoring to a later PR (which will be easier to revert if there
are unintended side-effects).

[^1]: As an added bonus, this would make the code better structured and more
efficient than the current sequence of `if (dyn_cast(...))` statements).
---
 .../FlowSensitive/DataflowEnvironment.cpp   |  7 +++
 .../Analysis/FlowSensitive/TransferTest.cpp | 17 +
 2 files changed, 24 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index d79e734402892a..f32ee4a2528a8b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -350,6 +350,13 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 return RecursiveASTVisitor::TraverseDecl(D);
   }
 
+  bool TraverseDecltypeTypeLoc(DecltypeTypeLoc Node) {
+// Don't traverse `decltype` because we don't analyze its argument (as it
+// isn't executed) and hence don't model fields that are only used in the
+// argument of a `decltype`.
+return true;
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 301bec32c0cf1d..3b8fde0eb244c1 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3331,6 +3331,23 @@ TEST(TransferTest, 
ResultObjectLocationDontVisitNestedRecordDecl) {
  ASTContext &ASTCtx) {});
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitDeclTypeArg) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // the argument of `decltype()`, but we don't model fields used only in 
these.
+  std::string Code = R"cc(
+struct S1 {};
+struct S2 { S1 s1; };
+void target() {
+decltype(S2{ S1() }) Dummy;
+}
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

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


[clang] [clang][dataflow] Don't propagate result objects inside `decltype`. (PR #90438)

2024-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: None (martinboehme)


Changes

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.

We're starting to see a repeating pattern here: We're getting crashes because
`ResultObjectVisitor` and `getReferencedDecls()` don't agree on which parts of
the AST to visit and, hence, which fields should be modeled.

I think we should ensure consistency between these two parts of the code by
using a `RecursiveASTVisitor` in `getReferencedDecls()`[^1]; the
`Traverse...()` functions that control which parts of the AST we visit would go
in a common base class that would be used for both `ResultObjectVisitor` and
`getReferencedDecls()`.

I'd like to focus this PR, however, on a targeted fix for the current crash and
postpone the refactoring to a later PR (which will be easier to revert if there
are unintended side-effects).

[^1]: As an added bonus, this would make the code better structured and more
efficient than the current sequence of `if (dyn_cast(...))` 
statements).


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp (+7) 
- (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (+17) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index d79e734402892a..f32ee4a2528a8b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -350,6 +350,13 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 return RecursiveASTVisitor::TraverseDecl(D);
   }
 
+  bool TraverseDecltypeTypeLoc(DecltypeTypeLoc Node) {
+// Don't traverse `decltype` because we don't analyze its argument (as it
+// isn't executed) and hence don't model fields that are only used in the
+// argument of a `decltype`.
+return true;
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 301bec32c0cf1d..3b8fde0eb244c1 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3331,6 +3331,23 @@ TEST(TransferTest, 
ResultObjectLocationDontVisitNestedRecordDecl) {
  ASTContext &ASTCtx) {});
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitDeclTypeArg) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // the argument of `decltype()`, but we don't model fields used only in 
these.
+  std::string Code = R"cc(
+struct S1 {};
+struct S2 { S1 s1; };
+void target() {
+decltype(S2{ S1() }) Dummy;
+}
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

``




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


[clang] [clang][dataflow] Don't propagate result objects inside `decltype`. (PR #90438)

2024-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (martinboehme)


Changes

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.

We're starting to see a repeating pattern here: We're getting crashes because
`ResultObjectVisitor` and `getReferencedDecls()` don't agree on which parts of
the AST to visit and, hence, which fields should be modeled.

I think we should ensure consistency between these two parts of the code by
using a `RecursiveASTVisitor` in `getReferencedDecls()`[^1]; the
`Traverse...()` functions that control which parts of the AST we visit would go
in a common base class that would be used for both `ResultObjectVisitor` and
`getReferencedDecls()`.

I'd like to focus this PR, however, on a targeted fix for the current crash and
postpone the refactoring to a later PR (which will be easier to revert if there
are unintended side-effects).

[^1]: As an added bonus, this would make the code better structured and more
efficient than the current sequence of `if (dyn_cast(...))` 
statements).


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp (+7) 
- (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (+17) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index d79e734402892a..f32ee4a2528a8b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -350,6 +350,13 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 return RecursiveASTVisitor::TraverseDecl(D);
   }
 
+  bool TraverseDecltypeTypeLoc(DecltypeTypeLoc Node) {
+// Don't traverse `decltype` because we don't analyze its argument (as it
+// isn't executed) and hence don't model fields that are only used in the
+// argument of a `decltype`.
+return true;
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 301bec32c0cf1d..3b8fde0eb244c1 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3331,6 +3331,23 @@ TEST(TransferTest, 
ResultObjectLocationDontVisitNestedRecordDecl) {
  ASTContext &ASTCtx) {});
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitDeclTypeArg) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // the argument of `decltype()`, but we don't model fields used only in 
these.
+  std::string Code = R"cc(
+struct S1 {};
+struct S2 { S1 s1; };
+void target() {
+decltype(S2{ S1() }) Dummy;
+}
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

``




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


[clang] [clang][CodeGen] fix UB in aarch64 bfloat16 scalar conversion (PR #89062)

2024-04-29 Thread via cfe-commits

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

LGTM, thanks.

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


[clang] [llvm] main (PR #90439)

2024-04-29 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray created 
https://github.com/llvm/llvm-project/pull/90439

- Fix mismatches between function parameter definitions and declarations 
(#89512)
- Revert "[llvm][RISCV] Enable trailing fences for seq-cst stores by default 
(#87376)"
- Revert "[RISCV] Support RISCV Atomics ABI attributes (#84597)"
- [SelectionDAG] Treat CopyFromReg as freezing the value (#85932)
- [DAGCombiner] Do not always fold FREEZE over BUILD_VECTOR (#85932)
- [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (#90143)
- [clang][X86] Fix -Wundef warning in cpuid.h (#89842)
- Add test cases for SELECT->AND miscompiles in DAGCombiner
- [M68k] Add support for MOVEQ instruction (#88542)
- [Transforms] Debug values are not remapped when cloning. (#87747)
- [RISCV][NFC] Future-proof reference to ISA manual in RISCVInstrInfoC.td
- [DAG] visitORCommutative - fold build_pair(not(x),not(y)) -> 
not(build_pair(x,y)) style patterns (#90050)
- [NFC][OpenACC] Remove stale FIXME comment in a test
- DAG: Simplify demanded bits for truncating atomic_store (#90113)
- [Offload] Remove remaining `__tgt_register_requires` references (#90198)
- Revert "[TableGen] Ignore inaccessible memory when checking pattern flags 
(#90061)"
- [SLP]Attempt to vectorize long stores, if short one failed.
- [mlir][MemRef] Add ExtractStridedMetadataOpCollapseShapeFolder (#89954)
- [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)
- [clang] Add test for CWG2149 "Brace elision and array length deduction" 
(#90079)
- [libc++][ranges] LWG3984: ranges::to's recursion branch may be ill-formed 
(#87964)
- [clang-tidy][NFC] Fix broken link in documentation of cert-env33-c (#90216)
- [mlir] Fix -Wdeprecated-declarations of cast in VCIXToLLVMIRTranslation.cpp 
(NFC)
- [mlir] Add sub-byte type emulation support for `memref.collapse_shape` 
(#89962)
- [MC] Rename temporary symbols of empty name to ".L0 " (#89693)
- [X86] Regenerate subreg-to-reg tests with update_llc_test_checks.py
- [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (#89446)
- [AArch64][SVE2] SVE2 NBSL instruction lowering. (#89732)
- [libc++][ranges] Exports operator|. (#90071)
- [NFC] update comments from an earlier version of SuffixTree (#89800)
- [scudo] Reflect the allowed values for M_DECAY_TIME on Android (#89114)
- [DXIL] Fix build warning (#90226)
- [OpenMP][AIX] Use syssmt() to get the number of SMTs per physical CPU (#89985)
- [RISCV] Flatten the ImpliedExts table in RISCVISAInfo.cpp (#89975)
- [LV] Add tests showing missed propgation of versiond stride values.
- [mlir][sparse] fold sparse convert into producer linalg op. (#8)
- [Arm64EC] Improve alignment mangling in arm64ec thunks. (#90115)
- [RISCV] Add an instruction PrettyPrinter to llvm-objdump (#90093)
- [APINotes] Allow annotating a C++ type as non-copyable in Swift
- [lldb] Switch to llvm::DWARFUnitHeader (#89808)
- [SLP]Fix PR90224: check that users of gep are all vectorized.
- [lldb] Fix typo in CumulativeSystemTimeIsValid check (#89680)
- [Libomptarget] Rename `libomptarget.rtl.x86_64` to `libomptarget.rtl.host` 
(#86868)
- [RISCV] Consistently use uint32_t in Disassembler decode functions. NFC
- [Driver,test] Replace CHECK-NOT: warning with -### -Werror
- [HLSL][SPIR-V] Target `directx` is required
- Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. 
(#89998)" (#90250)
- [RISCV] Fix off by 1 typo in decodeVMaskReg. NFC
- Implement the DWARF 6 language and version attributes. (#89980)
- [AMDGPU] Support byte_sel modifier on v_cvt_sr_fp8_f32 and v_cvt_sr_bf8_f32 
(#90244)
- [ci] Add clang project dependency for bolt testing (#90262)
- [NFC] [HWASan] factor out debug record annotation (#90252)
- [lldb][sbapi] Fix API break in SBDebugger broadcast bits (#90261)
- [VPlan] Also propagate versioned strides to users via sext/zext.
- [flang][cuda] Avoid to issue data transfer in device context (#90247)
- [WebAssembly] Add half-precision feature (#90248)
- [BOLT][NFC] Use getEHFrameHdrSectionName() (#90257)
- [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, 
RefPtr, and their variants. (#90153)
- [ASan][Test] Remove hardcoded linker version from test (#90147)
- [AArch64] Add support for Cortex-R82AE and improve Cortex-R82


>From 16f06cb0d4b84a8084e963dc7d2036ead9446a87 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Sat, 27 Apr 2024 22:51:19 +0100
Subject: [PATCH] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82

Cortex-R82AE is an Armv8R AArch64 CPU. Also, update Cortex-R82
feature flags to be more accurate.

Technical Reference Manual for Cortex-R82AE:
   https://developer.arm.com/documentation/101550/latest/
---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/test/Misc/target-invalid-cpu-note.c   |  4 ++--
 llvm/docs/ReleaseNotes.rst  |  2 +-
 .../llvm/TargetParser/AArch64TargetParser.h | 13 -
 llvm/lib/Target/AArch64/AArch64Processors.td| 15 ++-
 ll

[clang] [llvm] main (PR #90439)

2024-04-29 Thread Jonathan Thackray via cfe-commits

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


[clang] [llvm] main (PR #90439)

2024-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jonathan Thackray (jthackray)


Changes

- Fix mismatches between function parameter definitions and declarations (#89512)
- Revert "[llvm][RISCV] Enable trailing fences for seq-cst stores by default 
(#87376)"
- Revert "[RISCV] Support RISCV Atomics ABI attributes (#84597)"
- [SelectionDAG] Treat CopyFromReg as freezing the value (#85932)
- [DAGCombiner] Do not always fold FREEZE over BUILD_VECTOR (#85932)
- [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (#90143)
- [clang][X86] Fix -Wundef warning in cpuid.h (#89842)
- Add test cases for SELECT->AND miscompiles in DAGCombiner
- [M68k] Add support for MOVEQ instruction (#88542)
- [Transforms] Debug values are not remapped when cloning. (#87747)
- [RISCV][NFC] Future-proof reference to ISA manual in RISCVInstrInfoC.td
- [DAG] visitORCommutative - fold build_pair(not(x),not(y)) -> 
not(build_pair(x,y)) style patterns (#90050)
- [NFC][OpenACC] Remove stale FIXME comment in a test
- DAG: Simplify demanded bits for truncating atomic_store (#90113)
- [Offload] Remove remaining `__tgt_register_requires` references (#90198)
- Revert "[TableGen] Ignore inaccessible memory when checking pattern flags 
(#90061)"
- [SLP]Attempt to vectorize long stores, if short one failed.
- [mlir][MemRef] Add ExtractStridedMetadataOpCollapseShapeFolder (#89954)
- [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)
- [clang] Add test for CWG2149 "Brace elision and array length deduction" 
(#90079)
- [libc++][ranges] LWG3984: ranges::to's recursion branch may be ill-formed 
(#87964)
- [clang-tidy][NFC] Fix broken link in documentation of cert-env33-c (#90216)
- [mlir] Fix -Wdeprecated-declarations of cast in VCIXToLLVMIRTranslation.cpp 
(NFC)
- [mlir] Add sub-byte type emulation support for `memref.collapse_shape` (#89962)
- [MC] Rename temporary symbols of empty name to ".L0 " (#89693)
- [X86] Regenerate subreg-to-reg tests with update_llc_test_checks.py
- [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (#89446)
- [AArch64][SVE2] SVE2 NBSL instruction lowering. (#89732)
- [libc++][ranges] Exports operator|. (#90071)
- [NFC] update comments from an earlier version of SuffixTree (#89800)
- [scudo] Reflect the allowed values for M_DECAY_TIME on Android (#89114)
- [DXIL] Fix build warning (#90226)
- [OpenMP][AIX] Use syssmt() to get the number of SMTs per physical CPU (#89985)
- [RISCV] Flatten the ImpliedExts table in RISCVISAInfo.cpp (#89975)
- [LV] Add tests showing missed propgation of versiond stride values.
- [mlir][sparse] fold sparse convert into producer linalg op. (#8)
- [Arm64EC] Improve alignment mangling in arm64ec thunks. (#90115)
- [RISCV] Add an instruction PrettyPrinter to llvm-objdump (#90093)
- [APINotes] Allow annotating a C++ type as non-copyable in Swift
- [lldb] Switch to llvm::DWARFUnitHeader (#89808)
- [SLP]Fix PR90224: check that users of gep are all vectorized.
- [lldb] Fix typo in CumulativeSystemTimeIsValid check (#89680)
- [Libomptarget] Rename `libomptarget.rtl.x86_64` to `libomptarget.rtl.host` 
(#86868)
- [RISCV] Consistently use uint32_t in Disassembler decode functions. NFC
- [Driver,test] Replace CHECK-NOT: warning with -### -Werror
- [HLSL][SPIR-V] Target `directx` is required
- Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. 
(#89998)" (#90250)
- [RISCV] Fix off by 1 typo in decodeVMaskReg. NFC
- Implement the DWARF 6 language and version attributes. (#89980)
- [AMDGPU] Support byte_sel modifier on v_cvt_sr_fp8_f32 and v_cvt_sr_bf8_f32 
(#90244)
- [ci] Add clang project dependency for bolt testing (#90262)
- [NFC] [HWASan] factor out debug record annotation (#90252)
- [lldb][sbapi] Fix API break in SBDebugger broadcast bits (#90261)
- [VPlan] Also propagate versioned strides to users via sext/zext.
- [flang][cuda] Avoid to issue data transfer in device context (#90247)
- [WebAssembly] Add half-precision feature (#90248)
- [BOLT][NFC] Use getEHFrameHdrSectionName() (#90257)
- [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, 
RefPtr, and their variants. (#90153)
- [ASan][Test] Remove hardcoded linker version from test (#90147)
- [AArch64] Add support for Cortex-R82AE and improve Cortex-R82


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


8 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note.c (+2-2) 
- (modified) llvm/docs/ReleaseNotes.rst (+1-1) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+12-1) 
- (modified) llvm/lib/Target/AArch64/AArch64Processors.td (+14-1) 
- (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+1) 
- (modified) llvm/lib/TargetParser/Host.cpp (+1) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+15-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5d4d152b2eb540..c92d480023f4d4 100644
--- a/clang/docs/Rele

[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-29 Thread Nikolas Klauser via cfe-commits


@@ -14638,6 +14649,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
 return true;
   }
 
+  case Builtin::BIfmin:
+  case Builtin::BIfminf:

philnik777 wrote:

How would that help?

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


[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray created 
https://github.com/llvm/llvm-project/pull/90440

- Fix mismatches between function parameter definitions and declarations 
(#89512)
- Revert "[llvm][RISCV] Enable trailing fences for seq-cst stores by default 
(#87376)"
- Revert "[RISCV] Support RISCV Atomics ABI attributes (#84597)"
- [SelectionDAG] Treat CopyFromReg as freezing the value (#85932)
- [DAGCombiner] Do not always fold FREEZE over BUILD_VECTOR (#85932)
- [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (#90143)
- [clang][X86] Fix -Wundef warning in cpuid.h (#89842)
- Add test cases for SELECT->AND miscompiles in DAGCombiner
- [M68k] Add support for MOVEQ instruction (#88542)
- [Transforms] Debug values are not remapped when cloning. (#87747)
- [RISCV][NFC] Future-proof reference to ISA manual in RISCVInstrInfoC.td
- [DAG] visitORCommutative - fold build_pair(not(x),not(y)) -> 
not(build_pair(x,y)) style patterns (#90050)
- [NFC][OpenACC] Remove stale FIXME comment in a test
- DAG: Simplify demanded bits for truncating atomic_store (#90113)
- [Offload] Remove remaining `__tgt_register_requires` references (#90198)
- Revert "[TableGen] Ignore inaccessible memory when checking pattern flags 
(#90061)"
- [SLP]Attempt to vectorize long stores, if short one failed.
- [mlir][MemRef] Add ExtractStridedMetadataOpCollapseShapeFolder (#89954)
- [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)
- [clang] Add test for CWG2149 "Brace elision and array length deduction" 
(#90079)
- [libc++][ranges] LWG3984: ranges::to's recursion branch may be ill-formed 
(#87964)
- [clang-tidy][NFC] Fix broken link in documentation of cert-env33-c (#90216)
- [mlir] Fix -Wdeprecated-declarations of cast in VCIXToLLVMIRTranslation.cpp 
(NFC)
- [mlir] Add sub-byte type emulation support for `memref.collapse_shape` 
(#89962)
- [MC] Rename temporary symbols of empty name to ".L0 " (#89693)
- [X86] Regenerate subreg-to-reg tests with update_llc_test_checks.py
- [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (#89446)
- [AArch64][SVE2] SVE2 NBSL instruction lowering. (#89732)
- [libc++][ranges] Exports operator|. (#90071)
- [NFC] update comments from an earlier version of SuffixTree (#89800)
- [scudo] Reflect the allowed values for M_DECAY_TIME on Android (#89114)
- [DXIL] Fix build warning (#90226)
- [OpenMP][AIX] Use syssmt() to get the number of SMTs per physical CPU (#89985)
- [RISCV] Flatten the ImpliedExts table in RISCVISAInfo.cpp (#89975)
- [LV] Add tests showing missed propgation of versiond stride values.
- [mlir][sparse] fold sparse convert into producer linalg op. (#8)
- [Arm64EC] Improve alignment mangling in arm64ec thunks. (#90115)
- [RISCV] Add an instruction PrettyPrinter to llvm-objdump (#90093)
- [APINotes] Allow annotating a C++ type as non-copyable in Swift
- [lldb] Switch to llvm::DWARFUnitHeader (#89808)
- [SLP]Fix PR90224: check that users of gep are all vectorized.
- [lldb] Fix typo in CumulativeSystemTimeIsValid check (#89680)
- [Libomptarget] Rename `libomptarget.rtl.x86_64` to `libomptarget.rtl.host` 
(#86868)
- [RISCV] Consistently use uint32_t in Disassembler decode functions. NFC
- [Driver,test] Replace CHECK-NOT: warning with -### -Werror
- [HLSL][SPIR-V] Target `directx` is required
- Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. 
(#89998)" (#90250)
- [RISCV] Fix off by 1 typo in decodeVMaskReg. NFC
- Implement the DWARF 6 language and version attributes. (#89980)
- [AMDGPU] Support byte_sel modifier on v_cvt_sr_fp8_f32 and v_cvt_sr_bf8_f32 
(#90244)
- [ci] Add clang project dependency for bolt testing (#90262)
- [NFC] [HWASan] factor out debug record annotation (#90252)
- [lldb][sbapi] Fix API break in SBDebugger broadcast bits (#90261)
- [VPlan] Also propagate versioned strides to users via sext/zext.
- [flang][cuda] Avoid to issue data transfer in device context (#90247)
- [WebAssembly] Add half-precision feature (#90248)
- [BOLT][NFC] Use getEHFrameHdrSectionName() (#90257)
- [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, 
RefPtr, and their variants. (#90153)
- [ASan][Test] Remove hardcoded linker version from test (#90147)
- [AArch64] Add support for Cortex-R82AE and improve Cortex-R82


>From 16f06cb0d4b84a8084e963dc7d2036ead9446a87 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Sat, 27 Apr 2024 22:51:19 +0100
Subject: [PATCH] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82

Cortex-R82AE is an Armv8R AArch64 CPU. Also, update Cortex-R82
feature flags to be more accurate.

Technical Reference Manual for Cortex-R82AE:
   https://developer.arm.com/documentation/101550/latest/
---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/test/Misc/target-invalid-cpu-note.c   |  4 ++--
 llvm/docs/ReleaseNotes.rst  |  2 +-
 .../llvm/TargetParser/AArch64TargetParser.h | 13 -
 llvm/lib/Target/AArch64/AArch64Processors.td| 15 ++-
 ll

[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread Jonathan Thackray via cfe-commits

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


[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jonathan Thackray (jthackray)


Changes

- Fix mismatches between function parameter definitions and declarations (#89512)
- Revert "[llvm][RISCV] Enable trailing fences for seq-cst stores by default 
(#87376)"
- Revert "[RISCV] Support RISCV Atomics ABI attributes (#84597)"
- [SelectionDAG] Treat CopyFromReg as freezing the value (#85932)
- [DAGCombiner] Do not always fold FREEZE over BUILD_VECTOR (#85932)
- [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (#90143)
- [clang][X86] Fix -Wundef warning in cpuid.h (#89842)
- Add test cases for SELECT->AND miscompiles in DAGCombiner
- [M68k] Add support for MOVEQ instruction (#88542)
- [Transforms] Debug values are not remapped when cloning. (#87747)
- [RISCV][NFC] Future-proof reference to ISA manual in RISCVInstrInfoC.td
- [DAG] visitORCommutative - fold build_pair(not(x),not(y)) -> 
not(build_pair(x,y)) style patterns (#90050)
- [NFC][OpenACC] Remove stale FIXME comment in a test
- DAG: Simplify demanded bits for truncating atomic_store (#90113)
- [Offload] Remove remaining `__tgt_register_requires` references (#90198)
- Revert "[TableGen] Ignore inaccessible memory when checking pattern flags 
(#90061)"
- [SLP]Attempt to vectorize long stores, if short one failed.
- [mlir][MemRef] Add ExtractStridedMetadataOpCollapseShapeFolder (#89954)
- [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)
- [clang] Add test for CWG2149 "Brace elision and array length deduction" 
(#90079)
- [libc++][ranges] LWG3984: ranges::to's recursion branch may be ill-formed 
(#87964)
- [clang-tidy][NFC] Fix broken link in documentation of cert-env33-c (#90216)
- [mlir] Fix -Wdeprecated-declarations of cast in VCIXToLLVMIRTranslation.cpp 
(NFC)
- [mlir] Add sub-byte type emulation support for `memref.collapse_shape` (#89962)
- [MC] Rename temporary symbols of empty name to ".L0 " (#89693)
- [X86] Regenerate subreg-to-reg tests with update_llc_test_checks.py
- [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (#89446)
- [AArch64][SVE2] SVE2 NBSL instruction lowering. (#89732)
- [libc++][ranges] Exports operator|. (#90071)
- [NFC] update comments from an earlier version of SuffixTree (#89800)
- [scudo] Reflect the allowed values for M_DECAY_TIME on Android (#89114)
- [DXIL] Fix build warning (#90226)
- [OpenMP][AIX] Use syssmt() to get the number of SMTs per physical CPU (#89985)
- [RISCV] Flatten the ImpliedExts table in RISCVISAInfo.cpp (#89975)
- [LV] Add tests showing missed propgation of versiond stride values.
- [mlir][sparse] fold sparse convert into producer linalg op. (#8)
- [Arm64EC] Improve alignment mangling in arm64ec thunks. (#90115)
- [RISCV] Add an instruction PrettyPrinter to llvm-objdump (#90093)
- [APINotes] Allow annotating a C++ type as non-copyable in Swift
- [lldb] Switch to llvm::DWARFUnitHeader (#89808)
- [SLP]Fix PR90224: check that users of gep are all vectorized.
- [lldb] Fix typo in CumulativeSystemTimeIsValid check (#89680)
- [Libomptarget] Rename `libomptarget.rtl.x86_64` to `libomptarget.rtl.host` 
(#86868)
- [RISCV] Consistently use uint32_t in Disassembler decode functions. NFC
- [Driver,test] Replace CHECK-NOT: warning with -### -Werror
- [HLSL][SPIR-V] Target `directx` is required
- Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. 
(#89998)" (#90250)
- [RISCV] Fix off by 1 typo in decodeVMaskReg. NFC
- Implement the DWARF 6 language and version attributes. (#89980)
- [AMDGPU] Support byte_sel modifier on v_cvt_sr_fp8_f32 and v_cvt_sr_bf8_f32 
(#90244)
- [ci] Add clang project dependency for bolt testing (#90262)
- [NFC] [HWASan] factor out debug record annotation (#90252)
- [lldb][sbapi] Fix API break in SBDebugger broadcast bits (#90261)
- [VPlan] Also propagate versioned strides to users via sext/zext.
- [flang][cuda] Avoid to issue data transfer in device context (#90247)
- [WebAssembly] Add half-precision feature (#90248)
- [BOLT][NFC] Use getEHFrameHdrSectionName() (#90257)
- [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, 
RefPtr, and their variants. (#90153)
- [ASan][Test] Remove hardcoded linker version from test (#90147)
- [AArch64] Add support for Cortex-R82AE and improve Cortex-R82


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


8 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note.c (+2-2) 
- (modified) llvm/docs/ReleaseNotes.rst (+1-1) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+12-1) 
- (modified) llvm/lib/Target/AArch64/AArch64Processors.td (+14-1) 
- (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+1) 
- (modified) llvm/lib/TargetParser/Host.cpp (+1) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+15-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5d4d152b2eb540..c92d480023f4d4 100644
--- a/clang/docs/Rele

[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Jonathan Thackray (jthackray)


Changes

- Fix mismatches between function parameter definitions and declarations (#89512)
- Revert "[llvm][RISCV] Enable trailing fences for seq-cst stores by default 
(#87376)"
- Revert "[RISCV] Support RISCV Atomics ABI attributes (#84597)"
- [SelectionDAG] Treat CopyFromReg as freezing the value (#85932)
- [DAGCombiner] Do not always fold FREEZE over BUILD_VECTOR (#85932)
- [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (#90143)
- [clang][X86] Fix -Wundef warning in cpuid.h (#89842)
- Add test cases for SELECT->AND miscompiles in DAGCombiner
- [M68k] Add support for MOVEQ instruction (#88542)
- [Transforms] Debug values are not remapped when cloning. (#87747)
- [RISCV][NFC] Future-proof reference to ISA manual in RISCVInstrInfoC.td
- [DAG] visitORCommutative - fold build_pair(not(x),not(y)) -> 
not(build_pair(x,y)) style patterns (#90050)
- [NFC][OpenACC] Remove stale FIXME comment in a test
- DAG: Simplify demanded bits for truncating atomic_store (#90113)
- [Offload] Remove remaining `__tgt_register_requires` references (#90198)
- Revert "[TableGen] Ignore inaccessible memory when checking pattern flags 
(#90061)"
- [SLP]Attempt to vectorize long stores, if short one failed.
- [mlir][MemRef] Add ExtractStridedMetadataOpCollapseShapeFolder (#89954)
- [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)
- [clang] Add test for CWG2149 "Brace elision and array length deduction" 
(#90079)
- [libc++][ranges] LWG3984: ranges::to's recursion branch may be ill-formed 
(#87964)
- [clang-tidy][NFC] Fix broken link in documentation of cert-env33-c (#90216)
- [mlir] Fix -Wdeprecated-declarations of cast in VCIXToLLVMIRTranslation.cpp 
(NFC)
- [mlir] Add sub-byte type emulation support for `memref.collapse_shape` (#89962)
- [MC] Rename temporary symbols of empty name to ".L0 " (#89693)
- [X86] Regenerate subreg-to-reg tests with update_llc_test_checks.py
- [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (#89446)
- [AArch64][SVE2] SVE2 NBSL instruction lowering. (#89732)
- [libc++][ranges] Exports operator|. (#90071)
- [NFC] update comments from an earlier version of SuffixTree (#89800)
- [scudo] Reflect the allowed values for M_DECAY_TIME on Android (#89114)
- [DXIL] Fix build warning (#90226)
- [OpenMP][AIX] Use syssmt() to get the number of SMTs per physical CPU (#89985)
- [RISCV] Flatten the ImpliedExts table in RISCVISAInfo.cpp (#89975)
- [LV] Add tests showing missed propgation of versiond stride values.
- [mlir][sparse] fold sparse convert into producer linalg op. (#8)
- [Arm64EC] Improve alignment mangling in arm64ec thunks. (#90115)
- [RISCV] Add an instruction PrettyPrinter to llvm-objdump (#90093)
- [APINotes] Allow annotating a C++ type as non-copyable in Swift
- [lldb] Switch to llvm::DWARFUnitHeader (#89808)
- [SLP]Fix PR90224: check that users of gep are all vectorized.
- [lldb] Fix typo in CumulativeSystemTimeIsValid check (#89680)
- [Libomptarget] Rename `libomptarget.rtl.x86_64` to `libomptarget.rtl.host` 
(#86868)
- [RISCV] Consistently use uint32_t in Disassembler decode functions. NFC
- [Driver,test] Replace CHECK-NOT: warning with -### -Werror
- [HLSL][SPIR-V] Target `directx` is required
- Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. 
(#89998)" (#90250)
- [RISCV] Fix off by 1 typo in decodeVMaskReg. NFC
- Implement the DWARF 6 language and version attributes. (#89980)
- [AMDGPU] Support byte_sel modifier on v_cvt_sr_fp8_f32 and v_cvt_sr_bf8_f32 
(#90244)
- [ci] Add clang project dependency for bolt testing (#90262)
- [NFC] [HWASan] factor out debug record annotation (#90252)
- [lldb][sbapi] Fix API break in SBDebugger broadcast bits (#90261)
- [VPlan] Also propagate versioned strides to users via sext/zext.
- [flang][cuda] Avoid to issue data transfer in device context (#90247)
- [WebAssembly] Add half-precision feature (#90248)
- [BOLT][NFC] Use getEHFrameHdrSectionName() (#90257)
- [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, 
RefPtr, and their variants. (#90153)
- [ASan][Test] Remove hardcoded linker version from test (#90147)
- [AArch64] Add support for Cortex-R82AE and improve Cortex-R82


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


8 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note.c (+2-2) 
- (modified) llvm/docs/ReleaseNotes.rst (+1-1) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+12-1) 
- (modified) llvm/lib/Target/AArch64/AArch64Processors.td (+14-1) 
- (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+1) 
- (modified) llvm/lib/TargetParser/Host.cpp (+1) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+15-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5d4d152b2eb540..c92d480023f4d4 100644
--- a/clang

[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread Jonathan Thackray via cfe-commits

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


[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread Jonathan Thackray via cfe-commits

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


[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)

2024-04-29 Thread Haojian Wu via cfe-commits

hokein wrote:

> @hokein Independently of the direction taken I'd like to see a better 
> diagnostic than "atomic constraint using an undocumented/cryptic trait that 
> is not in the code is not satisfied". 
> So when we try to print atomic constraints, we should do something more user 
> friendly for is_deducible. (`note_atomic_constraint_evaluated_to_false` in 
> `diagnoseWellFormedUnsatisfiedConstraintExpr` AFAICT). It might be a bit 
> ad-hoc, but I think it's worth doing

I agree with you -- having a well-described diagnostic message is better and 
clearer. I'm happy to improve it once we settle on the final implementation 
approach (the current diagnostic `because '__is_deducible(AFoo, Foo)' 
evaluated to false` seems okay to me. GCC also emits similar diagnostics).

By the way, other parts of this patch are ready for review.

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


[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

2024-04-29 Thread Haojian Wu via cfe-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/82776

>From 3ab1a074592f85715c061007c56c69c24794a556 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 23 Feb 2024 10:03:16 +0100
Subject: [PATCH 1/2] [clang] Add __builtin_start_object_lifetime builtin.

This patch implements a clang built `__builtin_start_object_lifetime`,
it has the same semantics as C++23's `std::start_lifetime_as`, but
without the implicit-lifetime type restriction, it can be used for
implementing `std::start_lifetime_as` in the future.

Due to the current clang lowering, the builtin reuses the existing 
`__builtin_launder` implementation:
- it is a no-op for the most part;
- with `-fstrict-vtable-pointers` flag, we update the vtpr assumption correctly
  (mark the load/store vptr with appropriate invariant group intrinsics)
  to prevent incorrect vptr load folding;
- for now, the builtin is non-constant, cannot be executed in constant 
evaluation;

CAVEAT:
- this builtin may cause TBAA miscomplies without the `-fno-strict-alias`
  flag. These TBAA miscompiles are known issues and may need more LLVM
  IR support for the fix, fixing them is orthogonal to the implementaton of the
  builtin.

Context: 
https://discourse.llvm.org/t/extension-for-creating-objects-via-memcpy/76961
---
 clang/include/clang/Basic/Builtins.td |  6 +++
 clang/lib/CodeGen/CGBuiltin.cpp   |  1 +
 clang/lib/Sema/SemaChecking.cpp   |  2 +
 clang/test/CodeGen/builtins.c | 10 
 .../builtin-start-object-life-time.cpp| 49 +++
 clang/test/SemaCXX/builtins.cpp   | 33 -
 6 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGenCXX/builtin-start-object-life-time.cpp

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index de721a87b3341d..399fabe53d9fa0 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -926,6 +926,12 @@ def Launder : Builtin {
   let Prototype = "void*(void*)";
 }
 
+def StartObjectLifeTime : Builtin {
+  let Spellings = ["__builtin_start_object_lifetime"];
+  let Attributes = [NoThrow, CustomTypeChecking];
+  let Prototype = "void*(void*)";
+}
+
 def IsConstantEvaluated : LangBuiltin<"CXX_LANG"> {
   let Spellings = ["__builtin_is_constant_evaluated"];
   let Attributes = [NoThrow, Constexpr];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7e5f2edfc732cc..e81f39149bfbc9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4521,6 +4521,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 
 return RValue::get(nullptr);
   }
+  case Builtin::BI__builtin_start_object_lifetime:
   case Builtin::BI__builtin_launder: {
 const Expr *Arg = E->getArg(0);
 QualType ArgTy = Arg->getType()->getPointeeType();
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 51757f4cf727d6..f16a9a53857154 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -38,6 +38,7 @@
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/UnresolvedSet.h"
 #include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/IdentifierTable.h"
@@ -2641,6 +2642,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 TheCall->setType(Context.IntTy);
 break;
   }
+  case Builtin::BI__builtin_start_object_lifetime:
   case Builtin::BI__builtin_launder:
 return BuiltinLaunder(*this, TheCall);
   case Builtin::BI__sync_fetch_and_add:
diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index 407e0857d22311..00c81c23d0ed02 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -143,6 +143,7 @@ int main(void) {
   P(signbit, (1.0));
 
   R(launder, (&N));
+  R(start_object_lifetime, (&N));
 
   return 0;
 }
@@ -511,6 +512,15 @@ void test_builtin_launder(int *p) {
   int *d = __builtin_launder(p);
 }
 
+/// It should be a NOP in C since there are no vtables.
+// CHECK-LABEL: define{{.*}} void @test_builtin_start_object_lifetime
+void test_builtin_start_object_lifetime(int *p) {
+  // CHECK: [[TMP:%.*]] = load ptr,
+  // CHECK-NOT: @llvm.launder
+  // CHECK: store ptr [[TMP]],
+  int *d = __builtin_start_object_lifetime(p);
+}
+
 // __warn_memset_zero_len should be NOP, see 
https://sourceware.org/bugzilla/show_bug.cgi?id=25399
 // CHECK-LABEL: define{{.*}} void @test___warn_memset_zero_len
 void test___warn_memset_zero_len(void) {
diff --git a/clang/test/CodeGenCXX/builtin-start-object-life-time.cpp 
b/clang/test/CodeGenCXX/builtin-start-object-life-time.cpp
new file mode 100644
index 00..58012f52cc0ef5
--- /dev/null
+++ b/clang/test/CodeGenCXX/builtin-start-object-life-time.cpp
@@ -0,0 +

[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread via cfe-commits

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


[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread via cfe-commits

https://github.com/Sirraide commented:

The approach here looks correct, but I’m not sure it’s in the right place.

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


[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread via cfe-commits


@@ -6229,7 +6231,37 @@ static ExprResult BuildConvertedConstantExpression(Sema 
&S, Expr *From,
   if (Result.isInvalid())
 return Result;
 
-  // Check for a narrowing implicit conversion.
+  if (SCS->Second == ICK_Floating_Conversion) {

Sirraide wrote:

Is there a reason all of this is here instead of in 
`StandardConversionSequence::getNarrowingKind()`, where we seem to be already 
handling most of this?

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


[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread via cfe-commits


@@ -6229,7 +6231,37 @@ static ExprResult BuildConvertedConstantExpression(Sema 
&S, Expr *From,
   if (Result.isInvalid())
 return Result;
 
-  // Check for a narrowing implicit conversion.
+  if (SCS->Second == ICK_Floating_Conversion) {

Sirraide wrote:

‘all of this’ being everything you added here

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread Maxim Moskalets via cfe-commits

https://github.com/maxmosk created 
https://github.com/llvm/llvm-project/pull/90441

Replace CommonOptionsParser ctor by factory method ::create.

Found on page https://clang.llvm.org/docs/LibTooling.html

>From ed05f896b39f4bd6feb6fa01375d3971064b15fb Mon Sep 17 00:00:00 2001
From: Maxim Moskalets 
Date: Mon, 29 Apr 2024 11:39:10 +0300
Subject: [PATCH] [Clang] Fix LibTooling doc

Replace CommonOptionsParser ctor by factory method ::create.
---
 clang/docs/LibTooling.rst | 12 ++--
 clang/include/clang/Tooling/CommonOptionsParser.h |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index df50dcebf9b83c..d6fd1d99a5c845 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -71,9 +71,9 @@ and automatic location of the compilation database using 
source files paths.
   int main(int argc, const char **argv) {
 // CommonOptionsParser constructor will parse arguments and create a
 // CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
 
-// Use OptionsParser.getCompilations() and 
OptionsParser.getSourcePathList()
+// Use OptionsParser->getCompilations() and 
OptionsParser->getSourcePathList()
 // to retrieve CompilationDatabase and the list of input file paths.
   }
 
@@ -93,7 +93,7 @@ our ``FrontendAction`` over some code.  For example, to run 
the
 
   // We hand the CompilationDatabase we created and the sources to run over 
into
   // the tool constructor.
-  ClangTool Tool(OptionsParser.getCompilations(), Sources);
+  ClangTool Tool(OptionsParser->getCompilations(), Sources);
 
   // The ClangTool needs a new FrontendAction for each translation unit we run
   // on.  Thus, it takes a FrontendActionFactory as parameter.  To create a
@@ -133,9 +133,9 @@ version of this example tool is also checked into the clang 
tree at
   static cl::extrahelp MoreHelp("\nMore help text...\n");
 
   int main(int argc, const char **argv) {
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
-ClangTool Tool(OptionsParser.getCompilations(),
-   OptionsParser.getSourcePathList());
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
+ClangTool Tool(OptionsParser->getCompilations(),
+   OptionsParser->getSourcePathList());
 return Tool.run(newFrontendActionFactory().get());
   }
 
diff --git a/clang/include/clang/Tooling/CommonOptionsParser.h 
b/clang/include/clang/Tooling/CommonOptionsParser.h
index 3c0480af377943..857dcd23331f87 100644
--- a/clang/include/clang/Tooling/CommonOptionsParser.h
+++ b/clang/include/clang/Tooling/CommonOptionsParser.h
@@ -56,9 +56,9 @@ namespace tooling {
 /// ...
 ///
 /// int main(int argc, const char **argv) {
-///   CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
-///   ClangTool Tool(OptionsParser.getCompilations(),
-///  OptionsParser.getSourcePathList());
+///   auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
+///   ClangTool Tool(OptionsParser->getCompilations(),
+///  OptionsParser->getSourcePathList());
 ///   return Tool.run(newFrontendActionFactory().get());
 /// }
 /// \endcode

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Maxim Moskalets (maxmosk)


Changes

Replace CommonOptionsParser ctor by factory method ::create.

Found on page https://clang.llvm.org/docs/LibTooling.html

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


2 Files Affected:

- (modified) clang/docs/LibTooling.rst (+6-6) 
- (modified) clang/include/clang/Tooling/CommonOptionsParser.h (+3-3) 


``diff
diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index df50dcebf9b83c..d6fd1d99a5c845 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -71,9 +71,9 @@ and automatic location of the compilation database using 
source files paths.
   int main(int argc, const char **argv) {
 // CommonOptionsParser constructor will parse arguments and create a
 // CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
 
-// Use OptionsParser.getCompilations() and 
OptionsParser.getSourcePathList()
+// Use OptionsParser->getCompilations() and 
OptionsParser->getSourcePathList()
 // to retrieve CompilationDatabase and the list of input file paths.
   }
 
@@ -93,7 +93,7 @@ our ``FrontendAction`` over some code.  For example, to run 
the
 
   // We hand the CompilationDatabase we created and the sources to run over 
into
   // the tool constructor.
-  ClangTool Tool(OptionsParser.getCompilations(), Sources);
+  ClangTool Tool(OptionsParser->getCompilations(), Sources);
 
   // The ClangTool needs a new FrontendAction for each translation unit we run
   // on.  Thus, it takes a FrontendActionFactory as parameter.  To create a
@@ -133,9 +133,9 @@ version of this example tool is also checked into the clang 
tree at
   static cl::extrahelp MoreHelp("\nMore help text...\n");
 
   int main(int argc, const char **argv) {
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
-ClangTool Tool(OptionsParser.getCompilations(),
-   OptionsParser.getSourcePathList());
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
+ClangTool Tool(OptionsParser->getCompilations(),
+   OptionsParser->getSourcePathList());
 return Tool.run(newFrontendActionFactory().get());
   }
 
diff --git a/clang/include/clang/Tooling/CommonOptionsParser.h 
b/clang/include/clang/Tooling/CommonOptionsParser.h
index 3c0480af377943..857dcd23331f87 100644
--- a/clang/include/clang/Tooling/CommonOptionsParser.h
+++ b/clang/include/clang/Tooling/CommonOptionsParser.h
@@ -56,9 +56,9 @@ namespace tooling {
 /// ...
 ///
 /// int main(int argc, const char **argv) {
-///   CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
-///   ClangTool Tool(OptionsParser.getCompilations(),
-///  OptionsParser.getSourcePathList());
+///   auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
+///   ClangTool Tool(OptionsParser->getCompilations(),
+///  OptionsParser->getSourcePathList());
 ///   return Tool.run(newFrontendActionFactory().get());
 /// }
 /// \endcode

``




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


[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

2024-04-29 Thread Haojian Wu via cfe-commits

hokein wrote:

Friendly ping.

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


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-29 Thread Adrian Vogelsgesang via cfe-commits


@@ -187,7 +187,7 @@ C++2c implementation status
  
   Trivial infinite loops are not Undefined Behavior
   https://wg21.link/P2809R3";>P2809R3 (DR)
-  No
+  Clang 19

vogelsgesang wrote:

the wrong paper was marked as implemented

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


[clang] [llvm] [mlir] Move several vector intrinsics out of experimental namespace (PR #88748)

2024-04-29 Thread Maciej Gabka via cfe-commits

mgabka wrote:

I needed to adjust one more test after another rebase:
llvm/test/Transforms/LoopVectorize/AArch64/reduction-recurrence-costs-sve.ll 

I am merging it know without waiting for the pre commit validation, otrherwise 
will most likely need to update another tests etc. 

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


[clang] [llvm] [mlir] Move several vector intrinsics out of experimental namespace (PR #88748)

2024-04-29 Thread Maciej Gabka via cfe-commits

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits

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

Thanks for improving our documentation!

There’s some error handling missing here. The `CommonOptionsParser` constructor 
would previously just exit, but that is no longer the case here, so we actually 
need to handle errors now.

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits


@@ -71,9 +71,9 @@ and automatic location of the compilation database using 
source files paths.
   int main(int argc, const char **argv) {
 // CommonOptionsParser constructor will parse arguments and create a
 // CompilationDatabase.  In case of error it will terminate the program.

Sirraide wrote:

This needs to be updated too. ‘In case of error it will terminate the program’ 
is no longer correct.

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits


@@ -71,9 +71,9 @@ and automatic location of the compilation database using 
source files paths.
   int main(int argc, const char **argv) {
 // CommonOptionsParser constructor will parse arguments and create a
 // CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);

Sirraide wrote:

Also, `->` needs to be replaced with `.` again below.

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits


@@ -133,9 +133,9 @@ version of this example tool is also checked into the clang 
tree at
   static cl::extrahelp MoreHelp("\nMore help text...\n");
 
   int main(int argc, const char **argv) {
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
-ClangTool Tool(OptionsParser.getCompilations(),
-   OptionsParser.getSourcePathList());
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);

Sirraide wrote:

As above

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits


@@ -71,9 +71,9 @@ and automatic location of the compilation database using 
source files paths.
   int main(int argc, const char **argv) {
 // CommonOptionsParser constructor will parse arguments and create a
 // CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);

Sirraide wrote:

```suggestion
Expected ExpectedParser = 
  CommonOptionsParser::create(argc, argv, MyToolCategory);
if (auto E = ExpectedParser.takeError()) {
  errs() << "Error creating options parser: " << toString(std::move(E)) << 
"\n";
  return 1;
}

auto& OptionsParser = ExpectedParser.get();
```
Using `->` or `*` on an `Expected` will assert if the `Expected` hasn’t been 
checked for errors, even if it does not contain an error. Something like this 
should work, but please verify that this actually compiles. 

Furthermore, we normally spell out types instead of using `auto` in cases where 
the type isn’t obvious from the context. Moreover, I think there’s value in 
being a bit more verbose here since this documentation is mainly intended for 
people new to libtooling.





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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits


@@ -56,9 +56,9 @@ namespace tooling {
 /// ...
 ///
 /// int main(int argc, const char **argv) {
-///   CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
-///   ClangTool Tool(OptionsParser.getCompilations(),
-///  OptionsParser.getSourcePathList());
+///   auto OptionsParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);

Sirraide wrote:

And here too

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


[clang] [flang] [Flang] RFC: Add support for -w option (PR #90420)

2024-04-29 Thread Kiran Chandramohan via cfe-commits

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


[clang] [flang] [Flang] RFC: Add support for -w option (PR #90420)

2024-04-29 Thread Kiran Chandramohan via cfe-commits

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


[clang-tools-extra] [clang-tidy] Add modernize-use-std-format check (PR #90397)

2024-04-29 Thread Mike Crowe via cfe-commits


@@ -0,0 +1,107 @@
+//===--- UseStdFormatCheck.cpp - clang-tidy 
---===//
+//
+// 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
+//
+//===--===//
+
+#include "UseStdFormatCheck.h"
+#include "../utils/FormatStringConverter.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+namespace {
+AST_MATCHER(StringLiteral, isOrdinary) { return Node.isOrdinary(); }
+} // namespace
+
+UseStdFormatCheck::UseStdFormatCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  StrictMode(Options.getLocalOrGlobal("StrictMode", false)),
+  StrFormatLikeFunctions(utils::options::parseStringList(
+  Options.get("StrFormatLikeFunctions", ""))),
+  ReplacementFormatFunction(
+  Options.get("ReplacementFormatFunction", "std::format")),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM),
+  areDiagsSelfContained()),
+  MaybeHeaderToInclude(Options.get("FormatHeader")) {
+  if (StrFormatLikeFunctions.empty())
+StrFormatLikeFunctions.push_back("absl::StrFormat");
+
+  if (!MaybeHeaderToInclude && ReplacementFormatFunction == "std::format")
+MaybeHeaderToInclude = "";
+}
+
+void UseStdFormatCheck::registerPPCallbacks(const SourceManager &SM,
+Preprocessor *PP,
+Preprocessor *ModuleExpanderPP) {
+  IncludeInserter.registerPreprocessor(PP);
+}
+
+void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(argumentCountAtLeast(1),
+   hasArgument(0, stringLiteral(isOrdinary())),
+   callee(functionDecl(unless(cxxMethodDecl()),
+   matchers::matchesAnyListedName(
+   StrFormatLikeFunctions))
+  .bind("func_decl")))
+  .bind("strformat"),
+  this);
+}
+
+void UseStdFormatCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  using utils::options::serializeStringList;
+  Options.store(Opts, "StrictMode", StrictMode);
+  Options.store(Opts, "StrFormatLikeFunctions",
+serializeStringList(StrFormatLikeFunctions));
+  Options.store(Opts, "ReplacementFormatFunction", ReplacementFormatFunction);
+  Options.store(Opts, "IncludeStyle", IncludeInserter.getStyle());
+  if (MaybeHeaderToInclude)
+Options.store(Opts, "FormatHeader", *MaybeHeaderToInclude);
+}
+
+void UseStdFormatCheck::check(const MatchFinder::MatchResult &Result) {
+  const unsigned FormatArgOffset = 0;
+  const auto *OldFunction = Result.Nodes.getNodeAs("func_decl");
+  const auto *StrFormat = Result.Nodes.getNodeAs("strformat");
+
+  utils::FormatStringConverter::Configuration ConverterConfig;
+  ConverterConfig.StrictMode = StrictMode;
+  utils::FormatStringConverter Converter(Result.Context, StrFormat,
+ FormatArgOffset, ConverterConfig,
+ getLangOpts());
+  const Expr *StrFormatCall = StrFormat->getCallee();
+  if (!Converter.canApply()) {
+DiagnosticBuilder Diag = diag(StrFormat->getBeginLoc(),
+  "unable to use '%0' instead of %1 because 
%2")

mikecrowe wrote:

The use of `OldFunction->getIdentifier()` means that the string passed for `%1` 
is already surrounded by quotes. You can see this in the lit test strings:
```
// CHECK-MESSAGES: [[@LINE-1]]:13: warning: use 'std::format' instead of 
'StrFormat' [modernize-use-std-format]
```

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


[clang-tools-extra] [clang-tidy] Add modernize-use-std-format check (PR #90397)

2024-04-29 Thread Mike Crowe via cfe-commits

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits

Sirraide wrote:

I also just noticed that there already is a pr for this: #70427.

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


[clang] [llvm] [AArch64] Add intrinsics for bflaot16 min/max/minnm/maxnm (PR #90105)

2024-04-29 Thread via cfe-commits

https://github.com/CarolineConcatto commented:

It looks good Hassnaa, I am just concern about how we build the llvm-ir 
intrinsic. All the other BF intrinsics don't have the name b + the type size

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


[clang] [llvm] [AArch64] Add intrinsics for bflaot16 min/max/minnm/maxnm (PR #90105)

2024-04-29 Thread via cfe-commits

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


[clang] [llvm] [AArch64] Add intrinsics for bflaot16 min/max/minnm/maxnm (PR #90105)

2024-04-29 Thread via cfe-commits


@@ -109,6 +109,19 @@ define { ,  } 
@multi_vec_max_single_x2_u64(<
   ret { ,  } %res
 }
 
+; BFMAX (Single, x2)
+
+define { ,  } 
@multi_vec_max_single_x2_bf16( %zdn1,  %zdn2,  %zm) {
+; CHECK-LABEL: multi_vec_max_single_x2_bf16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:bfmax { z0.h, z1.h }, { z0.h, z1.h }, z2.h
+; CHECK-NEXT:ret
+  %res = call { ,  } 
@llvm.aarch64.sve.bfmax.single.x2.nxv8bf16( %zdn1,  %zdn2,  %zm)

CarolineConcatto wrote:

I am not sure we should keep this. I understand that in InstriniscAArch64.td 
you are declaring together with previous implementation, but maybe we should 
split it and have one just for BF types

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


[clang-tools-extra] [clang-tidy] Add modernize-use-std-format check (PR #90397)

2024-04-29 Thread Danny Mösch via cfe-commits


@@ -0,0 +1,107 @@
+//===--- UseStdFormatCheck.cpp - clang-tidy 
---===//
+//
+// 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
+//
+//===--===//
+
+#include "UseStdFormatCheck.h"
+#include "../utils/FormatStringConverter.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+namespace {
+AST_MATCHER(StringLiteral, isOrdinary) { return Node.isOrdinary(); }
+} // namespace
+
+UseStdFormatCheck::UseStdFormatCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  StrictMode(Options.getLocalOrGlobal("StrictMode", false)),
+  StrFormatLikeFunctions(utils::options::parseStringList(
+  Options.get("StrFormatLikeFunctions", ""))),
+  ReplacementFormatFunction(
+  Options.get("ReplacementFormatFunction", "std::format")),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM),
+  areDiagsSelfContained()),
+  MaybeHeaderToInclude(Options.get("FormatHeader")) {
+  if (StrFormatLikeFunctions.empty())
+StrFormatLikeFunctions.push_back("absl::StrFormat");
+
+  if (!MaybeHeaderToInclude && ReplacementFormatFunction == "std::format")
+MaybeHeaderToInclude = "";
+}
+
+void UseStdFormatCheck::registerPPCallbacks(const SourceManager &SM,
+Preprocessor *PP,
+Preprocessor *ModuleExpanderPP) {
+  IncludeInserter.registerPreprocessor(PP);
+}
+
+void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(argumentCountAtLeast(1),
+   hasArgument(0, stringLiteral(isOrdinary())),
+   callee(functionDecl(unless(cxxMethodDecl()),
+   matchers::matchesAnyListedName(
+   StrFormatLikeFunctions))
+  .bind("func_decl")))
+  .bind("strformat"),
+  this);
+}
+
+void UseStdFormatCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  using utils::options::serializeStringList;
+  Options.store(Opts, "StrictMode", StrictMode);
+  Options.store(Opts, "StrFormatLikeFunctions",
+serializeStringList(StrFormatLikeFunctions));
+  Options.store(Opts, "ReplacementFormatFunction", ReplacementFormatFunction);
+  Options.store(Opts, "IncludeStyle", IncludeInserter.getStyle());
+  if (MaybeHeaderToInclude)
+Options.store(Opts, "FormatHeader", *MaybeHeaderToInclude);
+}
+
+void UseStdFormatCheck::check(const MatchFinder::MatchResult &Result) {
+  const unsigned FormatArgOffset = 0;
+  const auto *OldFunction = Result.Nodes.getNodeAs("func_decl");
+  const auto *StrFormat = Result.Nodes.getNodeAs("strformat");
+
+  utils::FormatStringConverter::Configuration ConverterConfig;
+  ConverterConfig.StrictMode = StrictMode;
+  utils::FormatStringConverter Converter(Result.Context, StrFormat,
+ FormatArgOffset, ConverterConfig,
+ getLangOpts());
+  const Expr *StrFormatCall = StrFormat->getCallee();
+  if (!Converter.canApply()) {
+DiagnosticBuilder Diag = diag(StrFormat->getBeginLoc(),
+  "unable to use '%0' instead of %1 because 
%2")

SimplyDanny wrote:

That's fine then. Just a little surprising.

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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread Maxim Moskalets via cfe-commits

maxmosk wrote:

> I also just noticed that there already is a pr for this: #70427.

This PR wasn't approved and doc is still not fixed :(
What to do with this PR?

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


[clang] [llvm] [AArch64] Add intrinsics for bflaot16 min/max/minnm/maxnm (PR #90105)

2024-04-29 Thread Momchil Velikov via cfe-commits


@@ -3387,7 +3387,7 @@ let TargetPrefix = "aarch64" in {
   // Multi-vector floating point min/max number
   //
 
-  foreach instr = ["fmaxnm", "fminnm"] in {
+  foreach instr = ["fmaxnm", "bfmaxnm", "fminnm", "bfminnm"] in {

momchil-velikov wrote:

Likewise here.

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


[clang] [llvm] [AArch64] Add intrinsics for bflaot16 min/max/minnm/maxnm (PR #90105)

2024-04-29 Thread Momchil Velikov via cfe-commits


@@ -3373,7 +3373,7 @@ let TargetPrefix = "aarch64" in {
   // Multi-vector min/max
   //
 
-  foreach ty = ["f", "s", "u"] in {
+  foreach ty = ["bf", "f", "s", "u"] in {

momchil-velikov wrote:

You could just omit that part. Then the `bfloat` intrinsics would use 
`fmin`/`fmax`/etc in the names without ambiguity, since they are polymorphic.

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


[clang] [llvm] [SME] Add intrinsics for FCVT(wid.) and FCVTL (PR #90215)

2024-04-29 Thread via cfe-commits

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


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


[clang] [Clang] Fix LibTooling doc (PR #90441)

2024-04-29 Thread via cfe-commits

Sirraide wrote:

> This PR wasn't approved and doc is still not fixed :( What to do with this PR?

It somehow just went unnoticed all this time, unfortunately. I’ll approve the 
other pr since it seems to do the same thing that we’re also doing somewhere 
else in our documentation, and it’s pretty much what I suggested here anyway.

The comment in `clang/Tooling/CommonOptionsParser.h` still needs to be updated, 
which the other pr doesn’t do; you can still do that if you’d like. Sorry about 
the entire confusion here; this is something that shouldn’t normally happen...

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


[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread Mital Ashok via cfe-commits


@@ -6229,7 +6231,37 @@ static ExprResult BuildConvertedConstantExpression(Sema 
&S, Expr *From,
   if (Result.isInvalid())
 return Result;
 
-  // Check for a narrowing implicit conversion.
+  if (SCS->Second == ICK_Floating_Conversion) {

MitalAshok wrote:

Because it has a different specification from narrowing conversions 
( vs ), 
so we need stuff specific for converted constant expressions. E.g., 
`float{__FLT_DENORM_MIN__ / 4.0}` is not a narrowing conversion even though it 
rounds the double value to `0.0f`, but it shouldn't be a converted constant 
expression.

Theoretically we should only be calling `getNarrowingKind` when `SCS->Second == 
ICK_Integral_Conversion` (I think we also use it for boolean conversions 
[CWG1407](https://cplusplus.github.io/CWG/issues/1407.html)).

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


[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor on libTooling tutorial (NFC) (PR #70427)

2024-04-29 Thread via cfe-commits

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

LGTM except for one minor issue.

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


[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor on libTooling tutorial (NFC) (PR #70427)

2024-04-29 Thread via cfe-commits


@@ -63,15 +63,22 @@ and automatic location of the compilation database using 
source files paths.
   #include "llvm/Support/CommandLine.h"
 
   using namespace clang::tooling;
+  using namespace llvm;
 
   // Apply a custom category to all command-line options so that they are the
   // only ones displayed.
-  static llvm::cl::OptionCategory MyToolCategory("my-tool options");
+  static cl::OptionCategory MyToolCategory("my-tool options");
 
   int main(int argc, const char **argv) {
-// CommonOptionsParser constructor will parse arguments and create a
-// CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+// CommonOptionsParser::create will parse arguments and create a
+// CompilationDatabase. In case of error it will terminate the program.

Sirraide wrote:

```suggestion
// CompilationDatabase.
```
That’s no longer true.

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


[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor on libTooling tutorial (NFC) (PR #70427)

2024-04-29 Thread via cfe-commits

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


[clang] [llvm] [RISCV] Add processor definition and scheduling model for XiangShan-KunMingHu (PR #90392)

2024-04-29 Thread Camel Coder via cfe-commits
=?utf-8?b?6YOd5bq36L6+?= 
Message-ID:
In-Reply-To: 


camel-cdr wrote:

The execution unit layout does not match the current XiangShan master. Has the 
final execution unit layout been decided on?

[earlier 
layout](https://github.com/OpenXiangShan/XiangShan/blob/e25e4d90505c592524b410b127fe611ac49a3adf/src/main/scala/xiangshan/Parameters.scala#L355),
 which this PR seems to be based on:
```
VFEX0: VfaluCfg, VfmaCfg, VialuCfg, VimacCfg
VFEX1: VipuCfg, VppuCfg, VfcvtCfg, F2vCfg, F2fCfg, F2iCfg, VSetRvfWvfCfg
VFEX2: VfaluCfg, VfmaCfg, VialuCfg
VFEX3: VfdivCfg, VidivCfg
```
[current master 
layout](https://github.com/OpenXiangShan/XiangShan/blob/2e61107/src/main/scala/xiangshan/Parameters.scala#L357):
```
VFEX0: VfmaCfg, VialuCfg, VimacCfg, VppuCfg
VFEX1: VfaluCfg, VfcvtCfg, VipuCfg, VSetRvfWvfCfg
VFEX2: VfmaCfg, VialuCfg, F2vCfg
VFEX3: VfaluCfg, VfcvtCfg
VFEX4: VfdivCfg, VidivCfg
VFEX5: VfdivCfg, VidivCfg
```

There even is a open branch that seperates the vpu and fpu pipelines: 
https://github.com/OpenXiangShan/XiangShan/blob/fp-split/src/main/scala/xiangshan/Parameters.scala#L365

I'd love to have proper scheduling support for kunminghu, but it currectly 
doesn't look like a stable target.

BTW: Having two div, but only a single vppu seems like a bit of an odd choice. 
XuanTie C920 has two permutation execution units, and so do the more comparable 
ARM Neoverse N2 and AMD Zen1.


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


[clang] [flang] [Flang] RFC: Add support for -w option (PR #90420)

2024-04-29 Thread Jeff Hammond via cfe-commits

jeffhammond wrote:

Thanks!  I built it already and will test later today.

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


[clang] [llvm] [SME] Add intrinsics for FCVT(wid.) and FCVTL (PR #90215)

2024-04-29 Thread via cfe-commits

https://github.com/Lukacma updated 
https://github.com/llvm/llvm-project/pull/90215

>From a1750b2b5658f8ced700bbf010019703fc52f126 Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Mon, 15 Apr 2024 13:31:00 +
Subject: [PATCH 1/5] [LLVM][AARCH64]Replace +sme2p1+smef16f16 by +smef16f16

According to the latest ISA Spec release[1] all instructions under:
 HasSME2p1 and HasSMEF16F16
should now only require:
HasSMEF16F16

[1]https://developer.arm.com
---
 llvm/test/MC/AArch64/SME2p1/fadd.s | 8 
 llvm/test/MC/AArch64/SME2p1/fmla-diagnostics.s | 2 +-
 llvm/test/MC/AArch64/SME2p1/fmls-diagnostics.s | 2 +-
 llvm/test/MC/AArch64/SME2p1/fsub.s | 8 
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/llvm/test/MC/AArch64/SME2p1/fadd.s 
b/llvm/test/MC/AArch64/SME2p1/fadd.s
index bdb769093c8388..ec4f27e021a000 100644
--- a/llvm/test/MC/AArch64/SME2p1/fadd.s
+++ b/llvm/test/MC/AArch64/SME2p1/fadd.s
@@ -1,16 +1,24 @@
 // RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f16f16 < %s \
 // RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
 // RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f8f16 < %s \
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f16f16 < %s \
+// RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f8f16 < %s \
 // RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
 // RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=CHECK-ERROR
 // RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme-f16f16 < %s \
 // RUN:| llvm-objdump -d --mattr=+sme-f16f16 - | FileCheck %s 
--check-prefix=CHECK-INST
 // RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme-f16f16 < %s \
+// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme-f16f16 < %s \
+// RUN:| llvm-objdump -d --mattr=+sme-f16f16 - | FileCheck %s 
--check-prefix=CHECK-INST
+// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme-f16f16 < %s \
 // RUN:| llvm-objdump -d --mattr=-sme2p1 - | FileCheck %s 
--check-prefix=CHECK-UNKNOWN
 // RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f16f16 < %s \
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f16f16 < %s \
 // RUN:| sed '/.text/d' | sed 's/.*encoding: //g' \
 // RUN:| llvm-mc -triple=aarch64 -mattr=+sme-f16f16 -disassemble 
-show-encoding \
+// RUN:| llvm-mc -triple=aarch64 -mattr=+sme-f16f16 -disassemble 
-show-encoding \
 // RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
 
 faddza.h[w8, 0, vgx2], {z0.h, z1.h}  // 1101-10100100-00011100-
diff --git a/llvm/test/MC/AArch64/SME2p1/fmla-diagnostics.s 
b/llvm/test/MC/AArch64/SME2p1/fmla-diagnostics.s
index 2f0dccb57c9076..c31b54fc05deaf 100644
--- a/llvm/test/MC/AArch64/SME2p1/fmla-diagnostics.s
+++ b/llvm/test/MC/AArch64/SME2p1/fmla-diagnostics.s
@@ -66,7 +66,7 @@ fmla za.h[w8, 8, vgx2], {z12.h-z13.h}, {z8.h-z9.h}
 // Invalid Register Suffix
 
 fmla za.d[w8, 7, vgx2], {z12.h-z13.h}, {z8.h-z9.h}
-// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand, expected 
suffix .s
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand, expected 
suffix .h
 // CHECK-NEXT: fmla za.d[w8, 7, vgx2], {z12.h-z13.h}, {z8.h-z9.h}
 // CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
 
diff --git a/llvm/test/MC/AArch64/SME2p1/fmls-diagnostics.s 
b/llvm/test/MC/AArch64/SME2p1/fmls-diagnostics.s
index 3ff09321e3436b..2deb18186eafca 100644
--- a/llvm/test/MC/AArch64/SME2p1/fmls-diagnostics.s
+++ b/llvm/test/MC/AArch64/SME2p1/fmls-diagnostics.s
@@ -66,7 +66,7 @@ fmls za.h[w8, 8, vgx2], {z12.h-z13.h}, {z8.h-z9.h}
 // Invalid Register Suffix
 
 fmls za.d[w8, 7, vgx2], {z12.h-z13.h}, {z8.h-z9.h}
-// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand, expected 
suffix .s
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand, expected 
suffix .h
 // CHECK-NEXT: fmls za.d[w8, 7, vgx2], {z12.h-z13.h}, {z8.h-z9.h}
 // CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
 
diff --git a/llvm/test/MC/AArch64/SME2p1/fsub.s 
b/llvm/test/MC/AArch64/SME2p1/fsub.s
index 66410008eb11d1..e42a819e0d4150 100644
--- a/llvm/test/MC/AArch64/SME2p1/fsub.s
+++ b/llvm/test/MC/AArch64/SME2p1/fsub.s
@@ -1,16 +1,24 @@
 // RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f16f16 < %s \
 // RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
 // RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f8f16 < %s \
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f16f16 < %s \
+// RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme-f8f16 < %s \
 // RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
 // RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=CHECK-ER

[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/90440

>From 16f06cb0d4b84a8084e963dc7d2036ead9446a87 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Sat, 27 Apr 2024 22:51:19 +0100
Subject: [PATCH 1/2] [AArch64] Add support for Cortex-R82AE and improve
 Cortex-R82

Cortex-R82AE is an Armv8R AArch64 CPU. Also, update Cortex-R82
feature flags to be more accurate.

Technical Reference Manual for Cortex-R82AE:
   https://developer.arm.com/documentation/101550/latest/
---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/test/Misc/target-invalid-cpu-note.c   |  4 ++--
 llvm/docs/ReleaseNotes.rst  |  2 +-
 .../llvm/TargetParser/AArch64TargetParser.h | 13 -
 llvm/lib/Target/AArch64/AArch64Processors.td| 15 ++-
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp|  1 +
 llvm/lib/TargetParser/Host.cpp  |  1 +
 .../unittests/TargetParser/TargetParserTest.cpp | 17 +++--
 8 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5d4d152b2eb540..c92d480023f4d4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -645,6 +645,7 @@ Arm and AArch64 Support
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
+* Arm Cortex-R82AE (cortex-r82ae).
 * Arm Neoverse-N3 (neoverse-n3).
 * Arm Neoverse-V3 (neoverse-v3).
 * Arm Neoverse-V3AE (neoverse-v3ae).
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 21d80b7134508f..768b243b04e3a3 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, 
cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, neoverse-v3, 
neoverse-v3ae, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, ampere1b, 
cobalt-100, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, 
cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-r82ae, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, 
neoverse-v3, neoverse-v3ae, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, 
apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, 
apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, 
exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, 
thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, 
ampere1a, ampere1b, cobalt-100, grace{{$}}
 
 // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
-// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, 
cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, 
cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, 
cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, 
neoverse-v3, neoverse-v3ae, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, 
apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, 
apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, 
exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, 
thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, 
ampere1a, ampere1b, cobalt

[clang] [llvm] [AArch64] Add intrinsics for multi-vector to ZA array vector accumulators (PR #88266)

2024-04-29 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/88266

>From 09167c5df2b50476a5073ff2e527503d090e7995 Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Wed, 10 Apr 2024 11:25:50 +0100
Subject: [PATCH] [AArch64] Add intrinsics for multi-vector to ZA array vector
 accumulators

---
 clang/include/clang/Basic/arm_sme.td  |  10 +
 .../acle_sme2_add_sub_za16.c  | 193 ++
 .../acle_sme2_add_sub_za16.c  |  29 +++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |   2 +-
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |  16 +-
 .../AArch64/sme2-intrinsics-add-sub-za16.ll   | 148 ++
 6 files changed, 389 insertions(+), 9 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_add_sub_za16.c
 create mode 100644 
clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_add_sub_za16.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-add-sub-za16.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 1ac6d5170ea283..000bd97a4b25d5 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -298,6 +298,16 @@ multiclass ZAAddSub {
 def NAME # _ZA64_VG1X2_F64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x2", 
"vm2", "d", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x2", [IsStreaming, 
IsInOutZA], []>;
 def NAME # _ZA64_VG1X4_F64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x4", 
"vm4", "d", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x4", [IsStreaming, 
IsInOutZA], []>;
   }
+
+  let TargetGuard = "sme-f16f16|sme-f8f16" in {
+def NAME # _ZA16_VG1X2_F16 : Inst<"sv" # n_suffix # "_za16[_{d}]_vg1x2", 
"vm2", "h", MergeNone, "aarch64_sme_" # n_suffix # "_za16_vg1x2", [IsStreaming, 
IsInOutZA], []>;
+def NAME # _ZA16_VG1X4_F16 : Inst<"sv" # n_suffix # "_za16[_{d}]_vg1x4", 
"vm4", "h", MergeNone, "aarch64_sme_" # n_suffix # "_za16_vg1x4", [IsStreaming, 
IsInOutZA], []>;
+  }
+
+  let TargetGuard = "sme2,b16b16" in {
+def NAME # _ZA16_VG1X2_BF16 : Inst<"sv" # n_suffix # "_za16[_{d}]_vg1x2", 
"vm2", "b", MergeNone, "aarch64_sme_" # n_suffix # "_za16_vg1x2", [IsStreaming, 
IsInOutZA], []>;
+def NAME # _ZA16_VG1X4_BF16 : Inst<"sv" # n_suffix # "_za16[_{d}]_vg1x4", 
"vm4", "b", MergeNone, "aarch64_sme_" # n_suffix # "_za16_vg1x4", [IsStreaming, 
IsInOutZA], []>;
+  }
 }
 
 defm SVADD : ZAAddSub<"add">;
diff --git 
a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_add_sub_za16.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_add_sub_za16.c
new file mode 100644
index 00..d98427fac610b8
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_add_sub_za16.c
@@ -0,0 +1,193 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1   -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature 
+sme-f16f16 -target-feature +b16b16 -O2 -S -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1-x c++ -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature  
+sme-f8f16 -target-feature +b16b16 -O2 -S -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK-CXX
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS-fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature  
+sme-f8f16 -target-feature +b16b16 -O2 -S -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++ -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature 
+sme-f16f16 -target-feature +b16b16 -O2 -S -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK-CXX
+
+// RUN: %clang_cc1   -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature 
+sme-f16f16 -target-feature +b16b16 -O2 -S -Werror -Wall -o /dev/null
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+// CHECK-LABEL: define dso_local void @test_svadd_za16_vg1x2_f16(
+// CHECK-SAME: i32 noundef [[SLICE:%.*]],  [[ZN:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.vector.extract.nxv8f16.nxv16f16( [[ZN]], i64 0)
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.vector.extract.nxv8f16.nxv16f16( [[ZN]], i64 8)
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.add.za16.vg1x2.nxv8f16(i32 
[[SLICE]],  [[TMP0]],  [[TMP1]])
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LABEL: define dso_local void 
@_Z25test_svadd_za16_vg1x2_f16j13svfloat16x2_t(
+// CHECK-CXX-SAME: i32 noundef [[SLICE:%.*]],  [[ZN:%.*]]) 
local_unnamed

[clang] [llvm] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS (PR #88105)

2024-04-29 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/88105

>From 3ea7ee0aaf7f8be8c2ee42af92ba3b13b8212645 Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Tue, 9 Apr 2024 10:52:41 +0100
Subject: [PATCH 1/2] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS

According to the specification in
https://github.com/ARM-software/acle/pull/309 this adds the intrinsics

void svmopa_za16[_f16]_m(uint64_t tile, svbool_t pn, svbool_t pm,
 svfloat16_t zn, svfloat16_t zm)
__arm_streaming __arm_inout("za");
void svmops_za16[_f16]_m(uint64_t tile, svbool_t pn,
 svbool_t pm, svfloat16_t zn, svfloat16_t zm)
__arm_streaming __arm_inout("za");

as well as the corresponding `bf16` variants.
---
 clang/include/clang/Basic/arm_sme.td  | 24 +
 .../acle_sme2_mopa_nonwide.c  | 97 +++
 .../acle_sme2_mopa_nonwide.c  | 34 +++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  3 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td | 10 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td| 16 ++-
 .../CodeGen/AArch64/sme2-intrinsics-mopa.ll   | 42 
 7 files changed, 219 insertions(+), 7 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c
 create mode 100644 
clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-mopa.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 1ac6d5170ea283..a18a5094a15ed3 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -674,3 +674,27 @@ let TargetGuard = "sme2" in {
   def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.di[i", 
"cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, 
IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>;
   def SVLUTI4_LANE_ZT_X2 : Inst<"svluti4_lane_zt_{d}_x2", "2.di[i", 
"cUcsUsiUibhf", MergeNone, "aarch64_sme_luti4_lane_zt_x2", [IsStreaming, 
IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>;
 }
+
+
+// SME2p1 - FMOPA, FMOPS (non-widening)
+let TargetGuard = "sme2,b16b16" in {
+  def SVMOPA_BF16_NW : SInst<"svmopa_za16[_bf16]_m", "viPPdd", "b",
+ MergeNone, "aarch64_sme_mopa",
+ [IsStreaming, IsInOutZA],
+ [ImmCheck<0, ImmCheck0_1>]>;
+  def SVMOPS_BF16_NW : SInst<"svmops_za16[_bf16]_m", "viPPdd", "b",
+ MergeNone, "aarch64_sme_mops",
+ [IsStreaming, IsInOutZA],
+ [ImmCheck<0, ImmCheck0_1>]>;
+}
+
+let TargetGuard = "sme2p1,sme-f16f16" in {
+  def SVMOPA_F16_NW : SInst<"svmopa_za16[_f16]_m", "viPPdd", "h",
+MergeNone, "aarch64_sme_mopa",
+[IsStreaming, IsInOutZA],
+[ImmCheck<0, ImmCheck0_1>]>;
+  def SVMOPS_F16_NW : SInst<"svmops_za16[_f16]_m", "viPPdd", "h",
+MergeNone, "aarch64_sme_mops",
+[IsStreaming, IsInOutZA],
+[ImmCheck<0, ImmCheck0_1>]>;
+}
diff --git 
a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c
new file mode 100644
index 00..40fcad6a576483
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c
@@ -0,0 +1,97 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1   -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature  +b16b16 
-target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=CHECK
+// RUN: %clang_cc1-x c++ -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature  +b16b16 
-target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=CHECK-CXX
+// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS-fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature  +b16b16 
-target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=CHECK
+// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -x c++ -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature  +b16b16 
-target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=CHECK-CXX
+
+// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -x c++ -fclang-abi-compat=latest 
-triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-f

[clang] [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists (PR #90210)

2024-04-29 Thread via cfe-commits

cor3ntin wrote:

The CI failure is unrelated

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


[clang] df762a1 - [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists (#90210)

2024-04-29 Thread via cfe-commits

Author: Mital Ashok
Date: 2024-04-29T12:17:18+02:00
New Revision: df762a1643bb5b0b3c907611d118c82d4b68a39d

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

LOG: [SemaCXX] Recognise initializer_list injected-class-name types as 
initializer_lists (#90210)

This allows the implicitly-generated deduction guide for the copy
constructor to be recognised as an initializer-list constructor,
allowing CTAD for std::initializer_list

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64a523a6f25fc2..50cc9924233b53 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -590,6 +590,8 @@ Bug Fixes to C++ Support
 - Fixed a use-after-free bug in parsing of type constraints with default 
arguments that involve lambdas. (#GH67235)
 - Fixed bug in which the body of a consteval lambda within a template was not 
parsed as within an
   immediate function context.
+- Fix CTAD for ``std::initializer_list``. This allows 
``std::initializer_list{1, 2, 3}`` to be deduced as
+  ``std::initializer_list`` as intended.
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1a71a37c0732aa..338b0ec1e099c0 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -12054,11 +12054,17 @@ bool Sema::isStdInitializerList(QualType Ty, QualType 
*Element) {
 
 Template = Specialization->getSpecializedTemplate();
 Arguments = Specialization->getTemplateArgs().data();
-  } else if (const TemplateSpecializationType *TST =
- Ty->getAs()) {
-Template = dyn_cast_or_null(
-TST->getTemplateName().getAsTemplateDecl());
-Arguments = TST->template_arguments().begin();
+  } else {
+const TemplateSpecializationType *TST = nullptr;
+if (auto *ICN = Ty->getAs())
+  TST = ICN->getInjectedTST();
+else
+  TST = Ty->getAs();
+if (TST) {
+  Template = dyn_cast_or_null(
+  TST->getTemplateName().getAsTemplateDecl());
+  Arguments = TST->template_arguments().begin();
+}
   }
   if (!Template)
 return false;

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 003a157990d307..842d165c60d94c 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10790,8 +10790,6 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
   // FIXME: Perform "exact type" matching first, per CWG discussion?
   //Or implement this via an implied 'T(T) -> T' deduction guide?
 
-  // FIXME: Do we need/want a std::initializer_list special case?
-
   // Look up deduction guides, including those synthesized from constructors.
   //
   // C++1z [over.match.class.deduct]p1:

diff  --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
index 2f067ea53a5029..90404f115c75f7 100644
--- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -12,14 +12,19 @@ namespace std {
 size_t n;
 initializer_list();
   };
-  // FIXME: This should probably not be necessary.
-  template initializer_list(initializer_list) -> 
initializer_list;
 }
 
 template constexpr bool has_type(...) { return false; }
 template constexpr bool has_type(T&) { return true; }
 
-std::initializer_list il = {1, 2, 3, 4, 5};
+std::initializer_list il1 = {1, 2, 3, 4, 5};
+auto il2 = std::initializer_list{1, 2, 3, 4};
+auto il3 = std::initializer_list{il1};
+auto il4 = std::initializer_list{il1, il1, il1};
+static_assert(has_type>(il1));
+static_assert(has_type>(il2));
+static_assert(has_type>(il3));
+static_assert(has_type>>(il4));
 
 template struct vector {
   template vector(Iter, Iter);



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


[clang] [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists (PR #90210)

2024-04-29 Thread via cfe-commits

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


[clang] Re-apply "Emit missing cleanups for stmt-expr" and other commits (PR #89154)

2024-04-29 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/89154

>From f1ab4c2677394bbfc985d9680d5eecd7b2e6a882 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 17 Apr 2024 22:47:36 +
Subject: [PATCH 1/4] Reapply "[codegen] Emit missing cleanups for stmt-expr
 and coro suspensions" and related commits (#4)

This reverts commit 9d8be2408768912dc113a342050049231e4fc8d1.
---
 clang/lib/CodeGen/CGCall.cpp  |  13 +-
 clang/lib/CodeGen/CGCleanup.cpp   |  49 ++-
 clang/lib/CodeGen/CGCleanup.h |  57 ++-
 clang/lib/CodeGen/CGDecl.cpp  |  61 ++-
 clang/lib/CodeGen/CGExpr.cpp  |  12 +-
 clang/lib/CodeGen/CGExprAgg.cpp   |  87 ++--
 clang/lib/CodeGen/CGExprCXX.cpp   |  38 +-
 clang/lib/CodeGen/CodeGenFunction.cpp |   6 +
 clang/lib/CodeGen/CodeGenFunction.h   |  99 -
 .../CodeGenCXX/control-flow-in-stmt-expr.cpp  | 409 ++
 .../coro-suspend-cleanups.cpp |  93 
 11 files changed, 796 insertions(+), 128 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3f5463a9a70e9d..9004e96bc1a0cf 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4693,11 +4693,11 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, 
const Expr *E,
 AggValueSlot Slot = args.isUsingInAlloca()
 ? createPlaceholderSlot(*this, type) : CreateAggTemp(type, "agg.tmp");
 
-bool DestroyedInCallee = true, NeedsEHCleanup = true;
+bool DestroyedInCallee = true, NeedsCleanup = true;
 if (const auto *RD = type->getAsCXXRecordDecl())
   DestroyedInCallee = RD->hasNonTrivialDestructor();
 else
-  NeedsEHCleanup = needsEHCleanup(type.isDestructedType());
+  NeedsCleanup = type.isDestructedType();
 
 if (DestroyedInCallee)
   Slot.setExternallyDestructed();
@@ -4706,14 +4706,15 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, 
const Expr *E,
 RValue RV = Slot.asRValue();
 args.add(RV, type);
 
-if (DestroyedInCallee && NeedsEHCleanup) {
+if (DestroyedInCallee && NeedsCleanup) {
   // Create a no-op GEP between the placeholder and the cleanup so we can
   // RAUW it successfully.  It also serves as a marker of the first
   // instruction where the cleanup is active.
-  pushFullExprCleanup(EHCleanup, Slot.getAddress(),
-  type);
+  pushFullExprCleanup(NormalAndEHCleanup,
+  Slot.getAddress(), type);
   // This unreachable is a temporary marker which will be removed later.
-  llvm::Instruction *IsActive = Builder.CreateUnreachable();
+  llvm::Instruction *IsActive =
+  Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy));
   args.addArgCleanupDeactivation(EHStack.stable_begin(), IsActive);
 }
 return;
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index e6f8e6873004f2..8683f19d9da28e 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -634,12 +634,19 @@ static void destroyOptimisticNormalEntry(CodeGenFunction 
&CGF,
 /// Pops a cleanup block.  If the block includes a normal cleanup, the
 /// current insertion point is threaded through the cleanup, as are
 /// any branch fixups on the cleanup.
-void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
+void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough,
+  bool ForDeactivation) {
   assert(!EHStack.empty() && "cleanup stack is empty!");
   assert(isa(*EHStack.begin()) && "top not a cleanup!");
   EHCleanupScope &Scope = cast(*EHStack.begin());
   assert(Scope.getFixupDepth() <= EHStack.getNumBranchFixups());
 
+  // If we are deactivating a normal cleanup, we need to pretend that the
+  // fallthrough is unreachable. We restore this IP before returning.
+  CGBuilderTy::InsertPoint NormalDeactivateOrigIP;
+  if (ForDeactivation && (Scope.isNormalCleanup() || !getLangOpts().EHAsynch)) 
{
+NormalDeactivateOrigIP = Builder.saveAndClearIP();
+  }
   // Remember activation information.
   bool IsActive = Scope.isActive();
   Address NormalActiveFlag =
@@ -667,7 +674,8 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough) {
 
   // - whether there's a fallthrough
   llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock();
-  bool HasFallthrough = (FallthroughSource != nullptr && IsActive);
+  bool HasFallthrough =
+  FallthroughSource != nullptr && (IsActive || HasExistingBranches);
 
   // Branch-through fall-throughs leave the insertion point set to the
   // end of the last cleanup, which points to the current scope.  The
@@ -692,7 +70

[clang] Re-apply "Emit missing cleanups for stmt-expr" and other commits (PR #89154)

2024-04-29 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/89154

>From f1ab4c2677394bbfc985d9680d5eecd7b2e6a882 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 17 Apr 2024 22:47:36 +
Subject: [PATCH 1/4] Reapply "[codegen] Emit missing cleanups for stmt-expr
 and coro suspensions" and related commits (#4)

This reverts commit 9d8be2408768912dc113a342050049231e4fc8d1.
---
 clang/lib/CodeGen/CGCall.cpp  |  13 +-
 clang/lib/CodeGen/CGCleanup.cpp   |  49 ++-
 clang/lib/CodeGen/CGCleanup.h |  57 ++-
 clang/lib/CodeGen/CGDecl.cpp  |  61 ++-
 clang/lib/CodeGen/CGExpr.cpp  |  12 +-
 clang/lib/CodeGen/CGExprAgg.cpp   |  87 ++--
 clang/lib/CodeGen/CGExprCXX.cpp   |  38 +-
 clang/lib/CodeGen/CodeGenFunction.cpp |   6 +
 clang/lib/CodeGen/CodeGenFunction.h   |  99 -
 .../CodeGenCXX/control-flow-in-stmt-expr.cpp  | 409 ++
 .../coro-suspend-cleanups.cpp |  93 
 11 files changed, 796 insertions(+), 128 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3f5463a9a70e9d..9004e96bc1a0cf 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4693,11 +4693,11 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, 
const Expr *E,
 AggValueSlot Slot = args.isUsingInAlloca()
 ? createPlaceholderSlot(*this, type) : CreateAggTemp(type, "agg.tmp");
 
-bool DestroyedInCallee = true, NeedsEHCleanup = true;
+bool DestroyedInCallee = true, NeedsCleanup = true;
 if (const auto *RD = type->getAsCXXRecordDecl())
   DestroyedInCallee = RD->hasNonTrivialDestructor();
 else
-  NeedsEHCleanup = needsEHCleanup(type.isDestructedType());
+  NeedsCleanup = type.isDestructedType();
 
 if (DestroyedInCallee)
   Slot.setExternallyDestructed();
@@ -4706,14 +4706,15 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, 
const Expr *E,
 RValue RV = Slot.asRValue();
 args.add(RV, type);
 
-if (DestroyedInCallee && NeedsEHCleanup) {
+if (DestroyedInCallee && NeedsCleanup) {
   // Create a no-op GEP between the placeholder and the cleanup so we can
   // RAUW it successfully.  It also serves as a marker of the first
   // instruction where the cleanup is active.
-  pushFullExprCleanup(EHCleanup, Slot.getAddress(),
-  type);
+  pushFullExprCleanup(NormalAndEHCleanup,
+  Slot.getAddress(), type);
   // This unreachable is a temporary marker which will be removed later.
-  llvm::Instruction *IsActive = Builder.CreateUnreachable();
+  llvm::Instruction *IsActive =
+  Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy));
   args.addArgCleanupDeactivation(EHStack.stable_begin(), IsActive);
 }
 return;
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index e6f8e6873004f2..8683f19d9da28e 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -634,12 +634,19 @@ static void destroyOptimisticNormalEntry(CodeGenFunction 
&CGF,
 /// Pops a cleanup block.  If the block includes a normal cleanup, the
 /// current insertion point is threaded through the cleanup, as are
 /// any branch fixups on the cleanup.
-void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
+void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough,
+  bool ForDeactivation) {
   assert(!EHStack.empty() && "cleanup stack is empty!");
   assert(isa(*EHStack.begin()) && "top not a cleanup!");
   EHCleanupScope &Scope = cast(*EHStack.begin());
   assert(Scope.getFixupDepth() <= EHStack.getNumBranchFixups());
 
+  // If we are deactivating a normal cleanup, we need to pretend that the
+  // fallthrough is unreachable. We restore this IP before returning.
+  CGBuilderTy::InsertPoint NormalDeactivateOrigIP;
+  if (ForDeactivation && (Scope.isNormalCleanup() || !getLangOpts().EHAsynch)) 
{
+NormalDeactivateOrigIP = Builder.saveAndClearIP();
+  }
   // Remember activation information.
   bool IsActive = Scope.isActive();
   Address NormalActiveFlag =
@@ -667,7 +674,8 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough) {
 
   // - whether there's a fallthrough
   llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock();
-  bool HasFallthrough = (FallthroughSource != nullptr && IsActive);
+  bool HasFallthrough =
+  FallthroughSource != nullptr && (IsActive || HasExistingBranches);
 
   // Branch-through fall-throughs leave the insertion point set to the
   // end of the last cleanup, which points to the current scope.  The
@@ -692,7 +70

[clang] Re-apply "Emit missing cleanups for stmt-expr" and other commits (PR #89154)

2024-04-29 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/89154

>From f1ab4c2677394bbfc985d9680d5eecd7b2e6a882 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 17 Apr 2024 22:47:36 +
Subject: [PATCH 1/5] Reapply "[codegen] Emit missing cleanups for stmt-expr
 and coro suspensions" and related commits (#4)

This reverts commit 9d8be2408768912dc113a342050049231e4fc8d1.
---
 clang/lib/CodeGen/CGCall.cpp  |  13 +-
 clang/lib/CodeGen/CGCleanup.cpp   |  49 ++-
 clang/lib/CodeGen/CGCleanup.h |  57 ++-
 clang/lib/CodeGen/CGDecl.cpp  |  61 ++-
 clang/lib/CodeGen/CGExpr.cpp  |  12 +-
 clang/lib/CodeGen/CGExprAgg.cpp   |  87 ++--
 clang/lib/CodeGen/CGExprCXX.cpp   |  38 +-
 clang/lib/CodeGen/CodeGenFunction.cpp |   6 +
 clang/lib/CodeGen/CodeGenFunction.h   |  99 -
 .../CodeGenCXX/control-flow-in-stmt-expr.cpp  | 409 ++
 .../coro-suspend-cleanups.cpp |  93 
 11 files changed, 796 insertions(+), 128 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3f5463a9a70e9d..9004e96bc1a0cf 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4693,11 +4693,11 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, 
const Expr *E,
 AggValueSlot Slot = args.isUsingInAlloca()
 ? createPlaceholderSlot(*this, type) : CreateAggTemp(type, "agg.tmp");
 
-bool DestroyedInCallee = true, NeedsEHCleanup = true;
+bool DestroyedInCallee = true, NeedsCleanup = true;
 if (const auto *RD = type->getAsCXXRecordDecl())
   DestroyedInCallee = RD->hasNonTrivialDestructor();
 else
-  NeedsEHCleanup = needsEHCleanup(type.isDestructedType());
+  NeedsCleanup = type.isDestructedType();
 
 if (DestroyedInCallee)
   Slot.setExternallyDestructed();
@@ -4706,14 +4706,15 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, 
const Expr *E,
 RValue RV = Slot.asRValue();
 args.add(RV, type);
 
-if (DestroyedInCallee && NeedsEHCleanup) {
+if (DestroyedInCallee && NeedsCleanup) {
   // Create a no-op GEP between the placeholder and the cleanup so we can
   // RAUW it successfully.  It also serves as a marker of the first
   // instruction where the cleanup is active.
-  pushFullExprCleanup(EHCleanup, Slot.getAddress(),
-  type);
+  pushFullExprCleanup(NormalAndEHCleanup,
+  Slot.getAddress(), type);
   // This unreachable is a temporary marker which will be removed later.
-  llvm::Instruction *IsActive = Builder.CreateUnreachable();
+  llvm::Instruction *IsActive =
+  Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy));
   args.addArgCleanupDeactivation(EHStack.stable_begin(), IsActive);
 }
 return;
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index e6f8e6873004f2..8683f19d9da28e 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -634,12 +634,19 @@ static void destroyOptimisticNormalEntry(CodeGenFunction 
&CGF,
 /// Pops a cleanup block.  If the block includes a normal cleanup, the
 /// current insertion point is threaded through the cleanup, as are
 /// any branch fixups on the cleanup.
-void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
+void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough,
+  bool ForDeactivation) {
   assert(!EHStack.empty() && "cleanup stack is empty!");
   assert(isa(*EHStack.begin()) && "top not a cleanup!");
   EHCleanupScope &Scope = cast(*EHStack.begin());
   assert(Scope.getFixupDepth() <= EHStack.getNumBranchFixups());
 
+  // If we are deactivating a normal cleanup, we need to pretend that the
+  // fallthrough is unreachable. We restore this IP before returning.
+  CGBuilderTy::InsertPoint NormalDeactivateOrigIP;
+  if (ForDeactivation && (Scope.isNormalCleanup() || !getLangOpts().EHAsynch)) 
{
+NormalDeactivateOrigIP = Builder.saveAndClearIP();
+  }
   // Remember activation information.
   bool IsActive = Scope.isActive();
   Address NormalActiveFlag =
@@ -667,7 +674,8 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough) {
 
   // - whether there's a fallthrough
   llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock();
-  bool HasFallthrough = (FallthroughSource != nullptr && IsActive);
+  bool HasFallthrough =
+  FallthroughSource != nullptr && (IsActive || HasExistingBranches);
 
   // Branch-through fall-throughs leave the insertion point set to the
   // end of the last cleanup, which points to the current scope.  The
@@ -692,7 +70

[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread via cfe-commits


@@ -6229,7 +6231,37 @@ static ExprResult BuildConvertedConstantExpression(Sema 
&S, Expr *From,
   if (Result.isInvalid())
 return Result;
 
-  // Check for a narrowing implicit conversion.
+  if (SCS->Second == ICK_Floating_Conversion) {

Sirraide wrote:

Right, there’s a difference between ‘can be represented in the range of’ and 
‘can be represented exactly’, that makes sense. I missed that somehow.

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


[clang] Re-apply "Emit missing cleanups for stmt-expr" and other commits (PR #89154)

2024-04-29 Thread Utkarsh Saxena via cfe-commits

usx95 wrote:

I have built a very large corpus with a clang built with these changes and run 
its tests. No compilation or test failures were reported. The corpus was built 
with exceptions disabled.
I am fairly confident in the correctness of this and will proceed with landing 
this patch for now.

That said, a breakage with missing destructors or double-free can likely be 
associated with this patch. Please report any breakages, especially with 
exceptions enabled.

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


[clang] d72146f - Re-apply "Emit missing cleanups for stmt-expr" and other commits (#89154)

2024-04-29 Thread via cfe-commits

Author: Utkarsh Saxena
Date: 2024-04-29T12:33:46+02:00
New Revision: d72146f47156dc645b1c0a4cb9c72f01e6d6dd0e

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

LOG: Re-apply "Emit missing cleanups for stmt-expr" and other commits (#89154)

Latest diff:
https://github.com/llvm/llvm-project/pull/89154/files/f1ab4c2677394bbfc985d9680d5eecd7b2e6a882..adf9bc902baddb156c83ce0f8ec03c142e806d45

We address two additional bugs here: 

### Problem 1: Deactivated normal cleanup still runs, leading to
double-free
Consider the following:
```cpp

struct A { };

struct B { B(const A&); };

struct S {
  A a;
  B b;
};

int AcceptS(S s);

void Accept2(int x, int y);

void Test() {
  Accept2(AcceptS({.a = A{}, .b = A{}}), ({ return; 0; }));
}
```
We add cleanups as follows:
1. push dtor for field `S::a`
2. push dtor for temp `A{}` (used by ` B(const A&)` in `.b = A{}`)
3. push dtor for field `S::b`
4. Deactivate 3 `S::b`-> This pops the cleanup.
5. Deactivate 1 `S::a` -> Does not pop the cleanup as *2* is top. Should
create _active flag_!!
6. push dtor for `~S()`.
7. ...

It is important to deactivate **5** using active flags. Without the
active flags, the `return` will fallthrough it and would run both `~S()`
and dtor `S::a` leading to **double free** of `~A()`.
In this patch, we unconditionally emit active flags while deactivating
normal cleanups. These flags are deleted later by the `AllocaTracker` if
the cleanup is not emitted.

### Problem 2: Missing cleanup for conditional lifetime extension
We push 2 cleanups for lifetime-extended cleanup. The first cleanup is
useful if we exit from the middle of the expression (stmt-expr/coro
suspensions). This is deactivated after full-expr, and a new cleanup is
pushed, extending the lifetime of the temporaries (to the scope of the
reference being initialized).
If this lifetime extension happens to be conditional, then we use active
flags to remember whether the branch was taken and if the object was
initialized.
Previously, we used a **single** active flag, which was used by both
cleanups. This is wrong because the first cleanup will be forced to
deactivate after the full-expr and therefore this **active** flag will
always be **inactive**. The dtor for the lifetime extended entity would
not run as it always sees an **inactive** flag.

In this patch, we solve this using two separate active flags for both
cleanups. Both of them are activated if the conditional branch is taken,
but only one of them is deactivated after the full-expr.

---

Fixes https://github.com/llvm/llvm-project/issues/63818
Fixes https://github.com/llvm/llvm-project/issues/88478

---

Previous PR logs:
1. https://github.com/llvm/llvm-project/pull/85398
2. https://github.com/llvm/llvm-project/pull/88670
3. https://github.com/llvm/llvm-project/pull/88751
4. https://github.com/llvm/llvm-project/pull/4

Added: 
clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp
clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGCleanup.cpp
clang/lib/CodeGen/CGCleanup.h
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGenCXX/blocks.cpp
clang/test/CodeGenObjC/arc-blocks-exceptions.m
clang/test/CodeGenObjC/arc-blocks.m

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 50cc9924233b53..604782ca43dd54 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -460,6 +460,10 @@ Bug Fixes in This Version
 
 - Fixed an assertion failure on invalid InitListExpr in C89 mode (#GH88008).
 
+- Fixed missing destructor calls when we branch from middle of an expression.
+  This could happen through a branch in stmt-expr or in an expression 
containing a coroutine
+  suspension. Fixes (#GH63818) (#GH88478).
+
 - Clang will no longer diagnose an erroneous non-dependent ``switch`` condition
   during instantiation, and instead will only diagnose it once, during checking
   of the function template.

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index d2d92140b6b2a3..69548902dc43b9 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4698,11 +4698,11 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, 
const Expr *E,
 AggValueSlot Slot = args.isUsingInAlloca()
 ? createPlaceholderSlot(*this, type) : CreateAggTemp(type, "agg.tmp");
 
-bool DestroyedInCallee = true, NeedsEHCleanup = true;
+bool DestroyedInCallee = true, NeedsCleanup = true;
 if (const auto *RD = type->getAsCXXR

[clang] Re-apply "Emit missing cleanups for stmt-expr" and other commits (PR #89154)

2024-04-29 Thread Utkarsh Saxena via cfe-commits

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


[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

2024-04-29 Thread via cfe-commits

cor3ntin wrote:

@sam-mccall Are you referring to https://reviews.llvm.org/D147020 or something 
more recent?

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


[clang] [NFC] Use `const&` avoiding copies (PR #90334)

2024-04-29 Thread Danny Mösch via cfe-commits

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


[clang] [clang] Use `cwg_index.html` from GitHub for DR status page (PR #90352)

2024-04-29 Thread via cfe-commits

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


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


[clang] [llvm] [RISCV] Add processor definition and scheduling model for XiangShan-KunMingHu (PR #90392)

2024-04-29 Thread Pengcheng Wang via cfe-commits
=?utf-8?b?6YOd5bq36L6+?= 
Message-ID:
In-Reply-To: 


wangpc-pp wrote:

I'd like to see the support of KunMingHu, but please hold this PR and wait for 
the finalization of KunMingHu's architecture.

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


[clang] f2452d4 - [clang][Interp] Implement zero-init for record types

2024-04-29 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-29T13:02:31+02:00
New Revision: f2452d4b689469b6da63d9e8ffa96eaf4b39ac5d

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

LOG: [clang][Interp] Implement zero-init for record types

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 588ffa55c11e61..aebefd716e27cc 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -924,8 +924,31 @@ bool 
ByteCodeExprGen::VisitImplicitValueInitExpr(const ImplicitValueIni
   if (std::optional T = classify(QT))
 return this->visitZeroInitializer(*T, QT, E);
 
-  if (QT->isRecordType())
-return false;
+  if (QT->isRecordType()) {
+const RecordDecl *RD = QT->getAsRecordDecl();
+assert(RD);
+if (RD->isInvalidDecl())
+  return false;
+if (RD->isUnion()) {
+  // C++11 [dcl.init]p5: If T is a (possibly cv-qualified) union type, the
+  // object's first non-static named data member is zero-initialized
+  // FIXME
+  return false;
+}
+
+if (const auto *CXXRD = dyn_cast(RD);
+CXXRD && CXXRD->getNumVBases() > 0) {
+  // TODO: Diagnose.
+  return false;
+}
+
+const Record *R = getRecord(QT);
+if (!R)
+  return false;
+
+assert(Initializing);
+return this->visitZeroRecordInitializer(R, E);
+  }
 
   if (QT->isIncompleteArrayType())
 return true;

diff  --git a/clang/test/AST/Interp/records.cpp 
b/clang/test/AST/Interp/records.cpp
index 9307b9c090c5dd..ba5c58c96c7bf5 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -90,8 +90,7 @@ struct Ints2 {
   int a = 10;
   int b;
 };
-constexpr Ints2 ints22; // both-error {{without a user-provided default 
constructor}} \
-// expected-error {{must be initialized by a constant 
expression}}
+constexpr Ints2 ints22; // both-error {{without a user-provided default 
constructor}}
 
 constexpr Ints2 I2 = Ints2{12, 25};
 static_assert(I2.a == 12, "");
@@ -1409,3 +1408,15 @@ namespace VirtualBases {
 static_assert((X*)(Y1*)&z != (X*)(Y2*)&z, "");
   }
 }
+
+namespace ZeroInit {
+  struct S3 {
+S3() = default;
+S3(const S3&) = default;
+S3(S3&&) = default;
+constexpr S3(int n) : n(n) {}
+int n;
+  };
+  constexpr S3 s3d; // both-error {{default initialization of an object of 
const type 'const S3' without a user-provided default constructor}}
+  static_assert(s3d.n == 0, "");
+}



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


[clang] [clang] Use `cwg_index.html` from GitHub for DR status page (PR #90352)

2024-04-29 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

CI has been failing because of unrelated `Clang :: Driver/amdgpu-toolchain.c` 
test. I'm merging this as is.

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


[clang] 37f2928 - [clang] Use `cwg_index.html` from GitHub for DR status page (#90352)

2024-04-29 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-04-29T15:03:13+04:00
New Revision: 37f2928ce382603fdadd7bae87fa245ac65b7d4f

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

LOG: [clang] Use `cwg_index.html` from GitHub for DR status page (#90352)

Currently we're using official publication of CWG issue list available
at https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html.
Unfortunately, it's not updated as frequently as we sometimes need. For
instance, recently there was a confusion during review of CWG2149 test
(https://github.com/llvm/llvm-project/pull/90079#discussion_r1580174003).
This patch changes our `make_cxx_dr_status` script to use issue list
from CWG GitHub repository. I confirmed with CWG chair that this is the
most up-to-date source of information on CWG issues.

Changing the source of issue list uncovered previously unhandled
"tentatively ready" status of an issue. This status is considered
unresolved by the script (like `open`, `drafting`, and `review`), as the
resolution might change during face-to-face CWG meeting.

I also noticed that CWG decided to handle 2561 differently from what
we're doing, so this DR is now considered not available in Clang,
despite being declared as available since 18. CC @cor3ntin.

This patch also brings new issues into our DR list, so if someone was
waiting for a newly-filed issue to appear on our status page, it should
appear with this PR.

Added: 


Modified: 
clang/test/CXX/drs/cwg2149.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/CXX/drs/dr21xx.cpp
clang/test/CXX/drs/dr24xx.cpp
clang/test/CXX/drs/dr25xx.cpp
clang/test/CXX/drs/dr28xx.cpp
clang/www/cxx_dr_status.html
clang/www/make_cxx_dr_status

Removed: 




diff  --git a/clang/test/CXX/drs/cwg2149.cpp b/clang/test/CXX/drs/cwg2149.cpp
index d0f8cb2dfc0a93..8416e42cbd6970 100644
--- a/clang/test/CXX/drs/cwg2149.cpp
+++ b/clang/test/CXX/drs/cwg2149.cpp
@@ -11,7 +11,7 @@
 // cxx98-error@-1 {{variadic macros are a C99 feature}}
 #endif
 
-namespace cwg2149 { // cwg2149: 3.1 drafting 2024-04
+namespace cwg2149 { // cwg2149: 3.1
 #if __cplusplus <= 201103L
 struct X { int i, j, k; };
 #else

diff  --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index 291a77e0cc71dd..9797097acce753 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -90,7 +90,7 @@ namespace cwg2026 { // cwg2026: 11
   }
 }
 
-namespace cwg2049 { // cwg2049: 18 drafting P2308R1
+namespace cwg2049 { // cwg2049: 18
 #if __cplusplus >= 202302L
 template  struct X {};
 X<> a;

diff  --git a/clang/test/CXX/drs/dr21xx.cpp b/clang/test/CXX/drs/dr21xx.cpp
index 4fab10c279aa43..082deb42e4fa09 100644
--- a/clang/test/CXX/drs/dr21xx.cpp
+++ b/clang/test/CXX/drs/dr21xx.cpp
@@ -175,6 +175,8 @@ void foo() {
 }
 }
 
+// cwg2149 is in cwg2149.cpp
+
 namespace cwg2157 { // cwg2157: 11
 #if __cplusplus >= 201103L
   enum E : int;

diff  --git a/clang/test/CXX/drs/dr24xx.cpp b/clang/test/CXX/drs/dr24xx.cpp
index 5ffaebda68c132..9f876cd8708347 100644
--- a/clang/test/CXX/drs/dr24xx.cpp
+++ b/clang/test/CXX/drs/dr24xx.cpp
@@ -45,7 +45,7 @@ void fallthrough(int n) {
 #endif
 }
 
-namespace cwg2450 { // cwg2450: 18 review P2308R1
+namespace cwg2450 { // cwg2450: 18
 #if __cplusplus >= 202302L
 struct S {int a;};
 template 
@@ -59,7 +59,7 @@ f<{.a= 0}>();
 #endif
 }
 
-namespace cwg2459 { // cwg2459: 18 drafting P2308R1
+namespace cwg2459 { // cwg2459: 18
 #if __cplusplus >= 202302L
 struct A {
   constexpr A(float) {}

diff  --git a/clang/test/CXX/drs/dr25xx.cpp b/clang/test/CXX/drs/dr25xx.cpp
index 62b2a0a088cc13..481ae09cdb77ea 100644
--- a/clang/test/CXX/drs/dr25xx.cpp
+++ b/clang/test/CXX/drs/dr25xx.cpp
@@ -130,12 +130,14 @@ struct D3 : B {
 #endif
 
 #if __cplusplus >= 202302L
-namespace cwg2561 { // cwg2561: 18 review 2023-11-09
+namespace cwg2561 { // cwg2561: no
 struct C {
 constexpr C(auto) { }
 };
 void foo() {
 constexpr auto b = [](this C) { return 1; };
+// FIXME: closure type shouldn't have a conversion function to function
+//pointer, because explicit object parameter is present. 
 constexpr int (*fp)(C) = b;
 static_assert(fp(1) == 1);
 static_assert((&decltype(b)::operator())(1) == 1);

diff  --git a/clang/test/CXX/drs/dr28xx.cpp b/clang/test/CXX/drs/dr28xx.cpp
index 4d9b0c76758d53..1967e8b751db2d 100644
--- a/clang/test/CXX/drs/dr28xx.cpp
+++ b/clang/test/CXX/drs/dr28xx.cpp
@@ -10,7 +10,7 @@
 // expected-no-diagnostics
 #endif
 
-namespace cwg2847 { // cwg2847: 19
+namespace cwg2847 { // cwg2847: 19 review 2024-03-01
 
 #if __cplusplus >= 202002L
 

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index ea8872c91be604..19d29cb55d6ed0 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/w

[clang] [clang] Use `cwg_index.html` from GitHub for DR status page (PR #90352)

2024-04-29 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

https://github.com/llvm/llvm-project/pull/90352 has been merged.

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


[clang] [llvm] [AArch64] Add support for Cortex-R82AE and improve Cortex-R82 (PR #90440)

2024-04-29 Thread Jack Styles via cfe-commits

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


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


[clang] [clang] Handle trivial_abi attribute for Microsoft ABI. (PR #88857)

2024-04-29 Thread Tobias Hieta via cfe-commits

tru wrote:

ping on this.


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


[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor on libTooling tutorial (NFC) (PR #70427)

2024-04-29 Thread Kohei Asano via cfe-commits

https://github.com/khei4 updated https://github.com/llvm/llvm-project/pull/70427

>From 12e29c46366e93c98c96e7561258bc83f66755c1 Mon Sep 17 00:00:00 2001
From: khei4 
Date: Fri, 27 Oct 2023 17:46:34 +0900
Subject: [PATCH 1/2] use create instead of protected Constructor

---
 clang/docs/LibTooling.rst | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index df50dcebf9b83c..8ef59da67417ba 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -63,15 +63,22 @@ and automatic location of the compilation database using 
source files paths.
   #include "llvm/Support/CommandLine.h"
 
   using namespace clang::tooling;
+  using namespace llvm;
 
   // Apply a custom category to all command-line options so that they are the
   // only ones displayed.
-  static llvm::cl::OptionCategory MyToolCategory("my-tool options");
+  static cl::OptionCategory MyToolCategory("my-tool options");
 
   int main(int argc, const char **argv) {
-// CommonOptionsParser constructor will parse arguments and create a
-// CompilationDatabase.  In case of error it will terminate the program.
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+// CommonOptionsParser::create will parse arguments and create a
+// CompilationDatabase. In case of error it will terminate the program.
+auto ExpectedParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
+if (!ExpectedParser) {
+  // Fail gracefully for unsupported options.
+  llvm::errs() << ExpectedParser.takeError();
+  return 1;
+}
+CommonOptionsParser& OptionsParser = ExpectedParser.get();
 
 // Use OptionsParser.getCompilations() and 
OptionsParser.getSourcePathList()
 // to retrieve CompilationDatabase and the list of input file paths.
@@ -133,7 +140,12 @@ version of this example tool is also checked into the 
clang tree at
   static cl::extrahelp MoreHelp("\nMore help text...\n");
 
   int main(int argc, const char **argv) {
-CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+auto ExpectedParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
+if (!ExpectedParser) {
+  llvm::errs() << ExpectedParser.takeError();
+  return 1;
+}
+CommonOptionsParser& OptionsParser = ExpectedParser.get();
 ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
 return Tool.run(newFrontendActionFactory().get());

>From 44b1b694f57eeb16cd6b9269bcb2177ce03c2b7c Mon Sep 17 00:00:00 2001
From: Kohei Asano <32860920+kh...@users.noreply.github.com>
Date: Mon, 29 Apr 2024 20:24:16 +0900
Subject: [PATCH 2/2] Update clang/docs/LibTooling.rst

Co-authored-by: Sirraide 
---
 clang/docs/LibTooling.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index 8ef59da67417ba..87d84321ab2830 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -71,7 +71,7 @@ and automatic location of the compilation database using 
source files paths.
 
   int main(int argc, const char **argv) {
 // CommonOptionsParser::create will parse arguments and create a
-// CompilationDatabase. In case of error it will terminate the program.
+// CompilationDatabase.
 auto ExpectedParser = CommonOptionsParser::create(argc, argv, 
MyToolCategory);
 if (!ExpectedParser) {
   // Fail gracefully for unsupported options.

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


[clang] [clang] Implement CWG2851: floating-point conversions in converted constant expressions (PR #90387)

2024-04-29 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok updated 
https://github.com/llvm/llvm-project/pull/90387

>From 0b8176cf2171da0ce780c15131e19a24473a6989 Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Sun, 28 Apr 2024 09:48:47 +0100
Subject: [PATCH] [clang] Implement CWG2851: floating-point conversions in
 converted constant expressions

---
 clang/docs/ReleaseNotes.rst   |  3 +
 .../clang/Basic/DiagnosticSemaKinds.td|  4 ++
 clang/lib/Sema/SemaOverload.cpp   | 38 ++-
 clang/test/CXX/drs/dr28xx.cpp | 64 +++
 clang/www/cxx_dr_status.html  |  2 +-
 5 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 604782ca43dd54..6fb0b2d1030be8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -166,6 +166,9 @@ Resolutions to C++ Defect Reports
 - Clang now diagnoses declarative nested-name-specifiers with 
pack-index-specifiers.
   (`CWG2858: Declarative nested-name-specifiers and pack-index-specifiers 
`_).
 
+- Allow floating-point promotions and conversions in converted constant 
expressions.
+  (`CWG2851 Allow floating-point conversions in converted constant expressions 
`_).
+
 C Language Changes
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fdca82934cb4dc..cb248f2ea6374b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -85,6 +85,10 @@ def err_expr_not_cce : Error<
   "%select{case value|enumerator value|non-type template argument|"
   "array size|explicit specifier argument|noexcept specifier argument|"
   "call to 'size()'|call to 'data()'}0 is not a constant expression">;
+def err_float_conv_cant_represent : Error<
+  "non-type template argument evaluates to %0 which cannot be "
+  "exactly represented in type %1"
+>;
 def ext_cce_narrowing : ExtWarn<
   "%select{case value|enumerator value|non-type template argument|"
   "array size|explicit specifier argument|noexcept specifier argument|"
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 04cd9e78739d20..40d65638e3afc1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6072,6 +6072,10 @@ static bool CheckConvertedConstantConversions(Sema &S,
   case ICK_Integral_Promotion:
   case ICK_Integral_Conversion: // Narrowing conversions are checked elsewhere.
   case ICK_Zero_Queue_Conversion:
+  // Per CWG2851, floating-point promotions and conversions are allowed.
+  // The value of a conversion is checked afterwards.
+  case ICK_Floating_Promotion:
+  case ICK_Floating_Conversion:
 return true;
 
   case ICK_Boolean_Conversion:
@@ -6091,9 +6095,7 @@ static bool CheckConvertedConstantConversions(Sema &S,
 // only permitted if the source type is std::nullptr_t.
 return SCS.getFromType()->isNullPtrType();
 
-  case ICK_Floating_Promotion:
   case ICK_Complex_Promotion:
-  case ICK_Floating_Conversion:
   case ICK_Complex_Conversion:
   case ICK_Floating_Integral:
   case ICK_Compatible_Conversion:
@@ -6229,7 +6231,37 @@ static ExprResult BuildConvertedConstantExpression(Sema 
&S, Expr *From,
   if (Result.isInvalid())
 return Result;
 
-  // Check for a narrowing implicit conversion.
+  if (SCS->Second == ICK_Floating_Conversion) {
+// Unlike with narrowing conversions, the value must fit
+// exactly even if it is in range
+assert(CCE == Sema::CCEKind::CCEK_TemplateArg &&
+   "Only non-type template args should use floating-point 
conversions");
+
+// Initializer is From, except it is a full-expression
+const Expr *Initializer =
+IgnoreNarrowingConversion(S.Context, Result.get());
+
+// If it's value-dependent, we can't tell whether it will fit
+if (Initializer->isValueDependent())
+  return Result;
+
+// Not-constant diagnosed afterwards
+if (!Initializer->isCXX11ConstantExpr(S.Context, &PreNarrowingValue))
+  return Result;
+
+llvm::APFloat PostNarrowingValue = PreNarrowingValue.getFloat();
+bool LosesInfo = true;
+PostNarrowingValue.convert(S.Context.getFloatTypeSemantics(T),
+   llvm::APFloat::rmNearestTiesToEven, &LosesInfo);
+
+if (LosesInfo)
+  S.Diag(From->getBeginLoc(), diag::err_float_conv_cant_represent)
+  << PreNarrowingValue.getAsString(S.Context, From->getType()) << T;
+
+return Result;
+  }
+
+  // Check for a narrowing integer conversion.
   bool ReturnPreNarrowingValue = false;
   QualType PreNarrowingType;
   switch (SCS->getNarrowingKind(S.Context, Result.get(), PreNarrowingValue,
diff --git a/clang/test/CXX/drs/dr28xx.cpp b/clang/test/CXX/drs/dr28xx.cpp
index 1967e8b751db2d..e0a180a1df27f3 100644
--- a/clan

[clang] [Clang][Docs] use CommonOptionsParser::create instead of protected constructor on libTooling tutorial (NFC) (PR #70427)

2024-04-29 Thread via cfe-commits

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


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


[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)

2024-04-29 Thread via cfe-commits

cor3ntin wrote:

> I agree with you -- having a well-described diagnostic message is better and 
> clearer. I'm happy to improve it once we settle on the final implementation 
> approach (the current diagnostic because '__is_deducible(AFoo, Foo)' 
> evaluated to false seems okay to me. GCC also emits similar diagnostics).

Well, if we agree on that, the only thing to do for approach 3 is to deal with 
"anonymous" traits in ast dump and similar, which seems to be a fairly bounded 
effort!

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


[clang] [Clang] Add support for scalable vectors in __builtin_reduce_* functions (PR #87750)

2024-04-29 Thread Lawrence Benson via cfe-commits

https://github.com/lawben updated 
https://github.com/llvm/llvm-project/pull/87750

>From a56d6eacc7053a0dac38c5b7ba21d2e37a790baa Mon Sep 17 00:00:00 2001
From: Lawrence Benson 
Date: Fri, 5 Apr 2024 09:15:30 +0200
Subject: [PATCH 1/2] [AARCH64,RISCV] Add support for scalable vectors in
 __builtin_reduce* functions.

---
 clang/include/clang/AST/Type.h   |  4 ++
 clang/lib/AST/Type.cpp   | 12 +
 clang/lib/CodeGen/CGBuiltin.cpp  | 10 +++-
 clang/lib/Sema/SemaChecking.cpp  | 23 +++--
 clang/test/CodeGen/builtins-reduction-math.c | 53 
 5 files changed, 96 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 99f45d518c7960..a9f888a037109b 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2172,6 +2172,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   /// 'riscv_rvv_vector_bits' type attribute as VectorType.
   QualType getRVVEltType(const ASTContext &Ctx) const;
 
+  /// Returns the representative type for the element of a sizeless vector
+  /// builtin type.
+  QualType getSizelessVectorEltType(const ASTContext &Ctx) const;
+
   /// Types are partitioned into 3 broad categories (C99 6.2.5p1):
   /// object types, function types, and incomplete types.
 
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index cb22c91a12aa89..dcba47de0cc7ae 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2510,6 +2510,18 @@ bool Type::isSveVLSBuiltinType() const {
   return false;
 }
 
+QualType Type::getSizelessVectorEltType(const ASTContext &Ctx) const {
+  assert(isSizelessVectorType() && "Must be sizeless vector type");
+  // Currently supports SVE and RVV
+  if (isSVESizelessBuiltinType())
+return getSveEltType(Ctx);
+
+  if (isRVVSizelessBuiltinType())
+return getRVVEltType(Ctx);
+
+  llvm_unreachable("Unhandled type");
+}
+
 QualType Type::getSveEltType(const ASTContext &Ctx) const {
   assert(isSveVLSBuiltinType() && "unsupported type!");
 
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2537e715b63ee4..e76a211242fdd7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3868,9 +3868,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   }
 
   case Builtin::BI__builtin_reduce_max: {
-auto GetIntrinsicID = [](QualType QT) {
+auto GetIntrinsicID = [this](QualType QT) {
   if (auto *VecTy = QT->getAs())
 QT = VecTy->getElementType();
+  else if (QT->isSizelessVectorType())
+QT = QT->getSizelessVectorEltType(CGM.getContext());
+
   if (QT->isSignedIntegerType())
 return llvm::Intrinsic::vector_reduce_smax;
   if (QT->isUnsignedIntegerType())
@@ -3883,9 +3886,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   }
 
   case Builtin::BI__builtin_reduce_min: {
-auto GetIntrinsicID = [](QualType QT) {
+auto GetIntrinsicID = [this](QualType QT) {
   if (auto *VecTy = QT->getAs())
 QT = VecTy->getElementType();
+  else if (QT->isSizelessVectorType())
+QT = QT->getSizelessVectorEltType(CGM.getContext());
+
   if (QT->isSignedIntegerType())
 return llvm::Intrinsic::vector_reduce_smin;
   if (QT->isUnsignedIntegerType())
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 3dcd18b3afc8b4..6d45dd8bb7ed97 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3166,13 +3166,20 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 
 const Expr *Arg = TheCall->getArg(0);
 const auto *TyA = Arg->getType()->getAs();
-if (!TyA) {
+
+QualType ElTy;
+if (TyA)
+  ElTy = TyA->getElementType();
+else if (Arg->getType()->isSizelessVectorType())
+  ElTy = Arg->getType()->getSizelessVectorEltType(Context);
+
+if (ElTy.isNull()) {
   Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
   << 1 << /* vector ty*/ 4 << Arg->getType();
   return ExprError();
 }
 
-TheCall->setType(TyA->getElementType());
+TheCall->setType(ElTy);
 break;
   }
 
@@ -3188,12 +3195,20 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 
 const Expr *Arg = TheCall->getArg(0);
 const auto *TyA = Arg->getType()->getAs();
-if (!TyA || !TyA->getElementType()->isIntegerType()) {
+
+QualType ElTy;
+if (TyA)
+  ElTy = TyA->getElementType();
+else if (Arg->getType()->isSizelessVectorType())
+  ElTy = Arg->getType()->getSizelessVectorEltType(Context);
+
+if (ElTy.isNull() || !ElTy->isIntegerType()) {
   Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
   << 1  << /* vector of integers */ 6 << Arg->getType();
   return ExprError();
 }
-TheCall->setTyp

[clang] [clang] fix(85447): clang 18.1.0 crashes in clang::ASTContext::getTypeInfoImpl (PR #89850)

2024-04-29 Thread via cfe-commits

cor3ntin wrote:

Can you add a changelog entry indicating the issue fixed?

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


[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)

2024-04-29 Thread via cfe-commits

cor3ntin wrote:

> @cor3ntin There already was a FIXME to consider moving this check to where 
> the call operator is first instantiated; should I look into that as well or 
> is it fine to leave this here? Asking because I’m assuming there’s a reason 
> why it wasn’t done that way.

If you can do it easily, you should!
I don't remember the details sadly, It's been over a year!

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


[clang] [clang][CodeGen] fix UB in aarch64 bfloat16 scalar conversion (PR #89062)

2024-04-29 Thread via cfe-commits

nihui wrote:

> LGTM, thanks.

And please merge this fix for me, I have no commit access  :)

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


[clang] [Clang][Sema] Fix a bug on template partial specialization with issue on deduction of nontype template parameter (PR #90376)

2024-04-29 Thread via cfe-commits

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


[clang] [Clang][Sema] Fix a bug on template partial specialization with issue on deduction of nontype template parameter (PR #90376)

2024-04-29 Thread via cfe-commits

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


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


[clang] [clang] Fix crash when destructor definition is preceded with '=' (PR #90220)

2024-04-29 Thread via cfe-commits


@@ -3893,9 +3893,12 @@ namespace {
 }
 
 void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) {
-  if (E->getTemporary()->getDestructor()->isTrivial()) {
-Inherited::VisitStmt(E);
-return;
+  if (const CXXDestructorDecl *DtorDecl =
+  E->getTemporary()->getDestructor()) {
+if (DtorDecl->isTrivial()) {
+  Inherited::VisitStmt(E);
+  return;
+}

cor3ntin wrote:

I think I'm happy with doing it it here, but it would be helpful to add a 
comment.
If someone has a better idea and want to inspects all places where 
CXXBindTemporaryExpr is created, we can do that in a subsequent PR.

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


[clang] cb3174b - [clang][CodeGen] fix UB in aarch64 bfloat16 scalar conversion (#89062)

2024-04-29 Thread via cfe-commits

Author: nihui
Date: 2024-04-29T13:18:37+01:00
New Revision: cb3174bd7895535d2f397695b5b20b1e90876997

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

LOG: [clang][CodeGen] fix UB in aarch64 bfloat16 scalar conversion (#89062)

do not bitcast 16bit `bfloat16` to 32bit `int32_t` directly
bitcast to `int16_t`, and then upcast to `int32_t`

Fix ASAN runtime error when calling vcvtah_f32_bf16
`==21842==ERROR: AddressSanitizer: stack-buffer-overflow on address
0x007fda1dd063 at pc 0x005c0361c234 bp 0x007fda1dd030 sp 0x007fda1dd028
`

without patch
```c
__ai __attribute__((target("bf16"))) float32_t vcvtah_f32_bf16(bfloat16_t __p0) 
{
  float32_t __ret;
bfloat16_t __reint = __p0;
int32_t __reint1 = *(int32_t *) &__reint << 16;
  __ret = *(float32_t *) &__reint1;
  return __ret;
}
```

with this patch
```c
__ai __attribute__((target("bf16"))) float32_t vcvtah_f32_bf16(bfloat16_t __p0) 
{
  float32_t __ret;
bfloat16_t __reint = __p0;
int32_t __reint1 = (int32_t)(*(int16_t *) &__reint) << 16;
  __ret = *(float32_t *) &__reint1;
  return __ret;
}
```

fix issue https://github.com/llvm/llvm-project/issues/61983

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/test/CodeGen/arm-bf16-convert-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 6d655c39360d3b..6390ba3f9fe5e5 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -275,7 +275,7 @@ def OP_VCVT_BF16_F32_HI_A32
(call "vget_low", $p0))>;
 
 def OP_CVT_F32_BF16
-: Op<(bitcast "R", (op "<<", (bitcast "int32_t", $p0),
+: Op<(bitcast "R", (op "<<", (cast "int32_t", (bitcast "int16_t", $p0)),
  (literal "int32_t", "16")))>;
 
 
//===--===//

diff  --git a/clang/test/CodeGen/arm-bf16-convert-intrinsics.c 
b/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
index f50eaf371028cd..0f2c5b2546fa35 100644
--- a/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
+++ b/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
@@ -426,11 +426,12 @@ bfloat16_t test_vcvth_bf16_f32(float32_t a) {
 // CHECK-NEXT:[[__REINT_I:%.*]] = alloca bfloat, align 2
 // CHECK-NEXT:[[__REINT1_I:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store bfloat [[A:%.*]], ptr [[__REINT_I]], align 2
-// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[__REINT_I]], align 2
-// CHECK-NEXT:[[SHL_I:%.*]] = shl i32 [[TMP1]], 16
+// CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr [[__REINT_I]], align 2
+// CHECK-NEXT:[[CONV_I:%.*]] = sext i16 [[TMP0]] to i32
+// CHECK-NEXT:[[SHL_I:%.*]] = shl i32 [[CONV_I]], 16
 // CHECK-NEXT:store i32 [[SHL_I]], ptr [[__REINT1_I]], align 4
-// CHECK-NEXT:[[TMP3:%.*]] = load float, ptr [[__REINT1_I]], align 4
-// CHECK-NEXT:ret float [[TMP3]]
+// CHECK-NEXT:[[TMP1:%.*]] = load float, ptr [[__REINT1_I]], align 4
+// CHECK-NEXT:ret float [[TMP1]]
 //
 float32_t test_vcvtah_f32_bf16(bfloat16_t a) {
   return vcvtah_f32_bf16(a);



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


[clang] [clang][CodeGen] fix UB in aarch64 bfloat16 scalar conversion (PR #89062)

2024-04-29 Thread via cfe-commits

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


[clang] [clang] Fix crash when destructor definition is preceded with '=' (PR #90220)

2024-04-29 Thread via cfe-commits


@@ -3893,9 +3893,12 @@ namespace {
 }
 
 void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) {
-  if (E->getTemporary()->getDestructor()->isTrivial()) {
-Inherited::VisitStmt(E);
-return;
+  if (const CXXDestructorDecl *DtorDecl =
+  E->getTemporary()->getDestructor()) {
+if (DtorDecl->isTrivial()) {
+  Inherited::VisitStmt(E);
+  return;
+}

Sirraide wrote:

In addition to adding a comment here, thoughts about adding one to 
`CXXTemporary` to indicate that the destructor can be null? Because at least 
the comment above `CXXBindTemporaryExpr` makes it sound like that isn’t really 
supposed to be the case.

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


[clang] 959d98c - [clang][Interp][NFC] Fix a typo

2024-04-29 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-29T14:24:14+02:00
New Revision: 959d98c05ecacf79bbe78bc83e6dd99a3d58cab2

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

LOG: [clang][Interp][NFC] Fix a typo

Added: 


Modified: 
clang/lib/AST/Interp/Disasm.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index 01cc88ea9a8459..ccdc96a79436da 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -200,7 +200,7 @@ LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream 
&OS) const {
 OS << " primitive";
 
   if (isZeroSizeArray())
-OS << " zero-size-arrary";
+OS << " zero-size-array";
   else if (isUnknownSizeArray())
 OS << " unknown-size-array";
 



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


  1   2   3   4   5   >