[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-04-03 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

@tstellar Any chance we can cherry-pick this to the 20.x branch?

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


[clang] 041e842 - [Clang][AMDGPU] Expose buffer load lds as a clang builtin (#132048)

2025-04-03 Thread via cfe-commits

Author: Juan Manuel Martinez Caamaño
Date: 2025-04-03T09:22:38+02:00
New Revision: 041e84261a502a28401813bf55aa778ee0bbcdeb

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

LOG: [Clang][AMDGPU] Expose buffer load lds as a clang builtin (#132048)

CK is using either inline assembly or inline LLVM-IR builtins to
generate buffer_load_dword lds instructions.

This patch exposes this instruction as a Clang builtin available on gfx9 and 
gfx10.

Related to SWDEV-519702 and SWDEV-518861

Added: 
clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-error.cl

clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaAMDGPU.cpp
clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl
llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index c6c0bf7d8388d..cbef637be213a 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -163,6 +163,8 @@ BUILTIN(__builtin_amdgcn_raw_buffer_load_b64, "V2UiQbiiIi", 
"n")
 BUILTIN(__builtin_amdgcn_raw_buffer_load_b96, "V3UiQbiiIi", "n")
 BUILTIN(__builtin_amdgcn_raw_buffer_load_b128, "V4UiQbiiIi", "n")
 
+TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_load_lds, "vQbv*3IUiiiIiIi", 
"t", "vmem-to-lds-load-insts")
+
 
//===--===//
 // Ballot builtins.
 
//===--===//

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3f9ba933582da..1993cd5accc22 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -13056,6 +13056,6 @@ def err_acc_decl_for_routine
 : Error<"expected function or lambda declaration for 'routine' construct">;
 
 // AMDGCN builtins diagnostics
-def err_amdgcn_global_load_lds_size_invalid_value : Error<"invalid size 
value">;
-def note_amdgcn_global_load_lds_size_valid_value : Note<"size must be 
%select{1, 2, or 4|1, 2, 4, 12 or 16}0">;
+def err_amdgcn_load_lds_size_invalid_value : Error<"invalid size value">;
+def note_amdgcn_load_lds_size_valid_value : Note<"size must be %select{1, 2, 
or 4|1, 2, 4, 12 or 16}0">;
 } // end of sema component.

