[clang] [flang] [Flang][Driver] Add -print-resource-dir command line flag to emit Flang's resource directory (PR #90886)

2024-06-24 Thread Michael Klemm via cfe-commits

mjklemm wrote:

Yeah, go ahead and revert. I can create a new PR from it just print the 
resource dir. 

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


[clang] [clang] inherit GD to let the codegen add kcfi type for ifunc (PR #96400)

2024-06-24 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Please fix buildbot failure (it looks like clang/test/CodeGen/ifunc.c is 
failing).

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


[clang] [Clang] use const references for function parameters in operator== and operator!= overloads in Redeclarable.h (PR #92963)

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

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

>From c94e7cbe04c0f23094a7f2a3d2a7cbd103750301 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Tue, 21 May 2024 22:56:06 +0300
Subject: [PATCH] [Clang] use const references for function parameters in
 operator== and operator!= overloads in Redeclarable.h

---
 clang/include/clang/AST/Redeclarable.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/AST/Redeclarable.h 
b/clang/include/clang/AST/Redeclarable.h
index 091bb886f2d49..74ccd74ed60d6 100644
--- a/clang/include/clang/AST/Redeclarable.h
+++ b/clang/include/clang/AST/Redeclarable.h
@@ -281,10 +281,10 @@ class Redeclarable {
   return tmp;
 }
 
-friend bool operator==(redecl_iterator x, redecl_iterator y) {
+friend bool operator==(const redecl_iterator , const redecl_iterator ) 
{
   return x.Current == y.Current;
 }
-friend bool operator!=(redecl_iterator x, redecl_iterator y) {
+friend bool operator!=(const redecl_iterator , const redecl_iterator ) 
{
   return x.Current != y.Current;
 }
   };

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


[clang] [Clang] improve RewriteModernObjC code quality by using const reference for function parameters (PR #93252)

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

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

>From d160eb6c869d41ac64ff27442d2f8d964beb3ebf Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Fri, 24 May 2024 01:39:35 +0300
Subject: [PATCH] [Clang] improve RewriteModernObjC code quality by using const
 reference for function parameters

---
 .../Frontend/Rewrite/RewriteModernObjC.cpp| 37 +--
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp 
b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index 6ae955a2380b7..764cdc6f07cf6 100644
--- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -465,15 +465,15 @@ namespace {
 
 std::string SynthesizeByrefCopyDestroyHelper(VarDecl *VD, int flag);
 std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
-  StringRef funcName, std::string Tag);
-std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
-  StringRef funcName, std::string Tag);
-std::string SynthesizeBlockImpl(BlockExpr *CE,
-std::string Tag, std::string Desc);
-std::string SynthesizeBlockDescriptor(std::string DescTag,
-  std::string ImplTag,
-  int i, StringRef funcName,
-  unsigned hasCopy);
+   StringRef funcName,
+   const std::string );
+std::string SynthesizeBlockFunc(BlockExpr *CE, int i, StringRef funcName,
+const std::string );
+std::string SynthesizeBlockImpl(BlockExpr *CE, const std::string ,
+const std::string );
+std::string SynthesizeBlockDescriptor(const std::string ,
+  const std::string , int i,
+  StringRef funcName, unsigned 
hasCopy);
 Stmt *SynthesizeBlockCall(CallExpr *Exp, const Expr* BlockExp);
 void SynthesizeBlockLiterals(SourceLocation FunLocStart,
  StringRef FunName);
@@ -4037,7 +4037,7 @@ static bool HasLocalVariableExternalStorage(ValueDecl 
*VD) {
 
 std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
StringRef funcName,
-   std::string Tag) {
+   const std::string ) {
   const FunctionType *AFT = CE->getFunctionType();
   QualType RT = AFT->getReturnType();
   std::string StructRef = "struct " + Tag;
@@ -4131,9 +4131,8 @@ std::string 
RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
   return S;
 }
 
-std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
-   StringRef funcName,
-   std::string Tag) {
+std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(
+BlockExpr *CE, int i, StringRef funcName, const std::string ) {
   std::string StructRef = "struct " + Tag;
   std::string S = "static void __";
 
@@ -4175,8 +4174,9 @@ std::string 
RewriteModernObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
   return S;
 }
 
-std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string 
Tag,
- std::string Desc) {
+std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE,
+   const std::string ,
+   const std::string ) {
   std::string S = "\nstruct " + Tag;
   std::string Constructor = "  " + Tag;
 
@@ -4290,10 +4290,9 @@ std::string 
RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Ta
   return S;
 }
 
-std::string RewriteModernObjC::SynthesizeBlockDescriptor(std::string DescTag,
-   std::string ImplTag, int i,
-   StringRef FunName,
-   unsigned hasCopy) {
+std::string RewriteModernObjC::SynthesizeBlockDescriptor(
+const std::string , const std::string , int i,
+StringRef FunName, unsigned hasCopy) {
   std::string S = "\nstatic struct " + DescTag;
 
   S += " {\n  size_t reserved;\n";

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-06-24 Thread Eli Friedman via cfe-commits


@@ -5751,8 +5751,29 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   if (llvm::CallInst *Call = dyn_cast(CI)) {
 if (TargetDecl && TargetDecl->hasAttr())
   Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
-else if (IsMustTail)
+else if (IsMustTail) {
+  if (getTarget().getTriple().isPPC()) {
+if (getTarget().getTriple().isOSAIX())
+  CGM.getDiags().Report(Loc, diag::err_aix_musttail_unsupported);
+else if (!getTarget().hasFeature("pcrelative-memops")) {
+  if (getTarget().hasFeature("longcall"))
+CGM.getDiags().Report(Loc, diag::err_ppc_impossible_musttail) << 0;
+  else if (Call->isIndirectCall())
+CGM.getDiags().Report(Loc, diag::err_ppc_impossible_musttail) << 1;
+  else if (isa_and_nonnull(TargetDecl) &&
+   cast(TargetDecl)->isWeak())

efriedma-quic wrote:

This isn't the right way to check the definition is "weak", I think.  In 
addition to explicit weak attributes, you need some check for inline functions 
(both C and C++, which have different semantics).  Not sure what the CodeGen 
API for this is off the top of my head.

I think you also need to check for weak definitions in 
MustTailCallUndefinedGlobals.

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


[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-24 Thread Xiang Li via cfe-commits

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


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


[clang] [ObjC][CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-24 Thread John McCall via cfe-commits

rjmccall wrote:

I don't usually do that for people, sorry.

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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-24 Thread Jannick Kremer via cfe-commits

DeinAlptraum wrote:

@Endilll done with the TokenKind refactoring, so this is ready to go from my 
side.

Regarding reviewers, can you recommend any others? Since I assume I'll open a 
couple more PRs for the Python bindings after this

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


[clang] [Clang] fix cast failures by adjusting the resolution of record declaration contexts to handle semantic and lexical distinctions (PR #96228)

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

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


[clang] [PAC][clang][Driver] Add signed GOT flag (PR #96160)

2024-06-24 Thread Daniil Kovalev via cfe-commits

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


[clang] [llvm] [PAC][ELF][AArch64] Encode signed GOT flag in PAuth core info (PR #96159)

2024-06-24 Thread Daniil Kovalev via cfe-commits

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


[clang] [llvm] [llvm][misexpect] Update MisExpect to use provenance tracking metadata (PR #86610)

2024-06-24 Thread Paul Kirth via cfe-commits

ilovepi wrote:

Ping. Now that the metadata patches have landed, I think we can start 
discussing using that in MisExpect.

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


[clang] [TBAA] Emit int TBAA metadata on FP math libcalls (PR #96025)

2024-06-24 Thread Eli Friedman via cfe-commits


@@ -707,7 +707,36 @@ static RValue emitLibraryCall(CodeGenFunction , const 
FunctionDecl *FD,
   const CallExpr *E, llvm::Constant *calleeValue) {
   CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
   CGCallee callee = CGCallee::forDirect(calleeValue, GlobalDecl(FD));
-  return CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
+  RValue Call =
+  CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
+
+  // Check the supported intrinsic.
+  if (unsigned BuiltinID = FD->getBuiltinID()) {
+auto IntrinsicID = [&]() -> unsigned {
+  switch (BuiltinID) {
+  case Builtin::BIexpf:
+  case Builtin::BI__builtin_expf:
+  case Builtin::BI__builtin_expf128:
+return true;
+  }
+  // TODO: support more FP math libcalls
+  return false;
+}();
+
+const llvm::Triple  = CGF.getTarget().getTriple();
+// Restrict to Linux because not all targets set errno, such as MacOS.

efriedma-quic wrote:

LangOpts.MathErrno

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


[clang] [TBAA] Emit int TBAA metadata on FP math libcalls (PR #96025)

2024-06-24 Thread Eli Friedman via cfe-commits


@@ -707,7 +707,34 @@ static RValue emitLibraryCall(CodeGenFunction , const 
FunctionDecl *FD,
   const CallExpr *E, llvm::Constant *calleeValue) {
   CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
   CGCallee callee = CGCallee::forDirect(calleeValue, GlobalDecl(FD));
-  return CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
+  RValue Call =
+  CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
+
+  // Check the supported intrinsic.
+  if (unsigned BuiltinID = FD->getBuiltinID()) {
+auto IntrinsicID = [&]() -> unsigned {
+  switch (BuiltinID) {
+  case Builtin::BIexpf:
+  case Builtin::BI__builtin_expf:
+  case Builtin::BI__builtin_expf128:
+return true;
+  }
+  // TODO: support more FP math libcalls
+  return false;
+}();
+
+if (IntrinsicID) {
+  llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+  MDNode *RootMD = CGF.CGM.getTBAARoot();
+  // Emit "int" TBAA metadata on FP math libcalls.
+  MDNode *AliasType = MDHelper.createTBAANode("int", RootMD);

efriedma-quic wrote:

Looked it up; should be `CGM.getTBAATypeInfo(Context.IntTy)`?

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,llvm,mlir,polly` at step 6 
"build-unified-tree".

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

Here is the relevant piece of the build log for the reference:
```
Step 6 (build-unified-tree) failure: build (failure)
...
349.209 [3512/58/2037] Building CXX object 
tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
349.616 [3511/58/2038] Building CXX object 
tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/InterpreterUtils.cpp.o
349.917 [3510/58/2039] Building CXX object 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
349.986 [3509/58/2040] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/XCore.cpp.o
351.696 [3508/58/2041] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGDebugInfo.cpp.o
351.733 [3507/58/2042] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/X86.cpp.o
353.616 [3506/58/2043] Building CXX object 
tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/IncrementalParser.cpp.o
353.744 [3505/58/2044] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGOpenMPRuntime.cpp.o
354.405 [3504/58/2045] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenPGO.cpp.o
354.757 [3503/58/2046] Building CXX object 
examples/Kaleidoscope/Chapter7/CMakeFiles/Kaleidoscope-Ch7.dir/toy.cpp.o
FAILED: 
examples/Kaleidoscope/Chapter7/CMakeFiles/Kaleidoscope-Ch7.dir/toy.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/build/buildbot/premerge-monolithic-linux/build/examples/Kaleidoscope/Chapter7
 
-I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/examples/Kaleidoscope/Chapter7
 -I/build/buildbot/premerge-monolithic-linux/build/include 
-I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include -gmlt 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG  -fno-exceptions 
-funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT 
examples/Kaleidoscope/Chapter7/CMakeFiles/Kaleidoscope-Ch7.dir/toy.cpp.o -MF 
examples/Kaleidoscope/Chapter7/CMakeFiles/Kaleidoscope-Ch7.dir/toy.cpp.o.d -o 
examples/Kaleidoscope/Chapter7/CMakeFiles/Kaleidoscope-Ch7.dir/toy.cpp.o -c 
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/examples/Kaleidoscope/Chapter7/toy.cpp:747:15:
 error: no matching constructor for initialization of 'IRBuilder<>'
  IRBuilder<> TmpB(>getEntryBlock(),
  ^~~
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2656:12:
 note: candidate constructor not viable: no known conversion from 'iterator' 
(aka 'ilist_iterator_w_bits, false, false>') to 'MDNode *' for 
2nd argument
  explicit IRBuilder(InsertPosition IP, MDNode *FPMathTag = nullptr,
   ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2663:12:
 note: candidate constructor not viable: no known conversion from 'iterator' 
(aka 'ilist_iterator_w_bits, false, false>') to 
'llvm::ConstantFolder' for 2nd argument
  explicit IRBuilder(InsertPosition IP, FolderTy Folder,
   ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2646:3:
 note: candidate constructor not viable: no known conversion from 'BasicBlock 
*' to 'LLVMContext &' for 1st argument
  IRBuilder(LLVMContext , FolderTy Folder, InserterTy Inserter = InserterTy(),
  ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2652:12:
 note: candidate constructor not viable: no known conversion from 'BasicBlock 
*' to 'LLVMContext &' for 1st argument
  explicit IRBuilder(LLVMContext , MDNode *FPMathTag = nullptr,
   ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2674:3:
 note: candidate constructor not viable: requires 1 argument, but 2 were 
provided
  IRBuilder(const IRBuilder &) = delete;
  ^
1 error generated.
357.285 [3503/57/2047] Building CXX object 

[clang] e6ec366 - [clang][Interp] Fix classifying __builtin_addressof() argument

2024-06-24 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-06-24T19:27:28+02:00
New Revision: e6ec3664cb72fd95669cb516b21572da4236fd91

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

LOG: [clang][Interp] Fix classifying __builtin_addressof() argument

It's an lvalue, so we need to use the classify() taking an expression.

Added: 


Modified: 
clang/lib/AST/Interp/InterpBuiltin.cpp
clang/test/AST/Interp/functions.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index aeb6ec42eb39e..98928b3c22d7c 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -609,8 +609,8 @@ static bool interp__builtin_addressof(InterpState , 
CodePtr OpPC,
   const InterpFrame *Frame,
   const Function *Func,
   const CallExpr *Call) {
-  PrimType PtrT =
-  S.getContext().classify(Call->getArg(0)->getType()).value_or(PT_Ptr);
+  assert(Call->getArg(0)->isLValue());
+  PrimType PtrT = S.getContext().classify(Call->getArg(0)).value_or(PT_Ptr);
 
   if (PtrT == PT_FnPtr) {
 const FunctionPointer  = S.Stk.peek();

diff  --git a/clang/test/AST/Interp/functions.cpp 
b/clang/test/AST/Interp/functions.cpp
index 10c62a43ef33b..f43be1d3c0403 100644
--- a/clang/test/AST/Interp/functions.cpp
+++ b/clang/test/AST/Interp/functions.cpp
@@ -473,6 +473,10 @@ namespace AddressOf {
 
   constexpr _Complex float F = {3, 4};
   static_assert(__builtin_addressof(F) == , "");
+
+  void testAddressof(int x) {
+static_assert( == __builtin_addressof(x), "");
+  }
 }
 
 namespace std {



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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits

https://github.com/mattweingarten updated 
https://github.com/llvm/llvm-project/pull/94264

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add support for builtin_verbose_trap (PR #79230)

2024-06-24 Thread David Blaikie via cfe-commits

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


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


[clang] Add support for builtin_verbose_trap (PR #79230)

2024-06-24 Thread David Blaikie via cfe-commits


@@ -28,7 +29,7 @@ namespace llvm {
 }
 
 // Prefix of the name of the artificial inline frame.
-#define CLANG_TRAP_PREFIX "__clang_trap_msg"
+inline constexpr llvm::StringRef CLANG_TRAP_PREFIX = "__clang_trap_msg";

dwblaikie wrote:

The name should be changed to use the usual variable/constant naming convention 
(ClangTrapPrefix, I think, in this case).

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


[clang] Add support for builtin_verbose_trap (PR #79230)

2024-06-24 Thread David Blaikie via cfe-commits

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


[clang] [clang] Improve diagnostics for constraints of inline asm (NFC) (PR #96363)

2024-06-24 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

In a lot of cases, we report_fatal_error because we don't actually expect users 
to run into the issues... indicate some internal inconsistency in the compiler, 
or some unsupported configuration, or something like that.  Because of this, 
report_fatal_error prints the standard "report a bug" crash message.   For 
inline asm specifically, emitError from the backend is probably best in most 
cases, so non-clang frontends get better diagnostics, and we don't have to 
duplicate code.

> In other words we have to return something wrong intentionally to continue 
> compilation

Yes, this can be a bit tricky in some cases, but usually there's something 
straightforward you can do (for example, drop the inline asm stmt).  Note that 
we don't actually generate an output file, so it doesn't matter what you do as 
long as it doesn't cause something else to crash.

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


[clang] Add support for builtin_verbose_trap (PR #79230)

2024-06-24 Thread Akira Hatanaka via cfe-commits

https://github.com/ahatanak updated 
https://github.com/llvm/llvm-project/pull/79230

>From 95200f3bb3859738981240a9d8c503a13ede9601 Mon Sep 17 00:00:00 2001
From: Akira Hatanaka 
Date: Tue, 16 Jan 2024 13:18:09 -0800
Subject: [PATCH 01/18] Add support for builtin_verbose_trap

The builtin causes the program to stop its execution abnormally and shows a
human-readable description of the reason for the termination when a debugger is
attached or in a symbolicated crash log.

The motivation for the builtin is explained in the following RFC:

https://discourse.llvm.org/t/rfc-adding-builtin-verbose-trap-string-literal/75845
---
 clang/docs/LanguageExtensions.rst | 49 ++-
 clang/include/clang/AST/Expr.h|  5 ++
 clang/include/clang/Basic/Builtins.td |  6 +++
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/lib/AST/ExprConstant.cpp| 18 +--
 clang/lib/CodeGen/CGBuiltin.cpp   | 12 +
 clang/lib/CodeGen/CGDebugInfo.cpp | 42 
 clang/lib/CodeGen/CGDebugInfo.h   | 20 
 clang/lib/Sema/SemaChecking.cpp   | 22 +
 .../CodeGenCXX/debug-info-verbose-trap.cpp| 49 +++
 clang/test/SemaCXX/verbose-trap.cpp   | 28 +++
 11 files changed, 249 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/debug-info-verbose-trap.cpp
 create mode 100644 clang/test/SemaCXX/verbose-trap.cpp

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa8..1dd8d3bcec920 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3467,6 +3467,54 @@ Query for this feature with 
``__has_builtin(__builtin_trap)``.
 
 ``__builtin_arm_trap`` is lowered to the ``llvm.aarch64.break`` builtin, and 
then to ``brk #payload``.
 
+``__builtin_verbose_trap``
+--
+
+``__builtin_verbose_trap`` causes the program to stop its execution abnormally
+and shows a human-readable description of the reason for the termination when a
+debugger is attached or in a symbolicated crash log.
+
+**Syntax**:
+
+.. code-block:: c++
+
+__builtin_verbose_trap(const char *reason)
+
+**Description**
+
+``__builtin_verbose_trap`` is lowered to the ` ``llvm.trap`` 
`_ builtin.
+Additionally, clang emits debug metadata that represents an artificial inline
+frame whose name encodes the string passed to the builtin, prefixed by a 
"magic"
+prefix.
+
+For example, consider the following code:
+
+.. code-block:: c++
+
+void foo(int* p) {
+  if (p == nullptr)
+__builtin_verbose_trap("Argument_must_not_be_null");
+}
+
+The debug metadata would look as if it were produced for the following code:
+
+.. code-block:: c++
+
+__attribute__((always_inline))
+inline void "__llvm_verbose_trap: Argument_must_not_be_null"() {
+  __builtin_trap();
+}
+
+void foo(int* p) {
+  if (p == nullptr)
+"__llvm_verbose_trap: Argument_must_not_be_null"();
+}
+
+However, the LLVM IR would not actually contain a call to the artificial
+function — it only exists in the debug metadata.
+
+Query for this feature with ``__has_builtin(__builtin_verbose_trap)``.
+
 ``__builtin_allow_runtime_check``
 -
 
@@ -3514,7 +3562,6 @@ guarded check. It's unused now. It will enable 
kind-specific lowering in future.
 E.g. a higher hotness cutoff can be used for more expensive kind of check.
 
 Query for this feature with ``__has_builtin(__builtin_allow_runtime_check)``.
-
 ``__builtin_nondeterministic_value``
 
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 2bfefeabc348b..9606a5fddd47e 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -787,6 +787,11 @@ class Expr : public ValueStmt {
  const Expr *PtrExpression, ASTContext ,
  EvalResult ) const;
 
+  /// If the current Expr can be evaluated to a pointer to a null-terminated
+  /// constant string, return the constant string (without the terminating 
null)
+  /// in Result. Return true if it succeeds.
+  bool tryEvaluateString(std::string , ASTContext ) const;
+
   /// Enumeration used to describe the kind of Null pointer constant
   /// returned from \c isNullPointerConstant().
   enum NullPointerConstantKind {
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index de721a87b3341..5b3b9d04e576a 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1152,6 +1152,12 @@ def Trap : Builtin {
   let Prototype = "void()";
 }
 
+def VerboseTrap : Builtin {
+  let Spellings = ["__builtin_verbose_trap"];
+  let Attributes = [NoThrow, NoReturn];
+  let Prototype = "void(char 

[clang] [flang] [Flang][Driver] Add -print-resource-dir command line flag to emit Flang's resource directory (PR #90886)

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

DavidTruby wrote:

Hi @mjklemm, this appears to be breaking linking entirely on Windows, I'm not 
sure how it's taken us so long to notice...
With the patch I get errors trying to find compiler-rt but without it I can 
build fine. I wonder why this patch _changed_ the resource directory, as well 
as making it printable with a flag?

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread Stephen Tozer via cfe-commits

SLTozer wrote:

Looks like I missed a spot - reverting for now, will wait for a bit to see if 
any other errors fall out from the various configurations on CI before 
reapplying.

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


[clang] added regcall struct by reg support (PR #95257)

2024-06-24 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> I don't have any context beyond what's written on 
> https://reviews.llvm.org/D25204 . And at this point, I'm not sure what 
> compiler we're trying to be compatible with. (I added @erichkeane in case he 
> remembers.)

The original feature was written for compatibility with ICC and the fixes are 
also for compatibility with ICC.

> Do you know why currently clang does not do that ? is there different version 
> of regcall spec it follows?

I suspect this was an oversight, but @erichkeane may recall more specific 
details (note, he's out on leave until Sept, so I don't expect to hear back 
from him any time soon). AFAIK, the spec you linked is the correct one for us 
to follow.

> Also if we add new regcall struct implementation, would that break binaries 
> across clang version?

It would be an ABI break because we'd start passing structures differently. 
However, we have ABI tags; we can implement the new functionality under an ABI 
tag so users can get the old ABI still if they need to (search for `AbiTagAttr` 
to see examples of how we do this elsewhere and how we test for it).

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


[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-06-24 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

This is roughly what I expected the patch to look like.  Maybe consider adding 
a couple small wrapper functions around isEmptyRecord/isEmptyField to simplify 
the uses (and so we can use a name that indicates why the checks exist).

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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-24 Thread Jannick Kremer via cfe-commits

https://github.com/DeinAlptraum updated 
https://github.com/llvm/llvm-project/pull/95608

>From 35bfcfbc69ee812c59350440b7b15c5e23ad1307 Mon Sep 17 00:00:00 2001
From: Jannick Kremer 
Date: Fri, 14 Jun 2024 22:12:09 +0100
Subject: [PATCH 1/2] [libclang/python] Refactor enum usage

Use Python's builtin enum class instead of writing our own.

This is preparation for strict typing in PR #78114
---
 clang/bindings/python/clang/cindex.py | 1670 -
 .../python/tests/cindex/test_enums.py |   14 +-
 2 files changed, 768 insertions(+), 916 deletions(-)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index b3d51e4d2a668..aacfc333723c4 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -68,6 +68,7 @@
 
 import collections.abc
 import os
+from enum import Enum
 
 
 # Python 3 strings are unicode, translate them to/from utf8 for C-interop.
@@ -611,51 +612,25 @@ def register(value, name):
 
 
 ### Cursor Kinds ###
-class BaseEnumeration:
+class BaseEnumeration(Enum):
 """
 Common base class for named enumerations held in sync with Index.h values.
-
-Subclasses must define their own _kinds and _name_map members, as:
-_kinds = []
-_name_map = None
-These values hold the per-subclass instances and value-to-name mappings,
-respectively.
-
 """
 
-def __init__(self, value):
-if value >= len(self.__class__._kinds):
-self.__class__._kinds += [None] * (value - 
len(self.__class__._kinds) + 1)
-if self.__class__._kinds[value] is not None:
-raise ValueError(
-"{0} value {1} already loaded".format(str(self.__class__), 
value)
-)
-self.value = value
-self.__class__._kinds[value] = self
-self.__class__._name_map = None
 
 def from_param(self):
 return self.value
 
-@property
-def name(self):
-"""Get the enumeration name of this cursor kind."""
-if self._name_map is None:
-self._name_map = {}
-for key, value in self.__class__.__dict__.items():
-if isinstance(value, self.__class__):
-self._name_map[value] = key
-return self._name_map[self]
-
 @classmethod
 def from_id(cls, id):
-if id < 0 or id >= len(cls._kinds) or cls._kinds[id] is None:
-raise ValueError("Unknown template argument kind %d" % id)
-return cls._kinds[id]
+try:
+return cls(id)
+except ValueError:
+raise ValueError("Unknown %s %d" % (cls.__name__, id)) from None
 
 def __repr__(self):
 return "%s.%s" % (
-self.__class__,
+self.__class__.__name__,
 self.name,
 )
 
@@ -665,14 +640,10 @@ class CursorKind(BaseEnumeration):
 A CursorKind describes the kind of entity that a cursor points to.
 """
 
-# The required BaseEnumeration declarations.
-_kinds = []
-_name_map = None
-
 @staticmethod
 def get_all_kinds():
 """Return all CursorKind enumeration instances."""
-return [x for x in CursorKind._kinds if not x is None]
+return list(CursorKind)
 
 def is_declaration(self):
 """Test if this is a declaration kind."""
@@ -710,822 +681,820 @@ def is_unexposed(self):
 """Test if this is an unexposed kind."""
 return conf.lib.clang_isUnexposed(self)
 
-def __repr__(self):
-return "CursorKind.%s" % (self.name,)
-
 
-###
-# Declaration Kinds
+###
+# Declaration Kinds
 
-# A declaration whose specific kind is not exposed via this interface.
-#
-# Unexposed declarations have the same operations as any other kind of
-# declaration; one can extract their location information, spelling, find their
-# definitions, etc. However, the specific kind of the declaration is not
-# reported.
-CursorKind.UNEXPOSED_DECL = CursorKind(1)
+# A declaration whose specific kind is not exposed via this interface.
+#
+# Unexposed declarations have the same operations as any other kind of
+# declaration; one can extract their location information, spelling, find
+# their definitions, etc. However, the specific kind of the declaration is
+# not reported.
+UNEXPOSED_DECL = 1
 
-# A C or C++ struct.
-CursorKind.STRUCT_DECL = CursorKind(2)
+# A C or C++ struct.
+STRUCT_DECL = 2
 
-# A C or C++ union.
-CursorKind.UNION_DECL = CursorKind(3)
+# A C or C++ union.
+UNION_DECL = 3
 
-# A C++ class.
-CursorKind.CLASS_DECL = CursorKind(4)
+# A C++ class.
+CLASS_DECL = 4
 
-# An enumeration.
-CursorKind.ENUM_DECL = CursorKind(5)
+# An enumeration.
+ENUM_DECL = 5
 
-# A field (in C) or non-static data member (in C++) in a struct, union, or C++
-# class.
-CursorKind.FIELD_DECL = CursorKind(6)
+# A field (in C) or non-static data member (in C++) in a struct, union, or
+# C++ class.

[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-24 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
cc7a18c18011d1e0c70187ceb60e3e69bf7cd0ee...82f120f207a4a9425cdbccafdba8974bc00ffc51
 clang/bindings/python/clang/cindex.py 
clang/bindings/python/tests/cindex/test_enums.py 
clang/bindings/python/tests/cindex/test_token_kind.py
``





View the diff from darker here.


``diff
--- clang/cindex.py 2024-06-24 16:45:44.00 +
+++ clang/cindex.py 2024-06-24 16:49:25.859947 +
@@ -600,11 +600,11 @@
 
 @classmethod
 def from_value(cls, value):
 """Obtain a registered TokenKind instance from its value."""
 return cls.from_id(value)
-
+
 PUNCTUATION = 0
 KEYWORD = 1
 IDENTIFIER = 2
 LITERAL = 3
 COMMENT = 4

``




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


[clang] [libclang/python] Refactor enum usage (PR #95608)

2024-06-24 Thread Jannick Kremer via cfe-commits

https://github.com/DeinAlptraum updated 
https://github.com/llvm/llvm-project/pull/95608

>From 35bfcfbc69ee812c59350440b7b15c5e23ad1307 Mon Sep 17 00:00:00 2001
From: Jannick Kremer 
Date: Fri, 14 Jun 2024 22:12:09 +0100
Subject: [PATCH 1/2] [libclang/python] Refactor enum usage

Use Python's builtin enum class instead of writing our own.

This is preparation for strict typing in PR #78114
---
 clang/bindings/python/clang/cindex.py | 1670 -
 .../python/tests/cindex/test_enums.py |   14 +-
 2 files changed, 768 insertions(+), 916 deletions(-)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index b3d51e4d2a668..aacfc333723c4 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -68,6 +68,7 @@
 
 import collections.abc
 import os
+from enum import Enum
 
 
 # Python 3 strings are unicode, translate them to/from utf8 for C-interop.
@@ -611,51 +612,25 @@ def register(value, name):
 
 
 ### Cursor Kinds ###
-class BaseEnumeration:
+class BaseEnumeration(Enum):
 """
 Common base class for named enumerations held in sync with Index.h values.
-
-Subclasses must define their own _kinds and _name_map members, as:
-_kinds = []
-_name_map = None
-These values hold the per-subclass instances and value-to-name mappings,
-respectively.
-
 """
 
-def __init__(self, value):
-if value >= len(self.__class__._kinds):
-self.__class__._kinds += [None] * (value - 
len(self.__class__._kinds) + 1)
-if self.__class__._kinds[value] is not None:
-raise ValueError(
-"{0} value {1} already loaded".format(str(self.__class__), 
value)
-)
-self.value = value
-self.__class__._kinds[value] = self
-self.__class__._name_map = None
 
 def from_param(self):
 return self.value
 
-@property
-def name(self):
-"""Get the enumeration name of this cursor kind."""
-if self._name_map is None:
-self._name_map = {}
-for key, value in self.__class__.__dict__.items():
-if isinstance(value, self.__class__):
-self._name_map[value] = key
-return self._name_map[self]
-
 @classmethod
 def from_id(cls, id):
-if id < 0 or id >= len(cls._kinds) or cls._kinds[id] is None:
-raise ValueError("Unknown template argument kind %d" % id)
-return cls._kinds[id]
+try:
+return cls(id)
+except ValueError:
+raise ValueError("Unknown %s %d" % (cls.__name__, id)) from None
 
 def __repr__(self):
 return "%s.%s" % (
-self.__class__,
+self.__class__.__name__,
 self.name,
 )
 
@@ -665,14 +640,10 @@ class CursorKind(BaseEnumeration):
 A CursorKind describes the kind of entity that a cursor points to.
 """
 
-# The required BaseEnumeration declarations.
-_kinds = []
-_name_map = None
-
 @staticmethod
 def get_all_kinds():
 """Return all CursorKind enumeration instances."""
-return [x for x in CursorKind._kinds if not x is None]
+return list(CursorKind)
 
 def is_declaration(self):
 """Test if this is a declaration kind."""
@@ -710,822 +681,820 @@ def is_unexposed(self):
 """Test if this is an unexposed kind."""
 return conf.lib.clang_isUnexposed(self)
 
-def __repr__(self):
-return "CursorKind.%s" % (self.name,)
-
 
-###
-# Declaration Kinds
+###
+# Declaration Kinds
 
-# A declaration whose specific kind is not exposed via this interface.
-#
-# Unexposed declarations have the same operations as any other kind of
-# declaration; one can extract their location information, spelling, find their
-# definitions, etc. However, the specific kind of the declaration is not
-# reported.
-CursorKind.UNEXPOSED_DECL = CursorKind(1)
+# A declaration whose specific kind is not exposed via this interface.
+#
+# Unexposed declarations have the same operations as any other kind of
+# declaration; one can extract their location information, spelling, find
+# their definitions, etc. However, the specific kind of the declaration is
+# not reported.
+UNEXPOSED_DECL = 1
 
-# A C or C++ struct.
-CursorKind.STRUCT_DECL = CursorKind(2)
+# A C or C++ struct.
+STRUCT_DECL = 2
 
-# A C or C++ union.
-CursorKind.UNION_DECL = CursorKind(3)
+# A C or C++ union.
+UNION_DECL = 3
 
-# A C++ class.
-CursorKind.CLASS_DECL = CursorKind(4)
+# A C++ class.
+CLASS_DECL = 4
 
-# An enumeration.
-CursorKind.ENUM_DECL = CursorKind(5)
+# An enumeration.
+ENUM_DECL = 5
 
-# A field (in C) or non-static data member (in C++) in a struct, union, or C++
-# class.
-CursorKind.FIELD_DECL = CursorKind(6)
+# A field (in C) or non-static data member (in C++) in a struct, union, or
+# C++ class.

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits


@@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap ) {
 
   return true;
 }
+#elif defined(__linux__) && defined(__riscv)
+// struct riscv_hwprobe
+struct RISCVHwProbe {
+  int64_t Key;
+  uint64_t Value;
+};
+bool sys::getHostCPUFeatures(StringMap ) {
+  RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_BASE_BEHAVIOR=*/3, 0},
+   {/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}};
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/Query,
+/*pair_count=*/std::size(Query), /*cpu_count=*/0,
+/*cpus=*/0, /*flags=*/0);
+  if (Ret != 0)
+return false;
+
+  uint64_t BaseMask = Query[0].Value;
+  // Check whether RISCV_HWPROBE_BASE_BEHAVIOR_IMA is set.
+  if (BaseMask & 1) {
+Features["i"] = true;
+Features["m"] = true;
+Features["a"] = true;
+  }
+
+  uint64_t ExtMask = Query[1].Value;
+  Features["f"] = ExtMask & (1 << 0);   // RISCV_HWPROBE_IMA_FD
+  Features["d"] = ExtMask & (1 << 0);   // RISCV_HWPROBE_IMA_FD
+  Features["c"] = ExtMask & (1 << 1);   // RISCV_HWPROBE_IMA_C
+  Features["v"] = ExtMask & (1 << 2);   // RISCV_HWPROBE_IMA_V
+  Features["zba"] = ExtMask & (1 << 3); // RISCV_HWPROBE_EXT_ZBA
+  Features["zbb"] = ExtMask & (1 << 4); // RISCV_HWPROBE_EXT_ZBB
+  Features["zbs"] = ExtMask & (1 << 5); // RISCV_HWPROBE_EXT_ZBS
+  Features["zicboz"] = ExtMask & (1 << 6);  // RISCV_HWPROBE_EXT_ZICBOZ
+  Features["zbc"] = ExtMask & (1 << 7); // RISCV_HWPROBE_EXT_ZBC
+  Features["zbkb"] = ExtMask & (1 << 8);// RISCV_HWPROBE_EXT_ZBKB
+  Features["zbkc"] = ExtMask & (1 << 9);// RISCV_HWPROBE_EXT_ZBKC
+  Features["zbkx"] = ExtMask & (1 << 10);   // RISCV_HWPROBE_EXT_ZBKX
+  Features["zknd"] = ExtMask & (1 << 11);   // RISCV_HWPROBE_EXT_ZKND
+  Features["zkne"] = ExtMask & (1 << 12);   // RISCV_HWPROBE_EXT_ZKNE
+  Features["zknh"] = ExtMask & (1 << 13);   // RISCV_HWPROBE_EXT_ZKNH
+  Features["zksed"] = ExtMask & (1 << 14);  // RISCV_HWPROBE_EXT_ZKSED
+  Features["zksh"] = ExtMask & (1 << 15);   // RISCV_HWPROBE_EXT_ZKSH
+  Features["zkt"] = ExtMask & (1 << 16);// RISCV_HWPROBE_EXT_ZKT
+  Features["zvbb"] = ExtMask & (1 << 17);   // RISCV_HWPROBE_EXT_ZVBB
+  Features["zvbc"] = ExtMask & (1 << 18);   // RISCV_HWPROBE_EXT_ZVBC
+  Features["zvkb"] = ExtMask & (1 << 19);   // RISCV_HWPROBE_EXT_ZVKB
+  Features["zvkg"] = ExtMask & (1 << 20);   // RISCV_HWPROBE_EXT_ZVKG
+  Features["zvkned"] = ExtMask & (1 << 21); // RISCV_HWPROBE_EXT_ZVKNED
+  Features["zvknha"] = ExtMask & (1 << 22); // RISCV_HWPROBE_EXT_ZVKNHA
+  Features["zvknhb"] = ExtMask & (1 << 23); // RISCV_HWPROBE_EXT_ZVKNHB
+  Features["zvksed"] = ExtMask & (1 << 24); // RISCV_HWPROBE_EXT_ZVKSED
+  Features["zvksh"] = ExtMask & (1 << 25);  // RISCV_HWPROBE_EXT_ZVKSH
+  Features["zvkt"] = ExtMask & (1 << 26);   // RISCV_HWPROBE_EXT_ZVKT
+  Features["zfh"] = ExtMask & (1 << 27);// RISCV_HWPROBE_EXT_ZFH
+  Features["zfhmin"] = ExtMask & (1 << 28); // RISCV_HWPROBE_EXT_ZFHMIN
+  Features["zihintntl"] = ExtMask & (1 << 29);  // RISCV_HWPROBE_EXT_ZIHINTNTL
+  Features["zvfh"] = ExtMask & (1 << 30);   // RISCV_HWPROBE_EXT_ZVFH
+  Features["zvfhmin"] = ExtMask & (1ULL << 31); // RISCV_HWPROBE_EXT_ZVFHMIN
+  Features["zfa"] = ExtMask & (1ULL << 32); // RISCV_HWPROBE_EXT_ZFA
+  // TODO: set ztso when it is no longer experimental.
+  // Features["ztso"] = ExtMask & (1ULL << 33);// RISCV_HWPROBE_EXT_ZTSO

dtcxzyw wrote:

Hwprobe docs says the core supports Ztso ***v1.0*** when RISCV_HWPROBE_EXT_ZTSO 
is set.
> RISCV_HWPROBE_EXT_ZTSO: The Ztso extension is supported as
defined in the RISC-V ISA manual starting from [commit 
5618fb5a216b](https://github.com/riscv/riscv-isa-manual/commit/5618fb5a216b6eb76cbd2b1c8e3d1b55628a072a)
 (“Ztso is now ratified.”)

I don't think it's appropriate to add experimental features for users.


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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread Stephen Tozer via cfe-commits

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


[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Craig Topper via cfe-commits


@@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap ) {
 
   return true;
 }
+#elif defined(__linux__) && defined(__riscv)
+// struct riscv_hwprobe
+struct RISCVHwProbe {
+  int64_t Key;
+  uint64_t Value;
+};
+bool sys::getHostCPUFeatures(StringMap ) {
+  RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_BASE_BEHAVIOR=*/3, 0},
+   {/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}};
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/Query,
+/*pair_count=*/std::size(Query), /*cpu_count=*/0,
+/*cpus=*/0, /*flags=*/0);
+  if (Ret != 0)
+return false;
+
+  uint64_t BaseMask = Query[0].Value;
+  // Check whether RISCV_HWPROBE_BASE_BEHAVIOR_IMA is set.
+  if (BaseMask & 1) {
+Features["i"] = true;
+Features["m"] = true;
+Features["a"] = true;
+  }
+
+  uint64_t ExtMask = Query[1].Value;
+  Features["f"] = ExtMask & (1 << 0);   // RISCV_HWPROBE_IMA_FD
+  Features["d"] = ExtMask & (1 << 0);   // RISCV_HWPROBE_IMA_FD
+  Features["c"] = ExtMask & (1 << 1);   // RISCV_HWPROBE_IMA_C
+  Features["v"] = ExtMask & (1 << 2);   // RISCV_HWPROBE_IMA_V
+  Features["zba"] = ExtMask & (1 << 3); // RISCV_HWPROBE_EXT_ZBA
+  Features["zbb"] = ExtMask & (1 << 4); // RISCV_HWPROBE_EXT_ZBB
+  Features["zbs"] = ExtMask & (1 << 5); // RISCV_HWPROBE_EXT_ZBS
+  Features["zicboz"] = ExtMask & (1 << 6);  // RISCV_HWPROBE_EXT_ZICBOZ
+  Features["zbc"] = ExtMask & (1 << 7); // RISCV_HWPROBE_EXT_ZBC
+  Features["zbkb"] = ExtMask & (1 << 8);// RISCV_HWPROBE_EXT_ZBKB
+  Features["zbkc"] = ExtMask & (1 << 9);// RISCV_HWPROBE_EXT_ZBKC
+  Features["zbkx"] = ExtMask & (1 << 10);   // RISCV_HWPROBE_EXT_ZBKX
+  Features["zknd"] = ExtMask & (1 << 11);   // RISCV_HWPROBE_EXT_ZKND
+  Features["zkne"] = ExtMask & (1 << 12);   // RISCV_HWPROBE_EXT_ZKNE
+  Features["zknh"] = ExtMask & (1 << 13);   // RISCV_HWPROBE_EXT_ZKNH
+  Features["zksed"] = ExtMask & (1 << 14);  // RISCV_HWPROBE_EXT_ZKSED
+  Features["zksh"] = ExtMask & (1 << 15);   // RISCV_HWPROBE_EXT_ZKSH
+  Features["zkt"] = ExtMask & (1 << 16);// RISCV_HWPROBE_EXT_ZKT
+  Features["zvbb"] = ExtMask & (1 << 17);   // RISCV_HWPROBE_EXT_ZVBB
+  Features["zvbc"] = ExtMask & (1 << 18);   // RISCV_HWPROBE_EXT_ZVBC
+  Features["zvkb"] = ExtMask & (1 << 19);   // RISCV_HWPROBE_EXT_ZVKB
+  Features["zvkg"] = ExtMask & (1 << 20);   // RISCV_HWPROBE_EXT_ZVKG
+  Features["zvkned"] = ExtMask & (1 << 21); // RISCV_HWPROBE_EXT_ZVKNED
+  Features["zvknha"] = ExtMask & (1 << 22); // RISCV_HWPROBE_EXT_ZVKNHA
+  Features["zvknhb"] = ExtMask & (1 << 23); // RISCV_HWPROBE_EXT_ZVKNHB
+  Features["zvksed"] = ExtMask & (1 << 24); // RISCV_HWPROBE_EXT_ZVKSED
+  Features["zvksh"] = ExtMask & (1 << 25);  // RISCV_HWPROBE_EXT_ZVKSH
+  Features["zvkt"] = ExtMask & (1 << 26);   // RISCV_HWPROBE_EXT_ZVKT
+  Features["zfh"] = ExtMask & (1 << 27);// RISCV_HWPROBE_EXT_ZFH
+  Features["zfhmin"] = ExtMask & (1 << 28); // RISCV_HWPROBE_EXT_ZFHMIN
+  Features["zihintntl"] = ExtMask & (1 << 29);  // RISCV_HWPROBE_EXT_ZIHINTNTL
+  Features["zvfh"] = ExtMask & (1 << 30);   // RISCV_HWPROBE_EXT_ZVFH
+  Features["zvfhmin"] = ExtMask & (1ULL << 31); // RISCV_HWPROBE_EXT_ZVFHMIN
+  Features["zfa"] = ExtMask & (1ULL << 32); // RISCV_HWPROBE_EXT_ZFA
+  // TODO: set ztso when it is no longer experimental.
+  // Features["ztso"] = ExtMask & (1ULL << 33);// RISCV_HWPROBE_EXT_ZTSO

topperc wrote:

I think I missed why "experimental-ztso" doesn't work.

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


[clang] [MS ABI]: Support preserve_none in MS ABI (PR #96487)

2024-06-24 Thread Aaron Ballman via cfe-commits

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

Generally LGTM, though the changes should come with a release note in 
`clang/docs/ReleaseNotes.rst` so users know about the fix.

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


[clang] [MS ABI]: Support preserve_none in MS ABI (PR #96487)

2024-06-24 Thread Aaron Ballman via cfe-commits

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


[clang] [compiler-rt] [llvm] [PAC][AArch64] Support init/fini array signing (PR #96478)

2024-06-24 Thread Anton Korobeynikov via cfe-commits

asl wrote:

Can we have LLVM IR test as well?

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


[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits

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


[clang] [Clang] use parent declaration context to avoid asserting cast failure in defaulted comparison method (PR #96228)

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


@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s

a-tarasyuk wrote:

@shafik Thanks for the feedback. I've moved the test to the appropriate 
existing test. From my understanding, the crash is related to this

https://github.com/llvm/llvm-project/blob/f985a8826bfa4ca3d23e654185de35e30ea6dc79/clang/include/clang/AST/DeclBase.h#L897-L914

In the case of `void s::f()`, `getLexicalParent` returned the global context, 
which caused the crash. Does that make sense? Or is there a better way to 
handle this? Please let me know what your thoughts are about that case.

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread Stephen Tozer via cfe-commits

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


[clang] [llvm] [llvm][ProfDataUtils] provide getNumBranchWeights API (PR #90146)

2024-06-24 Thread Paul Kirth via cfe-commits

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


[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-06-24 Thread Michael Buch via cfe-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/96422

>From f5938919b3a0060db6b373bead1c52f4bb65c841 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 21 Jun 2024 12:15:07 +0100
Subject: [PATCH 1/4] [clang][CGRecordLayout] Remove dependency on isZeroSize

This is a follow-up from the conversation starting at
https://github.com/llvm/llvm-project/pull/93809#issuecomment-2173729801

The root problem that motivated the change are external AST
sources that compute `ASTRecordLayout`s themselves instead of
letting Clang compute them from the AST. One such examples is
LLDB using DWARF to get the definitive offsets and sizes of C++
structures. Such layouts should be considered correct (modulo
buggy DWARF), but various assertions and lowering logic around
the `CGRecordLayoutBuilder` relies on the AST having
`[[no_unique_address]]` attached to them. This is a layout-altering
attribute which is not encoded in DWARF. This causes us LLDB to trip
over the various LLVM<->Clang layout consistency checks. There has been
precedent for avoiding such layout-altering attributes to affect
lowering with externally-provided layouts (e.g., packed structs).

This patch proposes to replace the `isZeroSize` checks in
`CGRecordLayoutBuilder` (which roughly means "empty field
with [[no_unique_address]]") with checks for
`CodeGen::isEmptyField`/`CodeGen::isEmptyRecord`.
---
 clang/lib/CodeGen/ABIInfoImpl.cpp |  6 ++---
 clang/lib/CodeGen/ABIInfoImpl.h   |  6 ++---
 clang/lib/CodeGen/CGExpr.cpp  |  3 ++-
 clang/lib/CodeGen/CGRecordLayoutBuilder.cpp   | 14 ++--
 clang/test/CodeGen/X86/x86_64-vaarg.c |  3 ++-
 clang/test/CodeGen/debug-info-packed-struct.c |  2 +-
 clang/test/CodeGen/paren-list-agg-init.cpp| 15 +
 .../CodeGenCXX/2011-12-19-init-list-ctor.cpp  |  6 ++---
 clang/test/CodeGenCXX/auto-var-init.cpp   | 10 -
 .../test/CodeGenCXX/bitfield-access-empty.cpp | 16 +++---
 clang/test/CodeGenCXX/class-layout.cpp|  2 +-
 clang/test/CodeGenCXX/compound-literals.cpp   |  2 +-
 clang/test/CodeGenCXX/exceptions.cpp  |  7 +++---
 .../lambda-deterministic-captures.cpp |  4 +---
 clang/test/CodeGenCXX/ms_struct.cpp   |  4 +---
 clang/test/CodeGenCXX/partial-destruction.cpp | 11 --
 clang/test/CodeGenCXX/pr18962.cpp |  5 ++---
 clang/test/CodeGenCXX/references.cpp  |  4 +---
 clang/test/CodeGenCXX/temporaries.cpp | 12 +-
 clang/test/CodeGenObjCXX/lambda-to-block.mm   |  9 
 clang/test/OpenMP/irbuilder_for_iterator.cpp  | 10 -
 clang/test/OpenMP/irbuilder_for_rangefor.cpp  | 14 +---
 .../test/OpenMP/task_member_call_codegen.cpp  | 22 ---
 clang/test/Sema/ms_class_layout.cpp   | 14 ++--
 24 files changed, 85 insertions(+), 116 deletions(-)

diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp 
b/clang/lib/CodeGen/ABIInfoImpl.cpp
index e9a26abb77837..92fcc3bc2c5f4 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -248,7 +248,7 @@ Address CodeGen::emitMergePHI(CodeGenFunction , Address 
Addr1,
   return Address(PHI, Addr1.getElementType(), Align);
 }
 
-bool CodeGen::isEmptyField(ASTContext , const FieldDecl *FD,
+bool CodeGen::isEmptyField(const ASTContext , const FieldDecl *FD,
bool AllowArrays, bool AsIfNoUniqueAddr) {
   if (FD->isUnnamedBitField())
 return true;
@@ -289,8 +289,8 @@ bool CodeGen::isEmptyField(ASTContext , const 
FieldDecl *FD,
   return isEmptyRecord(Context, FT, AllowArrays, AsIfNoUniqueAddr);
 }
 
-bool CodeGen::isEmptyRecord(ASTContext , QualType T, bool AllowArrays,
-bool AsIfNoUniqueAddr) {
+bool CodeGen::isEmptyRecord(const ASTContext , QualType T,
+bool AllowArrays, bool AsIfNoUniqueAddr) {
   const RecordType *RT = T->getAs();
   if (!RT)
 return false;
diff --git a/clang/lib/CodeGen/ABIInfoImpl.h b/clang/lib/CodeGen/ABIInfoImpl.h
index 92986fb431646..e3f373e39c35a 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.h
+++ b/clang/lib/CodeGen/ABIInfoImpl.h
@@ -126,15 +126,15 @@ Address emitMergePHI(CodeGenFunction , Address Addr1,
 /// is an unnamed bit-field or an (array of) empty record(s). If
 /// AsIfNoUniqueAddr is true, then C++ record fields are considered empty if
 /// the [[no_unique_address]] attribute would have made them empty.
-bool isEmptyField(ASTContext , const FieldDecl *FD, bool AllowArrays,
-  bool AsIfNoUniqueAddr = false);
+bool isEmptyField(const ASTContext , const FieldDecl *FD,
+  bool AllowArrays, bool AsIfNoUniqueAddr = false);
 
 /// isEmptyRecord - Return true iff a structure contains only empty
 /// fields. Note that a structure with a flexible array member is not
 /// considered empty. If AsIfNoUniqueAddr is true, then C++ record fields are
 /// considered empty if the 

[clang] [llvm] [llvm][misexpect] Update MisExpect to use provenance tracking metadata (PR #86610)

2024-06-24 Thread Paul Kirth via cfe-commits

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread Stephen Tozer via cfe-commits


@@ -44,15 +44,19 @@ template <> struct ilist_alloc_traits {
 iterator_range::iterator>
 getDbgRecordRange(DbgMarker *);
 
+/// Class used to generate an insert position (ultimately always a
+/// BasicBlock::iterator, which it will implicitly convert to) from either:
+/// - An Instruction, inserting immediately prior.

SLTozer wrote:

It isn't deprecated yet, but I can put a comment indicating the future intent.

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


[clang] [Clang][Driver] Expose `-fno-eliminate-unused-debug-types` to clang-cl (PR #95259)

2024-06-24 Thread David Blaikie via cfe-commits

dwblaikie wrote:

> > I will say, `-fno-eliminate-unused-debug-types` is a really heavy hammer 
> > that makes debug info much larger - and my understanding was that games 
> > tended to have trouble with large debug builds, so I'd be surprised if this 
> > was a great path forward.
> 
> Absolutely, this is only a short term hack until I figure out a better way to 
> fix it.
> 
> > Do you have a small example of where Clang and MSVC differ in emitting some 
> > particular unreferenced type? I would imagine MSVC isn't emitting /every/ 
> > written type...
> 
> It's essentially the examples in #46924. A class that is only used to hold 
> some const/constexpr values. These values are then used by the .NATVIS file. 
> With `/Z7`, MSVC seems to always emit them as `S_CONSTANT`s. But in Clang 
> since the type isn't used, it is never emitted by 
> `CGDebugInfo::EmitAndRetainType()`. Setting `DebugInfo == 
> llvm::codegenoptions::UnusedTypeInfo` fixes the problem. Is there a better 
> way?

Ah, I'll take up the discussion on the issue, I think - thanks for pointing 
that out.

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


[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits


@@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap ) {
 
   return true;
 }
+#elif defined(__linux__) && defined(__riscv)
+// struct riscv_hwprobe
+struct RISCVHwProbe {
+  int64_t Key;
+  uint64_t Value;
+};
+bool sys::getHostCPUFeatures(StringMap ) {
+  RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_BASE_BEHAVIOR=*/3, 0},
+   {/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}};
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/Query,
+/*pair_count=*/std::size(Query), /*cpu_count=*/0,
+/*cpus=*/0, /*flags=*/0);
+  if (Ret != 0)
+return false;
+
+  uint64_t BaseMask = Query[0].Value;
+  // Check whether RISCV_HWPROBE_BASE_BEHAVIOR_IMA is set.
+  if (BaseMask & 1) {
+Features["i"] = true;
+Features["m"] = true;
+Features["a"] = true;
+  }
+
+  uint64_t ExtMask = Query[1].Value;
+  Features["f"] = ExtMask & (1 << 0);   // RISCV_HWPROBE_IMA_FD
+  Features["d"] = ExtMask & (1 << 0);   // RISCV_HWPROBE_IMA_FD
+  Features["c"] = ExtMask & (1 << 1);   // RISCV_HWPROBE_IMA_C
+  Features["v"] = ExtMask & (1 << 2);   // RISCV_HWPROBE_IMA_V
+  Features["zba"] = ExtMask & (1 << 3); // RISCV_HWPROBE_EXT_ZBA
+  Features["zbb"] = ExtMask & (1 << 4); // RISCV_HWPROBE_EXT_ZBB
+  Features["zbs"] = ExtMask & (1 << 5); // RISCV_HWPROBE_EXT_ZBS
+  Features["zicboz"] = ExtMask & (1 << 6);  // RISCV_HWPROBE_EXT_ZICBOZ
+  Features["zbc"] = ExtMask & (1 << 7); // RISCV_HWPROBE_EXT_ZBC
+  Features["zbkb"] = ExtMask & (1 << 8);// RISCV_HWPROBE_EXT_ZBKB
+  Features["zbkc"] = ExtMask & (1 << 9);// RISCV_HWPROBE_EXT_ZBKC
+  Features["zbkx"] = ExtMask & (1 << 10);   // RISCV_HWPROBE_EXT_ZBKX
+  Features["zknd"] = ExtMask & (1 << 11);   // RISCV_HWPROBE_EXT_ZKND
+  Features["zkne"] = ExtMask & (1 << 12);   // RISCV_HWPROBE_EXT_ZKNE
+  Features["zknh"] = ExtMask & (1 << 13);   // RISCV_HWPROBE_EXT_ZKNH
+  Features["zksed"] = ExtMask & (1 << 14);  // RISCV_HWPROBE_EXT_ZKSED
+  Features["zksh"] = ExtMask & (1 << 15);   // RISCV_HWPROBE_EXT_ZKSH
+  Features["zkt"] = ExtMask & (1 << 16);// RISCV_HWPROBE_EXT_ZKT
+  Features["zvbb"] = ExtMask & (1 << 17);   // RISCV_HWPROBE_EXT_ZVBB
+  Features["zvbc"] = ExtMask & (1 << 18);   // RISCV_HWPROBE_EXT_ZVBC
+  Features["zvkb"] = ExtMask & (1 << 19);   // RISCV_HWPROBE_EXT_ZVKB
+  Features["zvkg"] = ExtMask & (1 << 20);   // RISCV_HWPROBE_EXT_ZVKG
+  Features["zvkned"] = ExtMask & (1 << 21); // RISCV_HWPROBE_EXT_ZVKNED
+  Features["zvknha"] = ExtMask & (1 << 22); // RISCV_HWPROBE_EXT_ZVKNHA
+  Features["zvknhb"] = ExtMask & (1 << 23); // RISCV_HWPROBE_EXT_ZVKNHB
+  Features["zvksed"] = ExtMask & (1 << 24); // RISCV_HWPROBE_EXT_ZVKSED
+  Features["zvksh"] = ExtMask & (1 << 25);  // RISCV_HWPROBE_EXT_ZVKSH
+  Features["zvkt"] = ExtMask & (1 << 26);   // RISCV_HWPROBE_EXT_ZVKT
+  Features["zfh"] = ExtMask & (1 << 27);// RISCV_HWPROBE_EXT_ZFH
+  Features["zfhmin"] = ExtMask & (1 << 28); // RISCV_HWPROBE_EXT_ZFHMIN
+  Features["zihintntl"] = ExtMask & (1 << 29);  // RISCV_HWPROBE_EXT_ZIHINTNTL
+  Features["zvfh"] = ExtMask & (1 << 30);   // RISCV_HWPROBE_EXT_ZVFH
+  Features["zvfhmin"] = ExtMask & (1ULL << 31); // RISCV_HWPROBE_EXT_ZVFHMIN
+  Features["zfa"] = ExtMask & (1ULL << 32); // RISCV_HWPROBE_EXT_ZFA
+  // TODO: set ztso when it is no longer experimental.
+  // Features["ztso"] = ExtMask & (1ULL << 33);// RISCV_HWPROBE_EXT_ZTSO

dtcxzyw wrote:

@topperc @preames What do you think about the ztso support as a todo?


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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread Stephen Tozer via cfe-commits


@@ -637,8 +637,7 @@ void ARMParallelDSP::InsertParallelMACs(Reduction ) {
 Intrinsic::getDeclaration(M, Intrinsic::arm_smlad) :
 Intrinsic::getDeclaration(M, Intrinsic::arm_smlald);
 
-IRBuilder Builder(InsertAfter->getParent(),
-BasicBlock::iterator(InsertAfter));
+IRBuilder Builder((BasicBlock::iterator(InsertAfter)));

SLTozer wrote:

Funnily enough, that doesn't actually work:
```
./llvm/lib/Target/ARM/ARMParallelDSP.cpp:640:32: warning: parentheses were 
disambiguated as a function declaration [-Wvexing-parse]
  640 | IRBuilder Builder(BasicBlock::iterator(InsertAfter));
  |^~~
```
Hence the weird double parentheses - however having looked back at this I can 
see `InsertAfter` is always non-null, so `->getIterator()` is safe.

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


[clang] [Clang] use parent declaration context to avoid asserting cast failure in defaulted comparison method (PR #96228)

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

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

>From 9e2730da07df0ee5102912490a687ba40bf06def Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 24 Jun 2024 18:55:51 +0300
Subject: [PATCH] [Clang] fix cast failures by adjusting the resolution of
 record declaration contexts to handle semantic and lexical distinctions

---
 clang/docs/ReleaseNotes.rst|  1 +
 clang/lib/Sema/SemaDeclCXX.cpp |  5 -
 .../class.compare/class.compare.default/p1.cpp | 18 ++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index df579ae398c5e..86bd8cf4a6210 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -934,6 +934,7 @@ Bug Fixes to C++ Support
 - Fix an assertion failure caused by parsing a lambda used as a default 
argument for the value of a
   forward-declared class. (#GH93512).
 - Fixed a bug in access checking inside return-type-requirement of compound 
requirements. (#GH93788).
+- Fixed failed assertion when resolving context of defaulted comparison method 
outside of struct. (#GH96043).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9b220103247dd..0ecad756d4499 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9192,7 +9192,10 @@ ComputeDefaultedComparisonExceptionSpec(Sema , 
SourceLocation Loc,
 EnterExpressionEvaluationContext Context(
 S, Sema::ExpressionEvaluationContext::Unevaluated);
 
-CXXRecordDecl *RD = cast(FD->getLexicalParent());
+CXXRecordDecl *RD =
+cast(FD->getFriendObjectKind() == Decl::FOK_None
+? FD->getDeclContext()
+: FD->getLexicalDeclContext());
 SourceLocation BodyLoc =
 FD->getEndLoc().isValid() ? FD->getEndLoc() : FD->getLocation();
 StmtResult Body =
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index 252860bfc4de0..ddf82f432c2ea 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -265,3 +265,21 @@ void f2() {
// access info for unnamed bit-field
 }
 }
+
+namespace GH96043 {
+template  class a {};
+template  b c(a);
+template  class e {
+public:
+  typedef a f;
+  f begin();
+};
+template  constexpr bool operator==(d h, g i) {
+  return *c(h.begin()) == *c(i.begin());
+}
+struct j {
+  e bar;
+  bool operator==(const j &) const;
+};
+bool j::operator==(const j &) const = default;
+}

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


[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-24 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw updated 
https://github.com/llvm/llvm-project/pull/94352

>From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 4 Jun 2024 21:08:27 +0800
Subject: [PATCH 01/11] [RISCV] Add support for getHostCPUFeatures using
 hwprobe

Co-authored-by: Yangyu Chen 
---
 llvm/lib/TargetParser/Host.cpp | 68 ++
 1 file changed, 68 insertions(+)

diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 68155acd9e5bc..b4a13b38eb380 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1998,6 +1998,74 @@ bool sys::getHostCPUFeatures(StringMap ) {
 
   return true;
 }
+#elif defined(__linux__) && defined(__riscv)
+#ifdef __has_include
+#if __has_include()
+#include 
+#endif
+#endif
+bool sys::getHostCPUFeatures(StringMap ) {
+#ifdef RISCV_HWPROBE_KEY_MVENDORID
+  riscv_hwprobe Query[2]{
+  {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
+  {RISCV_HWPROBE_KEY_CPUPERF_0, 0},
+  };
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/,
+/*pair_count=*/1, /*cpu_count=*/0, /*cpus=*/0, 
/*flags=*/0);
+  if (Ret != 0)
+return false;
+
+  uint64_t ExtMask = Query[0].value;
+  Features["f"] = ExtMask & RISCV_HWPROBE_IMA_FD;
+  Features["d"] = ExtMask & RISCV_HWPROBE_IMA_FD;
+  Features["c"] = ExtMask & RISCV_HWPROBE_IMA_C;
+  Features["v"] = ExtMask & RISCV_HWPROBE_IMA_V;
+  Features["zba"] = ExtMask & RISCV_HWPROBE_IMA_ZBA;
+  Features["zbb"] = ExtMask & RISCV_HWPROBE_IMA_ZBB;
+  Features["zbs"] = ExtMask & RISCV_HWPROBE_IMA_ZBS;
+  Features["zicboz"] = ExtMask & RISCV_HWPROBE_IMA_ZICBOZ;
+  Features["zbc"] = ExtMask & RISCV_HWPROBE_IMA_ZBC;
+  Features["zbkb"] = ExtMask & RISCV_HWPROBE_IMA_ZBKB;
+  Features["zbkc"] = ExtMask & RISCV_HWPROBE_IMA_ZBKC;
+  Features["zbkx"] = ExtMask & RISCV_HWPROBE_IMA_ZBKX;
+  Features["zknd"] = ExtMask & RISCV_HWPROBE_IMA_ZKND;
+  Features["zkne"] = ExtMask & RISCV_HWPROBE_IMA_ZKNE;
+  Features["zknh"] = ExtMask & RISCV_HWPROBE_IMA_ZKNH;
+  Features["zksed"] = ExtMask & RISCV_HWPROBE_IMA_ZKSED;
+  Features["zksh"] = ExtMask & RISCV_HWPROBE_IMA_ZKSH;
+  Features["zkt"] = ExtMask & RISCV_HWPROBE_IMA_ZKT;
+  Features["zvbb"] = ExtMask & RISCV_HWPROBE_IMA_ZVBB;
+  Features["zvbc"] = ExtMask & RISCV_HWPROBE_IMA_ZVBC;
+  Features["zvkb"] = ExtMask & RISCV_HWPROBE_IMA_ZVKB;
+  Features["zvkg"] = ExtMask & RISCV_HWPROBE_IMA_ZVKG;
+  Features["zvkned"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNED;
+  Features["zvknha"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNHA;
+  Features["zvknhb"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNHB;
+  Features["zvksed"] = ExtMask & RISCV_HWPROBE_IMA_ZVKSED;
+  Features["zvksh"] = ExtMask & RISCV_HWPROBE_IMA_ZVKSH;
+  Features["zvkt"] = ExtMask & RISCV_HWPROBE_IMA_ZVKT;
+  Features["zfh"] = ExtMask & RISCV_HWPROBE_IMA_ZFH;
+  Features["zfhmin"] = ExtMask & RISCV_HWPROBE_IMA_ZFHMIN;
+  Features["zihintntl"] = ExtMask & RISCV_HWPROBE_IMA_ZIHINTNTL;
+  Features["zvfh"] = ExtMask & RISCV_HWPROBE_IMA_ZVFH;
+  Features["zvfhmin"] = ExtMask & RISCV_HWPROBE_IMA_ZVFHMIN;
+  Features["zfa"] = ExtMask & RISCV_HWPROBE_IMA_ZFA;
+  Features["ztso"] = ExtMask & RISCV_HWPROBE_IMA_ZTSO;
+  Features["zacas"] = ExtMask & RISCV_HWPROBE_IMA_ZACAS;
+  Features["zicond"] = ExtMask & RISCV_HWPROBE_IMA_ZICOND;
+  Features["zihintpause"] = ExtMask & RISCV_HWPROBE_IMA_ZIHINTPAUSE;
+
+  uint64_t MisalignedMask = Query[1].value;
+  if (MisalignedMask == RISCV_HWPROBE_MISALIGNED_FAST) {
+Features["unaligned-scalar-mem"] = true;
+Features["unaligned-vector-mem"] = true;
+  }
+
+  return true;
+#else
+  return false;
+#endif
+}
 #else
 bool sys::getHostCPUFeatures(StringMap ) { return false; }
 #endif

>From a2fa6e3d64d3a1e2a8e3a7af91068bdb1fda28b1 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 4 Jun 2024 22:10:55 +0800
Subject: [PATCH 02/11] [RISCV] Address review comments.

---
 llvm/lib/TargetParser/Host.cpp | 112 +++--
 1 file changed, 52 insertions(+), 60 deletions(-)

diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index b4a13b38eb380..ec275c0a7fded 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1999,72 +1999,64 @@ bool sys::getHostCPUFeatures(StringMap ) 
{
   return true;
 }
 #elif defined(__linux__) && defined(__riscv)
-#ifdef __has_include
-#if __has_include()
-#include 
-#endif
-#endif
+// struct riscv_hwprobe
+struct RISCVHwProbe {
+  int64_t Key;
+  uint64_t Value;
+};
 bool sys::getHostCPUFeatures(StringMap ) {
-#ifdef RISCV_HWPROBE_KEY_MVENDORID
-  riscv_hwprobe Query[2]{
-  {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
-  {RISCV_HWPROBE_KEY_CPUPERF_0, 0},
-  };
-  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/,
-/*pair_count=*/1, /*cpu_count=*/0, /*cpus=*/0, 
/*flags=*/0);
+  RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}};
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, 

[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Congcong Cai via cfe-commits

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

lgtm

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


[clang] [Sema] Fix crash in Sema::FindInstantiatedDecl (PR #96509)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alejandro Álvarez Ayllón (alejandro-alvarez-sonarsource)


Changes

When looking for a template instantiation with a non-type parameter of unknown 
type and with a default value.

This can happen when a template non-type parameter has a broken expression that 
gets replaced by a `RecoveryExpr`.

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+1-1) 
- (added) clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp 
(+12) 


``diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 0681520764d9a..999fec0ebb259 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, 
NamedDecl *D,
   getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
   }
   QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
-  if (T.isNull())
+  if (T.isNull() || T->containsErrors())
 return nullptr;
   CXXRecordDecl *SubstRecord = T->getAsCXXRecordDecl();
 
diff --git a/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp 
b/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp
new file mode 100644
index 0..a644cc3d057cb
--- /dev/null
+++ b/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+constexpr Missing a = 0; // expected-error {{unknown type name 'Missing'}}
+
+template < typename T, Missing b = a> // expected-error {{unknown type name 
'Missing'}}
+class Klass { // expected-note {{candidate template ignored: could not match 
'Klass' against 'int'}}
+  Klass(T);   // expected-note {{candidate template ignored: substitution 
failure [with T = int, b = ()]}}
+};
+
+Klass foo{5}; // no-crash \
+ expected-error {{no viable constructor or deduction guide for 
deduction of template arguments of 'Klass'}}
+

``




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


[clang] [Sema] Fix crash in Sema::FindInstantiatedDecl (PR #96509)

2024-06-24 Thread Alejandro Álvarez Ayllón via cfe-commits

https://github.com/alejandro-alvarez-sonarsource created 
https://github.com/llvm/llvm-project/pull/96509

When looking for a template instantiation with a non-type parameter of unknown 
type and with a default value.

This can happen when a template non-type parameter has a broken expression that 
gets replaced by a `RecoveryExpr`.

From 96b0c2c18c197a1ce03d31b01c14d1b18348e9ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
 
Date: Thu, 1 Jun 2023 16:30:54 +0200
Subject: [PATCH] [Sema] Fix crash in Sema::FindInstantiatedDecl

when looking for a template instantiation with a non-type
parameter of unknown type and with a default value.

This can happen when a template non-type parameter has a broken
expression that gets replaced by a `RecoveryExpr`.
---
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp   |  2 +-
 .../instantiate-template-broken-nontype-default.cpp  | 12 
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 0681520764d9a..999fec0ebb259 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, 
NamedDecl *D,
   getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
   }
   QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
-  if (T.isNull())
+  if (T.isNull() || T->containsErrors())
 return nullptr;
   CXXRecordDecl *SubstRecord = T->getAsCXXRecordDecl();
 
diff --git a/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp 
b/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp
new file mode 100644
index 0..a644cc3d057cb
--- /dev/null
+++ b/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+constexpr Missing a = 0; // expected-error {{unknown type name 'Missing'}}
+
+template < typename T, Missing b = a> // expected-error {{unknown type name 
'Missing'}}
+class Klass { // expected-note {{candidate template ignored: could not match 
'Klass' against 'int'}}
+  Klass(T);   // expected-note {{candidate template ignored: substitution 
failure [with T = int, b = ()]}}
+};
+
+Klass foo{5}; // no-crash \
+ expected-error {{no viable constructor or deduction guide for 
deduction of template arguments of 'Klass'}}
+

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


[clang] [clang] Improve diagnostics for constraints of inline asm (NFC) (PR #96363)

2024-06-24 Thread Evgenii Kudriashov via cfe-commits

e-kud wrote:

> It's really unfortunate to have to add all this asm handling to clang. Can't 
> it rely on backend diagnostic remarks for this?

I've tried to do the similar thing in the backend: 
https://reviews.llvm.org/D152332. The problem I see is that `llc`'s error 
handler ignores errors and continues compilation until something further 
reports a fatal error. In other words we have to return something wrong 
intentionally to continue compilation. On the other hand, we can prepare all 
callers to have an error somewhere inside but there will be a lot of refactor 
because there is no common practice to emit target specific errors. 
`report_fatal_error` is more likable.

```
$ grep -R emitError lib/Target/X86/*
lib/Target/X86/X86FloatingPoint.cpp:  MI.emitError("fixed input regs must 
be last on the x87 stack");
lib/Target/X86/X86FloatingPoint.cpp:  MI.emitError("output regs must be 
last on the x87 stack");
lib/Target/X86/X86FloatingPoint.cpp:  MI.emitError("clobbers must be last 
on the x87 stack");
lib/Target/X86/X86FloatingPoint.cpp:  MI.emitError("implicitly popped regs 
must be last on the x87 stack");
lib/Target/X86/X86PreTileConfig.cpp:static void emitErrorMsg(MachineFunction 
) {
lib/Target/X86/X86PreTileConfig.cpp:  Context.emitError(
lib/Target/X86/X86PreTileConfig.cpp:  emitErrorMsg(MF);
lib/Target/X86/X86PreTileConfig.cpp:  emitErrorMsg(MF);
$ grep -R emitError lib/Target/AArch64/*
lib/Target/AArch64/AArch64AsmPrinter.cpp:BaseGV->getContext().emitError(
$ grep -R emitError lib/Target/RISCV/*
$
```
```
$ grep -R emitError lib/Target/* | wc -l
47
$ grep -R report_fatal_error lib/Target/* | wc -l
675
```
I'm not sure whether it is much better. 



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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-24 Thread Lucas Duarte Prates via cfe-commits


@@ -154,17 +156,39 @@ std::optional 
AArch64::parseCpu(StringRef Name) {
   return {};
 }
 
-void AArch64::PrintSupportedExtensions(StringMap DescMap) {
+void AArch64::PrintSupportedExtensions() {
   outs() << "All available -march extensions for AArch64\n\n"
  << "" << left_justify("Name", 20)
- << (DescMap.empty() ? "\n" : "Description\n");
+ << left_justify("Architecture Feature(s)", 55)
+ << "Description\n";
   for (const auto  : Extensions) {
 // Extensions without a feature cannot be used with -march.
-if (!Ext.Feature.empty()) {
-  std::string Description = DescMap[Ext.Name].str();
+if (!Ext.UserVisibleName.empty() && !Ext.PosTargetFeature.empty()) {
+  outs() << ""
+ << format(Ext.Description.empty() ? "%-20s%s\n" : 
"%-20s%-55s%s\n",
+   Ext.UserVisibleName.str().c_str(),
+   Ext.ArchFeatureName.str().c_str(),
+   Ext.Description.str().c_str());
+}
+  }
+}
+
+void
+AArch64::printEnabledExtensions(std::vector EnabledFeatureNames) {
+  outs() << "Extensions enabled for the given AArch64 target\n\n"
+ << "" << left_justify("Architecture Feature(s)", 55)
+ << "Description\n";
+  auto IsEnabled = [&](const ExtensionInfo ) {
+StringRef FeatureName = Ext.PosTargetFeature.drop_front(); // drop '+' 
before comparing

pratlucas wrote:

No, the only `PosTargetFeature` was chosen as a reference here. 
`EnabledFeatureNames` captures the list of plain names - i.e. without the `+` 
or `-` prefixes, so we just need a fixed reference to compare them to.

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


[clang] f985a88 - Revert "[RISCV] Remove experimental from Ztso. (#96465)"

2024-06-24 Thread Philip Reames via cfe-commits

Author: Philip Reames
Date: 2024-06-24T08:32:28-07:00
New Revision: f985a8826bfa4ca3d23e654185de35e30ea6dc79

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

LOG: Revert "[RISCV] Remove experimental from Ztso. (#96465)"

This reverts commit 9cd6ef4b8a5c843ef491437c765d4cb2ff2f8fe3.  See
discussion on review thread.

Added: 


Modified: 
clang/test/Driver/riscv-arch.c
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/test/CodeGen/RISCV/GlobalISel/atomic-fence.ll
llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll
llvm/test/CodeGen/RISCV/atomic-fence.ll
llvm/test/CodeGen/RISCV/atomic-load-store.ll
llvm/test/CodeGen/RISCV/atomic-rmw.ll
llvm/test/CodeGen/RISCV/atomicrmw-uinc-udec-wrap.ll
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/CodeGen/RISCV/module-elf-flags.ll
llvm/test/MC/RISCV/Ztso.s
llvm/test/MC/RISCV/attribute-arch.s
llvm/test/MC/RISCV/elf-flags.s
llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Removed: 




diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index c3c471c4bc396..ffd92e1f398c4 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -365,30 +365,24 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZFHMIN %s
 // RV32-ZFHMIN: "-target-feature" "+zfhmin"
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32izalasr -### %s \
+// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iztso -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOFLAG 
%s
-// RV32-EXPERIMENTAL-NOFLAG: error: invalid arch name 'rv32izalasr'
+// RV32-EXPERIMENTAL-NOFLAG: error: invalid arch name 'rv32iztso'
 // RV32-EXPERIMENTAL-NOFLAG: requires '-menable-experimental-extensions'
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32izalasr 
-menable-experimental-extensions -### %s \
+// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iztso 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOVERS 
%s
-// RV32-EXPERIMENTAL-NOVERS: error: invalid arch name 'rv32izalasr'
+// RV32-EXPERIMENTAL-NOVERS: error: invalid arch name 'rv32iztso'
 // RV32-EXPERIMENTAL-NOVERS: experimental extension requires explicit version 
number
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32izalasr0p7 
-menable-experimental-extensions -### %s \
+// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iztso0p7 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-BADVERS 
%s
-// RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32izalasr0p7'
-// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.7 for experimental 
extension 'zalasr' (this compiler supports 0.1)
+// RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32iztso0p7'
+// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.7 for experimental 
extension 'ztso' (this compiler supports 0.1)
 
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32izalasr0p1 
-menable-experimental-extensions -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32iztso0p1 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
-// RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-zalasr"
-
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32iztso1p0 -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZTSO %s
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32iztso -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZTSO %s
-// RV32-ZTSO: "-target-feature" "+ztso"
+// RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-ztso"
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32izbb1p0 -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZBB %s

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 46a61e3c0afc7..d7935af532dfa 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -1650,13 +1650,13 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZICFILP-EXT %s
 // CHECK-ZICFILP-EXT: __riscv_zicfilp 4000{{$}}
 
-// RUN: %clang --target=riscv32-unknown-linux-gnu \
-// RUN:   -march=rv32iztso1p0 -E -dM %s \
+// RUN: %clang --target=riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
+// RUN:   -march=rv32iztso0p1 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZTSO-EXT %s
-// RUN: %clang --target=riscv64-unknown-linux-gnu \
-// 

[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -124,6 +124,13 @@ struct PortableMemInfoBlock {
   OS << "" << #Name << ": " << Name << "\n";
 #include "llvm/ProfileData/MIBEntryDef.inc"
 #undef MIBEntryDef
+if (AccessHistogramSize > 0) {
+  OS << "" << "AccessHistogramValues" << ":";
+  for (uint32_t I = 0; I < AccessHistogramSize; ++I) {
+OS << " -" << ((uint64_t *)AccessHistogram)[I];

mattweingarten wrote:

I though only having space delimiting did not produce valid yaml, I double 
checked and was wrong. Changed to space delimiting, thanks!

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -20,25 +20,25 @@ CHECK-NEXT:  -
 
 CHECK:  Records:
 CHECK-NEXT:  -
-CHECK-NEXT:FunctionGUID: 15505678318020221912
+CHECK-NEXT:FunctionGUID: 3873612792189045660
 CHECK-NEXT:AllocSites:
 CHECK-NEXT:-
 CHECK-NEXT:  Callstack:
 CHECK-NEXT:  -
-CHECK-NEXT:Function: 15505678318020221912
-CHECK-NEXT:SymbolName: qux
+CHECK-NEXT:Function: 3873612792189045660
+CHECK-NEXT:SymbolName: _Z3quxi

mattweingarten wrote:

good question, I suspect this test has not been regenerated in a long time and 
something changed in meantime in memprof? I think it might have to do with the 
SymbolNames being mangled vs demangled, which changes the hash value? Is it a 
problem that the hash value changed?

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


[clang] [clang-format] Don't count template template parameter as declaration (PR #96396)

2024-06-24 Thread Emilia Kond via cfe-commits

rymiel wrote:

Isn't fixing bugs meant to change defaults? See #61732, #48746 and #93793. The 
old version is confusing since it looks like a separate template parameter when 
it isn't.

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -0,0 +1,101 @@
+REQUIRES: x86_64-linux
+
+This is a copy of memprof-basict.test with slight changes to check that we can 
still read v3 of memprofraw.
+
+To update the inputs used below run Inputs/update_memprof_inputs.sh 
/path/to/updated/clang

mattweingarten wrote:

yes, good point! 

done.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-24 Thread Lucas Duarte Prates via cfe-commits


@@ -1841,7 +1868,8 @@ INSTANTIATE_TEST_SUITE_P(
  AArch64::AEK_PROFILE, AArch64::AEK_RAND,
  AArch64::AEK_FP16FML, AArch64::AEK_I8MM,
  AArch64::AEK_JSCVT,   AArch64::AEK_FCMA,
- AArch64::AEK_PAUTH,   AArch64::AEK_PERFMON}),
+ AArch64::AEK_PAUTH,   AArch64::AEK_PERFMON,
+ AArch64::AEK_CCDP}),

pratlucas wrote:

I don't see an advantage to not having AEK entries for all extensions. Having 
this correspondence not only increases testability, as shown by the changes in 
`TargetParserTest.cpp`, but also makes them consistently visible to the wider 
codebase via the Target Parser interface.

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -0,0 +1,101 @@
+REQUIRES: x86_64-linux
+
+This is a copy of memprof-basict.test with slight changes to check that we can 
still read v3 of memprofraw.

mattweingarten wrote:

done

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -508,7 +519,26 @@ void createProfileFileNameVar(Module ) {
   }
 }
 
+// Set MemprofHistogramFlag as a Global veriable in IR. This makes it 
accessible
+// to
+// the runtime, changing shadow count behavior.
+void createMemprofHistogramFlagVar(Module ) {
+  const StringRef VarName(MemProfHistogramFlagVar);
+  Type *IntTy1 = Type::getInt1Ty(M.getContext());
+  auto MemprofHistogramFlag = new GlobalVariable(
+  M, IntTy1, true, GlobalValue::WeakAnyLinkage,
+  Constant::getIntegerValue(IntTy1, APInt(1, ClHistogram)), VarName);
+  // MemprofHistogramFlag->setVisibility(GlobalValue::HiddenVisibility);

mattweingarten wrote:

done.

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -508,7 +519,26 @@ void createProfileFileNameVar(Module ) {
   }
 }
 
+// Set MemprofHistogramFlag as a Global veriable in IR. This makes it 
accessible
+// to

mattweingarten wrote:

done.

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -610,13 +670,33 @@ RawMemProfReader::peekBuildIds(MemoryBuffer *DataBuffer) {
   return BuildIds.takeVector();
 }
 
+// FIXME: Add a schema for serializing similiar to IndexedMemprofReader. This
+// will help being able to deserialize different versions raw memprof versions
+// more easily.
+llvm::SmallVector>
+RawMemProfReader::readMemInfoBlocks(const char *Ptr) {
+  if (MemprofRawVersion == 3ULL) {
+errs() << "Reading V3\n";

mattweingarten wrote:

done.

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -96,19 +102,63 @@ llvm::SmallVector readSegmentEntries(const 
char *Ptr) {
 }
 
 llvm::SmallVector>
-readMemInfoBlocks(const char *Ptr) {
+readMemInfoBlocksV3(const char *Ptr) {
   using namespace support;
 
   const uint64_t NumItemsToRead =
-  endian::readNext(Ptr);
+  endian::readNext(Ptr);
+
   llvm::SmallVector> Items;
   for (uint64_t I = 0; I < NumItemsToRead; I++) {
 const uint64_t Id =
-endian::readNext(Ptr);
-const MemInfoBlock MIB = *reinterpret_cast(Ptr);
+endian::readNext(Ptr);
+
+// We cheat a bit here and remove the const from cast to set the
+// Histogram Pointer to newly allocated buffer. We also cheat, since V3 and
+// V4 do not have the same fields. V3 is missing AccessHistogramSize and
+// AccessHistogram. This means we read "dirty" data in here, but it should
+// not segfault, since there will be callstack data placed after this in 
the
+// binary format.
+MemInfoBlock MIB = *reinterpret_cast(Ptr);
+// Overwrite dirty data.

mattweingarten wrote:

My thought process is that the MemInfoBlock MIB is a allocated on the stack, 
since its a local variable and not a pointer. Meaning the reinterpret_cast 
copies the information from the data-buffer  into the stack variable. Correct 
me if I am wrong

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -205,8 +205,14 @@ class RawMemProfReader final : public MemProfReader {
 
   object::SectionedAddress getModuleOffset(uint64_t VirtualAddress);
 
+  llvm::SmallVector>
+  readMemInfoBlocks(const char *Ptr);
+
   // The profiled binary.
   object::OwningBinary Binary;
+  // Version of raw memprof binary currently being read. Defaults to most 
update

mattweingarten wrote:

done.

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


[clang] [llvm] [RISCV] Remove experimental from Ztso. (PR #96465)

2024-06-24 Thread Philip Reames via cfe-commits

preames wrote:

> I think @preames told me he was keeping this experimental for a reason.

Yes, revert pending.

The concern here is that there are multiple possible ABIs here, and at the 
point I implemented this, the ABI chosen in my initial set of patches was 
compatible with the then current WMO ABI, but is *incompatible* with the 
revised ABI for load acquire/store release.  I know there has been some work on 
this since, but the prominent warning comment has not been removed, and there 
is not discussion in this review about status.  

I will note that simply deleting a comment from the docs *which directly 
explain why something is still experimental* without discussing exactly that 
issue in the review thread is, IMO, poor behavior on all parties involved.  


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


[clang] [clang-format] Add SpacesInParensOption for filtering repeated parens (PR #77522)

2024-06-24 Thread Gedare Bloom via cfe-commits

https://github.com/gedare updated 
https://github.com/llvm/llvm-project/pull/77522

>From 4a7489251b842da778dd839bd5af3db12ba0fe0b Mon Sep 17 00:00:00 2001
From: Gedare Bloom 
Date: Mon, 17 Jul 2023 18:24:30 -0600
Subject: [PATCH 1/5] Add SpaceInParensOption ExceptDoubleParentheses

This change allows finer control over addition of spaces between a pair of
consecutive opening parentheses with a pair of closing parentheses.
---
 clang/docs/ClangFormatStyleOptions.rst |  28 +-
 clang/docs/ReleaseNotes.rst|   3 +
 clang/include/clang/Format/Format.h|  40 ++-
 clang/lib/Format/Format.cpp|   5 +-
 clang/lib/Format/TokenAnnotator.cpp|  70 +++--
 clang/unittests/Format/ConfigParseTest.cpp |  21 +-
 clang/unittests/Format/FormatTest.cpp  | 314 +
 7 files changed, 441 insertions(+), 40 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index bb00c20922d36..d5cda03e55f26 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6214,6 +6214,7 @@ the configuration (without a prefix: ``Auto``).
 # Example of usage:
 SpacesInParens: Custom
 SpacesInParensOptions:
+  ExceptDoubleParentheses: false
   InConditionalStatements: true
   InEmptyParentheses: true
 
@@ -6226,9 +6227,23 @@ the configuration (without a prefix: ``Auto``).
 # Should be declared this way:
 SpacesInParens: Custom
 SpacesInParensOptions:
+  ExceptDoubleParentheses: false
   InConditionalStatements: true
   Other: true
 
+  * ``bool ExceptDoubleParentheses`` Override any of the following options to 
prevent addition of space
+between the first two parentheses in situations where a pair of
+parentheses have been used.
+
+.. code-block:: c++
+
+  true:
+  __attribute__(( noreturn ))
+  __decltype__(( x ))
+  if (( a = b ))
+ false:
+   Uses the applicable option.
+
   * ``bool InConditionalStatements`` Put a space in parentheses only inside 
conditional statements
 (``for/if/while/switch...``).
 
@@ -6242,8 +6257,9 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-   true:  false:
-   x = ( int32 )y vs. x = (int32)y
+  true:  false:
+  x = ( int32 )y  vs.x = (int32)y
+  y = (( int (*)(int) )foo)(x);  y = ((int (*)(int))foo)(x);
 
   * ``bool InEmptyParentheses`` Insert a space in empty parentheses, i.e. 
``()``.
 
@@ -6261,8 +6277,12 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-   true:  false:
-   t f( Deleted & ) & = delete;   vs. t f(Deleted &) & = delete;
+  true: false:
+  t f( Deleted & ) & = delete;vs.   t f(Deleted &) & = delete;
+  decltype( ( x ) ) decltype((x))
+  x = ( (int32)y )  x = ((int32))y
+  y = ( (int ( * )( int ))foo )( x );   y = ((int (*)(int))foo)(x);
+   __attribute__( ( noreturn ) )__attribute__((noreturn))
 
 
 .. _SpacesInParentheses:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 92ada517acae3..bbb24a59191fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1079,6 +1079,9 @@ clang-format
 - Adds ``AllowShortCaseExpressionOnASingleLine`` option.
 - Adds ``AlignCaseArrows`` suboption to 
``AlignConsecutiveShortCaseStatements``.
 - Adds ``LeftWithLastLine`` suboption to ``AlignEscapedNewlines``.
+- Add ``ExceptDoubleParentheses`` sub-option for ``SpacesInParensOptions``
+  to override addition of spaces between multiple, non-redundant parentheses
+  similar to the rules used for ``RemoveParentheses``.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7d257be10af42..3469cbad027c2 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4650,10 +4650,23 @@ struct FormatStyle {
   ///   # Should be declared this way:
   ///   SpacesInParens: Custom
   ///   SpacesInParensOptions:
+  /// ExceptDoubleParentheses: false
   /// InConditionalStatements: true
   /// Other: true
   /// \endcode
   struct SpacesInParensCustom {
+/// Override any of the following options to prevent addition of space
+/// between the first two parentheses in situations where a pair of
+/// parentheses have been used.
+/// \code
+///   true:
+///   __attribute__(( noreturn ))
+///   __decltype__(( x ))
+///   if (( a = b ))
+/// \endcode
+///  false:
+///Uses the applicable option.
+bool ExceptDoubleParentheses;
 /// Put a space in parentheses only inside conditional statements
 /// (``for/if/while/switch...``).
 /// 

[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -38,4 +38,5 @@ MEMPROF_FLAG(bool, 
allocator_frees_and_returns_null_on_realloc_zero, true,
 MEMPROF_FLAG(bool, print_text, false,
   "If set, prints the heap profile in text format. Else use the raw binary 
serialization format.")
 MEMPROF_FLAG(bool, print_terse, false,
- "If set, prints memory profile in a terse format. Only applicable 
if print_text = true.")
+ "If set, prints memory profile in a terse format. Only applicable 
"

mattweingarten wrote:

done.

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -216,6 +228,35 @@ u64 GetShadowCount(uptr p, u32 size) {
   return count;
 }
 
+// Accumulates the access count from the shadow for the given pointer and size.
+// See memprof_mapping.h for an overview on histogram counters.
+u64 GetShadowCountHistogram(uptr p, u32 size) {
+  u8 *shadow = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p);
+  u8 *shadow_end = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p + size);
+  u64 count = 0;
+  for (; shadow <= shadow_end; shadow++)
+count += *shadow;
+  return count;
+}
+
+// If we use the normal approach from clearCountersWithoutHistogram, the
+// histogram will clear too much data and may overwrite shadow counters that 
are
+// in use. Likely because of rounding up the shadow_end pointer.
+// See memprof_mapping.h for an overview on histogram counters.
+void clearCountersHistogram(uptr addr, uptr size) {
+  u8 *shadow_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr);
+  u8 *shadow_end_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr + size);
+  for (; shadow_8 < shadow_end_8; shadow_8++) {
+*shadow_8 = 0;
+  }
+}
+
+void clearCountersWithoutHistogram(uptr addr, uptr size) {
+  uptr shadow_beg = MEM_TO_SHADOW(addr);
+  uptr shadow_end = MEM_TO_SHADOW(addr + size - SHADOW_GRANULARITY) + 1;
+  REAL(memset)((void *)shadow_beg, 0, shadow_end - shadow_beg);
+}
+
 // Clears the shadow counters (when memory is allocated).
 void ClearShadow(uptr addr, uptr size) {

mattweingarten wrote:

This function uses the MEM_TO_SHADOW computed pointers "kind of", but in 
reality it just rounds these pointers up to nearest page_sizes. So in effect, 
full pages should be cleared no matter if it is with histogram or without.

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


[clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)

2024-06-24 Thread Matthew Weingarten via cfe-commits


@@ -216,6 +228,35 @@ u64 GetShadowCount(uptr p, u32 size) {
   return count;
 }
 
+// Accumulates the access count from the shadow for the given pointer and size.
+// See memprof_mapping.h for an overview on histogram counters.
+u64 GetShadowCountHistogram(uptr p, u32 size) {
+  u8 *shadow = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p);
+  u8 *shadow_end = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p + size);
+  u64 count = 0;
+  for (; shadow <= shadow_end; shadow++)
+count += *shadow;
+  return count;
+}
+
+// If we use the normal approach from clearCountersWithoutHistogram, the
+// histogram will clear too much data and may overwrite shadow counters that 
are
+// in use. Likely because of rounding up the shadow_end pointer.
+// See memprof_mapping.h for an overview on histogram counters.
+void clearCountersHistogram(uptr addr, uptr size) {
+  u8 *shadow_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr);
+  u8 *shadow_end_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr + size);
+  for (; shadow_8 < shadow_end_8; shadow_8++) {

mattweingarten wrote:

changed.


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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Clement Courbet (legrosbuffle)


Changes

`GetDirectCallee` can be null.

Fixes #96498.

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


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 (+9) 


``diff
diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index a6062ccf42230..106feb7fb4172 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -296,7 +296,7 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, 
Indirections) {
   return false;
 }
 const auto *const Method =
-dyn_cast(OpCall->getDirectCallee());
+dyn_cast_or_null(OpCall->getDirectCallee());
 
 if (Method == nullptr) {
   // This is not a member operator. Typically, a friend operator. These
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index f259552dc8f1d..d02bb98cf583c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -906,3 +906,12 @@ void negativeNonConstMemberExpr() {
   }
 }
 
+
+bool operator==(ExpensiveToCopyType, ExpensiveToCopyType);
+
+template bool OperatorWithNoDirectCallee(T t) {
+  ExpensiveToCopyType a1;
+  ExpensiveToCopyType a2 = a1;
+  return a1 == t;
+}
+

``




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


[clang-tools-extra] [clang-tidy] Fix assert in performance-unnecessary-copy-init. (PR #96506)

2024-06-24 Thread Clement Courbet via cfe-commits

https://github.com/legrosbuffle created 
https://github.com/llvm/llvm-project/pull/96506

`GetDirectCallee` can be null.

Fixes #96498.

>From 5034dc92f9098874471b3f035fceb8275629b37a Mon Sep 17 00:00:00 2001
From: Clement Courbet 
Date: Mon, 24 Jun 2024 15:05:48 +
Subject: [PATCH] [clang-tidy] Fix assert in performance-unnecessary-copy-init.

`GetDirectCallee` can be null.

Fixes #96498.
---
 clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp  | 2 +-
 .../performance/unnecessary-copy-initialization.cpp  | 9 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index a6062ccf42230..106feb7fb4172 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -296,7 +296,7 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, 
Indirections) {
   return false;
 }
 const auto *const Method =
-dyn_cast(OpCall->getDirectCallee());
+dyn_cast_or_null(OpCall->getDirectCallee());
 
 if (Method == nullptr) {
   // This is not a member operator. Typically, a friend operator. These
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index f259552dc8f1d..d02bb98cf583c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -906,3 +906,12 @@ void negativeNonConstMemberExpr() {
   }
 }
 
+
+bool operator==(ExpensiveToCopyType, ExpensiveToCopyType);
+
+template bool OperatorWithNoDirectCallee(T t) {
+  ExpensiveToCopyType a1;
+  ExpensiveToCopyType a2 = a1;
+  return a1 == t;
+}
+

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


[clang] 3e36dfa - [C23] Remove WG14 N2660 from the list of papers we track

2024-06-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2024-06-24T11:12:18-04:00
New Revision: 3e36dfafa0d11b2a5d7776d88f170c449116aa0e

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

LOG: [C23] Remove WG14 N2660 from the list of papers we track

This paper was a clarification paper that made no normative changes to
the wording, so we can lean on the C99 status for this.

Added: 


Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index f6a92d94874a5..434c9e20011d4 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -642,11 +642,6 @@ C23 implementation status
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2186.pdf;>N2186
   Unknown
 
-
-  Clarifying the restrict Keyword v2
-  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2260.pdf;>N2660
-  Unknown
-
 
   Harmonizing static_assert with C++
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2265.pdf;>N2665



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


[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-24 Thread Maciej Gabka via cfe-commits

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


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


[clang] [llvm] [RISCV] Remove experimental from Ztso. (PR #96465)

2024-06-24 Thread Craig Topper via cfe-commits

topperc wrote:

I think @preames told me he was keeping this experimental for a reason.

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

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


@@ -637,8 +637,7 @@ void ARMParallelDSP::InsertParallelMACs(Reduction ) {
 Intrinsic::getDeclaration(M, Intrinsic::arm_smlad) :
 Intrinsic::getDeclaration(M, Intrinsic::arm_smlald);
 
-IRBuilder Builder(InsertAfter->getParent(),
-BasicBlock::iterator(InsertAfter));
+IRBuilder Builder((BasicBlock::iterator(InsertAfter)));

nikic wrote:

```suggestion
IRBuilder Builder(BasicBlock::iterator(InsertAfter));
```

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

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

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

LGTM if CI is happy.

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

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


@@ -3136,7 +3136,7 @@ static void LLVMPositionBuilderImpl(IRBuilder<> *Builder, 
BasicBlock *Block,
 Instruction *Instr, bool BeforeDbgRecords) 
{
   BasicBlock::iterator I = Instr ? Instr->getIterator() : Block->end();
   I.setHeadBit(BeforeDbgRecords);
-  Builder->SetInsertPoint(Block, I);
+  Builder->SetInsertPoint(I);

nikic wrote:

Maybe assert that BB and Instr are consistent here?

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

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


@@ -44,15 +44,19 @@ template <> struct ilist_alloc_traits {
 iterator_range::iterator>
 getDbgRecordRange(DbgMarker *);
 
+/// Class used to generate an insert position (ultimately always a
+/// BasicBlock::iterator, which it will implicitly convert to) from either:
+/// - An Instruction, inserting immediately prior.

nikic wrote:

Indicate that this is deprecated?

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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

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

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


[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)

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

ilya-biryukov wrote:

@hokein could you please split this into two PRs, one with an NFC change and 
another one with adding assignment support?
GitHub is not great at providing the UI to review individual commits and we 
won't be able to merge as 2 separate commits with the green button (which seems 
like a desirable end state for the readability of the commit history).

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


[clang] [Serialization] Storing DeclID separately (PR #95897)

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

ilya-biryukov wrote:

Sorry for not getting to it today, I'll send a review tomorrow.

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


[clang] [Serialization] Don't read all declaration id eagerly when merge the tables (PR #95506)

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

ilya-biryukov wrote:

I feel the increased complexity does not seem like a good trade-off if it does 
not significantly improve performance.
However I don't feel too strongly about it, so I suggest you get a second 
opinion if you feel strongly that we should land this.

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


[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-06-24 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balázs Kéri (balazske)


Changes

The checker could report false positives if pointer arithmetic was done on 
pointers to non-array data before pointer subtraction. Another problem is fixed 
that could cause false positive if members of the same structure but in 
different memory objects are subtracted.

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


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp (+19-3) 
- (modified) clang/test/Analysis/pointer-sub.c (+20-9) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
index eea93a41f1384..63ed4df67d6d5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
@@ -49,12 +49,28 @@ class PointerSubChecker
 };
 }
 
+static bool isArrayVar(const MemRegion *R) {
+  while (R) {
+if (isa(R))
+  return true;
+if (const auto *ER = dyn_cast(R))
+  R = ER->getSuperRegion();
+else
+  return false;
+  }
+  return false;
+}
+
 bool PointerSubChecker::checkArrayBounds(CheckerContext , const Expr *E,
  const ElementRegion *ElemReg,
  const MemRegion *Reg) const {
   if (!ElemReg)
 return true;
 
+  const MemRegion *SuperReg = ElemReg->getSuperRegion();
+  if (!isArrayVar(SuperReg))
+return true;
+
   auto ReportBug = [&](const llvm::StringLiteral ) {
 if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
   auto R = std::make_unique(BT, Msg, N);
@@ -64,7 +80,6 @@ bool PointerSubChecker::checkArrayBounds(CheckerContext , 
const Expr *E,
   };
 
   ProgramStateRef State = C.getState();
-  const MemRegion *SuperReg = ElemReg->getSuperRegion();
   SValBuilder  = C.getSValBuilder();
 
   if (SuperReg == Reg) {
@@ -121,8 +136,9 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator 
*B,
   if (LR == RR)
 return;
 
-  // No warning if one operand is unknown.
-  if (isa(LR) || isa(RR))
+  // No warning if one operand is unknown or resides in a region that could be
+  // equal to the other.
+  if (LR->getSymbolicBase() || RR->getSymbolicBase())
 return;
 
   const auto *ElemLR = dyn_cast(LR);
diff --git a/clang/test/Analysis/pointer-sub.c 
b/clang/test/Analysis/pointer-sub.c
index 88e6dec2d172f..404b8530b89c0 100644
--- a/clang/test/Analysis/pointer-sub.c
+++ b/clang/test/Analysis/pointer-sub.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.PointerSub -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.PointerSub 
-analyzer-output=text-minimal -verify %s
 
 void f1(void) {
   int x, y, z[10];
@@ -73,15 +73,15 @@ void f4(void) {
   d = a[2] - a[1]; // expected-warning{{Subtraction of two pointers that}}
 }
 
-typedef struct {
+struct S {
   int a;
   int b;
   int c[10]; // expected-note2{{Array at the right-hand side of subtraction}}
   int d[10]; // expected-note2{{Array at the left-hand side of subtraction}}
-} S;
+};
 
 void f5(void) {
-  S s;
+  struct S s;
   int y;
   int d;
 
@@ -92,18 +92,18 @@ void f5(void) {
   d = [3] - [2]; // expected-warning{{Subtraction of two pointers 
that}}
   d = s.d - s.c; // expected-warning{{Subtraction of two pointers that}}
 
-  S sa[10];
+  struct S sa[10];
   d = [2] - [1];
   d = [2].a - [1].b; // expected-warning{{Subtraction of two pointers 
that}}
 }
 
 void f6(void) {
-  long long l;
+  long long l = 2;
   char *a1 = (char *)
   int d = a1[3] - l;
 
-  long long la1[3]; // expected-note{{Array at the right-hand side of 
subtraction}}
-  long long la2[3]; // expected-note{{Array at the left-hand side of 
subtraction}}
+  long long la1[3] = {1}; // expected-note{{Array at the right-hand side of 
subtraction}}
+  long long la2[3] = {1}; // expected-note{{Array at the left-hand side of 
subtraction}}
   char *pla1 = (char *)la1;
   char *pla2 = (char *)la2;
   d = pla1[1] - pla1[0];
@@ -117,6 +117,17 @@ void f7(int *p) {
 }
 
 void f8(int n) {
-  int a[10];
+  int a[10] = {1};
   int d = a[n] - a[0];
 }
+
+int f9(const char *p1) {
+  const char *p2 = p1;
+  --p1;
+  ++p2;
+  return p1 - p2; // no-warning
+}
+
+int f10(struct S *p1, struct S *p2) {
+  return >c[5] - >c[5]; // no-warning
+}

``




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


[libunwind] [llvm] [runtimes] remove workaround for old CMake when setting `--unwindlib=none` (PR #93429)

2024-06-24 Thread antoine moynault via cfe-commits

antmox wrote:

I may be missing something, but it looks like the armv7m-picolibc-no-exceptions 
issue is still related to https://gitlab.kitware.com/cmake/cmake/-/issues/23454

I notice that once the `--unwindlib=none` flag is added to 
`CMAKE_REQUIRED_LINK_OPTIONS`, it is also added to ar commands during the next 
cmake tests (starting with `CXX_SUPPORTS_NOSTDLIBXX_FLAG`).
Failing these tests will result in `fno-exceptions` not being used later

This is probably due to the fact that for Armv7M-picolibc, 
`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to `STATIC_LIBRARY` here: 
https://github.com/llvm/llvm-project/blob/main/libcxx/cmake/caches/Armv7M-picolibc.cmake#L7C35-L7C49


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


[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-06-24 Thread Balázs Kéri via cfe-commits

https://github.com/balazske created 
https://github.com/llvm/llvm-project/pull/96501

The checker could report false positives if pointer arithmetic was done on 
pointers to non-array data before pointer subtraction. Another problem is fixed 
that could cause false positive if members of the same structure but in 
different memory objects are subtracted.

From b431151f83fa2980e4a132191ccf5713ab69806b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Mon, 24 Jun 2024 16:48:54 +0200
Subject: [PATCH] [clang][analyzer] Improve PointerSubChecker

The checker could report false positives if pointer arithmetic was
done on pointers to non-array data before pointer subtraction.
Another problem is fixed that could cause false positive if members
of the same structure but in different memory objects are subtracted.
---
 .../Checkers/PointerSubChecker.cpp| 22 --
 clang/test/Analysis/pointer-sub.c | 29 +--
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
index eea93a41f1384..63ed4df67d6d5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
@@ -49,12 +49,28 @@ class PointerSubChecker
 };
 }
 
+static bool isArrayVar(const MemRegion *R) {
+  while (R) {
+if (isa(R))
+  return true;
+if (const auto *ER = dyn_cast(R))
+  R = ER->getSuperRegion();
+else
+  return false;
+  }
+  return false;
+}
+
 bool PointerSubChecker::checkArrayBounds(CheckerContext , const Expr *E,
  const ElementRegion *ElemReg,
  const MemRegion *Reg) const {
   if (!ElemReg)
 return true;
 
+  const MemRegion *SuperReg = ElemReg->getSuperRegion();
+  if (!isArrayVar(SuperReg))
+return true;
+
   auto ReportBug = [&](const llvm::StringLiteral ) {
 if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
   auto R = std::make_unique(BT, Msg, N);
@@ -64,7 +80,6 @@ bool PointerSubChecker::checkArrayBounds(CheckerContext , 
const Expr *E,
   };
 
   ProgramStateRef State = C.getState();
-  const MemRegion *SuperReg = ElemReg->getSuperRegion();
   SValBuilder  = C.getSValBuilder();
 
   if (SuperReg == Reg) {
@@ -121,8 +136,9 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator 
*B,
   if (LR == RR)
 return;
 
-  // No warning if one operand is unknown.
-  if (isa(LR) || isa(RR))
+  // No warning if one operand is unknown or resides in a region that could be
+  // equal to the other.
+  if (LR->getSymbolicBase() || RR->getSymbolicBase())
 return;
 
   const auto *ElemLR = dyn_cast(LR);
diff --git a/clang/test/Analysis/pointer-sub.c 
b/clang/test/Analysis/pointer-sub.c
index 88e6dec2d172f..404b8530b89c0 100644
--- a/clang/test/Analysis/pointer-sub.c
+++ b/clang/test/Analysis/pointer-sub.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.PointerSub -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.PointerSub 
-analyzer-output=text-minimal -verify %s
 
 void f1(void) {
   int x, y, z[10];
@@ -73,15 +73,15 @@ void f4(void) {
   d = a[2] - a[1]; // expected-warning{{Subtraction of two pointers that}}
 }
 
-typedef struct {
+struct S {
   int a;
   int b;
   int c[10]; // expected-note2{{Array at the right-hand side of subtraction}}
   int d[10]; // expected-note2{{Array at the left-hand side of subtraction}}
-} S;
+};
 
 void f5(void) {
-  S s;
+  struct S s;
   int y;
   int d;
 
@@ -92,18 +92,18 @@ void f5(void) {
   d = [3] - [2]; // expected-warning{{Subtraction of two pointers 
that}}
   d = s.d - s.c; // expected-warning{{Subtraction of two pointers that}}
 
-  S sa[10];
+  struct S sa[10];
   d = [2] - [1];
   d = [2].a - [1].b; // expected-warning{{Subtraction of two pointers 
that}}
 }
 
 void f6(void) {
-  long long l;
+  long long l = 2;
   char *a1 = (char *)
   int d = a1[3] - l;
 
-  long long la1[3]; // expected-note{{Array at the right-hand side of 
subtraction}}
-  long long la2[3]; // expected-note{{Array at the left-hand side of 
subtraction}}
+  long long la1[3] = {1}; // expected-note{{Array at the right-hand side of 
subtraction}}
+  long long la2[3] = {1}; // expected-note{{Array at the left-hand side of 
subtraction}}
   char *pla1 = (char *)la1;
   char *pla2 = (char *)la2;
   d = pla1[1] - pla1[0];
@@ -117,6 +117,17 @@ void f7(int *p) {
 }
 
 void f8(int n) {
-  int a[10];
+  int a[10] = {1};
   int d = a[n] - a[0];
 }
+
+int f9(const char *p1) {
+  const char *p2 = p1;
+  --p1;
+  ++p2;
+  return p1 - p2; // no-warning
+}
+
+int f10(struct S *p1, struct S *p2) {
+  return >c[5] - >c[5]; // no-warning
+}

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-24 Thread Jon Roelofs via cfe-commits


@@ -1130,7 +1130,8 @@ INSTANTIATE_TEST_SUITE_P(
  AArch64::AEK_MTE, AArch64::AEK_SSBS,
  AArch64::AEK_FP16,AArch64::AEK_FP16FML,
  AArch64::AEK_SB,  AArch64::AEK_JSCVT,
- AArch64::AEK_FCMA,AArch64::AEK_PERFMON}),
+ AArch64::AEK_FCMA,AArch64::AEK_PERFMON,
+ AArch64::AEK_ETE, AArch64::AEK_AM}),

jroelofs wrote:

OMG that would be amazing. Dealing with downstream diff there is really 
painful. It would be fantastic to have each one on their own line so that any 
downstream changes are purely `+ lines`.

If you do that, please make sure it's in its own commit, and as NFC as you can 
make it, so it's much easier to "audit" when merging.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-24 Thread Lucas Duarte Prates via cfe-commits


@@ -161,6 +162,39 @@ static int PrintSupportedExtensions(std::string TargetStr) 
{
   return 0;
 }
 
+static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
+  std::string Error;
+  const llvm::Target *TheTarget =
+  llvm::TargetRegistry::lookupTarget(TargetOpts.Triple, Error);
+  if (!TheTarget) {
+llvm::errs() << Error;
+return 1;
+  }
+
+  llvm::TargetOptions BackendOptions;

pratlucas wrote:

`TargetOpts` captures the frontend options as a `clang::TargetOptions` 
instance. The target machine takes an instance of `llvm::TargetOptions` 
instead. It's confusing that the same class name was chosen for both.

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


[clang] [Doc] Update documentation for no-transitive-change (PR #96453)

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

ilya-biryukov wrote:

I really like the idea of documenting this, hopefully this create some fruitful 
discussions with the build system developers and other compiler users.

After trying to put myself into the shoes of the compiler users reading this, I 
can't help but think that the "no transitive changes"  is slightly confusing 
and hard to grasp. The example does help quite a bit, but I also feel there 
should be a way to document this in shorter form. (E.g. we can double-down on 
the "this is a build optimization" angle and being explicit that we want people 
to try this and let them know how to report bugs about it?)

I wanted to take a little bit of time to think how to do it before providing 
concrete suggestions, but still wanted to mention this.

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


[clang] b012ab0 - [C23] Claim conformance to WG14 N3033

2024-06-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2024-06-24T10:52:17-04:00
New Revision: b012ab01cb39e440a38dad5d7dd71b419480264b

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

LOG: [C23] Claim conformance to WG14 N3033

Clang has implemented __VA_OPT__ since Clang 12.

Added: 
clang/test/C/C2x/n3033.c
clang/test/C/C2x/n3033_2.c

Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/test/C/C2x/n3033.c b/clang/test/C/C2x/n3033.c
new file mode 100644
index 0..bf249a37facb3
--- /dev/null
+++ b/clang/test/C/C2x/n3033.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c23 -E %s | FileCheck %s
+
+/* WG14 N3033: Clang 12
+ * Comma ommission and deletion (__VA_OPT__)
+ */
+
+#define F(...)   f(0 __VA_OPT__(,) __VA_ARGS__)
+#define G(X, ...)f(0, X __VA_OPT__(,) __VA_ARGS__)
+#define SDEF(sname, ...) S sname __VA_OPT__(= { __VA_ARGS__ })
+#define EMP
+
+F(a, b, c)// replaced by f(0, a, b, c)
+// CHECK: f(0 , a, b, c)
+F()   // replaced by f(0)
+// CHECK: f(0 )
+F(EMP)// replaced by f(0)
+// CHECK: f(0 )
+
+G(a, b, c)// replaced by f(0, a, b, c)
+// CHECK: f(0, a , b, c)
+G(a, )// replaced by f(0, a)
+// CHECK: f(0, a )
+G(a)  // replaced by f(0, a)
+// CHECK: f(0, a )
+
+SDEF(foo);// replaced by S foo;
+// CHECK: S foo ;
+SDEF(bar, 1, 2);  // replaced by S bar = { 1, 2 };
+// CHECK: S bar = { 1, 2 };
+
+//#define H1(X, ...)   X __VA_OPT__(##) __VA_ARGS__  // error: ## may not 
appear at the beginning of a replacement list (6.10.3.3)
+
+#define H2(X, Y, ...)__VA_OPT__(X ## Y,) __VA_ARGS__
+H2(a, b, c, d)// replaced by ab, c, d
+// CHECK: ab, c, d
+
+#define H3(X, ...)   #__VA_OPT__(X##X X##X)
+H3(, 0)   // replaced by ""
+// CHECK: ""
+
+#define H4(X, ...)   __VA_OPT__(a X ## X) ## b
+H4(, 1)   // replaced by a b
+// CHECK: a b
+
+#define H5A(...) __VA_OPT__()/**/__VA_OPT__()
+#define H5B(X)   a ## X ## b
+#define H5C(X)   H5B(X)
+H5C(H5A())// replaced by ab
+// CHECK: ab
+

diff  --git a/clang/test/C/C2x/n3033_2.c b/clang/test/C/C2x/n3033_2.c
new file mode 100644
index 0..5da206658690c
--- /dev/null
+++ b/clang/test/C/C2x/n3033_2.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c23 -verify %s
+
+#define H1(X, ...)   X __VA_OPT__(##) __VA_ARGS__ // expected-error {{'##' 
cannot appear at start of __VA_OPT__ argument}}
+

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 6b375a6b7999d..f6a92d94874a5 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -1184,7 +1184,7 @@ C23 implementation status
 
   Comma ommission and deletion (__VA_OPT__)
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3033.htm;>N3033
-  Unknown
+  Clang 12
 
 
   Underspecified object definitions



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


[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Stephen Tozer (SLTozer)


Changes

Uses the new InsertPosition class (added in #94226) to simplify some of 
the IRBuilder interface, and removes the need to pass a BasicBlock alongside a 
BasicBlock::iterator, using the fact that we can now get the parent basic block 
from the iterator even if it points to the sentinel. This patch removes the 
BasicBlock argument from each constructor or call to setInsertPoint.

This has no functional effect, but later on as we look to remove the 
`Instruction *InsertBefore` argument from instruction-creation (discussed 
[here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)),
 this will simplify the process by allowing us to deprecate the InsertPosition 
constructor directly and catch all the cases where we use instructions rather 
than iterators.

---

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


97 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGGPUBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+3-4) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenABITypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2-2) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+15-63) 
- (modified) llvm/include/llvm/IR/Instruction.h (+6-2) 
- (modified) llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h 
(+1-3) 
- (modified) llvm/lib/Analysis/MemoryBuiltins.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/AtomicExpandPass.cpp (+4-4) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandLargeFpConvert.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandMemCmp.cpp (+3-3) 
- (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/HardwareLoops.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/IntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/SafeStack.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/ShadowStackGCLowering.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/SjLjEHPrepare.cpp (+2-3) 
- (modified) llvm/lib/CodeGen/WasmEHPrepare.cpp (+1-1) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+13-16) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+2-2) 
- (modified) llvm/lib/IR/Core.cpp (+1-1) 
- (modified) llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/ARMParallelDSP.cpp (+2-4) 
- (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/MVETailPredication.cpp (+1-1) 
- (modified) llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (+2-2) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+2-4) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp (+1-1) 
- (modified) llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp (+1-1) 
- (modified) llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp 
(+1-1) 
- (modified) llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp (+2-2) 
- (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-2) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-7) 
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+1-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2-3) 
- (modified) llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+22-22) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) 

[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Stephen Tozer (SLTozer)


Changes

Uses the new InsertPosition class (added in #94226) to simplify some of 
the IRBuilder interface, and removes the need to pass a BasicBlock alongside a 
BasicBlock::iterator, using the fact that we can now get the parent basic block 
from the iterator even if it points to the sentinel. This patch removes the 
BasicBlock argument from each constructor or call to setInsertPoint.

This has no functional effect, but later on as we look to remove the 
`Instruction *InsertBefore` argument from instruction-creation (discussed 
[here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)),
 this will simplify the process by allowing us to deprecate the InsertPosition 
constructor directly and catch all the cases where we use instructions rather 
than iterators.

---

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


97 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGGPUBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+3-4) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenABITypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2-2) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+15-63) 
- (modified) llvm/include/llvm/IR/Instruction.h (+6-2) 
- (modified) llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h 
(+1-3) 
- (modified) llvm/lib/Analysis/MemoryBuiltins.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/AtomicExpandPass.cpp (+4-4) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandLargeFpConvert.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandMemCmp.cpp (+3-3) 
- (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/HardwareLoops.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/IntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/SafeStack.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/ShadowStackGCLowering.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/SjLjEHPrepare.cpp (+2-3) 
- (modified) llvm/lib/CodeGen/WasmEHPrepare.cpp (+1-1) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+13-16) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+2-2) 
- (modified) llvm/lib/IR/Core.cpp (+1-1) 
- (modified) llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/ARMParallelDSP.cpp (+2-4) 
- (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/MVETailPredication.cpp (+1-1) 
- (modified) llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (+2-2) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+2-4) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp (+1-1) 
- (modified) llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp (+1-1) 
- (modified) llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp 
(+1-1) 
- (modified) llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp (+2-2) 
- (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-2) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-7) 
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+1-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2-3) 
- (modified) llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+22-22) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) 

[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-arm

Author: Stephen Tozer (SLTozer)


Changes

Uses the new InsertPosition class (added in #94226) to simplify some of 
the IRBuilder interface, and removes the need to pass a BasicBlock alongside a 
BasicBlock::iterator, using the fact that we can now get the parent basic block 
from the iterator even if it points to the sentinel. This patch removes the 
BasicBlock argument from each constructor or call to setInsertPoint.

This has no functional effect, but later on as we look to remove the 
`Instruction *InsertBefore` argument from instruction-creation (discussed 
[here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)),
 this will simplify the process by allowing us to deprecate the InsertPosition 
constructor directly and catch all the cases where we use instructions rather 
than iterators.

---

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


97 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGGPUBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+3-4) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenABITypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2-2) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+15-63) 
- (modified) llvm/include/llvm/IR/Instruction.h (+6-2) 
- (modified) llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h 
(+1-3) 
- (modified) llvm/lib/Analysis/MemoryBuiltins.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/AtomicExpandPass.cpp (+4-4) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandLargeFpConvert.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandMemCmp.cpp (+3-3) 
- (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/HardwareLoops.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/IntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/SafeStack.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/ShadowStackGCLowering.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/SjLjEHPrepare.cpp (+2-3) 
- (modified) llvm/lib/CodeGen/WasmEHPrepare.cpp (+1-1) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+13-16) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+2-2) 
- (modified) llvm/lib/IR/Core.cpp (+1-1) 
- (modified) llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/ARMParallelDSP.cpp (+2-4) 
- (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/MVETailPredication.cpp (+1-1) 
- (modified) llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (+2-2) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+2-4) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp (+1-1) 
- (modified) llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp (+1-1) 
- (modified) llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp 
(+1-1) 
- (modified) llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp (+2-2) 
- (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-2) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-7) 
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+1-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2-3) 
- (modified) llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+22-22) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) 

[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-hlsl
@llvm/pr-subscribers-backend-webassembly

@llvm/pr-subscribers-clang-codegen

Author: Stephen Tozer (SLTozer)


Changes

Uses the new InsertPosition class (added in #94226) to simplify some of 
the IRBuilder interface, and removes the need to pass a BasicBlock alongside a 
BasicBlock::iterator, using the fact that we can now get the parent basic block 
from the iterator even if it points to the sentinel. This patch removes the 
BasicBlock argument from each constructor or call to setInsertPoint.

This has no functional effect, but later on as we look to remove the 
`Instruction *InsertBefore` argument from instruction-creation (discussed 
[here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)),
 this will simplify the process by allowing us to deprecate the InsertPosition 
constructor directly and catch all the cases where we use instructions rather 
than iterators.

---

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


97 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGGPUBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+3-4) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenABITypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2-2) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+15-63) 
- (modified) llvm/include/llvm/IR/Instruction.h (+6-2) 
- (modified) llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h 
(+1-3) 
- (modified) llvm/lib/Analysis/MemoryBuiltins.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/AtomicExpandPass.cpp (+4-4) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandLargeFpConvert.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandMemCmp.cpp (+3-3) 
- (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/HardwareLoops.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/IntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/SafeStack.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/ShadowStackGCLowering.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/SjLjEHPrepare.cpp (+2-3) 
- (modified) llvm/lib/CodeGen/WasmEHPrepare.cpp (+1-1) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+13-16) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+2-2) 
- (modified) llvm/lib/IR/Core.cpp (+1-1) 
- (modified) llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/ARMParallelDSP.cpp (+2-4) 
- (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/MVETailPredication.cpp (+1-1) 
- (modified) llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (+2-2) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+2-4) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp (+1-1) 
- (modified) llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp (+1-1) 
- (modified) llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp 
(+1-1) 
- (modified) llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp (+2-2) 
- (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-2) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-7) 
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+1-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2-3) 
- (modified) llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+22-22) 
- (modified) 

[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Stephen Tozer (SLTozer)


Changes

Uses the new InsertPosition class (added in #94226) to simplify some of 
the IRBuilder interface, and removes the need to pass a BasicBlock alongside a 
BasicBlock::iterator, using the fact that we can now get the parent basic block 
from the iterator even if it points to the sentinel. This patch removes the 
BasicBlock argument from each constructor or call to setInsertPoint.

This has no functional effect, but later on as we look to remove the 
`Instruction *InsertBefore` argument from instruction-creation (discussed 
[here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)),
 this will simplify the process by allowing us to deprecate the InsertPosition 
constructor directly and catch all the cases where we use instructions rather 
than iterators.

---

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


97 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGGPUBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+3-4) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenABITypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2-2) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+15-63) 
- (modified) llvm/include/llvm/IR/Instruction.h (+6-2) 
- (modified) llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h 
(+1-3) 
- (modified) llvm/lib/Analysis/MemoryBuiltins.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/AtomicExpandPass.cpp (+4-4) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandLargeFpConvert.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandMemCmp.cpp (+3-3) 
- (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/HardwareLoops.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/IntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/SafeStack.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/ShadowStackGCLowering.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/SjLjEHPrepare.cpp (+2-3) 
- (modified) llvm/lib/CodeGen/WasmEHPrepare.cpp (+1-1) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+13-16) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+2-2) 
- (modified) llvm/lib/IR/Core.cpp (+1-1) 
- (modified) llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/ARMParallelDSP.cpp (+2-4) 
- (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/MVETailPredication.cpp (+1-1) 
- (modified) llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (+2-2) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+2-4) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp (+1-1) 
- (modified) llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp (+1-1) 
- (modified) llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp 
(+1-1) 
- (modified) llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp (+2-2) 
- (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-2) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-7) 
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+1-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2-3) 
- (modified) llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+22-22) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) 

[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-powerpc

Author: Stephen Tozer (SLTozer)


Changes

Uses the new InsertPosition class (added in #94226) to simplify some of 
the IRBuilder interface, and removes the need to pass a BasicBlock alongside a 
BasicBlock::iterator, using the fact that we can now get the parent basic block 
from the iterator even if it points to the sentinel. This patch removes the 
BasicBlock argument from each constructor or call to setInsertPoint.

This has no functional effect, but later on as we look to remove the 
`Instruction *InsertBefore` argument from instruction-creation (discussed 
[here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)),
 this will simplify the process by allowing us to deprecate the InsertPosition 
constructor directly and catch all the cases where we use instructions rather 
than iterators.

---

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


97 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGGPUBuiltin.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+3-4) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenABITypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2-2) 
- (modified) llvm/include/llvm/IR/IRBuilder.h (+15-63) 
- (modified) llvm/include/llvm/IR/Instruction.h (+6-2) 
- (modified) llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h 
(+1-3) 
- (modified) llvm/lib/Analysis/MemoryBuiltins.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/AtomicExpandPass.cpp (+4-4) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandLargeFpConvert.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/ExpandMemCmp.cpp (+3-3) 
- (modified) llvm/lib/CodeGen/ExpandVectorPredication.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/HardwareLoops.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/IntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/SafeStack.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/ShadowStackGCLowering.cpp (+2-2) 
- (modified) llvm/lib/CodeGen/SjLjEHPrepare.cpp (+2-3) 
- (modified) llvm/lib/CodeGen/WasmEHPrepare.cpp (+1-1) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+13-16) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+2-2) 
- (modified) llvm/lib/IR/Core.cpp (+1-1) 
- (modified) llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/ARMParallelDSP.cpp (+2-4) 
- (modified) llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp (+1-1) 
- (modified) llvm/lib/Target/ARM/MVETailPredication.cpp (+1-1) 
- (modified) llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (+2-2) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp (+2-4) 
- (modified) llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp (+1-1) 
- (modified) llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp (+1-1) 
- (modified) llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp 
(+1-1) 
- (modified) llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp (+2-2) 
- (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-2) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-7) 
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+1-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2-3) 
- (modified) llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+22-22) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) 

[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)

2024-06-24 Thread Stephen Tozer via cfe-commits

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


[clang] [Clang][SveEmitter] Split up TargetGuard into SVE and SME component. (PR #96482)

2024-06-24 Thread Paul Walker via cfe-commits

https://github.com/paulwalker-arm approved this pull request.

This is certainly a step in the right direction.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-24 Thread Lucas Duarte Prates via cfe-commits


@@ -161,6 +162,39 @@ static int PrintSupportedExtensions(std::string TargetStr) 
{
   return 0;
 }
 
+static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
+  std::string Error;
+  const llvm::Target *TheTarget =
+  llvm::TargetRegistry::lookupTarget(TargetOpts.Triple, Error);
+  if (!TheTarget) {
+llvm::errs() << Error;
+return 1;
+  }
+
+  llvm::TargetOptions BackendOptions;
+  std::string FeaturesStr = llvm::join(TargetOpts.FeaturesAsWritten, ",");
+  std::unique_ptr TheTargetMachine(
+  TheTarget->createTargetMachine(TargetOpts.Triple, TargetOpts.CPU, 
FeaturesStr, BackendOptions, std::nullopt));
+  const llvm::Triple  = TheTargetMachine->getTargetTriple();
+  const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo();
+  const std::vector Features =
+MCInfo->getEnabledProcessorFeatures();
+
+  std::vector EnabledFeatureNames;
+  for (const llvm::SubtargetFeatureKV  : Features)
+EnabledFeatureNames.push_back(feature.Key);

pratlucas wrote:

Unfortunately `llvm::SubtargetFeatureKV` doesn't hold a lot of information and 
semantics of its contents is even less clear the what's capture here. I'll add 
a comment to this block clarifying what's being captured. 

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


<    1   2   3   4   5   6   7   8   9   10   >