[clang] c4d0d95 - [KeyInstr][Clang] Reset atomGroup number for each function (#141607)

2025-05-28 Thread via cfe-commits

Author: Orlando Cazalet-Hyams
Date: 2025-05-28T11:25:41+01:00
New Revision: c4d0d95a4fb92d65594f3575814a027815b5182f

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

LOG: [KeyInstr][Clang] Reset atomGroup number for each function (#141607)

CGDebugInfo::completeFunction was added previously but mistakenly not
called (dropped through the cracks while putting together the patch
stack). Moved out of #134652 and #134654.

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

Added: 
clang/test/DebugInfo/KeyInstructions/multi-func.c

Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index e2357563f7d56..4193f0a1b278f 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -36,6 +36,7 @@
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Dominators.h"
@@ -1507,6 +1508,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, 
llvm::Function *Fn,
 // Disable debug info indefinitely for this function
 DebugInfo = nullptr;
   }
+  // Finalize function debug info on exit.
+  auto Cleanup = llvm::make_scope_exit([this] {
+if (CGDebugInfo *DI = getDebugInfo())
+  DI->completeFunction();
+  });
 
   // The function might not have a body if we're generating thunks for a
   // function declaration.

diff  --git a/clang/test/DebugInfo/KeyInstructions/multi-func.c 
b/clang/test/DebugInfo/KeyInstructions/multi-func.c
new file mode 100644
index 0..6e225eed81de8
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/multi-func.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions 
-gno-column-info -x c++ %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions 
-gno-column-info -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// Check atomGroup is reset to start at 1 in each function.
+
+int g;
+// CHECK: store{{.*}}, !dbg [[AG:!.*]]
+void a() { g = 0; }
+
+// CHECK: store{{.*}}, !dbg [[BG:!.*]]
+void b() { g = 0; }
+
+// CHECK: [[A:!.*]] = distinct !DISubprogram(name: "a",
+// CHECK: [[AG]] = !DILocation(line: 11, scope: [[A]], atomGroup: 1, atomRank: 
1)
+// CHECK: [[B:!.*]] = distinct !DISubprogram(name: "b",
+// CHECK: [[BG]] = !DILocation(line: 14, scope: [[B]], atomGroup: 1, atomRank: 
1)



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


[clang] [KeyInstr][Clang] Reset atomGroup number for each function (PR #141607)

2025-05-28 Thread Orlando Cazalet-Hyams via cfe-commits

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


[clang] [C2y] Add stdcountof.h (PR #140890)

2025-05-28 Thread Aaron Ballman via cfe-commits

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


[clang] 5ab944a - [C2y] Add stdcountof.h (#140890)

2025-05-28 Thread via cfe-commits

Author: Aaron Ballman
Date: 2025-05-28T06:41:01-04:00
New Revision: 5ab944a8c6a213beb96f3747a441b02e497732e4

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

LOG: [C2y] Add stdcountof.h (#140890)

WG14 N3469 changed _Lengthof to _Countof but it also introduced the
 header to expose a macro with a non-ugly identifier. GCC
vends this header as part of the compiler implementation, so Clang
should do the same.

Suggested-by: Alejandro Colomar 

Added: 
clang/lib/Headers/stdcountof.h

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Headers/CMakeLists.txt
clang/lib/Headers/module.modulemap
clang/lib/Lex/ModuleMap.cpp
clang/lib/Lex/PPDirectives.cpp
clang/test/C/C2y/n3469.c
clang/test/Modules/Inputs/builtin-headers/system-modules.modulemap
clang/test/Modules/builtin-headers.mm

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee74431cf33a7..c83f135da541c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -251,7 +251,9 @@ C2y Feature Support
   a conforming extension in earlier C language modes, but not in C++ language
   modes (``std::extent`` and ``std::size`` already provide the same
   functionality but with more granularity). The feature can be tested via
-  ``__has_feature(c_countof)`` or ``__has_extension(c_countof)``.
+  ``__has_feature(c_countof)`` or ``__has_extension(c_countof)``. This also
+  adds the  header file which exposes the ``countof`` macro
+  which expands to ``_Countof``.
 
 C23 Feature Support
 ^^^

diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index 53219dc932587..24f5327b07dda 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -18,6 +18,7 @@ set(core_files
   __stdarg_va_list.h
   stdatomic.h
   stdbool.h
+  stdcountof.h
   stdckdint.h
   stddef.h
   __stddef_header_macro.h

diff  --git a/clang/lib/Headers/module.modulemap 
b/clang/lib/Headers/module.modulemap
index dcaf09e8f2c55..35897a3ed0e79 100644
--- a/clang/lib/Headers/module.modulemap
+++ b/clang/lib/Headers/module.modulemap
@@ -231,6 +231,11 @@ module _Builtin_stdbool [system] {
   export *
 }
 
+module _Builtin_stdcountof [system] {
+  header "stdcountof.h"
+  export *
+}
+
 module _Builtin_stddef [system] {
   textual header "stddef.h"
 

diff  --git a/clang/lib/Headers/stdcountof.h b/clang/lib/Headers/stdcountof.h
new file mode 100644
index 0..5714e6d6ff860
--- /dev/null
+++ b/clang/lib/Headers/stdcountof.h
@@ -0,0 +1,15 @@
+/*=== stdcountof.h - Standard header for countof ---===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __STDCOUNTOF_H
+#define __STDCOUNTOF_H
+
+#define countof _Countof
+
+#endif /* __STDCOUNTOF_H */

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index c088e4eecb3fb..637a08fe4dcdb 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -258,6 +258,7 @@ static bool isBuiltinHeaderName(StringRef FileName) {
.Case("stdarg.h", true)
.Case("stdatomic.h", true)
.Case("stdbool.h", true)
+   .Case("stdcountof.h", true)
.Case("stddef.h", true)
.Case("stdint.h", true)
.Case("tgmath.h", true)

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index b2a8459d6b9cc..68f9ca9cb4d40 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -252,8 +252,8 @@ static bool warnByDefaultOnWrongCase(StringRef Include) {
 .Cases("assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", true)
 .Cases("float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", true)
 .Cases("math.h", "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", true)
-.Cases("stdatomic.h", "stdbool.h", "stdckdint.h", "stddef.h", true)
-.Cases("stdint.h", "stdio.h", "stdlib.h", "stdnoreturn.h", true)
+.Cases("stdatomic.h", "stdbool.h", "stdckdint.h", "stdcountof.h", true)
+.Cases("stddef.h", "stdint.h", "stdio.h", "stdlib.h", "stdnoreturn.h", 
true)
 .Cases("string.h", "tgmath.h", "threads.h", "time.h", "uchar.h", true)
 .Cases("wchar.h", "wctype.h", true)
 

diff  --git a/clang/test/C/C2y/n3469.c b/clang/test/C/C2y/n3469.c
index 3d9ac8e6411e9..4660596614075 100644
--- a/clang/test/C/C2y/n3469.c
+++ b/clang/test/C/C2y/n3469.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c2y -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2y 

[clang] [KeyIntsr][Clang] Builtins alloca auto-init atom (PR #134651)

2025-05-28 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134651

>From bf3a37df3a82797227e476485f6cf4c0c9a7c912 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Fri, 4 Apr 2025 14:36:43 +0100
Subject: [PATCH 1/5] [KeyInstr][Clang] Store-like builtin atoms

---
 clang/lib/CodeGen/CGBuiltin.cpp  | 30 +++
 clang/test/KeyInstructions/builtin.c | 77 
 2 files changed, 97 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/KeyInstructions/builtin.c

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 809ffe549be88..fd46b6c40ccd9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4352,7 +4352,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(1));
 EmitNonNullArgCheck(Dest, E->getArg(0)->getType(),
 E->getArg(0)->getExprLoc(), FD, 0);
-Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
+auto *I = Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
+addInstToNewSourceAtom(I, nullptr);
 return RValue::get(nullptr);
   }
 
@@ -4367,7 +4368,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 EmitNonNullArgCheck(RValue::get(Dest.emitRawPointer(*this)),
 E->getArg(1)->getType(), E->getArg(1)->getExprLoc(), 
FD,
 0);
-Builder.CreateMemMove(Dest, Src, SizeVal, false);
+auto *I = Builder.CreateMemMove(Dest, Src, SizeVal, false);
+addInstToNewSourceAtom(I, nullptr);
 return RValue::get(nullptr);
   }
 
@@ -4380,7 +4382,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(2));
 EmitArgCheck(TCK_Store, Dest, E->getArg(0), 0);
 EmitArgCheck(TCK_Load, Src, E->getArg(1), 1);
-Builder.CreateMemCpy(Dest, Src, SizeVal, false);
+auto *I = Builder.CreateMemCpy(Dest, Src, SizeVal, false);
+addInstToNewSourceAtom(I, nullptr);
 if (BuiltinID == Builtin::BImempcpy ||
 BuiltinID == Builtin::BI__builtin_mempcpy)
   return RValue::get(Builder.CreateInBoundsGEP(
@@ -4396,7 +4399,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 E->getArg(2)->EvaluateKnownConstInt(getContext()).getZExtValue();
 EmitArgCheck(TCK_Store, Dest, E->getArg(0), 0);
 EmitArgCheck(TCK_Load, Src, E->getArg(1), 1);
-Builder.CreateMemCpyInline(Dest, Src, Size);
+auto *I = Builder.CreateMemCpyInline(Dest, Src, Size);
+addInstToNewSourceAtom(I, nullptr);
 return RValue::get(nullptr);
   }
 
@@ -4417,7 +4421,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Address Dest = EmitPointerWithAlignment(E->getArg(0));
 Address Src = EmitPointerWithAlignment(E->getArg(1));
 Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size);
-Builder.CreateMemCpy(Dest, Src, SizeVal, false);
+auto *I = Builder.CreateMemCpy(Dest, Src, SizeVal, false);
+addInstToNewSourceAtom(I, nullptr);
 return RValue::get(Dest, *this);
   }
 
@@ -4443,7 +4448,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Address Dest = EmitPointerWithAlignment(E->getArg(0));
 Address Src = EmitPointerWithAlignment(E->getArg(1));
 Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size);
-Builder.CreateMemMove(Dest, Src, SizeVal, false);
+auto *I = Builder.CreateMemMove(Dest, Src, SizeVal, false);
+addInstToNewSourceAtom(I, nullptr);
 return RValue::get(Dest, *this);
   }
 
@@ -4455,7 +4461,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(2));
 EmitArgCheck(TCK_Store, Dest, E->getArg(0), 0);
 EmitArgCheck(TCK_Load, Src, E->getArg(1), 1);
-Builder.CreateMemMove(Dest, Src, SizeVal, false);
+auto *I = Builder.CreateMemMove(Dest, Src, SizeVal, false);
+addInstToNewSourceAtom(I, nullptr);
 return RValue::get(Dest, *this);
   }
   case Builtin::BImemset:
@@ -4466,7 +4473,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(2));
 EmitNonNullArgCheck(Dest, E->getArg(0)->getType(),
 E->getArg(0)->getExprLoc(), FD, 0);
-Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
+auto *I = Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
+addInstToNewSourceAtom(I, nullptr);
 return RValue::get(Dest, *this);
   }
   case Builtin::BI__builtin_memset_inline: {
@@ -4478,7 +4486,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 EmitNonNullArgCheck(RValue::get(Dest.emitRawPointer(*this)),
 E->getArg(0)->getType(

[clang] [KeyIntsr][Clang] Builtins alloca auto-init atom (PR #134651)

2025-05-28 Thread Orlando Cazalet-Hyams via cfe-commits


@@ -4466,7 +4473,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(2));
 EmitNonNullArgCheck(Dest, E->getArg(0)->getType(),
 E->getArg(0)->getExprLoc(), FD, 0);
-Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
+auto *I = Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);

OCHyams wrote:

Fair point - done. The other memsets covered so far look like they all store 
constants.

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


[clang] [KeyInstr][Clang] Reset atomGroup number for each function (PR #141607)

2025-05-28 Thread Stephen Tozer via cfe-commits

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


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


[clang] [flang] [flang][driver] Introduce FCC_OVERRIDE_OPTIONS. (PR #140556)

2025-05-28 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

Does `CCC_OVERRIDE_OPTIONS` expands to Clang Compiler Commandline Override 
Options? If so `FCC_OVERRIDE_OPTIONS` expanding to Fortran Compiler Commandline 
Override Options seems the right replacement.

If `CCC_OVERRIDE_OPTIONS` expands to Clang C Compiler Override Options then 
`FFC_OVERRIDE_OPTIONS` (as suggested by @tarunprabhu) expanding to Flang 
Fortran Compiler Overrided Options is better.

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


[clang] [Clang] Reset ArgPackSubstIndex before rewriting CTAD template parameters (PR #141741)

2025-05-28 Thread Younan Zhang via cfe-commits

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

032ad59 taught the instantiator to expand template argument packs for rewrite. 
However we might already be in a pack expansion when we synthesizing the CTAD 
guide, so we reset the ArgPackSubstIndex to ensure it doesn't get confused.

No release note because this is a regression in Clang 21.

>From 4fdb0069e260e36d8cbd021536adc14f6b9ddef1 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Wed, 28 May 2025 18:37:38 +0800
Subject: [PATCH] [Clang] Reset ArgPackSubstIndex before rewriting CTAD
 template parameters

032ad59 taught the instantiator to expand template argument
packs for rewrite. However we might already be in a pack expansion when
we synthesizing the CTAD guide, so we reset the ArgPackSubstIndex to
ensure it doesn't get confused.
---
 clang/lib/Sema/SemaTemplateDeductionGuide.cpp |  4 ++
 clang/test/SemaTemplate/deduction-guide.cpp   | 53 +++
 2 files changed, 57 insertions(+)

diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 29c5736a9bf9e..b5394a75479f1 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -1099,6 +1099,10 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   // parameters, used for building `TemplateArgsForBuildingFPrime`.
   SmallVector TransformedDeducedAliasArgs(
   AliasTemplate->getTemplateParameters()->size());
+  // We might be already within a pack expansion, but rewriting template
+  // parameters is independent of that. (We may or may not expand new packs
+  // when rewriting. So clear the state)
+  Sema::ArgPackSubstIndexRAII _(SemaRef, std::nullopt);
 
   for (unsigned AliasTemplateParamIdx : DeducedAliasTemplateParams) {
 auto *TP =
diff --git a/clang/test/SemaTemplate/deduction-guide.cpp 
b/clang/test/SemaTemplate/deduction-guide.cpp
index c1ce55e1c8029..faabba5539503 100644
--- a/clang/test/SemaTemplate/deduction-guide.cpp
+++ b/clang/test/SemaTemplate/deduction-guide.cpp
@@ -913,3 +913,56 @@ void f() {
 // CHECK-NEXT:   `-ParmVarDecl {{.+}} 'int'
 
 }
+
+namespace GH141425 {
+
+template
+struct Container
+{
+Container(Lambda...) {}
+};
+
+template
+using Alias = Container;
+
+template
+struct Invocable {
+using T = decltype([]() {
+(void)Alias([]() -> void {});
+}());
+};
+
+struct Type {
+using T = bool;
+};
+
+template
+struct ExpandType {
+using T = bool;
+};
+
+template
+using Expand = ExpandType;
+
+Expand> _{};
+
+// CHECK-LABEL: Dumping GH141425:::
+// CHECK-NEXT:  FunctionTemplateDecl {{.+}} implicit 
+// CHECK-NEXT:   |-TemplateTypeParmDecl {{.+}} class depth 0 index 0 ... T
+// CHECK-NEXT:   |-TypeTraitExpr {{.+}} 'bool' __is_deducible
+// CHECK-NEXT:   | |-DeducedTemplateSpecializationType {{.+}} 
'GH141425::Alias' dependent
+// CHECK-NEXT:   | | `-name: 'GH141425::Alias'
+// CHECK-NEXT:   | |   `-TypeAliasTemplateDecl {{.+}} Alias
+// CHECK-NEXT:   | `-TemplateSpecializationType {{.+}} 'Container' 
dependent
+// CHECK-NEXT:   |   |-name: 'Container':'GH141425::Container' qualified
+// CHECK-NEXT:   |   | `-ClassTemplateDecl {{.+}} Container
+// CHECK-NEXT:   |   `-TemplateArgument type 'T...':'type-parameter-0-0...'
+// CHECK-NEXT:   | `-PackExpansionType {{.+}} 'T...' dependent
+// CHECK-NEXT:   |   `-SubstTemplateTypeParmType {{.+}} 'T' sugar 
dependent contains_unexpanded_pack class depth 0 index 0 ... Lambda pack_index 0
+// CHECK-NEXT:   | |-FunctionTemplate {{.+}} ''
+// CHECK-NEXT:   | `-TemplateTypeParmType {{.+}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK-NEXT:   |   `-TemplateTypeParm {{.+}} 'T'
+// CHECK-NEXT:   |-CXXDeductionGuideDecl {{.+}} implicit  'auto (T...) -> Container'
+// CHECK-NEXT:   | `-ParmVarDecl {{.+}} 'T...' pack
+
+}

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


[clang] [Clang] Reset ArgPackSubstIndex before rewriting CTAD template parameters (PR #141741)

2025-05-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

032ad59 taught the instantiator to expand template argument packs for rewrite. 
However we might already be in a pack expansion when we synthesizing the CTAD 
guide, so we reset the ArgPackSubstIndex to ensure it doesn't get confused.

No release note because this is a regression in Clang 21.

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

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+4) 
- (modified) clang/test/SemaTemplate/deduction-guide.cpp (+53) 


``diff
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 29c5736a9bf9e..b5394a75479f1 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -1099,6 +1099,10 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   // parameters, used for building `TemplateArgsForBuildingFPrime`.
   SmallVector TransformedDeducedAliasArgs(
   AliasTemplate->getTemplateParameters()->size());
+  // We might be already within a pack expansion, but rewriting template
+  // parameters is independent of that. (We may or may not expand new packs
+  // when rewriting. So clear the state)
+  Sema::ArgPackSubstIndexRAII _(SemaRef, std::nullopt);
 
   for (unsigned AliasTemplateParamIdx : DeducedAliasTemplateParams) {
 auto *TP =
diff --git a/clang/test/SemaTemplate/deduction-guide.cpp 
b/clang/test/SemaTemplate/deduction-guide.cpp
index c1ce55e1c8029..faabba5539503 100644
--- a/clang/test/SemaTemplate/deduction-guide.cpp
+++ b/clang/test/SemaTemplate/deduction-guide.cpp
@@ -913,3 +913,56 @@ void f() {
 // CHECK-NEXT:   `-ParmVarDecl {{.+}} 'int'
 
 }
+
+namespace GH141425 {
+
+template
+struct Container
+{
+Container(Lambda...) {}
+};
+
+template
+using Alias = Container;
+
+template
+struct Invocable {
+using T = decltype([]() {
+(void)Alias([]() -> void {});
+}());
+};
+
+struct Type {
+using T = bool;
+};
+
+template
+struct ExpandType {
+using T = bool;
+};
+
+template
+using Expand = ExpandType;
+
+Expand> _{};
+
+// CHECK-LABEL: Dumping GH141425:::
+// CHECK-NEXT:  FunctionTemplateDecl {{.+}} implicit 
+// CHECK-NEXT:   |-TemplateTypeParmDecl {{.+}} class depth 0 index 0 ... T
+// CHECK-NEXT:   |-TypeTraitExpr {{.+}} 'bool' __is_deducible
+// CHECK-NEXT:   | |-DeducedTemplateSpecializationType {{.+}} 
'GH141425::Alias' dependent
+// CHECK-NEXT:   | | `-name: 'GH141425::Alias'
+// CHECK-NEXT:   | |   `-TypeAliasTemplateDecl {{.+}} Alias
+// CHECK-NEXT:   | `-TemplateSpecializationType {{.+}} 'Container' 
dependent
+// CHECK-NEXT:   |   |-name: 'Container':'GH141425::Container' qualified
+// CHECK-NEXT:   |   | `-ClassTemplateDecl {{.+}} Container
+// CHECK-NEXT:   |   `-TemplateArgument type 'T...':'type-parameter-0-0...'
+// CHECK-NEXT:   | `-PackExpansionType {{.+}} 'T...' dependent
+// CHECK-NEXT:   |   `-SubstTemplateTypeParmType {{.+}} 'T' sugar 
dependent contains_unexpanded_pack class depth 0 index 0 ... Lambda pack_index 0
+// CHECK-NEXT:   | |-FunctionTemplate {{.+}} ''
+// CHECK-NEXT:   | `-TemplateTypeParmType {{.+}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK-NEXT:   |   `-TemplateTypeParm {{.+}} 'T'
+// CHECK-NEXT:   |-CXXDeductionGuideDecl {{.+}} implicit  'auto (T...) -> Container'
+// CHECK-NEXT:   | `-ParmVarDecl {{.+}} 'T...' pack
+
+}

``




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


[clang] [Clang] Reset ArgPackSubstIndex before rewriting CTAD template parameters (PR #141741)

2025-05-28 Thread Younan Zhang via cfe-commits

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


[clang] [llvm] [clang][CodeGen][AA] Add `!llvm.errno.tbaa` gathering int-compatible TBAA nodes (PR #125258)

2025-05-28 Thread Antonio Frighetto via cfe-commits

antoniofrighetto wrote:

> Sorry, can you back up and explain the root problem you're trying to solve? 
> You have a platform where we're emitting accesses to `errno` as if it weren't 
> an `int`? What does it look like in source?

Oh, sorry for not providing context earlier. The reasoning behind is to allow 
certain optimizations involving errno-writing libcalls to occur, if we are able 
to prove the involved memory location does not alias errno (e.g., because we 
are accessing a float-typed pointer). IIUC, in standard C, errno is an int, so 
all legitimate accesses must use int-compatible types (or otherwise violating 
strict aliasing). Hence, we should be able to leverage TBAA and prove not 
aliasing with errno, if we do not alias for any nodes belonging to 
`!llvm.errno.tbaa` (which is presumably gathering all int-based nodes; this 
should require confirmation).

Original miscompilation issue: 
https://github.com/llvm/llvm-project/issues/114772, previous discussion at: 
https://discourse.llvm.org/t/rfc-modelling-errno-memory-effects/82972.

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


[clang] [NFC][AArch64] Add relnote saying modal FP8 intrinsics now fully implemented by ACLE (PR #141743)

2025-05-28 Thread Jonathan Thackray via cfe-commits

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

None

>From a76663bd47510c46b7c4415d4b5d97642ce69967 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 28 May 2025 11:47:00 +0100
Subject: [PATCH] [NFC][AArch64] Add relnote saying modal FP8 intrinsics now
 fully implemented by ACLE

---
 clang/docs/ReleaseNotes.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee74431cf33a7..0e375d72b62b4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -849,6 +849,10 @@ X86 Support
 Arm and AArch64 Support
 ^^^
 
+- Implementation of modal 8-bit floating point intrinsics in accordance with
+  the Arm C Language Extensions (ACLE)
+  `as specified here 
_`
+  is now available.
 - Support has been added for the following processors (command-line 
identifiers in parentheses):
   - Arm Cortex-A320 (``cortex-a320``)
 - For ARM targets, cc1as now considers the FPU's features for the selected CPU 
or Architecture.

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


[clang] [clang][bytecode] Recursively start lifetimes as well (PR #141742)

2025-05-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

The constructor starts the lifetime of all the subobjects.

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


3 Files Affected:

- (modified) clang/lib/AST/ByteCode/DynamicAllocator.cpp (+5-3) 
- (modified) clang/lib/AST/ByteCode/Interp.cpp (+30-7) 
- (modified) clang/test/AST/ByteCode/placement-new.cpp (+42) 


``diff
diff --git a/clang/lib/AST/ByteCode/DynamicAllocator.cpp 
b/clang/lib/AST/ByteCode/DynamicAllocator.cpp
index 733984508ed79..4f0f511fb6164 100644
--- a/clang/lib/AST/ByteCode/DynamicAllocator.cpp
+++ b/clang/lib/AST/ByteCode/DynamicAllocator.cpp
@@ -86,9 +86,11 @@ Block *DynamicAllocator::allocate(const Descriptor *D, 
unsigned EvalID,
   ID->IsInitialized = false;
   ID->IsVolatile = false;
 
-  ID->LifeState =
-  AllocForm == Form::Operator ? Lifetime::Ended : Lifetime::Started;
-  ;
+  if (D->isCompositeArray())
+ID->LifeState = Lifetime::Started;
+  else
+ID->LifeState =
+AllocForm == Form::Operator ? Lifetime::Ended : Lifetime::Started;
 
   B->IsDynamic = true;
 
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index e454d9e3bc218..a8286dd75f09a 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1699,20 +1699,38 @@ bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t 
ArgSize,
   return Call(S, OpPC, F, VarArgSize);
 }
 
+static void startLifetimeRecurse(const Pointer &Ptr) {
+  if (const Record *R = Ptr.getRecord()) {
+Ptr.startLifetime();
+for (const Record::Field &Fi : R->fields())
+  startLifetimeRecurse(Ptr.atField(Fi.Offset));
+return;
+  }
+
+  if (const Descriptor *FieldDesc = Ptr.getFieldDesc();
+  FieldDesc->isCompositeArray()) {
+assert(Ptr.getLifetime() == Lifetime::Started);
+for (unsigned I = 0; I != FieldDesc->getNumElems(); ++I)
+  startLifetimeRecurse(Ptr.atIndex(I).narrow());
+return;
+  }
+
+  Ptr.startLifetime();
+}
+
 bool StartLifetime(InterpState &S, CodePtr OpPC) {
   const auto &Ptr = S.Stk.peek();
   if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
 return false;
-
-  Ptr.startLifetime();
+  startLifetimeRecurse(Ptr.narrow());
   return true;
 }
 
 // FIXME: It might be better to the recursing as part of the generated code for
 // a destructor?
 static void endLifetimeRecurse(const Pointer &Ptr) {
-  Ptr.endLifetime();
   if (const Record *R = Ptr.getRecord()) {
+Ptr.endLifetime();
 for (const Record::Field &Fi : R->fields())
   endLifetimeRecurse(Ptr.atField(Fi.Offset));
 return;
@@ -1720,9 +1738,14 @@ static void endLifetimeRecurse(const Pointer &Ptr) {
 
   if (const Descriptor *FieldDesc = Ptr.getFieldDesc();
   FieldDesc->isCompositeArray()) {
+// No endLifetime() for array roots.
+assert(Ptr.getLifetime() == Lifetime::Started);
 for (unsigned I = 0; I != FieldDesc->getNumElems(); ++I)
   endLifetimeRecurse(Ptr.atIndex(I).narrow());
+return;
   }
+
+  Ptr.endLifetime();
 }
 
 /// Ends the lifetime of the peek'd pointer.
@@ -1730,7 +1753,7 @@ bool EndLifetime(InterpState &S, CodePtr OpPC) {
   const auto &Ptr = S.Stk.peek();
   if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
 return false;
-  endLifetimeRecurse(Ptr);
+  endLifetimeRecurse(Ptr.narrow());
   return true;
 }
 
@@ -1739,7 +1762,7 @@ bool EndLifetimePop(InterpState &S, CodePtr OpPC) {
   const auto &Ptr = S.Stk.pop();
   if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
 return false;
-  endLifetimeRecurse(Ptr);
+  endLifetimeRecurse(Ptr.narrow());
   return true;
 }
 
@@ -1758,9 +1781,9 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, 
const Expr *E,
 
   // CheckLifetime for this and all base pointers.
   for (Pointer P = Ptr;;) {
-if (!CheckLifetime(S, OpPC, P, AK_Construct)) {
+if (!CheckLifetime(S, OpPC, P, AK_Construct))
   return false;
-}
+
 if (P.isRoot())
   break;
 P = P.getBase();
diff --git a/clang/test/AST/ByteCode/placement-new.cpp 
b/clang/test/AST/ByteCode/placement-new.cpp
index a301c96739c83..f23d71510602c 100644
--- a/clang/test/AST/ByteCode/placement-new.cpp
+++ b/clang/test/AST/ByteCode/placement-new.cpp
@@ -423,3 +423,45 @@ namespace SubObj {
   }
   static_assert(construct_after_lifetime_2()); // both-error {{}} both-note 
{{in call}}
 }
+
+namespace RecursiveLifetimeStart {
+  struct B {
+int b;
+  };
+
+  struct A {
+B b;
+int a;
+  };
+
+  constexpr int foo() {
+A a;
+a.~A();
+
+new (&a) A();
+a.a = 10;
+a.b.b = 12;
+return a.a;
+  }
+  static_assert(foo() == 10);
+}
+
+namespace ArrayRoot {
+  struct S {
+int a;
+  };
+  constexpr int foo() {
+S* ss = std::allocator().allocate(2);
+new (ss) S{};
+new (ss + 1) S{};
+
+S* ps = &ss[2];
+ps = ss;
+ps->~S();
+
+std::allocator().deallocate(ss);
+return 0;
+  }
+
+  static_assert(foo() == 0);
+}

``




https://github.com/llvm/llv

[clang] [clang][bytecode] Recursively start lifetimes as well (PR #141742)

2025-05-28 Thread Timm Baeder via cfe-commits

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

The constructor starts the lifetime of all the subobjects.

>From 11f8d2e4c3282a9b49f9cf08b7d16f6c32e08134 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 28 May 2025 11:27:39 +0200
Subject: [PATCH] [clang][bytecode] Recursively start lifetimes as well

The constructor starts the lifetime of all the subobjects.
---
 clang/lib/AST/ByteCode/DynamicAllocator.cpp |  8 ++--
 clang/lib/AST/ByteCode/Interp.cpp   | 37 ++
 clang/test/AST/ByteCode/placement-new.cpp   | 42 +
 3 files changed, 77 insertions(+), 10 deletions(-)

diff --git a/clang/lib/AST/ByteCode/DynamicAllocator.cpp 
b/clang/lib/AST/ByteCode/DynamicAllocator.cpp
index 733984508ed79..4f0f511fb6164 100644
--- a/clang/lib/AST/ByteCode/DynamicAllocator.cpp
+++ b/clang/lib/AST/ByteCode/DynamicAllocator.cpp
@@ -86,9 +86,11 @@ Block *DynamicAllocator::allocate(const Descriptor *D, 
unsigned EvalID,
   ID->IsInitialized = false;
   ID->IsVolatile = false;
 
-  ID->LifeState =
-  AllocForm == Form::Operator ? Lifetime::Ended : Lifetime::Started;
-  ;
+  if (D->isCompositeArray())
+ID->LifeState = Lifetime::Started;
+  else
+ID->LifeState =
+AllocForm == Form::Operator ? Lifetime::Ended : Lifetime::Started;
 
   B->IsDynamic = true;
 
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index e454d9e3bc218..a8286dd75f09a 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1699,20 +1699,38 @@ bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t 
ArgSize,
   return Call(S, OpPC, F, VarArgSize);
 }
 
+static void startLifetimeRecurse(const Pointer &Ptr) {
+  if (const Record *R = Ptr.getRecord()) {
+Ptr.startLifetime();
+for (const Record::Field &Fi : R->fields())
+  startLifetimeRecurse(Ptr.atField(Fi.Offset));
+return;
+  }
+
+  if (const Descriptor *FieldDesc = Ptr.getFieldDesc();
+  FieldDesc->isCompositeArray()) {
+assert(Ptr.getLifetime() == Lifetime::Started);
+for (unsigned I = 0; I != FieldDesc->getNumElems(); ++I)
+  startLifetimeRecurse(Ptr.atIndex(I).narrow());
+return;
+  }
+
+  Ptr.startLifetime();
+}
+
 bool StartLifetime(InterpState &S, CodePtr OpPC) {
   const auto &Ptr = S.Stk.peek();
   if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
 return false;
-
-  Ptr.startLifetime();
+  startLifetimeRecurse(Ptr.narrow());
   return true;
 }
 
 // FIXME: It might be better to the recursing as part of the generated code for
 // a destructor?
 static void endLifetimeRecurse(const Pointer &Ptr) {
-  Ptr.endLifetime();
   if (const Record *R = Ptr.getRecord()) {
+Ptr.endLifetime();
 for (const Record::Field &Fi : R->fields())
   endLifetimeRecurse(Ptr.atField(Fi.Offset));
 return;
@@ -1720,9 +1738,14 @@ static void endLifetimeRecurse(const Pointer &Ptr) {
 
   if (const Descriptor *FieldDesc = Ptr.getFieldDesc();
   FieldDesc->isCompositeArray()) {
+// No endLifetime() for array roots.
+assert(Ptr.getLifetime() == Lifetime::Started);
 for (unsigned I = 0; I != FieldDesc->getNumElems(); ++I)
   endLifetimeRecurse(Ptr.atIndex(I).narrow());
+return;
   }
+
+  Ptr.endLifetime();
 }
 
 /// Ends the lifetime of the peek'd pointer.
@@ -1730,7 +1753,7 @@ bool EndLifetime(InterpState &S, CodePtr OpPC) {
   const auto &Ptr = S.Stk.peek();
   if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
 return false;
-  endLifetimeRecurse(Ptr);
+  endLifetimeRecurse(Ptr.narrow());
   return true;
 }
 
@@ -1739,7 +1762,7 @@ bool EndLifetimePop(InterpState &S, CodePtr OpPC) {
   const auto &Ptr = S.Stk.pop();
   if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
 return false;
-  endLifetimeRecurse(Ptr);
+  endLifetimeRecurse(Ptr.narrow());
   return true;
 }
 
@@ -1758,9 +1781,9 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, 
const Expr *E,
 
   // CheckLifetime for this and all base pointers.
   for (Pointer P = Ptr;;) {
-if (!CheckLifetime(S, OpPC, P, AK_Construct)) {
+if (!CheckLifetime(S, OpPC, P, AK_Construct))
   return false;
-}
+
 if (P.isRoot())
   break;
 P = P.getBase();
diff --git a/clang/test/AST/ByteCode/placement-new.cpp 
b/clang/test/AST/ByteCode/placement-new.cpp
index a301c96739c83..f23d71510602c 100644
--- a/clang/test/AST/ByteCode/placement-new.cpp
+++ b/clang/test/AST/ByteCode/placement-new.cpp
@@ -423,3 +423,45 @@ namespace SubObj {
   }
   static_assert(construct_after_lifetime_2()); // both-error {{}} both-note 
{{in call}}
 }
+
+namespace RecursiveLifetimeStart {
+  struct B {
+int b;
+  };
+
+  struct A {
+B b;
+int a;
+  };
+
+  constexpr int foo() {
+A a;
+a.~A();
+
+new (&a) A();
+a.a = 10;
+a.b.b = 12;
+return a.a;
+  }
+  static_assert(foo() == 10);
+}
+
+namespace ArrayRoot {
+  struct S {
+int a;
+  };
+  constexpr int foo() {
+S* ss = std::allocator().alloca

[clang] [NFC][AArch64] Add relnote saying modal FP8 intrinsics now fully implemented by ACLE (PR #141743)

2025-05-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jonathan Thackray (jthackray)


Changes



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


1 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee74431cf33a7..0e375d72b62b4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -849,6 +849,10 @@ X86 Support
 Arm and AArch64 Support
 ^^^
 
+- Implementation of modal 8-bit floating point intrinsics in accordance with
+  the Arm C Language Extensions (ACLE)
+  `as specified here 
_`
+  is now available.
 - Support has been added for the following processors (command-line 
identifiers in parentheses):
   - Arm Cortex-A320 (``cortex-a320``)
 - For ARM targets, cc1as now considers the FPU's features for the selected CPU 
or Architecture.

``




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


[clang] [CIR] Defer declarations and tentative definitions (PR #141700)

2025-05-28 Thread Henrich Lauko via cfe-commits

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


[clang] [KeyInstr][Clang] For stmt atom (PR #134646)

2025-05-28 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134646

>From 0c7a83007e218dd7338b92f1d50319b0f35cf55f Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 3 Apr 2025 19:12:47 +0100
Subject: [PATCH 1/7] [KeyInstr][Clang] For stmt atom

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
---
 clang/lib/CodeGen/CGStmt.cpp   | 18 +--
 clang/test/DebugInfo/KeyInstructions/for.c | 37 ++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/DebugInfo/KeyInstructions/for.c

diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 31d64a5a788ee..0655e38cd4e4b 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1326,6 +1326,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
 Continue = getJumpDestInCurrentScope("for.inc");
   BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
 
+  llvm::BasicBlock *ForBody = nullptr;
   if (S.getCond()) {
 // If the for statement has a condition scope, emit the local variable
 // declaration.
@@ -1350,7 +1351,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
   ExitBlock = createBasicBlock("for.cond.cleanup");
 
 // As long as the condition is true, iterate the loop.
-llvm::BasicBlock *ForBody = createBasicBlock("for.body");
+ForBody = createBasicBlock("for.body");
 
 // C99 6.8.5p2/p4: The first substatement is executed if the expression
 // compares unequal to 0.  The condition must be a scalar type.
@@ -1364,7 +1365,14 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
   BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
   BoolCondVal, Stmt::getLikelihood(S.getBody()));
 
-Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+auto *I = Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+// Key Instructions: Emit the condition and branch as separate atoms to
+// match existing loop stepping behaviour. FIXME: We could have the branch
+// as the backup location for the condition, which would probably be a
+// better experience (no jumping to the brace).
+if (auto *I = dyn_cast(BoolCondVal))
+  addInstToNewSourceAtom(I, nullptr);
+addInstToNewSourceAtom(I, nullptr);
 
 if (ExitBlock != LoopExit.getBlock()) {
   EmitBlock(ExitBlock);
@@ -1418,6 +1426,12 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
 
   if (CGM.shouldEmitConvergenceTokens())
 ConvergenceTokenStack.pop_back();
+
+  if (ForBody) {
+// Key Instructions: We want the for closing brace to be step-able on to
+// match existing behaviour.
+addInstToNewSourceAtom(ForBody->getTerminator(), nullptr);
+  }
 }
 
 void
diff --git a/clang/test/DebugInfo/KeyInstructions/for.c 
b/clang/test/DebugInfo/KeyInstructions/for.c
new file mode 100644
index 0..3221ece69a717
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/for.c
@@ -0,0 +1,37 @@
+// RUN: %clang -gkey-instructions -x c++ %s -gmlt -S -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o -  \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// Perennial quesiton: should the inc be its own source atom or not
+// (currently it is).
+
+// FIXME: See do.c and while.c regarding cmp and cond br groups.
+
+void a(int A) {
+// CHECK: entry:
+// CHECK: store i32 0, ptr %i{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: for.cond:
+// CHECK: %cmp = icmp slt i32 %0, %1, !dbg [[G2R1:!.*]]
+// CHECK: br i1 %cmp, label %for.body, label %for.end, !dbg [[G3R1:!.*]]
+
+// FIXME: Added uncond br group here which is useful for O0, which we're
+// no longer targeting. With optimisations loop rotate puts the condition
+// into for.inc and simplifycfg smooshes that and for.body together, so
+// it's not clear whether it adds any value.
+// CHECK: for.body:
+// CHECK: br label %for.inc, !dbg [[G5R1:!.*]]
+
+// CHECK: for.inc:
+// CHECK: %inc = add{{.*}}, !dbg [[G4R2:!.*]]
+// CHECK: store i32 %inc, ptr %i{{.*}}, !dbg [[G4R1:!.*]]
+for (int i = 0; i < A; ++i) { }
+}
+
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
+// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
+// CHECK: [[G5R1]] = !DILocation

[clang] [AMDGPU] fix amdgpu_max_num_work_groups in templates (PR #141633)

2025-05-28 Thread Matt Arsenault via cfe-commits

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


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


[clang] [flang] [llvm] Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler (PR #136098)

2025-05-28 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

> > Thank you for seeing this through and making all the little changes. I have 
> > requested reviews from @MaskRay and @aeubanks for the clang side of things.
> 
> hello,I noticed that this PR has been awaiting clang review for three weeks. 
> I still haven't gotten a comment from them.would it be possible for you to 
> suggest others who might be available to help review? Thanks

Adding @AaronBallman for reviewing the clang side or to suggest a suitable 
reviewer.

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


[clang] [clang][LoongArch] Add support for the _Float16 type (PR #141703)

2025-05-28 Thread via cfe-commits

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

LGTM

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits


@@ -388,6 +388,76 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   return true;
 }
 
+enum class AttrFeatureKind { Arch, Tune, NoFeature, Feature, Invalid };
+
+static std::pair
+getAttrFeatureTypeAndValue(llvm::StringRef AttrFeature) {
+  if (auto Split = AttrFeature.split("="); !Split.second.empty()) {
+if (Split.first.trim() == "arch")
+  return {AttrFeatureKind::Arch, Split.second.trim()};
+if (Split.first.trim() == "tune")
+  return {AttrFeatureKind::Tune, Split.second.trim()};
+  }
+  if (AttrFeature.starts_with("no-"))
+return {AttrFeatureKind::NoFeature, AttrFeature.drop_front(3)};
+  return {AttrFeatureKind::Feature, AttrFeature};

Ami-zhang wrote:

Appreciate the review suggestion. The validation will be handled in 
isValidFeatureName(), with corresponding test cases added.Thanks!

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits

https://github.com/Ami-zhang updated 
https://github.com/llvm/llvm-project/pull/140700

>From a9f8fa53dd260f8161a2762c5ec118722cbf22a1 Mon Sep 17 00:00:00 2001
From: Ami-zhang 
Date: Wed, 14 May 2025 15:21:54 +0800
Subject: [PATCH 1/2] [Clang][LoongArch] Support target attribute for function

This adds support under LoongArch for the target("..") attributes.

The supported formats are:
- "arch=" strings, that specify the architecture features for a
  function as per the -march=arch option.
- "tune=" strings, that specify the tune-cpu cpu for a function as
  per -mtune.
- "", "no-" enabled/disables the specific feature.
---
 clang/lib/Basic/Targets/LoongArch.cpp | 49 ++
 clang/lib/Basic/Targets/LoongArch.h   |  4 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 11 +++
 clang/test/CodeGen/LoongArch/targetattr.c | 92 +++
 clang/test/Sema/attr-target-loongarch.c   | 25 +
 .../llvm/TargetParser/LoongArchTargetParser.h |  1 +
 .../TargetParser/LoongArchTargetParser.cpp| 13 +++
 7 files changed, 195 insertions(+)
 create mode 100644 clang/test/CodeGen/LoongArch/targetattr.c
 create mode 100644 clang/test/Sema/attr-target-loongarch.c

diff --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index ca742797d7a3b..aee273a76a608 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -388,6 +388,51 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   return true;
 }
 
+ParsedTargetAttr
+LoongArchTargetInfo::parseTargetAttr(StringRef Features) const {
+  ParsedTargetAttr Ret;
+  if (Features == "default")
+return Ret;
+  SmallVector AttrFeatures;
+  Features.split(AttrFeatures, ",");
+
+  for (auto &Feature : AttrFeatures) {
+Feature = Feature.trim();
+
+if (Feature.starts_with("arch=")) {
+  StringRef ArchValue = Feature.split("=").second.trim();
+
+  if (llvm::LoongArch::isValidArchName(ArchValue) ||
+  ArchValue == "la64v1.0" || ArchValue == "la64v1.1") {
+std::vector ArchFeatures;
+if (llvm::LoongArch::getArchFeatures(ArchValue, ArchFeatures)) {
+  Ret.Features.insert(Ret.Features.end(), ArchFeatures.begin(),
+  ArchFeatures.end());
+}
+
+if (!Ret.CPU.empty())
+  Ret.Duplicate = "arch=";
+else if (ArchValue == "la64v1.0" || ArchValue == "la64v1.1")
+  Ret.CPU = "loongarch64";
+else
+  Ret.CPU = ArchValue;
+  } else {
+Ret.Features.push_back("!arch=" + ArchValue.str());
+  }
+} else if (Feature.starts_with("tune=")) {
+  if (!Ret.Tune.empty())
+Ret.Duplicate = "tune=";
+  else
+Ret.Tune = Feature.split("=").second.trim();
+} else if (Feature.starts_with("no-")) {
+  Ret.Features.push_back("-" + Feature.split("-").second.str());
+} else {
+  Ret.Features.push_back("+" + Feature.str());
+}
+  }
+  return Ret;
+}
+
 bool LoongArchTargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::LoongArch::isValidCPUName(Name);
 }
@@ -396,3 +441,7 @@ void LoongArchTargetInfo::fillValidCPUList(
 SmallVectorImpl &Values) const {
   llvm::LoongArch::fillValidCPUList(Values);
 }
+
+bool LoongArchTargetInfo::isValidFeatureName(StringRef Name) const {
+  return llvm::LoongArch::isValidFeatureName(Name);
+}
diff --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 4c7b53abfef9b..a83bb925bc310 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -101,6 +101,9 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override;
 
+  ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
+  bool supportsTargetAttributeTune() const override { return true; }
+
   bool
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
@@ -110,6 +113,7 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
 
   bool isValidCPUName(StringRef Name) const override;
   void fillValidCPUList(SmallVectorImpl &Values) const override;
+  bool isValidFeatureName(StringRef Name) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 4d7f0455444f1..8e44e2e44bb24 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3195,6 +3195,17 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, 
StringRef AttrStr) {
 }
   }
 
+  if (Context.getTargetInfo().getTriple().isLoongArch()) {
+for (const auto &Feature : ParsedAttrs.Features) {
+  StringRef CurFeature = Feature;
+  if (CurFeature.starts_with("!arch=")) {
+StringRef ArchValue = CurFeature.split("=").second.trim();
+return Diag(Lit

[clang] [Clang][OpenMP][LoopTransformations] Fix incorrect number of generated loops for Tile and Reverse directives (PR #140532)

2025-05-28 Thread Walter J.T.V via cfe-commits

eZWALT wrote:

> > AnalyzeLoopSequence
> 
> Could you point, where this is located?

Of course, [See line 14315 in 
`SemaOpenMP.cpp`](https://github.com/eZWALT/llvm-project/blob/main/clang/lib/Sema/SemaOpenMP.cpp#L14315)


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


[clang] [Clang][OpenMP][LoopTransformations] Fix incorrect number of generated loops for Tile and Reverse directives (PR #140532)

2025-05-28 Thread Walter J.T.V via cfe-commits

eZWALT wrote:

> > AnalyzeLoopSequence
> 
> Could you point, where this is located?

Although now that i think about it, this function is not inside this PR but 
rather on the PR #139293, but the dependency is clear. 

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


[libclc] [libclc] Move prefetch to clc library (PR #141721)

2025-05-28 Thread Fraser Cormack via cfe-commits

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

LGTM, thanks

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


[libclc] [llvm] [libclc] Support LLVM_ENABLE_RUNTIMES when building (PR #141574)

2025-05-28 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> > That said, I don't believe it "works" in the way it's supposed to. It still 
> > grabs the host tools using `get_host_tool_path` in CMake, and custom 
> > commands to build with that. I take it we're supposed to use 
> > `CMAKE_C_COMPILER` as if we were a regular CMake project? Are we able to 
> > use `opt` and `llvm-link` and other LLVM tools?
> 
> Yes, the whole point is that we can use `add_library` instead of custom 
> commands. You can still find those tools and use them if necessary however. 
> For that you'd want to emit an object library and then add a custom command 
> that uses all the generated objects to link / opt them and finally output 
> them. OpenMP's GPU runtime used to do that but I hacked around it with LTO 
> stuff.

I'll need to look into that - maybe we can talk offline. Since `libclc` is used 
by downstream toolchains I feel it'll be hard to significantly change how it's 
built or presented to the host. We could support two methods of building but 
that would get sticky pretty quickly.

> Yeah, something like `LIBCLC_TARGETS_TO_BUILD` is likely what should be 
> implied by the `LLVM_DEFAULT_TARGET_TRIPLE` value that the runtimes build 
> passes in. (Also, does amdgcn-amd-amdhsa not work? That's the canonical one).

I'm not sure about how best to deal with `LIBCLC_TARGETS_TO_BUILD`. It could 
also pick up from `LLVM_TARGETS_TO_BUILD` but we have targets like `clspv` and 
`clspv64` which don't conveniently match any LLVM triple and are used by a 
downstream.

I'm not sure about how the AMD triples work, perhaps @arsenm can answer that. I 
know that downstream we're changing the final bytecode library to 
`amdgcn-amd-amdhsa` - perhaps for a similar reason.

> It's an external project, it uses the same handling. You can do `ninja -C 
> ./runtimes/runtimes--bins` and it will behave the same.

Ah yes, thank you :+1:.


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


[libclc] [llvm] [libclc] Support LLVM_ENABLE_RUNTIMES when building (PR #141574)

2025-05-28 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/141574

>From f5278d261d203cea8889174c8b0a16c03d1cbad9 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Tue, 27 May 2025 11:11:14 +0100
Subject: [PATCH 1/2] [libclc] Support LLVM_ENABLE_RUNTIMES when building

This commit deprecates the use of LLVM_ENABLE_PROJECTS in favour of
LLVM_ENABLE_RUNTIMES.

Alternatively, using -DLLVM_RUNTIME_TARGETS= combined with
-DRUNTIMES__LLVM_ENABLE_RUNTIMES=libclc also gets pretty far but
fails due to zlib problems building the LLVM utility 'prepare_builtins'.
I'm not sure what's going on there but I don't think it's required at
this stage. More work would be required to support that option.

This does nothing to change how the host tools are found in order to be
used to actually build the libclc libraries.

Fixes #124013.
---
 libclc/CMakeLists.txt| 2 +-
 llvm/CMakeLists.txt  | 9 -
 llvm/runtimes/CMakeLists.txt | 2 +-
 runtimes/CMakeLists.txt  | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 0d9a21c6d63a9..657cab713f8d9 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -72,7 +72,7 @@ else()
   # Note that we check this later (for both build types) but we can provide a
   # more useful error message when built in-tree. We assume that LLVM tools are
   # always available so don't warn here.
-  if( NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
+  if( NOT LLVM_RUNTIMES_BUILD AND NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
 message(FATAL_ERROR "Clang is not enabled, but is required to build libclc 
in-tree")
   endif()
 
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index ed44b16bf9aeb..b27ea78eb5e6c 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -136,7 +136,7 @@ endforeach()
 # As we migrate runtimes to using the bootstrapping build, the set of default 
runtimes
 # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
 set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
-set(LLVM_SUPPORTED_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt")
+set(LLVM_SUPPORTED_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" 
(${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
 if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
@@ -200,6 +200,13 @@ if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
   endif ()
 endif ()
 
+if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS)
+  message(WARNING "Using LLVM_ENABLE_PROJECTS=libclc is deprecated now, and 
will "
+"become a fatal error in the LLVM 21 release.  Please use "
+"-DLLVM_ENABLE_RUNTIMES=libclc or see the instructions at "
+"https://libclc.llvm.org/ for building the runtimes.")
+endif()
+
 # Set a shorthand option to enable the GPU build of the 'libc' project.
 option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF)
 if(LIBC_GPU_BUILD)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index cabadfc9184f8..9f86650ec58d1 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -193,7 +193,7 @@ endif()
 
 function(_get_runtime_name name out_var)
   string(FIND ${name} "lib" idx)
-  if(idx EQUAL 0 AND NOT ${name} STREQUAL "libc")
+  if(idx EQUAL 0 AND NOT (${name} STREQUAL "libc" OR ${name} STREQUAL 
"libclc"))
 string(SUBSTRING ${name} 3 -1 name)
   endif()
   set(${out_var} ${name} PARENT_SCOPE)
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 7f1e2ae065d6c..c62a6c7e8d2b3 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -35,7 +35,7 @@ list(INSERT CMAKE_MODULE_PATH 0
 
 # We order libraries to mirror roughly how they are layered, except that 
compiler-rt can depend
 # on libc++, so we put it after.
-set(LLVM_DEFAULT_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
+set(LLVM_DEFAULT_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload;libclc")
 set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc;flang-rt")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" 
(${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")

>From fa24e06de8d9eb9fa0870546af93f30e60475abd Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 28 May 2025 10:46:23 +0100
Subject: [PATCH 2/2] move libclc earlier in runtimes order

---
 runtimes/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index c62a6c7e8d2b3..878b2eee38618 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -35,7 +35,7 @@ list(INSERT CMAKE_MODULE_PATH 0
 
 # We order libraries to mirror roughly h

[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits


@@ -3195,6 +3195,17 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, 
StringRef AttrStr) {
 }
   }
 
+  if (Context.getTargetInfo().getTriple().isLoongArch()) {
+for (const auto &Feature : ParsedAttrs.Features) {
+  StringRef CurFeature = Feature;
+  if (CurFeature.starts_with("!arch=")) {

wangleiat wrote:

My mistake — I didn't notice the `!`.

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


[clang] [clang][Sema] Diagnose exceptions only in non-dependent context in discarded `try/catch/throw` blocks (PR #139859)

2025-05-28 Thread Rajveer Singh Bharadwaj via cfe-commits

https://github.com/Rajveer100 updated 
https://github.com/llvm/llvm-project/pull/139859

>From 2fc6e7ccab49888b60bbb43e0e6350555c5eb9f1 Mon Sep 17 00:00:00 2001
From: Rajveer 
Date: Wed, 14 May 2025 13:44:31 +0530
Subject: [PATCH] [clang][Sema] Diagnose exceptions only in non-dependent
 context in discarded `try/catch/throw` blocks

Resolves #138939

When enabling `--fno-exceptions` flag, discarded statements containing
`try/catch/throw` in an independent context can be avoided from being
rejected.
---
 clang/include/clang/Sema/Sema.h  |  2 ++
 clang/lib/Sema/SemaExprCXX.cpp   |  5 ++---
 clang/lib/Sema/SemaStmt.cpp  | 26 +++---
 clang/lib/Sema/TreeTransform.h   |  4 
 clang/test/SemaCXX/no-exceptions.cpp | 25 -
 5 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6ea7ee281e14d..ebb40498e11aa 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11154,6 +11154,8 @@ class Sema final : public SemaBase {
   StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
   ArrayRef Handlers);
 
+  void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry);
+
   StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
   SourceLocation TryLoc, Stmt *TryBlock,
   Stmt *Handler);
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index b2a982e953012..5c770b36f6491 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -853,10 +853,9 @@ ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr 
*Ex,
   getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
   // Don't report an error if 'throw' is used in system headers or in an OpenMP
   // target region compiled for a GPU architecture.
-  if (!IsOpenMPGPUTarget && !getLangOpts().CXXExceptions &&
-  !getSourceManager().isInSystemHeader(OpLoc) && !getLangOpts().CUDA) {
+  if (!IsOpenMPGPUTarget && !getLangOpts().CUDA) {
 // Delay error emission for the OpenMP device code.
-targetDiag(OpLoc, diag::err_exceptions_disabled) << "throw";
+DiagnoseExceptionUse(OpLoc, /* IsTry= */ false);
   }
 
   // In OpenMP target regions, we replace 'throw' with a trap on GPU targets.
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index e8c1f8490342a..d882b04202caf 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -4302,13 +4302,8 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, 
Stmt *TryBlock,
   const llvm::Triple &T = Context.getTargetInfo().getTriple();
   const bool IsOpenMPGPUTarget =
   getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
-  // Don't report an error if 'try' is used in system headers or in an OpenMP
-  // target region compiled for a GPU architecture.
-  if (!IsOpenMPGPUTarget && !getLangOpts().CXXExceptions &&
-  !getSourceManager().isInSystemHeader(TryLoc) && !getLangOpts().CUDA) {
-// Delay error emission for the OpenMP device code.
-targetDiag(TryLoc, diag::err_exceptions_disabled) << "try";
-  }
+
+  DiagnoseExceptionUse(TryLoc, /* IsTry= */ true);
 
   // In OpenMP target regions, we assume that catch is never reached on GPU
   // targets.
@@ -4410,6 +4405,23 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, 
Stmt *TryBlock,
 Handlers);
 }
 
+void Sema::DiagnoseExceptionUse(SourceLocation Loc, bool IsTry) {
+  const llvm::Triple &T = Context.getTargetInfo().getTriple();
+  const bool IsOpenMPGPUTarget =
+  getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
+
+  // Don't report an error if 'try' is used in system headers or in an OpenMP
+  // target region compiled for a GPU architecture.
+  if (IsOpenMPGPUTarget || getLangOpts().CUDA)
+// Delay error emission for the OpenMP device code.
+return;
+
+  if (!getLangOpts().CXXExceptions &&
+  !getSourceManager().isInSystemHeader(Loc) &&
+  !CurContext->isDependentContext())
+targetDiag(Loc, diag::err_exceptions_disabled) << (IsTry ? "try" : 
"throw");
+}
+
 StmtResult Sema::ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc,
   Stmt *TryBlock, Stmt *Handler) {
   assert(TryBlock && Handler);
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 335e21d927b76..b8ee3fedd6812 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -9162,6 +9162,8 @@ StmtResult 
TreeTransform::TransformCXXTryStmt(CXXTryStmt *S) {
 Handlers.push_back(Handler.getAs());
   }
 
+  getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
+
   if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
   !HandlerChanged)
 return S;
@@ -14384,6 +14386,8 @@ 
Tr

[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-05-28 Thread Nathan Gauër via cfe-commits

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


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


[clang] [llvm] Reland "Add macro to suppress -Wunnecessary-virtual-specifier" (PR #141091)

2025-05-28 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@cor3ntin can we merge it? building clang with ToT clang results in a lot of 
warnings now.

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


[clang] 3a42cbd - [AArch64] Rename AArch64SVEACLETypes.def and add base SVE_TYPE.

2025-05-28 Thread David Green via cfe-commits

Author: David Green
Date: 2025-05-28T12:26:54+01:00
New Revision: 3a42cbd47d3e92b8794378d2a0e8ec7ae81950d7

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

LOG: [AArch64] Rename AArch64SVEACLETypes.def and add base SVE_TYPE.

Added: 
clang/include/clang/Basic/AArch64ACLETypes.def

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Serialization/ASTBitCodes.h
clang/include/module.modulemap
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/Targets/AArch64.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReader.cpp
clang/tools/libclang/CIndex.cpp

Removed: 
clang/include/clang/Basic/AArch64SVEACLETypes.def



diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 9a3f4c80c17ba..8d24d393eab09 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1219,7 +1219,7 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/OpenCLExtensionTypes.def"
 #define SVE_TYPE(Name, Id, SingletonId) \
   CanQualType SingletonId;
-#include "clang/Basic/AArch64SVEACLETypes.def"
+#include "clang/Basic/AArch64ACLETypes.def"
 #define PPC_VECTOR_TYPE(Name, Id, Size) \
   CanQualType Id##Ty;
 #include "clang/Basic/PPCTypes.def"

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 3d84f999567ca..48f6486e4266e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3094,7 +3094,7 @@ class BuiltinType : public Type {
 #include "clang/Basic/OpenCLExtensionTypes.def"
 // SVE Types
 #define SVE_TYPE(Name, Id, SingletonId) Id,
-#include "clang/Basic/AArch64SVEACLETypes.def"
+#include "clang/Basic/AArch64ACLETypes.def"
 // PPC MMA Types
 #define PPC_VECTOR_TYPE(Name, Id, Size) Id,
 #include "clang/Basic/PPCTypes.def"

diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index c8dc083df7e10..f43d3ebd229d2 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -881,7 +881,7 @@ let Class = BuiltinType in {
 
 #define SVE_TYPE(NAME, ID, SINGLETON_ID) \
   case BuiltinType::ID: return ctx.SINGLETON_ID;
-#include "clang/Basic/AArch64SVEACLETypes.def"
+#include "clang/Basic/AArch64ACLETypes.def"
 
 #define PPC_VECTOR_TYPE(NAME, ID, SIZE) \
   case BuiltinType::ID: return ctx.ID##Ty;

diff  --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def 
b/clang/include/clang/Basic/AArch64ACLETypes.def
similarity index 98%
rename from clang/include/clang/Basic/AArch64SVEACLETypes.def
rename to clang/include/clang/Basic/AArch64ACLETypes.def
index 6a6f51c95ebd0..89e8e31d9ce3a 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64ACLETypes.def
@@ -1,4 +1,4 @@
-//===-- AArch64SVEACLETypes.def - Metadata about SVE types --*- C++ 
-*-===//
+//===-- AArch64ACLETypes.def - Metadata about SVE types -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -57,6 +57,10 @@
 //  - IsBF true for vector of brain float elements.
 
//===--===//
 
+#ifndef SVE_TYPE
+#define SVE_TYPE(Name, Id, SingletonId)
+#endif
+
 #ifndef SVE_SCALAR_TYPE
 #define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
   SVE_TYPE(Name, Id, SingletonId)

diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 5cb9998126a85..9d265f27b8e31 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1129,7 +1129,7 @@ enum PredefinedTypeIDs {
 #include "clang/Basic/OpenCLExtensionTypes.def"
 // \brief SVE types with auto numeration
 #define SVE_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID,
-#include "clang/Basic/AArch64SVEACLETypes.def"
+#include "clang/Basic/AArch64ACLETypes.def"
 // \brief  PowerPC MMA types with auto numeration
 #define PPC_VECTOR_TYPE(Name, Id, Size) PREDEF_TYPE_##Id##_ID,
 #include "clang/Basic/PPCTypes.def"

diff  --git a/clang/include/mod

[clang] [clang][Sema] Diagnose exceptions only in non-dependent context in discarded `try/catch/throw` blocks (PR #139859)

2025-05-28 Thread Rajveer Singh Bharadwaj via cfe-commits

Rajveer100 wrote:

Done.

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


[clang] [NFC][AArch64] Add relnote saying modal FP8 intrinsics now fully implemented by ACLE (PR #141743)

2025-05-28 Thread via cfe-commits

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

LGTM!
Thank you Jonathan.

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


[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2025-05-28 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> If you feel that there's a technical reason that the compiler output is no 
> longer reasonable, you are welcome to bring it up as a technical argument. My 
> point is simply that "my transform stopped working because clang's compiler 
> output changed" is not, in and of itself, clang's problem to solve.

Agreed; while we aim to not be disruptive with changes, such changes are 
expected and reasonable.

@BukeBeyond -- please familiarize yourself with our community [Code of 
Conduct](https://llvm.org/docs/CodeOfConduct.html). Telling people who they are 
speaking for, accusing people of malicious intent, and demeaning people are not 
in line with our community standards. Editing your comments and/or adding a 
small apology would be appropriate.

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


[clang] [AArch64] Add missing Neon Types (PR #126945)

2025-05-28 Thread David Green via cfe-commits

https://github.com/davemgreen updated 
https://github.com/llvm/llvm-project/pull/126945

>From 5a17166859760dcbc258892be46f7f909c2b00a9 Mon Sep 17 00:00:00 2001
From: Tomas Matheson 
Date: Wed, 12 Feb 2025 14:31:47 +
Subject: [PATCH 1/3] Add missing Neon Types

The AAPCS64 adds a number of vector types to the C unconditionally:
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#11appendix-support-for-advanced-simd-extensions

The equivalent SVE types are already available in clang:
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#12appendix-support-for-scalable-vectors

__mfp8 is defined in the ACLE
https://arm-software.github.io/acle/main/acle.html#data-types

I'm not sure whether __mfp8 should be defined for A32. For now I have left it 
as it is.
---
 .../include/clang/Basic/AArch64ACLETypes.def  |  36 +
 clang/include/clang/Basic/LangOptions.def |   1 +
 clang/include/clang/Basic/Specifiers.h|   6 +
 clang/include/clang/Basic/TokenKinds.def  |   6 +
 clang/include/clang/Sema/DeclSpec.h   |   6 +
 clang/lib/AST/ASTContext.cpp  |  14 +-
 clang/lib/Basic/IdentifierTable.cpp   |   5 +-
 clang/lib/Basic/LangOptions.cpp   |   3 +
 clang/lib/Parse/ParseDecl.cpp |  13 ++
 clang/lib/Parse/ParseTentative.cpp|   8 ++
 clang/lib/Sema/DeclSpec.cpp   |   9 ++
 clang/lib/Sema/SemaTemplateVariadic.cpp   |   4 +
 clang/lib/Sema/SemaType.cpp   |   7 +
 clang/test/AST/ast-dump-aarch64-neon-types.c  | 128 ++
 14 files changed, 242 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/AST/ast-dump-aarch64-neon-types.c

diff --git a/clang/include/clang/Basic/AArch64ACLETypes.def 
b/clang/include/clang/Basic/AArch64ACLETypes.def
index 89e8e31d9ce3a..e508b130569d4 100644
--- a/clang/include/clang/Basic/AArch64ACLETypes.def
+++ b/clang/include/clang/Basic/AArch64ACLETypes.def
@@ -205,6 +205,42 @@ SVE_OPAQUE_TYPE(__SVCount_t, __SVCount_t, SveCount, 
SveCountTy)
 
 SVE_SCALAR_TYPE(__mfp8, __mfp8, MFloat8, MFloat8Ty, 8)
 
+// Unlike the SVE types above, the Neon vector types are parsed as keywords and
+// mapped to the equivalent __attribute__(neon_vector_type(...)) vector type.
+// They are not builtin types.
+#ifndef NEON_VECTOR_TYPE
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind)
+#endif
+NEON_VECTOR_TYPE(__Int8x8_t, CharTy, 8, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int16x4_t, ShortTy, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int32x2_t, IntTy, 32, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint8x8_t, CharTy, 8, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint16x4_t, UnsignedShortTy, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint32x2_t, UnsignedIntTy, 32, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float16x4_t, Float16Ty, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float32x2_t, FloatTy, 32, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Poly8x8_t, CharTy, 8, 8, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Poly16x4_t, UnsignedShortTy, 16, 4, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Bfloat16x4_t, BFloat16Ty, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int8x16_t, CharTy, 8, 16, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int16x8_t, ShortTy, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int32x4_t, IntTy, 32, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int64x2_t, LongLongTy, 64, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint8x16_t, CharTy, 8, 16, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint16x8_t, UnsignedShortTy, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint32x4_t, UnsignedIntTy, 32, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint64x2_t, UnsignedLongLongTy, 64, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float16x8_t, Float16Ty, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float32x4_t, FloatTy, 32, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float64x2_t, DoubleTy, 64, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Poly8x16_t, CharTy, 8, 16, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Poly16x8_t, UnsignedShortTy, 16, 8, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Poly64x2_t, UnsignedLongLongTy, 64, 2, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Bfloat16x8_t, BFloat16Ty, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Mfloat8x8_t, MFloat8Ty, 8, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Mfloat8x16_t, MFloat8Ty, 16, 8, VectorKind::Neon)
+
+#undef NEON_VECTOR_TYPE
 #undef SVE_VECTOR_TYPE
 #undef SVE_VECTOR_TYPE_MFLOAT
 #undef SVE_VECTOR_TYPE_BFLOAT
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 789761c1f3647..cd2af3e13499d 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -463,6 +463,7 @@ COMPATIBLE_VALUE_LANGOPT(FunctionAlignment, 5, 0, "Default 
alignment for functio
 COMPATIBLE_VALUE_LANGOPT(LoopAlignment, 32, 0, "Default alignment for loops")
 
 LANGOPT(FixedPoint, 1, 0, "fixed point types")
+LANGOPT(ACLE, 1, 0, "Arm C Language Extensions")
 LANGO

[clang] [AArch64] Add missing Neon Types (PR #126945)

2025-05-28 Thread David Green via cfe-commits

davemgreen wrote:

> LGTM with one nitpick. I've run this through a fuzzer which tests ABI 
> compatibility with GCC and didn't find any problems.

Thanks for the review and the extra testing!

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


[clang] d1b0cbf - [clang][DebugInfo] Add symbol for debugger with VTable information. (#130255)

2025-05-28 Thread via cfe-commits

Author: Carlos Alberto Enciso
Date: 2025-05-28T09:15:48+01:00
New Revision: d1b0cbff806b50d399826e79b9a53e4726c21302

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

LOG: [clang][DebugInfo] Add symbol for debugger with VTable information. 
(#130255)

The IR now includes a global variable for the debugger that holds
the address of the vtable.

Now every class that contains virtual functions, has a static
member (marked as artificial) that identifies where that vtable
is loaded in memory. The unmangled name is '_vtable$'.

This new symbol will allow a debugger to easily associate
classes with the physical location of their VTables using
only the DWARF information. Previously, this had to be done
by searching for ELF symbols with matching names; something
that was time-consuming and error-prone in certain edge cases.

Added: 
clang/test/CodeGenCXX/vtable-debug-info-inheritance-diamond.cpp
clang/test/CodeGenCXX/vtable-debug-info-inheritance-multiple.cpp
clang/test/CodeGenCXX/vtable-debug-info-inheritance-simple-main.cpp
clang/test/CodeGenCXX/vtable-debug-info-inheritance-simple.cpp
clang/test/CodeGenCXX/vtable-debug-info-inheritance-virtual.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGenCXX/debug-info-class.cpp
clang/test/CodeGenCXX/debug-info-template-member.cpp
clang/test/Modules/ExtDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d5662b194a116..9a6f3b1e69a86 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2635,6 +2635,55 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl 
*RD) {
   return internString("_vptr$", RD->getNameAsString());
 }
 
+// Emit symbol for the debugger that points to the vtable address for
+// the given class. The symbol is named as '_vtable$'.
+// The debugger does not need to know any details about the contents of the
+// vtable as it can work this out using its knowledge of the ABI and the
+// existing information in the DWARF. The type is assumed to be 'void *'.
+void CGDebugInfo::emitVTableSymbol(llvm::GlobalVariable *VTable,
+   const CXXRecordDecl *RD) {
+  if (!CGM.getTarget().getCXXABI().isItaniumFamily())
+return;
+
+  ASTContext &Context = CGM.getContext();
+  StringRef SymbolName = "_vtable$";
+  SourceLocation Loc;
+  QualType VoidPtr = Context.getPointerType(Context.VoidTy);
+
+  // We deal with two 
diff erent contexts:
+  // - The type for the variable, which is part of the class that has the
+  //   vtable, is placed in the context of the DICompositeType metadata.
+  // - The DIGlobalVariable for the vtable is put in the DICompileUnitScope.
+
+  // The created non-member should be mark as 'artificial'. It will be
+  // placed inside the scope of the C++ class/structure.
+  llvm::DIScope *DContext = getContextDescriptor(RD, TheCU);
+  auto *Ctxt = cast(DContext);
+  llvm::DIFile *Unit = getOrCreateFile(Loc);
+  llvm::DIType *VTy = getOrCreateType(VoidPtr, Unit);
+  llvm::DINode::DIFlags Flags = getAccessFlag(AccessSpecifier::AS_private, RD) 
|
+llvm::DINode::FlagArtificial;
+  auto Tag = CGM.getCodeGenOpts().DwarfVersion >= 5
+ ? llvm::dwarf::DW_TAG_variable
+ : llvm::dwarf::DW_TAG_member;
+  llvm::DIDerivedType *DT = DBuilder.createStaticMemberType(
+  Ctxt, SymbolName, Unit, /*LineNumber=*/0, VTy, Flags,
+  /*Val=*/nullptr, Tag);
+
+  // Use the same vtable pointer to global alignment for the symbol.
+  unsigned PAlign = CGM.getVtableGlobalVarAlignment();
+
+  // The global variable is in the CU scope, and links back to the type it's
+  // "within" via the declaration field.
+  llvm::DIGlobalVariableExpression *GVE =
+  DBuilder.createGlobalVariableExpression(
+  TheCU, SymbolName, VTable->getName(), Unit, /*LineNo=*/0,
+  getOrCreateType(VoidPtr, Unit), VTable->hasLocalLinkage(),
+  /*isDefined=*/true, nullptr, DT, /*TemplateParameters=*/nullptr,
+  PAlign);
+  VTable->addDebugInfo(GVE);
+}
+
 StringRef CGDebugInfo::getDynamicInitializerName(const VarDecl *VD,
  DynamicInitKind StubKind,
  llvm::Function *InitFn) {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index ec27fb04f3d9c..855881744237c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -669,6 +669,9 @@ class CGDebugInfo {
   void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,

[clang] [llvm] [clang][DebugInfo] Add symbol for debugger with VTable information. (PR #130255)

2025-05-28 Thread Carlos Alberto Enciso via cfe-commits

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


[clang] [llvm] [clang][DebugInfo] Add symbol for debugger with VTable information. (PR #130255)

2025-05-28 Thread Carlos Alberto Enciso via cfe-commits

CarlosAlbertoEnciso wrote:

@dwblaikie @labath @pogo59 @jmorse @Michael137 @tromey Many thanks for all your 
valuable feedback.

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


[clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

2025-05-28 Thread Pavel Labath via cfe-commits

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

Looks good. Thanks for the fix.

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


[clang] [CIR] Defer declarations and tentative definitions (PR #141700)

2025-05-28 Thread Henrich Lauko via cfe-commits


@@ -1044,6 +1057,24 @@ StringRef CIRGenModule::getMangledName(GlobalDecl gd) {
   return mangledDeclNames[canonicalGd] = result.first->first();
 }
 
+void CIRGenModule::emitTentativeDefinition(const VarDecl *d) {
+  assert(!d->getInit() && "Cannot emit definite definitions here!");
+
+  StringRef mangledName = getMangledName(d);
+  mlir::Operation *gv = getGlobalValue(mangledName);
+
+  // If we already have a definition, not declaration, with the same mangled
+  // name, emitting of declaration is not required (and would actually 
overwrite
+  // the emitted definition).
+  if (gv && !cast(gv).isDeclaration())

xlauko wrote:

```suggestion
  if (gv && !mlir::cast(gv).isDeclaration())
```

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


[clang] [CIR] Defer declarations and tentative definitions (PR #141700)

2025-05-28 Thread Henrich Lauko via cfe-commits


@@ -135,6 +135,10 @@ class CIRGenConsumer : public clang::ASTConsumer {
 }
 }
   }
+
+  void CompleteTentativeDefinition(VarDecl *D) override {
+Gen->CompleteTentativeDefinition(D);
+  }

xlauko wrote:

```suggestion
  void CompleteTentativeDefinition(VarDecl *d) override {
Gen->CompleteTentativeDefinition(d);
  }
```

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


[clang] [CIR] Defer declarations and tentative definitions (PR #141700)

2025-05-28 Thread Henrich Lauko via cfe-commits

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

lgtm, with minor nits

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits


@@ -388,6 +388,76 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   return true;
 }
 
+enum class AttrFeatureKind { Arch, Tune, NoFeature, Feature, Invalid };
+
+static std::pair
+getAttrFeatureTypeAndValue(llvm::StringRef AttrFeature) {
+  if (auto Split = AttrFeature.split("="); !Split.second.empty()) {
+if (Split.first.trim() == "arch")
+  return {AttrFeatureKind::Arch, Split.second.trim()};
+if (Split.first.trim() == "tune")
+  return {AttrFeatureKind::Tune, Split.second.trim()};
+  }
+  if (AttrFeature.starts_with("no-"))
+return {AttrFeatureKind::NoFeature, AttrFeature.drop_front(3)};
+  return {AttrFeatureKind::Feature, AttrFeature};

wangleiat wrote:

The default return may cause us to miss the check for invalid strings. (like 
this: "+lasx", here will be two plus signs in the generated IR) . Perhaps we 
can perform the check inside `isValidFeature()`?"

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits


@@ -3195,6 +3195,17 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, 
StringRef AttrStr) {
 }
   }
 
+  if (Context.getTargetInfo().getTriple().isLoongArch()) {
+for (const auto &Feature : ParsedAttrs.Features) {
+  StringRef CurFeature = Feature;
+  if (CurFeature.starts_with("!arch=")) {

wangleiat wrote:

According to `LoongArchTargetInfo::parseTargetAttr()`, this condition may 
always be false.

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits


@@ -85,6 +85,7 @@ struct ArchInfo {
 };
 
 bool isValidArchName(StringRef Arch);
+bool isValidFeatureName(StringRef Arch);

wangleiat wrote:

Arch -> Feature

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


[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-05-28 Thread Younan Zhang via cfe-commits


@@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char {
 llvm::PointerUnion *
 findInstantiationOf(const Decl *D);
 
+/// Similar to \p findInstantiationOf(), but it wouldn't assert if the
+/// instantiation was not found within the current instantiation scope. 
This
+/// is helpful for on-demand declaration instantiation.
+llvm::PointerUnion *
+findInstantiationUnsafe(const Decl *D);

zyn0217 wrote:

I renamed it to `getInstantiationOfIfExists.`

> Finally, as interface, is there a reason these are returning a pointer to a 
> pointer union?

It's pre-existing, we track the instantiated decls and packs together within a 
map.

Refactoring the interface (either the return type or the name) would bring a 
lot of churn, for which I think merits a separate PR.

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


[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-28 Thread Walter Lee via cfe-commits

googlewalt wrote:

Never mind.  Fixed by 
https://github.com/llvm/llvm-project/commit/f3b404be973507432cf86c177978d9de708d850c.

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


[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

2025-05-28 Thread via cfe-commits


@@ -85,6 +85,7 @@ struct ArchInfo {
 };
 
 bool isValidArchName(StringRef Arch);
+bool isValidFeatureName(StringRef Arch);

Ami-zhang wrote:

Done.

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


[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-05-28 Thread Younan Zhang via cfe-commits


@@ -13458,6 +13473,10 @@ class Sema final : public SemaBase {
   // FIXME: Should we have a similar limit for other forms of synthesis?
   unsigned NonInstantiationEntries;
 
+  /// The number of \p CodeSynthesisContexts that are not constraint
+  /// substitution.
+  unsigned NonConstraintSubstitutionEntries;
+

zyn0217 wrote:

Because we might be getting into ConstraintSubstitution context recursively


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


[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-05-28 Thread Younan Zhang via cfe-commits

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


[clang] 63de20c - Reland "Add macro to suppress -Wunnecessary-virtual-specifier" (#141091)

2025-05-28 Thread via cfe-commits

Author: Devon Loehr
Date: 2025-05-28T12:15:22+02:00
New Revision: 63de20c0de05ce7b8b3968a9d210aa0f3d01acd4

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

LOG: Reland "Add macro to suppress -Wunnecessary-virtual-specifier" (#141091)

This fixes #139614 on non-clang compilers by moving `__has_warning`
completely inside the `#if defined(__clang__)` block. This prevents a
parse failure from compilers which don't recognize `__has_warning`.

Original description:
Followup to #138741.

This adds the requested macro to silence
`-Wunnecessary-virtual-specifier` when declaring virtual anchor
functions in `final` classes, per [LLVM
policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers).

It also cleans up any remaining instances of the warning, allowing us to
stop disabling it when we build LLVM.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/DeclFriend.h
clang/include/clang/AST/DeclOpenMP.h
clang/include/clang/Driver/Action.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ByteCode/InterpFrame.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Driver/ToolChains/Hexagon.h
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/include/llvm/Analysis/InstSimplifyFolder.h
llvm/include/llvm/Analysis/TargetFolder.h
llvm/include/llvm/IR/ConstantFolder.h
llvm/include/llvm/IR/NoFolder.h
llvm/include/llvm/Support/Compiler.h
llvm/include/llvm/Transforms/Scalar/GVNExpression.h
llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
llvm/lib/Target/X86/X86InstrInfo.h

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 9290ff3764c8c..69ad18f4c0581 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -173,7 +173,7 @@ class PragmaCommentDecl final
 PragmaMSCommentKind CommentKind)
   : Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {}
 
-  virtual void anchor();
+  LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
 
 public:
   static PragmaCommentDecl *Create(const ASTContext &C, TranslationUnitDecl 
*DC,
@@ -207,7 +207,7 @@ class PragmaDetectMismatchDecl final
size_t ValueStart)
   : Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {}
 
-  virtual void anchor();
+  LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
 
 public:
   static PragmaDetectMismatchDecl *Create(const ASTContext &C,
@@ -5024,7 +5024,7 @@ class ImportDecl final : public Decl,
 ///   export void foo();
 /// \endcode
 class ExportDecl final : public Decl, public DeclContext {
-  virtual void anchor();
+  LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
 
 private:
   friend class ASTDeclReader;

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index d40d11cbe1a3b..df76e6f5015b3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3297,7 +3297,7 @@ class LifetimeExtendedTemporaryDecl final
 
   mutable APValue *Value = nullptr;
 
-  virtual void anchor();
+  LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
 
   LifetimeExtendedTemporaryDecl(Expr *Temp, ValueDecl *EDecl, unsigned 
Mangling)
   : Decl(Decl::LifetimeExtendedTemporary, EDecl->getDeclContext(),

diff  --git a/clang/include/clang/AST/DeclFriend.h 
b/clang/include/clang/AST/DeclFriend.h
index 1644e2de98f80..1f8c210263677 100644
--- a/clang/include/clang/AST/DeclFriend.h
+++ b/clang/include/clang/AST/DeclFriend.h
@@ -52,7 +52,7 @@ class ASTContext;
 class FriendDecl final
 : public Decl,
   private llvm::TrailingObjects {
-  virtual void anchor();
+  LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
 
 public:
   using FriendUnion = llvm::PointerUnion;

diff  --git a/clang/include/clang/AST/DeclOpenMP.h 
b/clang/include/clang/AST/DeclOpenMP.h
index cf383889c0ad9..2d07f9d9f5d8c 100644
--- a/clang/include/clang/AST/DeclOpenMP.h
+++ b/clang/include/clang/AST/DeclOpenMP.h
@@ -110,7 +110,7 @@ template  class OMPDeclarativeDirective : 
public U {
 class OMPThreadPrivateDecl final : public OMPDeclarativeDirective {
   friend class OMPDeclarativeDirective;
 
-  virtual void anchor();
+  LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
 
   OMPThreadPrivateDecl(DeclContext *DC = nullptr,
SourceLocation L = SourceLocation())
@@ -418,7 +418,7 @@ class OMPRequiresDecl final : public 
OMPDeclarativeDirective {
   friend class OMPDeclarativeDirective;
   friend class ASTDeclReader;
 
-  virtual void anchor();
+  LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
 
   OMPRequiresDecl(DeclContext *DC, SourceLocation L)
   : OMPDeclarativeDirective(OMPRequires, DC, L) {}
@@ -

[clang] [llvm] Reland "Add macro to suppress -Wunnecessary-virtual-specifier" (PR #141091)

2025-05-28 Thread via cfe-commits

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


[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)

2025-05-28 Thread Walter Lee via cfe-commits

googlewalt wrote:

This doesn't build with -Werror, as seen in llvm-ci build 
https://lab.llvm.org/buildbot/#/builders/145/builds/7332.  Can you please take 
a look?

```
FAILED: 
tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangBuiltinTemplatesEmitter.cpp.o
 
ccache /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ 
--gcc-toolchain=/gcc-toolchain/usr -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 
-DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/utils/TableGen
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/utils/TableGen
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-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 -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangBuiltinTemplatesEmitter.cpp.o
 -MF 
tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangBuiltinTemplatesEmitter.cpp.o.d
 -o 
tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangBuiltinTemplatesEmitter.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp:25:8:
 error: 'llvm::StringSet' may not intend to support class template argument 
deduction [-Werror,-Wctad-maybe-unsupported]
   25 | static llvm::StringSet BuiltinClasses;
  |^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include/llvm/ADT/StringSet.h:25:7:
 note: add a deduction guide to suppress this warning
   25 | class StringSet : public StringMap {
  |   ^
1 error generated.
```

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


[clang] [clang] constexpr atomic builtins (__c11_atomic_OP and __atomic_OP) (PR #98756)

2025-05-28 Thread Hana Dusíková via cfe-commits

hanickadot wrote:

> @hanickadot Ping :)

Soon, busy, will be back.

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


[clang] [llvm] [MIPS] Reland Add FeatureMSA to i6400 and i6500 cores (#134985) (PR #141730)

2025-05-28 Thread Mallikarjuna Gouda via cfe-commits

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


[clang] [llvm] [clang][RISCV][Zicfilp] Emit RISCV function-signature-based CFI label in llvm::Function metadata (PR #111661)

2025-05-28 Thread Ming-Yi Lai via cfe-commits

mylai-mtk wrote:

> There are intentional tradeoffs here, for the ABI, which should be made 
> carefully; in some cases, it might be the right tradeoff to reject 
> standard-compliant code. If you've considered it, I guess I won't object. I 
> can't find any discussion of it, though.

The reduction of unprototyped function types to prototyped no parameter 
function types is proposed by me in 
,
 which is accepted without much discussion/objection. I also proposed treating 
such usages as errors, but it looks like this part had not been taken into the 
spec.

> With my psABI hat on, settling on an ABI that turns out to be wrong is my big 
> concern, but you can't find those corner cases until you try it at scale (and 
> that's speaking from experience where we've missed things in the past for 
> CHERI). This is probably the kind of thing that needs to be explicitly marked 
> as experimental and with no ABI forward-compatibility guarantees, but that 
> needs to be landed so that people can start actually using it and finding 
> where it falls down in the real world. (But that doesn't obviate proper code 
> review, the implementation should still be proper even if the ABI isn't 
> stable.)

Agree. I'm pretty sure that the mangling scheme is not perfect, especially when 
applied to ancient C projects. With regard to forward-compatibility management, 
I think we can introduce versioning to Zicfilp psABI as well? (cf. 
Tag_RISCV_atomic_abi in `.riscv.attributes` section) @kito-cheng 

> Given the comparison with the AArch64 PAuth work, how much is building on 
> that versus doing our own independent thing?

We did not refer to the AArch64 PtrAuth work when we devised the Zicfilp 
mangling scheme, and instead, our foundation was the Itanium C++ ABI. The time 
at which these 2 mangling schemes appeared were close, and I did not know that 
AArch64 was developing a similar thing back then, so adapting the Itanium C++ 
ABI looked like the most practical approach. 

> Is there any real-world deployment experience from that that we can make use 
> of?

Not that I know of... The AArch64 PtrAuth work is in the main trunk for only 
less than 1 year, and it may take multiple years for the feature to mature, so 
I would say that we can surely learn some valuable things from it if we observe 
it long enough, but for now, I think both schemes are in a similarly nascent 
status, with the AArch64 PtrAuth scheme being more explicit and controllable.

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


[clang] [clang-format] Handle .h files for LK_C and LK_ObjC (PR #141714)

2025-05-28 Thread Owen Pan via cfe-commits

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

>From 2d30adbd7bcce89c157e5b3eb517854cfbd35f48 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 27 May 2025 20:50:56 -0700
Subject: [PATCH] [clang-format] Handle .h files for LK_C and LK_ObjC

Fix #137792
---
 clang/include/clang/Format/Format.h| 10 ++
 clang/lib/Format/Format.cpp| 18 +-
 clang/unittests/Format/ConfigParseTest.cpp | 18 ++
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3ac4318824ac0..127b1d08919de 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5536,7 +5536,7 @@ struct FormatStyle {
   parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
  bool AllowUnknownOptions,
  llvm::SourceMgr::DiagHandlerTy DiagHandler,
- void *DiagHandlerCtxt);
+ void *DiagHandlerCtxt, bool IsDotHFile);
 };
 
 /// Returns a format style complying with the LLVM coding standards:
@@ -5602,13 +5602,15 @@ std::error_code
 parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
bool AllowUnknownOptions = false,
llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr,
-   void *DiagHandlerCtx = nullptr);
+   void *DiagHandlerCtx = nullptr, bool IsDotHFile = false);
 
 /// Like above but accepts an unnamed buffer.
 inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
-  bool AllowUnknownOptions = false) {
+  bool AllowUnknownOptions = false,
+  bool IsDotHFile = false) {
   return parseConfiguration(llvm::MemoryBufferRef(Config, "YAML"), Style,
-AllowUnknownOptions);
+AllowUnknownOptions, /*DiagHandler=*/nullptr,
+/*DiagHandlerCtx=*/nullptr, IsDotHFile);
 }
 
 /// Gets configuration in a YAML string.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 0cfa061681053..bdaf264e9adce 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2108,7 +2108,7 @@ ParseError validateQualifierOrder(FormatStyle *Style) {
 std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
FormatStyle *Style, bool 
AllowUnknownOptions,
llvm::SourceMgr::DiagHandlerTy DiagHandler,
-   void *DiagHandlerCtxt) {
+   void *DiagHandlerCtxt, bool IsDotHFile) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
   assert(Language != FormatStyle::LK_None);
@@ -2155,6 +2155,10 @@ std::error_code parseConfiguration(llvm::MemoryBufferRef 
Config,
 // For backward compatibility.
 (Lang == FormatStyle::LK_Cpp && Language == FormatStyle::LK_C)) {
   LanguageFound = true;
+} else if (IsDotHFile && Language == FormatStyle::LK_Cpp &&
+   (Lang == FormatStyle::LK_C || Lang == FormatStyle::LK_ObjC)) {
+  Language = Lang;
+  LanguageFound = true;
 }
   }
   if (!LanguageFound) {
@@ -4177,13 +4181,15 @@ const char *DefaultFallbackStyle = "LLVM";
 llvm::ErrorOr>
 loadAndParseConfigFile(StringRef ConfigFile, llvm::vfs::FileSystem *FS,
FormatStyle *Style, bool AllowUnknownOptions,
-   llvm::SourceMgr::DiagHandlerTy DiagHandler) {
+   llvm::SourceMgr::DiagHandlerTy DiagHandler,
+   bool IsDotHFile) {
   llvm::ErrorOr> Text =
   FS->getBufferForFile(ConfigFile.str());
   if (auto EC = Text.getError())
 return EC;
   if (auto EC = parseConfiguration(*Text.get(), Style, AllowUnknownOptions,
-   DiagHandler)) {
+   DiagHandler, /*DiagHandlerCtx=*/nullptr,
+   IsDotHFile)) {
 return EC;
   }
   return Text;
@@ -4221,13 +4227,15 @@ Expected getStyle(StringRef StyleName, 
StringRef FileName,
 FS = llvm::vfs::getRealFileSystem().get();
   assert(FS);
 
+  const bool IsDotHFile = FileName.ends_with(".h");
+
   // User provided clang-format file using -style=file:path/to/format/file.
   if (!Style.InheritsParentConfig &&
   StyleName.starts_with_insensitive("file:")) {
 auto ConfigFile = StyleName.substr(5);
 llvm::ErrorOr> Text =
 loadAndParseConfigFile(ConfigFile, FS, &Style, AllowUnknownOptions,
-   DiagHandler);
+   DiagHandler, IsDotHFile);
 if (auto EC = Text.getError()) {
   return make_string_error("Error reading " + ConfigFile + ": " +

[clang] 5584020 - [HLSL][SPIRV] Implement the SPIR-V target type for cbuffers. (#140061)

2025-05-28 Thread via cfe-commits

Author: Steven Perron
Date: 2025-05-28T07:51:03-04:00
New Revision: 5584020d8abf46f2852a59ed5333a7f2145bfec5

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

LOG: [HLSL][SPIRV] Implement the SPIR-V target type for cbuffers. (#140061)

This change implement the type used to represent cbuffer for SPIR-V.

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

Added: 


Modified: 
clang/lib/Basic/Targets/SPIR.h
clang/lib/CodeGen/Targets/SPIR.cpp
clang/test/CodeGenHLSL/default_cbuffer.hlsl

Removed: 




diff  --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index bf249e271a870..fcedce98c7067 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -47,7 +47,7 @@ static const unsigned SPIRDefIsPrivMap[] = {
 0,  // ptr32_uptr
 0,  // ptr64
 0,  // hlsl_groupshared
-2,  // hlsl_constant
+12, // hlsl_constant
 10, // hlsl_private
 11, // hlsl_device
 // Wasm address space values for this target are dummy values,

diff  --git a/clang/lib/CodeGen/Targets/SPIR.cpp 
b/clang/lib/CodeGen/Targets/SPIR.cpp
index cb190b32abdb1..92ae46234e6b1 100644
--- a/clang/lib/CodeGen/Targets/SPIR.cpp
+++ b/clang/lib/CodeGen/Targets/SPIR.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "ABIInfoImpl.h"
+#include "HLSLBufferLayoutBuilder.h"
 #include "TargetInfo.h"
 
 using namespace clang;
@@ -495,9 +496,19 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
 {RuntimeArrayType},
 {StorageClass, IsWritable});
   }
-  case llvm::dxil::ResourceClass::CBuffer:
-llvm_unreachable("CBuffer handles are not implemented for SPIR-V yet");
+  case llvm::dxil::ResourceClass::CBuffer: {
+QualType ContainedTy = ResType->getContainedType();
+if (ContainedTy.isNull() || !ContainedTy->isStructureType())
+  return nullptr;
+
+llvm::Type *BufferLayoutTy =
+HLSLBufferLayoutBuilder(CGM, "spirv.Layout")
+.createLayoutType(ContainedTy->getAsStructureType(), Packoffsets);
+uint32_t StorageClass = /* Uniform storage class */ 2;
+return llvm::TargetExtType::get(Ctx, "spirv.VulkanBuffer", 
{BufferLayoutTy},
+{StorageClass, false});
 break;
+  }
   case llvm::dxil::ResourceClass::Sampler:
 return llvm::TargetExtType::get(Ctx, "spirv.Sampler");
   }

diff  --git a/clang/test/CodeGenHLSL/default_cbuffer.hlsl 
b/clang/test/CodeGenHLSL/default_cbuffer.hlsl
index bec048a80d82b..0581c3072480a 100644
--- a/clang/test/CodeGenHLSL/default_cbuffer.hlsl
+++ b/clang/test/CodeGenHLSL/default_cbuffer.hlsl
@@ -1,12 +1,19 @@
-// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -finclude-default-header -triple 
dxil-pc-shadermodel6.3-compute -fnative-half-type -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -finclude-default-header -triple 
dxil-pc-shadermodel6.3-compute -fnative-half-type -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,DXIL
+// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -finclude-default-header -triple 
spirv-pc-vulkan1.3-compute -fnative-half-type -emit-llvm -disable-llvm-passes 
-o - %s | FileCheck %s --check-prefixes=CHECK,SPIRV
 
-// CHECK: %"__cblayout_$Globals" = type <{ float, float, target("dx.Layout", 
%__cblayout_S, 4, 0) }>
+// DXIL: %"__cblayout_$Globals" = type <{ float, float, target("dx.Layout", 
%__cblayout_S, 4, 0) }>
+// SPIRV: %"__cblayout_$Globals" = type <{ float, float, 
target("spirv.Layout", %__cblayout_S, 4, 0) }>
 // CHECK: %__cblayout_S = type <{ float }>
 
-// CHECK-DAG: @"$Globals.cb" = global target("dx.CBuffer", target("dx.Layout", 
%"__cblayout_$Globals", 20, 0, 4, 16))
-// CHECK-DAG: @a = external addrspace(2) global float
-// CHECK-DAG: @g = external addrspace(2) global float
-// CHECK-DAG: @h = external addrspace(2) global target("dx.Layout", 
%__cblayout_S, 4, 0), align 4
+// DXIL-DAG: @"$Globals.cb" = global target("dx.CBuffer", target("dx.Layout", 
%"__cblayout_$Globals", 20, 0, 4, 16))
+// DXIL-DAG: @a = external addrspace(2) global float
+// DXIL-DAG: @g = external addrspace(2) global float
+// DXIL-DAG: @h = external addrspace(2) global target("dx.Layout", 
%__cblayout_S, 4, 0), align 4
+
+// SPIRV-DAG: @"$Globals.cb" = global target("spirv.VulkanBuffer", 
target("spirv.Layout", %"__cblayout_$Globals", 20, 0, 4, 16), 2, 0)
+// SPIRV-DAG: @a = external addrspace(12) global float
+// SPIRV-DAG: @g = external addrspace(12) global float
+// SPIRV-DAG: @h = external addrspace(12) global target("spirv.Layout", 
%__cblayout_S, 4, 0), align 8
 
 struct EmptyStruct {
 };
@@ -35,4 +42,5 @@ void main()

[clang] [HLSL][SPIRV] Implement the SPIR-V target type for cbuffers. (PR #140061)

2025-05-28 Thread Steven Perron via cfe-commits

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


[clang] [KeyIntsr][Clang] Builtins alloca auto-init atom (PR #134651)

2025-05-28 Thread Stephen Tozer via cfe-commits


@@ -4466,7 +4473,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(2));
 EmitNonNullArgCheck(Dest, E->getArg(0)->getType(),
 E->getArg(0)->getExprLoc(), FD, 0);
-Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
+auto *I = Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);

SLTozer wrote:

One last question, for this (and possibly other memsets) is it possible that 
the src argument is an instruction, and if so should it be get a rank 2 
location?

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


[clang] 54ddbc6 - [AMDGPU] fix amdgpu_max_num_work_groups in templates (#141633)

2025-05-28 Thread via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2025-05-28T08:05:03-04:00
New Revision: 54ddbc6be3eeb91ae24f5e002fc1d0be7cb07654

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

LOG: [AMDGPU] fix amdgpu_max_num_work_groups in templates (#141633)

Clang does not instantiate amdgpu_max_num_work_groups attribute with one
template argument, causing
assertion codegen.

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 44700a446dfac..174c8fc59e4fa 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -648,21 +648,30 @@ static void 
instantiateDependentAMDGPUMaxNumWorkGroupsAttr(
   EnterExpressionEvaluationContext Unevaluated(
   S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
 
-  ExprResult ResultX = S.SubstExpr(Attr.getMaxNumWorkGroupsX(), TemplateArgs);
-  if (!ResultX.isUsable())
-return;
-  ExprResult ResultY = S.SubstExpr(Attr.getMaxNumWorkGroupsY(), TemplateArgs);
-  if (!ResultY.isUsable())
-return;
-  ExprResult ResultZ = S.SubstExpr(Attr.getMaxNumWorkGroupsZ(), TemplateArgs);
-  if (!ResultZ.isUsable())
-return;
+  Expr *XExpr = nullptr;
+  Expr *YExpr = nullptr;
+  Expr *ZExpr = nullptr;
+
+  if (Attr.getMaxNumWorkGroupsX()) {
+ExprResult ResultX = S.SubstExpr(Attr.getMaxNumWorkGroupsX(), 
TemplateArgs);
+if (ResultX.isUsable())
+  XExpr = ResultX.getAs();
+  }
+
+  if (Attr.getMaxNumWorkGroupsY()) {
+ExprResult ResultY = S.SubstExpr(Attr.getMaxNumWorkGroupsY(), 
TemplateArgs);
+if (ResultY.isUsable())
+  YExpr = ResultY.getAs();
+  }
 
-  Expr *XExpr = ResultX.getAs();
-  Expr *YExpr = ResultY.getAs();
-  Expr *ZExpr = ResultZ.getAs();
+  if (Attr.getMaxNumWorkGroupsZ()) {
+ExprResult ResultZ = S.SubstExpr(Attr.getMaxNumWorkGroupsZ(), 
TemplateArgs);
+if (ResultZ.isUsable())
+  ZExpr = ResultZ.getAs();
+  }
 
-  S.AMDGPU().addAMDGPUMaxNumWorkGroupsAttr(New, Attr, XExpr, YExpr, ZExpr);
+  if (XExpr)
+S.AMDGPU().addAMDGPUMaxNumWorkGroupsAttr(New, Attr, XExpr, YExpr, ZExpr);
 }
 
 // This doesn't take any template parameters, but we have a custom action that

diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
index 253ac0898f546..fa4821e3c597f 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -78,6 +78,24 @@ __global__ void template_32_4_a_max_num_work_groups() {}
 template __global__ void template_32_4_a_max_num_work_groups<2>();
 // CHECK: define{{.*}} amdgpu_kernel void 
@_Z35template_32_4_a_max_num_work_groupsILj2EEvv() 
[[MAX_NUM_WORK_GROUPS_32_4_2:#[0-9]+]]
 
+template
+__attribute__((amdgpu_max_num_work_groups(a)))
+__global__ void template_a_max_num_work_groups() {}
+template __global__ void template_a_max_num_work_groups<32>();
+// CHECK: define{{.*}} amdgpu_kernel void 
@_Z30template_a_max_num_work_groupsILj32EEvv() [[MAX_NUM_WORK_GROUPS_32_1_1]]
+
+template
+__attribute__((amdgpu_max_num_work_groups(a, b)))
+__global__ void template_a_b_max_num_work_groups() {}
+template __global__ void template_a_b_max_num_work_groups<32, 1>();
+// CHECK: define{{.*}} amdgpu_kernel void 
@_Z32template_a_b_max_num_work_groupsILj32ELj1EEvv() 
[[MAX_NUM_WORK_GROUPS_32_1_1]]
+
+template
+__attribute__((amdgpu_max_num_work_groups(a, b, c)))
+__global__ void template_a_b_c_max_num_work_groups() {}
+template __global__ void template_a_b_c_max_num_work_groups<32, 4, 2>();
+// CHECK: define{{.*}} amdgpu_kernel void 
@_Z34template_a_b_c_max_num_work_groupsILj32ELj4ELj2EEvv() 
[[MAX_NUM_WORK_GROUPS_32_4_2]]
+
 // Make sure this is silently accepted on other targets.
 // NAMD-NOT: "amdgpu-flat-work-group-size"
 // NAMD-NOT: "amdgpu-waves-per-eu"



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


[clang] [llvm] [UBSan] Support src:*=sanitize for multiple ignorelists. (PR #141640)

2025-05-28 Thread Qinkun Bao via cfe-commits

https://github.com/qinkunbao updated 
https://github.com/llvm/llvm-project/pull/141640

>From d858fbe3ce415fda7d43d4e99c5a94646174b965 Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Tue, 27 May 2025 17:32:30 +
Subject: [PATCH 1/7] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6

[skip ci]
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/docs/SanitizerSpecialCaseList.rst   | 26 ++--
 .../clang/Basic/SanitizerSpecialCaseList.h|  7 ++-
 clang/lib/Basic/NoSanitizeList.cpp| 10 ++-
 clang/lib/Basic/SanitizerSpecialCaseList.cpp  | 21 +--
 .../ubsan-src-ignorelist-category.test| 36 +--
 llvm/include/llvm/Support/SpecialCaseList.h   | 15 +++--
 llvm/lib/Support/SpecialCaseList.cpp  | 34 +-
 .../tools/llvm-cfi-verify/llvm-cfi-verify.cpp | 15 +++--
 .../unittests/Support/SpecialCaseListTest.cpp | 62 ---
 10 files changed, 176 insertions(+), 51 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b93fa33acc2a0..80a5b7072677d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1009,6 +1009,7 @@ Sanitizers
 --
 
 - ``-fsanitize=vptr`` is no longer a part of ``-fsanitize=undefined``.
+- Sanitizer ignorelists now support the syntax ``src:*=sanitize``.
 
 Python Binding Changes
 --
diff --git a/clang/docs/SanitizerSpecialCaseList.rst 
b/clang/docs/SanitizerSpecialCaseList.rst
index 5c88c2976e861..692af8df0359b 100644
--- a/clang/docs/SanitizerSpecialCaseList.rst
+++ b/clang/docs/SanitizerSpecialCaseList.rst
@@ -58,7 +58,7 @@ Usage with UndefinedBehaviorSanitizer
 ability to adjust instrumentation based on type.
 
 By default, supported sanitizers will have their instrumentation disabled for
-types specified within an ignorelist.
+entries specified within an ignorelist.
 
 .. code-block:: bash
 
@@ -77,10 +77,9 @@ For example, supplying the above ``ignorelist.txt`` to
 ``-fsanitize-ignorelist=ignorelist.txt`` disables overflow sanitizer
 instrumentation for arithmetic operations containing values of type ``int``.
 
-The ``=sanitize`` category is also supported. Any types assigned to the
-``sanitize`` category will have their sanitizer instrumentation remain. If the
-same type appears within or across ignorelists with different categories the
-``sanitize`` category takes precedence -- regardless of order.
+The ``=sanitize`` category is also supported. Any ``=sanitize`` category
+entries enable sanitizer instrumentation, even if it was ignored by entries
+before.
 
 With this, one may disable instrumentation for some or all types and
 specifically allow instrumentation for one or many types -- including types
@@ -103,6 +102,23 @@ supported sanitizers.
 char c = toobig; // also not instrumented
   }
 
+If multiple entries match the source, than the latest entry takes the
+precedence.
+
+.. code-block:: bash
+
+  $ cat ignorelist1.txt
+  # test.cc will be instrumented.
+  src:*
+  src:*/mylib/*=sanitize
+  src:*/mylib/test.cc
+
+  $ cat ignorelist2.txt
+  # test.cc will not be instrumented.
+  src:*
+  src:*/mylib/test.cc
+  src:*/mylib/*=sanitize
+
 Format
 ==
 
diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h 
b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index d024b7dfc2e85..25d518e7128cf 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -43,13 +43,18 @@ class SanitizerSpecialCaseList : public 
llvm::SpecialCaseList {
   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
  StringRef Category = StringRef()) const;
 
+  // Query ignorelisted entries if any bit in Mask matches the entry's section.
+  // Return 0 if not found. If found, return the line number (starts with 1).
+  unsigned inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef 
Query,
+  StringRef Category = StringRef()) const;
+
 protected:
   // Initialize SanitizerSections.
   void createSanitizerSections();
 
   struct SanitizerSection {
 SanitizerSection(SanitizerMask SM, SectionEntries &E)
-: Mask(SM), Entries(E){};
+: Mask(SM), Entries(E) {};
 
 SanitizerMask Mask;
 SectionEntries &Entries;
diff --git a/clang/lib/Basic/NoSanitizeList.cpp 
b/clang/lib/Basic/NoSanitizeList.cpp
index e7e63c1f419e6..4feef5c6ea052 100644
--- a/clang/lib/Basic/NoSanitizeList.cpp
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -44,7 +44,15 @@ bool NoSanitizeList::containsFunction(SanitizerMask Mask,
 
 bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
   StringRef Category) const {
-  return SSCL->inSection(Mask, "src", FileName, Category);
+  unsigned N

[clang] [flang] [flang][driver] Introduce FCC_OVERRIDE_OPTIONS. (PR #140556)

2025-05-28 Thread Kiran Chandramohan via cfe-commits


@@ -0,0 +1,12 @@
+! RUN: env FCC_OVERRIDE_OPTIONS="#+-Os +-Oz +-O +-O3 +-Oignore +a +b +c xb Xa 
Omagic ^-###  " %flang -target x86_64-unknown-linux-gnu %s -O2 b -O3 2>&1 | 
FileCheck %s

kiranchandramohan wrote:

Does `+`, `x`,`X` have special meanings? Is that documented anywhere?

I think we should document `FCC_OVERRIDE_OPTIONS`.  One possible location is 
https://github.com/llvm/llvm-project/blob/main/flang/docs/FlangDriver.md

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


[clang] [C] Fix parsing of [[clang::assume]] (PR #141747)

2025-05-28 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman created 
https://github.com/llvm/llvm-project/pull/141747

The assumption attribute is exposed with a Clang spelling, which means we 
support __attribute__((assume)) as well as [[clang::assume]] as spellings for 
the attribute.

In C++, the [[clang::assume]] spelling worked as expected. In C, that spelling 
would emit an "unknown attribute ignored" diagnostic. This was happening 
because we were failing to pass in the scope name and source location when 
creating the attribute. In C++, this worked by chance because [[assume]] is a 
known attribute in C++. But in C, where there is thankfully no [[assume]] 
standard attribute, the lack of a scope meant we would set the attribute kind 
to "unknown".

>From 83104f072456c346ecf9463e78804b19deaa64dd Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Wed, 28 May 2025 07:55:20 -0400
Subject: [PATCH] [C] Fix parsing of [[clang::assume]]

The assumption attribute is exposed with a Clang spelling, which means
we support __attribute__((assume)) as well as [[clang::assume]] as
spellings for the attribute.

In C++, the [[clang::assume]] spelling worked as expected. In C, that
spelling would emit an "unknown attribute ignored" diagnostic. This was
happening because we were failing to pass in the scope name and source
location when creating the attribute. In C++, this worked by chance
because [[assume]] is a known attribute in C++. But in C, where there
is thankfully no [[assume]] standard attribute, the lack of a scope
meant we would set the attribute kind to "unknown".
---
 clang/docs/ReleaseNotes.rst|  3 +++
 clang/include/clang/Parse/Parser.h | 10 +-
 clang/lib/Parse/ParseDecl.cpp  |  6 --
 clang/lib/Parse/ParseDeclCXX.cpp   | 16 
 clang/test/Sema/assume.c   | 25 +
 5 files changed, 45 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/Sema/assume.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 35ab1461e7b89..59086bd68d9b9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -226,6 +226,9 @@ C Language Changes
 - Added the existing ``-Wduplicate-decl-specifier`` diagnostic, which is on by
   default, to ``-Wc++-compat`` because duplicated declaration specifiers are
   not valid in C++.
+- The ``[[clang::assume()]]`` attribute is now correctly recognized in C. The
+  ``__attribute__((assume()))`` form has always been supported, so the fix is
+  specific to the attribute syntax used.
 
 C2y Feature Support
 ^^^
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e6492b81dfff8..c4bef4729fd36 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3037,11 +3037,11 @@ class Parser : public CodeCompletionHandler {
 
   /// Parse the argument to C++23's [[assume()]] attribute. Returns true on
   /// error.
-  bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
-  IdentifierInfo *AttrName,
-  SourceLocation AttrNameLoc,
-  SourceLocation *EndLoc,
-  ParsedAttr::Form Form);
+  bool
+  ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs, IdentifierInfo *AttrName,
+ SourceLocation AttrNameLoc,
+ IdentifierInfo *ScopeName, SourceLocation 
ScopeLoc,
+ SourceLocation *EndLoc, ParsedAttr::Form Form);
 
   /// Try to parse an 'identifier' which appears within an attribute-token.
   ///
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f7eb56426f6de..d6c36616bab47 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -676,7 +676,8 @@ void Parser::ParseGNUAttributeArgs(
  Form);
 return;
   } else if (AttrKind == ParsedAttr::AT_CXXAssume) {
-ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
+ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, ScopeName,
+   ScopeLoc, EndLoc, Form);
 return;
   }
 
@@ -734,7 +735,8 @@ unsigned Parser::ParseClangAttributeArgs(
 break;
 
   case ParsedAttr::AT_CXXAssume:
-ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
+ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, ScopeName,
+   ScopeLoc, EndLoc, Form);
 break;
   }
   return !Attrs.empty() ? Attrs.begin()->getNumArgs() : 0;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index a665487a2f87d..2cf33a856c4f4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -4452,11 +4452,10 @@ static bool 
IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName,
   }
 }
 
-bool Parser::ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
- 

[clang] [C] Fix parsing of [[clang::assume]] (PR #141747)

2025-05-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Aaron Ballman (AaronBallman)


Changes

The assumption attribute is exposed with a Clang spelling, which means we 
support __attribute__((assume)) as well as [[clang::assume]] as spellings for 
the attribute.

In C++, the [[clang::assume]] spelling worked as expected. In C, that spelling 
would emit an "unknown attribute ignored" diagnostic. This was happening 
because we were failing to pass in the scope name and source location when 
creating the attribute. In C++, this worked by chance because [[assume]] is a 
known attribute in C++. But in C, where there is thankfully no [[assume]] 
standard attribute, the lack of a scope meant we would set the attribute kind 
to "unknown".

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


5 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/include/clang/Parse/Parser.h (+5-5) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+4-2) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+8-8) 
- (added) clang/test/Sema/assume.c (+25) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 35ab1461e7b89..59086bd68d9b9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -226,6 +226,9 @@ C Language Changes
 - Added the existing ``-Wduplicate-decl-specifier`` diagnostic, which is on by
   default, to ``-Wc++-compat`` because duplicated declaration specifiers are
   not valid in C++.
+- The ``[[clang::assume()]]`` attribute is now correctly recognized in C. The
+  ``__attribute__((assume()))`` form has always been supported, so the fix is
+  specific to the attribute syntax used.
 
 C2y Feature Support
 ^^^
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e6492b81dfff8..c4bef4729fd36 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3037,11 +3037,11 @@ class Parser : public CodeCompletionHandler {
 
   /// Parse the argument to C++23's [[assume()]] attribute. Returns true on
   /// error.
-  bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
-  IdentifierInfo *AttrName,
-  SourceLocation AttrNameLoc,
-  SourceLocation *EndLoc,
-  ParsedAttr::Form Form);
+  bool
+  ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs, IdentifierInfo *AttrName,
+ SourceLocation AttrNameLoc,
+ IdentifierInfo *ScopeName, SourceLocation 
ScopeLoc,
+ SourceLocation *EndLoc, ParsedAttr::Form Form);
 
   /// Try to parse an 'identifier' which appears within an attribute-token.
   ///
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f7eb56426f6de..d6c36616bab47 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -676,7 +676,8 @@ void Parser::ParseGNUAttributeArgs(
  Form);
 return;
   } else if (AttrKind == ParsedAttr::AT_CXXAssume) {
-ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
+ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, ScopeName,
+   ScopeLoc, EndLoc, Form);
 return;
   }
 
@@ -734,7 +735,8 @@ unsigned Parser::ParseClangAttributeArgs(
 break;
 
   case ParsedAttr::AT_CXXAssume:
-ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
+ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, ScopeName,
+   ScopeLoc, EndLoc, Form);
 break;
   }
   return !Attrs.empty() ? Attrs.begin()->getNumArgs() : 0;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index a665487a2f87d..2cf33a856c4f4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -4452,11 +4452,10 @@ static bool 
IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName,
   }
 }
 
-bool Parser::ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
-IdentifierInfo *AttrName,
-SourceLocation AttrNameLoc,
-SourceLocation *EndLoc,
-ParsedAttr::Form Form) {
+bool Parser::ParseCXXAssumeAttributeArg(
+ParsedAttributes &Attrs, IdentifierInfo *AttrName,
+SourceLocation AttrNameLoc, IdentifierInfo *ScopeName,
+SourceLocation ScopeLoc, SourceLocation *EndLoc, ParsedAttr::Form Form) {
   assert(Tok.is(tok::l_paren) && "Not a C++11 attribute argument list");
   BalancedDelimiterTracker T(*this, tok::l_paren);
   T.consumeOpen();
@@ -4498,8 +4497,8 @@ bool Parser::ParseCXXAssumeAttributeArg(ParsedAttributes 
&Attrs,
   ArgsUnion Assumption = Res.get();
   auto RParen = Tok.getLocation();
   T.consumeClose();
-  Attrs.addNe

[clang] [AMDGPU] fix amdgpu_max_num_work_groups in templates (PR #141633)

2025-05-28 Thread Yaxun Liu via cfe-commits

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


[clang] [Docs] Explicitly document libclang ABI and API stability (PR #141657)

2025-05-28 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/141657

>From c7a41997f41daea5669e1a5b003e0b42699c56d4 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Tue, 27 May 2025 14:52:35 -0400
Subject: [PATCH 1/4] [Docs] Explicitly document libclang ABI and API stability

Our current docs leave a lot of latitude ("relatively stable") without
explaining what the goals are for this stability. This patch adds some
basic documentation explaining that there are some changes which can
impact ABI and API stability that we reserve the right to make, lists
some scenarios we explicitly do not support, but otherwise tries to
assure the reader that the APIs and ABI are stable.
---
 clang/docs/LibClang.rst | 45 -
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/clang/docs/LibClang.rst b/clang/docs/LibClang.rst
index 08cf452a0df6c..bfcb95ee4a8ad 100644
--- a/clang/docs/LibClang.rst
+++ b/clang/docs/LibClang.rst
@@ -4,7 +4,7 @@
 Libclang tutorial
 =
 The C Interface to Clang provides a relatively small API that exposes 
facilities for parsing source code into an abstract syntax tree (AST), loading 
already-parsed ASTs, traversing the AST, associating physical source locations 
with elements within the AST, and other facilities that support Clang-based 
development tools.
-This C interface to Clang will never provide all of the information 
representation stored in Clang's C++ AST, nor should it: the intent is to 
maintain an API that is relatively stable from one release to the next, 
providing only the basic functionality needed to support development tools.
+This C interface to Clang will never provide all of the information 
representation stored in Clang's C++ AST, nor should it: the intent is to 
maintain an API that is :ref:`relatively stable ` from one release 
to the next, providing only the basic functionality needed to support 
development tools.
 The entire C interface of libclang is available in the file `Index.h`_
 
 Essential types overview
@@ -358,3 +358,46 @@ Complete example code
 
 
 .. _Index.h: 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang-c/Index.h
+
+.. _Stability:
+
+ABI and API Stability
+-
+
+The C interfaces in libclang are intended to be relatively stable. This allows
+a programmer to use libclang without having to worry as much about Clang
+upgrades breaking existing code. However, the library is not unchanging. For
+example, the library will gain new interfaces over time as needs arise,
+existing APIs may be deprecated for eventual removal, etc. Also, the underlying
+implementation of the facilities by Clang may change behavior as bugs are
+fixed, features get implemented, etc.
+
+The library should be ABI and API stable over time, but ABI- and API-breaking
+changes can happen in the following situations:
+
+* Adding new enumerator to an enumeration (can be ABI-breaking in C++).
+* Removing an explicitly deprecated API after a suitably long deprecation
+  period.
+* Uses of implementation details, such names or comments that say something is
+  "private", "reserved", "internal", etc.
+
+The library has version macros (``CINDEX_VERSION_MAJOR``,
+``CINDEX_VERSION_MINOR``, and ``CINDEX_VERSION``) which can be used to test for
+specific library versions at compile time. The ``CINDEX_VERSION_MAJOR`` macro
+is only incremented if there are major source- or ABI-breaking changes. Except
+for removing an explicitly deprecate API, the changes listed above are not
+considered major source- or ABI-breaking changes. Historically, the value this
+macro expands to has not changed, but may be incremented in the future should
+the need arise. The ``CINDEX_VERSION_MINOR`` macro is incremented as new APIs
+are added. The ``CINDEX_VERSION`` macro expands to a value based on the major
+and minor version macros.
+
+In an effort to allow the library to be modified as new needs arise, the
+following situations are explicitly unsupported:
+
+* Loading different library versions into the same executable and passing
+  objects between the libraries; despite general ABI stability, different
+  versions of the library may use different implementation details that are not
+  compatible across library versions.
+* For the same reason as above, serializing objects from one version of the
+  library and deserializing with a different version is also not supported.

>From b183361ee957a170cfa26f603191421b4c4c32b2 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Wed, 28 May 2025 08:06:33 -0400
Subject: [PATCH 2/4] Update some typos found during code review

---
 clang/docs/LibClang.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LibClang.rst b/clang/docs/LibClang.rst
index bfcb95ee4a8ad..248db892a3515 100644
--- a/clang/docs/LibClang.rst
+++ b/clang/docs/LibClang.rst
@@ -378,14 +378,14 @@ changes can happen in the following situations:
 * Adding

[clang] [NFC][AArch64] Add relnote saying modal FP8 intrinsics now fully implemented by ACLE (PR #141743)

2025-05-28 Thread Jonathan Thackray via cfe-commits

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

>From a76663bd47510c46b7c4415d4b5d97642ce69967 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 28 May 2025 11:47:00 +0100
Subject: [PATCH 1/2] [NFC][AArch64] Add relnote saying modal FP8 intrinsics
 now fully implemented by ACLE

---
 clang/docs/ReleaseNotes.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee74431cf33a7..0e375d72b62b4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -849,6 +849,10 @@ X86 Support
 Arm and AArch64 Support
 ^^^
 
+- Implementation of modal 8-bit floating point intrinsics in accordance with
+  the Arm C Language Extensions (ACLE)
+  `as specified here 
_`
+  is now available.
 - Support has been added for the following processors (command-line 
identifiers in parentheses):
   - Arm Cortex-A320 (``cortex-a320``)
 - For ARM targets, cc1as now considers the FPU's features for the selected CPU 
or Architecture.

>From 33fc84a1e7ca7079de46d8efb640d3433679e243 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 28 May 2025 13:11:35 +0100
Subject: [PATCH 2/2] fixup! Fix typo

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0e375d72b62b4..ccbcf1715989b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -851,7 +851,7 @@ Arm and AArch64 Support
 
 - Implementation of modal 8-bit floating point intrinsics in accordance with
   the Arm C Language Extensions (ACLE)
-  `as specified here 
_`
+  `as specified here 
`_
   is now available.
 - Support has been added for the following processors (command-line 
identifiers in parentheses):
   - Arm Cortex-A320 (``cortex-a320``)

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


[clang] [Docs] Explicitly document libclang ABI and API stability (PR #141657)

2025-05-28 Thread Aaron Ballman via cfe-commits


@@ -358,3 +358,46 @@ Complete example code
 
 
 .. _Index.h: 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang-c/Index.h
+
+.. _Stability:
+
+ABI and API Stability
+-
+
+The C interfaces in libclang are intended to be relatively stable. This allows
+a programmer to use libclang without having to worry as much about Clang
+upgrades breaking existing code. However, the library is not unchanging. For
+example, the library will gain new interfaces over time as needs arise,
+existing APIs may be deprecated for eventual removal, etc. Also, the underlying
+implementation of the facilities by Clang may change behavior as bugs are
+fixed, features get implemented, etc.
+
+The library should be ABI and API stable over time, but ABI- and API-breaking
+changes can happen in the following situations:
+
+* Adding new enumerator to an enumeration (can be ABI-breaking in C++).
+* Removing an explicitly deprecated API after a suitably long deprecation
+  period.
+* Uses of implementation details, such names or comments that say something is
+  "private", "reserved", "internal", etc.

AaronBallman wrote:

I tried to make it more clear that the list is non-exhaustive, and I added some 
wording about bug fixes. 


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


[clang] [clang] Move opt level in clang toolchain to clang::ConstructJob start (PR #141036)

2025-05-28 Thread Omar Ahmed via cfe-commits

omarahmed wrote:

@Artem-B @tarunprabhu Could you merge it for me as I don't have access, Thanks!

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


[clang] [clang][Sema] Diagnose exceptions only in non-dependent context in discarded `try/catch/throw` blocks (PR #139859)

2025-05-28 Thread Rajveer Singh Bharadwaj via cfe-commits

https://github.com/Rajveer100 updated 
https://github.com/llvm/llvm-project/pull/139859

>From a385808a47e3a7b585a225b9fbf10c55ba01ef5b Mon Sep 17 00:00:00 2001
From: Rajveer 
Date: Wed, 14 May 2025 13:44:31 +0530
Subject: [PATCH] [clang][Sema] Diagnose exceptions only in non-dependent
 context in discarded `try/catch/throw` blocks

Resolves #138939

When enabling `--fno-exceptions` flag, discarded statements containing
`try/catch/throw` in an independent context can be avoided from being
rejected.
---
 clang/include/clang/Sema/Sema.h  |  2 ++
 clang/lib/Sema/SemaExprCXX.cpp   |  9 ++---
 clang/lib/Sema/SemaStmt.cpp  | 26 +++---
 clang/lib/Sema/TreeTransform.h   |  4 
 clang/test/SemaCXX/no-exceptions.cpp | 25 -
 5 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6ea7ee281e14d..ebb40498e11aa 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11154,6 +11154,8 @@ class Sema final : public SemaBase {
   StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
   ArrayRef Handlers);
 
+  void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry);
+
   StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
   SourceLocation TryLoc, Stmt *TryBlock,
   Stmt *Handler);
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index b2a982e953012..cc75371a82ec5 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -851,13 +851,8 @@ ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr 
*Ex,
   const llvm::Triple &T = Context.getTargetInfo().getTriple();
   const bool IsOpenMPGPUTarget =
   getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
-  // Don't report an error if 'throw' is used in system headers or in an OpenMP
-  // target region compiled for a GPU architecture.
-  if (!IsOpenMPGPUTarget && !getLangOpts().CXXExceptions &&
-  !getSourceManager().isInSystemHeader(OpLoc) && !getLangOpts().CUDA) {
-// Delay error emission for the OpenMP device code.
-targetDiag(OpLoc, diag::err_exceptions_disabled) << "throw";
-  }
+
+  DiagnoseExceptionUse(OpLoc, /* IsTry= */ false);
 
   // In OpenMP target regions, we replace 'throw' with a trap on GPU targets.
   if (IsOpenMPGPUTarget)
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index e8c1f8490342a..d882b04202caf 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -4302,13 +4302,8 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, 
Stmt *TryBlock,
   const llvm::Triple &T = Context.getTargetInfo().getTriple();
   const bool IsOpenMPGPUTarget =
   getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
-  // Don't report an error if 'try' is used in system headers or in an OpenMP
-  // target region compiled for a GPU architecture.
-  if (!IsOpenMPGPUTarget && !getLangOpts().CXXExceptions &&
-  !getSourceManager().isInSystemHeader(TryLoc) && !getLangOpts().CUDA) {
-// Delay error emission for the OpenMP device code.
-targetDiag(TryLoc, diag::err_exceptions_disabled) << "try";
-  }
+
+  DiagnoseExceptionUse(TryLoc, /* IsTry= */ true);
 
   // In OpenMP target regions, we assume that catch is never reached on GPU
   // targets.
@@ -4410,6 +4405,23 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, 
Stmt *TryBlock,
 Handlers);
 }
 
+void Sema::DiagnoseExceptionUse(SourceLocation Loc, bool IsTry) {
+  const llvm::Triple &T = Context.getTargetInfo().getTriple();
+  const bool IsOpenMPGPUTarget =
+  getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
+
+  // Don't report an error if 'try' is used in system headers or in an OpenMP
+  // target region compiled for a GPU architecture.
+  if (IsOpenMPGPUTarget || getLangOpts().CUDA)
+// Delay error emission for the OpenMP device code.
+return;
+
+  if (!getLangOpts().CXXExceptions &&
+  !getSourceManager().isInSystemHeader(Loc) &&
+  !CurContext->isDependentContext())
+targetDiag(Loc, diag::err_exceptions_disabled) << (IsTry ? "try" : 
"throw");
+}
+
 StmtResult Sema::ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc,
   Stmt *TryBlock, Stmt *Handler) {
   assert(TryBlock && Handler);
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 335e21d927b76..b8ee3fedd6812 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -9162,6 +9162,8 @@ StmtResult 
TreeTransform::TransformCXXTryStmt(CXXTryStmt *S) {
 Handlers.push_back(Handler.getAs());
   }
 
+  getSema().DiagnoseExceptionUse(S->getTryLoc(), /* IsTry= */ true);
+
   if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryB

[clang] [C2y] Handle FP-suffixes on prefixed octals (#141230) (PR #141695)

2025-05-28 Thread Aaron Ballman via cfe-commits

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


[clang] [C2y] Handle FP-suffixes on prefixed octals (#141230) (PR #141695)

2025-05-28 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

I added @cor3ntin and @tahonermann for some extra sets of eyes, seeing as how I 
already messed this up once before. :-)

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


[clang] [C2y] Handle FP-suffixes on prefixed octals (#141230) (PR #141695)

2025-05-28 Thread Aaron Ballman via cfe-commits


@@ -1432,14 +1432,26 @@ void 
NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
 Diags.Report(TokLoc, DiagId);
 ++s;
 DigitsBegin = s;
-SawOctalPrefix = true;
+radix = 8;

AaronBallman wrote:

There's code below which also unconditionally sets `radix` to `8`; we should 
remove that and update the comments. We also seem to skip the octal digits 
twice (I think it's a noop to do it a second time, but it's still a code smell).

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


[clang] dcf3c79 - [NFC][AArch64] Add relnote saying modal FP8 intrinsics now fully implemented by ACLE (#141743)

2025-05-28 Thread via cfe-commits

Author: Jonathan Thackray
Date: 2025-05-28T13:22:05+01:00
New Revision: dcf3c79c36ac0e077eee26e8bc1e55d2eb99430c

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

LOG: [NFC][AArch64] Add relnote saying modal FP8 intrinsics now fully 
implemented by ACLE (#141743)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c83f135da541c..df8e035a65109 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -851,6 +851,10 @@ X86 Support
 Arm and AArch64 Support
 ^^^
 
+- Implementation of modal 8-bit floating point intrinsics in accordance with
+  the Arm C Language Extensions (ACLE)
+  `as specified here 
`_
+  is now available.
 - Support has been added for the following processors (command-line 
identifiers in parentheses):
   - Arm Cortex-A320 (``cortex-a320``)
 - For ARM targets, cc1as now considers the FPU's features for the selected CPU 
or Architecture.



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


[clang] [NFC][AArch64] Add relnote saying modal FP8 intrinsics now fully implemented by ACLE (PR #141743)

2025-05-28 Thread Jonathan Thackray via cfe-commits

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


[clang] [flang] [llvm] Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler (PR #136098)

2025-05-28 Thread Aaron Ballman via cfe-commits

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

Clang bits LGTM!

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


[clang] [Docs] Explicitly document libclang ABI and API stability (PR #141657)

2025-05-28 Thread Aaron Ballman via cfe-commits


@@ -373,19 +373,21 @@ implementation of the facilities by Clang may change 
behavior as bugs are
 fixed, features get implemented, etc.
 
 The library should be ABI and API stable over time, but ABI- and API-breaking
-changes can happen in the following situations:
+changes can happen in the following (non-exhaustive) situations:
 
 * Adding new enumerator to an enumeration (can be ABI-breaking in C++).
 * Removing an explicitly deprecated API after a suitably long deprecation
   period.
-* Uses of implementation details, such names or comments that say something is
-  "private", "reserved", "internal", etc.
+* Using implementation details, such as names or comments that say something
+  is "private", "reserved", "internal", etc.
+* Bug fixes or changes to Clang's internal implementation, or (rarely), bug

AaronBallman wrote:

I think bug fixes to Clang internals are always fair game for us and something 
libclang folks will have to react to, which is why it's important to disallow 
multiple versions of the library from interacting. But fixes to libclang itself 
is something I think we can be more judicious about. e.g., adding a forgotten 
enumerator really shouldn't be a problem. Renaming one we don't like the name 
for is more disruptive and something we'd likely avoid doing.

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


[clang] [llvm] [HLSL][RootSignature] Add parsing of floats for StaticSampler (PR #140181)

2025-05-28 Thread Finn Plummer via cfe-commits

https://github.com/inbelic updated 
https://github.com/llvm/llvm-project/pull/140181

>From 1c40e031725f1bd21c5c0d24d333781f99bd2a0a Mon Sep 17 00:00:00 2001
From: Finn Plummer 
Date: Thu, 15 May 2025 23:14:10 +
Subject: [PATCH 01/18] pre-req: add missing token to Lexer

---
 clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def | 3 +++
 clang/unittests/Lex/LexHLSLRootSignatureTest.cpp| 2 ++
 2 files changed, 5 insertions(+)

diff --git a/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def 
b/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
index ddebe82987197..5d16eaa5b72f6 100644
--- a/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
+++ b/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
@@ -100,6 +100,9 @@ KEYWORD(flags)
 KEYWORD(numDescriptors)
 KEYWORD(offset)
 
+// StaticSampler Keywords:
+KEYWORD(mipLODBias)
+
 // Unbounded Enum:
 UNBOUNDED_ENUM(unbounded, "unbounded")
 
diff --git a/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp 
b/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp
index 3e38c281f4fb1..b610b8f10f8da 100644
--- a/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp
@@ -136,6 +136,8 @@ TEST_F(LexHLSLRootSignatureTest, ValidLexAllTokensTest) {
 space visibility flags
 numDescriptors offset
 
+mipLODBias
+
 unbounded
 DESCRIPTOR_RANGE_OFFSET_APPEND
 

>From f3ace332f9984dfefea388b9bc26da0e7643c6c5 Mon Sep 17 00:00:00 2001
From: Finn Plummer 
Date: Thu, 15 May 2025 23:15:04 +
Subject: [PATCH 02/18] pre-req: add parsing of MipLODBias as an uint

- defines a float data member of StaticSampler that will be used to test
functionality of parsing a float
---
 .../clang/Parse/ParseHLSLRootSignature.h  |  1 +
 clang/lib/Parse/ParseHLSLRootSignature.cpp| 21 +++
 .../Parse/ParseHLSLRootSignatureTest.cpp  |  3 ++-
 .../llvm/Frontend/HLSL/HLSLRootSignature.h|  1 +
 4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h 
b/clang/include/clang/Parse/ParseHLSLRootSignature.h
index da17388a2aea5..2ec806c380b37 100644
--- a/clang/include/clang/Parse/ParseHLSLRootSignature.h
+++ b/clang/include/clang/Parse/ParseHLSLRootSignature.h
@@ -111,6 +111,7 @@ class RootSignatureParser {
 
   struct ParsedStaticSamplerParams {
 std::optional Reg;
+std::optional MipLODBias;
   };
   std::optional parseStaticSamplerParams();
 
diff --git a/clang/lib/Parse/ParseHLSLRootSignature.cpp 
b/clang/lib/Parse/ParseHLSLRootSignature.cpp
index a37505e360fc0..d16644f990847 100644
--- a/clang/lib/Parse/ParseHLSLRootSignature.cpp
+++ b/clang/lib/Parse/ParseHLSLRootSignature.cpp
@@ -376,6 +376,10 @@ std::optional 
RootSignatureParser::parseStaticSampler() {
 
   Sampler.Reg = Params->Reg.value();
 
+  // Fill in optional values
+  if (Params->MipLODBias.has_value())
+Sampler.MipLODBias = Params->MipLODBias.value();
+
   if (consumeExpectedToken(TokenKind::pu_r_paren,
diag::err_hlsl_unexpected_end_of_params,
/*param of=*/TokenKind::kw_StaticSampler))
@@ -661,6 +665,23 @@ RootSignatureParser::parseStaticSamplerParams() {
 return std::nullopt;
   Params.Reg = Reg;
 }
+
+// `mipLODBias` `=` NUMBER
+if (tryConsumeExpectedToken(TokenKind::kw_mipLODBias)) {
+  if (Params.MipLODBias.has_value()) {
+getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
+<< CurToken.TokKind;
+return std::nullopt;
+  }
+
+  if (consumeExpectedToken(TokenKind::pu_equal))
+return std::nullopt;
+
+  auto MipLODBias = parseUIntParam();
+  if (!MipLODBias.has_value())
+return std::nullopt;
+  Params.MipLODBias = (float)*MipLODBias;
+}
   } while (tryConsumeExpectedToken(TokenKind::pu_comma));
 
   return Params;
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp 
b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index cd3b12dbe4d24..c7dae1c27ceeb 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -225,7 +225,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) 
{
 
 TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
   const llvm::StringLiteral Source = R"cc(
-StaticSampler(s0)
+StaticSampler(s0, mipLODBias = 0)
   )cc";
 
   TrivialModuleLoader ModLoader;
@@ -247,6 +247,7 @@ TEST_F(ParseHLSLRootSignatureTest, 
ValidParseStaticSamplerTest) {
   ASSERT_TRUE(std::holds_alternative(Elem));
   ASSERT_EQ(std::get(Elem).Reg.ViewType, RegisterType::SReg);
   ASSERT_EQ(std::get(Elem).Reg.Number, 0u);
+  ASSERT_EQ(std::get(Elem).MipLODBias, 0u);
 
   ASSERT_TRUE(Consumer->isSatisfied());
 }
diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h 
b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
index f9de86b567fea..fea9a9962991c 100644
--- a/llvm/i

[clang] [llvm] [HLSL][RootSignature] Add parsing of floats for StaticSampler (PR #140181)

2025-05-28 Thread Finn Plummer via cfe-commits


@@ -821,22 +873,115 @@ std::optional 
RootSignatureParser::handleUIntLiteral() {
   PP.getSourceManager(), PP.getLangOpts(),
   PP.getTargetInfo(), PP.getDiagnostics());
   if (Literal.hadError)
-return true; // Error has already been reported so just return
+return std::nullopt; // Error has already been reported so just return
 
-  assert(Literal.isIntegerLiteral() && "IsNumberChar will only support 
digits");
+  assert(Literal.isIntegerLiteral() &&
+ "NumSpelling can only consist of digits");
 
-  llvm::APSInt Val = llvm::APSInt(32, false);
+  llvm::APSInt Val = llvm::APSInt(32, /*IsUnsigned=*/true);
   if (Literal.GetIntegerValue(Val)) {
 // Report that the value has overflowed
 PP.getDiagnostics().Report(CurToken.TokLoc,
diag::err_hlsl_number_literal_overflow)
-<< 0 << CurToken.NumSpelling;
+<< /*integer type*/ 0 << /*is signed*/ 0;
 return std::nullopt;
   }
 
   return Val.getExtValue();
 }
 
+std::optional RootSignatureParser::handleIntLiteral(bool Negated) {
+  // Parse the numeric value and do semantic checks on its specification
+  clang::NumericLiteralParser Literal(CurToken.NumSpelling, CurToken.TokLoc,
+  PP.getSourceManager(), PP.getLangOpts(),
+  PP.getTargetInfo(), PP.getDiagnostics());
+  if (Literal.hadError)
+return std::nullopt; // Error has already been reported so just return
+
+  assert(Literal.isIntegerLiteral() &&
+ "NumSpelling can only consist of digits");
+
+  llvm::APSInt Val = llvm::APSInt(32, /*IsUnsigned=*/true);
+  // GetIntegerValue will overwrite Val from the parsed Literal and return
+  // true if it overflows as a 32-bit unsigned int. Then check that it also
+  // doesn't overflow as a signed 32-bit int.
+  int64_t MaxMagnitude =
+  -static_cast(std::numeric_limits::min());
+  if (Literal.GetIntegerValue(Val) || MaxMagnitude < Val.getExtValue()) {

inbelic wrote:

Updated such that `handleIntLiteral` will correctly handle overflow for a 
positive signed integer `int32_t`.

The only caveat is that it doesn't have a test case as this can't currently be 
invoked through the current public parser api.

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


[clang] 894a0dd - Revert "[KeyIntsr][Clang] Builtins atoms (#134651)"

2025-05-28 Thread Orlando Cazalet-Hyams via cfe-commits

Author: Orlando Cazalet-Hyams
Date: 2025-05-28T18:31:08+01:00
New Revision: 894a0dd57f81211f9e431d9e84f2856d34f46993

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

LOG: Revert "[KeyIntsr][Clang] Builtins atoms (#134651)"

This reverts commit b14799e9e0ed2cae7cbce45c41326b151fea.

Breaks downstream bots.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 
clang/test/DebugInfo/KeyInstructions/builtin.c



diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index be65fa438bb06..89b321090f2d8 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -29,7 +29,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/IR/InlineAsm.h"
-#include "llvm/IR/Instruction.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/IntrinsicsX86.h"
 #include "llvm/IR/MatrixBuilder.h"
@@ -4191,7 +4190,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Matrix, Dst.emitRawPointer(*this),
 Align(Dst.getAlignment().getQuantity()), Stride, IsVolatile,
 MatrixTy->getNumRows(), MatrixTy->getNumColumns());
-addInstToNewSourceAtom(cast(Result), Matrix);
 return RValue::get(Result);
   }
 
@@ -4352,8 +4350,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(1));
 EmitNonNullArgCheck(Dest, E->getArg(0)->getType(),
 E->getArg(0)->getExprLoc(), FD, 0);
-auto *I = Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
-addInstToNewSourceAtom(I, nullptr);
+Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
 return RValue::get(nullptr);
   }
 
@@ -4368,8 +4365,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 EmitNonNullArgCheck(RValue::get(Dest.emitRawPointer(*this)),
 E->getArg(1)->getType(), E->getArg(1)->getExprLoc(), 
FD,
 0);
-auto *I = Builder.CreateMemMove(Dest, Src, SizeVal, false);
-addInstToNewSourceAtom(I, nullptr);
+Builder.CreateMemMove(Dest, Src, SizeVal, false);
 return RValue::get(nullptr);
   }
 
@@ -4382,8 +4378,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Value *SizeVal = EmitScalarExpr(E->getArg(2));
 EmitArgCheck(TCK_Store, Dest, E->getArg(0), 0);
 EmitArgCheck(TCK_Load, Src, E->getArg(1), 1);
-auto *I = Builder.CreateMemCpy(Dest, Src, SizeVal, false);
-addInstToNewSourceAtom(I, nullptr);
+Builder.CreateMemCpy(Dest, Src, SizeVal, false);
 if (BuiltinID == Builtin::BImempcpy ||
 BuiltinID == Builtin::BI__builtin_mempcpy)
   return RValue::get(Builder.CreateInBoundsGEP(
@@ -4399,8 +4394,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 E->getArg(2)->EvaluateKnownConstInt(getContext()).getZExtValue();
 EmitArgCheck(TCK_Store, Dest, E->getArg(0), 0);
 EmitArgCheck(TCK_Load, Src, E->getArg(1), 1);
-auto *I = Builder.CreateMemCpyInline(Dest, Src, Size);
-addInstToNewSourceAtom(I, nullptr);
+Builder.CreateMemCpyInline(Dest, Src, Size);
 return RValue::get(nullptr);
   }
 
@@ -4421,8 +4415,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Address Dest = EmitPointerWithAlignment(E->getArg(0));
 Address Src = EmitPointerWithAlignment(E->getArg(1));
 Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size);
-auto *I = Builder.CreateMemCpy(Dest, Src, SizeVal, false);
-addInstToNewSourceAtom(I, nullptr);
+Builder.CreateMemCpy(Dest, Src, SizeVal, false);
 return RValue::get(Dest, *this);
   }
 
@@ -4448,8 +4441,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Address Dest = EmitPointerWithAlignment(E->getArg(0));
 Address Src = EmitPointerWithAlignment(E->getArg(1));
 Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size);
-auto *I = Builder.CreateMemMove(Dest, Src, SizeVal, false);
-addInstToNewSourceAtom(I, nullptr);
+Builder.CreateMemMove(Dest, Src, SizeVal, false);
 return RValue::get(Dest, *this);
   }
 
@@ -4469,8 +4461,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   .getQuantity()));
 EmitArgCheck(TCK_Store, Dest, E->getArg(0), 0);
 EmitArgCheck(TCK_Load, Src, E->getArg(1), 1);
-auto *I = Builder.CreateMemMove(Dest, Src, SizeVal, false);
-addInstToNewSourceAtom(I, nullptr);
+Builder.CreateMemMove(Dest, Src, SizeVal, false);
 return RValue::get(Dest, *this);
   }
   case Builti

[clang] Include [[clang::require_explicit_initialization]] warnings in system headers (PR #141133)

2025-05-28 Thread via cfe-commits

higher-performance wrote:

Could I move forward with merging this? Or does anyone feel there are blockers 
here?

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


[clang] [llvm] Reland "Add macro to suppress -Wunnecessary-virtual-specifier" (PR #141091)

2025-05-28 Thread Nico Weber via cfe-commits


@@ -710,4 +710,28 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
 #define LLVM_PREFERRED_TYPE(T)
 #endif
 
+/// \macro LLVM_VIRTUAL_ANCHOR_FUNCTION
+/// This macro is used to adhere to LLVM's policy that each class with a vtable
+/// must have at least one out-of-line virtual function. This macro allows us
+/// to declare such a function in `final` classes without triggering a warning.
+// clang-format off
+// Autoformatting makes this look awful.
+#if defined(__clang__)
+  // Make sure this is only parsed if __clang__ is defined

nico wrote:

(I think some clangs on some bots don't have `__has_warning`; I ran into that 
recently too: 
https://github.com/llvm/llvm-project/commit/c2a62af2a51d58183bcd72ee8a86c37ddd526758
 I'll push a similar commit for this.)

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


[clang] [NFCI][ubsan] Precommit tests for -fsanitize-annotate-debug-info (PR #141814)

2025-05-28 Thread Vitaly Buka via cfe-commits

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


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


[clang] [CIR] Defer declarations and tentative definitions (PR #141700)

2025-05-28 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor updated 
https://github.com/llvm/llvm-project/pull/141700

>From f0520c397b3739c09aeaf75c20e33ecf9053c2af Mon Sep 17 00:00:00 2001
From: Andy Kaylor 
Date: Fri, 23 May 2025 17:53:48 -0700
Subject: [PATCH 1/2] [CIR] Defer declarations and tentative definitions

This change adds code to defer emitting declarations and tentative
definitions until they are referenced or trigger by a call to
CompleteTentativeDefinition. This is needed to avoid premature handling
of declarations and definitions that might not be referenced in the
current translation unit. It also avoids incorrectly adding an
initializer to external declarations.

This change also updates the way the insertion location for globals is
chosen so that all globals will be emitted together at the top of the
module. This makes no functional difference, but it is very useful for
writing sensible tests.

Some tests are modified in this change to reorder global variables so
that they can be checked in the order in which they will be emitted.
---
 clang/include/clang/CIR/CIRGenerator.h|  2 +
 clang/include/clang/CIR/MissingFeatures.h |  1 +
 clang/lib/CIR/CodeGen/CIRGenModule.cpp| 61 ++-
 clang/lib/CIR/CodeGen/CIRGenModule.h  |  4 ++
 clang/lib/CIR/CodeGen/CIRGenerator.cpp|  7 +++
 clang/lib/CIR/FrontendAction/CIRGenAction.cpp |  4 ++
 clang/test/CIR/CodeGen/array.cpp  | 26 +---
 clang/test/CIR/CodeGen/basic.c| 47 +++---
 clang/test/CIR/CodeGen/basic.cpp  | 53 
 clang/test/CIR/CodeGen/string-literals.c  |  7 ++-
 clang/test/CIR/CodeGen/struct.c   | 12 ++--
 clang/test/CIR/Lowering/array.cpp | 18 --
 clang/test/CIR/Lowering/hello.c   |  8 +--
 13 files changed, 155 insertions(+), 95 deletions(-)

diff --git a/clang/include/clang/CIR/CIRGenerator.h 
b/clang/include/clang/CIR/CIRGenerator.h
index 883dce9deb8e3..bb20fdf72693b 100644
--- a/clang/include/clang/CIR/CIRGenerator.h
+++ b/clang/include/clang/CIR/CIRGenerator.h
@@ -54,6 +54,8 @@ class CIRGenerator : public clang::ASTConsumer {
   ~CIRGenerator() override;
   void Initialize(clang::ASTContext &astContext) override;
   bool HandleTopLevelDecl(clang::DeclGroupRef group) override;
+  void CompleteTentativeDefinition(clang::VarDecl *d) override;
+
   mlir::ModuleOp getModule() const;
   mlir::MLIRContext &getMLIRContext() { return *mlirContext; };
   const mlir::MLIRContext &getMLIRContext() const { return *mlirContext; };
diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index fb205e9cd85d1..56bf9b1130f12 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -201,6 +201,7 @@ struct MissingFeatures {
   static bool writebacks() { return false; }
   static bool cleanupsToDeactivate() { return false; }
   static bool stackBase() { return false; }
+  static bool deferredDecls() { return false; }
 
   // Missing types
   static bool dataMemberType() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 60a3048f548e8..a1c2bc2e2ee72 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -231,8 +231,20 @@ void CIRGenModule::emitGlobal(clang::GlobalDecl gd) {
   return;
 }
   } else {
-assert(cast(global)->isFileVarDecl() &&
-   "Cannot emit local var decl as global");
+const auto *vd = cast(global);
+assert(vd->isFileVarDecl() && "Cannot emit local var decl as global.");
+if (vd->isThisDeclarationADefinition() != VarDecl::Definition &&
+!astContext.isMSStaticDataMemberInlineDefinition(vd)) {
+  assert(!cir::MissingFeatures::openMP());
+  // If this declaration may have caused an inline variable definition to
+  // change linkage, make sure that it's emitted.
+  if (astContext.getInlineVariableDefinitionKind(vd) ==
+  ASTContext::InlineVariableDefinitionKind::Strong)
+getAddrOfGlobalVar(vd);
+  // Otherwise, we can ignore this declaration. The variable will be 
emitted
+  // on its first use.
+  return;
+}
   }
 
   // TODO(CIR): Defer emitting some global definitions until later
@@ -279,22 +291,23 @@ cir::GlobalOp CIRGenModule::createGlobalOp(CIRGenModule 
&cgm,
   {
 mlir::OpBuilder::InsertionGuard guard(builder);
 
-// Some global emissions are triggered while emitting a function, e.g.
-// void s() { const char *s = "yolo"; ... }
-//
-// Be sure to insert global before the current function
-CIRGenFunction *curCGF = cgm.curCGF;
-if (curCGF)
-  builder.setInsertionPoint(curCGF->curFn);
-
-g = builder.create(loc, name, t);
-if (!curCGF) {
-  if (insertPoint)
-cgm.getModule().insert(insertPoint, g);
+// If an insertion point is provided, we're replacing an existing global,
+

[clang] [NFCI][ubsan] Precommit tests for -fsanitize-annotate-debug-info (PR #141814)

2025-05-28 Thread Thurston Dang via cfe-commits

https://github.com/thurstond updated 
https://github.com/llvm/llvm-project/pull/141814

>From 04f6229593a5891025d4ac240b3b5b15535a1e25 Mon Sep 17 00:00:00 2001
From: Thurston Dang 
Date: Wed, 28 May 2025 17:55:46 +
Subject: [PATCH 1/2] [NFCI][ubsan] Precommit tests for
 -fsanitize-annotate-debug-info

These tests will track progress on extending
https://github.com/llvm/llvm-project/pull/139809 from CFI to more UBSan
checks.
---
 clang/test/CodeGen/ubsan-function-debuginfo.c | 74 +++
 .../CodeGen/unsigned-promotion-debuginfo.c| 95 +++
 2 files changed, 169 insertions(+)
 create mode 100644 clang/test/CodeGen/ubsan-function-debuginfo.c
 create mode 100644 clang/test/CodeGen/unsigned-promotion-debuginfo.c

diff --git a/clang/test/CodeGen/ubsan-function-debuginfo.c 
b/clang/test/CodeGen/ubsan-function-debuginfo.c
new file mode 100644
index 0..c452b84907045
--- /dev/null
+++ b/clang/test/CodeGen/ubsan-function-debuginfo.c
@@ -0,0 +1,74 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s 
-o - \
+// RUN:   -fdebug-prefix-map=%S/= -fno-ident -fdebug-compilation-dir=%S 
-debug-info-kind=limited \
+// RUN:   -fsanitize-annotate-debug-info=function \
+// RUN:   | FileCheck %s
+
+// CHECK-LABEL: define dso_local void @call_no_prototype(
+// CHECK-SAME: ptr noundef [[F:%.*]]) #[[ATTR0:[0-9]+]] !dbg [[DBG4:![0-9]+]] 
!func_sanitize [[META12:![0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[F]], ptr [[F_ADDR]], align 8
+// CHECK-NEXT:  #dbg_declare(ptr [[F_ADDR]], [[META13:![0-9]+]], 
!DIExpression(), [[META14:![0-9]+]])
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[F_ADDR]], align 8, !dbg 
[[DBG15:![0-9]+]]
+// CHECK-NEXT:call void (...) [[TMP0]](), !dbg [[DBG15]]
+// CHECK-NEXT:ret void, !dbg [[DBG16:![0-9]+]]
+//
+void call_no_prototype(void (*f)()) { f(); }
+
+// CHECK-LABEL: define dso_local void @call_prototype(
+// CHECK-SAME: ptr noundef [[F:%.*]]) #[[ATTR0]] !dbg [[DBG17:![0-9]+]] 
!func_sanitize [[META23:![0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[F]], ptr [[F_ADDR]], align 8
+// CHECK-NEXT:  #dbg_declare(ptr [[F_ADDR]], [[META24:![0-9]+]], 
!DIExpression(), [[META25:![0-9]+]])
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[F_ADDR]], align 8, !dbg 
[[DBG26:![0-9]+]]
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr <{ i32, i32 }>, ptr [[TMP0]], 
i32 -1, i32 0, !dbg [[DBG26]], !nosanitize [[META11:![0-9]+]]
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, ptr [[TMP1]], align 4, !dbg 
[[DBG26]], !nosanitize [[META11]]
+// CHECK-NEXT:[[TMP3:%.*]] = icmp eq i32 [[TMP2]], -1056584962, !dbg 
[[DBG26]], !nosanitize [[META11]]
+// CHECK-NEXT:br i1 [[TMP3]], label %[[TYPECHECK:.*]], label 
%[[CONT1:.*]], !dbg [[DBG26]], !nosanitize [[META11]]
+// CHECK:   [[TYPECHECK]]:
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr <{ i32, i32 }>, ptr [[TMP0]], 
i32 -1, i32 1, !dbg [[DBG26]], !nosanitize [[META11]]
+// CHECK-NEXT:[[TMP5:%.*]] = load i32, ptr [[TMP4]], align 8, !dbg 
[[DBG26]], !nosanitize [[META11]]
+// CHECK-NEXT:[[TMP6:%.*]] = icmp eq i32 [[TMP5]], 905068220, !dbg 
[[DBG26]], !nosanitize [[META11]]
+// CHECK-NEXT:br i1 [[TMP6]], label %[[CONT:.*]], label 
%[[HANDLER_FUNCTION_TYPE_MISMATCH:.*]], !dbg [[DBG26]], !prof 
[[PROF27:![0-9]+]], !nosanitize [[META11]]
+// CHECK:   [[HANDLER_FUNCTION_TYPE_MISMATCH]]:
+// CHECK-NEXT:[[TMP7:%.*]] = ptrtoint ptr [[TMP0]] to i64, !dbg [[DBG26]], 
!nosanitize [[META11]]
+// CHECK-NEXT:call void @__ubsan_handle_function_type_mismatch_abort(ptr 
@[[GLOB1:[0-9]+]], i64 [[TMP7]]) #[[ATTR2:[0-9]+]], !dbg [[DBG26]], !nosanitize 
[[META11]]
+// CHECK-NEXT:unreachable, !dbg [[DBG26]], !nosanitize [[META11]]
+// CHECK:   [[CONT]]:
+// CHECK-NEXT:br label %[[CONT1]], !dbg [[DBG26]], !nosanitize [[META11]]
+// CHECK:   [[CONT1]]:
+// CHECK-NEXT:call void [[TMP0]](), !dbg [[DBG26]]
+// CHECK-NEXT:ret void, !dbg [[DBG28:![0-9]+]]
+//
+void call_prototype(void (*f)(void)) { f(); }
+//.
+// CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, 
file: [[META1:![0-9]+]], isOptimized: false, runtimeVersion: 0, emissionKind: 
FullDebug, splitDebugInlining: false, nameTableKind: None)
+// CHECK: [[META1]] = !DIFile(filename: "", directory: {{.*}})
+// CHECK: [[DBG4]] = distinct !DISubprogram(name: "call_no_prototype", scope: 
[[META5:![0-9]+]], file: [[META5]], line: 16, type: [[META6:![0-9]+]], 
scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: 
[[META0]], retainedNodes: [[META11]])
+// CHECK: [[META5]] = !DIFile(filename: "{{.*}}ubsan-function-debuginfo.c", 
directory: {{.*}})
+// CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+

[clang] [NFCI][ubsan] Precommit tests for -fsanitize-annotate-debug-info (PR #141814)

2025-05-28 Thread Vitaly Buka via cfe-commits

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


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


[clang] [NFCI][ubsan] Precommit tests for -fsanitize-annotate-debug-info (PR #141814)

2025-05-28 Thread Thurston Dang via cfe-commits


@@ -0,0 +1,74 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s 
-o - \

thurstond wrote:

Done

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


[clang] [OpenMP] Fix atomic compare handling with overloaded operators (PR #141142)

2025-05-28 Thread Johannes Doerfert via cfe-commits


@@ -991,3 +991,34 @@ int mixed() {
   // expected-note@+1 {{in instantiation of function template specialization 
'mixed' requested here}}
   return mixed();
 }
+
+#ifdef OMP51
+struct U {};
+struct U operator<(U, U);
+struct U operator>(U, U);
+struct U operator==(U, U);
+
+template  void templated() {
+  T cx, cv, ce, cd;
+#pragma omp atomic compare capture
+  if (cx == ce) {
+cx = cd;
+  } else {
+cv = cx;
+  }
+#pragma omp atomic compare capture
+  {
+cv = cx;
+if (ce > cx) {
+  cx = ce;
+}
+  }
+#pragma omp atomic compare capture
+  {
+cv = cx;
+if (cx < ce) {
+  cx = ce;
+}
+  }
+}
+#endif

jdoerfert wrote:

We need a similar test as a codegen test as well.

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


[clang] [OpenMP] Fix atomic compare handling with overloaded operators (PR #141142)

2025-05-28 Thread Johannes Doerfert via cfe-commits


@@ -12062,32 +12154,56 @@ bool 
OpenMPAtomicCompareCaptureChecker::checkForm3(IfStmt *S,
   X = BO->getLHS();
   D = BO->getRHS();
 
-  auto *Cond = dyn_cast(S->getCond());
-  if (!Cond) {
+  if (auto *Cond = dyn_cast(S->getCond())) {
+C = Cond;
+if (Cond->getOpcode() != BO_EQ) {
+  ErrorInfo.Error = ErrorTy::NotEQ;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+  return false;
+}
+
+if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS())) {
+  E = Cond->getRHS();
+} else if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getRHS())) {
+  E = Cond->getLHS();
+} else {
+  ErrorInfo.Error = ErrorTy::InvalidComparison;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+  return false;
+}
+  } else if (auto *Call = dyn_cast(S->getCond())) {
+C = Call;
+if (Call->getNumArgs() != 2) {
+  ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Call->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Call->getSourceRange();
+  return false;
+}
+if (Call->getOperator() != clang::OverloadedOperatorKind::OO_EqualEqual) {
+  ErrorInfo.Error = ErrorTy::NotEQ;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Call->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Call->getSourceRange();
+  return false;
+}
+
+if (checkIfTwoExprsAreSame(ContextRef, X, Call->getArg(0))) {
+  E = Call->getArg(1);
+} else if (checkIfTwoExprsAreSame(ContextRef, X, Call->getArg(1))) {
+  E = Call->getArg(0);
+} else {
+  ErrorInfo.Error = ErrorTy::InvalidComparison;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Call->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Call->getSourceRange();
+  return false;
+}

jdoerfert wrote:

Here and above, I think we can reasonably make helpers. It can take things like
```
bool IsEqual, bool IsLT, ..., auto *LHS, auto *RHS
```
and check the conditions.


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


[clang] [CIR] Allow use different Int types together in Vec Shift Op (PR #141111)

2025-05-28 Thread Amr Hesham via cfe-commits

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


[clang] [llvm] [clang][CodeGen][AA] Add `!llvm.errno.tbaa` gathering int-compatible TBAA nodes (PR #125258)

2025-05-28 Thread John McCall via cfe-commits

rjmccall wrote:

> Oh, sorry for not providing context earlier. The reasoning behind is to allow 
> certain optimizations involving errno-writing libcalls (marked as 
> `memory(errnomem: write)`) to occur, if we are able to prove the involved 
> memory location does not alias errno (e.g., because we are accessing a 
> float-typed pointer). IIUC, in standard C, errno is an int, so all legitimate 
> accesses must use int-compatible types (or otherwise violating strict 
> aliasing). Hence, we should be able to leverage TBAA and prove not aliasing 
> with errno, if we do not alias for any nodes belonging to `!llvm.errno.tbaa` 
> (which is presumably gathering all int-based nodes; this should require 
> confirmation).

I see. So the idea here is *not* that we're changing the TBAA nodes used for 
any actual accesses. Instead, we're using a named global metadata to specify 
the TBAA node that all `errno` accesses would use so that LLVM can do alias 
analysis around these libcalls (presumably to allow load/store optimization 
across them). That makes a lot of sense, thanks for the clarification. Please 
update your commit messages and PR title and description; I think if you 
re-read them, you're see that they sound as if you're trying to change how 
accesses to `errno` are annotated. In the meantime, I think I have the context 
to review the PR now.

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


[clang] Include [[clang::require_explicit_initialization]] warnings in system headers (PR #141133)

2025-05-28 Thread via cfe-commits

higher-performance wrote:

I see, thanks for explaining. That would be great if you can discuss it offline 
in the near future.

In the meantime, let me just emphasize a some points from my side before I 
forget:

- The question of delayed initialization is (so far as I can tell) entirely 
orthogonal to the question of what the standard library should be doing here. 
If we keep the current spec, then obviously the existing behavior is buggy, and 
this PR is required for the fix. If we _do_ relax the attribute to allow 
delayed initialization, then it would require dataflow analysis out of the 
standard library (since it would now be okay to do `std::construct_at(...)` 
followed by filling in the fields). Either way, I struggle to see how treating 
the standard library differently would solve anything.
- Insofar as the current spec goes -- just as `std::construct_at` cannot 
possibly detect (let alone try to avoid) an in-class member initializer that 
goes awry when invoked, I think it also cannot (and should not) try to avoid 
the same issue w.r.t. this attribute. It simply does not have enough 
information, and this is true for every function out there that constructs a 
user-specified type (`emplace_back`, etc.), not just those in the standard 
library.

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


[clang] [OpenMP] Fix atomic compare handling with overloaded operators (PR #141142)

2025-05-28 Thread Joseph Huber via cfe-commits


@@ -12062,32 +12154,56 @@ bool 
OpenMPAtomicCompareCaptureChecker::checkForm3(IfStmt *S,
   X = BO->getLHS();
   D = BO->getRHS();
 
-  auto *Cond = dyn_cast(S->getCond());
-  if (!Cond) {
+  if (auto *Cond = dyn_cast(S->getCond())) {
+C = Cond;
+if (Cond->getOpcode() != BO_EQ) {
+  ErrorInfo.Error = ErrorTy::NotEQ;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+  return false;
+}
+
+if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS())) {
+  E = Cond->getRHS();
+} else if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getRHS())) {
+  E = Cond->getLHS();
+} else {
+  ErrorInfo.Error = ErrorTy::InvalidComparison;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+  return false;
+}
+  } else if (auto *Call = dyn_cast(S->getCond())) {
+C = Call;
+if (Call->getNumArgs() != 2) {
+  ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Call->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Call->getSourceRange();
+  return false;
+}
+if (Call->getOperator() != clang::OverloadedOperatorKind::OO_EqualEqual) {
+  ErrorInfo.Error = ErrorTy::NotEQ;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Call->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Call->getSourceRange();
+  return false;
+}
+
+if (checkIfTwoExprsAreSame(ContextRef, X, Call->getArg(0))) {
+  E = Call->getArg(1);
+} else if (checkIfTwoExprsAreSame(ContextRef, X, Call->getArg(1))) {
+  E = Call->getArg(0);
+} else {
+  ErrorInfo.Error = ErrorTy::InvalidComparison;
+  ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Call->getExprLoc();
+  ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Call->getSourceRange();
+  return false;
+}

jhuber6 wrote:

I tried that but the switch statements required some kind of helper to abstract 
over the differing enum values. I could potentially just replace those with 
`if` and `else` that just did short circuiting or something I guess.

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


[clang] [OpenMP] Fix atomic compare handling with overloaded operators (PR #141142)

2025-05-28 Thread Joseph Huber via cfe-commits


@@ -991,3 +991,34 @@ int mixed() {
   // expected-note@+1 {{in instantiation of function template specialization 
'mixed' requested here}}
   return mixed();
 }
+
+#ifdef OMP51
+struct U {};
+struct U operator<(U, U);
+struct U operator>(U, U);
+struct U operator==(U, U);
+
+template  void templated() {
+  T cx, cv, ce, cd;
+#pragma omp atomic compare capture
+  if (cx == ce) {
+cx = cd;
+  } else {
+cv = cx;
+  }
+#pragma omp atomic compare capture
+  {
+cv = cx;
+if (ce > cx) {
+  cx = ce;
+}
+  }
+#pragma omp atomic compare capture
+  {
+cv = cx;
+if (cx < ce) {
+  cx = ce;
+}
+  }
+}
+#endif

jhuber6 wrote:

Codegen wasn't the issue here, if you manually instantiated it the code would 
work fine, the issue was just Sema incorrectly rejecting this when there was no 
type given.

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


  1   2   3   4   5   >