diff  --git a/clang/lib/Sema/SemaAMDGPU.cpp b/clang/lib/Sema/SemaAMDGPU.cpp
index a4d075dfd0768..7fec099374152 100644
--- a/clang/lib/Sema/SemaAMDGPU.cpp
+++ b/clang/lib/Sema/SemaAMDGPU.cpp
@@ -35,6 +35,7 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned 
BuiltinID,
   Builtin::evaluateRequiredTargetFeatures("gfx950-insts", 
CallerFeatureMap);
 
   switch (BuiltinID) {
+  case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_load_lds:
   case AMDGPU::BI__builtin_amdgcn_global_load_lds: {
 constexpr const int SizeIdx = 2;
 llvm::APSInt Size;
@@ -54,11 +55,9 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned 
BuiltinID,
   [[fallthrough]];
 }
 default:
-  Diag(ArgExpr->getExprLoc(),
-   diag::err_amdgcn_global_load_lds_size_invalid_value)
+  Diag(ArgExpr->getExprLoc(), diag::err_amdgcn_load_lds_size_invalid_value)
   << ArgExpr->getSourceRange();
-  Diag(ArgExpr->getExprLoc(),
-   diag::note_amdgcn_global_load_lds_size_valid_value)
+  Diag(ArgExpr->getExprLoc(), diag::note_amdgcn_load_lds_size_valid_value)
   << HasGFX950Insts << ArgExpr->getSourceRange();
   return true;
 }

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl
index 3403b69e07e4b..5e3ed9027c17a 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl
@@ -170,3 +170,12 @@ v3u32 
test_amdgcn_raw_ptr_buffer_load_b96_non_const_soffset(__amdgpu_buffer_rsrc
 v4u32 
test_amdgcn_raw_ptr_buffer_load_b128_non_const_soffset(__amdgpu_buffer_rsrc_t 
rsrc, int offset, int soffset) {
   return __builtin_amdgcn_raw_buffer_load_b128(rsrc, /*offset=*/0, soffset, 
/*aux=*/0);
 }
+
+// CHECK-LABEL: @test_amdgcn_raw_ptr_buffer_load_lds(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.amdgcn.raw.ptr.buffer.load.lds(ptr 
addrspace(8) [[RSRC:%.*]], ptr addrspace(3) [[LDS:%.*]], i32 1, i32 
[[OFFSET:%.*]], i32 [[SOFFSET:%.*]], i32 2, i32 3)
+// CHECK-NEXT:ret void
+//
+void test_amdgcn_raw_ptr_buffer_load_lds(__amdgpu_buffer_rsrc_t rsrc, __local 
void * lds, int offset, int soffset

[clang] [flang] [llvm] [Clang][AMDGPU] Expose buffer load lds as a clang builtin (PR #132048)

2025-04-03 Thread Juan Manuel Martinez Caamaño via cfe-commits

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


[clang] [llvm] [ARM][Clang] Make `+nosimd` functional for AArch32 Targets (PR #130623)

2025-04-03 Thread David Green via cfe-commits


@@ -0,0 +1,31 @@
+// Ensures that when targeting an ARM target with an Asm file, clang
+// collects the features from the FPU. This is critical in the
+// activation of NEON for supported targets. The Cortex-R52 will be
+// used and tested for VFP and NEON Support
+
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null | 
count 0
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null -### 
2> %t | FileCheck --check-prefix=CHECK-TARGET-FEATURES < %t %s

davemgreen wrote:

I think this might need to either pipe &2 into stdout, or `cat %t | FileCheck..`

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


[clang-tools-extra] [clang-tidy] Add check bugprone-misleading-setter-of-reference (PR #132242)

2025-04-03 Thread Balázs Kéri via cfe-commits

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

From e3064b600ea726ab7b3dea054e9f11e1ce028297 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Wed, 19 Mar 2025 16:09:04 +0100
Subject: [PATCH 1/2] [clang-tidy] Add check
 bugprone-misleading-setter-of-reference

---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  1 +
 .../MisleadingSetterOfReferenceCheck.cpp  | 58 +++
 .../MisleadingSetterOfReferenceCheck.h| 37 
 .../misleading-setter-of-reference.rst| 42 ++
 .../misleading-setter-of-reference.cpp| 50 
 6 files changed, 191 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/misleading-setter-of-reference.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/misleading-setter-of-reference.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index b780a85bdf3fe..64f4a524daf0d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -41,6 +41,7 @@
 #include "LambdaFunctionNameCheck.h"
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
+#include "MisleadingSetterOfReferenceCheck.h"
 #include "MisplacedOperatorInStrlenInAllocCheck.h"
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
@@ -170,6 +171,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-macro-parentheses");
 CheckFactories.registerCheck(
 "bugprone-macro-repeated-side-effects");
+CheckFactories.registerCheck(
+"bugprone-misleading-setter-of-reference");
 CheckFactories.registerCheck(
 "bugprone-misplaced-operator-in-strlen-in-alloc");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index e310ea9c94543..d862794cde323 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -42,6 +42,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   LambdaFunctionNameCheck.cpp
   MacroParenthesesCheck.cpp
   MacroRepeatedSideEffectsCheck.cpp
+  MisleadingSetterOfReferenceCheck.cpp
   MisplacedOperatorInStrlenInAllocCheck.cpp
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
new file mode 100644
index 0..043d15e7fead2
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
@@ -0,0 +1,58 @@
+//===--- MisleadingSetterOfReferenceCheck.cpp - 
clang-tidy-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MisleadingSetterOfReferenceCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void MisleadingSetterOfReferenceCheck::registerMatchers(MatchFinder *Finder) {
+  auto RefField =
+  fieldDecl(unless(isPublic()),
+hasType(referenceType(pointee(equalsBoundNode("type")
+  .bind("member");
+  auto AssignLHS =
+  memberExpr(hasObjectExpression(cxxThisExpr()), member(RefField));
+  auto DerefOperand = expr(ignoringParenImpCasts(
+  declRefExpr(to(parmVarDecl(equalsBoundNode("parm"));
+  auto AssignRHS = expr(ignoringParenImpCasts(
+  unaryOperator(hasOperatorName("*"), hasUnaryOperand(DerefOperand;
+
+  auto BinaryOpAssign = binaryOperator(hasOperatorName("="), hasLHS(AssignLHS),
+   hasRHS(AssignRHS));
+  auto CXXOperatorCallAssign = cxxOperatorCallExpr(
+  hasOverloadedOperatorName("="), hasLHS(AssignLHS), hasRHS(AssignRHS));
+
+  auto SetBody =
+  compoundStmt(statementCountIs(1),
+   anyOf(has(BinaryOpAssign), has(CXXOperatorCallAssign)));
+  auto BadSetFunction =
+  cxxMethodDecl(parameterCountIs(1), isPublic(),
+hasAnyParameter(parmVarDecl(hasType(pointerType(pointee(
+qualType().bind("type")
+

[libclc] [libclc] Move fmin & fmax to CLC library (PR #134218)

2025-04-03 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/134218

This is an alternative to #128506 which doesn't attempt to change the codegen 
for fmin and fmax on their way to the CLC library.

The amdgcn and r600 custom definitions of fmin/fmax are now converted to custom 
definitions of __clc_fmin and __clc_fmax.

The only codegen change is that non-standard vector/scalar overloads of 
fmin/fmax have been removed. We were currently (accidentally, presumably) 
providing overloads with mixed elment types such as fmin(double2, float), 
fmax(half4, double), etc. The only vector/scalar overloads in the OpenCL spec 
are those with scalars of the same element type as the vector in the first 
argument.

>From 583261a0d1fc57ddb8ae964cbaf4f044c39d9bf2 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Thu, 3 Apr 2025 09:29:28 +0100
Subject: [PATCH] [libclc] Move fmin & fmax to CLC library

This is an alternative to #128506 which doesn't attempt to change the
codegen for fmin and fmax on their way to the CLC library.

The amdgcn and r600 custom definitions of fmin/fmax are now converted to
custom definitions of __clc_fmin and __clc_fmax.

The only codegen change is that non-standard vector/scalar overloads of
fmin/fmax have been removed. We were currently (accidentally,
presumably) providing overloads with mixed elment types such as
fmin(double2, float), fmax(half4, double), etc. The only vector/scalar
overloads in the OpenCL spec are those with scalars of the same element
type as the vector in the first argument.
---
 libclc/amdgcn/lib/SOURCES |  2 -
 libclc/amdgcn/lib/math/fmax.cl| 53 ---
 libclc/amdgcn/lib/math/fmin.cl| 53 ---
 libclc/clc/include/clc/math/clc_fmax.h| 20 +++
 libclc/clc/include/clc/math/clc_fmin.h| 20 +++
 .../binary_decl_with_scalar_second_arg.inc| 15 ++
 .../binary_def_with_scalar_second_arg.inc | 25 +
 libclc/clc/lib/amdgcn/SOURCES |  2 +
 libclc/clc/lib/amdgcn/math/clc_fmax.cl| 49 +
 libclc/clc/lib/amdgcn/math/clc_fmin.cl| 50 +
 libclc/clc/lib/generic/SOURCES|  4 +-
 libclc/clc/lib/generic/math/clc_fmax.cl   | 36 +
 libclc/clc/lib/generic/math/clc_fmin.cl   | 36 +
 libclc/clc/lib/r600/SOURCES   |  2 +
 libclc/clc/lib/r600/math/clc_fmax.cl  | 32 +++
 libclc/clc/lib/r600/math/clc_fmin.cl  | 33 
 libclc/generic/lib/math/fmax.cl   | 31 ++-
 libclc/generic/lib/math/fmin.cl   | 30 ++-
 libclc/r600/lib/SOURCES   |  2 -
 libclc/r600/lib/math/fmax.cl  | 36 -
 libclc/r600/lib/math/fmin.cl  | 37 -
 21 files changed, 329 insertions(+), 239 deletions(-)
 delete mode 100644 libclc/amdgcn/lib/math/fmax.cl
 delete mode 100644 libclc/amdgcn/lib/math/fmin.cl
 create mode 100644 libclc/clc/include/clc/math/clc_fmax.h
 create mode 100644 libclc/clc/include/clc/math/clc_fmin.h
 create mode 100644 
libclc/clc/include/clc/shared/binary_decl_with_scalar_second_arg.inc
 create mode 100644 
libclc/clc/include/clc/shared/binary_def_with_scalar_second_arg.inc
 create mode 100644 libclc/clc/lib/amdgcn/math/clc_fmax.cl
 create mode 100644 libclc/clc/lib/amdgcn/math/clc_fmin.cl
 create mode 100644 libclc/clc/lib/generic/math/clc_fmax.cl
 create mode 100644 libclc/clc/lib/generic/math/clc_fmin.cl
 create mode 100644 libclc/clc/lib/r600/math/clc_fmax.cl
 create mode 100644 libclc/clc/lib/r600/math/clc_fmin.cl
 delete mode 100644 libclc/r600/lib/math/fmax.cl
 delete mode 100644 libclc/r600/lib/math/fmin.cl

diff --git a/libclc/amdgcn/lib/SOURCES b/libclc/amdgcn/lib/SOURCES
index 6c6e77db0d84b..213f62cc73a74 100644
--- a/libclc/amdgcn/lib/SOURCES
+++ b/libclc/amdgcn/lib/SOURCES
@@ -1,6 +1,4 @@
 cl_khr_int64_extended_atomics/minmax_helpers.ll
-math/fmax.cl
-math/fmin.cl
 mem_fence/fence.cl
 synchronization/barrier.cl
 workitem/get_global_offset.cl
diff --git a/libclc/amdgcn/lib/math/fmax.cl b/libclc/amdgcn/lib/math/fmax.cl
deleted file mode 100644
index 8d3bf0495390f..0
--- a/libclc/amdgcn/lib/math/fmax.cl
+++ /dev/null
@@ -1,53 +0,0 @@
-//===--===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include 
-#include 
-
-_CLC_DEF _CLC_OVERLOAD float fmax(float x, float y)
-{
-   /* fcanonicalize removes sNaNs and flushes denormals if not enabled.
-* Otherwise fmax instruction flushes the values for comparison,
-* but outputs original denormal */
-   x = __builtin_can

[clang] [CodeGen] Use pimpl idiom for CVTables (NFC) (PR #134217)

2025-04-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Nikita Popov (nikic)


Changes

Avoid pulling in the CVTables.h header in CodeGenModules.h by putting the 
member behind a unique_ptr.

This had less impact than I was hoping, with only a 0.15% reduction in build 
time for clang. Apparently the expensive parts of CGVTables.h still get 
included via other pathways.

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


24 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCXX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCXXABI.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCXXABI.h (+1) 
- (modified) clang/lib/CodeGen/CGCall.cpp (+1) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGNonTrivialStruct.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1) 
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+1) 
- (modified) clang/lib/CodeGen/CGVTT.cpp (+2-1) 
- (modified) clang/lib/CodeGen/CGVTables.cpp (+15-2) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+1) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+4-2) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+10-14) 
- (modified) clang/lib/CodeGen/SwiftCallingConv.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/ARM.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/LoongArch.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/Mips.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/RISCV.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/X86.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 310addebd50e9..0ab0bb860bfa2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -25,6 +25,7 @@
 #include "PatternInit.h"
 #include "TargetInfo.h"
 #include "clang/AST/OSLog.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/Basic/TargetInfo.h"
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 6f47e24eed5b3..668812b498e1c 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -13,6 +13,7 @@
 // We might split this into multiple files if it gets too unwieldy
 
 #include "CGCXXABI.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 9f77fbec21380..7e21d5a72616e 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/RecordLayout.h"
 
 using namespace clang;
 using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 148a7ba6df7e6..ed4c9fdf8540a 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -32,6 +32,7 @@ class CXXDestructorDecl;
 class CXXMethodDecl;
 class CXXRecordDecl;
 class MangleContext;
+struct ReturnAdjustment;
 
 namespace CodeGen {
 class CGCallee;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b202255c3a15b..0b2947256af0f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c683dbb0af825..0d6c50d9cb00f 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -15,6 +15,7 @@
 #include "CGCXXABI.h"
 #include "CGDebugInfo.h"
 #include "CGRecordLayout.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "TargetInfo.h"
 #include "clang/AST/Attr.h"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d659243d38d5f..abdb0827ff5c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -15,6 +15,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGRecordLayout.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3d3a111f0514a..a29c3014740d6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -28,6 +28,7 @@
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/NSAPI.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/

[clang] [CodeGen] Use pimpl idiom for CVTables (NFC) (PR #134217)

2025-04-03 Thread Nikita Popov via cfe-commits

https://github.com/nikic created 
https://github.com/llvm/llvm-project/pull/134217

Avoid pulling in the CVTables.h header in CodeGenModules.h by putting the 
member behind a unique_ptr.

This had less impact than I was hoping, with only a 0.15% reduction in build 
time for clang. Apparently the expensive parts of CGVTables.h still get 
included via other pathways.

>From 3f5afa939324400fe1c02307d5129dd15737d820 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Thu, 3 Apr 2025 09:46:46 +0200
Subject: [PATCH] [CodeGen] Use pimpl idiom for CVTables (NFC)

Avoid pulling in the CVTables.h header in CodeGenModules.h by
putting the member behind a unique_ptr.

This had less impact than I was hoping, with only a 0.15% reduction
in build time for clang. Apparently the expensive parts of CGVTables.h
still get included via other pathways.
---
 clang/lib/CodeGen/CGBuiltin.cpp  |  1 +
 clang/lib/CodeGen/CGCXX.cpp  |  1 +
 clang/lib/CodeGen/CGCXXABI.cpp   |  1 +
 clang/lib/CodeGen/CGCXXABI.h |  1 +
 clang/lib/CodeGen/CGCall.cpp |  1 +
 clang/lib/CodeGen/CGClass.cpp|  1 +
 clang/lib/CodeGen/CGDebugInfo.cpp|  1 +
 clang/lib/CodeGen/CGExpr.cpp |  1 +
 clang/lib/CodeGen/CGExprAgg.cpp  |  1 +
 clang/lib/CodeGen/CGExprCXX.cpp  |  1 +
 clang/lib/CodeGen/CGNonTrivialStruct.cpp |  1 +
 clang/lib/CodeGen/CGOpenMPRuntime.cpp|  1 +
 clang/lib/CodeGen/CGStmtOpenMP.cpp   |  1 +
 clang/lib/CodeGen/CGVTT.cpp  |  3 ++-
 clang/lib/CodeGen/CGVTables.cpp  | 17 +++--
 clang/lib/CodeGen/CodeGenFunction.h  |  1 +
 clang/lib/CodeGen/CodeGenModule.cpp  |  6 --
 clang/lib/CodeGen/CodeGenModule.h| 24 ++--
 clang/lib/CodeGen/SwiftCallingConv.cpp   |  1 +
 clang/lib/CodeGen/Targets/ARM.cpp|  1 +
 clang/lib/CodeGen/Targets/LoongArch.cpp  |  1 +
 clang/lib/CodeGen/Targets/Mips.cpp   |  1 +
 clang/lib/CodeGen/Targets/RISCV.cpp  |  1 +
 clang/lib/CodeGen/Targets/X86.cpp|  1 +
 24 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 310addebd50e9..0ab0bb860bfa2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -25,6 +25,7 @@
 #include "PatternInit.h"
 #include "TargetInfo.h"
 #include "clang/AST/OSLog.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/Basic/TargetInfo.h"
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 6f47e24eed5b3..668812b498e1c 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -13,6 +13,7 @@
 // We might split this into multiple files if it gets too unwieldy
 
 #include "CGCXXABI.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 9f77fbec21380..7e21d5a72616e 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/RecordLayout.h"
 
 using namespace clang;
 using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 148a7ba6df7e6..ed4c9fdf8540a 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -32,6 +32,7 @@ class CXXDestructorDecl;
 class CXXMethodDecl;
 class CXXRecordDecl;
 class MangleContext;
+struct ReturnAdjustment;
 
 namespace CodeGen {
 class CGCallee;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b202255c3a15b..0b2947256af0f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c683dbb0af825..0d6c50d9cb00f 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -15,6 +15,7 @@
 #include "CGCXXABI.h"
 #include "CGDebugInfo.h"
 #include "CGRecordLayout.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "TargetInfo.h"
 #include "clang/AST/Attr.h"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d659243d38d5f..abdb0827ff5c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -15,6 +15,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGRecordLayout.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
diff --git a/clang/l

[clang] [CodeGen] Use pimpl idiom for CVTables (NFC) (PR #134217)

2025-04-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikita Popov (nikic)


Changes

Avoid pulling in the CVTables.h header in CodeGenModules.h by putting the 
member behind a unique_ptr.

This had less impact than I was hoping, with only a 0.15% reduction in build 
time for clang. Apparently the expensive parts of CGVTables.h still get 
included via other pathways.

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


24 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCXX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCXXABI.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCXXABI.h (+1) 
- (modified) clang/lib/CodeGen/CGCall.cpp (+1) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGNonTrivialStruct.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1) 
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+1) 
- (modified) clang/lib/CodeGen/CGVTT.cpp (+2-1) 
- (modified) clang/lib/CodeGen/CGVTables.cpp (+15-2) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+1) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+4-2) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+10-14) 
- (modified) clang/lib/CodeGen/SwiftCallingConv.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/ARM.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/LoongArch.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/Mips.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/RISCV.cpp (+1) 
- (modified) clang/lib/CodeGen/Targets/X86.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 310addebd50e9..0ab0bb860bfa2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -25,6 +25,7 @@
 #include "PatternInit.h"
 #include "TargetInfo.h"
 #include "clang/AST/OSLog.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/Basic/TargetInfo.h"
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 6f47e24eed5b3..668812b498e1c 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -13,6 +13,7 @@
 // We might split this into multiple files if it gets too unwieldy
 
 #include "CGCXXABI.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 9f77fbec21380..7e21d5a72616e 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/RecordLayout.h"
 
 using namespace clang;
 using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 148a7ba6df7e6..ed4c9fdf8540a 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -32,6 +32,7 @@ class CXXDestructorDecl;
 class CXXMethodDecl;
 class CXXRecordDecl;
 class MangleContext;
+struct ReturnAdjustment;
 
 namespace CodeGen {
 class CGCallee;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b202255c3a15b..0b2947256af0f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c683dbb0af825..0d6c50d9cb00f 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -15,6 +15,7 @@
 #include "CGCXXABI.h"
 #include "CGDebugInfo.h"
 #include "CGRecordLayout.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "TargetInfo.h"
 #include "clang/AST/Attr.h"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d659243d38d5f..abdb0827ff5c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -15,6 +15,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGRecordLayout.h"
+#include "CGVTables.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3d3a111f0514a..a29c3014740d6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -28,6 +28,7 @@
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/NSAPI.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/

[clang] [CIR] Upstream support for break and continue statements (PR #134181)

2025-04-03 Thread Henrich Lauko via cfe-commits

https://github.com/xlauko commented:

LGTM

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


[clang] [CIR] Upstream support for break and continue statements (PR #134181)

2025-04-03 Thread Henrich Lauko via cfe-commits


@@ -569,6 +569,35 @@ def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator,
   ];
 }
 
+//===--===//
+// BreakOp
+//===--===//
+
+def BreakOp : CIR_Op<"break", [Terminator]> {
+  let summary = "C/C++ `break` statement equivalent";
+  let description = [{
+The `cir.break` operation is used to cease the control flow to the parent
+operation, exiting its region's control flow. It is only allowed if it is
+within a breakable operation (loops and `switch`).
+  }];
+  let assemblyFormat = "attr-dict";
+  let hasVerifier = 1;
+}
+
+//===--===//
+// ContinueOp
+//===--===//
+
+def ContinueOp : CIR_Op<"continue", [Terminator]> {
+  let summary = "C/C++ `continue` statement equivalent";
+  let description = [{
+The `cir.continue` operation is used to continue execution to the next
+iteration of a loop. It is only allowed within `cir.loop` regions.

xlauko wrote:

nit: There is technically nothing like `cir.loop`. More precise would be to 
mention `LoopOpInterface` directly here?

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


[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)

2025-04-03 Thread Victor Campos via cfe-commits

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

LGTM. Please wait for @smithp35 's approval too.

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


[libclc] [libclc]: clspv: add a dummy implememtation for mul_hi (PR #134094)

2025-04-03 Thread Fraser Cormack via cfe-commits

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


[clang] [modules] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)

2025-04-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248:
 warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does 
not support testing the just-built runtime libraries when the test compiler is 
configured to use different runtime libraries. Either modify this test suite to 
support this test configuration, or set 
COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries 
included in the compiler instead.
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259:
 note: Testing using libraries in 
"/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/i386-unknown-linux-gnu"
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:237:
 warning: Compiler lib dir != compiler-rt lib dir
Compiler libdir: 
"/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/i386-unknown-linux-gnu"
compiler-rt libdir:  
"/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248:
 warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does 
not support testing the just-built runtime libraries when the test compiler is 
configured to use different runtime libraries. Either modify this test suite to 
support this test configuration, or set 
COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries 
included in the compiler instead.
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259:
 note: Testing using libraries in 
"/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 4894 of 10694 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60..
FAIL: ThreadSanitizer-x86_64 :: cxa_guard_acquire.cpp (3357 of 4894)
 TEST 'ThreadSanitizer-x86_64 :: cxa_guard_acquire.cpp' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  
--driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ 
-std=c++11 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ 
-nostdinc++ 
-I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1
 -O1 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/cxa_guard_acquire.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/cxa_guard_acquire.cpp.tmp
 &&  
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/cxa_guard_acquire.cpp.tmp
 2>&1 | FileCheck 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/cxa_guard_acquire.cpp
 # RUN: at line 1
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang 
--driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ 
-std=c++11 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ 
-nostdinc++ 
-I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1
 -O1 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/cxa_guard_acquire.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/cxa_guard_acquire.cpp.tmp
+ FileCheck 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/cxa_guard_acquire.cpp
+ 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/cxa_guard_acquire.cpp.tmp
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/cxa_guard_acquire.cpp:71:17:
 error: CHECK-NEXT: is not on the line after the previous m

[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)

2025-04-03 Thread Simi Pallipurath via cfe-commits

https://github.com/simpal01 updated 
https://github.com/llvm/llvm-project/pull/134099

>From 7f6302053575732f633c69bbf55f2624da1e8bf4 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath 
Date: Wed, 2 Apr 2025 12:35:16 +0100
Subject: [PATCH 1/3] Refine multilib selection to handle alignment based on
 architecture features.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Update the multilib selection logic to bypass the
alignment option based on each architecture’s
feature set, rather than relying solely on command-line
options.

Previously, alignment option was bypassed only when
-mno-unaligned-access was explicitly specified on the
commandline. This change makes the selection more robust
and architecture aware.
---
 clang/lib/Driver/ToolChain.cpp| 24 +--
 .../test/Driver/print-multi-selection-flags.c |  6 +
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 8a922b283daf5..476026f82b32b 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -239,12 +239,12 @@ static void getAArch64MultilibFlags(const Driver &D,
 Result.push_back(BranchProtectionArg->getAsString(Args));
   }
 
-  if (Arg *AlignArg = Args.getLastArg(
-  options::OPT_mstrict_align, options::OPT_mno_strict_align,
-  options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) {
-if (AlignArg->getOption().matches(options::OPT_mstrict_align) ||
-AlignArg->getOption().matches(options::OPT_mno_unaligned_access))
-  Result.push_back(AlignArg->getAsString(Args));
+  if (FeatureSet.contains("+strict-align")) {
+Result.push_back("-mno-unaligned-access");
+Result.push_back("-mstrict-align");
+  } else {
+Result.push_back("-munaligned-access");
+Result.push_back("-mno-strict-align");
   }
 
   if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian,
@@ -313,12 +313,12 @@ static void getARMMultilibFlags(const Driver &D,
 Result.push_back(BranchProtectionArg->getAsString(Args));
   }
 
-  if (Arg *AlignArg = Args.getLastArg(
-  options::OPT_mstrict_align, options::OPT_mno_strict_align,
-  options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) {
-if (AlignArg->getOption().matches(options::OPT_mstrict_align) ||
-AlignArg->getOption().matches(options::OPT_mno_unaligned_access))
-  Result.push_back(AlignArg->getAsString(Args));
+  if (FeatureSet.contains("+strict-align")) {
+Result.push_back("-mno-unaligned-access");
+Result.push_back("-mstrict-align");
+  } else {
+Result.push_back("-munaligned-access");
+Result.push_back("-mno-strict-align");
   }
 
   if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian,
diff --git a/clang/test/Driver/print-multi-selection-flags.c 
b/clang/test/Driver/print-multi-selection-flags.c
index 5a35ae374f011..b21c2d11c1009 100644
--- a/clang/test/Driver/print-multi-selection-flags.c
+++ b/clang/test/Driver/print-multi-selection-flags.c
@@ -69,9 +69,15 @@
 // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard
 
 // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | 
FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=arm-none-eabi | FileCheck 
--check-prefix=CHECK-NO-UNALIGNED-ACCESS %s
 // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=aarch64-none-elf -mno-unaligned-access 
| FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s
 // CHECK-NO-UNALIGNED-ACCESS: -mno-unaligned-access
 
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=arm-none-eabi -munaligned-access | 
FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=aarch64-none-elf | FileCheck 
--check-prefix=CHECK-UNALIGNED-ACCESS %s
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=aarch64-none-elf -munaligned-access | 
FileCheck --check-prefix=CHECK-UNALIGNED-ACCESS %s
+// CHECK-UNALIGNED-ACCESS: -munaligned-access
+
 // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=arm-none-eabi -mbig-endian | FileCheck 
--check-prefix=CHECK-BIG-ENDIAN %s
 // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml 
-print-multi-flags-experimental --target=aarch64-none-elf -mbig-endian | 
FileCheck --check-prefix=CHECK-BIG-ENDIAN %s
 // CHECK-BIG-ENDIAN: -mbig-endian

>From 0242cea7fc54c90c5fbb8a16628a14167d4377cc Mon Sep 17 00:00:00 2001
From: Simi Pallipurath 
Date: Wed, 2 Apr 2025 17:25:06 +0100
Subject: [PATCH 2/3] fixup! Test that test -mstrict-ali

[clang] [clang-format] Fix a bug in annotating braces (PR #134039)

2025-04-03 Thread Owen Pan via cfe-commits

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


[clang] [Clang] Fix dependent local class instantiation bugs (PR #134038)

2025-04-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

This patch fixes two long-standing bugs that prevent Clang from instantiating 
local class members inside a dependent context. These bugs were introduced in 
commits 21eb1af469c3 and 919df9d75a.

21eb1af469c3 introduced a concept called eligible methods such that it did an 
attempt to skip past ineligible method instantiation when instantiating class 
members. Unfortunately, this broke the instantiation chain for local classes - 
getTemplateInstantiationPattern() would fail to find the correct definition 
pattern if the class was defined within a partially transformed dependent 
context.

919df9d75a introduced a separate issue by incorrectly copying the 
DeclarationNameInfo during function definition instantiation from the template 
pattern, even though that DNI might contain a transformed TypeSourceInfo. Since 
that TSI was already updated when the declaration was instantiated, this led to 
inconsistencies. As a result, the final instantiated function could lose track 
of the transformed declarations, hence we crash: 
https://compiler-explorer.com/z/vjvoG76Tf.

This PR corrects them by

1. Removing the bypass logic for method instantiation. The eligible flag is 
independent of instantiation and can be updated properly afterward, so skipping 
instantiation is unnecessary.

2. Carefully handling TypeSourceInfo by creating a new instance that preserves 
the pattern's source location while using the already transformed type.

Fixes https://github.com/llvm/llvm-project/issues/59734
Fixes https://github.com/llvm/llvm-project/issues/132208


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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (-3) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+56-1) 
- (modified) clang/test/SemaTemplate/instantiate-local-class.cpp (+73-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e409f206f6eae..6107fd7667306 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -348,6 +348,7 @@ Bug Fixes to C++ Support
   by template argument deduction.
 - Clang is now better at instantiating the function definition after its use 
inside
   of a constexpr lambda. (#GH125747)
+- Fixed a local class member function instantiation bug inside dependent 
lambdas. (#GH59734), (#GH132208)
 - Clang no longer crashes when trying to unify the types of arrays with
   certain differences in qualifiers (this could happen during template argument
   deduction or when building a ternary operator). (#GH97005)
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 00dcadb41e8fb..5b502b494e410 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -4264,9 +4264,6 @@ Sema::InstantiateClassMembers(SourceLocation 
PointOfInstantiation,
   if (FunctionDecl *Pattern =
   Function->getInstantiatedFromMemberFunction()) {
 
-if (Function->isIneligibleOrNotSelected())
-  continue;
-
 if (Function->getTrailingRequiresClause()) {
   ConstraintSatisfaction Satisfaction;
   if (CheckFunctionConstraints(Function, Satisfaction) ||
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 8aaaea0bcdd66..a8d23fb2be6d5 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5590,7 +5590,62 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
   Function->setLocation(PatternDecl->getLocation());
   Function->setInnerLocStart(PatternDecl->getInnerLocStart());
   Function->setRangeEnd(PatternDecl->getEndLoc());
-  Function->setDeclarationNameLoc(PatternDecl->getNameInfo().getInfo());
+  // Let the instantiation use the Pattern's DeclarationNameLoc, due to the
+  // following awkwardness:
+  //   1. There are out-of-tree users of getNameInfo().getSourceRange(), who
+  //   expect the source range of the instantiated declaration to be set to
+  //   point the definition.
+  //
+  //   2. That getNameInfo().getSourceRange() might return the TypeLocInfo's
+  //   location it tracked.
+  //
+  //   3. Function might come from an (implicit) declaration, while the pattern
+  //   comes from a definition. In these cases, we need the PatternDecl's 
source
+  //   location.
+  //
+  // To that end, we need to more or less tweak the DeclarationNameLoc. 
However,
+  // we can't blindly copy the DeclarationNameLoc from the PatternDecl to the
+  // function, since it contains associated TypeLocs that should have already
+  // been transformed. So, we rebuild the TypeLoc for that purpose. 
Technically,
+  // we should create a new function declaration and assign everything we n

[clang] [Clang][ARM]Ensure both -mno-unaligned-access and -munaligned-access are passed to multilib selection logic (PR #134099)

2025-04-03 Thread Simi Pallipurath via cfe-commits


@@ -239,12 +239,12 @@ static void getAArch64MultilibFlags(const Driver &D,
 Result.push_back(BranchProtectionArg->getAsString(Args));
   }
 
-  if (Arg *AlignArg = Args.getLastArg(
-  options::OPT_mstrict_align, options::OPT_mno_strict_align,
-  options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) {
-if (AlignArg->getOption().matches(options::OPT_mstrict_align) ||
-AlignArg->getOption().matches(options::OPT_mno_unaligned_access))
-  Result.push_back(AlignArg->getAsString(Args));
+  if (FeatureSet.contains("+strict-align")) {

simpal01 wrote:

Canonicalized unaligned access option to 
-mno-unaligned-access/-munaligned-access. multilib.yaml also uses the same 
options.

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


[clang] [Clang] Fix dependent local class instantiation bugs (PR #134038)

2025-04-03 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][SYCL] Add AOT compilation support for Intel GPUs in clang-sycl-linker (PR #133194)

2025-04-03 Thread Justin Cai via cfe-commits


@@ -0,0 +1,131 @@
+//===--- SYCL.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_SYCL_H
+#define LLVM_CLANG_BASIC_SYCL_H
+
+#include "clang/Basic/Cuda.h"
+
+namespace llvm {
+class StringRef;
+template  class SmallString;
+} // namespace llvm
+
+namespace clang {
+// List of architectures (Intel CPUs and Intel GPUs)
+// that support SYCL offloading.
+enum class SYCLSupportedIntelArchs {

jzc wrote:

I added the Intel arches to the OffloadArch enum. Although, perhaps the file it 
is defined in (Cuda.h) should be named to something more appropriate? If so, I 
can change that in a follow up PR to avoid unrelated changes.

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


[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-04-03 Thread Carlos Galvez via cfe-commits

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


[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-04-03 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

/cherry-pick 6333fa5160fbde4bd2cf6afe8856695c13ab621f

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


[clang] e1aaee7 - [modules] Handle friend function that was a definition but became only a declaration during AST deserialization (#132214)

2025-04-03 Thread via cfe-commits

Author: Dmitry Polukhin
Date: 2025-04-03T08:27:13+01:00
New Revision: e1aaee7ea218f1d89646fa1f43bb4c94c27808b5

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

LOG: [modules] Handle friend function that was a definition but became only a 
declaration during AST deserialization (#132214)

Fix for regression #130917, changes in #111992 were too broad. This change 
reduces scope of previous fix. Added 
`ExternalASTSource::wasThisDeclarationADefinition` to detect cases when 
FunctionDecl lost body due to declaration merges.

Added: 
clang/test/SemaCXX/friend-default-parameters-modules.cpp
clang/test/SemaCXX/friend-default-parameters.cpp

Modified: 
clang/include/clang/AST/ExternalASTSource.h
clang/include/clang/Sema/MultiplexExternalSemaSource.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/ExternalASTSource.cpp
clang/lib/Sema/MultiplexExternalSemaSource.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExternalASTSource.h 
b/clang/include/clang/AST/ExternalASTSource.h
index 42aed56d42e07..f45e3af7602c1 100644
--- a/clang/include/clang/AST/ExternalASTSource.h
+++ b/clang/include/clang/AST/ExternalASTSource.h
@@ -191,6 +191,10 @@ class ExternalASTSource : public 
RefCountedBase {
 
   virtual ExtKind hasExternalDefinitions(const Decl *D);
 
+  /// True if this function declaration was a definition before in its own
+  /// module.
+  virtual bool wasThisDeclarationADefinition(const FunctionDecl *FD);
+
   /// Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.
   ///

diff  --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h 
b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index 921bebe3a44af..391c2177d75ec 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -92,6 +92,8 @@ class MultiplexExternalSemaSource : public ExternalSemaSource 
{
 
   ExtKind hasExternalDefinitions(const Decl *D) override;
 
+  bool wasThisDeclarationADefinition(const FunctionDecl *FD) override;
+
   /// Find all declarations with the given name in the
   /// given context.
   bool FindExternalVisibleDeclsByName(const DeclContext *DC,

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 2779b3d1cf2ea..58fcc06c3696d 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1392,6 +1392,10 @@ class ASTReader
 
   llvm::DenseMap DefinitionSource;
 
+  /// Friend functions that were defined but might have had their bodies
+  /// removed.
+  llvm::DenseSet ThisDeclarationWasADefinitionSet;
+
   bool shouldDisableValidationForFile(const serialization::ModuleFile &M) 
const;
 
   /// Reads a statement from the specified cursor.
@@ -2374,6 +2378,8 @@ class ASTReader
 
   ExtKind hasExternalDefinitions(const Decl *D) override;
 
+  bool wasThisDeclarationADefinition(const FunctionDecl *FD) override;
+
   /// Retrieve a selector from the given module with its local ID
   /// number.
   Selector getLocalSelector(ModuleFile &M, unsigned LocalID);

diff  --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e2451f294741d..3e865cb7679b5 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -38,6 +38,10 @@ ExternalASTSource::hasExternalDefinitions(const Decl *D) {
   return EK_ReplyHazy;
 }
 
+bool ExternalASTSource::wasThisDeclarationADefinition(const FunctionDecl *FD) {
+  return false;
+}
+
 void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
 unsigned Length,
 SmallVectorImpl &Decls) {}

diff  --git a/clang/lib/Sema/MultiplexExternalSemaSource.cpp 
b/clang/lib/Sema/MultiplexExternalSemaSource.cpp
index 6d945300c386c..fbfb242598c24 100644
--- a/clang/lib/Sema/MultiplexExternalSemaSource.cpp
+++ b/clang/lib/Sema/MultiplexExternalSemaSource.cpp
@@ -107,6 +107,14 @@ MultiplexExternalSemaSource::hasExternalDefinitions(const 
Decl *D) {
   return EK_ReplyHazy;
 }
 
+bool MultiplexExternalSemaSource::wasThisDeclarationADefinition(
+const FunctionDecl *FD) {
+  for (const auto &S : Sources)
+if (S->wasThisDeclarationADefinition(FD))
+  return true;
+  return false;
+}
+
 bool MultiplexExternalSemaSource::FindExternalVisibleDeclsByName(
 const DeclContext *DC, DeclarationName Name,
 const DeclContext *OriginalDC) {

diff  --git a/clang/lib/Sema/SemaTemplateInstant

[clang] [Clang][SYCL] Add AOT compilation support for Intel GPUs in clang-sycl-linker (PR #133194)

2025-04-03 Thread Justin Cai via cfe-commits


@@ -0,0 +1,131 @@
+//===--- SYCL.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_SYCL_H
+#define LLVM_CLANG_BASIC_SYCL_H
+
+#include "clang/Basic/Cuda.h"
+
+namespace llvm {
+class StringRef;
+template  class SmallString;
+} // namespace llvm
+
+namespace clang {
+// List of architectures (Intel CPUs and Intel GPUs)
+// that support SYCL offloading.
+enum class SYCLSupportedIntelArchs {
+  // Intel CPUs
+  UNKNOWN,
+  SKYLAKEAVX512,
+  COREAVX2,
+  COREI7AVX,
+  COREI7,
+  WESTMERE,
+  SANDYBRIDGE,
+  IVYBRIDGE,
+  BROADWELL,
+  COFFEELAKE,
+  ALDERLAKE,
+  SKYLAKE,
+  SKX,
+  CASCADELAKE,
+  ICELAKECLIENT,
+  ICELAKESERVER,
+  SAPPHIRERAPIDS,
+  GRANITERAPIDS,
+  // Intel GPUs
+  BDW,
+  SKL,
+  KBL,
+  CFL,
+  APL,
+  BXT,
+  GLK,
+  WHL,
+  AML,
+  CML,
+  ICLLP,
+  ICL,
+  EHL,
+  JSL,
+  TGLLP,
+  TGL,
+  RKL,
+  ADL_S,
+  RPL_S,
+  ADL_P,
+  ADL_N,
+  DG1,
+  ACM_G10,
+  DG2_G10,
+  ACM_G11,
+  DG2_G11,
+  ACM_G12,
+  DG2_G12,
+  PVC,
+  PVC_VG,
+  MTL_U,
+  MTL_S,
+  ARL_U,
+  ARL_S,
+  MTL_H,
+  ARL_H,
+  BMG_G21,
+  LNL_M,
+};
+
+// Check if the given Arch value is a Generic AMD GPU.
+// Currently GFX*_GENERIC AMD GPUs do not support SYCL offloading.
+// This list is used to filter out GFX*_GENERIC AMD GPUs in
+// `IsSYCLSupportedAMDGPUArch`.
+static inline bool IsAMDGenericGPUArch(OffloadArch Arch) {

jzc wrote:

I am unsure myself. However, I actually included this code in this PR by 
accident, so I am removing this function for the time being.

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


[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)

2025-04-03 Thread Muhammad Bassiouni via cfe-commits

https://github.com/bassiounix created 
https://github.com/llvm/llvm-project/pull/134214

closes #133660.

I added the suffix support to this pr as the generated macros uses the `BF16` 
suffix.

The only line I found in GCC which we don't seem to support as a macro is 
```c
#define __BFLT16_IS_IEC_60559__ 0
```

we don't have `__*_IS_IEC_60559__` in our macro builder so I skipped it.

cc @AaronBallman  @lntue @jhuber6 

>From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Thu, 3 Apr 2025 10:08:59 +0200
Subject: [PATCH 1/2] add `bf16`/`BF16` suffix support

---
 clang/include/clang/Lex/LiteralSupport.h |  1 +
 clang/lib/Lex/LiteralSupport.cpp | 17 -
 clang/lib/Sema/SemaExpr.cpp  |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Lex/LiteralSupport.h 
b/clang/include/clang/Lex/LiteralSupport.h
index ea5f63bc20399..1907cfc365d97 100644
--- a/clang/include/clang/Lex/LiteralSupport.h
+++ b/clang/include/clang/Lex/LiteralSupport.h
@@ -77,6 +77,7 @@ class NumericLiteralParser {
   bool isFloat : 1; // 1.0f
   bool isImaginary : 1; // 1.0i
   bool isFloat16 : 1;   // 1.0f16
+  bool isBFloat16 : 1;  // 1.0bf16
   bool isFloat128 : 1;  // 1.0q
   bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr
   bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 20933cc8dee69..ab0d301a70fbd 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
   isFloat = false;
   isImaginary = false;
   isFloat16 = false;
+  isBFloat16 = false;
   isFloat128 = false;
   MicrosoftInteger = 0;
   isFract = false;
@@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
   bool isFPConstant = isFloatingLiteral();
   bool HasSize = false;
   bool DoubleUnderscore = false;
+  bool isBF16 = false;
 
   // Loop over all of the characters of the suffix.  If we see something bad,
   // we break out of the loop.
   for (; s != ThisTokEnd; ++s) {
 switch (*s) {
+case 'b':
+case 'B':
+  if (isBFloat16) break;
+  if (isBF16) break;
+  if (HasSize) break;
+
+  isBF16 = true;
+  continue;
 case 'R':
 case 'r':
   if (!LangOpts.FixedPoint)
@@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
(LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) &&
   s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
 s += 2; // success, eat up 2 characters.
-isFloat16 = true;
+if (isBF16) {
+  isBFloat16 = true;
+} else {
+  isFloat16 = true;
+}
 continue;
   }
 
@@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
 isSizeT = false;
 isFloat = false;
 isFloat16 = false;
+isBFloat16 = false;
 isHalf = false;
 isImaginary = false;
 isBitInt = false;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..b4210fc22ae52 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, 
Scope *UDLScope) {
   Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy;
 else if (Literal.isFloat16)
   Ty = Context.Float16Ty;
+else if (Literal.isBFloat16)
+  Ty = Context.BFloat16Ty;
 else if (Literal.isFloat128)
   Ty = Context.Float128Ty;
 else if (getLangOpts().HLSL)

>From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Thu, 3 Apr 2025 10:09:22 +0200
Subject: [PATCH 2/2] add `__bf16` macros

---
 clang/lib/Frontend/InitPreprocessor.cpp | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 0b54665501c76..9bca74a8b4bd6 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, 
Preprocessor &PP,
 template 
 static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal,
 T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal,
-T IEEEQuadVal) {
+T BFloatVal, T IEEEQuadVal) {
   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf())
 return IEEEHalfVal;
   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle())
@@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T 
IEEEHalfVal, T IEEESingleVal,
 return X87DoubleExtendedVal;
   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoub

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-04-03 Thread via cfe-commits

llvmbot wrote:

/pull-request llvm/llvm-project#134215

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


[clang] [OpenCL] Add cl_ext_image_unsigned_10x6_12x4_14x2 extension (PR #134216)

2025-04-03 Thread Sven van Haastregt via cfe-commits

svenvh wrote:

Extension specification: https://github.com/KhronosGroup/OpenCL-Docs/pull/1352

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


[clang] [OpenCL] Add cl_ext_image_unsigned_10x6_12x4_14x2 extension (PR #134216)

2025-04-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Sven van Haastregt (svenvh)


Changes

Add the defines for the `cl_ext_image_unsigned_10x6_12x4_14x2` extension.

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


2 Files Affected:

- (modified) clang/lib/Headers/opencl-c-base.h (+9) 
- (modified) clang/test/Headers/opencl-c-header.cl (+6) 


``diff
diff --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index b6bcf32c09c08..2b7f5043e09e4 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -47,6 +47,7 @@
 #define __opencl_c_ext_fp32_local_atomic_min_max 1
 #define __opencl_c_ext_image_raw10_raw12 1
 #define __opencl_c_ext_image_unorm_int_2_101010 1
+#define __opencl_c_ext_image_unsigned_10x6_12x4_14x2 1
 #define cl_khr_kernel_clock 1
 #define __opencl_c_kernel_clock_scope_device 1
 #define __opencl_c_kernel_clock_scope_work_group 1
@@ -490,6 +491,14 @@ typedef enum memory_order
 #ifdef __opencl_c_ext_image_unorm_int_2_101010
 #define CLK_UNORM_INT_2_101010_EXT 0x10E5
 #endif // __opencl_c_ext_image_unorm_int_2_101010
+#ifdef __opencl_c_ext_image_unsigned_10x6_12x4_14x2
+#define CLK_UNSIGNED_INT10X6_EXT 0x10E6
+#define CLK_UNSIGNED_INT12X4_EXT 0x10E7
+#define CLK_UNSIGNED_INT14X2_EXT 0x10E8
+#define CLK_UNORM_10X6_EXT 0x10E1
+#define CLK_UNORM_12X4_EXT 0x10E9
+#define CLK_UNORM_14X2_EXT 0x10EA
+#endif // __opencl_c_ext_image_unsigned_10x6_12x4_14x2
 
 // Channel order, numbering must be aligned with cl_channel_order in cl.h
 //
diff --git a/clang/test/Headers/opencl-c-header.cl 
b/clang/test/Headers/opencl-c-header.cl
index 7317ff0adaafb..17cbb67f26038 100644
--- a/clang/test/Headers/opencl-c-header.cl
+++ b/clang/test/Headers/opencl-c-header.cl
@@ -193,6 +193,9 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #if __opencl_c_ext_image_unorm_int_2_101010 != 1
 #error "Incorrectly defined __opencl_c_ext_image_unorm_int_2_101010"
 #endif
+#if __opencl_c_ext_image_unsigned_10x6_12x4_14x2 != 1
+#error "Incorrectly defined __opencl_c_ext_image_unsigned_10x6_12x4_14x2"
+#endif
 
 #else
 
@@ -283,6 +286,9 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #ifdef __opencl_c_ext_image_unorm_int_2_101010
 #error "Incorrect __opencl_c_ext_image_unorm_int_2_101010 define"
 #endif
+#ifdef __opencl_c_ext_image_unsigned_10x6_12x4_14x2
+#error "Incorrect __opencl_c_ext_image_unsigned_10x6_12x4_14x2 define"
+#endif
 
 #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 

``




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


[clang] [Clang] Fix dependent local class instantiation bugs (PR #134038)

2025-04-03 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

I talked to @erichkeane and updated the approach to make it feel less like a 
workaround and independent of lambda instantiation.

As noted, both cases worked prior to clang 15, which means they didn’t rely on 
deferred lambda body instantiation to compile correctly.

Regarding the lambda side of things - since @mizvekov is already working on a 
major ContextDecl refactoring in that area, I don’t think it's appropriate to 
initiate another large-scale change simultaneously. That would result in a lot 
of conflicts, as I can expect. It's also expected that much of the present 
issues will be alleviated once that gets landed and it's not too late for us to 
start working on the lambda deferral afterwards.

That said, this patch is aimed at fixing a regression and doesn't actually 
touch the lambda code itself (even though the bug involves lambdas), so it 
shouldn't become a burden that complicates future work on deferred lambda body 
instantiation. In fact, I think this should actually improve our test coverage 
overall.

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


[clang-tools-extra] 6333fa5 - [clang-tidy] Fix broken HeaderFilterRegex when read from config file (#133582)

2025-04-03 Thread via cfe-commits

Author: Carlos Galvez
Date: 2025-04-03T09:28:34+02:00
New Revision: 6333fa5160fbde4bd2cf6afe8856695c13ab621f

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

LOG: [clang-tidy] Fix broken HeaderFilterRegex when read from config file 
(#133582)

PR https://github.com/llvm/llvm-project/pull/91400 broke the usage of
HeaderFilterRegex via config file, because it is now created at a
different point in the execution and leads to a different value.

The result of that is that using HeaderFilterRegex only in the config
file does NOT work, in other words clang-tidy stops triggering warnings
on header files, thereby losing a lot of coverage.

This patch reverts the logic so that the header filter is created upon
calling the getHeaderFilter() function.

Additionally, this patch adds 2 unit tests to prevent regressions in the
future:

- One of them, "simple", tests the most basic use case with a single
top-level .clang-tidy file.

- The second one, "inheritance", demonstrates that the subfolder only
gets warnings from headers within it, and not from parent headers.

Fixes #118009
Fixes #121969
Fixes #133453

Co-authored-by: Carlos Gálvez 

Added: 

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/inheritance/.clang-tidy

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/inheritance/foo.cpp

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/inheritance/foo.h

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/inheritance/subfolder/.clang-tidy

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/inheritance/subfolder/bar.cpp

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/inheritance/subfolder/bar.h

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/simple/.clang-tidy

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/simple/foo.cpp

clang-tools-extra/test/clang-tidy/infrastructure/header-filter-from-config-file/simple/foo.h

Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 4c75b42270114..71e852545203e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -311,18 +311,7 @@ ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
 : Context(Ctx), ExternalDiagEngine(ExternalDiagEngine),
   RemoveIncompatibleErrors(RemoveIncompatibleErrors),
   GetFixesFromNotes(GetFixesFromNotes),
-  EnableNolintBlocks(EnableNolintBlocks) {
-
-  if (Context.getOptions().HeaderFilterRegex &&
-  !Context.getOptions().HeaderFilterRegex->empty())
-HeaderFilter =
-std::make_unique(*Context.getOptions().HeaderFilterRegex);
-
-  if (Context.getOptions().ExcludeHeaderFilterRegex &&
-  !Context.getOptions().ExcludeHeaderFilterRegex->empty())
-ExcludeHeaderFilter = std::make_unique(
-*Context.getOptions().ExcludeHeaderFilterRegex);
-}
+  EnableNolintBlocks(EnableNolintBlocks) {}
 
 void ClangTidyDiagnosticConsumer::finalizeLastError() {
   if (!Errors.empty()) {
@@ -571,17 +560,30 @@ void 
ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
   }
 
   StringRef FileName(File->getName());
-  LastErrorRelatesToUserCode =
-  LastErrorRelatesToUserCode || Sources.isInMainFile(Location) ||
-  (HeaderFilter &&
-   (HeaderFilter->match(FileName) &&
-!(ExcludeHeaderFilter && ExcludeHeaderFilter->match(FileName;
+  LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||
+   Sources.isInMainFile(Location) ||
+   (getHeaderFilter()->match(FileName) &&
+!getExcludeHeaderFilter()->match(FileName));
 
   unsigned LineNumber = Sources.getExpansionLineNumber(Location);
   LastErrorPassesLineFilter =
   LastErrorPassesLineFilter || passesLineFilter(FileName, LineNumber);
 }
 
+llvm::Regex *ClangTidyDiagnosticConsumer::getHeaderFilter() {
+  if (!HeaderFilter)
+HeaderFilter =
+std::make_unique(*Context.getOptions().HeaderFilterRegex);
+  return HeaderFilter.get();
+}
+
+llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() {
+  if (!ExcludeHeaderFilter)
+ExcludeHeaderFilter = std::make_unique(
+*Context.getOptions().ExcludeHe

[clang] [modules] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)

2025-04-03 Thread Dmitry Polukhin via cfe-commits

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


[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)

2025-04-03 Thread Muhammad Bassiouni via cfe-commits

https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/134214

>From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Thu, 3 Apr 2025 10:08:59 +0200
Subject: [PATCH 1/3] add `bf16`/`BF16` suffix support

---
 clang/include/clang/Lex/LiteralSupport.h |  1 +
 clang/lib/Lex/LiteralSupport.cpp | 17 -
 clang/lib/Sema/SemaExpr.cpp  |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Lex/LiteralSupport.h 
b/clang/include/clang/Lex/LiteralSupport.h
index ea5f63bc20399..1907cfc365d97 100644
--- a/clang/include/clang/Lex/LiteralSupport.h
+++ b/clang/include/clang/Lex/LiteralSupport.h
@@ -77,6 +77,7 @@ class NumericLiteralParser {
   bool isFloat : 1; // 1.0f
   bool isImaginary : 1; // 1.0i
   bool isFloat16 : 1;   // 1.0f16
+  bool isBFloat16 : 1;  // 1.0bf16
   bool isFloat128 : 1;  // 1.0q
   bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr
   bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 20933cc8dee69..ab0d301a70fbd 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
   isFloat = false;
   isImaginary = false;
   isFloat16 = false;
+  isBFloat16 = false;
   isFloat128 = false;
   MicrosoftInteger = 0;
   isFract = false;
@@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
   bool isFPConstant = isFloatingLiteral();
   bool HasSize = false;
   bool DoubleUnderscore = false;
+  bool isBF16 = false;
 
   // Loop over all of the characters of the suffix.  If we see something bad,
   // we break out of the loop.
   for (; s != ThisTokEnd; ++s) {
 switch (*s) {
+case 'b':
+case 'B':
+  if (isBFloat16) break;
+  if (isBF16) break;
+  if (HasSize) break;
+
+  isBF16 = true;
+  continue;
 case 'R':
 case 'r':
   if (!LangOpts.FixedPoint)
@@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
(LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) &&
   s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
 s += 2; // success, eat up 2 characters.
-isFloat16 = true;
+if (isBF16) {
+  isBFloat16 = true;
+} else {
+  isFloat16 = true;
+}
 continue;
   }
 
@@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
 isSizeT = false;
 isFloat = false;
 isFloat16 = false;
+isBFloat16 = false;
 isHalf = false;
 isImaginary = false;
 isBitInt = false;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..b4210fc22ae52 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, 
Scope *UDLScope) {
   Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy;
 else if (Literal.isFloat16)
   Ty = Context.Float16Ty;
+else if (Literal.isBFloat16)
+  Ty = Context.BFloat16Ty;
 else if (Literal.isFloat128)
   Ty = Context.Float128Ty;
 else if (getLangOpts().HLSL)

>From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001
From: bassiounix 
Date: Thu, 3 Apr 2025 10:09:22 +0200
Subject: [PATCH 2/3] add `__bf16` macros

---
 clang/lib/Frontend/InitPreprocessor.cpp | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 0b54665501c76..9bca74a8b4bd6 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, 
Preprocessor &PP,
 template 
 static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal,
 T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal,
-T IEEEQuadVal) {
+T BFloatVal, T IEEEQuadVal) {
   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf())
 return IEEEHalfVal;
   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle())
@@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T 
IEEEHalfVal, T IEEESingleVal,
 return X87DoubleExtendedVal;
   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble())
 return PPCDoubleDoubleVal;
+  if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat())
+return BFloatVal;
   assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad());
   return IEEEQuadVal;
 }
@@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, 
StringRef Prefix,
   Norm

[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)

2025-04-03 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- 
clang/include/clang/Lex/LiteralSupport.h 
clang/lib/Frontend/InitPreprocessor.cpp clang/lib/Lex/LiteralSupport.cpp 
clang/lib/Sema/SemaExpr.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 69ab02d6c..e37dd3448 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -107,7 +107,7 @@ static T PickFP(const llvm::fltSemantics *Sem, T 
IEEEHalfVal, T IEEESingleVal,
 return X87DoubleExtendedVal;
   if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble())
 return PPCDoubleDoubleVal;
-  if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat())
+  if (Sem == (const llvm::fltSemantics *)&llvm::APFloat::BFloat())
 return BFloatVal;
   assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad());
   return IEEEQuadVal;
@@ -138,8 +138,8 @@ static void DefineFloatMacros(MacroBuilder &Builder, 
StringRef Prefix,
   int Max10Exp = PickFP(Sem, 4, 38, 308, 4932, 308, 38, 4932);
   int MinExp = PickFP(Sem, -13, -125, -1021, -16381, -968, -125, -16381);
   int MaxExp = PickFP(Sem, 16, 128, 1024, 16384, 1024, 128, 16384);
-  Min = PickFP(Sem, "6.103515625e-5", "1.17549435e-38", 
"2.2250738585072014e-308",
-   "3.36210314311209350626e-4932",
+  Min = PickFP(Sem, "6.103515625e-5", "1.17549435e-38",
+   "2.2250738585072014e-308", "3.36210314311209350626e-4932",
"2.00416836000897277799610805135016e-292",
"1.1754943508222875079687365374568e-38",
"3.36210314311209350626267781732175260e-4932");
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index ab0d301a7..bdfb7575b 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -982,9 +982,12 @@ NumericLiteralParser::NumericLiteralParser(StringRef 
TokSpelling,
 switch (*s) {
 case 'b':
 case 'B':
-  if (isBFloat16) break;
-  if (isBF16) break;
-  if (HasSize) break;
+  if (isBFloat16)
+break;
+  if (isBF16)
+break;
+  if (HasSize)
+break;
 
   isBF16 = true;
   continue;

``




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


[clang-tools-extra] [clang-tidy] Add check bugprone-misleading-setter-of-reference (PR #132242)

2025-04-03 Thread Balázs Kéri via cfe-commits

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

From e3064b600ea726ab7b3dea054e9f11e1ce028297 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Wed, 19 Mar 2025 16:09:04 +0100
Subject: [PATCH 1/3] [clang-tidy] Add check
 bugprone-misleading-setter-of-reference

---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  1 +
 .../MisleadingSetterOfReferenceCheck.cpp  | 58 +++
 .../MisleadingSetterOfReferenceCheck.h| 37 
 .../misleading-setter-of-reference.rst| 42 ++
 .../misleading-setter-of-reference.cpp| 50 
 6 files changed, 191 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/misleading-setter-of-reference.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/misleading-setter-of-reference.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index b780a85bdf3fe..64f4a524daf0d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -41,6 +41,7 @@
 #include "LambdaFunctionNameCheck.h"
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
+#include "MisleadingSetterOfReferenceCheck.h"
 #include "MisplacedOperatorInStrlenInAllocCheck.h"
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
@@ -170,6 +171,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-macro-parentheses");
 CheckFactories.registerCheck(
 "bugprone-macro-repeated-side-effects");
+CheckFactories.registerCheck(
+"bugprone-misleading-setter-of-reference");
 CheckFactories.registerCheck(
 "bugprone-misplaced-operator-in-strlen-in-alloc");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index e310ea9c94543..d862794cde323 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -42,6 +42,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   LambdaFunctionNameCheck.cpp
   MacroParenthesesCheck.cpp
   MacroRepeatedSideEffectsCheck.cpp
+  MisleadingSetterOfReferenceCheck.cpp
   MisplacedOperatorInStrlenInAllocCheck.cpp
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
new file mode 100644
index 0..043d15e7fead2
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
@@ -0,0 +1,58 @@
+//===--- MisleadingSetterOfReferenceCheck.cpp - 
clang-tidy-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MisleadingSetterOfReferenceCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void MisleadingSetterOfReferenceCheck::registerMatchers(MatchFinder *Finder) {
+  auto RefField =
+  fieldDecl(unless(isPublic()),
+hasType(referenceType(pointee(equalsBoundNode("type")
+  .bind("member");
+  auto AssignLHS =
+  memberExpr(hasObjectExpression(cxxThisExpr()), member(RefField));
+  auto DerefOperand = expr(ignoringParenImpCasts(
+  declRefExpr(to(parmVarDecl(equalsBoundNode("parm"));
+  auto AssignRHS = expr(ignoringParenImpCasts(
+  unaryOperator(hasOperatorName("*"), hasUnaryOperand(DerefOperand;
+
+  auto BinaryOpAssign = binaryOperator(hasOperatorName("="), hasLHS(AssignLHS),
+   hasRHS(AssignRHS));
+  auto CXXOperatorCallAssign = cxxOperatorCallExpr(
+  hasOverloadedOperatorName("="), hasLHS(AssignLHS), hasRHS(AssignRHS));
+
+  auto SetBody =
+  compoundStmt(statementCountIs(1),
+   anyOf(has(BinaryOpAssign), has(CXXOperatorCallAssign)));
+  auto BadSetFunction =
+  cxxMethodDecl(parameterCountIs(1), isPublic(),
+hasAnyParameter(parmVarDecl(hasType(pointerType(pointee(
+qualType().bind("type")
+

[clang] e3c0565 - Reapply "[cmake] Refactor clang unittest cmake" (#134195)

2025-04-03 Thread via cfe-commits

Author: Reid Kleckner
Date: 2025-04-02T21:07:30-07:00
New Revision: e3c0565b74b1f5122ab4dbabc3e941924e116330

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

LOG: Reapply "[cmake] Refactor clang unittest cmake" (#134195)

This reapplies 5ffd9bdb50b57 (#133545) with fixes.

The BUILD_SHARED_LIBS=ON build was fixed by adding missing LLVM
dependencies to the InterpTests binary in
unittests/AST/ByteCode/CMakeLists.txt .

Added: 


Modified: 
clang/unittests/AST/ByteCode/CMakeLists.txt
clang/unittests/AST/CMakeLists.txt
clang/unittests/ASTMatchers/CMakeLists.txt
clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
clang/unittests/Analysis/CMakeLists.txt
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
clang/unittests/Basic/CMakeLists.txt
clang/unittests/CMakeLists.txt
clang/unittests/CodeGen/CMakeLists.txt
clang/unittests/CrossTU/CMakeLists.txt
clang/unittests/DirectoryWatcher/CMakeLists.txt
clang/unittests/Driver/CMakeLists.txt
clang/unittests/Format/CMakeLists.txt
clang/unittests/Frontend/CMakeLists.txt
clang/unittests/Index/CMakeLists.txt
clang/unittests/InstallAPI/CMakeLists.txt
clang/unittests/Interpreter/CMakeLists.txt
clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
clang/unittests/Lex/CMakeLists.txt
clang/unittests/Rewrite/CMakeLists.txt
clang/unittests/Sema/CMakeLists.txt
clang/unittests/Serialization/CMakeLists.txt
clang/unittests/StaticAnalyzer/CMakeLists.txt
clang/unittests/Support/CMakeLists.txt
clang/unittests/Tooling/CMakeLists.txt
clang/unittests/Tooling/Syntax/CMakeLists.txt
clang/unittests/libclang/CMakeLists.txt
clang/unittests/libclang/CrashTests/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/AST/ByteCode/CMakeLists.txt 
b/clang/unittests/AST/ByteCode/CMakeLists.txt
index b862fb4834fbd..1469cd6b2a8ea 100644
--- a/clang/unittests/AST/ByteCode/CMakeLists.txt
+++ b/clang/unittests/AST/ByteCode/CMakeLists.txt
@@ -2,19 +2,17 @@ add_clang_unittest(InterpTests
   BitcastBuffer.cpp
   Descriptor.cpp
   toAPValue.cpp
-  )
-
-clang_target_link_libraries(InterpTests
-  PRIVATE
+  CLANG_LIBS
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
   clangSerialization
   clangTooling
-  )
-
-  target_link_libraries(InterpTests
-  PRIVATE
+  LINK_LIBS
   clangTesting
-)
+  LLVM_COMPONENTS
+  FrontendOpenMP
+  Support
+  TargetParser
+  )

diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index bfa6082a6ffa4..f27d34e8a0719 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -1,10 +1,3 @@
-set(LLVM_LINK_COMPONENTS
-  FrontendOpenMP
-  Support
-  TargetParser
-  )
-
-
 add_subdirectory(ByteCode)
 
 add_clang_unittest(ASTTests
@@ -43,10 +36,7 @@ add_clang_unittest(ASTTests
   TemplateNameTest.cpp
   TypePrinterTest.cpp
   UnresolvedSetTest.cpp
-  )
-
-clang_target_link_libraries(ASTTests
-  PRIVATE
+  CLANG_LIBS
   clangAST
   clangASTMatchers
   clangBasic
@@ -54,11 +44,12 @@ clang_target_link_libraries(ASTTests
   clangLex
   clangSerialization
   clangTooling
-  )
-
-target_link_libraries(ASTTests
-  PRIVATE
+  LINK_LIBS
   clangTesting
   LLVMTestingAnnotations
   LLVMTestingSupport
-)
+  LLVM_COMPONENTS
+  FrontendOpenMP
+  Support
+  TargetParser
+  )

diff  --git a/clang/unittests/ASTMatchers/CMakeLists.txt 
b/clang/unittests/ASTMatchers/CMakeLists.txt
index 6a1e629d81b65..47bd5c108bb5a 100644
--- a/clang/unittests/ASTMatchers/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/CMakeLists.txt
@@ -1,31 +1,23 @@
-set(LLVM_LINK_COMPONENTS
-  FrontendOpenMP
-  Support
-  TargetParser
-  )
-
 add_clang_unittest(ASTMatchersTests
   ASTMatchersInternalTest.cpp
   ASTMatchersNodeTest.cpp
   ASTMatchersNarrowingTest.cpp
   ASTMatchersTraversalTest.cpp
   GtestMatchersTest.cpp
-  )
-
-clang_target_link_libraries(ASTMatchersTests
-  PRIVATE
+  CLANG_LIBS
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
   clangSerialization
   clangTooling
-  )
-
-target_link_libraries(ASTMatchersTests
-  PRIVATE
+  LINK_LIBS
   clangTesting
   LLVMTestingSupport
-)
+  LLVM_COMPONENTS
+  FrontendOpenMP
+  Support
+  TargetParser
+  )
 
 add_subdirectory(Dynamic)

diff  --git a/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt 
b/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
index 6d0e12bcb0759..b6db7ce62afe7 100644
--- a/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -1,16 +1,8 @@
-set(LLVM_LINK_COMPONENTS
-  FrontendOpenMP
-  Support
-  )
-
 add_clang_unittest(DynamicASTMatchersTests
   VariantValueTest.cpp
   ParserTest.cpp
   RegistryTest.cpp
-  )
-
-clang_target_link_libraries(DynamicASTMatchersTests
- 

[clang] [Clang][CodeGen] Do not use the GEP result to infer offset and result type (PR #134221)

2025-04-03 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw created 
https://github.com/llvm/llvm-project/pull/134221

If `CreateConstInBoundsGEP2_32` returns a constant null/gep, the cast to 
GetElementPtrInst will fail.
This patch uses two static helpers 
`GEPOperator::accumulateConstantOffset/GetElementPtrInst::getIndexedType` to 
infer offset and result type instead of depending on the GEP result.

This patch is extracted from https://github.com/llvm/llvm-project/pull/130734. 
It may be useful to fix https://github.com/llvm/llvm-project/issues/132449.


>From e0723e3a2215f69ced633fd281ac026eda61 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Thu, 3 Apr 2025 16:32:56 +0800
Subject: [PATCH] [Clang][CodeGen] Do not use the GEP result to infer offset

---
 clang/lib/CodeGen/CGBuilder.h | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index b8036cf6e6a30..090f75d3b5d3c 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -64,21 +64,25 @@ class CGBuilderTy : public CGBuilderBaseTy {
   Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
  const llvm::Twine &Name) {
 const llvm::DataLayout &DL = BB->getDataLayout();
-llvm::GetElementPtrInst *GEP;
+llvm::Value *V;
 if (IsInBounds)
-  GEP = cast(CreateConstInBoundsGEP2_32(
-  Addr.getElementType(), emitRawPointerFromAddress(Addr), Idx0, Idx1,
-  Name));
+  V = CreateConstInBoundsGEP2_32(Addr.getElementType(),
+ emitRawPointerFromAddress(Addr), Idx0,
+ Idx1, Name);
 else
-  GEP = cast(CreateConstGEP2_32(
-  Addr.getElementType(), emitRawPointerFromAddress(Addr), Idx0, Idx1,
-  Name));
+  V = CreateConstGEP2_32(Addr.getElementType(),
+ emitRawPointerFromAddress(Addr), Idx0, Idx1, 
Name);
 llvm::APInt Offset(
 DL.getIndexSizeInBits(Addr.getType()->getPointerAddressSpace()), 0,
 /*isSigned=*/true);
-if (!GEP->accumulateConstantOffset(DL, Offset))
-  llvm_unreachable("offset of GEP with constants is always computable");
-return Address(GEP, GEP->getResultElementType(),
+if (!llvm::GEPOperator::accumulateConstantOffset(
+Addr.getElementType(), {getInt32(Idx0), getInt32(Idx1)}, DL,
+Offset))
+  llvm_unreachable(
+  "accumulateConstantOffset with constant indices should not fail.");
+llvm::Type *ElementTy = llvm::GetElementPtrInst::getIndexedType(
+Addr.getElementType(), {Idx0, Idx1});
+return Address(V, ElementTy,
Addr.getAlignment().alignmentAtOffset(
CharUnits::fromQuantity(Offset.getSExtValue())),
IsInBounds ? Addr.isKnownNonNull() : NotKnownNonNull);

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


[clang] [clang][AST] Fix end location of DeclarationNameInfo on instantiated methods (PR #92654)

2025-04-03 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@Abramo-Bagnara @steakhal I noticed the same issue and I have posted the fix in 
#134038

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


[clang] [Clang][CodeGen] Do not use the GEP result to infer offset and result type (PR #134221)

2025-04-03 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Yingwei Zheng (dtcxzyw)


Changes

If `CreateConstInBoundsGEP2_32` returns a constant null/gep, the cast to 
GetElementPtrInst will fail.
This patch uses two static helpers 
`GEPOperator::accumulateConstantOffset/GetElementPtrInst::getIndexedType` to 
infer offset and result type instead of depending on the GEP result.

This patch is extracted from https://github.com/llvm/llvm-project/pull/130734. 
It may be useful to fix https://github.com/llvm/llvm-project/issues/132449.


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


1 Files Affected:

- (modified) clang/lib/CodeGen/CGBuilder.h (+14-10) 


``diff
diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index b8036cf6e6a30..090f75d3b5d3c 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -64,21 +64,25 @@ class CGBuilderTy : public CGBuilderBaseTy {
   Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
  const llvm::Twine &Name) {
 const llvm::DataLayout &DL = BB->getDataLayout();
-llvm::GetElementPtrInst *GEP;
+llvm::Value *V;
 if (IsInBounds)
-  GEP = cast(CreateConstInBoundsGEP2_32(
-  Addr.getElementType(), emitRawPointerFromAddress(Addr), Idx0, Idx1,
-  Name));
+  V = CreateConstInBoundsGEP2_32(Addr.getElementType(),
+ emitRawPointerFromAddress(Addr), Idx0,
+ Idx1, Name);
 else
-  GEP = cast(CreateConstGEP2_32(
-  Addr.getElementType(), emitRawPointerFromAddress(Addr), Idx0, Idx1,
-  Name));
+  V = CreateConstGEP2_32(Addr.getElementType(),
+ emitRawPointerFromAddress(Addr), Idx0, Idx1, 
Name);
 llvm::APInt Offset(
 DL.getIndexSizeInBits(Addr.getType()->getPointerAddressSpace()), 0,
 /*isSigned=*/true);
-if (!GEP->accumulateConstantOffset(DL, Offset))
-  llvm_unreachable("offset of GEP with constants is always computable");
-return Address(GEP, GEP->getResultElementType(),
+if (!llvm::GEPOperator::accumulateConstantOffset(
+Addr.getElementType(), {getInt32(Idx0), getInt32(Idx1)}, DL,
+Offset))
+  llvm_unreachable(
+  "accumulateConstantOffset with constant indices should not fail.");
+llvm::Type *ElementTy = llvm::GetElementPtrInst::getIndexedType(
+Addr.getElementType(), {Idx0, Idx1});
+return Address(V, ElementTy,
Addr.getAlignment().alignmentAtOffset(
CharUnits::fromQuantity(Offset.getSExtValue())),
IsInBounds ? Addr.isKnownNonNull() : NotKnownNonNull);

``




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


[libclc] [libclc]: clspv: add a dummy implememtation for mul_hi (PR #134094)

2025-04-03 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr updated 
https://github.com/llvm/llvm-project/pull/134094

>From 46d4e40a3142b36811b85ac3d2ececf46d5b8e7c Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
Date: Wed, 2 Apr 2025 17:12:17 +0200
Subject: [PATCH 1/2] [libclc]: clspv: add a dummy implememtation for mul_hi

clspv uses a better implementation that is not using a bigger side
when not available.
Add a dummy implementation for mul_hi to avoid to override the
implementation of clspv with the one in libclc.
---
 libclc/clc/lib/clspv/SOURCES   | 1 +
 libclc/clc/lib/clspv/integer/clc_mul_hi.cl | 0
 2 files changed, 1 insertion(+)
 create mode 100644 libclc/clc/lib/clspv/integer/clc_mul_hi.cl

diff --git a/libclc/clc/lib/clspv/SOURCES b/libclc/clc/lib/clspv/SOURCES
index b1401f8307a4c..b91b0e70a397d 100644
--- a/libclc/clc/lib/clspv/SOURCES
+++ b/libclc/clc/lib/clspv/SOURCES
@@ -1 +1,2 @@
 math/clc_sw_fma.cl
+integer/clc_mul_hi.cl
diff --git a/libclc/clc/lib/clspv/integer/clc_mul_hi.cl 
b/libclc/clc/lib/clspv/integer/clc_mul_hi.cl
new file mode 100644
index 0..e69de29bb2d1d

>From a1952cbc08dad20ac812eaede1dd4685b1df7d80 Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
Date: Thu, 3 Apr 2025 10:51:35 +0200
Subject: [PATCH 2/2] Update clc_mul_hi.cl

---
 libclc/clc/lib/clspv/integer/clc_mul_hi.cl | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libclc/clc/lib/clspv/integer/clc_mul_hi.cl 
b/libclc/clc/lib/clspv/integer/clc_mul_hi.cl
index e69de29bb2d1d..54a51bbce4303 100644
--- a/libclc/clc/lib/clspv/integer/clc_mul_hi.cl
+++ b/libclc/clc/lib/clspv/integer/clc_mul_hi.cl
@@ -0,0 +1,5 @@
+/*
+Opt-out of libclc mul_hi implementation for clspv.
+clspv has an internal implementation that does not required using a bigger 
data size.
+That implementation is based on OpMulExtended which is SPIR-V specific, thus 
it cannot be written in OpenCL-C.
+*/

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


[clang] [Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (PR #132348)

2025-04-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-with-thin-lto-ubuntu` running on `as-worker-92` while building `clang` 
at step 7 "test-stage1-compiler".

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


Here is the relevant piece of the build log for the reference

```
Step 7 (test-stage1-compiler) failure: build (failure)
0.069 [1/2/1] Preparing lit tests
0.639 [1/1/2] cd 
/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/clang/bindings/python
 && /usr/bin/cmake -E env CLANG_NO_DEFAULT_CONFIG=1 
CLANG_LIBRARY_PATH=/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage1/lib
 /usr/bin/python3.10 -m unittest discover
FAILED: tools/clang/bindings/python/tests/CMakeFiles/check-clang-python 
/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage1/tools/clang/bindings/python/tests/CMakeFiles/check-clang-python
 
cd 
/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/clang/bindings/python
 && /usr/bin/cmake -E env CLANG_NO_DEFAULT_CONFIG=1 
CLANG_LIBRARY_PATH=/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/build/stage1/lib
 /usr/bin/python3.10 -m unittest discover
F.F..
==
FAIL: test_diagnostic_category (tests.cindex.test_diagnostics.TestDiagnostics)
Ensure that category properties work.
--
Traceback (most recent call last):
  File 
"/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/clang/bindings/python/tests/cindex/test_diagnostics.py",
 line 82, in test_diagnostic_category
self.assertEqual(d.category_number, 2)
AssertionError: 3 != 2

==
FAIL: test_diagnostic_string_format 
(tests.cindex.test_diagnostics.TestDiagnostics)
--
Traceback (most recent call last):
  File 
"/home/buildbot/as-worker-92/clang-with-thin-lto-ubuntu/llvm-project/clang/bindings/python/tests/cindex/test_diagnostics.py",
 line 124, in test_diagnostic_string_format
self.assertEqual(
AssertionError: "t.c:1:26: error: expected ';' after struct [2, Parse Issue]" 
!= "t.c:1:26: error: expected ';' after struct [3, Parse Issue]"
- t.c:1:26: error: expected ';' after struct [2, Parse Issue]
? ^
+ t.c:1:26: error: expected ';' after struct [3, Parse Issue]
? ^


--
Ran 157 tests in 0.523s

FAILED (failures=2)
ninja: build stopped: subcommand failed.

```



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


[libclc] [libclc] Move fmin & fmax to CLC library (PR #134218)

2025-04-03 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

fmin/fmax are needed for minmag/maxmag/fract, and fract is needed for 
sin/cos/tan so these builtins are a bottleneck right now.

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


[clang] [OpenCL] Add cl_ext_image_unsigned_10x6_12x4_14x2 extension (PR #134216)

2025-04-03 Thread Kévin Petit via cfe-commits

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

LGTM, thanks! (The definitions match the specification, tests ran, CI failures 
look unrelated.)

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


[libclc] 7baa7ed - [libclc]: clspv: add a dummy implememtation for mul_hi (#134094)

2025-04-03 Thread via cfe-commits

Author: Romaric Jodin
Date: 2025-04-03T10:18:39+01:00
New Revision: 7baa7edc00c5c92e2d17bae760db2e6df97dcec6

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

LOG: [libclc]: clspv: add a dummy implememtation for mul_hi (#134094)

clspv uses a better implementation that is not using a bigger side when
not available.
Add a dummy implementation for mul_hi to avoid to override the
implementation of clspv with the one in libclc.

Added: 
libclc/clc/lib/clspv/integer/clc_mul_hi.cl

Modified: 
libclc/clc/lib/clspv/SOURCES

Removed: 




diff  --git a/libclc/clc/lib/clspv/SOURCES b/libclc/clc/lib/clspv/SOURCES
index b1401f8307a4c..b91b0e70a397d 100644
--- a/libclc/clc/lib/clspv/SOURCES
+++ b/libclc/clc/lib/clspv/SOURCES
@@ -1 +1,2 @@
 math/clc_sw_fma.cl
+integer/clc_mul_hi.cl

diff  --git a/libclc/clc/lib/clspv/integer/clc_mul_hi.cl 
b/libclc/clc/lib/clspv/integer/clc_mul_hi.cl
new file mode 100644
index 0..54a51bbce4303
--- /dev/null
+++ b/libclc/clc/lib/clspv/integer/clc_mul_hi.cl
@@ -0,0 +1,5 @@
+/*
+Opt-out of libclc mul_hi implementation for clspv.
+clspv has an internal implementation that does not required using a bigger 
data size.
+That implementation is based on OpMulExtended which is SPIR-V specific, thus 
it cannot be written in OpenCL-C.
+*/



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


[clang] [CLANG-CL] ignores wpadded (PR #130182)

2025-04-03 Thread Mikael Holmén via cfe-commits

mikaelholmen wrote:

If I compile clang with clang (18.1.8) the new windows-Wpadded.cpp testcase 
fails for me like
```
error: 'expected-warning' diagnostics seen but not expected: 
  File /repo/clang/test/SemaCXX/windows-Wpadded.cpp Line 20: padding struct 
'Derived' with 2 bits to align 'c'
1 error generated.
```
However, if I compile clang with gcc (13.3.0) and run the testcase it does not 
fail.

Am I the only one seeing this?

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


[clang] [llvm] [NVPTX] Add intrinsics for cvt .f6x2 and .ue8m0x2 variants (PR #134345)

2025-04-03 Thread Srinivasa Ravi via cfe-commits

https://github.com/Wolfram70 created 
https://github.com/llvm/llvm-project/pull/134345

This change adds NVVM intrinsics and clang builtins for the cvt instruction 
variants of types `.e2m3x2`, `.e3m2x2`, and `.ue8m0x2` introduced in PTX 8.6 
for `sm_100a`, `sm_101a`, and `sm_120a`.

Tests are added in `NVPTX/convert-sm100a.ll` and
`clang/test/CodeGen/builtins-nvptx.c` and verified through ptxas 12.8.0.

PTX Spec Reference: 
https://docs.nvidia.com/cuda/parallel-thread-execution/#data-movement-and-conversion-instructions-cvt

>From 184b9a4e591f562fcc75f341500eb74e39ec9105 Mon Sep 17 00:00:00 2001
From: Srinivasa Ravi 
Date: Wed, 5 Mar 2025 12:35:39 +0530
Subject: [PATCH] [NVPTX] Add intrinsics for cvt .f6x2 and .ue8m0x2 variants

This change adds NVVM intrinsics and clang builtins for the cvt
instruction variants of types .e2m3x2, .e3m2x2, and .ue8m0x2 introduced
in PTX 8.6 for `sm_100a`, `sm_101a`, and `sm_120a`.

Tests are added in `NVPTX/convert-sm1XXa.ll` and
`clang/test/CodeGen/builtins-nvptx.c` and verified through ptxas 12.8.0.

PTX Spec Reference: 
https://docs.nvidia.com/cuda/parallel-thread-execution/#data-movement-and-conversion-instructions-cvt
---
 clang/include/clang/Basic/BuiltinsNVPTX.td |  31 +++
 clang/test/CodeGen/builtins-nvptx.c| 191 +-
 llvm/include/llvm/IR/IntrinsicsNVVM.td |  39 +++
 llvm/lib/Target/NVPTX/NVPTXInstrInfo.td|  47 
 llvm/lib/Target/NVPTX/NVPTXIntrinsics.td   |  56 
 llvm/test/CodeGen/NVPTX/convert-sm100a.ll  | 290 +
 6 files changed, 650 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/CodeGen/NVPTX/convert-sm100a.ll

diff --git a/clang/include/clang/Basic/BuiltinsNVPTX.td 
b/clang/include/clang/Basic/BuiltinsNVPTX.td
index 61e48b31c244b..d240b1a8d0d16 100644
--- a/clang/include/clang/Basic/BuiltinsNVPTX.td
+++ b/clang/include/clang/Basic/BuiltinsNVPTX.td
@@ -580,6 +580,15 @@ def __nvvm_f2bf16_rz : 
NVPTXBuiltinSMAndPTX<"__bf16(float)", SM_80, PTX70>;
 def __nvvm_f2bf16_rz_relu : NVPTXBuiltinSMAndPTX<"__bf16(float)", SM_80, 
PTX70>;
 
 def __nvvm_f2tf32_rna : NVPTXBuiltinSMAndPTX<"int32_t(float)", SM_80, PTX70>;
+def __nvvm_f2tf32_rna_satfinite : NVPTXBuiltinSMAndPTX<"int32_t(float)", 
SM_89, PTX81>;
+def __nvvm_f2tf32_rn : NVPTXBuiltinSMAndPTX<"int32_t(float)", SM_90, PTX78>;
+def __nvvm_f2tf32_rn_relu : NVPTXBuiltinSMAndPTX<"int32_t(float)", SM_90, 
PTX78>;
+def __nvvm_f2tf32_rn_satfinite : NVPTXBuiltinSMAndPTX<"int32_t(float)", 
SM_100, PTX86>;
+def __nvvm_f2tf32_rn_relu_satfinite : NVPTXBuiltinSMAndPTX<"int32_t(float)", 
SM_100, PTX86>;
+def __nvvm_f2tf32_rz : NVPTXBuiltinSMAndPTX<"int32_t(float)", SM_90, PTX78>;
+def __nvvm_f2tf32_rz_relu : NVPTXBuiltinSMAndPTX<"int32_t(float)", SM_90, 
PTX78>;
+def __nvvm_f2tf32_rz_satfinite : NVPTXBuiltinSMAndPTX<"int32_t(float)", 
SM_100, PTX86>;
+def __nvvm_f2tf32_rz_relu_satfinite : NVPTXBuiltinSMAndPTX<"int32_t(float)", 
SM_100, PTX86>;
 
 def __nvvm_ff_to_e4m3x2_rn : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM_89, PTX81>;
 def __nvvm_ff_to_e4m3x2_rn_relu : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM_89, PTX81>;
@@ -596,6 +605,28 @@ def __nvvm_e4m3x2_to_f16x2_rn_relu : 
NVPTXBuiltinSMAndPTX<"_Vector<2, __fp16>(sh
 def __nvvm_e5m2x2_to_f16x2_rn : NVPTXBuiltinSMAndPTX<"_Vector<2, 
__fp16>(short)", SM_89, PTX81>;
 def __nvvm_e5m2x2_to_f16x2_rn_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, 
__fp16>(short)", SM_89, PTX81>;
 
+def __nvvm_ff_to_e2m3x2_rn : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_ff_to_e2m3x2_rn_relu : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_ff_to_e3m2x2_rn : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_ff_to_e3m2x2_rn_relu : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+
+def __nvvm_e2m3x2_to_f16x2_rn : NVPTXBuiltinSMAndPTX<"_Vector<2, 
__fp16>(short)", SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_e2m3x2_to_f16x2_rn_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, 
__fp16>(short)", SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_e3m2x2_to_f16x2_rn : NVPTXBuiltinSMAndPTX<"_Vector<2, 
__fp16>(short)", SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_e3m2x2_to_f16x2_rn_relu : NVPTXBuiltinSMAndPTX<"_Vector<2, 
__fp16>(short)", SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+
+def __nvvm_ff_to_ue8m0x2_rz : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_ff_to_ue8m0x2_rz_satfinite : NVPTXBuiltinSMAndPTX<"short(float, 
float)", SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_ff_to_ue8m0x2_rp : NVPTXBuiltinSMAndPTX<"short(float, float)", 
SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+def __nvvm_ff_to_ue8m0x2_rp_satfinite : NVPTXBuiltinSMAndPTX<"short(float, 
float)", SM<"100a", [SM_101a, SM_120a]>, PTX86>;
+
+def __nvvm_bf16x2_to_ue8m0x2_rz : NVPTXBuiltinSMAndPTX<"short(_Vector<2, 
__bf16>)", SM<"100a", [SM

[clang] [llvm] [ARM] Adding diagnostics for mcmodel=tiny when used in invalid targets (PR #125643)

2025-04-03 Thread via cfe-commits

ShashwathiNavada wrote:

ping @cor3ntin 

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits

nikic wrote:

> Overall the patch is much better. Once it's moved to `utils` I think it will 
> be good. @nikic I seem to recall that we now prefer markdown over `.rst` 
> files. Is that correct? I tried to find documentation for the policy, but I 
> seem to be missing it in my grep/googling.

I believe doc files that are used for man page generation are required to use 
.rst, because we don't want ability to generate man pages with just a sphinx 
dependency.

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,12 @@
+llvm-mustachespec - LLVM tool to test Mustache Compliance Library
+=
+
+llvm-mustachespec test the mustache spec conformance of the LLVM

nikic wrote:

```suggestion
llvm-mustachespec tests the mustache spec conformance of the LLVM
```

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,104 @@
+//===- llvm-mustachespec.cpp - The LLVM Modular Optimizer
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// Simple drivers to test the mustache spec found here
+// https://github.com/mustache/
+// It is used to verify that the current implementation conforms to the spec
+// simply download the spec and pass the test files to the driver
+//
+// Currently Triple Mustache is not supported we expect the following spec
+// test to fail:
+//Triple Mustache
+//Triple Mustache Integer Interpolation
+//Triple Mustache Decimal Interpolation
+//Triple Mustache Null Interpolation
+//Triple Mustache Context Miss Interpolation
+//Dotted Names - Triple Mustache Interpolation
+//Implicit Iterators - Triple Mustache
+//Triple Mustache - Surrounding Whitespace
+//Triple Mustache - Standalone
+//Triple Mustache With Padding
+//Standalone Indentation
+//Implicit Iterator - Triple mustache
+//
+// Usage:
+//  mustache path/to/test/file/test.json path/to/test/file/test2.json ...
+//===--===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Mustache.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+using namespace llvm::mustache;
+
+cl::list InputFiles(cl::Positional, cl::desc(""),
+ cl::OneOrMore);
+
+void runThroughTest(StringRef InputFile) {
+  llvm::outs() << "Running Tests: " << InputFile << "\n";
+  ErrorOr> BufferOrError =
+  MemoryBuffer::getFile(InputFile);
+
+  if (auto EC = BufferOrError.getError()) {
+return;
+  }
+  std::unique_ptr Buffer = std::move(BufferOrError.get());
+  llvm::StringRef FileContent = Buffer->getBuffer();
+  Expected Json = parse(FileContent);
+
+  if (auto E = Json.takeError()) {
+errs() << "Parsing error: " << toString(std::move(E)) << "\n";
+return;
+  }
+  // Get test
+  Array *Obj = (*Json).getAsObject()->getArray("tests");

nikic wrote:

```suggestion
  Array *Obj = Json->getAsObject()->getArray("tests");
```
This looks a bit odd, does this work?

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,12 @@
+llvm-mustachespec - LLVM tool to test Mustache Compliance Library
+=
+
+llvm-mustachespec test the mustache spec conformance of the LLVM
+mustache library. The spec can be found here https://github.com/mustache/spec

nikic wrote:

```suggestion
mustache library. The spec can be found here: `Mustache Spec 
`_.
```
or something.

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,104 @@
+//===- llvm-mustachespec.cpp - The LLVM Modular Optimizer
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// Simple drivers to test the mustache spec found here
+// https://github.com/mustache/
+// It is used to verify that the current implementation conforms to the spec
+// simply download the spec and pass the test files to the driver
+//
+// Currently Triple Mustache is not supported we expect the following spec
+// test to fail:
+//Triple Mustache
+//Triple Mustache Integer Interpolation
+//Triple Mustache Decimal Interpolation
+//Triple Mustache Null Interpolation
+//Triple Mustache Context Miss Interpolation
+//Dotted Names - Triple Mustache Interpolation
+//Implicit Iterators - Triple Mustache
+//Triple Mustache - Surrounding Whitespace
+//Triple Mustache - Standalone
+//Triple Mustache With Padding
+//Standalone Indentation
+//Implicit Iterator - Triple mustache

nikic wrote:

I wonder whether it would make sense to include this list directly in the 
program, and report these as "xfail"? That way it's easy to see whether there 
are any unexpected failures without manually comparing to this list.

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,104 @@
+//===- llvm-mustachespec.cpp - The LLVM Modular Optimizer
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// Simple drivers to test the mustache spec found here
+// https://github.com/mustache/
+// It is used to verify that the current implementation conforms to the spec
+// simply download the spec and pass the test files to the driver
+//
+// Currently Triple Mustache is not supported we expect the following spec
+// test to fail:
+//Triple Mustache
+//Triple Mustache Integer Interpolation
+//Triple Mustache Decimal Interpolation
+//Triple Mustache Null Interpolation
+//Triple Mustache Context Miss Interpolation
+//Dotted Names - Triple Mustache Interpolation
+//Implicit Iterators - Triple Mustache
+//Triple Mustache - Surrounding Whitespace
+//Triple Mustache - Standalone
+//Triple Mustache With Padding
+//Standalone Indentation
+//Implicit Iterator - Triple mustache
+//
+// Usage:
+//  mustache path/to/test/file/test.json path/to/test/file/test2.json ...
+//===--===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Mustache.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+using namespace llvm::mustache;
+
+cl::list InputFiles(cl::Positional, cl::desc(""),
+ cl::OneOrMore);
+
+void runThroughTest(StringRef InputFile) {
+  llvm::outs() << "Running Tests: " << InputFile << "\n";
+  ErrorOr> BufferOrError =
+  MemoryBuffer::getFile(InputFile);
+
+  if (auto EC = BufferOrError.getError()) {
+return;
+  }
+  std::unique_ptr Buffer = std::move(BufferOrError.get());
+  llvm::StringRef FileContent = Buffer->getBuffer();
+  Expected Json = parse(FileContent);
+
+  if (auto E = Json.takeError()) {
+errs() << "Parsing error: " << toString(std::move(E)) << "\n";
+return;
+  }
+  // Get test
+  Array *Obj = (*Json).getAsObject()->getArray("tests");
+  size_t Total = 0;
+  size_t Success = 0;
+  for (Value V : *Obj) {
+Object *TestCase = V.getAsObject();
+StringRef TemplateStr = TestCase->getString("template").value();
+StringRef ExpectedStr = TestCase->getString("expected").value();
+StringRef Name = TestCase->getString("name").value();
+Value *Data = TestCase->get("data");
+Value *Partials = TestCase->get("partials");
+
+if (!Data)
+  continue;
+
+Template T = Template(TemplateStr);
+if (Partials) {
+  for (auto &PartialPairs : *Partials->getAsObject()) {
+const auto &[Partial, Str] = PartialPairs;
+T.registerPartial((*Str.getAsString()).str(), Partial.str());

nikic wrote:

```suggestion
T.registerPartial(Str.getAsString()->str(), Partial.str());
```

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,104 @@
+//===- llvm-mustachespec.cpp - The LLVM Modular Optimizer
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// Simple drivers to test the mustache spec found here
+// https://github.com/mustache/
+// It is used to verify that the current implementation conforms to the spec
+// simply download the spec and pass the test files to the driver
+//
+// Currently Triple Mustache is not supported we expect the following spec
+// test to fail:
+//Triple Mustache
+//Triple Mustache Integer Interpolation
+//Triple Mustache Decimal Interpolation
+//Triple Mustache Null Interpolation
+//Triple Mustache Context Miss Interpolation
+//Dotted Names - Triple Mustache Interpolation
+//Implicit Iterators - Triple Mustache
+//Triple Mustache - Surrounding Whitespace
+//Triple Mustache - Standalone
+//Triple Mustache With Padding
+//Standalone Indentation
+//Implicit Iterator - Triple mustache
+//
+// Usage:
+//  mustache path/to/test/file/test.json path/to/test/file/test2.json ...
+//===--===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Mustache.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+using namespace llvm::mustache;
+
+cl::list InputFiles(cl::Positional, cl::desc(""),
+ cl::OneOrMore);
+
+void runThroughTest(StringRef InputFile) {
+  llvm::outs() << "Running Tests: " << InputFile << "\n";

nikic wrote:

```suggestion
  outs() << "Running Tests: " << InputFile << "\n";
```
You're using `using namespace llvm`, don't need all these `llvm::` prefixes.

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,104 @@
+//===- llvm-mustachespec.cpp - The LLVM Modular Optimizer
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// Simple drivers to test the mustache spec found here
+// https://github.com/mustache/
+// It is used to verify that the current implementation conforms to the spec
+// simply download the spec and pass the test files to the driver
+//
+// Currently Triple Mustache is not supported we expect the following spec
+// test to fail:
+//Triple Mustache
+//Triple Mustache Integer Interpolation
+//Triple Mustache Decimal Interpolation
+//Triple Mustache Null Interpolation
+//Triple Mustache Context Miss Interpolation
+//Dotted Names - Triple Mustache Interpolation
+//Implicit Iterators - Triple Mustache
+//Triple Mustache - Surrounding Whitespace
+//Triple Mustache - Standalone
+//Triple Mustache With Padding
+//Standalone Indentation
+//Implicit Iterator - Triple mustache
+//
+// Usage:
+//  mustache path/to/test/file/test.json path/to/test/file/test2.json ...
+//===--===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Mustache.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+using namespace llvm::mustache;
+
+cl::list InputFiles(cl::Positional, cl::desc(""),
+ cl::OneOrMore);
+
+void runThroughTest(StringRef InputFile) {
+  llvm::outs() << "Running Tests: " << InputFile << "\n";
+  ErrorOr> BufferOrError =
+  MemoryBuffer::getFile(InputFile);
+
+  if (auto EC = BufferOrError.getError()) {
+return;
+  }

nikic wrote:

Shouldn't the error get reported?

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


[clang-tools-extra] [llvm] [llvm] add tool to verify mustache library (PR #111487)

2025-04-03 Thread Nikita Popov via cfe-commits


@@ -0,0 +1,104 @@
+//===- llvm-mustachespec.cpp - The LLVM Modular Optimizer
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// Simple drivers to test the mustache spec found here
+// https://github.com/mustache/
+// It is used to verify that the current implementation conforms to the spec
+// simply download the spec and pass the test files to the driver
+//
+// Currently Triple Mustache is not supported we expect the following spec

nikic wrote:

```suggestion
// Currently Triple Mustache is not supported, so we expect the following spec
```

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


[clang] [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (PR #134124)

2025-04-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-amdgpu-runtime-2` running on `rocm-worker-hw-02` while building 
`clang` at step 5 "compile-openmp".

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


Here is the relevant piece of the build log for the reference

```
Step 5 (compile-openmp) failure: build (failure)
...
63.023 [708/64/3821] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaOpenMP.cpp.o
63.134 [707/64/3822] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/Parsing.cpp.o
63.298 [706/64/3823] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexingAction.cpp.o
63.316 [705/64/3824] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/Stencil.cpp.o
63.394 [704/64/3825] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/RangeSelector.cpp.o
63.559 [703/64/3826] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangedConstraintManager.cpp.o
63.566 [702/64/3827] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/Transformer.cpp.o
63.839 [701/64/3828] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CoreEngine.cpp.o
63.842 [700/64/3829] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/RewriteRule.cpp.o
63.902 [699/64/3830] Linking CXX shared library lib/libclangSema.so.21.0git
FAILED: lib/libclangSema.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation 
-Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 
-DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   
-Wl,-rpath-link,/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./lib
  -Wl,--gc-sections -shared -Wl,-soname,libclangSema.so.21.0git -o 
lib/libclangSema.so.21.0git 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/AnalysisBasedWarnings.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/CheckExprLifetime.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/CodeCompleteConsumer.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/DeclSpec.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/DelayedDiagnostic.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/HeuristicResolver.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/HLSLBuiltinTypeDeclBuilder.cpp.o
 tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/HLSLExternalSemaSource.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/IdentifierResolver.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/JumpDiagnostics.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/MultiplexExternalSemaSource.cpp.o
 tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/ParsedAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Scope.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/ScopeInfo.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAMDGPU.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaARM.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAVR.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAccess.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAPINotes.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAvailability.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaBPF.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaBase.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaBoundsSafety.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCXXScopeSpec.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCast.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaChecking.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCodeComplete.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaConcept.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaConsumer.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCoroutine.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCUDA.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDecl.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclAttr.cpp.o 
tools/clang/lib/

[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)

2025-04-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Zahira Ammarguellat (zahiraam)


Changes



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


3 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp (+1-1) 
- (modified) clang-tools-extra/clangd/ConfigCompile.cpp (+1-1) 
- (modified) clang-tools-extra/clangd/Headers.cpp (+1-1) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
index bafcd402ca851..7650d9e8a592f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
@@ -260,7 +260,7 @@ static IntegerRange createFromType(const ASTContext 
&Context,
 llvm::APSInt LowerValue(PrecisionBits + 2, /*isUnsigned*/ false);
 LowerValue.setBit(PrecisionBits);
 LowerValue.setSignBit();
-return {LowerValue, UpperValue};
+return {std::move(LowerValue), UpperValue};
   }
   assert(T.isInteger() && "Unexpected builtin type");
   uint64_t TypeSize = Context.getTypeSize(&T);
diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 3d7f792aa136b..13c2405e76df7 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -535,7 +535,7 @@ struct FragmentCompiler {
 }
 if (Filters->empty())
   return std::nullopt;
-auto Filter = [Filters](llvm::StringRef Path) {
+auto Filter = [Filters = std::move(Filters)](llvm::StringRef Path) {
   for (auto &Regex : *Filters)
 if (Regex.match(Path))
   return true;
diff --git a/clang-tools-extra/clangd/Headers.cpp 
b/clang-tools-extra/clangd/Headers.cpp
index 0ffd9ee4d2751..0d43ada87d359 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -305,7 +305,7 @@ IncludeInserter::calculateIncludePath(const HeaderFile 
&InsertedHeader,
   if (llvm::sys::path::is_absolute(Suggested))
 return std::nullopt;
   bool IsAngled = false;
-  for (auto Filter : AngledHeaders) {
+  for (auto &Filter : AngledHeaders) {
 if (Filter(Suggested)) {
   IsAngled = true;
   break;

``




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


[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-04-03 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,142 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++11  -fptrauth-calls 
-fptrauth-intrinsics -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++11  -fptrauth-calls 
-fptrauth-intrinsics -verify -fsyntax-only %s
+
+#define AQ __ptrauth(1,1,50)
+#define AQ2 __ptrauth(1,1,51)
+#define IQ __ptrauth(1,0,50)
+
+struct __attribute__((trivial_abi)) AddrDisc { // expected-warning 
{{'trivial_abi' cannot be applied to 'AddrDisc'}} expected-note {{'trivial_abi' 
is disallowed on 'AddrDisc' because it has an address-discriminated '__ptrauth' 
field}}
+  int * AQ m0;
+};
+
+struct __attribute__((trivial_abi)) NoAddrDisc {
+  int * IQ m0;
+};
+
+namespace test_union {
+
+  union U0 {
+int * AQ f0; // expected-note 4 {{'U0' is implicitly deleted because 
variant field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+
+// ptrauth fields that don't have an address-discriminated qualifier don't
+// delete the special functions.
+int * IQ f1;
+  };
+
+  union U1 {
+int * AQ f0; // expected-note 8 {{'U1' is implicitly deleted because 
variant field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+U1() = default;
+~U1() = default;
+U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy 
constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted 
function was implicitly deleted here}} expected-note{{replace 'default'}}
+U1(U1 &&) = default; // expected-warning {{explicitly defaulted move 
constructor is implicitly deleted}} expected-note{{replace 'default'}}
+U1 & operator=(const U1 &) = default; // expected-warning {{explicitly 
defaulted copy assignment operator is implicitly deleted}} expected-note 2 
{{explicitly defaulted function was implicitly deleted here}} 
expected-note{{replace 'default'}}
+U1 & operator=(U1 &&) = default; // expected-warning {{explicitly 
defaulted move assignment operator is implicitly deleted}} 
expected-note{{replace 'default'}}
+  };
+
+  // It's fine if the user has explicitly defined the special functions.
+  union U2 {
+int * AQ f0;
+U2() = default;
+~U2() = default;
+U2(const U2 &);
+U2(U2 &&);
+U2 & operator=(const U2 &);
+U2 & operator=(U2 &&);
+  };
+
+  // Address-discriminated ptrauth fields in anonymous union fields delete the
+  // defaulted copy/move constructors/assignment operators of the containing
+  // class.
+  struct S0 {
+union {
+  int * AQ f0; // expected-note 4 {{' is implicitly deleted because 
variant field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+  char f1;
+};
+  };
+
+  struct S1 {
+union {
+  union {
+int * AQ f0; // expected-note 4 {{implicitly deleted because variant 
field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+char f1;
+  } u; // expected-note 4 {{'S1' is implicitly deleted because field 'u' 
has a deleted}}
+  int f2;
+};
+  };
+
+  U0 *x0;
+  U1 *x1;
+  U2 *x2;
+  S0 *x3;
+  S1 *x4;
+
+  // No diagnostics since constructors/destructors of the unions aren't 
deleted by default.
+  void testDefaultConstructor() {
+U0 u0;
+U1 u1;
+U2 u2;
+S0 s0;
+S1 s1;
+  }
+
+  // No diagnostics since destructors of the unions aren't deleted by default.
+  void testDestructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+delete u0;
+delete u1;
+delete u2;
+delete s0;
+delete s1;
+  }
+
+  void testCopyConstructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+U0 t0(*u0); // expected-error {{call to implicitly-deleted copy 
constructor}}
+U1 t1(*u1); // expected-error {{call to implicitly-deleted copy 
constructor}}
+U2 t2(*u2);
+S0 t3(*s0); // expected-error {{call to implicitly-deleted copy 
constructor}}
+S1 t4(*s1); // expected-error {{call to implicitly-deleted copy 
constructor}}
+  }
+
+  void testCopyAssignment(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+*x0 = *u0; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+*x1 = *u1; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+*x2 = *u2;
+*x3 = *s0; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+*x4 = *s1; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+  }
+
+  void testMoveConstructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+U0 t0(static_cast(*u0)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+U1 t1(static_cast(*u1)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+U2 t2(static_cast(*u2));
+S0 t3(static_cast(*s0)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+S1 t4(static_cast(*s1)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+  }
+
+  void testMoveAssignme

[clang] [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (PR #134124)

2025-04-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clangd-ubuntu-tsan` 
running on `clangd-ubuntu-clang` while building `clang` at step 5 
"build-clangd-clangd-index-server-clangd-indexer".

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


Here is the relevant piece of the build log for the reference

```
Step 5 (build-clangd-clangd-index-server-clangd-indexer) failure: build 
(failure)
...
1265.662 [6/8/3242] Building CXX object 
tools/clang/tools/extra/clangd/indexer/CMakeFiles/clangd-indexer.dir/IndexerMain.cpp.o
1266.858 [5/8/3243] Building CXX object 
tools/clang/tools/extra/clangd/index/remote/marshalling/CMakeFiles/obj.clangdRemoteMarshalling.dir/Marshalling.cpp.o
1266.894 [4/8/3244] Linking CXX static library lib/libclangdRemoteMarshalling.a
1266.929 [3/8/3245] Linking CXX static library lib/libclangdRemoteIndex.a
1268.675 [3/7/3246] Building CXX object 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractVariable.cpp.o
1269.470 [3/6/3247] Building CXX object 
tools/clang/tools/extra/clangd/tool/CMakeFiles/obj.clangdMain.dir/ClangdMain.cpp.o
1269.626 [3/5/3248] Building CXX object 
tools/clang/tools/extra/clangd/tool/CMakeFiles/obj.clangdMain.dir/Check.cpp.o
1269.674 [2/5/3249] Linking CXX static library lib/libclangdMain.a
1271.275 [2/4/3250] Building CXX object 
tools/clang/tools/extra/clangd/index/remote/server/CMakeFiles/clangd-index-server.dir/Server.cpp.o
1274.604 [1/4/3251] Linking CXX executable bin/clangd-indexer
FAILED: bin/clangd-indexer 
: && /usr/bin/clang++ -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer 
-gline-tables-only -fsanitize=thread -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 
-DNDEBUG 
-Wl,-rpath-link,/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/./lib  
-Wl,--gc-sections 
tools/clang/tools/extra/clangd/indexer/CMakeFiles/clangd-indexer.dir/IndexerMain.cpp.o
 -o bin/clangd-indexer  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  
-lpthread  lib/libclangAST.a  lib/libclangBasic.a  lib/libclangFrontend.a  
lib/libclangIndex.a  lib/libclangLex.a  lib/libclangTooling.a  
lib/libclangDaemon.a  lib/libclangdSupport.a  lib/libLLVMAArch64Info.a  
lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  
lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  
lib/libLLVMLoongArchInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  
lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  
lib/libLLVMSparcInfo.a  lib/libLLVMSPIRVInfo.a  lib/libLLVMSystemZInfo.a  
lib/libLLVMVEInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  
lib/libLLVMXCoreInfo.a  lib/libclangDependencyScanning.a  
lib/libclangToolingSyntax.a  lib/libclangTidyAndroidModule.a  
lib/libclangTidyAbseilModule.a  lib/libclangTidyAlteraModule.a  
lib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  
lib/libclangTidyConcurrencyModule.a  lib/libclangTidyDarwinModule.a  
lib/libclangTidyFuchsiaModule.a  lib/libclangTidyHICPPModule.a  
lib/libclangTidyCppCoreGuidelinesModule.a  lib/libclangTidyBugproneModule.a  
lib/libclangAnalysisFlowSensitiveModels.a  lib/libclangAnalysisFlowSensitive.a  
lib/libclangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  
lib/libclangTidyLLVMModule.a  lib/libclangTidyLLVMLibcModule.a  
lib/libclangTidyMiscModule.a  lib/libclangIncludeCleaner.a  
lib/libclangToolingInclusionsStdlib.a  lib/libclangTidyModernizeModule.a  
lib/libclangTidyObjCModule.a  lib/libclangTidyOpenMPModule.a  
lib/libclangTidyPerformanceModule.a  lib/libclangTidyPortabilityModule.a  
lib/libclangTidyReadabilityModule.a  lib/libclangTidyZirconModule.a  
lib/libclangTidyMPIModule.a  lib/libclangTidyUtils.a  lib/libclangTidy.a  
lib/libclangTooling.a  lib/libclangStaticAnalyzerFrontend.a  
lib/libclangTransformer.a  lib/libclangToolingRefactoring.a  
lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  
lib/libclangCrossTU.a  lib/libclangIndex.a  lib/libclangFrontend.a  
lib/libclangDriver.a  lib/libLLVMWindowsDriver.a  lib/libclangParse.a  
lib/libLLVMOption.a  lib/libclangSerialization.a  lib/libclangSema.a  
lib/libclangAPINotes.a  lib/libclangEdit.a  lib/libclangAnalysis.a  
lib/libclangASTMatchers.a  lib/libclangAST.a  lib/libclangSupport.a  
lib/libLLVMFrontendHLSL.a  lib/libclangFormat.a  
lib/libclangToolingInclusions.a  lib/libclangToolingCore.a  
lib/libclangRewrite.a  lib/libclangLex.a  lib/libclangBasic.

[clang] [CIR] Upstream support for promoted types with unary plus/minus (PR #133829)

2025-04-03 Thread Bruno Cardoso Lopes via cfe-commits


@@ -405,3 +405,45 @@ float fpPostInc2() {
 // OGCG:   store float %[[A_INC]], ptr %[[A]], align 4
 // OGCG:   store float %[[A_LOAD]], ptr %[[B]], align 4
 // OGCG:   %[[B_TO_OUTPUT:.*]] = load float, ptr %[[B]], align 4
+
+_Float16 fp16UPlus(_Float16 f) {
+  return +f;
+}
+
+// CHECK: cir.func @fp16UPlus({{.*}}) -> !cir.f16
+// CHECK:   %[[INPUT:.*]] = cir.load %[[F:.*]]
+// CHECK:   %[[PROMOTED:.*]] = cir.cast(floating, %[[INPUT]] : !cir.f16), 
!cir.float

bcardosolopes wrote:

> Long term, I think we have at least two options

Both (1) and (2) have different design tradeoffs and my experience has been 
that it varies depending on the use case in question. For this specific case, 
I'd say that if the promotions aren't crucial for analysis on top of CIR (right 
now), I'd defer the details to LLVM, staying with (1) - note that here the 
operation itself wraps the semantic, because it contains enough info for you to 
lower things properly later on. In case you can see the explicit promotions 
being helpful for other things (random speculative example: callconv lowering) 
then it might be worth doing (2). Either way, implementation experience will 
tell if you should move from one to the other approach over time - in CIR so 
far we've come back n forth with some design as part of evolving things over 
time.

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


[clang] [llvm] [NVPTX] Auto-Upgrade llvm.nvvm.atomic.load.{inc,dec}.32 (PR #134111)

2025-04-03 Thread Akshay Deodhar via cfe-commits


@@ -2070,8 +2070,8 @@ defm INT_PTX_ATOMIC_UMIN_32 : F_ATOMIC_2_AS]>;
 
 // atom_inc  atom_dec

akshayrdeodhar wrote:

We don't have a PTX test to prove that the final lowering to PTX will be the 
same, but this looks good enough.

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


[clang] [llvm] [NVPTX] Auto-Upgrade llvm.nvvm.atomic.load.{inc,dec}.32 (PR #134111)

2025-04-03 Thread Akshay Deodhar via cfe-commits

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

LGTM! Comments are just questions.

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


[clang] [llvm] [NVPTX] Auto-Upgrade llvm.nvvm.atomic.load.{inc,dec}.32 (PR #134111)

2025-04-03 Thread Akshay Deodhar via cfe-commits

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


[clang] [clang-tools-extra] [clang] NFC: introduce UnsignedOrNone as a replacement for std::optional (PR #134142)

2025-04-03 Thread Matheus Izvekov via cfe-commits

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


[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)

2025-04-03 Thread Fangrui Song via cfe-commits

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


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


[clang] Headers: prefer `corecrt_malloc.h` to `malloc.h` (PR #131668)

2025-04-03 Thread Saleem Abdulrasool via cfe-commits

compnerd wrote:

I don't think that this fully fixes the issue as it doesn't completely break 
the cycle.

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


[clang-tools-extra] [clang-doc][NFC] refactor out file helpers (PR #134298)

2025-04-03 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/134298

>From fa35468f673ace035036a1c15d2d6ab756c2581e Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 3 Apr 2025 15:59:34 -0400
Subject: [PATCH 1/2] factor out file helpers

---
 clang-tools-extra/clang-doc/CMakeLists.txt|  2 +
 clang-tools-extra/clang-doc/HTMLGenerator.cpp | 18 +
 .../clang-doc/support/CMakeLists.txt  |  9 +++
 clang-tools-extra/clang-doc/support/File.cpp  | 74 +++
 clang-tools-extra/clang-doc/support/File.h| 26 +++
 5 files changed, 112 insertions(+), 17 deletions(-)
 create mode 100644 clang-tools-extra/clang-doc/support/CMakeLists.txt
 create mode 100644 clang-tools-extra/clang-doc/support/File.cpp
 create mode 100644 clang-tools-extra/clang-doc/support/File.h

diff --git a/clang-tools-extra/clang-doc/CMakeLists.txt 
b/clang-tools-extra/clang-doc/CMakeLists.txt
index 520fe58cbe68e..f4f62c74d6592 100644
--- a/clang-tools-extra/clang-doc/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   BitstreamReader
   FrontendOpenMP
   )
+add_subdirectory(support)
 
 add_clang_library(clangDoc STATIC
   BitcodeReader.cpp
@@ -23,6 +24,7 @@ add_clang_library(clangDoc STATIC
 
 clang_target_link_libraries(clangDoc
   PRIVATE
+  clangDocSupport
   clangAnalysis
   clangAST
   clangASTMatchers
diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 18a0de826630c..49ccffa0d2269 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -8,6 +8,7 @@
 
 #include "Generators.h"
 #include "Representation.h"
+#include "support/File.h"
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -1146,23 +1147,6 @@ static llvm::Error genIndex(const ClangDocContext 
&CDCtx) {
   return llvm::Error::success();
 }
 
-static llvm::Error copyFile(StringRef FilePath, StringRef OutDirectory) {
-  llvm::SmallString<128> PathWrite;
-  llvm::sys::path::native(OutDirectory, PathWrite);
-  llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
-  llvm::SmallString<128> PathRead;
-  llvm::sys::path::native(FilePath, PathRead);
-  std::error_code OK;
-  std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
-  if (FileErr != OK) {
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "error creating file " +
-   llvm::sys::path::filename(FilePath) +
-   ": " + FileErr.message() + "\n");
-  }
-  return llvm::Error::success();
-}
-
 llvm::Error HTMLGenerator::createResources(ClangDocContext &CDCtx) {
   auto Err = serializeIndex(CDCtx);
   if (Err)
diff --git a/clang-tools-extra/clang-doc/support/CMakeLists.txt 
b/clang-tools-extra/clang-doc/support/CMakeLists.txt
new file mode 100644
index 0..a4f7993d5c9d8
--- /dev/null
+++ b/clang-tools-extra/clang-doc/support/CMakeLists.txt
@@ -0,0 +1,9 @@
+# clang-doc/support contains support libraries that do not depend
+# on clang either programmatically or conceptually.
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_library(clangDocSupport STATIC
+  File.cpp
+  )
\ No newline at end of file
diff --git a/clang-tools-extra/clang-doc/support/File.cpp 
b/clang-tools-extra/clang-doc/support/File.cpp
new file mode 100644
index 0..a9162bee8cd70
--- /dev/null
+++ b/clang-tools-extra/clang-doc/support/File.cpp
@@ -0,0 +1,74 @@
+//===-- FileHelpersClangDoc.cpp - File Helpers ---*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "File.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+namespace clang {
+namespace doc {
+
+llvm::Error
+copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory) {
+  llvm::SmallString<128> PathWrite;
+  llvm::sys::path::native(OutDirectory, PathWrite);
+  llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
+  llvm::SmallString<128> PathRead;
+  llvm::sys::path::native(FilePath, PathRead);
+  std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
+  if (FileErr) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "error creating file " +
+   llvm::sys::path::filename(FilePath) +
+   ": " + FileErr.message() + "\n");
+  }
+  return llvm::Error::success();
+}
+
+
+llvm::SmallString<128> computeRelativePath(llvm::StringRef Destination,
+  

[clang-tools-extra] [clang-doc][NFC] refactor out file helpers (PR #134298)

2025-04-03 Thread via cfe-commits

https://github.com/PeterChou1 created 
https://github.com/llvm/llvm-project/pull/134298

Split from https://github.com/llvm/llvm-project/pull/133161

refactor the code to extract file helpers used in HTML generators for use in 
other generators for clang-doc

>From fa35468f673ace035036a1c15d2d6ab756c2581e Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 3 Apr 2025 15:59:34 -0400
Subject: [PATCH] factor out file helpers

---
 clang-tools-extra/clang-doc/CMakeLists.txt|  2 +
 clang-tools-extra/clang-doc/HTMLGenerator.cpp | 18 +
 .../clang-doc/support/CMakeLists.txt  |  9 +++
 clang-tools-extra/clang-doc/support/File.cpp  | 74 +++
 clang-tools-extra/clang-doc/support/File.h| 26 +++
 5 files changed, 112 insertions(+), 17 deletions(-)
 create mode 100644 clang-tools-extra/clang-doc/support/CMakeLists.txt
 create mode 100644 clang-tools-extra/clang-doc/support/File.cpp
 create mode 100644 clang-tools-extra/clang-doc/support/File.h

diff --git a/clang-tools-extra/clang-doc/CMakeLists.txt 
b/clang-tools-extra/clang-doc/CMakeLists.txt
index 520fe58cbe68e..f4f62c74d6592 100644
--- a/clang-tools-extra/clang-doc/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   BitstreamReader
   FrontendOpenMP
   )
+add_subdirectory(support)
 
 add_clang_library(clangDoc STATIC
   BitcodeReader.cpp
@@ -23,6 +24,7 @@ add_clang_library(clangDoc STATIC
 
 clang_target_link_libraries(clangDoc
   PRIVATE
+  clangDocSupport
   clangAnalysis
   clangAST
   clangASTMatchers
diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 18a0de826630c..49ccffa0d2269 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -8,6 +8,7 @@
 
 #include "Generators.h"
 #include "Representation.h"
+#include "support/File.h"
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -1146,23 +1147,6 @@ static llvm::Error genIndex(const ClangDocContext 
&CDCtx) {
   return llvm::Error::success();
 }
 
-static llvm::Error copyFile(StringRef FilePath, StringRef OutDirectory) {
-  llvm::SmallString<128> PathWrite;
-  llvm::sys::path::native(OutDirectory, PathWrite);
-  llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
-  llvm::SmallString<128> PathRead;
-  llvm::sys::path::native(FilePath, PathRead);
-  std::error_code OK;
-  std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
-  if (FileErr != OK) {
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "error creating file " +
-   llvm::sys::path::filename(FilePath) +
-   ": " + FileErr.message() + "\n");
-  }
-  return llvm::Error::success();
-}
-
 llvm::Error HTMLGenerator::createResources(ClangDocContext &CDCtx) {
   auto Err = serializeIndex(CDCtx);
   if (Err)
diff --git a/clang-tools-extra/clang-doc/support/CMakeLists.txt 
b/clang-tools-extra/clang-doc/support/CMakeLists.txt
new file mode 100644
index 0..a4f7993d5c9d8
--- /dev/null
+++ b/clang-tools-extra/clang-doc/support/CMakeLists.txt
@@ -0,0 +1,9 @@
+# clang-doc/support contains support libraries that do not depend
+# on clang either programmatically or conceptually.
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_library(clangDocSupport STATIC
+  File.cpp
+  )
\ No newline at end of file
diff --git a/clang-tools-extra/clang-doc/support/File.cpp 
b/clang-tools-extra/clang-doc/support/File.cpp
new file mode 100644
index 0..a9162bee8cd70
--- /dev/null
+++ b/clang-tools-extra/clang-doc/support/File.cpp
@@ -0,0 +1,74 @@
+//===-- FileHelpersClangDoc.cpp - File Helpers ---*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "File.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+namespace clang {
+namespace doc {
+
+llvm::Error
+copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory) {
+  llvm::SmallString<128> PathWrite;
+  llvm::sys::path::native(OutDirectory, PathWrite);
+  llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
+  llvm::SmallString<128> PathRead;
+  llvm::sys::path::native(FilePath, PathRead);
+  std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
+  if (FileErr) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "error creating file " +
+   llvm::sys::path::filename(FilePath) +
+   ": " + FileErr.me

[clang-tools-extra] [clang-doc][NFC] refactor out file helpers (PR #134298)

2025-04-03 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- 
clang-tools-extra/clang-doc/support/File.cpp 
clang-tools-extra/clang-doc/support/File.h 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/clang-doc/support/File.cpp 
b/clang-tools-extra/clang-doc/support/File.cpp
index a9162bee8..b1fe6f6d8 100644
--- a/clang-tools-extra/clang-doc/support/File.cpp
+++ b/clang-tools-extra/clang-doc/support/File.cpp
@@ -12,8 +12,7 @@
 namespace clang {
 namespace doc {
 
-llvm::Error
-copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory) {
+llvm::Error copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory) {
   llvm::SmallString<128> PathWrite;
   llvm::sys::path::native(OutDirectory, PathWrite);
   llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
@@ -29,14 +28,13 @@ copyFile(llvm::StringRef FilePath, llvm::StringRef 
OutDirectory) {
   return llvm::Error::success();
 }
 
-
 llvm::SmallString<128> computeRelativePath(llvm::StringRef Destination,
llvm::StringRef Origin) {
   // If Origin is empty, the relative path to the Destination is its complete
   // path.
   if (Origin.empty())
 return Destination;
-  
+
   // The relative path is an empty path if both directories are the same.
   if (Destination == Origin)
 return {};
diff --git a/clang-tools-extra/clang-doc/support/File.h 
b/clang-tools-extra/clang-doc/support/File.h
index fc52d185a..828da7df3 100644
--- a/clang-tools-extra/clang-doc/support/File.h
+++ b/clang-tools-extra/clang-doc/support/File.h
@@ -14,11 +14,10 @@
 namespace clang {
 namespace doc {
 
-llvm::Error 
-copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory);
+llvm::Error copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory);
 
-llvm::SmallString<128> 
-computeRelativePath(llvm::StringRef Destination,llvm::StringRef Origin);
+llvm::SmallString<128> computeRelativePath(llvm::StringRef Destination,
+   llvm::StringRef Origin);
 
 } // namespace doc
 } // namespace clang

``




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


[clang] [clang][modules] Lazily load by name lookups in module maps (PR #132853)

2025-04-03 Thread Michael Spencer via cfe-commits

Bigcheese wrote:

> This now makes much more sense after the renames from the prep-commit. There 
> are still some naming inconsistencies, though. For example 
> `ModuleMap::loadModuleMapFile()` both **parses** and loads a module map file, 
> but `ModuleMap::findOrLoadModule()` expects the module map file to be already 
> parsed and only loads the module. I think there's value in making this 
> distinction more explicit. Maybe we could say that loading a module/module 
> map file consists of parsing and _materializing_? No we can consistently name 
> functions that do one, the other, or both.

I don't think I want all 3 concepts as that's more mental complexity without 
much benefit. I view it as `loadModuleMapFile` takes a path and thus 
necessarily parses before loading. Could call it `parseAndLoadModuleMapFile`, 
but that's pretty long. 

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


[clang-tools-extra] [clang-doc][NFC] refactor out file helpers (PR #134298)

2025-04-03 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/134298

>From fa35468f673ace035036a1c15d2d6ab756c2581e Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 3 Apr 2025 15:59:34 -0400
Subject: [PATCH 1/5] factor out file helpers

---
 clang-tools-extra/clang-doc/CMakeLists.txt|  2 +
 clang-tools-extra/clang-doc/HTMLGenerator.cpp | 18 +
 .../clang-doc/support/CMakeLists.txt  |  9 +++
 clang-tools-extra/clang-doc/support/File.cpp  | 74 +++
 clang-tools-extra/clang-doc/support/File.h| 26 +++
 5 files changed, 112 insertions(+), 17 deletions(-)
 create mode 100644 clang-tools-extra/clang-doc/support/CMakeLists.txt
 create mode 100644 clang-tools-extra/clang-doc/support/File.cpp
 create mode 100644 clang-tools-extra/clang-doc/support/File.h

diff --git a/clang-tools-extra/clang-doc/CMakeLists.txt 
b/clang-tools-extra/clang-doc/CMakeLists.txt
index 520fe58cbe68e..f4f62c74d6592 100644
--- a/clang-tools-extra/clang-doc/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   BitstreamReader
   FrontendOpenMP
   )
+add_subdirectory(support)
 
 add_clang_library(clangDoc STATIC
   BitcodeReader.cpp
@@ -23,6 +24,7 @@ add_clang_library(clangDoc STATIC
 
 clang_target_link_libraries(clangDoc
   PRIVATE
+  clangDocSupport
   clangAnalysis
   clangAST
   clangASTMatchers
diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 18a0de826630c..49ccffa0d2269 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -8,6 +8,7 @@
 
 #include "Generators.h"
 #include "Representation.h"
+#include "support/File.h"
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -1146,23 +1147,6 @@ static llvm::Error genIndex(const ClangDocContext 
&CDCtx) {
   return llvm::Error::success();
 }
 
-static llvm::Error copyFile(StringRef FilePath, StringRef OutDirectory) {
-  llvm::SmallString<128> PathWrite;
-  llvm::sys::path::native(OutDirectory, PathWrite);
-  llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
-  llvm::SmallString<128> PathRead;
-  llvm::sys::path::native(FilePath, PathRead);
-  std::error_code OK;
-  std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
-  if (FileErr != OK) {
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "error creating file " +
-   llvm::sys::path::filename(FilePath) +
-   ": " + FileErr.message() + "\n");
-  }
-  return llvm::Error::success();
-}
-
 llvm::Error HTMLGenerator::createResources(ClangDocContext &CDCtx) {
   auto Err = serializeIndex(CDCtx);
   if (Err)
diff --git a/clang-tools-extra/clang-doc/support/CMakeLists.txt 
b/clang-tools-extra/clang-doc/support/CMakeLists.txt
new file mode 100644
index 0..a4f7993d5c9d8
--- /dev/null
+++ b/clang-tools-extra/clang-doc/support/CMakeLists.txt
@@ -0,0 +1,9 @@
+# clang-doc/support contains support libraries that do not depend
+# on clang either programmatically or conceptually.
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_library(clangDocSupport STATIC
+  File.cpp
+  )
\ No newline at end of file
diff --git a/clang-tools-extra/clang-doc/support/File.cpp 
b/clang-tools-extra/clang-doc/support/File.cpp
new file mode 100644
index 0..a9162bee8cd70
--- /dev/null
+++ b/clang-tools-extra/clang-doc/support/File.cpp
@@ -0,0 +1,74 @@
+//===-- FileHelpersClangDoc.cpp - File Helpers ---*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "File.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+namespace clang {
+namespace doc {
+
+llvm::Error
+copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory) {
+  llvm::SmallString<128> PathWrite;
+  llvm::sys::path::native(OutDirectory, PathWrite);
+  llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
+  llvm::SmallString<128> PathRead;
+  llvm::sys::path::native(FilePath, PathRead);
+  std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
+  if (FileErr) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "error creating file " +
+   llvm::sys::path::filename(FilePath) +
+   ": " + FileErr.message() + "\n");
+  }
+  return llvm::Error::success();
+}
+
+
+llvm::SmallString<128> computeRelativePath(llvm::StringRef Destination,
+  

[clang] Revert "[HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr`" (PR #134273)

2025-04-03 Thread Finn Plummer via cfe-commits

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


[clang] [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (PR #134124)

2025-04-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`cross-project-tests-sie-ubuntu` running on `doug-worker-1a` while building 
`clang` at step 5 "build-unified-tree".

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


Here is the relevant piece of the build log for the reference

```
Step 5 (build-unified-tree) failure: build (failure)
...
1493.392 [90/8/859] Linking CXX static library lib/libclangTransformer.a
1493.401 [89/8/860] Linking CXX static library lib/libclangHandleCXX.a
1493.441 [88/8/861] Linking CXX static library lib/libclangStaticAnalyzerCore.a
1493.485 [87/8/862] Linking CXX executable bin/obj2yaml
1493.747 [86/8/863] Building CXX object 
tools/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeFiles/lldbPluginSystemRuntimeMacOSX.dir/AbortWithPayloadFrameRecognizer.cpp.o
1493.972 [85/8/864] Linking CXX static library 
lib/libclangStaticAnalyzerCheckers.a
1494.049 [84/8/865] Linking CXX executable bin/yaml2obj
1494.068 [83/8/866] Linking CXX static library 
lib/libclangStaticAnalyzerFrontend.a
1494.360 [82/8/867] Linking CXX executable bin/diagtool
1495.159 [81/8/868] Linking CXX executable bin/clang-diff
FAILED: bin/clang-diff 
: && /opt/ccache/bin/g++ -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG -fuse-ld=gold-Wl,--gc-sections 
tools/clang/tools/clang-diff/CMakeFiles/clang-diff.dir/ClangDiff.cpp.o -o 
bin/clang-diff  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  -lpthread  
lib/libclangBasic.a  lib/libclangFrontend.a  lib/libclangSerialization.a  
lib/libclangTooling.a  lib/libclangToolingASTDiff.a  lib/libclangFrontend.a  
lib/libclangParse.a  lib/libclangSerialization.a  lib/libclangSema.a  
lib/libclangAPINotes.a  lib/libclangEdit.a  lib/libclangAnalysis.a  
lib/libclangSupport.a  lib/libLLVMFrontendHLSL.a  lib/libclangDriver.a  
lib/libLLVMWindowsDriver.a  lib/libLLVMOption.a  lib/libclangASTMatchers.a  
lib/libclangFormat.a  lib/libclangToolingInclusions.a  
lib/libclangToolingCore.a  lib/libclangRewrite.a  lib/libclangAST.a  
lib/libclangLex.a  lib/libclangBasic.a  lib/libLLVMFrontendOpenMP.a  
lib/libLLVMScalarOpts.a  lib/libLLVMAggressiveInstCombine.a  
lib/libLLVMInstCombine.a  lib/libLLVMFrontendOffloading.a  
lib/libLLVMTransformUtils.a  lib/libLLVMObjectYAML.a  
lib/libLLVMFrontendAtomic.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  
lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoPDB.a  
lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  
lib/libLLVMDebugInfoBTF.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMObject.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMIRReader.a  
lib/libLLVMBitReader.a  lib/libLLVMAsmParser.a  lib/libLLVMTextAPI.a  
lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  
lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libLLVMSupport.a  
-lrt  -ldl  -lpthread  -lm  /usr/lib/x86_64-linux-gnu/libz.so  
lib/libLLVMDemangle.a && :
lib/libclangSema.a(SemaHLSL.cpp.o):SemaHLSL.cpp:function 
clang::SemaHLSL::handleRootSignatureAttr(clang::Decl*, clang::ParsedAttr 
const&): error: undefined reference to 
'clang::hlsl::RootSignatureParser::RootSignatureParser(llvm::SmallVector, 6u>&, 
clang::hlsl::RootSignatureLexer&, clang::Preprocessor&)'
lib/libclangSema.a(SemaHLSL.cpp.o):SemaHLSL.cpp:function 
clang::SemaHLSL::handleRootSignatureAttr(clang::Decl*, clang::ParsedAttr 
const&): error: undefined reference to 
'clang::hlsl::RootSignatureParser::parse()'
collect2: error: ld returned 1 exit status
1495.343 [81/7/869] Linking CXX shared library lib/libclang-cpp.so.21.0git
1495.446 [81/6/870] Linking CXX executable bin/clang-extdef-mapping
FAILED: bin/clang-extdef-mapping 
: && /opt/ccache/bin/g++ -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG -fuse-ld=gold-Wl,--gc-sections 
tools/clang/tools/clang-extdef-mapping/CMakeFiles/clang-extdef-mapping.dir/ClangExtDefMapGen.cpp.o
 -o bin/clang-extdef-mapping  -Wl,-rpath,"\$ORIGIN/../lib:"  
lib/libLLVMX86CodeGen.a  l

[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)

2025-04-03 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> most of them are safe

What's the distinguishing factor here?  Do you consider it "safe" to mark 
inbounds if the pointer is immediately dereferenced?  Or does the pointer have 
to refer to a known successful allocation?  Or something else?

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


[clang] 3f6ae3f - [flang] Added driver options for arrays repacking. (#134002)

2025-04-03 Thread via cfe-commits

Author: Slava Zakharin
Date: 2025-04-03T10:43:28-07:00
New Revision: 3f6ae3f0a81ac32aee7633b7c240ce8eb25192ff

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

LOG: [flang] Added driver options for arrays repacking. (#134002)

Added options:
  * -f[no-]repack-arrays
  * -f[no-]stack-repack-arrays
  * -frepack-arrays-contiguity=whole/innermost

Added: 
flang/test/Driver/frepack-arrays-contiguity.f90
flang/test/Driver/frepack-arrays.f90
flang/test/Driver/fstack-repack-arrays.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/docs/ArrayRepacking.md
flang/include/flang/Lower/LoweringOptions.def
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Lower/ConvertVariable.cpp
flang/test/Lower/repack-arrays.f90
flang/tools/bbc/bbc.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e69b804de63b5..2ca5f99e4ca63 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6825,7 +6825,6 @@ defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, 
Group;
 defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group;
 defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group;
 defm recursive : BooleanFFlag<"recursive">, Group;
-defm repack_arrays : BooleanFFlag<"repack-arrays">, Group;
 defm second_underscore : BooleanFFlag<"second-underscore">, 
Group;
 defm sign_zero : BooleanFFlag<"sign-zero">, Group;
 defm whole_file : BooleanFFlag<"whole-file">, Group;
@@ -6967,6 +6966,52 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables 
UNSIGNED type">;
 def fno_automatic : Flag<["-"], "fno-automatic">, Group,
   HelpText<"Implies the SAVE attribute for non-automatic local objects in 
subprograms unless RECURSIVE">;
 
+defm repack_arrays
+: BoolOptionWithoutMarshalling<
+  "f", "repack-arrays", PosFlag,
+  NegFlag,
+  BothFlags<[], [],
+" non-contiguous assumed shape dummy arrays into "
+"contiguous memory">>,
+  DocBrief<[{Create temporary copies of non-contiguous assumed shape dummy
+arrays in subprogram prologues, and destroy them in subprogram epilogues.
+The temporary copy is initialized with values from the original array
+in the prologue, if needed. In the epilogue, the current values
+in the temporary array are copied into the original array, if needed.
+
+Accessing the contiguous temporary in the program code may result
+in faster execution comparing to accessing elements of the original array,
+when they are sparse in memory. At the same time, the overhead
+of copying values between the original and the temporary arrays
+may be significant, which may slow down some programs.
+
+Enabling array repacking may also change the behavior of certain
+programs:
+
+* The copy actions may introduce a data race in valid OpenACC/OpenMP programs.
+  For example, if 
diff erent threads execute the same subprogram
+  with a non-contiguous assumed shape dummy array, and the 
diff erent threads
+  access unrelated parts of the array, then the whole array copy
+  made in each thread will cause a data race.
+* OpenACC/OpenMP offload programs may behave incorrectly with regards
+  to the device data environment, due to the fact that the original
+  array and the temporary may have 
diff erent presence status on the device.
+* ``IS_CONTIGUOUS`` intrinsic may return ``TRUE`` with the array repacking
+  enabled, whereas if would return ``FALSE`` with the repacking disabled.
+* The result of ``LOC`` intrinsic applied to an actual argument associated
+  with a non-contiguous assumed shape dummy array, may be 
diff erent
+  from the result of ``LOC`` applied to the dummy array.}]>;
+
+def frepack_arrays_contiguity_EQ
+: Joined<["-"], "frepack-arrays-contiguity=">,
+  Group,
+  Values<"whole,innermost">,
+  HelpText<
+  "When -frepack-arrays is in effect, 'whole' enables "
+  "repacking for arrays that are non-contiguous in any dimension, "
+  "'innermost' enables repacking for arrays that are non-contiguous "
+  "in the innermost dimension (the default)">;
+
 defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program",
   PosFlag,
@@ -6980,6 +7025,22 @@ defm loop_versioning : BoolOptionWithoutMarshalling<"f", 
"version-loops-for-stri
   PosFlag,
NegFlag>;
 
+defm stack_repack_arrays
+: BoolOptionWithoutMarshalling<
+  "f", "stack-repack-arrays",
+  PosFlag,
+  NegFlag<
+  SetFalse, [], [],
+  "Allocate -frepack-arrays temporaries on the heap (default)">>,
+  DocBrief<[{Controls whether the array temporaries created under
+**-frepack-arrays

[clang] [CIR] Upstream support for promoted types with unary plus/minus (PR #133829)

2025-04-03 Thread Bruno Cardoso Lopes via cfe-commits


@@ -405,3 +405,45 @@ float fpPostInc2() {
 // OGCG:   store float %[[A_INC]], ptr %[[A]], align 4
 // OGCG:   store float %[[A_LOAD]], ptr %[[B]], align 4
 // OGCG:   %[[B_TO_OUTPUT:.*]] = load float, ptr %[[B]], align 4
+
+_Float16 fp16UPlus(_Float16 f) {
+  return +f;
+}
+
+// CHECK: cir.func @fp16UPlus({{.*}}) -> !cir.f16
+// CHECK:   %[[INPUT:.*]] = cir.load %[[F:.*]]
+// CHECK:   %[[PROMOTED:.*]] = cir.cast(floating, %[[INPUT]] : !cir.f16), 
!cir.float

bcardosolopes wrote:

> When you say, "land the direct version first," do you mean proceed with this 
> PR as is? That seems reasonable to me. I just wanted to make sure we're all 
> in agreement.

Yes!

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


[clang] [-Wunsafe-buffer-usage] Fix false positives for string literals (PR #115554)

2025-04-03 Thread Malavika Samak via cfe-commits

malavikasamak wrote:

I think we can close this PR, since we already merged this as part of 
https://github.com/llvm/llvm-project/pull/115552

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


[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)

2025-04-03 Thread Slava Zakharin via cfe-commits

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


[clang] [CIR] Upstream support for break and continue statements (PR #134181)

2025-04-03 Thread Bruno Cardoso Lopes via cfe-commits


@@ -265,3 +265,125 @@ void test_empty_while_true() {
 // OGCG:   br label %[[WHILE_BODY:.*]]
 // OGCG: [[WHILE_BODY]]:
 // OGCG:   ret void
+
+void unreachable_after_continue() {
+  for (;;) {
+continue;
+int x = 1;
+  }
+}
+
+// CIR: cir.func @unreachable_after_continue
+// CIR:   cir.scope {
+// CIR: cir.for : cond {
+// CIR:   %[[TRUE:.*]] = cir.const #true
+// CIR:   cir.condition(%[[TRUE]])
+// CIR: } body {
+// CIR:   cir.scope {
+// CIR: %[[X:.*]] = cir.alloca !s32i, !cir.ptr, ["x", init] 
{alignment = 4 : i64}
+// CIR: cir.continue
+// CIR:   ^bb1:  // no predecessors
+// CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store %[[ONE]], %[[X]] : !s32i, !cir.ptr
+// CIR: cir.yield
+// CIR:   }
+// CIR:   cir.yield
+// CIR: } step {
+// CIR:   cir.yield
+// CIR: }
+// CIR:   }
+// CIR:   cir.return
+// CIR: }
+
+// LLVM: define void @unreachable_after_continue()

bcardosolopes wrote:

https://godbolt.org/z/dj67e1dME

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


[clang] [CIR] Upstream support for break and continue statements (PR #134181)

2025-04-03 Thread Erich Keane via cfe-commits


@@ -265,3 +265,125 @@ void test_empty_while_true() {
 // OGCG:   br label %[[WHILE_BODY:.*]]
 // OGCG: [[WHILE_BODY]]:
 // OGCG:   ret void
+
+void unreachable_after_continue() {
+  for (;;) {
+continue;
+int x = 1;
+  }
+}
+
+// CIR: cir.func @unreachable_after_continue
+// CIR:   cir.scope {
+// CIR: cir.for : cond {
+// CIR:   %[[TRUE:.*]] = cir.const #true
+// CIR:   cir.condition(%[[TRUE]])
+// CIR: } body {
+// CIR:   cir.scope {
+// CIR: %[[X:.*]] = cir.alloca !s32i, !cir.ptr, ["x", init] 
{alignment = 4 : i64}
+// CIR: cir.continue
+// CIR:   ^bb1:  // no predecessors
+// CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store %[[ONE]], %[[X]] : !s32i, !cir.ptr
+// CIR: cir.yield
+// CIR:   }
+// CIR:   cir.yield
+// CIR: } step {
+// CIR:   cir.yield
+// CIR: }
+// CIR:   }
+// CIR:   cir.return
+// CIR: }
+
+// LLVM: define void @unreachable_after_continue()

erichkeane wrote:

Oh, ooof that is hideous.  But looks like it works at least.

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


[clang] [llvm] [DirectX] Implement UseNativeLowPrecision shader flag analysis (PR #134288)

2025-04-03 Thread Deric C. via cfe-commits

https://github.com/Icohedron created 
https://github.com/llvm/llvm-project/pull/134288

Fixes #112267 


>From c482c96c99ab76458904b3f94b1146ccfee0f55c Mon Sep 17 00:00:00 2001
From: Icohedron 
Date: Wed, 2 Apr 2025 21:16:16 +
Subject: [PATCH 1/2] Add test for UseNativeLowPrecision shader flag

---
 .../ShaderFlags/use-native-low-precision.ll   | 45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 
llvm/test/CodeGen/DirectX/ShaderFlags/use-native-low-precision.ll

diff --git a/llvm/test/CodeGen/DirectX/ShaderFlags/use-native-low-precision.ll 
b/llvm/test/CodeGen/DirectX/ShaderFlags/use-native-low-precision.ll
new file mode 100644
index 0..95c916b169cdf
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/ShaderFlags/use-native-low-precision.ll
@@ -0,0 +1,45 @@
+; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
+; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
+
+target triple = "dxil-pc-shadermodel6.7-library"
+
+;CHECK: ; Combined Shader Flags for Module
+;CHECK-NEXT: ; Shader Flags Value: 0x00800020
+;CHECK-NEXT: ;
+;CHECK-NEXT: ; Note: shader requires additional functionality:
+;CHECK-NEXT: ; Note: extra DXIL module flags:
+;CHECK-NEXT: ;   D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
+;CHECK-NEXT: ;   Native 16bit types enabled
+;CHECK-NEXT: ;
+;CHECK-NEXT: ; Shader Flags for Module Functions
+
+;CHECK-LABEL: ; Function add_i16 : 0x00800020
+define i16 @add_i16(i16 %a, i16 %b) #0 {
+  %sum = add i16 %a, %b
+  ret i16 %sum
+}
+
+; NOTE: The flag for native low precision is set for every function in the
+; module regardless of whether or not the function uses low precision data
+; types. This matches the behavior in DXC
+;CHECK-LABEL: ; Function add_i32 : 0x0080
+define i32 @add_i32(i32 %a, i32 %b) #0 {
+  %sum = add i32 %a, %b
+  ret i32 %sum
+}
+
+;CHECK-LABEL: ; Function add_half : 0x00800020
+define half @add_half(half %a, half %b) #0 {
+  %sum = fadd half %a, %b
+  ret half %sum
+}
+
+attributes #0 = { convergent norecurse nounwind "hlsl.export" }
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"dx.nativelowprec", i32 1}
+
+; DXC: - Name:SFI0
+; DXC-NEXT: Size:8
+; DXC-NOT: Flags:
+; DXC: ...

>From 1d90753f91b62cd6c5a72f7855ad88a45fe6f16d Mon Sep 17 00:00:00 2001
From: Icohedron 
Date: Thu, 3 Apr 2025 16:24:32 +
Subject: [PATCH 2/2] Implement UseNativeLowPrecision shader flag analysis

---
 clang/lib/CodeGen/CGHLSLRuntime.cpp| 3 +++
 clang/test/CodeGenHLSL/enable-16bit-types.hlsl | 9 +
 llvm/lib/Target/DirectX/DXILShaderFlags.cpp| 6 ++
 3 files changed, 18 insertions(+)
 create mode 100644 clang/test/CodeGenHLSL/enable-16bit-types.hlsl

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 3b1810b62a2cd..ca5f180d2a64c 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -282,10 +282,13 @@ void CGHLSLRuntime::addHLSLBufferLayoutType(const 
RecordType *StructType,
 
 void CGHLSLRuntime::finishCodeGen() {
   auto &TargetOpts = CGM.getTarget().getTargetOpts();
+  auto &LangOpts = CGM.getLangOpts();
   llvm::Module &M = CGM.getModule();
   Triple T(M.getTargetTriple());
   if (T.getArch() == Triple::ArchType::dxil)
 addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
+  if (LangOpts.NativeHalfType)
+M.setModuleFlag(llvm::Module::ModFlagBehavior::Error, "dx.nativelowprec", 
1);
 
   generateGlobalCtorDtorCalls();
 }
diff --git a/clang/test/CodeGenHLSL/enable-16bit-types.hlsl 
b/clang/test/CodeGenHLSL/enable-16bit-types.hlsl
new file mode 100644
index 0..7da66a3ed863b
--- /dev/null
+++ b/clang/test/CodeGenHLSL/enable-16bit-types.hlsl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fnative-half-type -finclude-default-header -triple 
dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s --check-prefix=FLAG
+// RUN: %clang_cc1 -finclude-default-header -triple 
dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s --check-prefix=NOFLAG
+
+// NOTE: -enable-16bit-types is a DXCFlag that aliases -fnative-half-type
+
+// FLAG-DAG: ![[NLP:.*]] = !{i32 1, !"dx.nativelowprec", i32 1}
+// FLAG-DAG: !llvm.module.flags = !{{{.*}}![[NLP]]{{.*}}}
+
+// NOFLAG-NOT: dx.nativelowprec
diff --git a/llvm/lib/Target/DirectX/DXILShaderFlags.cpp 
b/llvm/lib/Target/DirectX/DXILShaderFlags.cpp
index babf495220393..437d1402ccedc 100644
--- a/llvm/lib/Target/DirectX/DXILShaderFlags.cpp
+++ b/llvm/lib/Target/DirectX/DXILShaderFlags.cpp
@@ -188,6 +188,12 @@ void ModuleShaderFlags::initialize(Module &M, 
DXILResourceTypeMap &DRTM,
 continue;
   }
 
+  // Set UseNativeLowPrecision using dx.nativelowprec module metadata
+  if (auto *NativeLowPrec = mdconst::extract_or_null(
+  M.getModuleFlag("dx.nativelowprec")))
+if (NativeLowPrec->getValue() != 0)
+  SCCSF.UseNativeLowPreci

[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)

2025-04-03 Thread via cfe-commits

SunilKuravinakop wrote:


> You can see 2 CpaturedStmt here - one for outer task region (outermost one) 
> and one for the actual target region (the innermost one). You need to do 
> something similar for dispatch

I have done a commit where -ast-dump works now. CodeGen is still failing for 
`EmitIfElse` . Please give me a feedback if I am doing it correctly. 

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


[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)

2025-04-03 Thread Zahira Ammarguellat via cfe-commits


@@ -260,7 +260,7 @@ static IntegerRange createFromType(const ASTContext 
&Context,
 llvm::APSInt LowerValue(PrecisionBits + 2, /*isUnsigned*/ false);
 LowerValue.setBit(PrecisionBits);
 LowerValue.setSignBit();
-return {LowerValue, UpperValue};
+return {std::move(LowerValue), UpperValue};

zahiraam wrote:

Do you think this should be reverted?

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


[clang] [flang] [Flang][Driver][AMDGPU] Fix -mcode-object-version (PR #134230)

2025-04-03 Thread Sergio Afonso via cfe-commits

https://github.com/skatrak updated 
https://github.com/llvm/llvm-project/pull/134230

>From 5a3bf580e8c22b9813c082d1249b9b99823241f1 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Wed, 2 Apr 2025 16:34:38 +0100
Subject: [PATCH] [Flang][OpenMP][Driver][AMDGPU] Fix -mcode-object-version

This patch updates flang to follow clang's behavior when processing the
`-mcode-object-version option`.

It is now used to populate an LLVM module flag called
`amdhsa_code_object_version` expected by the backend and also updates the
driver to add the `--amdhsa-code-object-version` option to the frontend
invocation for device compilation of AMDGPU targets.
---
 clang/lib/Driver/ToolChains/Flang.cpp |  3 +++
 flang/include/flang/Frontend/CodeGenOptions.h |  2 +-
 flang/lib/Frontend/FrontendActions.cpp| 11 ++
 flang/test/Driver/code-object-version.f90 |  7 ++
 .../amdgpu-code-object-version.f90| 22 +++
 5 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Integration/amdgpu-code-object-version.f90

diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 8312234e33a64..82d5201e4f337 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -410,6 +410,9 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args,
   if (Arg *A = Args.getLastArg(options::OPT_mcode_object_version_EQ)) {
 StringRef Val = A->getValue();
 CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val));
+CmdArgs.push_back(Args.MakeArgString("-mllvm"));
+CmdArgs.push_back(
+Args.MakeArgString("--amdhsa-code-object-version=" + Val));
   }
 
   const ToolChain &TC = getToolChain();
diff --git a/flang/include/flang/Frontend/CodeGenOptions.h 
b/flang/include/flang/Frontend/CodeGenOptions.h
index 23d99e1f0897a..2b4e823b3fef4 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.h
+++ b/flang/include/flang/Frontend/CodeGenOptions.h
@@ -95,7 +95,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
   /// \brief Code object version for AMDGPU.
   llvm::CodeObjectVersionKind CodeObjectVersion =
-  llvm::CodeObjectVersionKind::COV_5;
+  llvm::CodeObjectVersionKind::COV_None;
 
   /// Optimization remark with an optional regular expression pattern.
   struct OptRemark {
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index bd2c0632cb35d..d304e74f34f5c 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -804,6 +804,17 @@ void CodeGenAction::generateLLVMIR() {
 llvmModule->addModuleFlag(
 llvm::Module::Error, "target-abi",
 llvm::MDString::get(llvmModule->getContext(), targetOpts.abi));
+
+  if (triple.isAMDGPU() ||
+  (triple.isSPIRV() && triple.getVendor() == llvm::Triple::AMD)) {
+// Emit amdhsa_code_object_version module flag, which is code object 
version
+// times 100.
+if (opts.CodeObjectVersion != llvm::CodeObjectVersionKind::COV_None) {
+  llvmModule->addModuleFlag(llvm::Module::Error,
+"amdhsa_code_object_version",
+opts.CodeObjectVersion);
+}
+  }
 }
 
 static std::unique_ptr
diff --git a/flang/test/Driver/code-object-version.f90 
b/flang/test/Driver/code-object-version.f90
index e10877563c4d0..430cc864d03ec 100644
--- a/flang/test/Driver/code-object-version.f90
+++ b/flang/test/Driver/code-object-version.f90
@@ -5,5 +5,12 @@
 ! RUN: %flang  -target  x86_64-unknown-linux-gnu -mcode-object-version=3  -S  
%s -o \
 ! RUN:   /dev/null 2>&1 | FileCheck  --check-prefix=UNUSED_PARAM %s
 
+! RUN: %flang -target amdgcn-amd-amdhsa -mcpu=gfx908 -mcode-object-version=5 
-nogpulib -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=VALID_USE
+
 ! INVALID_VERSION: error: invalid integral value '3' in 
'-mcode-object-version=3'
 ! UNUSED_PARAM: warning: argument unused during compilation: 
'-mcode-object-version=3' [-Wunused-command-line-argument]
+
+! VALID_USE: "-fc1" "-triple" "amdgcn-amd-amdhsa"
+! VALID_USE-SAME: "-mcode-object-version=5"
+! VALID_USE-SAME: "-mllvm" "--amdhsa-code-object-version=5"
diff --git a/flang/test/Integration/amdgpu-code-object-version.f90 
b/flang/test/Integration/amdgpu-code-object-version.f90
new file mode 100644
index 0..c5194d2007f2a
--- /dev/null
+++ b/flang/test/Integration/amdgpu-code-object-version.f90
@@ -0,0 +1,22 @@
+!REQUIRES: amdgpu-registered-target
+
+!RUN: %flang_fc1 -emit-llvm -triple amdgcn-amd-amdhsa -target-cpu gfx908 %s -o 
- | FileCheck --check-prefix=COV-DEFAULT %s
+!RUN: %flang_fc1 -emit-llvm -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-mcode-object-version=none %s -o - | FileCheck --check-prefix=COV-NONE %s
+!RUN: %flang_fc1 -emit-llvm -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-mcode-object-version=4 %s -o - | FileCheck --check-prefix=COV-4 %s
+!RUN: %flang_fc1 -emit-llvm -triple am

[clang] [Clang] Fix unnecessary extra return block emmited during function epilog after musttail call (PR #134282)

2025-04-03 Thread Eli Friedman via cfe-commits


@@ -1491,7 +1491,10 @@ void CodeGenFunction::EmitComplexExprIntoLValue(const 
Expr *E, LValue dest,
  "Invalid complex expression to emit");
   ComplexExprEmitter Emitter(*this);
   ComplexPairTy Val = Emitter.Visit(const_cast(E));
-  Emitter.EmitStoreOfComplex(Val, dest, isInit);
+  // The insert point may be empty if we have just emmited a

efriedma-quic wrote:

```suggestion
  // The insert point may be empty if we have just emitted a
```

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


[clang] [llvm] [clang][IR] Overload @llvm.thread.pointer to support non-AS0 targets (PR #132489)

2025-04-03 Thread Jessica Clarke via cfe-commits

jrtc27 wrote:

Ping

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


[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)

2025-04-03 Thread Zahira Ammarguellat via cfe-commits


@@ -260,7 +260,7 @@ static IntegerRange createFromType(const ASTContext 
&Context,
 llvm::APSInt LowerValue(PrecisionBits + 2, /*isUnsigned*/ false);
 LowerValue.setBit(PrecisionBits);
 LowerValue.setSignBit();
-return {LowerValue, UpperValue};
+return {std::move(LowerValue), UpperValue};

zahiraam wrote:

> this doesn't have any impact. And if using move, why not for a second too

Good point.  I was only addressing the issues that the sanitizer identified.

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


[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-04-03 Thread Ashley Coleman via cfe-commits

https://github.com/V-FEXrt approved this pull request.


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


[clang] [Clang] Fix unnecessary extra return block emmited during function epilog after musttail call (PR #134282)

2025-04-03 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic commented:

There's a comment in CodeGenFunction::EmitReturnBlock that says:

```
  // FIXME: We are at an unreachable point, there is no reason to emit the block
  // unless it has uses. However, we still need a place to put the debug
  // region.end for now.
```

Is that out of date?



Note that for most functions, we actually emit the return block, then erase it 
if it's unused. (See the end of CodeGenFunction::FinishFunction).

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


[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)

2025-04-03 Thread Fangrui Song via cfe-commits

MaskRay wrote:

Looks good to me, but please allow some time for other reviewers to weigh in.

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


[clang] [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (PR #134124)

2025-04-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`amdgpu-offload-ubuntu-22-cmake-build-only` running on `rocm-docker-ubu-22` 
while building `clang` at step 4 "annotate".

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


Here is the relevant piece of the build log for the reference

```
Step 4 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py 
--jobs=32' (failure)
...
[6455/7730] Creating library symlink lib/libclangAnalysisFlowSensitive.so
[6456/7730] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/LayoutOverrideSource.cpp.o
[6457/7730] Building CXX object 
tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/PerfReader.cpp.o
[6458/7730] Building CXX object 
tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/CSPreInliner.cpp.o
[6459/7730] Building CXX object 
tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/ProfiledBinary.cpp.o
[6460/7730] Building CXX object 
tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/ProfileGenerator.cpp.o
[6461/7730] Building CXX object 
tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/MissingFrameInferrer.cpp.o
[6462/7730] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/ArgumentsAdjusters.cpp.o
[6463/7730] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CreateInvocationFromCommandLine.cpp.o
[6464/7730] Linking CXX shared library lib/libclangSema.so.21.0git
FAILED: lib/libclangSema.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation 
-Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 
-DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   
-Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/./lib
  -Wl,--gc-sections -shared -Wl,-soname,libclangSema.so.21.0git -o 
lib/libclangSema.so.21.0git 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/AnalysisBasedWarnings.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/CheckExprLifetime.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/CodeCompleteConsumer.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/DeclSpec.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/DelayedDiagnostic.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/HeuristicResolver.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/HLSLBuiltinTypeDeclBuilder.cpp.o
 tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/HLSLExternalSemaSource.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/IdentifierResolver.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/JumpDiagnostics.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/MultiplexExternalSemaSource.cpp.o
 tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/ParsedAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Scope.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/ScopeInfo.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAMDGPU.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaARM.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAVR.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAccess.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAPINotes.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAvailability.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaBPF.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaBase.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaBoundsSafety.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCXXScopeSpec.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCast.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaChecking.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCodeComplete.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaConcept.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaConsumer.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCoroutine.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCUDA.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDecl.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclCXX.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclObjC.cpp.o 
tools/clang/lib/Sema/CMakeFile

[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)

2025-04-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yingwei Zheng (dtcxzyw)


Changes

This patch turns off inbounds/nuw flags for member accesses when 
`-fwrapv-pointer` is set.
Note: There are many calls to `CGBuilderTy::CreateStructGEP`, and most of them 
are safe. So I think it is probably overkill to handle this in 
`CreateStructGEP`.

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

It is required by https://github.com/llvm/llvm-project/pull/130734.


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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGExpr.cpp (+9-2) 
- (modified) clang/test/CodeGen/pointer-overflow.c (+21) 


``diff
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3d3a111f0514a..d32591ed896d0 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4922,6 +4922,9 @@ static Address emitAddrOfFieldStorage(CodeGenFunction 
&CGF, Address base,
   unsigned idx =
 CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
 
+  if (CGF.getLangOpts().PointerOverflowDefined)
+return CGF.Builder.CreateConstGEP2_32(base, 0, idx, field->getName());
+
   return CGF.Builder.CreateStructGEP(base, idx, field->getName());
 }
 
@@ -4979,9 +4982,13 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
 if (!UseVolatile) {
   if (!IsInPreservedAIRegion &&
   (!getDebugInfo() || !rec->hasAttr())) {
-if (Idx != 0)
+if (Idx != 0) {
   // For structs, we GEP to the field that the record layout suggests.
-  Addr = Builder.CreateStructGEP(Addr, Idx, field->getName());
+  if (getLangOpts().PointerOverflowDefined)
+Addr = Builder.CreateConstGEP2_32(Addr, 0, Idx, field->getName());
+  else
+Addr = Builder.CreateStructGEP(Addr, Idx, field->getName());
+}
   } else {
 llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
 getContext().getRecordType(rec), rec->getLocation());
diff --git a/clang/test/CodeGen/pointer-overflow.c 
b/clang/test/CodeGen/pointer-overflow.c
index 9c7821b841980..70e3c855bff90 100644
--- a/clang/test/CodeGen/pointer-overflow.c
+++ b/clang/test/CodeGen/pointer-overflow.c
@@ -10,3 +10,24 @@ void test(void) {
   // DEFAULT: getelementptr inbounds nuw i32, ptr
   // FWRAPV-POINTER: getelementptr i32, ptr
 }
+
+struct S {
+  int a;
+  int b;
+  int c: 10;
+  int d: 10;
+};
+
+int test_struct(struct S* s) {
+  // -fwrapv-pointer should turn off inbounds nuw for struct GEP's
+  return s->b;
+  // DEFAULT: getelementptr inbounds nuw %struct.S, ptr
+  // FWRAPV-POINTER: getelementptr %struct.S, ptr
+}
+
+int test_struct_bitfield(struct S* s) {
+  // -fwrapv-pointer should turn off inbounds nuw for struct GEP's
+  return s->d;
+  // DEFAULT: getelementptr inbounds nuw %struct.S, ptr
+  // FWRAPV-POINTER: getelementptr %struct.S, ptr
+}

``




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


[clang] [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (PR #134124)

2025-04-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` 
running on `lldb-x86_64-debian` while building `clang` at step 4 "build".

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


Here is the relevant piece of the build log for the reference

```
Step 4 (build) failure: build (failure)
...
134.836 [159/72/736] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/UninitializedObject/UninitializedObjectChecker.cpp.o
134.868 [158/72/737] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexHigh.cpp.o
134.900 [157/72/738] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexInclusionStack.cpp.o
135.453 [156/72/739] Building CXX object 
tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/InterpreterValuePrinter.cpp.o
135.513 [155/72/740] Building CXX object 
tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/IncrementalParser.cpp.o
135.525 [154/72/741] Building CXX object 
tools/clang/tools/clang-extdef-mapping/CMakeFiles/clang-extdef-mapping.dir/ClangExtDefMapGen.cpp.o
135.554 [153/72/742] Building CXX object 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
135.584 [152/72/743] Building CXX object 
tools/clang/tools/clang-check/CMakeFiles/clang-check.dir/ClangCheck.cpp.o
135.943 [151/72/744] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/StreamChecker.cpp.o
136.222 [150/72/745] Linking CXX executable bin/clang-diff
FAILED: bin/clang-diff 
: && /usr/bin/clang++ -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -fuse-ld=gold-Wl,--gc-sections 
tools/clang/tools/clang-diff/CMakeFiles/clang-diff.dir/ClangDiff.cpp.o -o 
bin/clang-diff  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  
lib/libclangBasic.a  lib/libclangFrontend.a  lib/libclangSerialization.a  
lib/libclangTooling.a  lib/libclangToolingASTDiff.a  lib/libclangFrontend.a  
lib/libclangParse.a  lib/libclangSerialization.a  lib/libclangSema.a  
lib/libclangAPINotes.a  lib/libclangEdit.a  lib/libclangAnalysis.a  
lib/libclangSupport.a  lib/libLLVMFrontendHLSL.a  lib/libclangDriver.a  
lib/libLLVMWindowsDriver.a  lib/libLLVMOption.a  lib/libclangASTMatchers.a  
lib/libclangFormat.a  lib/libclangToolingInclusions.a  
lib/libclangToolingCore.a  lib/libclangRewrite.a  lib/libclangAST.a  
lib/libclangLex.a  lib/libclangBasic.a  lib/libLLVMFrontendOpenMP.a  
lib/libLLVMScalarOpts.a  lib/libLLVMAggressiveInstCombine.a  
lib/libLLVMInstCombine.a  lib/libLLVMFrontendOffloading.a  
lib/libLLVMTransformUtils.a  lib/libLLVMObjectYAML.a  
lib/libLLVMFrontendAtomic.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  
lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoPDB.a  
lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  
lib/libLLVMDebugInfoBTF.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMObject.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMIRReader.a  
lib/libLLVMBitReader.a  lib/libLLVMAsmParser.a  lib/libLLVMTextAPI.a  
lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  
lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libLLVMSupport.a  
-lrt  -ldl  -lm  /usr/lib/x86_64-linux-gnu/libz.so  lib/libLLVMDemangle.a && :
lib/libclangSema.a(SemaHLSL.cpp.o):SemaHLSL.cpp:function 
clang::SemaHLSL::handleRootSignatureAttr(clang::Decl*, clang::ParsedAttr 
const&): error: undefined reference to 
'clang::hlsl::RootSignatureParser::RootSignatureParser(llvm::SmallVector, 6u>&, 
clang::hlsl::RootSignatureLexer&, clang::Preprocessor&)'
lib/libclangSema.a(SemaHLSL.cpp.o):SemaHLSL.cpp:function 
clang::SemaHLSL::handleRootSignatureAttr(clang::Decl*, clang::ParsedAttr 
const&): error: undefined reference to 
'clang::hlsl::RootSignatureParser::parse()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
136.410 [150/71/746] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXType.cpp.o
136.483 [150/70/747] Building CXX object 
tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
136.702 [150/69/748] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXCursor.cpp.o
136.947 [150/68/749] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ASTUtils.cpp.o
137.160 

[clang] [clang] [ARM] Explicitly enable NEON for Windows/Darwin targets (PR #122095)

2025-04-03 Thread Adam Nemet via cfe-commits


@@ -659,13 +659,21 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
 CPUArgFPUKind != llvm::ARM::FK_INVALID ? CPUArgFPUKind : 
ArchArgFPUKind;
 (void)llvm::ARM::getFPUFeatures(FPUKind, Features);
   } else {
+bool Generic = true;
 if (!ForAS) {
   std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple);
+  if (CPU != "generic")
+Generic = false;
   llvm::ARM::ArchKind ArchKind =
   arm::getLLVMArchKindForARM(CPU, ArchName, Triple);
   FPUKind = llvm::ARM::getDefaultFPU(CPU, ArchKind);
   (void)llvm::ARM::getFPUFeatures(FPUKind, Features);
 }
+if (Generic && (Triple.isOSWindows() || Triple.isOSDarwin()) &&

anemet wrote:

Hi @mstorsjo, this breaks Darwin when compiling assembly with armv7s which is 
neon-vfp4.  vfp4 instructions (e.g. vfma) are no longer recognized because you 
effectively downgraded neon-vfp4 to neon.  When `ForAS` you assume a "generic" 
CPU unconditionally rather than "swift".

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


[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)

2025-04-03 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw created 
https://github.com/llvm/llvm-project/pull/134269

This patch turns off inbounds/nuw flags for member accesses when 
`-fwrapv-pointer` is set.
Note: There are many calls to `CGBuilderTy::CreateStructGEP`, and most of them 
are safe. So I think it is probably overkill to handle this in 
`CreateStructGEP`.

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

It is required by https://github.com/llvm/llvm-project/pull/130734.


>From 14dc299cfb3cb9440eeba400ed1b8e4a99bf3b24 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Fri, 4 Apr 2025 00:15:47 +0800
Subject: [PATCH] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct
 GEPs

---
 clang/lib/CodeGen/CGExpr.cpp  | 11 +--
 clang/test/CodeGen/pointer-overflow.c | 21 +
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3d3a111f0514a..d32591ed896d0 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4922,6 +4922,9 @@ static Address emitAddrOfFieldStorage(CodeGenFunction 
&CGF, Address base,
   unsigned idx =
 CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
 
+  if (CGF.getLangOpts().PointerOverflowDefined)
+return CGF.Builder.CreateConstGEP2_32(base, 0, idx, field->getName());
+
   return CGF.Builder.CreateStructGEP(base, idx, field->getName());
 }
 
@@ -4979,9 +4982,13 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
 if (!UseVolatile) {
   if (!IsInPreservedAIRegion &&
   (!getDebugInfo() || !rec->hasAttr())) {
-if (Idx != 0)
+if (Idx != 0) {
   // For structs, we GEP to the field that the record layout suggests.
-  Addr = Builder.CreateStructGEP(Addr, Idx, field->getName());
+  if (getLangOpts().PointerOverflowDefined)
+Addr = Builder.CreateConstGEP2_32(Addr, 0, Idx, field->getName());
+  else
+Addr = Builder.CreateStructGEP(Addr, Idx, field->getName());
+}
   } else {
 llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
 getContext().getRecordType(rec), rec->getLocation());
diff --git a/clang/test/CodeGen/pointer-overflow.c 
b/clang/test/CodeGen/pointer-overflow.c
index 9c7821b841980..70e3c855bff90 100644
--- a/clang/test/CodeGen/pointer-overflow.c
+++ b/clang/test/CodeGen/pointer-overflow.c
@@ -10,3 +10,24 @@ void test(void) {
   // DEFAULT: getelementptr inbounds nuw i32, ptr
   // FWRAPV-POINTER: getelementptr i32, ptr
 }
+
+struct S {
+  int a;
+  int b;
+  int c: 10;
+  int d: 10;
+};
+
+int test_struct(struct S* s) {
+  // -fwrapv-pointer should turn off inbounds nuw for struct GEP's
+  return s->b;
+  // DEFAULT: getelementptr inbounds nuw %struct.S, ptr
+  // FWRAPV-POINTER: getelementptr %struct.S, ptr
+}
+
+int test_struct_bitfield(struct S* s) {
+  // -fwrapv-pointer should turn off inbounds nuw for struct GEP's
+  return s->d;
+  // DEFAULT: getelementptr inbounds nuw %struct.S, ptr
+  // FWRAPV-POINTER: getelementptr %struct.S, ptr
+}

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-03 Thread Jan Leyonberg via cfe-commits


@@ -4645,12 +4789,23 @@ initTargetDefaultAttrs(omp::TargetOp targetOp, 
Operation *capturedOp,
   (maxThreadsVal >= 0 && maxThreadsVal < combinedMaxThreadsVal))
 combinedMaxThreadsVal = maxThreadsVal;
 
+  // Calculate reduction data size, limited to single reduction variable for
+  // now.
+  int32_t reductionDataSize = 0;
+  if (isGPU && capturedOp) {
+if (auto teamsOp = castOrGetParentOfType(capturedOp))
+  reductionDataSize = getReductionDataSize(teamsOp);
+  }
+
   // Update kernel bounds structure for the `OpenMPIRBuilder` to use.
   attrs.ExecFlags = targetOp.getKernelExecFlags(capturedOp);
   attrs.MinTeams = minTeamsVal;
   attrs.MaxTeams.front() = maxTeamsVal;
   attrs.MinThreads = 1;
   attrs.MaxThreads.front() = combinedMaxThreadsVal;
+  attrs.ReductionDataSize = reductionDataSize;
+  if (attrs.ReductionDataSize != 0)
+attrs.ReductionBufferLength = 1024;

jsjodin wrote:

I looked into this a bit more and it is basically a fixed value in clang that 
can be modified with the fopenmp-cuda-teams-reduction-recs-num flang. I added a 
TODO for now.

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


[clang] 65fa57b - [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (#134124)

2025-04-03 Thread via cfe-commits

Author: Finn Plummer
Date: 2025-04-03T09:27:54-07:00
New Revision: 65fa57bdcc9d745dd8c222426e79618fb7cf1c91

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

LOG: [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` 
(#134124)

- Defines HLSLRootSignature Attr in `Attr.td`
- Define and implement handleHLSLRootSignature in `SemaHLSL`
- Adds sample test case to show AST Node is generated in
`RootSignatures-AST.hlsl`

This commit will "hook-up" the seperately defined RootSignature parser
and invoke it to create the RootElements, then store them on the
ASTContext and finally store the reference to the Elements in
RootSignatureAttr

Resolves https://github.com/llvm/llvm-project/issues/119011

-

Co-authored-by: Finn Plummer 

Added: 
clang/test/AST/HLSL/RootSignatures-AST.hlsl
clang/test/SemaHLSL/RootSignature-err.hlsl

Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Sema/SemaHLSL.h
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaHLSL.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 994f236337b99..37c3f8bbfb5f9 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -26,6 +26,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Support/Compiler.h"
 #include "llvm/Frontend/HLSL/HLSLResource.h"
+#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/VersionTuple.h"

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index fd9e686485552..9ef4f2b6b91ed 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4710,6 +4710,25 @@ def Error : InheritableAttr {
   let Documentation = [ErrorAttrDocs];
 }
 
+def HLSLRootSignature : Attr {
+  /// [RootSignature(Signature)]
+  let Spellings = [Microsoft<"RootSignature">];
+  let Args = [StringArgument<"Signature">];
+  let Subjects = SubjectList<[Function],
+ ErrorDiag, "'function'">;
+  let LangOpts = [HLSL];
+  let Documentation = [HLSLRootSignatureDocs];
+  let AdditionalMembers = [{
+private:
+  ArrayRef RootElements;
+public:
+  void setElements(ArrayRef Elements) {
+RootElements = Elements;
+  }
+  auto getElements() const { return RootElements; }
+}];
+}
+
 def HLSLNumThreads: InheritableAttr {
   let Spellings = [Microsoft<"numthreads">];
   let Args = [IntArgument<"X">, IntArgument<"Y">, IntArgument<"Z">];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index c8b371280e35d..1b969e456b910 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8145,6 +8145,17 @@ and 
https://microsoft.github.io/hlsl-specs/proposals/0013-wave-size-range.html
   }];
 }
 
+def HLSLRootSignatureDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``RootSignature`` attribute applies to HLSL entry functions to define what
+types of resources are bound to the graphics pipeline.
+
+For details about the use and specification of Root Signatures please see here:
+https://learn.microsoft.com/en-us/windows/win32/direct3d12/root-signatures
+  }];
+}
+
 def NumThreadsDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index f333fe30e8da0..1bd35332612cd 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -118,6 +118,7 @@ class SemaHLSL : public SemaBase {
bool IsCompAssign);
   void emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, BinaryOperatorKind Opc);
 
+  void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL);
   void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL);
   void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL);
   void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL);

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 0b844b44930b9..b36d327f5bd0a 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7498,6 +7498,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
 break;
 
   // HLSL attributes:
+  case ParsedAttr::AT_HLSLRootSignature:
+S.HLSL().handleRootSignatureAttr(D, AL);
+break;
   case ParsedAttr::AT_HLSLNumThreads:
 S.HLSL().handleNumThreadsAttr(D, AL);
 break;

diff  --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index fe600386e6fa9..bed14c111b544 100644
--- a/clang

[clang] [clang] NFC: introduce UnsignedOrNone as a replacement for std::optional (PR #134142)

2025-04-03 Thread Matheus Izvekov via cfe-commits

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


[clang] [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (PR #134124)

2025-04-03 Thread Finn Plummer via cfe-commits

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


[clang] [MS][clang] Fix crash on deletion of array of pointers (PR #134088)

2025-04-03 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

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


  1   2   3   4   5   >