[clang-tools-extra] [clangd] forward clang-tidy's readability-identifier-naming fix to textDocument/rename (PR #78454)

2024-01-31 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> Duplicate issue: 
> [clangd/clangd#741](https://github.com/clangd/clangd/issues/741)

Nice find, I closed it as a duplicate.

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


[llvm] [clang] `llvm-cov` assertion failure when handling MC/DC that involves macros (PR #80098)

2024-01-31 Thread Wentao Zhang via cfe-commits


@@ -1973,6 +1981,8 @@ struct CounterCoverageMappingBuilder
   void VisitBinLAnd(const BinaryOperator *E) {
 bool IsRootNode = MCDCBuilder.isIdle();
 
+MCDCDebugCounter++;

whentojump wrote:

Hi thanks again for taking the look!
My intuition was to make the ID different whenever a new decision region is 
going to be added by calling `createDecisionRegion()`. There might be something 
obvious that I ignored.
And after reading some of the other posts (I'm still learning most of them, 
please bear with that!), I generally agree with the approaches whose 
modifications are minimized within `llvm-cov`, instead of touching the front 
end.

Regards

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


[clang] [clang] Represent array refs as `TemplateArgument::Declaration` (PR #80050)

2024-01-31 Thread Jeremiah Rodriguez via cfe-commits

jeremiahar wrote:

This also avoids regressing https://github.com/llvm/llvm-project/issues/79957 
(I cherrypicked this commit and compiled the test case locally)

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


[llvm] [flang] [clang] [mlir] [compiler-rt] [clang-tools-extra] [mlir][tosa] Add dialect version. (PR #79514)

2024-01-31 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph requested changes to this pull request.

This lack some information to me:

- What is the purpose of this?
- What kind of compatibility is this supposed to provide?
- What is the versioning scheme?

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


[clang] d71831a - [NFC] [clang-repl] Fix test failures due to incosistent target settings

2024-01-31 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2024-01-31T16:05:15+08:00
New Revision: d71831a2172e4cf7c3f3540c472ce2aeb14d4505

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

LOG: [NFC] [clang-repl] Fix test failures due to incosistent target settings

See https://github.com/llvm/llvm-project/pull/79261 for details.

It shows that clang-repl uses a different target triple with clang so that it
may be problematic if the calng-repl reads the generated BMI from clang
in a different target triple.

While the underlying issue is not easy to fix, this patch tries to make
this test green to not bother developers.

Added: 


Modified: 
clang/test/Interpreter/cxx20-modules.cppm

Removed: 




diff  --git a/clang/test/Interpreter/cxx20-modules.cppm 
b/clang/test/Interpreter/cxx20-modules.cppm
index 2c6eba5255191..cd2b04fdc547d 100644
--- a/clang/test/Interpreter/cxx20-modules.cppm
+++ b/clang/test/Interpreter/cxx20-modules.cppm
@@ -6,13 +6,13 @@
 // RUN: split-file %s %t
 //
 // RUN: %clang -std=c++20 %t/mod.cppm --precompile \
-// RUN: -o %t/mod.pcm
-// RUN: %clang %t/mod.pcm -c -o %t/mod.o
-// RUN: %clang -shared %t/mod.o -o %t/libmod.so
+// RUN: -o %t/mod.pcm --target=x86_64-linux-gnu
+// RUN: %clang %t/mod.pcm -c -o %t/mod.o --target=x86_64-linux-gnu
+// RUN: %clang -shared %t/mod.o -o %t/libmod.so --target=x86_64-linux-gnu
 //
 // RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH \
 // RUN: clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=%t/mod.pcm \
-// RUN: | FileCheck %t/import.cpp
+// RUN: -Xcc=--target=x86_64-linux-gnu | FileCheck %t/import.cpp
 
 //--- mod.cppm
 export module M;



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


[clang-tools-extra] [pseudo] remove most of clang-pseudo (PR #80081)

2024-01-31 Thread Haojian Wu via cfe-commits

hokein wrote:

We have some internal usages of the library. To make the integration life 
easier, I think it is better to do an internal cleanup first, and then land 
this patch.

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


[clang] [C++20] [Modules] Introduce reduced BMI (PR #75894)

2024-01-31 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

@iains would you like to take a look on this. I feel OK to not land this in 18 
but I think it is really important to land this in 19. Although it is still 
early to that, there are other works to do (e.g., the next patch and more 
testing). So it may be better to start it earlier.

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


[clang] [clang][Interp] Handle complex values in visitBool() (PR #79452)

2024-01-31 Thread Timm Baeder via cfe-commits

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

>From d4364d84bff990a241904cdf6644afac9b304923 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 25 Jan 2024 15:20:52 +0100
Subject: [PATCH] [clang][Interp] Handle complex values in visitBool()

In C++, we get a ComplexToBool cast, but we might not in C.
---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp | 115 +--
 clang/lib/AST/Interp/ByteCodeExprGen.h   |   1 +
 clang/test/AST/Interp/c.c|   4 +
 clang/test/AST/Interp/complex.cpp|   2 +
 4 files changed, 72 insertions(+), 50 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 8188d6f7f5c24..962a192b1dd09 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -231,57 +231,11 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
 
   case CK_IntegralComplexToBoolean:
   case CK_FloatingComplexToBoolean: {
-PrimType ElemT = classifyComplexElementType(SubExpr->getType());
-// We emit the expression (__real(E) != 0 || __imag(E) != 0)
-// for us, that means (bool)E[0] || (bool)E[1]
+if (DiscardResult)
+  return this->discard(SubExpr);
 if (!this->visit(SubExpr))
   return false;
-if (!this->emitConstUint8(0, CE))
-  return false;
-if (!this->emitArrayElemPtrUint8(CE))
-  return false;
-if (!this->emitLoadPop(ElemT, CE))
-  return false;
-if (ElemT == PT_Float) {
-  if (!this->emitCastFloatingIntegral(PT_Bool, CE))
-return false;
-} else {
-  if (!this->emitCast(ElemT, PT_Bool, CE))
-return false;
-}
-
-// We now have the bool value of E[0] on the stack.
-LabelTy LabelTrue = this->getLabel();
-if (!this->jumpTrue(LabelTrue))
-  return false;
-
-if (!this->emitConstUint8(1, CE))
-  return false;
-if (!this->emitArrayElemPtrPopUint8(CE))
-  return false;
-if (!this->emitLoadPop(ElemT, CE))
-  return false;
-if (ElemT == PT_Float) {
-  if (!this->emitCastFloatingIntegral(PT_Bool, CE))
-return false;
-} else {
-  if (!this->emitCast(ElemT, PT_Bool, CE))
-return false;
-}
-// Leave the boolean value of E[1] on the stack.
-LabelTy EndLabel = this->getLabel();
-this->jump(EndLabel);
-
-this->emitLabel(LabelTrue);
-if (!this->emitPopPtr(CE))
-  return false;
-if (!this->emitConstBool(true, CE))
-  return false;
-
-this->fallthrough(EndLabel);
-this->emitLabel(EndLabel);
-
-return true;
+return this->emitComplexBoolCast(SubExpr);
   }
 
   case CK_IntegralComplexToReal:
@@ -1912,8 +1866,15 @@ bool ByteCodeExprGen::visitInitializer(const 
Expr *E) {
 template 
 bool ByteCodeExprGen::visitBool(const Expr *E) {
   std::optional T = classify(E->getType());
-  if (!T)
+  if (!T) {
+// Convert complex values to bool.
+if (E->getType()->isAnyComplexType()) {
+  if (!this->visit(E))
+return false;
+  return this->emitComplexBoolCast(E);
+}
 return false;
+  }
 
   if (!this->visit(E))
 return false;
@@ -3003,6 +2964,60 @@ bool ByteCodeExprGen::emitComplexReal(const 
Expr *SubExpr) {
   return true;
 }
 
+template 
+bool ByteCodeExprGen::emitComplexBoolCast(const Expr *E) {
+  assert(!DiscardResult);
+  PrimType ElemT = classifyComplexElementType(E->getType());
+  // We emit the expression (__real(E) != 0 || __imag(E) != 0)
+  // for us, that means (bool)E[0] || (bool)E[1]
+  if (!this->emitConstUint8(0, E))
+return false;
+  if (!this->emitArrayElemPtrUint8(E))
+return false;
+  if (!this->emitLoadPop(ElemT, E))
+return false;
+  if (ElemT == PT_Float) {
+if (!this->emitCastFloatingIntegral(PT_Bool, E))
+  return false;
+  } else {
+if (!this->emitCast(ElemT, PT_Bool, E))
+  return false;
+  }
+
+  // We now have the bool value of E[0] on the stack.
+  LabelTy LabelTrue = this->getLabel();
+  if (!this->jumpTrue(LabelTrue))
+return false;
+
+  if (!this->emitConstUint8(1, E))
+return false;
+  if (!this->emitArrayElemPtrPopUint8(E))
+return false;
+  if (!this->emitLoadPop(ElemT, E))
+return false;
+  if (ElemT == PT_Float) {
+if (!this->emitCastFloatingIntegral(PT_Bool, E))
+  return false;
+  } else {
+if (!this->emitCast(ElemT, PT_Bool, E))
+  return false;
+  }
+  // Leave the boolean value of E[1] on the stack.
+  LabelTy EndLabel = this->getLabel();
+  this->jump(EndLabel);
+
+  this->emitLabel(LabelTrue);
+  if (!this->emitPopPtr(E))
+return false;
+  if (!this->emitConstBool(true, E))
+return false;
+
+  this->fallthrough(EndLabel);
+  this->emitLabel(EndLabel);
+
+  return true;
+}
+
 /// When calling this, we have a pointer of the local-to-destroy
 /// on the stack.
 /// Emit destruction of record types (or arrays of record types).
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/

[llvm] [libcxx] [lld] [libc] [compiler-rt] [lldb] [clang] [clang-tools-extra] [flang] [concepts] Push a CurContext before substituting into out-of-line constraints for comparison (PR #79985)

2024-01-31 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

I plan to backport this patch and #79698 to clang 18 a few days later to see if 
we're actually not breaking anything.

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


[clang] 64a849a - [clang][Interp] Support arbitrary precision constants (#79747)

2024-01-31 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-01-31T10:00:42+01:00
New Revision: 64a849a52e08827e889be22ed3ceafe62cd03793

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

LOG: [clang][Interp] Support arbitrary precision constants (#79747)

Add (de)serialization support for them, like we do for Floating values.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeEmitter.cpp
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/Disasm.cpp
clang/lib/AST/Interp/IntegralAP.h
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Opcodes.td
clang/test/AST/Interp/intap.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index fd2a92d9d3f91..409ce21506caa 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -10,6 +10,7 @@
 #include "ByteCodeGenError.h"
 #include "Context.h"
 #include "Floating.h"
+#include "IntegralAP.h"
 #include "Opcode.h"
 #include "Program.h"
 #include "clang/AST/ASTLambda.h"
@@ -209,9 +210,11 @@ static void emit(Program &P, std::vector &Code, 
const T &Val,
   }
 }
 
-template <>
-void emit(Program &P, std::vector &Code, const Floating &Val,
-  bool &Success) {
+/// Emits a serializable value. These usually (potentially) contain
+/// heap-allocated memory and aren't trivially copyable.
+template 
+static void emitSerialized(std::vector &Code, const T &Val,
+   bool &Success) {
   size_t Size = Val.bytesToSerialize();
 
   if (Code.size() + Size > std::numeric_limits::max()) {
@@ -228,6 +231,24 @@ void emit(Program &P, std::vector &Code, const 
Floating &Val,
   Val.serialize(Code.data() + ValPos);
 }
 
+template <>
+void emit(Program &P, std::vector &Code, const Floating &Val,
+  bool &Success) {
+  emitSerialized(Code, Val, Success);
+}
+
+template <>
+void emit(Program &P, std::vector &Code,
+  const IntegralAP &Val, bool &Success) {
+  emitSerialized(Code, Val, Success);
+}
+
+template <>
+void emit(Program &P, std::vector &Code, const IntegralAP 
&Val,
+  bool &Success) {
+  emitSerialized(Code, Val, Success);
+}
+
 template 
 bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &... Args, const SourceInfo 
&SI) {
   bool Success = true;

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 8188d6f7f5c24..386abef598594 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2204,15 +2204,13 @@ bool ByteCodeExprGen::emitConst(T Value, 
PrimType Ty, const Expr *E) {
 return this->emitConstSint64(Value, E);
   case PT_Uint64:
 return this->emitConstUint64(Value, E);
-  case PT_IntAP:
-  case PT_IntAPS:
-assert(false);
-return false;
   case PT_Bool:
 return this->emitConstBool(Value, E);
   case PT_Ptr:
   case PT_FnPtr:
   case PT_Float:
+  case PT_IntAP:
+  case PT_IntAPS:
 llvm_unreachable("Invalid integral type");
 break;
   }
@@ -2228,6 +2226,11 @@ bool ByteCodeExprGen::emitConst(T Value, const 
Expr *E) {
 template 
 bool ByteCodeExprGen::emitConst(const APSInt &Value, PrimType Ty,
  const Expr *E) {
+  if (Ty == PT_IntAPS)
+return this->emitConstIntAPS(Value, E);
+  if (Ty == PT_IntAP)
+return this->emitConstIntAP(Value, E);
+
   if (Value.isSigned())
 return this->emitConst(Value.getSExtValue(), Ty, E);
   return this->emitConst(Value.getZExtValue(), Ty, E);

diff  --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index d276df8f29262..eba437e05f59d 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -12,6 +12,7 @@
 
 #include "Floating.h"
 #include "Function.h"
+#include "IntegralAP.h"
 #include "Opcode.h"
 #include "PrimType.h"
 #include "Program.h"
@@ -37,6 +38,20 @@ template <> inline Floating ReadArg(Program &P, 
CodePtr &OpPC) {
   return F;
 }
 
+template <>
+inline IntegralAP ReadArg>(Program &P, CodePtr &OpPC) 
{
+  IntegralAP I = IntegralAP::deserialize(*OpPC);
+  OpPC += align(I.bytesToSerialize());
+  return I;
+}
+
+template <>
+inline IntegralAP ReadArg>(Program &P, CodePtr &OpPC) {
+  IntegralAP I = IntegralAP::deserialize(*OpPC);
+  OpPC += align(I.bytesToSerialize());
+  return I;
+}
+
 LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
 
 LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {

diff  --git a/clang/lib/AST/Interp/IntegralAP.h 
b/clang/lib/AST/Interp/IntegralAP.h
index 55e29caa1cd74..bab9774288bfa 100644
--- a/clang/lib/AST/Interp/IntegralAP.h
+++ b/clang/lib/AST/Interp/IntegralAP.h
@@ -263,6 +263,31 @@ template  class IntegralAP final {
   *R = IntegralAP(A.V.lshr(ShiftAmount

[clang] [clang][Interp] Support arbitrary precision constants (PR #79747)

2024-01-31 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


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


[clang] [clang][analyzer] Simplify code of StreamChecker (NFC). (PR #79312)

2024-01-31 Thread Balázs Kéri via cfe-commits

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

From 62dc7fdb2f86c81af501f7f1255a98d97ede303f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Wed, 24 Jan 2024 16:28:57 +0100
Subject: [PATCH 1/2] [clang][analyzer] Simplify code of StreamChecker (NFC).

Common parts of some "eval" functions are moved into one function.
The non-common parts of the "eval" functions are passed through
lambda parameters to the new function.
---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 438 +-
 1 file changed, 230 insertions(+), 208 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 07727b339d967..95e7e5d9f0912 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -400,6 +400,51 @@ class StreamChecker : public Checker;
+using GetSuccessStateFn = std::function;
+using GetFailureStateFn =
+std::function(
+SymbolRef, const CallExpr *, ASTContext &, SValBuilder &)>;
+
+EvalRWCommonFn(InitFn I, GetSuccessStateFn GSS, GetFailureStateFn GFS)
+: Init(I), GetSuccessState(GSS), GetFailureState(GFS) {}
+EvalRWCommonFn(GetSuccessStateFn GSS, GetFailureStateFn GFS)
+: Init([](SymbolRef, const CallExpr *, ASTContext &, SValBuilder &) {
+return nullptr;
+  }),
+  GetSuccessState(GSS), GetFailureState(GFS) {}
+
+// Called at start of the evaluation.
+// Should return 'nullptr' to continue evaluation, or a program state that
+// is added and evaluation stops here.
+// This is used to handle special cases when no success or failure state
+// is added.
+InitFn Init;
+// Create the state for the "success" case of the function and return it.
+// Can return 'nullptr' to not add a success state.
+GetSuccessStateFn GetSuccessState;
+// Create the state for the "failure" case of the function.
+// Return the state and the new stream error state (combination of possible
+// errors).
+GetFailureStateFn GetFailureState;
+  };
+
+  /// Common part of many eval functions in the checker.
+  /// This can be used for simple stream read and write functions.
+  /// This function handles full modeling of such functions, by passing a
+  /// 'GetSuccessState' and 'GetFailureState' function. These functions should
+  /// create the program state for the success and failure cases. 'IsRead'
+  /// indicates if the modeled function is a stream read or write operation.
+  /// If the evaluated function is a read operation and the stream is already
+  /// in EOF, the new error will always be EOF and no success state is added.
+  /// This case is handled here and 'GetFailureState' should not care about it.
+  void evalRWCommon(const FnDescription *Desc, const CallEvent &Call,
+CheckerContext &C, bool IsRead, EvalRWCommonFn Fn) const;
+
   /// Check that the stream (in StreamVal) is not NULL.
   /// If it can only be NULL a fatal error is emitted and nullptr returned.
   /// Otherwise the return value is a new state where the stream is constrained
@@ -726,225 +771,140 @@ void StreamChecker::preReadWrite(const FnDescription 
*Desc,
 void StreamChecker::evalFreadFwrite(const FnDescription *Desc,
 const CallEvent &Call, CheckerContext &C,
 bool IsFread) const {
-  ProgramStateRef State = C.getState();
-  SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol();
-  if (!StreamSym)
-return;
-
-  const CallExpr *CE = dyn_cast_or_null(Call.getOriginExpr());
-  if (!CE)
-return;
-
-  std::optional SizeVal = Call.getArgSVal(1).getAs();
-  if (!SizeVal)
-return;
-  std::optional NMembVal = Call.getArgSVal(2).getAs();
-  if (!NMembVal)
-return;
-
-  const StreamState *OldSS = State->get(StreamSym);
-  if (!OldSS)
-return;
-
-  assertStreamStateOpened(OldSS);
-
-  // C'99 standard, §7.19.8.1.3, the return value of fread:
-  // The fread function returns the number of elements successfully read, which
-  // may be less than nmemb if a read error or end-of-file is encountered. If
-  // size or nmemb is zero, fread returns zero and the contents of the array 
and
-  // the state of the stream remain unchanged.
-
-  if (State->isNull(*SizeVal).isConstrainedTrue() ||
-  State->isNull(*NMembVal).isConstrainedTrue()) {
-// This is the "size or nmemb is zero" case.
-// Just return 0, do nothing more (not clear the error flags).
-State = bindInt(0, State, C, CE);
-C.addTransition(State);
-return;
-  }
-
-  // Generate a transition for the success state.
-  // If we know the state to be FEOF at fread, do not add a success state.
-  if (!IsFread || (OldSS->ErrorState != ErrorFEof)) {
-ProgramStateRef StateNotFailed =
-State->BindExpr(CE, C.getLocationContext(), *NMembVal);
-   

[clang] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token (PR #80101)

2024-01-31 Thread Owen Pan via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/80101

>From f3ad3ceebba663615e75b5a6fc8969f4a98a03ea Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 30 Jan 2024 19:11:30 -0800
Subject: [PATCH 1/2] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to
 Token

So that it can be used by clang-format.
---
 clang/include/clang/Lex/Token.h |  3 +++
 clang/include/clang/Sema/Sema.h |  2 --
 clang/lib/Lex/Lexer.cpp | 45 +
 clang/lib/Parse/ParseExpr.cpp   |  2 +-
 clang/lib/Parse/ParseObjc.cpp   |  2 +-
 clang/lib/Sema/SemaDecl.cpp | 45 -
 6 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/clang/include/clang/Lex/Token.h b/clang/include/clang/Lex/Token.h
index 1409e2c58b550..0a9c73d120de2 100644
--- a/clang/include/clang/Lex/Token.h
+++ b/clang/include/clang/Lex/Token.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LEX_TOKEN_H
 #define LLVM_CLANG_LEX_TOKEN_H
 
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -288,6 +289,8 @@ class Token {
   /// Return the ObjC keyword kind.
   tok::ObjCKeywordKind getObjCKeywordID() const;
 
+  bool isSimpleTypeSpecifier(const LangOptions &LangOpts) const;
+
   /// Return true if this token has trigraphs or escaped newlines in it.
   bool needsCleaning() const { return getFlag(NeedsCleaning); }
 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 490df817ddfa2..3b42850a7a85a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2683,8 +2683,6 @@ class Sema final {
 
   void DiagnoseUseOfUnimplementedSelectors();
 
-  bool isSimpleTypeSpecifier(const Token &Tok) const;
-
   ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc,
  Scope *S, CXXScopeSpec *SS = nullptr,
  bool isClassName = false, bool HasTrailingDot = false,
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 50b56265f6e16..d927f28b47c27 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -74,6 +74,51 @@ tok::ObjCKeywordKind Token::getObjCKeywordID() const {
   return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword;
 }
 
+/// Determine whether the token kind starts a simple-type-specifier.
+bool Token::isSimpleTypeSpecifier(const LangOptions &LangOpts) const {
+  switch (getKind()) {
+  case tok::annot_typename:
+  case tok::annot_decltype:
+  case tok::annot_pack_indexing_type:
+return true;
+
+  case tok::kw_short:
+  case tok::kw_long:
+  case tok::kw___int64:
+  case tok::kw___int128:
+  case tok::kw_signed:
+  case tok::kw_unsigned:
+  case tok::kw_void:
+  case tok::kw_char:
+  case tok::kw_int:
+  case tok::kw_half:
+  case tok::kw_float:
+  case tok::kw_double:
+  case tok::kw___bf16:
+  case tok::kw__Float16:
+  case tok::kw___float128:
+  case tok::kw___ibm128:
+  case tok::kw_wchar_t:
+  case tok::kw_bool:
+  case tok::kw__Bool:
+  case tok::kw__Accum:
+  case tok::kw__Fract:
+  case tok::kw__Sat:
+#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
+#include "clang/Basic/TransformTypeTraits.def"
+  case tok::kw___auto_type:
+  case tok::kw_char16_t:
+  case tok::kw_char32_t:
+  case tok::kw_typeof:
+  case tok::kw_decltype:
+  case tok::kw_char8_t:
+return getIdentifierInfo()->isKeyword(LangOpts);
+
+  default:
+return false;
+  }
+}
+
 
//===--===//
 // Lexer Class Implementation
 
//===--===//
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index e5d4285b99183..52cebdb6f64ba 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1609,7 +1609,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   if (TryAnnotateTypeOrScopeToken())
 return ExprError();
 
-  if (!Actions.isSimpleTypeSpecifier(Tok))
+  if (!Tok.isSimpleTypeSpecifier(getLangOpts()))
 // We are trying to parse a simple-type-specifier but might not get 
such
 // a token after error recovery.
 return ExprError();
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 4771b69eadb34..88bab0eb27a3e 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -2971,7 +2971,7 @@ bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, 
void *&TypeOrExpr) {
   tok::annot_cxxscope))
 TryAnnotateTypeOrScopeToken();
 
-  if (!Actions.isSimpleTypeSpecifier(Tok)) {
+  if (!Tok.isSimpleTypeSpecifier(getLangOpts())) {
 //   objc-receiver:
 // expression
 // Make sure any typos in the receiver are corrected or diagnosed, so that
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 00c750e4

[clang] [clang][analyzer] Add note tags to alpha.unix.BlockInCriticalSection (PR #80029)

2024-01-31 Thread Endre Fülöp via cfe-commits

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

From f7875a7f1ff20f3cf850ce1c23bec6d6c3d88d57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Endre=20F=C3=BCl=C3=B6p?= 
Date: Tue, 30 Jan 2024 11:33:30 +0100
Subject: [PATCH] [clang][analyzer] Add note tags to
 alpha.unix.BlockInCriticalSection checker

On entering a critical section, a note tag is now placed along the
bugpath.
---
 .../BlockInCriticalSectionChecker.cpp | 18 -
 .../Analysis/block-in-critical-section.cpp| 77 ++-
 2 files changed, 75 insertions(+), 20 deletions(-)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
index 66e080adb1382..1297ae96c8b64 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
@@ -57,6 +57,8 @@ class BlockInCriticalSectionChecker : public 
Checker {
 const CallEvent &call,
 CheckerContext &C) const;
 
+  const NoteTag *createCriticalSectionNote(CheckerContext &C) const;
+
 public:
   bool isBlockingFunction(const CallEvent &Call) const;
   bool isLockFunction(const CallEvent &Call) const;
@@ -126,8 +128,9 @@ void BlockInCriticalSectionChecker::checkPostCall(const 
CallEvent &Call,
 State = State->set(--mutexCount);
 C.addTransition(State);
   } else if (isLockFunction(Call)) {
+const NoteTag *Note = createCriticalSectionNote(C);
 State = State->set(++mutexCount);
-C.addTransition(State);
+C.addTransition(State, Note);
   } else if (mutexCount > 0) {
 SymbolRef BlockDesc = Call.getReturnValue().getAsSymbol();
 reportBlockInCritSection(BlockDesc, Call, C);
@@ -151,10 +154,21 @@ void 
BlockInCriticalSectionChecker::reportBlockInCritSection(
   C.emitReport(std::move(R));
 }
 
+const NoteTag *BlockInCriticalSectionChecker::createCriticalSectionNote(
+CheckerContext &C) const {
+  const BugType *BT = &this->BlockInCritSectionBugType;
+  return C.getNoteTag([BT](PathSensitiveBugReport &BR, llvm::raw_ostream &OS) {
+if (&BR.getBugType() != BT)
+  return;
+OS << "Entering critical section here";
+  });
+}
+
 void ento::registerBlockInCriticalSectionChecker(CheckerManager &mgr) {
   mgr.registerChecker();
 }
 
-bool ento::shouldRegisterBlockInCriticalSectionChecker(const CheckerManager 
&mgr) {
+bool ento::shouldRegisterBlockInCriticalSectionChecker(
+const CheckerManager &mgr) {
   return true;
 }
diff --git a/clang/test/Analysis/block-in-critical-section.cpp 
b/clang/test/Analysis/block-in-critical-section.cpp
index fcf6188fc033e..93d46c741e16f 100644
--- a/clang/test/Analysis/block-in-critical-section.cpp
+++ b/clang/test/Analysis/block-in-critical-section.cpp
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.BlockInCriticalSection 
-std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 \
+// RUN:   -analyzer-checker=alpha.unix.BlockInCriticalSection \
+// RUN:   -std=c++11 \
+// RUN:   -analyzer-output text \
+// RUN:   -verify %s
 
 void sleep(int x) {}
 
@@ -21,7 +25,7 @@ template
 struct not_real_lock {
   not_real_lock(std::mutex) {}
 };
-}
+} // namespace std
 
 void getc() {}
 void fgets() {}
@@ -39,81 +43,115 @@ void mtx_unlock() {}
 
 void testBlockInCriticalSectionWithStdMutex() {
   std::mutex m;
-  m.lock();
+  m.lock(); // expected-note 5{{Entering critical section here}}
   sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of 
critical section}}
+// expected-note@-1 {{Call to blocking function 'sleep' inside of 
critical section}}
   getc(); // expected-warning {{Call to blocking function 'getc' inside of 
critical section}}
+  // expected-note@-1 {{Call to blocking function 'getc' inside of 
critical section}}
   fgets(); // expected-warning {{Call to blocking function 'fgets' inside of 
critical section}}
+   // expected-note@-1 {{Call to blocking function 'fgets' inside of 
critical section}}
   read(); // expected-warning {{Call to blocking function 'read' inside of 
critical section}}
+  // expected-note@-1 {{Call to blocking function 'read' inside of 
critical section}}
   recv(); // expected-warning {{Call to blocking function 'recv' inside of 
critical section}}
+  // expected-note@-1 {{Call to blocking function 'recv' inside of 
critical section}}
   m.unlock();
 }
 
 void testBlockInCriticalSectionWithPthreadMutex() {
-  pthread_mutex_lock();
+  pthread_mutex_lock(); // expected-note 10{{Entering critical section here}}
   sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of 
critical section}}
+// expected-note@-1 {{Call to blocking function 'sleep' inside of 
critical section}}
   getc(); // expected-warning {{Call to blocking function 'getc' inside of 
critical section}}
+  // expected-note@-1 {

[flang] [libc] [clang] [libcxxabi] [lld] [mlir] [lldb] [compiler-rt] [openmp] [clang-tools-extra] [llvm] [libcxx] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-31 Thread Oleksandr Alex Zinenko via cfe-commits

ftynse wrote:

Looks like whatever Windows container it runs on is missing a numpy 
installation. Not correlated with this patch in any way.

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


[mlir] [lld] [openmp] [llvm] [compiler-rt] [libcxx] [clang] [flang] [libc] [lldb] [libcxxabi] [clang-tools-extra] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-31 Thread Oleksandr Alex Zinenko via cfe-commits

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


[clang] [clang][ASTImporter] fix assert fail due to offset overflow (PR #79084)

2024-01-31 Thread Balázs Kéri via cfe-commits


@@ -9896,9 +9903,13 @@ Expected ASTImporter::Import(FileID FromID, bool 
IsBuiltin) {
 // FIXME: The filename may be a virtual name that does probably not
 // point to a valid file and we get no Entry here. In this case try 
with
 // the memory buffer below.
-if (Entry)
+if (Entry) {
+  if (isBufferSizeOverflow(ToSM, Entry->getSize()))
+return llvm::make_error(
+ASTImportError::UnsupportedConstruct);

balazske wrote:

This error is clearly not an unsupported AST construct. For this case a new 
error type should be added like `ASTImportError::SourceLocationOverflow` or 
`ResourceOverflow`. Code in `CrossTranslationUnitContext::importDefinitionImpl` 
should be updated to count this new error.
Alternatively the `llvm_unreachable` from `UnknownError` can be removed. But 
`UnknownError` should be used if something happens that is not supposed to 
happen, even if now it is used like "other error".

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


[clang] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token (PR #80101)

2024-01-31 Thread via cfe-commits

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


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


[clang] [mlir] [llvm] [X86] Stop custom-widening v2f32 = fpext v2bf16 (PR #80106)

2024-01-31 Thread via cfe-commits

https://github.com/yubingex007-a11y updated 
https://github.com/llvm/llvm-project/pull/80106

>From 447998dfa2a5cde2b2e08c1b6f6a3503a2c3fcce Mon Sep 17 00:00:00 2001
From: Bing1 Yu 
Date: Wed, 31 Jan 2024 14:20:31 +0800
Subject: [PATCH 1/2] [X86] Stop custom-widening v2f32 = fpext v2bf16

---
 llvm/lib/Target/X86/X86ISelLowering.cpp  |  5 ++-
 llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll | 41 
 2 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 531e00862558c..82753a74ba0dd 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -32815,10 +32815,11 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
 // No other ValueType for FP_EXTEND should reach this point.
 assert(N->getValueType(0) == MVT::v2f32 &&
"Do not know how to legalize this Node");
-if (!Subtarget.hasFP16() || !Subtarget.hasVLX())
-  return;
 bool IsStrict = N->isStrictFPOpcode();
 SDValue Src = N->getOperand(IsStrict ? 1 : 0);
+if (!Subtarget.hasFP16() || !Subtarget.hasVLX() ||
+Src.getValueType().getVectorElementType() != MVT::f16)
+  return;
 SDValue Ext = IsStrict ? DAG.getConstantFP(0.0, dl, MVT::v2f16)
: DAG.getUNDEF(MVT::v2f16);
 SDValue V = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v4f16, Src, Ext);
diff --git a/llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll 
b/llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll
new file mode 100644
index 0..d56bb62d22f06
--- /dev/null
+++ b/llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll
@@ -0,0 +1,41 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-- -mattr=avx512bf16,avx512fp16  | 
FileCheck %s
+define dso_local void @calc_matrix_tdpbf16ps(<2 x ptr> %ptr) 
local_unnamed_addr #0 {
+; CHECK-LABEL: calc_matrix_tdpbf16ps:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xorl %eax, %eax
+; CHECK-NEXT:testb %al, %al
+; CHECK-NEXT:je .LBB0_1
+; CHECK-NEXT:  # %bb.2: # %loop.127.preheader
+; CHECK-NEXT:retq
+; CHECK-NEXT:  .LBB0_1: # %ifmerge.89
+; CHECK-NEXT:movzwl (%rax), %eax
+; CHECK-NEXT:shll $16, %eax
+; CHECK-NEXT:vmovd %eax, %xmm0
+; CHECK-NEXT:vmulss %xmm0, %xmm0, %xmm0
+; CHECK-NEXT:vbroadcastss %xmm0, %xmm0
+; CHECK-NEXT:vmovlps %xmm0, (%rax)
+entry:
+  br label %then.13
+
+then.13:  ; preds = %entry
+  %0 = fpext bfloat poison to float
+  br i1 poison, label %loop.127.preheader, label %ifmerge.89
+
+ifmerge.89:   ; preds = %then.13
+  %.splatinsert144 = insertelement <2 x float> poison, float %0, i64 0
+  %.splat145 = shufflevector <2 x float> %.splatinsert144, <2 x float> poison, 
<2 x i32> zeroinitializer
+  %1 = tail call <2 x bfloat> @llvm.masked.gather.v2bf16.v2p0(<2 x ptr> undef, 
i32 2, <2 x i1> , <2 x bfloat> poison)
+  %2 = fpext <2 x bfloat> %1 to <2 x float>
+  %3 = fmul fast <2 x float> %.splat145, %2
+  %4 = fadd fast <2 x float> zeroinitializer, %3
+  store <2 x float> %4, ptr poison, align 4
+  unreachable
+
+loop.127.preheader:   ; preds = %then.13
+  ret void
+}
+
+; Function Attrs: nocallback nofree nosync nounwind willreturn memory(read)
+declare <2 x bfloat> @llvm.masked.gather.v2bf16.v2p0(<2 x ptr>, i32 immarg, <2 
x i1>, <2 x bfloat>) #1
+

>From e52d3bdd48c511634cf9c42d8e6a31d338c09ec4 Mon Sep 17 00:00:00 2001
From: Bing1 Yu 
Date: Wed, 31 Jan 2024 15:53:22 +0800
Subject: [PATCH 2/2] address comments

---
 llvm/lib/Target/X86/X86ISelLowering.cpp  | 3 +--
 llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll | 9 -
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 82753a74ba0dd..483fa01861f7c 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -32817,8 +32817,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
"Do not know how to legalize this Node");
 bool IsStrict = N->isStrictFPOpcode();
 SDValue Src = N->getOperand(IsStrict ? 1 : 0);
-if (!Subtarget.hasFP16() || !Subtarget.hasVLX() ||
-Src.getValueType().getVectorElementType() != MVT::f16)
+if (Src.getValueType().getVectorElementType() != MVT::f16)
   return;
 SDValue Ext = IsStrict ? DAG.getConstantFP(0.0, dl, MVT::v2f16)
: DAG.getUNDEF(MVT::v2f16);
diff --git a/llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll 
b/llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll
index d56bb62d22f06..eff1937b59343 100644
--- a/llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll
+++ b/llvm/test/CodeGen/X86/concat-fpext-v2bf16.ll
@@ -1,7 +1,8 @@
 ; NOTE: Assertions have been autogenerated by

[clang] Multilib support for libraries with exceptions (PR #75031)

2024-01-31 Thread via cfe-commits


@@ -264,6 +273,15 @@ ToolChain::getMultilibFlags(const llvm::opt::ArgList 
&Args) const {
 break;
   }
 
+  // Include fno-exceptions and fno-rtti
+  // to improve multilib selection
+  if (getRTTIMode() == ToolChain::RTTIMode::RM_Disabled) {
+Result.push_back("-fno-rtti");

amilendra wrote:

Thanks for the explanation. 

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-01-31 Thread via cfe-commits

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

LGTM from me.

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


[clang] Multilib support for libraries with exceptions (PR #75031)

2024-01-31 Thread via cfe-commits

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


[clang] [clang][Interp] Handle std::move etc. builtins (PR #70772)

2024-01-31 Thread Timm Baeder via cfe-commits

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

>From 8449070d0cec2ad120c9d8a36a72594d595b7fea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 31 Oct 2023 07:17:16 +0100
Subject: [PATCH] [clang][Interp] Handle std::move etc. builtins

---
 clang/lib/AST/Interp/ByteCodeExprGen.h  |  9 +--
 clang/lib/AST/Interp/Context.h  | 13 +++-
 clang/lib/AST/Interp/Interp.cpp |  2 +-
 clang/lib/AST/Interp/InterpBuiltin.cpp  | 22 +-
 clang/test/AST/Interp/functions.cpp | 89 +
 clang/test/SemaCXX/builtin-std-move.cpp |  6 +-
 6 files changed, 129 insertions(+), 12 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 893b75b028b6f..315169d487cd4 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -128,15 +128,8 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
   // If the function does not exist yet, it is compiled.
   const Function *getFunction(const FunctionDecl *FD);
 
-  /// Classifies a type.
   std::optional classify(const Expr *E) const {
-if (E->isGLValue()) {
-  if (E->getType()->isFunctionType())
-return PT_FnPtr;
-  return PT_Ptr;
-}
-
-return classify(E->getType());
+return Ctx.classify(E);
   }
   std::optional classify(QualType Ty) const {
 return Ctx.classify(Ty);
diff --git a/clang/lib/AST/Interp/Context.h b/clang/lib/AST/Interp/Context.h
index ab83a8d132246..c7620921e467e 100644
--- a/clang/lib/AST/Interp/Context.h
+++ b/clang/lib/AST/Interp/Context.h
@@ -70,9 +70,20 @@ class Context final {
   /// Return the size of T in bits.
   uint32_t getBitWidth(QualType T) const { return Ctx.getIntWidth(T); }
 
-  /// Classifies an expression.
+  /// Classifies a type.
   std::optional classify(QualType T) const;
 
+  /// Classifies an expression.
+  std::optional classify(const Expr *E) const {
+if (E->isGLValue()) {
+  if (E->getType()->isFunctionType())
+return PT_FnPtr;
+  return PT_Ptr;
+}
+
+return classify(E->getType());
+  }
+
   const CXXMethodDecl *
   getOverridingFunction(const CXXRecordDecl *DynamicDecl,
 const CXXRecordDecl *StaticDecl,
diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index be9ed81af69ec..4c3184aec9968 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -141,7 +141,7 @@ static bool CheckGlobal(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
 namespace clang {
 namespace interp {
 static void popArg(InterpState &S, const Expr *Arg) {
-  PrimType Ty = S.getContext().classify(Arg->getType()).value_or(PT_Ptr);
+  PrimType Ty = S.getContext().classify(Arg).value_or(PT_Ptr);
   TYPE_SWITCH(Ty, S.Stk.discard());
 }
 
diff --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index 754ca96b0c645..280aa39398c8e 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -634,12 +634,23 @@ static bool interp__builtin_addressof(InterpState &S, 
CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_move(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame, const Function 
*Func,
+ const CallExpr *Call) {
+
+  PrimType ArgT = S.getContext().classify(Call->getArg(0)).value_or(PT_Ptr);
+
+  TYPE_SWITCH(ArgT, const T &Arg = S.Stk.peek(); S.Stk.push(Arg););
+
+  return Func->getDecl()->isConstexpr();
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
   const CallExpr *Call) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
 
-  std::optional ReturnT = S.getContext().classify(Call->getType());
+  std::optional ReturnT = S.getContext().classify(Call);
 
   // If classify failed, we assume void.
   assert(ReturnT || Call->getType()->isVoidType());
@@ -848,6 +859,15 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
   return false;
 break;
 
+  case Builtin::BIas_const:
+  case Builtin::BIforward:
+  case Builtin::BIforward_like:
+  case Builtin::BImove:
+  case Builtin::BImove_if_noexcept:
+if (!interp__builtin_move(S, OpPC, Frame, F, Call))
+  return false;
+break;
+
   default:
 return false;
   }
diff --git a/clang/test/AST/Interp/functions.cpp 
b/clang/test/AST/Interp/functions.cpp
index 75f3c5d192b2c..6e995ce704e39 100644
--- a/clang/test/AST/Interp/functions.cpp
+++ b/clang/test/AST/Interp/functions.cpp
@@ -413,3 +413,92 @@ namespace AddressOf {
   constexpr _Complex float F = {3, 4};
   static_assert(__builtin_addressof(F) == &F, "");
 }
+
+namespace std {
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+template 
+constexpr typename std::remove_ref

[clang] [clang][analyzer] Add note tags to alpha.unix.BlockInCriticalSection (PR #80029)

2024-01-31 Thread via cfe-commits

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

LGTM.

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


[compiler-rt] [clang] [llvm] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

2024-01-31 Thread Freddy Ye via cfe-commits

FreddyLeaf wrote:

ping for review

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


[llvm] [clang-tools-extra] [clang] [GitHub][workflows] Add buildbot information comment to first merged PR from a new contributor (PR #78292)

2024-01-31 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/78292

>From 20822b4a2f8e228365c8fa912af18afc9956749e Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Tue, 16 Jan 2024 13:36:15 +
Subject: [PATCH 01/10] [GitHub][workflows] Add buildbot information comment to
 first merged PR from a new contributor

This change adds a comment to the first PR from a new contributor that is 
merged,
which tells them what to expect post merge from the build bots.

How they will be notified, where to ask questions, that you're more likely
to be reverted than in other projects, etc.

To do this, I have added a hidden HTML comment to the new contributor greeting 
comment.
This workflow will look for that to tell if the author of the PR was
a new contributor at the time they opened the merge.

It has to be done this way because as soon as the PR is merged, they are
by GitHub's definition no longer a new contributor and I suspect that
their author assocication will be "contributor" instead.

I cannot 100% confirm that without a whole lot of effort and probably breaking
GitHub's terms of service, but it's fairly cheap to work around anyway.

It seems rare / almost impossible to reopen a PR in llvm at least, but
in case it does happen the buildbot info comment has its own hidden
HTML comment. If we find this we will not post another copy of the
same information.

An example PR can be found here: 
https://github.com/DavidSpickett/llvm-project/pull/84
(exact text content subject to change)
---
 .github/workflows/merged-prs.yml| 36 +++
 llvm/utils/git/github-automation.py | 71 +
 2 files changed, 107 insertions(+)
 create mode 100644 .github/workflows/merged-prs.yml

diff --git a/.github/workflows/merged-prs.yml b/.github/workflows/merged-prs.yml
new file mode 100644
index 0..1b1503610dac1
--- /dev/null
+++ b/.github/workflows/merged-prs.yml
@@ -0,0 +1,36 @@
+name: "Add buildbot information to first PRs from new contributors"
+
+permissions:
+  contents: read
+
+on:
+  # It's safe to use pull_request_target here, because we aren't checking out
+  # code from the pull request branch.
+  # See 
https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
+  pull_request_target:
+types:
+  - closed
+
+jobs:
+  buildbot_comment:
+runs-on: ubuntu-latest
+permissions:
+  pull-requests: write
+if: >-
+  (github.repository == 'llvm/llvm-project') &&
+  (github.event.pull_request.merged == true)
+steps:
+  - name: Setup Automation Script
+run: |
+  curl -O -L --fail 
https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/github-automation.py
+  curl -O -L --fail 
https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/requirements.txt
+  chmod a+x github-automation.py
+  pip install -r requirements.txt
+
+  - name: Add Buildbot information comment
+run: |
+  ./github-automation.py \
+--token '${{ secrets.GITHUB_TOKEN }}' \
+pr-buildbot-information \
+--issue-number "${{ github.event.pull_request.number }}" \
+--author "${{ github.event.pull_request.user.login }}"
diff --git a/llvm/utils/git/github-automation.py 
b/llvm/utils/git/github-automation.py
index f78d91059ecd3..55659679536f4 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -208,6 +208,8 @@ def _get_curent_team(self) -> Optional[github.Team.Team]:
 
 
 class PRGreeter:
+COMMENT_TAG = "\n"
+
 def __init__(self, token: str, repo: str, pr_number: int):
 repo = github.Github(token).get_repo(repo)
 self.pr = repo.get_issue(pr_number).as_pull_request()
@@ -217,7 +219,9 @@ def run(self) -> bool:
 # by a user new to LLVM and/or GitHub itself.
 
 # This text is using Markdown formatting.
+
 comment = f"""\
+{PRGreeter.COMMENT_TAG}
 Thank you for submitting a Pull Request (PR) to the LLVM Project!
 
 This PR will be automatically labeled and the relevant teams will be
@@ -240,6 +244,64 @@ def run(self) -> bool:
 return True
 
 
+class PRBuildbotInformation:
+COMMENT_TAG = "\n"
+
+def __init__(self, token: str, repo: str, pr_number: int, author: str):
+repo = github.Github(token).get_repo(repo)
+self.pr = repo.get_issue(pr_number).as_pull_request()
+self.author = author
+
+def should_comment(self) -> bool:
+# As soon as a new contributor has a PR merged, they are no longer a 
new contributor.
+# We can tell that they were a new contributor previously because we 
would have
+# added a new contributor greeting comment when they opened the PR.
+found_greeting = False
+for comment in self.pr.as_issue().get_comments():
+if PRGreeter.COMMENT_TAG in comment.body:
+found_greeting = True
+elif 

[llvm] [clang] [clang-tools-extra] [GitHub][workflows] Add buildbot information comment to first merged PR from a new contributor (PR #78292)

2024-01-31 Thread Nikita Popov via cfe-commits

https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/78292

>From 20822b4a2f8e228365c8fa912af18afc9956749e Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Tue, 16 Jan 2024 13:36:15 +
Subject: [PATCH 01/10] [GitHub][workflows] Add buildbot information comment to
 first merged PR from a new contributor

This change adds a comment to the first PR from a new contributor that is 
merged,
which tells them what to expect post merge from the build bots.

How they will be notified, where to ask questions, that you're more likely
to be reverted than in other projects, etc.

To do this, I have added a hidden HTML comment to the new contributor greeting 
comment.
This workflow will look for that to tell if the author of the PR was
a new contributor at the time they opened the merge.

It has to be done this way because as soon as the PR is merged, they are
by GitHub's definition no longer a new contributor and I suspect that
their author assocication will be "contributor" instead.

I cannot 100% confirm that without a whole lot of effort and probably breaking
GitHub's terms of service, but it's fairly cheap to work around anyway.

It seems rare / almost impossible to reopen a PR in llvm at least, but
in case it does happen the buildbot info comment has its own hidden
HTML comment. If we find this we will not post another copy of the
same information.

An example PR can be found here: 
https://github.com/DavidSpickett/llvm-project/pull/84
(exact text content subject to change)
---
 .github/workflows/merged-prs.yml| 36 +++
 llvm/utils/git/github-automation.py | 71 +
 2 files changed, 107 insertions(+)
 create mode 100644 .github/workflows/merged-prs.yml

diff --git a/.github/workflows/merged-prs.yml b/.github/workflows/merged-prs.yml
new file mode 100644
index 0..1b1503610dac1
--- /dev/null
+++ b/.github/workflows/merged-prs.yml
@@ -0,0 +1,36 @@
+name: "Add buildbot information to first PRs from new contributors"
+
+permissions:
+  contents: read
+
+on:
+  # It's safe to use pull_request_target here, because we aren't checking out
+  # code from the pull request branch.
+  # See 
https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
+  pull_request_target:
+types:
+  - closed
+
+jobs:
+  buildbot_comment:
+runs-on: ubuntu-latest
+permissions:
+  pull-requests: write
+if: >-
+  (github.repository == 'llvm/llvm-project') &&
+  (github.event.pull_request.merged == true)
+steps:
+  - name: Setup Automation Script
+run: |
+  curl -O -L --fail 
https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/github-automation.py
+  curl -O -L --fail 
https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/requirements.txt
+  chmod a+x github-automation.py
+  pip install -r requirements.txt
+
+  - name: Add Buildbot information comment
+run: |
+  ./github-automation.py \
+--token '${{ secrets.GITHUB_TOKEN }}' \
+pr-buildbot-information \
+--issue-number "${{ github.event.pull_request.number }}" \
+--author "${{ github.event.pull_request.user.login }}"
diff --git a/llvm/utils/git/github-automation.py 
b/llvm/utils/git/github-automation.py
index f78d91059ecd3..55659679536f4 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -208,6 +208,8 @@ def _get_curent_team(self) -> Optional[github.Team.Team]:
 
 
 class PRGreeter:
+COMMENT_TAG = "\n"
+
 def __init__(self, token: str, repo: str, pr_number: int):
 repo = github.Github(token).get_repo(repo)
 self.pr = repo.get_issue(pr_number).as_pull_request()
@@ -217,7 +219,9 @@ def run(self) -> bool:
 # by a user new to LLVM and/or GitHub itself.
 
 # This text is using Markdown formatting.
+
 comment = f"""\
+{PRGreeter.COMMENT_TAG}
 Thank you for submitting a Pull Request (PR) to the LLVM Project!
 
 This PR will be automatically labeled and the relevant teams will be
@@ -240,6 +244,64 @@ def run(self) -> bool:
 return True
 
 
+class PRBuildbotInformation:
+COMMENT_TAG = "\n"
+
+def __init__(self, token: str, repo: str, pr_number: int, author: str):
+repo = github.Github(token).get_repo(repo)
+self.pr = repo.get_issue(pr_number).as_pull_request()
+self.author = author
+
+def should_comment(self) -> bool:
+# As soon as a new contributor has a PR merged, they are no longer a 
new contributor.
+# We can tell that they were a new contributor previously because we 
would have
+# added a new contributor greeting comment when they opened the PR.
+found_greeting = False
+for comment in self.pr.as_issue().get_comments():
+if PRGreeter.COMMENT_TAG in comment.body:
+found_greeting = True
+elif PRBuildbo

[llvm] [clang] [clang-tools-extra] [GitHub][workflows] Add buildbot information comment to first merged PR from a new contributor (PR #78292)

2024-01-31 Thread David Spickett via cfe-commits

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


[clang] [RISCV][Clang] Added builtin support for experimental Zimop extension (PR #79971)

2024-01-31 Thread Lyut Nersisyan via cfe-commits

https://github.com/ln8-8 updated https://github.com/llvm/llvm-project/pull/79971

>From a2a37921c83511796e051520c887092a3f58a3ba Mon Sep 17 00:00:00 2001
From: ln8-8 
Date: Tue, 30 Jan 2024 13:02:22 +0400
Subject: [PATCH 1/3] [RISCV][Clang] Added builtin support for experimental
 Zimop extension

This change adds builtin of mop.r.[n] and mop.rr.[n] instructions for Zimop 
extension based on 
https://github.com/riscv-non-isa/riscv-c-api-doc/blob/master/riscv-c-api.md.
---
 clang/include/clang/Basic/BuiltinsRISCV.def   |   7 ++
 clang/lib/CodeGen/CGBuiltin.cpp   |  14 +++
 clang/lib/Sema/SemaChecking.cpp   |   8 ++
 .../test/CodeGen/RISCV/rvb-intrinsics/zimop.c | 105 ++
 4 files changed, 134 insertions(+)
 create mode 100644 clang/test/CodeGen/RISCV/rvb-intrinsics/zimop.c

diff --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 1528b18c82ead..7e2dda21830c5 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -89,5 +89,12 @@ TARGET_BUILTIN(__builtin_riscv_sm3p1, "UiUi", "nc", "zksh")
 TARGET_BUILTIN(__builtin_riscv_ntl_load, "v.", "t", "zihintntl")
 TARGET_BUILTIN(__builtin_riscv_ntl_store, "v.", "t", "zihintntl")
 
+// Zimop extension
+TARGET_BUILTIN(__builtin_riscv_mopr_32, "UiUiUi", "nc", "experimental-zimop")
+TARGET_BUILTIN(__builtin_riscv_mopr_64, "UWiUWiUWi", "nc",
+"experimental-zimop,64bit")
+TARGET_BUILTIN(__builtin_riscv_moprr_32, "UiUiUiUi", "nc", 
"experimental-zimop")
+TARGET_BUILTIN(__builtin_riscv_moprr_64, "UWiUWiUWiUWi", "nc",
+ "experimental-zimop,64bit")
 #undef BUILTIN
 #undef TARGET_BUILTIN
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f3ab5ad7b08ec..28511f9e0beac 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -21189,6 +21189,10 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   case RISCV::BI__builtin_riscv_clmulh_64:
   case RISCV::BI__builtin_riscv_clmulr_32:
   case RISCV::BI__builtin_riscv_clmulr_64:
+  case RISCV::BI__builtin_riscv_mopr_32:
+  case RISCV::BI__builtin_riscv_mopr_64:
+  case RISCV::BI__builtin_riscv_moprr_32:
+  case RISCV::BI__builtin_riscv_moprr_64:
   case RISCV::BI__builtin_riscv_xperm4_32:
   case RISCV::BI__builtin_riscv_xperm4_64:
   case RISCV::BI__builtin_riscv_xperm8_32:
@@ -21237,6 +21241,16 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   ID = Intrinsic::riscv_clmulr;
   break;
 
+// Zimop
+case RISCV::BI__builtin_riscv_mopr_32:
+case RISCV::BI__builtin_riscv_mopr_64:
+  ID = Intrinsic::riscv_mopr;
+  break;
+case RISCV::BI__builtin_riscv_moprr_32:
+case RISCV::BI__builtin_riscv_moprr_64:
+  ID = Intrinsic::riscv_moprr;
+  break;
+
 // Zbkx
 case RISCV::BI__builtin_riscv_xperm8_32:
 case RISCV::BI__builtin_riscv_xperm8_64:
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 502b24bcdf8b4..c2702bec29dd7 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5588,6 +5588,14 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const 
TargetInfo &TI,
   // Check if rnum is in [0, 10]
   case RISCV::BI__builtin_riscv_aes64ks1i:
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 10);
+  // Check if n of mop.r.[n] is in [0, 31]
+  case RISCV::BI__builtin_riscv_mopr_32:
+  case RISCV::BI__builtin_riscv_mopr_64:
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, 31);
+  // Check if n of mop.rr.[n] is in [0, 7]
+  case RISCV::BI__builtin_riscv_moprr_32:
+  case RISCV::BI__builtin_riscv_moprr_64:
+return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
   // Check if value range for vxrm is in [0, 3]
   case RISCVVector::BI__builtin_rvv_vaaddu_vv:
   case RISCVVector::BI__builtin_rvv_vaaddu_vx:
diff --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/zimop.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/zimop.c
new file mode 100644
index 0..b4367e33bdc19
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/zimop.c
@@ -0,0 +1,105 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zimop 
-emit-llvm %s -o - \
+// RUN: -disable-O0-optnone | opt -S -passes=mem2reg \
+// RUN: | FileCheck %s  -check-prefix=RV32ZIMOP
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zimop 
-emit-llvm %s -o - \
+// RUN: -disable-O0-optnone | opt -S -passes=mem2reg \
+// RUN: | FileCheck %s  -check-prefix=RV64ZIMOP
+
+#include 
+
+#if __riscv_xlen == 64
+// RV64ZIMOP-LABEL: @mopr_0_64(
+// RV64ZIMOP-NEXT:  entry:
+// RV64ZIMOP-NEXT:[[TMP0:%.*]] = call i64 @llvm.riscv.mopr.i64(i64 
[[A:%.*]], i64 0)
+// RV64ZIMOP-NEXT:ret i64 [[TMP0]]
+//
+uint64_t mopr_0_64(uint64_t a) {
+  retur

[clang] [RISCV][Clang] Added builtin support for experimental Zimop extension (PR #79971)

2024-01-31 Thread Lyut Nersisyan via cfe-commits


@@ -89,5 +89,13 @@ TARGET_BUILTIN(__builtin_riscv_sm3p1, "UiUi", "nc", "zksh")
 TARGET_BUILTIN(__builtin_riscv_ntl_load, "v.", "t", "zihintntl")
 TARGET_BUILTIN(__builtin_riscv_ntl_store, "v.", "t", "zihintntl")
 
+// Zimop extension
+TARGET_BUILTIN(__builtin_riscv_mopr_32, "UiUiUi", "nc", "experimental-zimop")

ln8-8 wrote:

Added

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


[clang] [RISCV][Clang] Added builtin support for experimental Zimop extension (PR #79971)

2024-01-31 Thread Lyut Nersisyan via cfe-commits


@@ -21189,6 +21189,10 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   case RISCV::BI__builtin_riscv_clmulh_64:
   case RISCV::BI__builtin_riscv_clmulr_32:
   case RISCV::BI__builtin_riscv_clmulr_64:
+  case RISCV::BI__builtin_riscv_mopr_32:

ln8-8 wrote:

Changed


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


[clang] [compiler-rt] [Sanitizer] add signed-integer-wrap sanitizer (PR #80089)

2024-01-31 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> I tried running clang-format but the diff was huge and beyond just my changes.

https://clang.llvm.org/docs/ClangFormat.html#git-integration tells you how to 
narrow it down to just your changes. Once that's setup you can use the command 
from the comment the bot left.

Sometimes it will try to format too much, in which case it's fine to ignore it, 
but looking at what the bot reported here that's not the case.

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


[clang] [Clang][Sema] fix outline member function template with default align crash (PR #78400)

2024-01-31 Thread via cfe-commits

bgra8 wrote:

@jcsxky this patch introduced a regression. Please see the reproducer here: 
https://godbolt.org/z/rEfWP75Ta. It compiles before this change and fails at 
this change. It also compiles with gcc and clang-17.


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


[libcxxabi] [libcxx] [libc] [lld] [flang] [llvm] [clang] [lldb] [msan] Unpoison indirect outputs for userspace using memset for large operands (PR #79924)

2024-01-31 Thread Alexander Potapenko via cfe-commits


@@ -4552,16 +4552,22 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 }
 if (!ElemTy->isSized())
   return;
-Value *SizeVal =
-  IRB.CreateTypeSize(MS.IntptrTy, DL.getTypeStoreSize(ElemTy));
+auto Size = DL.getTypeStoreSize(ElemTy);
+Value *SizeVal = IRB.CreateTypeSize(MS.IntptrTy, Size);
 if (MS.CompileKernel) {
   IRB.CreateCall(MS.MsanInstrumentAsmStoreFn, {Operand, SizeVal});
 } else {
   // ElemTy, derived from elementtype(), does not encode the alignment of
   // the pointer. Conservatively assume that the shadow memory is 
unaligned.
+  // When Size is large, avoid StoreInst as it would expand to many
+  // instructions.
   auto [ShadowPtr, _] =
   getShadowOriginPtrUserspace(Operand, IRB, IRB.getInt8Ty(), Align(1));
-  IRB.CreateAlignedStore(getCleanShadow(ElemTy), ShadowPtr, Align(1));
+  if (Size <= 32)

ramosian-glider wrote:

Maybe some comment wouldn't hurt here to clarify this constant.

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


[clang] 0217d2e - [clang][AMDGPU] Remove trialing whitespace in doc

2024-01-31 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2024-01-31T10:29:48Z
New Revision: 0217d2e089afba8ca0713787521ba52a1056

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

LOG: [clang][AMDGPU] Remove trialing whitespace in doc

Added by f2a78e68eee53646327f71c475c7f18a28b7f576.

Wouldn't normally bother but it's showing up in some CI checks,
just want to reduce the noise.

Added: 


Modified: 
clang/docs/HIPSupport.rst

Removed: 




diff  --git a/clang/docs/HIPSupport.rst b/clang/docs/HIPSupport.rst
index 0c93d722ff14e..543c82cf90244 100644
--- a/clang/docs/HIPSupport.rst
+++ b/clang/docs/HIPSupport.rst
@@ -176,8 +176,8 @@ Predefined Macros
* - ``HIP_API_PER_THREAD_DEFAULT_STREAM``
  - Alias to ``__HIP_API_PER_THREAD_DEFAULT_STREAM__``. Deprecated.
 
-Note that some architecture specific AMDGPU macros will have default values 
when 
-used from the HIP host compilation. Other :doc:`AMDGPU macros ` 
+Note that some architecture specific AMDGPU macros will have default values 
when
+used from the HIP host compilation. Other :doc:`AMDGPU macros `
 like ``__AMDGCN_WAVEFRONT_SIZE__`` will default to 64 for example.
 
 Compilation Modes



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


[flang] [clang-tools-extra] [clang] [llvm] [compiler-rt] [llvm][AArch64] intrinsic to generate a ubfx instruction (PR #80103)

2024-01-31 Thread David Spickett via cfe-commits

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


[flang] [clang-tools-extra] [mlir] [libc] [lldb] [compiler-rt] [libcxx] [clang] [llvm] [OpenMP] atomic compare weak : Parser & AST support (PR #79475)

2024-01-31 Thread via cfe-commits

SunilKuravinakop wrote:

Can someone please merge these changes into master? Thank you.


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


[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)

2024-01-31 Thread Simon Pilgrim via cfe-commits


@@ -0,0 +1,332 @@
+; RUN: opt -vector-library=AMDLIBM -passes=inject-tli-mappings,loop-vectorize 
-S < %s | FileCheck %s
+
+; Test to verify that when math headers are built with
+; __FINITE_MATH_ONLY__ enabled, causing use of ___finite
+; function versions, vectorization can map these to vector versions.
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare float @__expf_finite(float) #0
+
+; CHECK-LABEL: @exp_f32
+; CHECK: <4 x float> @amd_vrs4_expf

RKSimon wrote:

I'm still not seeing cases where the vector width is varying depending on cpu 
abilities?

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


[llvm] [clang] [AArch64] Make Armv8.3-a extension set +pauth by default (PR #78027)

2024-01-31 Thread Anatoly Trosinenko via cfe-commits

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


[clang] [clang][analyzer] Add note tags to alpha.unix.BlockInCriticalSection (PR #80029)

2024-01-31 Thread Balázs Kéri via cfe-commits

balazske wrote:

I think we could get a note at the first `lock` call in this code, this 
behavior is not entirely correct:
```
void test() {
  std::mutex m;
  m.lock();
  m.unlock();
  m.lock();
  sleep(3);
  m.unlock();
}
```

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


[llvm] [clang] [AArch64] Make +pauth enabled in Armv8.3-a by default (PR #78027)

2024-01-31 Thread Anatoly Trosinenko via cfe-commits

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


[llvm] [clang] [AArch64] Make +pauth enabled in Armv8.3-a by default (PR #78027)

2024-01-31 Thread Anatoly Trosinenko via cfe-commits

atrosinenko wrote:

Ping.

A few notes:
* not setting `__ARM_FEATURE_PAUTH` in `getTargetDefinesARMV83A()` anymore (and 
thus relying on conditionally setting it in `getTargetDefines()`) makes the 
existing tests check that `HasPAuth` is set if v8.3+ architecture extension is 
requested
* in the Pointer Authentication section of `aarch64-target-features.c` test, 
one more test case is added (for the "negative" case `armv8.5-a+nopauth` that 
is supported now), other changes are to account for FEAT_PAUTH support and 
pac-ret being separate options and all four combinations are possible

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


[flang] [mlir] [clang-tools-extra] [libcxx] [clang] [llvm] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits

https://github.com/ayalz commented:

Thanks for following up on this!

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


[mlir] [flang] [clang-tools-extra] [libcxx] [clang] [llvm] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -9110,6 +9111,41 @@ void 
LoopVectorizationPlanner::adjustRecipesForReductions(
   continue;
 
 const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor();
+// Adjust AnyOf reductions; replace the reduction phi for the selected 
value
+// with a boolean reduction phi node to check if the condition is true in
+// any iteration. The final value is selected by the final
+// ComputeReductionResult.
+if (RecurrenceDescriptor::isAnyOfRecurrenceKind(
+RdxDesc.getRecurrenceKind())) {
+  auto *Select = cast(*find_if(PhiR->users(), [](VPUser *U) {
+return isa(U) ||
+   (isa(U) &&
+cast(U)->getUnderlyingInstr()->getOpcode() 
==
+Instruction::Select);
+  }));
+  VPValue *Cmp = Select->getOperand(0);
+  // If the compare is checking the reduction PHI node, adjust it to check
+  // the start value.
+  if (VPRecipeBase *CmpR = Cmp->getDefiningRecipe()) {
+for (unsigned I = 0; I != CmpR->getNumOperands(); ++I)
+  if (CmpR->getOperand(I) == PhiR)
+CmpR->setOperand(I, PhiR->getStartValue());
+  }
+  VPBuilder::InsertPointGuard Guard(Builder);
+  Builder.setInsertPoint(Select);
+
+  // If the true value of the select is the reduction phi, the new value is
+  // selected if the negated condition is true in any iteration.
+  if (Select->getOperand(1) == PhiR)
+Cmp = Builder.createNot(Cmp);

ayalz wrote:

As Mel pointed out, this case of "Red = cond ? PhiR : Other" where a single 
false cond suffices for the result to be Other, could be considered an `AllOf` 
reduction starting with true using createAnd() instead of createOr(), resulting 
in "AND(conds) ? Start : Other".

Negating cond swaps the operands and translates into the "Red = !cond ? Other : 
PhiR" form of an `AnyOf` reduction starting with false and using createOr(), 
where a single true !cond suffices for the result to be Other, resulting in 
"OR(!conds) ? Other : Start".

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


[flang] [mlir] [clang-tools-extra] [clang] [libcxx] [llvm] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -9110,6 +9111,41 @@ void 
LoopVectorizationPlanner::adjustRecipesForReductions(
   continue;
 
 const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor();
+// Adjust AnyOf reductions; replace the reduction phi for the selected 
value
+// with a boolean reduction phi node to check if the condition is true in
+// any iteration. The final value is selected by the final
+// ComputeReductionResult.
+if (RecurrenceDescriptor::isAnyOfRecurrenceKind(
+RdxDesc.getRecurrenceKind())) {
+  auto *Select = cast(*find_if(PhiR->users(), [](VPUser *U) {
+return isa(U) ||
+   (isa(U) &&
+cast(U)->getUnderlyingInstr()->getOpcode() 
==
+Instruction::Select);
+  }));

ayalz wrote:

nit: assert(Select && "a meaningful error message");

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


[clang] [libcxx] [clang-tools-extra] [mlir] [flang] [llvm] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits

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


[llvm] [mlir] [clang-tools-extra] [libcxx] [clang] [flang] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -1079,16 +1070,13 @@ Value *llvm::createAnyOfTargetReduction(IRBuilderBase 
&Builder, Value *Src,
 NewVal = SI->getTrueValue();
   }
 
-  // Create a splat vector with the new value and compare this to the vector
-  // we want to reduce.
-  ElementCount EC = cast(Src->getType())->getElementCount();
-  Value *Right = Builder.CreateVectorSplat(EC, InitVal);
-  Value *Cmp =
-  Builder.CreateCmp(CmpInst::ICMP_NE, Src, Right, "rdx.select.cmp");
-
   // If any predicate is true it means that we want to select the new value.
-  Cmp = Builder.CreateOrReduce(Cmp);
-  return Builder.CreateSelect(Cmp, NewVal, InitVal, "rdx.select");
+  Value *AnyOf =
+  Src->getType()->isVectorTy() ? Builder.CreateOrReduce(Src) : Src;
+  // The compares in the loop may yield poison, which propagates through the
+  // bitwise ORs. Freeze it here before the condition is used.
+  AnyOf = Builder.CreateFreeze(AnyOf);

ayalz wrote:

Further refactoring thought: the AnyOf boolean reduction completes with the 
CreateOrReduce(), and freezing it. Similar to a plain "result |= value[i]" OR 
reduction, on i1 values, where freezing may also be needed? The subsequent 
select deserves a separate recipe, which post-processes the result of the AnyOf 
reduction and also depends on the "IfAny" and "Else" (or "Start" and "Other") 
Live-In VP/Values directly, rather than looking for them here and now.

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


[libcxx] [llvm] [mlir] [clang-tools-extra] [clang] [flang] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -453,16 +453,17 @@ Value 
*VPInstruction::generateInstruction(VPTransformState &State,
 else if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RK)) {
   TrackingVH ReductionStartValue =
   RdxDesc.getRecurrenceStartValue();
-  ReducedPartRdx = createAnyOfOp(Builder, ReductionStartValue, RK,
- ReducedPartRdx, RdxPart);
+  ReducedPartRdx = Builder.CreateOr(ReducedPartRdx, RdxPart);

ayalz wrote:

Should `Op` be set to OR and treated by CreateBinOp() above?

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


[flang] [llvm] [libcxx] [mlir] [clang-tools-extra] [clang] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -453,16 +453,17 @@ Value 
*VPInstruction::generateInstruction(VPTransformState &State,
 else if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RK)) {
   TrackingVH ReductionStartValue =
   RdxDesc.getRecurrenceStartValue();
-  ReducedPartRdx = createAnyOfOp(Builder, ReductionStartValue, RK,
- ReducedPartRdx, RdxPart);
+  ReducedPartRdx = Builder.CreateOr(ReducedPartRdx, RdxPart);
 } else
   ReducedPartRdx = createMinMaxOp(Builder, RK, ReducedPartRdx, 
RdxPart);
   }
 }
 
 // Create the reduction after the loop. Note that inloop reductions create
 // the target reduction in the loop using a Reduction recipe.
-if (State.VF.isVector() && !PhiR->isInLoop()) {
+if ((State.VF.isVector() ||
+ RecurrenceDescriptor::isAnyOfRecurrenceKind(RK)) &&
+!PhiR->isInLoop()) {
   ReducedPartRdx =
   createTargetReduction(Builder, RdxDesc, ReducedPartRdx, OrigPhi);

ayalz wrote:

As raised above, it may be better to have ComputeReductionResult recipe take 
care only of reducing AnyOf to a boolean here, followed by a Select recipe to 
chose between Start and Other live-in values.

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


[libcxx] [mlir] [flang] [llvm] [clang] [clang-tools-extra] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -9142,7 +9178,9 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
 // then extend the loop exit value to enable InstCombine to evaluate the
 // entire expression in the smaller type.
 Type *PhiTy = PhiR->getStartValue()->getLiveInIRValue()->getType();
-if (MinVF.isVector() && PhiTy != RdxDesc.getRecurrenceType()) {
+if (MinVF.isVector() && PhiTy != RdxDesc.getRecurrenceType() &&
+!RecurrenceDescriptor::isAnyOfRecurrenceKind(
+RdxDesc.getRecurrenceKind())) {

ayalz wrote:

Would be it better to truncate AnyOf reductions to smaller type (boolean) here 
instead of above?

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


[mlir] [libcxx] [clang] [flang] [clang-tools-extra] [llvm] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -7486,7 +7486,8 @@ static void createAndCollectMergePhiForReduction(
   auto *PhiR = cast(RedResult->getOperand(0));
   const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor();
 
-  TrackingVH ReductionStartValue = RdxDesc.getRecurrenceStartValue();
+  TrackingVH ReductionStartValue =

ayalz wrote:

Is ReductionStartValue still used, after inlining it below? Why/is this change 
needed?

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


[llvm] [clang-tools-extra] [flang] [mlir] [libcxx] [clang] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -9110,6 +9111,41 @@ void 
LoopVectorizationPlanner::adjustRecipesForReductions(
   continue;
 
 const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor();
+// Adjust AnyOf reductions; replace the reduction phi for the selected 
value
+// with a boolean reduction phi node to check if the condition is true in
+// any iteration. The final value is selected by the final
+// ComputeReductionResult.
+if (RecurrenceDescriptor::isAnyOfRecurrenceKind(
+RdxDesc.getRecurrenceKind())) {
+  auto *Select = cast(*find_if(PhiR->users(), [](VPUser *U) {
+return isa(U) ||
+   (isa(U) &&
+cast(U)->getUnderlyingInstr()->getOpcode() 
==
+Instruction::Select);
+  }));
+  VPValue *Cmp = Select->getOperand(0);
+  // If the compare is checking the reduction PHI node, adjust it to check
+  // the start value.

ayalz wrote:

Hmm, either the true or false values of the select should use PhiR, but only 
it? The condition of an AnyOf reduction should be any boolean-expression 
predicate that depends on the current iteration only, i.e., should be a recipe 
(if it's live-in the entire select should be LICM'd), independent of AnyOf's 
PhiR, neither directly nor indirectly?

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


[clang] [clang-tools-extra] [flang] [mlir] [libcxx] [llvm] [LV] Improve AnyOf reduction codegen. (PR #78304)

2024-01-31 Thread via cfe-commits


@@ -9110,6 +9111,41 @@ void 
LoopVectorizationPlanner::adjustRecipesForReductions(
   continue;
 
 const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor();
+// Adjust AnyOf reductions; replace the reduction phi for the selected 
value

ayalz wrote:

adjustRecipesForReductions() is getting excessively long, should be refactored. 
Its documentation above should (also) include the adjustment of AnyOf 
reductions described here.

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


[clang] [clang] Only set the trailing bytes to zero when filling a partially … (PR #79502)

2024-01-31 Thread via cfe-commits


@@ -1209,8 +1301,21 @@ static void emitStoresForConstant(CodeGenModule &CGM, 
const VarDecl &D,
   // If the initializer is all or mostly the same, codegen with bzero / memset
   // then do a few stores afterward.
   if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
-auto *I = Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0),
-   SizeVal, isVolatile);
+size_t LeadingNonNullBytes =
+CountLeadingNonNullBytes(CGM.getDataLayout(), constant);

serge-sans-paille wrote:

I agree, what about the updated version then?

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


[clang] a74e9ce - [OpenMP] atomic compare weak : Parser & AST support (#79475)

2024-01-31 Thread via cfe-commits

Author: SunilKuravinakop
Date: 2024-01-31T06:32:06-05:00
New Revision: a74e9ce5dc5cc746bd625b0ef20524a90a073375

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

LOG: [OpenMP] atomic compare weak : Parser & AST support (#79475)

This is a support for " #pragma omp atomic compare weak". It has Parser
& AST support for now.

-

Authored-by: Sunil Kuravinakop 

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/tools/libclang/CIndex.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 924ca189381ba..325a1baa44614 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2513,6 +2513,46 @@ class OMPRelaxedClause final : public OMPClause {
   }
 };
 
+/// This represents 'weak' clause in the '#pragma omp atomic'
+/// directives.
+///
+/// \code
+/// #pragma omp atomic compare weak
+/// \endcode
+/// In this example directive '#pragma omp atomic' has 'weak' clause.
+class OMPWeakClause final : public OMPClause {
+public:
+  /// Build 'weak' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPWeakClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPWeakClause()
+  : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == llvm::omp::OMPC_weak;
+  }
+};
+
 /// This represents 'fail' clause in the '#pragma omp atomic'
 /// directive.
 ///

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 16b98b364eaca..9da5206a21c34 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3436,6 +3436,11 @@ bool 
RecursiveASTVisitor::VisitOMPRelaxedClause(OMPRelaxedClause *) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPWeakClause(OMPWeakClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
   return true;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1c0ebbe4e6834..7638a7e84c3c0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11042,7 +11042,8 @@ def note_omp_atomic_compare: Note<
   "expect lvalue for result value|expect scalar value|expect integer 
value|unexpected 'else' statement|expect '==' operator|expect an assignment 
statement 'v = x'|"
   "expect a 'if' statement|expect no more than two statements|expect a 
compound statement|expect 'else' statement|expect a form 'r = x == e; if (r) 
...'}0">;
 def err_omp_atomic_fail_wrong_or_no_clauses : Error<"expected a memory order 
clause">;
-def err_omp_atomic_fail_no_compare : Error<"expected 'compare' clause with the 
'fail' modifier">;
+def err_omp_atomic_no_compare : Error<"expected 'compare' clause with the '%0' 
modifier">;
+def err_omp_atomic_weak_no_equality : Error<"expected '==' operator for 'weak' 
clause">;
 def err_omp_atomic_several_clauses : Error<
   "directive '#pragma omp atomic' cannot contain more than one 'read', 
'write', 'update', 'capture', or 'compare' clause">;
 def err_omp_several_mem_order_clauses : Error<

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 490df817ddfa2..1ac2a465a0d59 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12377,6 +12377,9 @

[llvm] [clang-tools-extra] [flang] [libc] [mlir] [lldb] [libcxx] [compiler-rt] [clang] [OpenMP] atomic compare weak : Parser & AST support (PR #79475)

2024-01-31 Thread Alexey Bataev via cfe-commits

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


[polly] [clang] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread via cfe-commits

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


[clang] [AST] Add dump() method to TypeLoc (PR #65484)

2024-01-31 Thread via cfe-commits

cor3ntin wrote:

Ping

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


[compiler-rt] [flang] [llvm] [clang] [libc] [clang-tools-extra] [libcxx] [AMDGPU] Every convergent operation needs post-isel processing (PR #80102)

2024-01-31 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/80102

>From b64f7ba4afc6cbb3e5e34757e6979a0d5ee73e2b Mon Sep 17 00:00:00 2001
From: Sameer Sahasrabuddhe 
Date: Tue, 30 Jan 2024 11:26:53 +0530
Subject: [PATCH] [AMDGPU] Every convergent operation needs post-isel
 processing

---
 llvm/lib/Target/AMDGPU/AMDGPUInstructions.td |  3 +++
 llvm/lib/Target/AMDGPU/DSInstructions.td |  7 ---
 llvm/lib/Target/AMDGPU/SIInstructions.td | 17 ++---
 llvm/lib/Target/AMDGPU/SOPInstructions.td| 15 +++
 llvm/lib/Target/AMDGPU/VOP1Instructions.td   |  1 +
 llvm/lib/Target/AMDGPU/VOP2Instructions.td   |  2 +-
 llvm/lib/Target/AMDGPU/VOP3PInstructions.td  |  2 +-
 llvm/lib/Target/AMDGPU/VOPCInstructions.td   | 12 
 llvm/lib/Target/AMDGPU/VOPInstructions.td|  2 ++
 9 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td 
b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
index 360aafedc5224..3645381919217 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
@@ -46,6 +46,9 @@ class AMDGPUInst ;
 defm DS_WRXCHG2_RTN_B64 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2_rtn_b64", VReg_128, 
VReg_64>;
 defm DS_WRXCHG2ST64_RTN_B64 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2st64_rtn_b64", 
VReg_128, VReg_64>;
 
-let isConvergent = 1, usesCustomInserter = 1 in {
+let isConvergent = 1, hasPostISelHook = 1, usesCustomInserter = 1 in {
 def DS_GWS_INIT   : DS_GWS_1D<"ds_gws_init"> {
   let mayLoad = 0;
 }
@@ -627,7 +628,7 @@ def DS_WRITE_SRC2_B32 : DS_1A<"ds_write_src2_b32">;
 def DS_WRITE_SRC2_B64 : DS_1A<"ds_write_src2_b64">;
 } // End SubtargetPredicate = HasDsSrc2Insts
 
-let Uses = [EXEC], mayLoad = 0, mayStore = 0, isConvergent = 1 in {
+let Uses = [EXEC], mayLoad = 0, mayStore = 0, isConvergent = 1, 
hasPostISelHook = 1 in {
 def DS_SWIZZLE_B32 : DS_1A_RET <"ds_swizzle_b32", VGPR_32, 0, Swizzle>;
 }
 
@@ -677,7 +678,7 @@ let SubtargetPredicate = isGFX7Plus in {
 defm DS_WRAP_RTN_B32 : DS_1A2D_RET_mc<"ds_wrap_rtn_b32", VGPR_32>;
 defm DS_CONDXCHG32_RTN_B64 : DS_1A1D_RET_mc<"ds_condxchg32_rtn_b64", VReg_64>;
 
-let isConvergent = 1, usesCustomInserter = 1 in {
+let isConvergent = 1, hasPostISelHook = 1, usesCustomInserter = 1 in {
 def DS_GWS_SEMA_RELEASE_ALL : DS_GWS_0D<"ds_gws_sema_release_all">;
 }
 
diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td 
b/llvm/lib/Target/AMDGPU/SIInstructions.td
index 788e3162fb37e..66ce001a0d766 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -177,6 +177,7 @@ def WWM_COPY : SPseudoInstSI <
   let hasSideEffects = 0;
   let isAsCheapAsAMove = 1;
   let isConvergent = 1;
+  let hasPostISelHook = 1;
 }
 
 def ENTER_STRICT_WWM : SPseudoInstSI <(outs SReg_1:$sdst), (ins i64imm:$src0)> 
{
@@ -246,7 +247,7 @@ def FPTRUNC_DOWNWARD_PSEUDO : VPseudoInstSI <(outs 
VGPR_32:$vdst),
 
 // Invert the exec mask and overwrite the inactive lanes of dst with inactive,
 // restoring it after we're done.
-let Defs = [SCC], isConvergent = 1 in {
+let Defs = [SCC], isConvergent = 1, hasPostISelHook = 1 in {
 def V_SET_INACTIVE_B32 : VPseudoInstSI <(outs VGPR_32:$vdst),
   (ins VSrc_b32: $src, VSrc_b32:$inactive),
   [(set i32:$vdst, (int_amdgcn_set_inactive i32:$src, i32:$inactive))]> {
@@ -369,6 +370,7 @@ def WAVE_BARRIER : SPseudoInstSI<(outs), (ins),
   let mayLoad = 0;
   let mayStore = 0;
   let isConvergent = 1;
+  let hasPostISelHook = 1;
   let FixedSize = 1;
   let Size = 0;
   let isMeta = 1;
@@ -382,6 +384,7 @@ def SCHED_BARRIER : SPseudoInstSI<(outs), (ins 
i32imm:$mask),
   let mayLoad = 0;
   let mayStore = 0;
   let isConvergent = 1;
+  let hasPostISelHook = 1;
   let FixedSize = 1;
   let Size = 0;
   let isMeta = 1;
@@ -397,6 +400,7 @@ def SCHED_GROUP_BARRIER : SPseudoInstSI<
   let mayLoad = 0;
   let mayStore = 0;
   let isConvergent = 1;
+  let hasPostISelHook = 1;
   let FixedSize = 1;
   let Size = 0;
   let isMeta = 1;
@@ -410,6 +414,7 @@ def IGLP_OPT : SPseudoInstSI<(outs), (ins i32imm:$mask),
   let mayLoad = 0;
   let mayStore = 0;
   let isConvergent = 1;
+  let hasPostISelHook = 1;
   let FixedSize = 1;
   let Size = 0;
   let isMeta = 1;
@@ -509,6 +514,7 @@ multiclass PseudoInstKill  {
   let Defs = [EXEC,SCC] in
   def _PSEUDO : PseudoInstSI <(outs), ins> {
 let isConvergent = 1;
+let hasPostISelHook = 1;
 let usesCustomInserter = 1;
   }
 
@@ -626,6 +632,7 @@ def SI_CALL_ISEL : SPseudoInstSI <
   let usesCustomInserter = 1;
   // TODO: Should really base this on the call target
   let isConvergent = 1;
+  let hasPostISelHook = 1;
 }
 
 def : GCNPat<
@@ -644,6 +651,7 @@ def SI_CALL : SPseudoInstSI <
   let SchedRW = [WriteBranch];
   // TODO: Should really base this on the call target
   let isConvergent = 1;
+  let hasPostISelHook = 1;
 }
 
 class SI_TCRETURN_Pseudo : SPseudoInstSI <(outs),
@@ -659,6 +667,7 @@ class SI_TCRETURN_Pseudo : 
SPseudoInstSI <(o

[clang] [AMDGPU][GFX12] Add tests for unsupported builtins (PR #78729)

2024-01-31 Thread Mariusz Sikora via cfe-commits

https://github.com/mariusz-sikora-at-amd updated 
https://github.com/llvm/llvm-project/pull/78729

>From cc492d4134e4aa0aab56d01b21ec85937e49acfd Mon Sep 17 00:00:00 2001
From: Mariusz Sikora 
Date: Fri, 19 Jan 2024 16:29:46 +0100
Subject: [PATCH] [AMDGPU][GFX12] Add tests for unsupported builtins

__builtin_amdgcn_mfma* and __builtin_amdgcn_smfmac*
---
 .../builtins-amdgcn-gfx12-err.cl  | 86 ++-
 1 file changed, 85 insertions(+), 1 deletion(-)

diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl
index bcaea9a2482d1..f91fea1714510 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl
@@ -4,10 +4,94 @@
 
 typedef unsigned int uint;
 
-kernel void test_builtins_amdgcn_gws_insts(uint a, uint b) {
+#pragma OPENCL EXTENSION cl_khr_fp64:enable
+
+typedef float  v2f   __attribute__((ext_vector_type(2)));
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v16f  __attribute__((ext_vector_type(16)));
+typedef float  v32f  __attribute__((ext_vector_type(32)));
+typedef half   v4h   __attribute__((ext_vector_type(4)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef half   v32h  __attribute__((ext_vector_type(32)));
+typedef intv2i   __attribute__((ext_vector_type(2)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv16i  __attribute__((ext_vector_type(16)));
+typedef intv32i  __attribute__((ext_vector_type(32)));
+typedef short  v2s   __attribute__((ext_vector_type(2)));
+typedef short  v4s   __attribute__((ext_vector_type(4)));
+typedef short  v8s   __attribute__((ext_vector_type(8)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+typedef short  v32s  __attribute__((ext_vector_type(32)));
+typedef double v4d   __attribute__((ext_vector_type(4)));
+
+void builtin_test_unsupported(double a_double, float a_float,
+  int a_int, long  a_long,
+  v4d a_v4d,
+  v2s a_v2s, v4s a_v4s, v8s a_v8s,
+  v2i a_v2i, v4i a_v4i, v16i a_v16i, v32i a_v32i,
+  v2f a_v2f, v4f a_v4f, v16f a_v16f, v32f  a_v32f,
+  v4h a_v4h, v8h a_v8h,
+
+  uint a, uint b) {
+
   __builtin_amdgcn_ds_gws_init(a, b); // expected-error 
{{'__builtin_amdgcn_ds_gws_init' needs target feature gws}}
   __builtin_amdgcn_ds_gws_barrier(a, b); // expected-error 
{{'__builtin_amdgcn_ds_gws_barrier' needs target feature gws}}
   __builtin_amdgcn_ds_gws_sema_v(a); // expected-error 
{{'__builtin_amdgcn_ds_gws_sema_v' needs target feature gws}}
   __builtin_amdgcn_ds_gws_sema_br(a, b); // expected-error 
{{'__builtin_amdgcn_ds_gws_sema_br' needs target feature gws}}
   __builtin_amdgcn_ds_gws_sema_p(a); // expected-error 
{{'__builtin_amdgcn_ds_gws_sema_p' needs target feature gws}}
+
+  a_v32f = __builtin_amdgcn_mfma_f32_32x32x1f32(a_float, a_float, a_v32f, 0, 
0, 0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x1f32' needs target 
feature mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_16x16x1f32(a_float, a_float, a_v16f, 0, 
0, 0); // expected-error {{'__builtin_amdgcn_mfma_f32_16x16x1f32' needs target 
feature mai-insts}}
+  a_v4f =  __builtin_amdgcn_mfma_f32_4x4x1f32(a_float, a_float, a_v4f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_4x4x1f32' needs target 
feature mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_32x32x2f32(a_float, a_float, a_v16f, 0, 
0, 0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x2f32' needs target 
feature mai-insts}}
+  a_v4f =  __builtin_amdgcn_mfma_f32_16x16x4f32(a_float, a_float, a_v4f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_16x16x4f32' needs target 
feature mai-insts}}
+  a_v32f = __builtin_amdgcn_mfma_f32_32x32x4f16(a_v4h, a_v4h, a_v32f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x4f16' needs target 
feature mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_16x16x4f16(a_v4h, a_v4h, a_v16f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_16x16x4f16' needs target 
feature mai-insts}}
+  a_v4f = __builtin_amdgcn_mfma_f32_4x4x4f16(a_v4h, a_v4h, a_v4f, 0, 0, 0); // 
expected-error {{'__builtin_amdgcn_mfma_f32_4x4x4f16' needs target feature 
mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_32x32x8f16(a_v4h, a_v4h, a_v16f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x8f16' needs target 
feature mai-insts}}
+  a_v4f = __builtin_amdgcn_mfma_f32_16x16x16f16(a_v4h, a_v4h, a_v4f, 0, 0, 0); 
// expected-error {{'__builtin_amdgcn_mfma_f32_16x16x16f16' needs target 
feature mai-insts}}
+  a_v32i = __builtin_amdgcn_mfma_i32_32x32x4i8(a_int, a_int, a_v32i, 0, 0, 0); 
// expected-error {{'__builtin_amdgcn_mfma_i32_32x32x4i8' needs targ

[clang] [clang] Represent array refs as `TemplateArgument::Declaration` (PR #80050)

2024-01-31 Thread Andrey Ali Khan Bolshakov via cfe-commits

https://github.com/bolshakov-a updated 
https://github.com/llvm/llvm-project/pull/80050

>From ae4b26cbd22a52a932464dfe5c529b296bbf96dd Mon Sep 17 00:00:00 2001
From: Bolshakov 
Date: Tue, 30 Jan 2024 21:33:34 +0300
Subject: [PATCH] [clang] Represent array refs as
 `TemplateArgument::Declaration`

This returns (probably temporarily) array-referring NTTP behavior
to which was prior to #78041 to avoid regressions.
---
 clang/lib/Sema/SemaTemplate.cpp  | 44 +---
 clang/test/CoverageMapping/templates.cpp | 13 +++
 2 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 3f33ecb89502e..9e8d058041f04 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -7417,9 +7417,9 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
 if (ArgResult.isInvalid())
   return ExprError();
 
-// Prior to C++20, enforce restrictions on possible template argument
-// values.
-if (!getLangOpts().CPlusPlus20 && Value.isLValue()) {
+if (Value.isLValue()) {
+  APValue::LValueBase Base = Value.getLValueBase();
+  auto *VD = const_cast(Base.dyn_cast());
   //   For a non-type template-parameter of pointer or reference type,
   //   the value of the constant expression shall not refer to
   assert(ParamType->isPointerType() || ParamType->isReferenceType() ||
@@ -7428,8 +7428,6 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
   // -- a string literal
   // -- the result of a typeid expression, or
   // -- a predefined __func__ variable
-  APValue::LValueBase Base = Value.getLValueBase();
-  auto *VD = const_cast(Base.dyn_cast());
   if (Base &&
   (!VD ||
isa(VD))) 
{
@@ -7437,24 +7435,30 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
 << Arg->getSourceRange();
 return ExprError();
   }
-  // -- a subobject [until C++20]
-  if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 &&
-  VD && VD->getType()->isArrayType() &&
+
+  if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 && VD &&
+  VD->getType()->isArrayType() &&
   Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
   !Value.isLValueOnePastTheEnd() && ParamType->isPointerType()) {
-// Per defect report (no number yet):
-//   ... other than a pointer to the first element of a complete array
-//   object.
-  } else if (!Value.hasLValuePath() || Value.getLValuePath().size() ||
- Value.isLValueOnePastTheEnd()) {
-Diag(StartLoc, diag::err_non_type_template_arg_subobject)
-  << Value.getAsString(Context, ParamType);
-return ExprError();
+SugaredConverted = TemplateArgument(VD, ParamType);
+CanonicalConverted = TemplateArgument(
+cast(VD->getCanonicalDecl()), CanonParamType);
+return ArgResult.get();
+  }
+
+  // -- a subobject [until C++20]
+  if (!getLangOpts().CPlusPlus20) {
+if (!Value.hasLValuePath() || Value.getLValuePath().size() ||
+Value.isLValueOnePastTheEnd()) {
+  Diag(StartLoc, diag::err_non_type_template_arg_subobject)
+  << Value.getAsString(Context, ParamType);
+  return ExprError();
+}
+assert((VD || !ParamType->isReferenceType()) &&
+   "null reference should not be a constant expression");
+assert((!VD || !ParamType->isNullPtrType()) &&
+   "non-null value of type nullptr_t?");
   }
-  assert((VD || !ParamType->isReferenceType()) &&
- "null reference should not be a constant expression");
-  assert((!VD || !ParamType->isNullPtrType()) &&
- "non-null value of type nullptr_t?");
 }
 
 if (Value.isAddrLabelDiff())
diff --git a/clang/test/CoverageMapping/templates.cpp 
b/clang/test/CoverageMapping/templates.cpp
index 7010edbc32c34..143e566a33cb8 100644
--- a/clang/test/CoverageMapping/templates.cpp
+++ b/clang/test/CoverageMapping/templates.cpp
@@ -19,3 +19,16 @@ int main() {
   func(true);
   return 0;
 }
+
+namespace structural_value_crash {
+  template 
+  void tpl_fn() {
+(void)p;
+  }
+
+  int arr[] = {1, 2, 3};
+
+  void test() {
+tpl_fn();
+  }
+}

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


[clang] [clang][dataflow] Display line numbers in the HTML logger timeline. (PR #80130)

2024-01-31 Thread via cfe-commits

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

This makes it easier to count how many iterations an analysis takes to complete.
It also makes it easier to compare how a change to the analysis code affects
the timeline.


>From 9f49f326840a706fd3cab99843d7eb60762f3e3e Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Wed, 31 Jan 2024 11:46:17 +
Subject: [PATCH] [clang][dataflow] Display line numbers in the HTML logger
 timeline.

This makes it easier to count how many iterations an analysis takes to complete.
It also makes it easier to compare how a change to the analysis code affects
the timeline.
---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css  | 10 ++
 clang/lib/Analysis/FlowSensitive/HTMLLogger.html |  1 +
 2 files changed, 11 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 5da8db8fa87bf..e25270430efc2 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -29,6 +29,16 @@ section h2 {
 }
 #timeline {
   min-width: max-content;
+  counter-reset: entry_counter;
+}
+#timeline .entry .counter::before {
+  counter-increment: entry_counter;
+  content: counter(entry_counter) ":";
+}
+#timeline .entry .counter {
+  display: inline-block;
+  min-width: 2em; /* Enough space for two digits and a colon */
+  text-align: right;
 }
 #timeline .entry.hover {
   background-color: #aaa;
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index b9f76c5074c75..be173e8b2854d 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -42,6 +42,7 @@
 Timeline
 
   
+
 {{entry.block}}
 (post-visit)
 ({{entry.iter}})

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


[clang] [clang][dataflow] Display line numbers in the HTML logger timeline. (PR #80130)

2024-01-31 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: None (martinboehme)


Changes

This makes it easier to count how many iterations an analysis takes to complete.
It also makes it easier to compare how a change to the analysis code affects
the timeline.


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.css (+10) 
- (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.html (+1) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 5da8db8fa87bf..e25270430efc2 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -29,6 +29,16 @@ section h2 {
 }
 #timeline {
   min-width: max-content;
+  counter-reset: entry_counter;
+}
+#timeline .entry .counter::before {
+  counter-increment: entry_counter;
+  content: counter(entry_counter) ":";
+}
+#timeline .entry .counter {
+  display: inline-block;
+  min-width: 2em; /* Enough space for two digits and a colon */
+  text-align: right;
 }
 #timeline .entry.hover {
   background-color: #aaa;
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index b9f76c5074c75..be173e8b2854d 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -42,6 +42,7 @@
 Timeline
 
   
+
 {{entry.block}}
 (post-visit)
 ({{entry.iter}})

``




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


[clang] [clang][dataflow] Display line numbers in the HTML logger timeline. (PR #80130)

2024-01-31 Thread via cfe-commits

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


[clang] [clang] Represent array refs as `TemplateArgument::Declaration` (PR #80050)

2024-01-31 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

@jeremiahar, thanks for reporting! Added a coverage mapping test case.

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


[clang] [clang] [MinGW] Handle linking ARM64EC code (PR #78912)

2024-01-31 Thread Martin Storsjö via cfe-commits

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

LGTM, thanks for adding the test!

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


[clang] [clang] [MinGW] Handle linking ARM64EC code (PR #78912)

2024-01-31 Thread Martin Storsjö via cfe-commits

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


[clang] d74619a - [clang] [MinGW] Handle linking ARM64EC code (#78912)

2024-01-31 Thread via cfe-commits

Author: Billy Laws
Date: 2024-01-31T13:51:12+02:00
New Revision: d74619abb53bc9c5680f83bb1dead9c65135ecc6

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

LOG: [clang] [MinGW] Handle linking ARM64EC code (#78912)

Added: 


Modified: 
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 067758c05e97c..2b7fc104ea95a 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -132,7 +132,10 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 CmdArgs.push_back("thumb2pe");
 break;
   case llvm::Triple::aarch64:
-CmdArgs.push_back("arm64pe");
+if (TC.getEffectiveTriple().isWindowsArm64EC())
+  CmdArgs.push_back("arm64ecpe");
+else
+  CmdArgs.push_back("arm64pe");
 break;
   default:
 D.Diag(diag::err_target_unknown_triple) << TC.getEffectiveTriple().str();

diff  --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp
index bb22a0652b486..e42ff4554e452 100644
--- a/clang/test/Driver/mingw.cpp
+++ b/clang/test/Driver/mingw.cpp
@@ -80,3 +80,7 @@
 
 // RUN: %clang -target i686-windows-gnu -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_NO_INIT_ARRAY %s
 // CHECK_NO_INIT_ARRAY: "-fno-use-init-array"
+
+// RUN: %clang -target arm64ec-windows-gnu -### -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK_MINGW_EC_LINK
+// CHECK_MINGW_EC_LINK: "-m" "arm64ecpe"



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


[clang] [clang][Interp] Bail out on missing ComparisonCategoryInfo (PR #80131)

2024-01-31 Thread Timm Baeder via cfe-commits

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

Instead of asserting. This can happen in real-world code.

>From 3548cdb9907a44c25da61887b2f8e83268e3c2d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 31 Jan 2024 12:53:39 +0100
Subject: [PATCH] [clang][Interp] Bail out on missing ComparisonCategoryInfo

Instead of asserting. This can happen in real-world code.
---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp | 3 ++-
 clang/test/Sema/struct-cast.c| 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 8188d6f7f5c24..a1c458a09e5ae 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -379,7 +379,8 @@ bool ByteCodeExprGen::VisitBinaryOperator(const 
BinaryOperator *BO) {
   return true;
 const ComparisonCategoryInfo *CmpInfo =
 Ctx.getASTContext().CompCategories.lookupInfoForType(BO->getType());
-assert(CmpInfo);
+if (!CmpInfo)
+  return false;
 
 // We need a temporary variable holding our return value.
 if (!Initializing) {
diff --git a/clang/test/Sema/struct-cast.c b/clang/test/Sema/struct-cast.c
index 74d00c42c295e..05e5fa4f92ca7 100644
--- a/clang/test/Sema/struct-cast.c
+++ b/clang/test/Sema/struct-cast.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter 
-verify
 // expected-no-diagnostics
 
 struct S {

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


[clang] [clang][Interp] Bail out on missing ComparisonCategoryInfo (PR #80131)

2024-01-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Instead of asserting. This can happen in real-world code.

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


2 Files Affected:

- (modified) clang/lib/AST/Interp/ByteCodeExprGen.cpp (+2-1) 
- (modified) clang/test/Sema/struct-cast.c (+1) 


``diff
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 8188d6f7f5c24..a1c458a09e5ae 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -379,7 +379,8 @@ bool ByteCodeExprGen::VisitBinaryOperator(const 
BinaryOperator *BO) {
   return true;
 const ComparisonCategoryInfo *CmpInfo =
 Ctx.getASTContext().CompCategories.lookupInfoForType(BO->getType());
-assert(CmpInfo);
+if (!CmpInfo)
+  return false;
 
 // We need a temporary variable holding our return value.
 if (!Initializing) {
diff --git a/clang/test/Sema/struct-cast.c b/clang/test/Sema/struct-cast.c
index 74d00c42c295e..05e5fa4f92ca7 100644
--- a/clang/test/Sema/struct-cast.c
+++ b/clang/test/Sema/struct-cast.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter 
-verify
 // expected-no-diagnostics
 
 struct S {

``




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


[clang] [polly] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread via cfe-commits

rmarker wrote:

> > Let's leave `None` alone and add `ExceptShortType`
> 
> I meant to add `ExceptShortType` instead of `AllowShortType`. Sorry I didn't 
> realize that adding `AllowShortType` and making it to mean "not `None`" might 
> work, in which case we don't need to add `ExceptShortType`.

No problem.

Now that we've got both options, should we keep them?
Currently, `None` sometimes forbids breaking after short return types and 
sometimes allows it and just bases things off the penalty configuration. I feel 
like there will be some people who use `None` who would want the behaviour to 
be consistent one way and the other group wanting it consistent the opposite. 
With both, they can decide for themselves. Especially since the implementation 
for both is pretty simple and self-contained.

Though, if we only go with one, my vote would be for allowing breaking after 
short return types.
That is what we were using `None` for at work. I only discovered the issue, and 
the short return type concept at all, when investigating why it wasn't breaking 
in a few odd places we couldn't understand.

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


[mlir] [clang] [llvm] [X86] Stop custom-widening v2f32 = fpext v2bf16 (PR #80106)

2024-01-31 Thread Phoebe Wang via cfe-commits


@@ -32815,10 +32815,10 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
 // No other ValueType for FP_EXTEND should reach this point.
 assert(N->getValueType(0) == MVT::v2f32 &&
"Do not know how to legalize this Node");
-if (!Subtarget.hasFP16() || !Subtarget.hasVLX())
-  return;

phoebewang wrote:

I mean these lines should not be changed.

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


[compiler-rt] [clang] [llvm] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

2024-01-31 Thread Phoebe Wang via cfe-commits


@@ -139,20 +139,77 @@ enum ProcessorFeatures {
   FEATURE_AVX512BITALG,
   FEATURE_AVX512BF16,
   FEATURE_AVX512VP2INTERSECT,
+  FEATURE_3DNOW,
+  FEATURE_ADX = 40,
+  FEATURE_CLDEMOTE = 42,

phoebewang wrote:

Why do we skip some of features?

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


[clang] [clang-tools-extra] [llvm] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)

2024-01-31 Thread Florian Hahn via cfe-commits

https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/79512

>From 299a055e271264f918321bf7360ee37c6ede8b26 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Tue, 23 Jan 2024 13:39:38 +
Subject: [PATCH] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic
 inc agree.

We are replacing with a wider increment. If both OrigInc and IsomorphicInc
are NUW/NSW, then we can preserve them on the wider increment; the narrower
IsomorphicInc would wrap before the wider OrigInc, so the replacement won't
make IsomorphicInc's uses more poisonous.
---
 .../Utils/ScalarEvolutionExpander.cpp | 28 +--
 .../Transforms/IndVarSimplify/iv-poison.ll| 12 
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp 
b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index cf8cea937a6bf..902c4db883769 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1607,11 +1607,35 @@ void SCEVExpander::replaceCongruentIVInc(
   const SCEV *TruncExpr =
   SE.getTruncateOrNoop(SE.getSCEV(OrigInc), IsomorphicInc->getType());
   if (OrigInc == IsomorphicInc || TruncExpr != SE.getSCEV(IsomorphicInc) ||
-  !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) ||
-  !hoistIVInc(OrigInc, IsomorphicInc,
+  !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc))
+return;
+
+  bool BothHaveNUW = false;
+  bool BothHaveNSW = false;
+  auto *OBOIncV = dyn_cast(OrigInc);
+  auto *OBOIsomorphic = dyn_cast(IsomorphicInc);
+  assert(OrigInc->getType()->getScalarSizeInBits() >=
+ IsomorphicInc->getType()->getScalarSizeInBits()) && "Should only 
replace an increment with a wider one.");
+  if (OBOIncV && OBOIsomorphic) {
+BothHaveNUW =
+OBOIncV->hasNoUnsignedWrap() && OBOIsomorphic->hasNoUnsignedWrap();
+BothHaveNSW =
+OBOIncV->hasNoSignedWrap() && OBOIsomorphic->hasNoSignedWrap();
+  }
+
+  if (!hoistIVInc(OrigInc, IsomorphicInc,
   /*RecomputePoisonFlags*/ true))
 return;
 
+  // We are replacing with a wider increment. If both OrigInc and IsomorphicInc
+  // are NUW/NSW, then we can preserve them on the wider increment; the 
narrower
+  // IsomorphicInc would wrap before the wider OrigInc, so the replacement 
won't
+  // make IsomorphicInc's uses more poisonous.
+  if (BothHaveNUW || BothHaveNSW) {
+OrigInc->setHasNoUnsignedWrap(OBOIncV->hasNoUnsignedWrap() || BothHaveNUW);
+OrigInc->setHasNoSignedWrap(OBOIncV->hasNoSignedWrap() || BothHaveNSW);
+  }
+
   SCEV_DEBUG_WITH_TYPE(DebugType,
dbgs() << "INDVARS: Eliminated congruent iv.inc: "
   << *IsomorphicInc << '\n');
diff --git a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll 
b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
index 38299e0a6b353..383599f614357 100644
--- a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
+++ b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll
@@ -64,7 +64,7 @@ define i2 @iv_hoist_both_adds_nsw(i2 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i2 [[IV_0]], 1
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i2 1, [[ARG:%.*]]
 ; CHECK-NEXT:br i1 [[DOTNOT_NOT]], label [[EXIT:%.*]], label [[LOOP]]
 ; CHECK:   exit:
@@ -92,7 +92,7 @@ define i4 @iv_hoist_both_adds_nsw_extra_use(i4 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]]
@@ -124,7 +124,7 @@ define i4 
@iv_hoist_both_adds_nsw_extra_use_incs_reordered(i4 %arg) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], 
[[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]])
 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]]
@@ -244,7 +244,7 @@ define i2 @iv_hoist_both_adds_nuw(i2 %arg, i2 %start) {
 ; CHECK-NEXT:br label [[LOOP:%.*]]
 ; CHECK:   loop:
 ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ [[START:%.*]], [[BB:%.*]] ], [ 
[[IV_0_NEXT:%.*]], [[LOOP]] ]
-; CHECK-NEXT:[[IV_0_NEXT]] = add i2 [[IV_0]], 1
+; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1
 ; CHECK-NEXT:[[DOTN

[clang] [clang-tools-extra] [llvm] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)

2024-01-31 Thread Florian Hahn via cfe-commits

fhahn wrote:

ping :) 

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


[clang] [Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (PR #79821)

2024-01-31 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/79821

>From c22d670259f1d9fc22b6e01bf19d1f2316b1d617 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 29 Jan 2024 04:56:13 -0800
Subject: [PATCH 1/3] Fix erroneous warning.

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 clang/test/Driver/range.c | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8d8965fdf76fb..7ceb248f7afb9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2705,7 +2705,7 @@ static StringRef 
EnumComplexRangeToStr(LangOptions::ComplexRangeKind Range) {
 static void EmitComplexRangeDiag(const Driver &D,
  LangOptions::ComplexRangeKind Range1,
  LangOptions::ComplexRangeKind Range2) {
-  if (Range1 != LangOptions::ComplexRangeKind::CX_Full)
+  if (Range1 != Range2 && Range1 != LangOptions::ComplexRangeKind::CX_None)
 D.Diag(clang::diag::warn_drv_overriding_option)
 << EnumComplexRangeToStr(Range1) << EnumComplexRangeToStr(Range2);
 }
diff --git a/clang/test/Driver/range.c b/clang/test/Driver/range.c
index 045d9c7d3d802..023b5cffbe3e0 100644
--- a/clang/test/Driver/range.c
+++ b/clang/test/Driver/range.c
@@ -35,6 +35,9 @@
 // RUN: %clang -### -target x86_64 -ffast-math -fno-cx-limited-range -c %s 
2>&1 \
 // RUN:   | FileCheck --check-prefix=FULL %s
 
+// RUN: %clang -c -target x86_64 -fcx-limited-range %s -Xclang -verify=range
+// RUN: %clang -c -target x86_64 -fcx-fortran-rules %s -Xclang -verify=range
+
 // LMTD: -complex-range=limited
 // FULL: -complex-range=full
 // LMTD-NOT: -complex-range=fortran
@@ -44,3 +47,4 @@
 // CHECK-NOT: -complex-range=fortran
 // WARN1: warning: overriding '-fcx-limited-range' option with 
'-fcx-fortran-rules' [-Woverriding-option]
 // WARN2: warning: overriding '-fcx-fortran-rules' option with 
'-fcx-limited-range' [-Woverriding-option]
+// range-no-diagnostics

>From 407340d515c2f1bd9ced550077e9e3c316c4e2c1 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 30 Jan 2024 06:26:53 -0800
Subject: [PATCH 2/3] Fixed LIT test.

---
 clang/test/Driver/range.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/range.c b/clang/test/Driver/range.c
index 023b5cffbe3e0..9a51925dba9e8 100644
--- a/clang/test/Driver/range.c
+++ b/clang/test/Driver/range.c
@@ -35,8 +35,11 @@
 // RUN: %clang -### -target x86_64 -ffast-math -fno-cx-limited-range -c %s 
2>&1 \
 // RUN:   | FileCheck --check-prefix=FULL %s
 
-// RUN: %clang -c -target x86_64 -fcx-limited-range %s -Xclang -verify=range
-// RUN: %clang -c -target x86_64 -fcx-fortran-rules %s -Xclang -verify=range
+// RUN: %clang -### -Werror -target x86_64 -fcx-limited-range -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=LMTD %s
+
+// RUN: %clang -### -Werror -target x86_64 -fcx-fortran-rules -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=FRTRN %s
 
 // LMTD: -complex-range=limited
 // FULL: -complex-range=full

>From d7f2ad17b285fe0fcc153defb45dac2a16ab4e30 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Wed, 31 Jan 2024 04:58:57 -0800
Subject: [PATCH 3/3] Remove unused line in range.c.

---
 clang/test/Driver/range.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/test/Driver/range.c b/clang/test/Driver/range.c
index 9a51925dba9e8..49116df2f4480 100644
--- a/clang/test/Driver/range.c
+++ b/clang/test/Driver/range.c
@@ -50,4 +50,3 @@
 // CHECK-NOT: -complex-range=fortran
 // WARN1: warning: overriding '-fcx-limited-range' option with 
'-fcx-fortran-rules' [-Woverriding-option]
 // WARN2: warning: overriding '-fcx-fortran-rules' option with 
'-fcx-limited-range' [-Woverriding-option]
-// range-no-diagnostics

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


[clang] [clang] Represent array refs as `TemplateArgument::Declaration` (PR #80050)

2024-01-31 Thread via cfe-commits

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

I will accept that as it seems to unblock some folks, 
but I'd like to understand the root cause and what a proper fix would look like

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


[clang] [Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (PR #79821)

2024-01-31 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

@AaronBallman Any more comments?

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


[clang] [AMDGPU][GFX12] Add tests for unsupported builtins (PR #78729)

2024-01-31 Thread Mariusz Sikora via cfe-commits

https://github.com/mariusz-sikora-at-amd closed 
https://github.com/llvm/llvm-project/pull/78729
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f96e85b - [AMDGPU][GFX12] Add tests for unsupported builtins (#78729)

2024-01-31 Thread via cfe-commits

Author: Mariusz Sikora
Date: 2024-01-31T14:04:04+01:00
New Revision: f96e85b9494f549976fac3947756e6da1fcc572b

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

LOG: [AMDGPU][GFX12] Add tests for unsupported builtins (#78729)

__builtin_amdgcn_mfma* and __builtin_amdgcn_smfmac*

Added: 


Modified: 
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl
index bcaea9a2482d1..f91fea1714510 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12-err.cl
@@ -4,10 +4,94 @@
 
 typedef unsigned int uint;
 
-kernel void test_builtins_amdgcn_gws_insts(uint a, uint b) {
+#pragma OPENCL EXTENSION cl_khr_fp64:enable
+
+typedef float  v2f   __attribute__((ext_vector_type(2)));
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v16f  __attribute__((ext_vector_type(16)));
+typedef float  v32f  __attribute__((ext_vector_type(32)));
+typedef half   v4h   __attribute__((ext_vector_type(4)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef half   v32h  __attribute__((ext_vector_type(32)));
+typedef intv2i   __attribute__((ext_vector_type(2)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv16i  __attribute__((ext_vector_type(16)));
+typedef intv32i  __attribute__((ext_vector_type(32)));
+typedef short  v2s   __attribute__((ext_vector_type(2)));
+typedef short  v4s   __attribute__((ext_vector_type(4)));
+typedef short  v8s   __attribute__((ext_vector_type(8)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+typedef short  v32s  __attribute__((ext_vector_type(32)));
+typedef double v4d   __attribute__((ext_vector_type(4)));
+
+void builtin_test_unsupported(double a_double, float a_float,
+  int a_int, long  a_long,
+  v4d a_v4d,
+  v2s a_v2s, v4s a_v4s, v8s a_v8s,
+  v2i a_v2i, v4i a_v4i, v16i a_v16i, v32i a_v32i,
+  v2f a_v2f, v4f a_v4f, v16f a_v16f, v32f  a_v32f,
+  v4h a_v4h, v8h a_v8h,
+
+  uint a, uint b) {
+
   __builtin_amdgcn_ds_gws_init(a, b); // expected-error 
{{'__builtin_amdgcn_ds_gws_init' needs target feature gws}}
   __builtin_amdgcn_ds_gws_barrier(a, b); // expected-error 
{{'__builtin_amdgcn_ds_gws_barrier' needs target feature gws}}
   __builtin_amdgcn_ds_gws_sema_v(a); // expected-error 
{{'__builtin_amdgcn_ds_gws_sema_v' needs target feature gws}}
   __builtin_amdgcn_ds_gws_sema_br(a, b); // expected-error 
{{'__builtin_amdgcn_ds_gws_sema_br' needs target feature gws}}
   __builtin_amdgcn_ds_gws_sema_p(a); // expected-error 
{{'__builtin_amdgcn_ds_gws_sema_p' needs target feature gws}}
+
+  a_v32f = __builtin_amdgcn_mfma_f32_32x32x1f32(a_float, a_float, a_v32f, 0, 
0, 0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x1f32' needs target 
feature mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_16x16x1f32(a_float, a_float, a_v16f, 0, 
0, 0); // expected-error {{'__builtin_amdgcn_mfma_f32_16x16x1f32' needs target 
feature mai-insts}}
+  a_v4f =  __builtin_amdgcn_mfma_f32_4x4x1f32(a_float, a_float, a_v4f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_4x4x1f32' needs target 
feature mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_32x32x2f32(a_float, a_float, a_v16f, 0, 
0, 0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x2f32' needs target 
feature mai-insts}}
+  a_v4f =  __builtin_amdgcn_mfma_f32_16x16x4f32(a_float, a_float, a_v4f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_16x16x4f32' needs target 
feature mai-insts}}
+  a_v32f = __builtin_amdgcn_mfma_f32_32x32x4f16(a_v4h, a_v4h, a_v32f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x4f16' needs target 
feature mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_16x16x4f16(a_v4h, a_v4h, a_v16f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_16x16x4f16' needs target 
feature mai-insts}}
+  a_v4f = __builtin_amdgcn_mfma_f32_4x4x4f16(a_v4h, a_v4h, a_v4f, 0, 0, 0); // 
expected-error {{'__builtin_amdgcn_mfma_f32_4x4x4f16' needs target feature 
mai-insts}}
+  a_v16f = __builtin_amdgcn_mfma_f32_32x32x8f16(a_v4h, a_v4h, a_v16f, 0, 0, 
0); // expected-error {{'__builtin_amdgcn_mfma_f32_32x32x8f16' needs target 
feature mai-insts}}
+  a_v4f = __builtin_amdgcn_mfma_f32_16x16x16f16(a_v4h, a_v4h, a_v4f, 0, 0, 0); 
// expected-error {{'__builtin_amdgcn_mfma_f32_16x16x16f16' needs target 
feature mai-insts}}
+  a_v32i = __builtin_amd

[clang] [Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (PR #79821)

2024-01-31 Thread Aaron Ballman via cfe-commits

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

LGTM, thank you for the fix!

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


[clang] [Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (PR #79821)

2024-01-31 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

@MaskRay, @AaronBallman thanks for the review.

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


[lld] [llvm] [clang-tools-extra] [libcxx] [libc] [flang] [compiler-rt] [clang] [libc++][memory] P2652R2: Disallow Specialization of `allocator_traits` (PR #79978)

2024-01-31 Thread Nikolas Klauser via cfe-commits


@@ -0,0 +1,34 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___MEMORY_ALLOCATION_RESULT_H
+#define _LIBCPP___MEMORY_ALLOCATION_RESULT_H
+
+#include <__config>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+template 

philnik777 wrote:

Why did you move this to it's own header?

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


[flang] [compiler-rt] [libcxx] [clang-tools-extra] [lld] [libc] [clang] [llvm] [libc++][memory] P2652R2: Disallow Specialization of `allocator_traits` (PR #79978)

2024-01-31 Thread Nikolas Klauser via cfe-commits


@@ -88,9 +88,9 @@ def add_version_header(tc):
 {
 "name": "__cpp_lib_allocate_at_least",
 "values": {
-"c++23": 202106,
+# "c++23": 202106,  # P0401R6 Providing size feedback in the 
Allocator interface

philnik777 wrote:

This line isn't needed anymore.

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


[clang] [compiler-rt] [Sanitizer] add signed-integer-wrap sanitizer (PR #80089)

2024-01-31 Thread Thorsten Schütt via cfe-commits


@@ -0,0 +1,66 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s 
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECK
+
+// Check that -fsanitize=signed-integer-overflow doesn't instrument with 
-fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s 
-fsanitize=signed-integer-overflow | FileCheck %s --check-prefix=CHECKSIO
+
+extern volatile int a, b, c;
+
+// CHECK-LABEL: define void @test_add_overflow
+void test_add_overflow(void) {
+  // CHECK: [[ADD0:%.*]] = load {{.*}} i32
+  // CHECK-NEXT: [[ADD1:%.*]] = load {{.*}} i32
+  // CHECK-NEXT: {{%.*}} = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 
[[ADD0]], i32 [[ADD1]])
+  // CHECK: call void @__ubsan_handle_add_overflow
+
+  // CHECKSIO-NOT: call void @__ubsan_handle_add_overflow
+  a = b + c;
+}
+
+// CHECK-LABEL: define void @test_inc_overflow
+void test_inc_overflow(void) {
+  // This decays and gets handled by __ubsan_handle_add_overflow...
+  // CHECK: [[INC0:%.*]] = load {{.*}} i32
+  // CHECK-NEXT: call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[INC0]], 
i32 1)
+  // CHECK: br {{.*}} %handler.add_overflow
+
+  // CHECKSIO-NOT: br {{.*}} %handler.add_overflow

tschuett wrote:

In some tests the branch on the overflow bit is not visible. It gives you more 
confidence, if there is always a branch on the overflow bit.

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


[clang] [clang][dataflow] fix assert in `Environment::getResultObjectLocation` (PR #79608)

2024-01-31 Thread Paul Semel via cfe-commits

https://github.com/paulsemel updated 
https://github.com/llvm/llvm-project/pull/79608

>From 6af0f5971783214f6f3ce5f95aba97ed1c79824e Mon Sep 17 00:00:00 2001
From: Paul Semel 
Date: Fri, 26 Jan 2024 15:29:58 +
Subject: [PATCH 1/3] [dataflow] fix assert in
 `Environment::getResultObjectLocation`

When calling `Environment::getResultObjectLocation` with a
CXXOperatorCallExpr that is a prvalue, we just hit an assert because no
record was ever created.
---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 2271a75fbcaf7..3b028a3200b72 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -536,6 +536,11 @@ class TransferVisitor : public 
ConstStmtVisitor {
 
   copyRecord(*LocSrc, *LocDst, Env);
   Env.setStorageLocation(*S, *LocDst);
+} else {
+  // CXXOperatorCallExpr can be prvalues, in which case we must create a
+  // record for them in order for `Environment::getResultObjectLocation()`
+  // to be able to return a value.
+  VisitCallExpr(S);
 }
   }
 

>From acca94eb5c2c3ce858a704384361f54c1ae7557c Mon Sep 17 00:00:00 2001
From: Paul Semel 
Date: Tue, 30 Jan 2024 17:43:55 +0100
Subject: [PATCH 2/3] Update clang/lib/Analysis/FlowSensitive/Transfer.cpp

Co-authored-by: martinboehme 
---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 3b028a3200b72..bb3aec763c29c 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -536,12 +536,13 @@ class TransferVisitor : public 
ConstStmtVisitor {
 
   copyRecord(*LocSrc, *LocDst, Env);
   Env.setStorageLocation(*S, *LocDst);
-} else {
-  // CXXOperatorCallExpr can be prvalues, in which case we must create a
-  // record for them in order for `Environment::getResultObjectLocation()`
-  // to be able to return a value.
-  VisitCallExpr(S);
+  return;
 }
+
+// CXXOperatorCallExpr can be prvalues. Call `VisitCallExpr`() to create
+// a `RecordValue` for them so that 
`Environment::getResultObjectLocation()`
+// can return a value.
+VisitCallExpr(S);
   }
 
   void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {

>From 7375c69754a6ed203d6b5fe7aaaf4dc963fb034b Mon Sep 17 00:00:00 2001
From: Paul Semel 
Date: Tue, 30 Jan 2024 17:05:44 +
Subject: [PATCH 3/3] add test

---
 .../Analysis/FlowSensitive/TransferTest.cpp   | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 268ea4c7431f6..8bbb04024dcce 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2735,6 +2735,39 @@ TEST(TransferTest, 
ResultObjectLocationForDefaultInitExpr) {
   });
 }
 
+// This test ensures that CXXOperatorCallExpr returning prvalues are correctly
+// handled by the transfer functions, especially that `getResultObjectLocation`
+// correctly returns a storage location for those.
+TEST(TransferTest, ResultObjectLocationForCXXOperatorCallExpr) {
+  std::string Code = R"(
+struct A {
+  A operator+(int);
+};
+
+void target() {
+  A a;
+  a + 3;
+  (void)0; // [[p]]
+}
+  )";
+  using ast_matchers::cxxOperatorCallExpr;
+  using ast_matchers::match;
+  using ast_matchers::selectFirst;
+  using ast_matchers::traverse;
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto *CallExpr = selectFirst(
+"call_expr",
+match(cxxOperatorCallExpr().bind("call_expr"), ASTCtx));
+
+EXPECT_NE(&Env.getResultObjectLocation(*CallExpr), nullptr);
+  });
+}
+
 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][Sema] fix outline member function template with default align crash (PR #78400)

2024-01-31 Thread Qizhi Hu via cfe-commits

jcsxky wrote:

> @jcsxky this patch introduced a regression. Please see the reproducer here: 
> https://godbolt.org/z/rEfWP75Ta. It compiles before this change and fails at 
> this change. It also compiles with gcc and clang-17.

Sorry for importing new bugs. @erichkeane Could you help me revert this patch 
in order to not influence others since I am not familiar with github reverting 
operation? I afraid I would spent a long time to look into the root cause of 
the issue. Appreciate for you help and many thanks!

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


[llvm] [clang] [CloneFunction][DebugInfo] Avoid cloning DILocalVariables of inlined functions (PR #75385)

2024-01-31 Thread Vladislav Dzhidzhoev via cfe-commits

dzhidzhoev wrote:

> Hi,
> 
> We're seeing a crash with this commit and reproducer 
> https://gist.github.com/jmorse/b0248c3c9f9195487ffd7c7431a8d15e
> 
> llc: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2338: virtual void 
> llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction *): Assertion 
> `LScopes.getAbstractScopesList().size() == NumAbstractSubprograms && 
> "getOrCreateAbstractScope() inserted an abstract subprogram scope"' failed.
> 
> I'd previously posted the reproducer on 
> https://reviews.llvm.org/D144006#4656728 , however I'd anonymised the IR too 
> much to the point where it was broken in unrelated ways. Revision 2 of the 
> gist, as linked, should produce the crash. I suspect the extra lexical scopes 
> reachable through the retained-nodes list also need to be explored when the 
> LexicalScopes object gets constructed, to avoid scopes being added late and 
> causing containers to invalidate iterators. (Which is what that assertion is 
> there to detect).

It seems that the debug info metadata was already malformed before getting into 
the AsmPrinter pass, probably during the LTO process. I ran into trouble trying 
to find the root cause of the problem, since the information provided by the 
reproducer is not sufficient to investigate it.
Could you please provide an IR dump of the earlier stage of compilation or any 
source code? 

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


[clang] [clang] Represent array refs as `TemplateArgument::Declaration` (PR #80050)

2024-01-31 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

I think the problem is that the generalized NTTP feature is still raw. It 
should not break already working features, namely array reference NTTPs, hence 
they are swithed back to the old `TemplateArgument::Declaration`, as they 
worked prior to #78041, from the new `StructuralValue`.

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


[clang] [clang][Interp] Handle imaginary literals (PR #79130)

2024-01-31 Thread Aaron Ballman via cfe-commits

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


[clang] [clang][Interp] Handle imaginary literals (PR #79130)

2024-01-31 Thread Aaron Ballman via cfe-commits

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

LGTM aside from a minor simplification.

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


[clang] [clang][Interp] Handle imaginary literals (PR #79130)

2024-01-31 Thread Aaron Ballman via cfe-commits


@@ -112,12 +112,15 @@ bool Context::evaluateAsInitializer(State &Parent, const 
VarDecl *VD,
 #endif
 
   // Ensure global variables are fully initialized.
-  if (shouldBeGloballyIndexed(VD) && !Res.isInvalid() &&
-  (VD->getType()->isRecordType() || VD->getType()->isArrayType())) {
+  if (shouldBeGloballyIndexed(VD) &&
+  (VD->getType()->isRecordType() || VD->getType()->isArrayType() ||
+   VD->getType()->isAnyComplexType())) {
 assert(Res.isLValue());
 
-if (!Res.checkFullyInitialized(C.getState()))
-  return false;
+if (!VD->getType()->isAnyComplexType()) {
+  if (!Res.checkFullyInitialized(C.getState()))
+return false;
+}

AaronBallman wrote:

```suggestion
if (!VD->getType()->isAnyComplexType() &&
   !Res.checkFullyInitialized(C.getState()))
  return false;
```

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


[clang] [clang] Represent array refs as `TemplateArgument::Declaration` (PR #80050)

2024-01-31 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

> what a proper fix would look like

Probably, some more `OpaqueValueExpr` handlers should be rewritten correctly.

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


[clang] [clang] Represent array refs as `TemplateArgument::Declaration` (PR #80050)

2024-01-31 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

@cor3ntin, @erichkeane, could you merge it please?

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


[clang] [clang][Interp] Handle casts between complex types (PR #79269)

2024-01-31 Thread Aaron Ballman via cfe-commits


@@ -234,8 +234,14 @@ class Pointer {
 
   /// Returns the type of the innermost field.
   QualType getType() const {
-if (inPrimitiveArray() && Offset != Base)
-  return 
getFieldDesc()->getType()->getAsArrayTypeUnsafe()->getElementType();
+if (inPrimitiveArray() && Offset != Base) {
+  // Unfortunately, complex types are not array types in clang, but they 
are
+  // for us.
+  if (const auto *AT = getFieldDesc()->getType()->getAsArrayTypeUnsafe())
+return AT->getElementType();
+  if (const auto *CT = getFieldDesc()->getType()->castAs())

AaronBallman wrote:

```suggestion
  if (const auto *CT = getFieldDesc()->getType()->getAs())
```
Otherwise you wouldn't need the `if` at all because we'd assert if the type was 
wrong.

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


[clang] [clang][Interp] Handle casts between complex types (PR #79269)

2024-01-31 Thread Aaron Ballman via cfe-commits

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


[clang] [clang][Interp] Handle casts between complex types (PR #79269)

2024-01-31 Thread Aaron Ballman via cfe-commits

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

LGTM aside from a nit.

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


[clang-tools-extra] [llvm] [clang] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)

2024-01-31 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] e538486 - [Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (#79821)

2024-01-31 Thread via cfe-commits

Author: Zahira Ammarguellat
Date: 2024-01-31T09:20:36-05:00
New Revision: e538486e90539096e7851d0deba4ea9ed94fced2

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

LOG: [Driver] Fix erroneous warning for -fcx-limited-range and 
-fcx-fortran-rules. (#79821)

The options `-fcx-limited-range` and `-fcx-fortran-rules` were added in
_https://github.com/llvm/llvm-project/pull/70244_

The code adding the options introduced an erroneous warning.
`$ clang -c -fcx-limited-range t1.c` 
`clang: warning: overriding '' option with '-fcx-limited-range'
[-Woverriding-option]`
and
`$ clang -c -fcx-fortran-rules t1.c`
`clang: warning: overriding '' option with '-fcx-fortran-rules'
[-Woverriding-option]`

The warning doesn't make sense. This patch removes it.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/range.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8d8965fdf76fb..7ceb248f7afb9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2705,7 +2705,7 @@ static StringRef 
EnumComplexRangeToStr(LangOptions::ComplexRangeKind Range) {
 static void EmitComplexRangeDiag(const Driver &D,
  LangOptions::ComplexRangeKind Range1,
  LangOptions::ComplexRangeKind Range2) {
-  if (Range1 != LangOptions::ComplexRangeKind::CX_Full)
+  if (Range1 != Range2 && Range1 != LangOptions::ComplexRangeKind::CX_None)
 D.Diag(clang::diag::warn_drv_overriding_option)
 << EnumComplexRangeToStr(Range1) << EnumComplexRangeToStr(Range2);
 }

diff  --git a/clang/test/Driver/range.c b/clang/test/Driver/range.c
index 045d9c7d3d802..49116df2f4480 100644
--- a/clang/test/Driver/range.c
+++ b/clang/test/Driver/range.c
@@ -35,6 +35,12 @@
 // RUN: %clang -### -target x86_64 -ffast-math -fno-cx-limited-range -c %s 
2>&1 \
 // RUN:   | FileCheck --check-prefix=FULL %s
 
+// RUN: %clang -### -Werror -target x86_64 -fcx-limited-range -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=LMTD %s
+
+// RUN: %clang -### -Werror -target x86_64 -fcx-fortran-rules -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=FRTRN %s
+
 // LMTD: -complex-range=limited
 // FULL: -complex-range=full
 // LMTD-NOT: -complex-range=fortran



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


[clang] [Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (PR #79821)

2024-01-31 Thread Zahira Ammarguellat via cfe-commits

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


  1   2   3   4   5   >