[clang] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)

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

https://github.com/antoniofrighetto updated 
https://github.com/llvm/llvm-project/pull/120783

>From 54d3ac991abaa341dd4798bbf6aeb3ede4441d64 Mon Sep 17 00:00:00 2001
From: Antonio Frighetto 
Date: Fri, 20 Dec 2024 19:30:59 +0100
Subject: [PATCH 1/2] [IR][ModRef] Introduce `errno` memory location

Model C/C++ `errno` macro by adding a corresponding `errno`
memory location kind to the IR. Preliminary work to separate
`errno` writes from other memory accesses, to the benefit of
alias analyses and optimization correctness.

Previous discussion: 
https://discourse.llvm.org/t/rfc-modelling-errno-memory-effects/82972.
---
 .../CodeGen/sanitize-metadata-nosanitize.c| 18 +++---
 clang/test/CodeGenOpenCL/convergent.cl|  2 +-
 llvm/include/llvm/AsmParser/LLToken.h |  4 ++
 llvm/include/llvm/Bitcode/LLVMBitCodes.h  |  3 +
 llvm/include/llvm/IR/Function.h   | 15 +
 llvm/include/llvm/IR/InstrTypes.h | 15 +
 llvm/include/llvm/Support/ModRef.h| 57 ++-
 llvm/lib/AsmParser/LLLexer.cpp|  4 ++
 llvm/lib/AsmParser/LLParser.cpp   | 13 -
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 28 +
 llvm/lib/IR/Attributes.cpp|  3 +
 llvm/lib/IR/Function.cpp  | 29 ++
 llvm/lib/IR/Instructions.cpp  | 29 ++
 llvm/lib/Support/ModRef.cpp   |  3 +
 .../test/Assembler/memory-attribute-errors.ll |  6 +-
 llvm/test/Assembler/memory-attribute.ll   | 12 
 .../Transforms/FunctionAttrs/argmemonly.ll| 22 +++
 .../Transforms/FunctionAttrs/nocapture.ll | 30 +-
 .../FunctionAttrs/read-write-scc.ll   |  4 +-
 .../Transforms/FunctionAttrs/readattrs.ll |  2 +-
 .../Transforms/FunctionAttrs/writeonly.ll |  4 +-
 .../InferFunctionAttrs/norecurse_debug.ll |  2 +-
 .../cfi-nounwind-direct-call.ll   |  2 +-
 .../Transforms/SCCP/ipscp-drop-argmemonly.ll  | 12 ++--
 llvm/unittests/Support/ModRefTest.cpp |  4 +-
 mlir/test/Target/LLVMIR/llvmir.mlir   | 10 ++--
 26 files changed, 272 insertions(+), 61 deletions(-)

diff --git a/clang/test/CodeGen/sanitize-metadata-nosanitize.c 
b/clang/test/CodeGen/sanitize-metadata-nosanitize.c
index fd2fdce31b52fb..77dc7d9d492ecc 100644
--- a/clang/test/CodeGen/sanitize-metadata-nosanitize.c
+++ b/clang/test/CodeGen/sanitize-metadata-nosanitize.c
@@ -10,7 +10,7 @@
 // CHECK: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered2.module_ctor, ptr 
@__sanitizer_metadata_covered2.module_ctor }, { i32, ptr, ptr } { i32 2, ptr 
@__sanitizer_metadata_atomics2.module_ctor, ptr 
@__sanitizer_metadata_atomics2.module_ctor }]
 // CHECK: @llvm.global_dtors = appending global [2 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered2.module_dtor, ptr 
@__sanitizer_metadata_covered2.module_dtor }, { i32, ptr, ptr } { i32 2, ptr 
@__sanitizer_metadata_atomics2.module_dtor, ptr 
@__sanitizer_metadata_atomics2.module_dtor }]
 //.
-// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync 
nounwind willreturn memory(write, argmem: none, inaccessiblemem: none)
+// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync 
nounwind willreturn memory(write, argmem: none, inaccessiblemem: none, 
errnomem: none)
 // CHECK-LABEL: define dso_local void @escape
 // CHECK-SAME: (ptr noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] 
!pcsections [[META2:![0-9]+]] {
 // CHECK-NEXT:  entry:
@@ -21,7 +21,7 @@ __attribute__((noinline, not_tail_called)) void escape(const 
volatile void *p) {
   sink = p;
 }
 
-// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn 
memory(write, argmem: readwrite, inaccessiblemem: none)
+// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn 
memory(write, argmem: readwrite, inaccessiblemem: none, errnomem: none)
 // CHECK-LABEL: define dso_local i32 @normal_function
 // CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture noundef readonly 
[[Y:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] !pcsections [[META4:![0-9]+]] {
 // CHECK-NEXT:  entry:
@@ -38,7 +38,7 @@ int normal_function(int *x, int *y) {
   return *y;
 }
 
-// CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress 
nofree norecurse nounwind willreturn memory(write, argmem: readwrite, 
inaccessiblemem: none)
+// CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress 
nofree norecurse nounwind willreturn memory(write, argmem: readwrite, 
inaccessiblemem: none, errnomem: none)
 // CHECK-LABEL: define dso_local i32 @test_disable_sanitize_instrumentation
 // CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture noundef readonly 
[[Y:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
 // CHECK-NEXT:  entry:
@@ -55,7 +55,7 @@ __attribute__((disable_sanitizer_instrumentation)) int 
test_disable_sanitize_

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-28 Thread Sam James via cfe-commits


@@ -2486,6 +2486,23 @@ are listed below.
 
 $ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc
 
+Strict Aliasing
+---
+
+Clang by default applies C/C++'s strict aliasing rules during optimizations. In

thesamesam wrote:

Thanks! It looks good now.

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


[libclc] [libclc] Move conversion builtins to the CLC library (PR #124727)

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

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


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


[libclc] 78b5bb7 - [libclc][NFC] Move key math headers to CLC (#124739)

2025-01-28 Thread via cfe-commits

Author: Fraser Cormack
Date: 2025-01-28T14:17:23Z
New Revision: 78b5bb702fe97fe85f66d72598d0dfa7c49fe001

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

LOG: [libclc][NFC] Move key math headers to CLC (#124739)

Added: 
libclc/clc/include/clc/math/clc_subnormal_config.h
libclc/clc/include/clc/math/math.h
libclc/clc/include/clc/math/tables.h

Modified: 
libclc/clspv/lib/math/fma.cl
libclc/clspv/lib/subnormal_config.cl
libclc/generic/include/math/clc_ldexp.h
libclc/generic/lib/math/acos.cl
libclc/generic/lib/math/acosh.cl
libclc/generic/lib/math/acospi.cl
libclc/generic/lib/math/asin.cl
libclc/generic/lib/math/asinh.cl
libclc/generic/lib/math/asinpi.cl
libclc/generic/lib/math/atan.cl
libclc/generic/lib/math/atan2.cl
libclc/generic/lib/math/atan2pi.cl
libclc/generic/lib/math/atanh.cl
libclc/generic/lib/math/atanpi.cl
libclc/generic/lib/math/cbrt.cl
libclc/generic/lib/math/clc_exp10.cl
libclc/generic/lib/math/clc_fma.cl
libclc/generic/lib/math/clc_fmod.cl
libclc/generic/lib/math/clc_hypot.cl
libclc/generic/lib/math/clc_ldexp.cl
libclc/generic/lib/math/clc_pow.cl
libclc/generic/lib/math/clc_pown.cl
libclc/generic/lib/math/clc_powr.cl
libclc/generic/lib/math/clc_remainder.cl
libclc/generic/lib/math/clc_remquo.cl
libclc/generic/lib/math/clc_rootn.cl
libclc/generic/lib/math/clc_tan.cl
libclc/generic/lib/math/clc_tanpi.cl
libclc/generic/lib/math/cos.cl
libclc/generic/lib/math/cosh.cl
libclc/generic/lib/math/cospi.cl
libclc/generic/lib/math/ep_log.cl
libclc/generic/lib/math/ep_log.h
libclc/generic/lib/math/erf.cl
libclc/generic/lib/math/erfc.cl
libclc/generic/lib/math/exp.cl
libclc/generic/lib/math/exp2.cl
libclc/generic/lib/math/exp_helper.cl
libclc/generic/lib/math/expm1.cl
libclc/generic/lib/math/fdim.cl
libclc/generic/lib/math/fma.cl
libclc/generic/lib/math/ilogb.cl
libclc/generic/lib/math/ldexp.cl
libclc/generic/lib/math/lgamma_r.cl
libclc/generic/lib/math/log10.cl
libclc/generic/lib/math/log1p.cl
libclc/generic/lib/math/log2.cl
libclc/generic/lib/math/log_base.h
libclc/generic/lib/math/logb.cl
libclc/generic/lib/math/modf.cl
libclc/generic/lib/math/sin.cl
libclc/generic/lib/math/sincos_helpers.cl
libclc/generic/lib/math/sincos_helpers.h
libclc/generic/lib/math/sinh.cl
libclc/generic/lib/math/sinpi.cl
libclc/generic/lib/math/tables.cl
libclc/generic/lib/math/tanh.cl
libclc/generic/lib/math/tgamma.cl
libclc/generic/lib/subnormal_config.cl
libclc/r600/lib/math/fmax.cl
libclc/r600/lib/math/fmin.cl
libclc/spirv/lib/subnormal_config.cl
libclc/spirv64/lib/subnormal_config.cl

Removed: 
libclc/generic/include/config.h
libclc/generic/lib/math/math.h
libclc/generic/lib/math/tables.h



diff  --git a/libclc/generic/include/config.h 
b/libclc/clc/include/clc/math/clc_subnormal_config.h
similarity index 90%
rename from libclc/generic/include/config.h
rename to libclc/clc/include/clc/math/clc_subnormal_config.h
index 7aa5967f4eb688..eaab5aaee985b5 100644
--- a/libclc/generic/include/config.h
+++ b/libclc/clc/include/clc/math/clc_subnormal_config.h
@@ -19,6 +19,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __CLC_MATH_CLC_SUBNORMAL_CONFIG_H__
+#define __CLC_MATH_CLC_SUBNORMAL_CONFIG_H__
 
 #include 
 
@@ -26,3 +28,5 @@ _CLC_DECL bool __clc_subnormals_disabled();
 _CLC_DECL bool __clc_fp16_subnormals_supported();
 _CLC_DECL bool __clc_fp32_subnormals_supported();
 _CLC_DECL bool __clc_fp64_subnormals_supported();
+
+#endif // __CLC_MATH_CLC_SUBNORMAL_CONFIG_H__

diff  --git a/libclc/generic/lib/math/math.h 
b/libclc/clc/include/clc/math/math.h
similarity index 52%
rename from libclc/generic/lib/math/math.h
rename to libclc/clc/include/clc/math/math.h
index d5ef0871e52019..ed37af237bf821 100644
--- a/libclc/generic/lib/math/math.h
+++ b/libclc/clc/include/clc/math/math.h
@@ -20,12 +20,12 @@
  * THE SOFTWARE.
  */
 
-#ifndef __CLC_MATH_H_
-#define __CLC_MATH_H_
+#ifndef __CLC_MATH_MATH_H__
+#define __CLC_MATH_MATH_H__
 
-#include "clc/clcfunc.h"
-#include "clc/as_type.h"
-#include "config.h"
+#include 
+#include 
+#include 
 
 #define SNAN 0x001
 #define QNAN 0x002
@@ -54,64 +54,64 @@ bool __attribute__((noinline)) 
__clc_runtime_has_hw_fma32(void);
 #define MATH_RECIP(X) (1.0f / (X))
 #define MATH_SQRT(X) sqrt(X)
 
-#define SIGNBIT_SP32  0x8000
-#define EXSIGNBIT_SP320x7fff
-#define EXPBITS_SP32  0x7f80
-#define MANTBITS_SP32 0x007f
-#define ONEEXPBITS_SP32   0x3f80
-#define TWOEXPBITS_SP32   0x4000
-#define HALFEXPBITS_SP32  0x3f0

[clang] 820c6ac - [Clang] call HandleImmediateInvocation before checking for immediate escacalating expressions (reland) (#124708)

2025-01-28 Thread via cfe-commits

Author: cor3ntin
Date: 2025-01-28T15:18:38+01:00
New Revision: 820c6ac7f5e438cc268ecb1fa2c6b17f0d168000

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

LOG: [Clang] call HandleImmediateInvocation before checking for immediate 
escacalating expressions (reland) (#124708)

HandleImmediateInvocation can call MarkExpressionAsImmediateEscalating 
and should always be called before
CheckImmediateEscalatingFunctionDefinition.

However, we were not doing that in `ActFunctionBody`.

Fixes #119046

Added: 
clang/test/CodeGenCXX/gh119046.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ad524ad3c5bbba..c5a5da5daf8f5e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1036,6 +1036,7 @@ Bug Fixes to C++ Support
 - Fix type of expression when calling a template which returns an 
``__array_rank`` querying a type depending on a
   template parameter. Now, such expression can be used with ``static_assert`` 
and ``constexpr``. (#GH123498)
 - Correctly determine the implicit constexprness of lambdas in dependent 
contexts. (#GH97958) (#GH114234)
+- Fix that some dependent immediate expressions did not cause immediate 
escalation (#GH119046)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index fe68eadc951b5f..3cad9827fdab69 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16019,7 +16019,6 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
   if (!FD->isDeletedAsWritten())
 FD->setBody(Body);
   FD->setWillHaveBody(false);
-  CheckImmediateEscalatingFunctionDefinition(FD, FSI);
 
   if (getLangOpts().CPlusPlus14) {
 if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() &&
@@ -16397,6 +16396,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
 // the declaration context below. Otherwise, we're unable to transform
 // 'this' expressions when transforming immediate context functions.
 
+  if (FD)
+CheckImmediateEscalatingFunctionDefinition(FD, getCurFunction());
+
   if (!IsInstantiation)
 PopDeclContext();
 

diff  --git a/clang/test/CodeGenCXX/gh119046.cpp 
b/clang/test/CodeGenCXX/gh119046.cpp
new file mode 100644
index 00..cad76879f08624
--- /dev/null
+++ b/clang/test/CodeGenCXX/gh119046.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++2a -triple x86_64-elf-gnu %s -emit-llvm -o - | 
FileCheck %s
+
+struct S {
+consteval void operator()() {}
+};
+
+template 
+constexpr void dispatch(Fn fn) {
+fn();
+}
+
+template 
+struct value_visitor {
+constexpr void operator()() { visitor(); }
+Visitor&& visitor;
+};
+
+template 
+constexpr auto make_dispatch() {
+return dispatch>;
+}
+
+template 
+constexpr void visit(Visitor&&) {
+make_dispatch();
+}
+
+void f() { visit(S{}); }
+
+// CHECK: define {{.*}} @_Z1fv
+// CHECK-NOT: define {{.*}} @_Z5visitI1SEvOT_
+// CHECK-NOT: define {{.*}} @_Z13make_dispatchI1SEDav

diff  --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp 
b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
index 05904d9ade067f..dd5063cb29c5b7 100644
--- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -560,3 +560,19 @@ void foo() {
 S s;
 }
 } // namespace GH118000
+
+namespace GH119046 {
+
+template  constexpr auto tfn(int) {
+  return (unsigned long long)(&Cls::sfn);
+  //expected-note@-1 {{'tfn' is an immediate function because its 
body evaluates the address of a consteval function 'sfn'}}
+};
+struct S { static consteval void sfn() {} };
+
+int f() {
+  int a = 0; // expected-note{{declared here}}
+  return tfn(a);
+  //expected-error@-1 {{call to immediate function 
'GH119046::tfn' is not a constant expression}}
+  //expected-note@-2 {{read of non-const variable 'a' is not allowed in a 
constant expression}}
+}
+}



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


[libclc] [libclc][NFC] Move key math headers to CLC (PR #124739)

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

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


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


[clang] [Clang] call HandleImmediateInvocation before checking for immediate escacalating expressions (reland) (PR #124708)

2025-01-28 Thread Erich Keane via cfe-commits

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


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


[clang] [OpenMP][ASan] Enable ASan Instrumentation for AMDGPUOpenMPToolChain. (PR #124754)

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

https://github.com/jhuber6 commented:

Broad question, should we instead aim for having `-fsanitize` work for both 
sides? I've always been very much against all these `*-gpu` bloat flags when we 
could just do `-Xarch_host -fsanitize` or `-Xarch_device -fsanitize`. The word 
against that it usually whether or not it would force people to update some 
makefiles.

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Erich Keane via cfe-commits


@@ -0,0 +1 @@
+add_subdirectory(DirectToLLVM)

erichkeane wrote:

newline at end of file here too, because github.

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Erich Keane via cfe-commits


@@ -55,6 +55,9 @@ class CIRGenerator : public clang::ASTConsumer {
   void Initialize(clang::ASTContext &astContext) override;
   bool HandleTopLevelDecl(clang::DeclGroupRef group) override;
   mlir::ModuleOp getModule() const;
+  std::unique_ptr takeContext() {

erichkeane wrote:

This function is somewhat frightning TBH.  It potentially leaves the generator 
in an invalid state.  Is there a reason whoever takes this couldn't just keep a 
reference to this (for vice versa?).

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Erich Keane via cfe-commits

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

I have concerns about `takeContext`, else everything else is a NIT.

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-01-28 Thread Mats Jun Larsen via cfe-commits

https://github.com/junlarsen created 
https://github.com/llvm/llvm-project/pull/124771

Follow-up to https://github.com/llvm/llvm-project/issues/123569

>From f3bbd6f0db4109016d98fe15a2b086b491df2d93 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Wed, 29 Jan 2025 00:31:32 +0900
Subject: [PATCH] [CodeGen] Replace of PointerType::get(Type) with opaque
 version (NFC)

Follow-up to https://github.com/llvm/llvm-project/issues/123569
---
 clang/lib/CodeGen/Address.h |  8 
 clang/lib/CodeGen/CGBlocks.cpp  | 23 +--
 clang/lib/CodeGen/CGDecl.cpp|  5 +
 clang/lib/CodeGen/CGDeclCXX.cpp |  4 ++--
 clang/lib/CodeGen/CGExpr.cpp|  4 ++--
 clang/lib/CodeGen/CGObjCMac.cpp |  2 +-
 clang/lib/CodeGen/CodeGenModule.cpp |  6 +++---
 7 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a18c7169af1eb9..852aa0e686fe3c 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -19,6 +19,7 @@
 #include "clang/AST/Type.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/MathExtras.h"
 
 namespace clang {
@@ -197,10 +198,9 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-return llvm::PointerType::get(
-ElementType,
-llvm::cast(Pointer.getPointer()->getType())
-->getAddressSpace());
+auto AS = llvm::cast(Pointer.getPointer()->getType())
+  ->getAddressSpace();
+return llvm::PointerType::get(ElementType->getContext(), AS);
   }
 
   /// Return the type of the values stored in this address.
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index a7584a95c8ca7b..033528dbceb3bd 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };
-  BlockDescriptorType = llvm::StructType::create(
-  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
-
-  // Now form a pointer to that.
   unsigned AddrSpace = 0;
   if (getLangOpts().OpenCL)
 AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant);
-  BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace);
+  BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace);
   return BlockDescriptorType;
 }
 
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index ded905cdcc9f44..feb4ddbb52b2b7 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2868,15 +2868,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const 
OMPAllocateDecl *D) {
 
 // We can also keep the existing global if the address space is what we
 // expect it to be, if not, it is replaced.
-QualType ASTTy = VD->getType();
 clang::LangAS GVAS = GetGlobalVarAddressSpace(VD);
 auto TargetAS = getContext().getTargetAddressSpace(GVAS);
 if (Entry->getType()->getAddressSpace() == TargetAS)
   continue;
 
-// Make a new global with the correct type / address space.
-llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy);
-llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS);
+llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), 
TargetAS);
 
 // Replace all uses of the old global with a cast. Since we mutate the type
 // in place we neeed an intermediate that takes the spot of the old entry
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 1c2fecea1a6ac2..5005f6b3cbd2d1 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -347,7 +347,7 @@ void 
CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
+ CGM.getLLVMContext(),
  dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to atexit has a wrong type.");
 
@@ -374,7 +374,7 @@ 
CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) {
   // extern "C" int unatexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get

[clang] [clang-format] Fix annotating attrs in class/struct (PR #124634)

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

nico wrote:

(Why drop the formatting test? Seems good to have an integration test for this, 
no?)

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


[clang-tools-extra] [clang-tidy] Replace /* ... */ single-line comments with // ... comments (PR #124319)

2025-01-28 Thread via cfe-commits


@@ -0,0 +1,40 @@
+.. title:: clang-tidy - use-cpp-style-comments
+
+readability-use-cpp-style-comments
+==
+
+Replace C-style comments with C++-style comments.
+C-style comments (``/* ... */``) are inherited from C, while C++ introduces 
+``//`` as a more concise, readable, and less error-prone alternative. Modern 
C++ 
+guidelines recommend using C++-style comments for consistency and 
+maintainability. This check identifies and replaces C-style comments with 
+equivalent C++-style comments.
+
+Examples:
+
+Input:
+.. code-block::c++
+
+  /* This is a single-line comment */
+  int x = 42;  /* Inline comment */
+
+  /* This is a
+  multi-line comment */
+
+Output:
+.. code-block::c++

EugeneZelenko wrote:

Ditto.

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


[clang-tools-extra] [clang-tidy] Replace /* ... */ single-line comments with // ... comments (PR #124319)

2025-01-28 Thread via cfe-commits


@@ -0,0 +1,40 @@
+.. title:: clang-tidy - use-cpp-style-comments
+
+readability-use-cpp-style-comments
+==
+
+Replace C-style comments with C++-style comments.
+C-style comments (``/* ... */``) are inherited from C, while C++ introduces 
+``//`` as a more concise, readable, and less error-prone alternative. Modern 
C++ 
+guidelines recommend using C++-style comments for consistency and 
+maintainability. This check identifies and replaces C-style comments with 
+equivalent C++-style comments.
+
+Examples:
+
+Input:
+.. code-block::c++

EugeneZelenko wrote:

Ditto.

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-01-28 Thread Mats Jun Larsen via cfe-commits


@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };

junlarsen wrote:

I do feel a bit guilty about removing this comment. However, I'm not 
experienced enough to know if it's significant and something we'd like to keep?

Perhaps move it to the BlockDescriptorType decl?

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


[libclc] [libclc] Move conversion builtins to the CLC library (PR #124727)

2025-01-28 Thread Romaric Jodin via cfe-commits

rjodinchr wrote:

I think for `clspv`, we would need to invert the condition to skip user-facing 
functions. By that I mean that `clspv` will need all the `convert_*` functions, 
and not the `__clc_convert_*_rte`. Then we will need to update `clspv` to 
support natively the function with the `__clc_` prefix.

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


[clang-tools-extra] [clang-tidy] Replace /* ... */ single-line comments with // ... comments (PR #124319)

2025-01-28 Thread via cfe-commits


@@ -0,0 +1,40 @@
+.. title:: clang-tidy - use-cpp-style-comments
+
+readability-use-cpp-style-comments
+==
+
+Replace C-style comments with C++-style comments.
+C-style comments (``/* ... */``) are inherited from C, while C++ introduces 
+``//`` as a more concise, readable, and less error-prone alternative. Modern 
C++ 
+guidelines recommend using C++-style comments for consistency and 
+maintainability. This check identifies and replaces C-style comments with 
+equivalent C++-style comments.
+
+Examples:
+
+Input:
+.. code-block::c++
+
+  /* This is a single-line comment */
+  int x = 42;  /* Inline comment */
+
+  /* This is a
+  multi-line comment */
+
+Output:
+.. code-block::c++
+
+  // This is a single-line comment
+  int x = 42;  // Inline comment
+
+  // This is a
+  // multi-line comment
+
+.. note::
+
+  Inline Comments are neither fixed nor warned.
+
+  Example:

EugeneZelenko wrote:

Please separate with newline.

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-01-28 Thread Mats Jun Larsen via cfe-commits

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-01-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mats Jun Larsen (junlarsen)


Changes

Follow-up to https://github.com/llvm/llvm-project/issues/123569

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


7 Files Affected:

- (modified) clang/lib/CodeGen/Address.h (+4-4) 
- (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-22) 
- (modified) clang/lib/CodeGen/CGDecl.cpp (+1-4) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+3-3) 


``diff
diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a18c7169af1eb9..852aa0e686fe3c 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -19,6 +19,7 @@
 #include "clang/AST/Type.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/MathExtras.h"
 
 namespace clang {
@@ -197,10 +198,9 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-return llvm::PointerType::get(
-ElementType,
-llvm::cast(Pointer.getPointer()->getType())
-->getAddressSpace());
+auto AS = llvm::cast(Pointer.getPointer()->getType())
+  ->getAddressSpace();
+return llvm::PointerType::get(ElementType->getContext(), AS);
   }
 
   /// Return the type of the values stored in this address.
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index a7584a95c8ca7b..033528dbceb3bd 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };
-  BlockDescriptorType = llvm::StructType::create(
-  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
-
-  // Now form a pointer to that.
   unsigned AddrSpace = 0;
   if (getLangOpts().OpenCL)
 AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant);
-  BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace);
+  BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace);
   return BlockDescriptorType;
 }
 
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index ded905cdcc9f44..feb4ddbb52b2b7 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2868,15 +2868,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const 
OMPAllocateDecl *D) {
 
 // We can also keep the existing global if the address space is what we
 // expect it to be, if not, it is replaced.
-QualType ASTTy = VD->getType();
 clang::LangAS GVAS = GetGlobalVarAddressSpace(VD);
 auto TargetAS = getContext().getTargetAddressSpace(GVAS);
 if (Entry->getType()->getAddressSpace() == TargetAS)
   continue;
 
-// Make a new global with the correct type / address space.
-llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy);
-llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS);
+llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), 
TargetAS);
 
 // Replace all uses of the old global with a cast. Since we mutate the type
 // in place we neeed an intermediate that takes the spot of the old entry
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 1c2fecea1a6ac2..5005f6b3cbd2d1 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -347,7 +347,7 @@ void 
CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
+ CGM.getLLVMContext(),
  dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to atexit has a wrong type.");
 
@@ -374,7 +374,7 @@ 
CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) {
   // extern "C" int unatexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
+ CGM.getLLVMContext(),
  dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to unatexit has a wrong ty

[clang] [Clang] Enable -fextend-lifetimes at -Og (PR #118026)

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

SLTozer wrote:

With the prior patches having landed, this is now in a state where it could 
land; I've rebased it onto main, meaning all of the code diff in this PR is now 
relevant.

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


[clang] [OpenMP][ASan] Enable ASan Instrumentation for AMDGPUOpenMPToolChain. (PR #124754)

2025-01-28 Thread via cfe-commits

b-sumner wrote:

> I'm referring to the fact that for a normal compile, if the user passes 
> `-fsanitize=address`, should that enable it for both the host and device? My 
> argument is that the user is capable of passing something like `-Xarch_host 
> -fsanitize=undefined -Xarch_device -fsanitize=address` if they want 
> fine-grained control, or don't want it on the CPU but want it on the CPU and 
> vice-versa. This patch adds `-fanitize-gpu` which is a completely separate 
> option that only works in this single case.

I agree, -fsanitize=address is supposed to enable instrumentation on both host 
and device...and that is exactly what happens now.  If this patch is affecting 
the existing behavior then something is wrong.



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


[clang] [llvm] [WIP][clang][DebugInfo] Add new DW_AT_APPLE_ENUM_KIND to encode enum_extensibility (PR #124752)

2025-01-28 Thread Michael Buch via cfe-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/124752

When creating `EnumDecl`s from DWARF for Objective-C `NS_ENUM`s, the Swift 
compiler tries to figure out if it should perform "swiftification" of that enum 
(which involves renaming the enumerator cases, etc.). The heuristics by which 
it determines whether we want to swiftify an enum is by checking the 
`enum_extensibility` attribute (because that's what `NS_ENUM` pretty much are). 
Currently LLDB fails to attach the `EnumExtensibilityAttr` to `EnumDecl`s it 
creates (because there's not enough info in DWARF to derive it), which means we 
have to fall back to re-building Swift modules on-the-fly, slowing down 
expression evaluation substantially. This happens around 
https://github.com/swiftlang/swift/blob/4b3931c8ce437b3f13f245e6423f95c94a5876ac/lib/ClangImporter/ImportEnumInfo.cpp#L37-L59

To speed up Swift exression evaluation, this patch proposes encoding the 
C/C++/Objective-C `enum_extensibility` attribute in DWARF via a new 
`DW_AT_APPLE_ENUM_KIND`. This would currently be only used from the LLDB Swift 
plugin. But may be of interest to other language plugins as well (though I 
haven't come up with a concrete use-case for it outside of Swift).

I'm open to naming suggestions of the various new attributes/attribute 
constants proposed here. I tried to be as generic as possible if we wanted to 
extend it to other kinds of enum properties (e.g., flag enums).

The new attribute would look as follows:
```
DW_TAG_enumeration_type
  DW_AT_type  (0x003a "unsigned int")
  DW_AT_APPLE_enum_kind   (DW_APPLE_ENUM_KIND_Closed)
  DW_AT_name  ("ClosedEnum")
  DW_AT_byte_size (0x04)
  DW_AT_decl_file ("enum.c")
  DW_AT_decl_line (23)

DW_TAG_enumeration_type
  DW_AT_type  (0x003a "unsigned int")
  DW_AT_APPLE_enum_kind   (DW_APPLE_ENUM_KIND_Open)
  DW_AT_name  ("OpenEnum")
  DW_AT_byte_size (0x04)
  DW_AT_decl_file ("enum.c")
  DW_AT_decl_line (27)
```
Absence of the attribute means the extensibility of the enum is unknown and 
abides by whatever the language rules of that CU dictate.

This does feel like a big hammer for quite a specific use-case, so I'm happy to 
discuss alternatives.

Alternatives considered:
* Re-using an existing DWARF attribute to express extensibility. E.g., a 
`DW_TAG_enumeration_type` could have a `DW_AT_count` or `DW_AT_upper_bound` 
indicating the number of enumerators, which could imply closed-ness. I felt 
like a dedicated attribute (which could be generalized further) seemed more 
applicable. But I'm open to re-using existing attributes.
* Encoding the entire attribute string (i.e., `DW_TAG_LLVM_annotation 
("enum_extensibility((open))")`) on the `DW_TAG_enumeration_type`. Then in LLDB 
somehow parse that out into a `EnumExtensibilityAttr`. I haven't found a great 
API in Clang to parse arbitrary strings into AST nodes (the ones I've found 
required fully formed C++ constructs). Though if someone knows of a good way to 
do this, happy to consider that too.

>From b00ae7f30e725e7d3897c3b87cacc6eaba79feb8 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 27 Jan 2025 18:14:06 +
Subject: [PATCH] [WIP][clang][DebugInfo] Add new DW_AT_APPLE_ENUM_KIND to
 encode enum_extensibility

When creating `EnumDecl`s from DWARF for Objective-C `NS_ENUM`s, the Swift 
compiler tries to figure out if it should perform "swiftification" of that enum 
(which involves renaming the enumerator cases, etc.). The heuristics by which 
it determines whether we want to swiftify an enum is by checking the 
`enum_extensibility` attribute (because that's what `NS_ENUM` pretty much are). 
Currently LLDB fails to attach the `EnumExtensibilityAttr` to `EnumDecl`s it 
creates (because there's not enough info in DWARF to derive it), which means we 
have to fall back to re-building Swift modules on-the-fly, slowing down 
expression evaluation substantially. This happens around 
https://github.com/swiftlang/swift/blob/4b3931c8ce437b3f13f245e6423f95c94a5876ac/lib/ClangImporter/ImportEnumInfo.cpp#L37-L59

To speed up Swift exression evaluation, this patch proposes encoding the 
C/C++/Objective-C `enum_extensibility` attribute in DWARF via a new 
`DW_AT_APPLE_ENUM_KIND`. This would currently be only used from the LLDB Swift 
plugin. But may be of interest to other language plugins as well (though I 
haven't come up with a concrete use-case for it outside of Swift).

I'm open to naming suggestions of the various new attributes/attribute 
constants proposed here. I tried to be as generic as possible if we wanted to 
extend it to other kinds of enum properties (e.g., flag enums).

The new attribute would look as follows:
```
DW_TAG_enumeration_type
  DW_AT_type  (0x003a "unsigned int")
  DW_AT_APPLE_enum_kind   (DW_APPLE_ENUM_KIND_Closed)
  DW_AT_name  ("ClosedEnum")
  DW_AT_byte_size (0x04)
  DW_AT_decl_file ("enum.c")
  DW_AT_decl_line (23)

DW_TAG_enumeration_type
  DW_AT_type  (0x003a

[libclc] [libclc][NFC] Move key math headers to CLC (PR #124739)

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

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


[clang] [Driver][ASan] Refactor Clang-Driver "Sanitizer Bitcode" linking. (PR #123922)

2025-01-28 Thread Amit Kumar Pandey via cfe-commits

https://github.com/ampandey-1995 updated 
https://github.com/llvm/llvm-project/pull/123922

>From 5ec4303eb089038db1965b844b8b3bec136207bf Mon Sep 17 00:00:00 2001
From: Amit Pandey 
Date: Wed, 22 Jan 2025 15:41:41 +0530
Subject: [PATCH 1/3] [Driver][ASan] Refactor Clang-Driver "Sanitizer Bitcode"
 linking.

ASan bitcode linking is currently available for HIPAMD,OpenMP and
OpenCL. Moving sanitizer specific common parts of logic to appropriate
API's so as to reduce code redundancy and maintainability.
---
 clang/lib/Driver/ToolChains/AMDGPU.cpp   | 58 ++--
 clang/lib/Driver/ToolChains/AMDGPU.h |  2 +-
 clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp |  7 +--
 clang/lib/Driver/ToolChains/HIPAMD.cpp   | 25 ++---
 clang/lib/Driver/ToolChains/ROCm.h   | 12 ++--
 clang/test/Driver/hip-sanitize-options.hip   |  8 +--
 clang/test/Driver/rocm-device-libs.cl|  2 +-
 7 files changed, 58 insertions(+), 56 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index a8061ffd9321f5..83f486611bc946 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -950,6 +950,11 @@ void ROCMToolChain::addClangTargetOptions(
 ABIVer))
 return;
 
+  std::tuple GPUSan(
+  DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
+ options::OPT_fno_gpu_sanitize, true),
+  getSanitizerArgs(DriverArgs));
+
   bool Wave64 = isWave64(DriverArgs, Kind);
 
   // TODO: There are way too many flags that change this. Do we need to check
@@ -965,21 +970,19 @@ void ROCMToolChain::addClangTargetOptions(
   DriverArgs.hasArg(options::OPT_cl_fp32_correctly_rounded_divide_sqrt);
 
   // Add the OpenCL specific bitcode library.
-  llvm::SmallVector BCLibs;
-  BCLibs.push_back(RocmInstallation->getOpenCLPath().str());
+  llvm::SmallVector BCLibs;
+  BCLibs.emplace_back(RocmInstallation->getOpenCLPath().str());
 
   // Add the generic set of libraries.
   BCLibs.append(RocmInstallation->getCommonBitcodeLibs(
   DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
-  FastRelaxedMath, CorrectSqrt, ABIVer, false));
+  FastRelaxedMath, CorrectSqrt, ABIVer, GPUSan, false));
 
-  if (getSanitizerArgs(DriverArgs).needsAsanRt()) {
-CC1Args.push_back("-mlink-bitcode-file");
-CC1Args.push_back(
-DriverArgs.MakeArgString(RocmInstallation->getAsanRTLPath()));
-  }
-  for (StringRef BCFile : BCLibs) {
-CC1Args.push_back("-mlink-builtin-bitcode");
+  for (auto [BCFile, Internalize] : BCLibs) {
+if (Internalize)
+  CC1Args.push_back("-mlink-builtin-bitcode");
+else
+  CC1Args.push_back("-mlink-bitcode-file");
 CC1Args.push_back(DriverArgs.MakeArgString(BCFile));
   }
 }
@@ -1002,18 +1005,35 @@ bool RocmInstallationDetector::checkCommonBitcodeLibs(
   return true;
 }
 
-llvm::SmallVector
+llvm::SmallVector
 RocmInstallationDetector::getCommonBitcodeLibs(
 const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile, bool Wave64,
 bool DAZ, bool FiniteOnly, bool UnsafeMathOpt, bool FastRelaxedMath,
-bool CorrectSqrt, DeviceLibABIVersion ABIVer, bool isOpenMP = false) const 
{
-  llvm::SmallVector BCLibs;
-
-  auto AddBCLib = [&](StringRef BCFile) { BCLibs.push_back(BCFile.str()); };
+bool CorrectSqrt, DeviceLibABIVersion ABIVer,
+const std::tuple &GPUSan,
+bool isOpenMP = false) const {
+  llvm::SmallVector BCLibs;
+
+  auto GPUSanEnabled = [GPUSan]() { return std::get(GPUSan); };
+  auto AddBCLib = [&](ToolChain::BitCodeLibraryInfo BCLib,
+  bool Internalize = true) {
+BCLib.ShouldInternalize = Internalize;
+BCLibs.emplace_back(BCLib);
+  };
+  auto AddSanBCLibs = [&]() {
+if (GPUSanEnabled()) {
+  auto SanArgs = std::get(GPUSan);
+  if (SanArgs.needsAsanRt())
+AddBCLib(getAsanRTLPath(), false);
+}
+  };
 
+  AddSanBCLibs();
   AddBCLib(getOCMLPath());
   if (!isOpenMP)
 AddBCLib(getOCKLPath());
+  else if (GPUSanEnabled() && isOpenMP)
+AddBCLib(getOCKLPath(), false);
   AddBCLib(getDenormalsAreZeroPath(DAZ));
   AddBCLib(getUnsafeMathPath(UnsafeMathOpt || FastRelaxedMath));
   AddBCLib(getFiniteOnlyPath(FiniteOnly || FastRelaxedMath));
@@ -1027,7 +1047,7 @@ RocmInstallationDetector::getCommonBitcodeLibs(
   return BCLibs;
 }
 
-llvm::SmallVector
+llvm::SmallVector
 ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
const std::string &GPUArch,
bool isOpenMP) const {
@@ -1044,6 +1064,10 @@ ROCMToolChain::getCommonDeviceLibNames(const 
llvm::opt::ArgList &DriverArgs,
   // If --hip-device-lib is not set, add the default bitcode libraries.
   // TODO: There are way too many flags that change this. Do we need to check
   // them all?
+  std::tuple GPUSan(
+  DriverArgs.hasFlag(options::OPT_fgpu_sa

[clang] [llvm] [mlir] [openmp] [Offload] Rework offloading entry type to be more generic (PR #124018)

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

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


[clang] [clang] disallow narrowing when matching template template parameters (PR #124313)

2025-01-28 Thread Erich Keane via cfe-commits

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


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


[clang] [llvm] [mlir] [InferAttrs] Mark errnomem-setting libcalls as such (PR #124742)

2025-01-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Antonio Frighetto (antoniofrighetto)


Changes

Mark C standard library functions that set `errno` as such, as included in the 
POSIX specification. Likewise, while deducing function attributes, determine 
whether a memory access affects errno memory (this possibly should leverage 
Loc.TBAAErrno in upcoming PR).

Rebased on: #120783.

---

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


29 Files Affected:

- (modified) clang/test/CodeGen/sanitize-metadata-nosanitize.c (+9-9) 
- (modified) clang/test/CodeGenOpenCL/convergent.cl (+1-1) 
- (modified) llvm/include/llvm/AsmParser/LLToken.h (+4) 
- (modified) llvm/include/llvm/Bitcode/LLVMBitCodes.h (+3) 
- (modified) llvm/include/llvm/IR/Function.h (+15) 
- (modified) llvm/include/llvm/IR/InstrTypes.h (+15) 
- (modified) llvm/include/llvm/Support/ModRef.h (+56-1) 
- (modified) llvm/lib/AsmParser/LLLexer.cpp (+4) 
- (modified) llvm/lib/AsmParser/LLParser.cpp (+12-1) 
- (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+28) 
- (modified) llvm/lib/IR/Attributes.cpp (+3) 
- (modified) llvm/lib/IR/Function.cpp (+29) 
- (modified) llvm/lib/IR/Instructions.cpp (+29) 
- (modified) llvm/lib/Support/ModRef.cpp (+3) 
- (modified) llvm/lib/Transforms/IPO/FunctionAttrs.cpp (+12) 
- (modified) llvm/lib/Transforms/Utils/BuildLibCalls.cpp (+82-16) 
- (modified) llvm/test/Assembler/memory-attribute-errors.ll (+3-3) 
- (modified) llvm/test/Assembler/memory-attribute.ll (+12) 
- (modified) llvm/test/Transforms/FunctionAttrs/argmemonly.ll (+11-11) 
- (modified) llvm/test/Transforms/FunctionAttrs/nocapture.ll (+15-15) 
- (modified) llvm/test/Transforms/FunctionAttrs/read-write-scc.ll (+2-2) 
- (modified) llvm/test/Transforms/FunctionAttrs/readattrs.ll (+1-1) 
- (modified) llvm/test/Transforms/FunctionAttrs/writeonly.ll (+2-2) 
- (modified) llvm/test/Transforms/InferFunctionAttrs/annotate.ll (+96-93) 
- (modified) llvm/test/Transforms/InferFunctionAttrs/norecurse_debug.ll (+1-1) 
- (modified) llvm/test/Transforms/LowerTypeTests/cfi-nounwind-direct-call.ll 
(+1-1) 
- (modified) llvm/test/Transforms/SCCP/ipscp-drop-argmemonly.ll (+6-6) 
- (modified) llvm/unittests/Support/ModRefTest.cpp (+2-2) 
- (modified) mlir/test/Target/LLVMIR/llvmir.mlir (+5-5) 


``diff
diff --git a/clang/test/CodeGen/sanitize-metadata-nosanitize.c 
b/clang/test/CodeGen/sanitize-metadata-nosanitize.c
index fd2fdce31b52fb..77dc7d9d492ecc 100644
--- a/clang/test/CodeGen/sanitize-metadata-nosanitize.c
+++ b/clang/test/CodeGen/sanitize-metadata-nosanitize.c
@@ -10,7 +10,7 @@
 // CHECK: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered2.module_ctor, ptr 
@__sanitizer_metadata_covered2.module_ctor }, { i32, ptr, ptr } { i32 2, ptr 
@__sanitizer_metadata_atomics2.module_ctor, ptr 
@__sanitizer_metadata_atomics2.module_ctor }]
 // CHECK: @llvm.global_dtors = appending global [2 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 2, ptr @__sanitizer_metadata_covered2.module_dtor, ptr 
@__sanitizer_metadata_covered2.module_dtor }, { i32, ptr, ptr } { i32 2, ptr 
@__sanitizer_metadata_atomics2.module_dtor, ptr 
@__sanitizer_metadata_atomics2.module_dtor }]
 //.
-// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync 
nounwind willreturn memory(write, argmem: none, inaccessiblemem: none)
+// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync 
nounwind willreturn memory(write, argmem: none, inaccessiblemem: none, 
errnomem: none)
 // CHECK-LABEL: define dso_local void @escape
 // CHECK-SAME: (ptr noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] 
!pcsections [[META2:![0-9]+]] {
 // CHECK-NEXT:  entry:
@@ -21,7 +21,7 @@ __attribute__((noinline, not_tail_called)) void escape(const 
volatile void *p) {
   sink = p;
 }
 
-// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn 
memory(write, argmem: readwrite, inaccessiblemem: none)
+// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn 
memory(write, argmem: readwrite, inaccessiblemem: none, errnomem: none)
 // CHECK-LABEL: define dso_local i32 @normal_function
 // CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture noundef readonly 
[[Y:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] !pcsections [[META4:![0-9]+]] {
 // CHECK-NEXT:  entry:
@@ -38,7 +38,7 @@ int normal_function(int *x, int *y) {
   return *y;
 }
 
-// CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress 
nofree norecurse nounwind willreturn memory(write, argmem: readwrite, 
inaccessiblemem: none)
+// CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress 
nofree norecurse nounwind willreturn memory(write, argmem: readwrite, 
inaccessiblemem: none, errnomem: none)
 // CHECK-LABEL: define dso_local i32 @test_disable_sanitize_instrumentation
 // CHECK-SAME: (ptr noundef [[X:%.*]], ptr nocapture nounde

[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

2025-01-28 Thread Donát Nagy via cfe-commits


@@ -1544,7 +1544,7 @@ SVal 
RegionStoreManager::getBinding(RegionBindingsConstRef B, Loc L, QualType T)
   // The location does not have a bound value.  This means that it has
   // the value it had upon its creation and/or entry to the analyzed
   // function/method.  These are either symbolic values or 'undefined'.
-  if (R->hasStackNonParametersStorage()) {
+  if (R->hasRawStackNonParametersStorage()) {

NagyDonat wrote:

**Remark:** This is another example (in addition to e.g. the ArrayBoundV2 lower 
bound check) where it seems to be important to distinguish the "raw" (inherent) 
memory space and the "acquired" memory space: this logic applies a default to 
"real" local stack variables, that should not apply to initially unknown 
regions where we later conclude that they're on the stack (but perhaps don't 
bind anything as their content).

No action expected in this commit, but this could be another reason for keeping 
the separate "inherent" memory space field in the future.

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


[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

2025-01-28 Thread Donát Nagy via cfe-commits


@@ -353,7 +352,7 @@ static std::string getRegionName(const SubRegion *Region) {
 return "the memory returned by 'alloca'";
 
   if (isa(Region) &&
-  isa(Region->getMemorySpace()))
+  isa(Region->getRawMemorySpace()))

NagyDonat wrote:

I think this should use `getMemorySpace(State)` if it's not too cumbersome to 
pass a state to this function. (However, this is not an important change, just 
marginal prettification of a report message.)

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


[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

2025-01-28 Thread Donát Nagy via cfe-commits

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


[clang] [Clang] Enable -fextend-lifetimes at -Og (PR #118026)

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

https://github.com/SLTozer updated 
https://github.com/llvm/llvm-project/pull/118026

>From beb5e1955f9b0aa106512bb10d4543232e4d4cfa Mon Sep 17 00:00:00 2001
From: Stephen Tozer 
Date: Thu, 28 Nov 2024 13:53:20 +
Subject: [PATCH] Enable -fextend-lifetimes at -Og

---
 clang/docs/CommandGuide/clang.rst| 7 +--
 clang/docs/ReleaseNotes.rst  | 4 
 clang/lib/Driver/ToolChains/Clang.cpp| 8 +++-
 clang/test/Driver/extend-variable-liveness.c | 3 ++-
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index ca8176f854729b..f8294a01048fec 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -442,8 +442,11 @@ Code Generation Options
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
-:option:`-Og` Like :option:`-O1`. In future versions, this option might
-disable different optimizations in order to improve debuggability.
+:option:`-Og` Similar to :option:`-O1`, but with slightly reduced
+optimization and better variable visibility. The same optimizations are run
+as at :option:`-O1`, but the :option:`-fextend-variable-liveness` flag is
+also set, which tries to prevent optimizations from reducing the liveness 
of
+user variables, improving their availability when debugging.
 
 :option:`-O` Equivalent to :option:`-O1`.
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c5a5da5daf8f5e..7b8670c9f48140 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -580,6 +580,10 @@ Modified Compiler Flags
   ``-fexperimental-modules-reduced-bmi`` flag. The ``-fmodules-reduced-bmi`` 
flag
   is intended to be enabled by default in the future.
 
+- The ``-Og`` optimization flag now sets ``-fextend-variable-liveness``, a new
+  compiler flag which trades a small amount of optimization in exchange for
+  improved variable visibility.
+
 Removed Compiler Flags
 -
 
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 589de953be5be1..0ce32d7d0f1b89 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7706,7 +7706,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (Args.hasArg(options::OPT_fretain_comments_from_system_headers))
 CmdArgs.push_back("-fretain-comments-from-system-headers");
 
-  Args.AddLastArg(CmdArgs, options::OPT_fextend_variable_liveness_EQ);
+  if (Arg *A = Args.getLastArg(options::OPT_fextend_variable_liveness_EQ)) {
+A->render(Args, CmdArgs);
+  } else if (Arg *A = Args.getLastArg(options::OPT_O_Group);
+ A && A->containsValue("g")) {
+// Set -fextend-variable-liveness=all by default at -Og.
+CmdArgs.push_back("-fextend-variable-liveness=all");
+  }
 
   // Forward -fcomment-block-commands to -cc1.
   Args.AddAllArgs(CmdArgs, options::OPT_fcomment_block_commands);
diff --git a/clang/test/Driver/extend-variable-liveness.c 
b/clang/test/Driver/extend-variable-liveness.c
index bdd89d6f7721ce..95c9f6bc6904c1 100644
--- a/clang/test/Driver/extend-variable-liveness.c
+++ b/clang/test/Driver/extend-variable-liveness.c
@@ -1,7 +1,8 @@
 // Tests that -fextend-variable-liveness and its aliases are correctly passed
-// by the driver.
+// by the driver, and are set by default at -Og.
 
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,DEFAULT
+// RUN: %clang -### -Og -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,ALL
 // RUN: %clang -fextend-variable-liveness=none -### -c %s 2>&1 | FileCheck %s 
--check-prefixes=CHECK,NONE
 // RUN: %clang -fextend-variable-liveness=this -### -c %s 2>&1 | FileCheck %s 
--check-prefixes=CHECK,THIS
 // RUN: %clang -fextend-this-ptr-liveness -### -c %s 2>&1 | FileCheck %s 
--check-prefixes=CHECK,THIS

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


[clang] [TySan] Add initial documentation for Type Sanitizer (PR #123595)

2025-01-28 Thread via cfe-commits

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


[libclc] a8c82d5 - [libclc] Optimize isfpclass-like CLC builtins (#124145)

2025-01-28 Thread via cfe-commits

Author: Fraser Cormack
Date: 2025-01-28T16:23:52Z
New Revision: a8c82d5fde1dab47a1a3fe27bb8ced8f0eb33ab9

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

LOG: [libclc] Optimize isfpclass-like CLC builtins (#124145)

The builtins we were using to implement __clc_is(finite|inf|nan|normal)
-- __builtin_isfinite, etc. -- don't take vector types so we were
previously scalarizing. The __builtin_isfpclass builtin does take vector
types and thus allows us to keep things in vectors.

There is no change in codegen to the scalar versions of any of these
builtins.

Added: 


Modified: 
libclc/clc/include/clc/relational/relational.h
libclc/clc/lib/generic/relational/clc_isfinite.cl
libclc/clc/lib/generic/relational/clc_isinf.cl
libclc/clc/lib/generic/relational/clc_isnan.cl
libclc/clc/lib/generic/relational/clc_isnormal.cl
libclc/clc/lib/generic/relational/clc_signbit.cl

Removed: 




diff  --git a/libclc/clc/include/clc/relational/relational.h 
b/libclc/clc/include/clc/relational/relational.h
index f269715cfc83c9..2210d64bdac7ba 100644
--- a/libclc/clc/include/clc/relational/relational.h
+++ b/libclc/clc/include/clc/relational/relational.h
@@ -6,63 +6,6 @@
  * when the result is true.
  */
 
-#define _CLC_DEFINE_RELATIONAL_UNARY_SCALAR(RET_TYPE, FUNCTION, BUILTIN_NAME,  
\
-ARG_TYPE)  
\
-  _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) {   
\
-return BUILTIN_NAME(x);
\
-  }
-
-#define _CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE, FUNCTION, ARG_TYPE)
\
-  _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) {   
\
-return (RET_TYPE)((RET_TYPE){FUNCTION(x.lo), FUNCTION(x.hi)} !=
\
-  (RET_TYPE)0);
\
-  }
-
-#define _CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE, FUNCTION, ARG_TYPE)
\
-  _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) {   
\
-return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1),   
\
- FUNCTION(x.s2)} != (RET_TYPE)0);  
\
-  }
-
-#define _CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE, FUNCTION, ARG_TYPE)
\
-  _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) {   
\
-return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1),   
\
- FUNCTION(x.s2),   
\
- FUNCTION(x.s3)} != (RET_TYPE)0);  
\
-  }
-
-#define _CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE, FUNCTION, ARG_TYPE)
\
-  _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) {   
\
-return (   
\
-RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2),   
\
- FUNCTION(x.s3), FUNCTION(x.s4), FUNCTION(x.s5),   
\
- FUNCTION(x.s6), FUNCTION(x.s7)} != (RET_TYPE)0);  
\
-  }
-
-#define _CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE, FUNCTION, ARG_TYPE)   
\
-  _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) {   
\
-return (   
\
-RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2),   
\
- FUNCTION(x.s3), FUNCTION(x.s4), FUNCTION(x.s5),   
\
- FUNCTION(x.s6), FUNCTION(x.s7), FUNCTION(x.s8),   
\
- FUNCTION(x.s9), FUNCTION(x.sa), FUNCTION(x.sb),   
\
- FUNCTION(x.sc), FUNCTION(x.sd), FUNCTION(x.se),   
\
- FUNCTION(x.sf)} != (RET_TYPE)0);  
\
-  }
-
-#define _CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(RET_TYPE, FUNCTION, ARG_TYPE) 
\
-  _CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE##2, FUNCTION, ARG_TYPE##2)
\
-  _CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE##3, FUNCTION, ARG_TYPE##3)
\
-  _CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE##4, FUNCTION, ARG_TYPE##4)
\
-  _CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE##8, FUNCTION, ARG_TYPE##8)
\
-  _CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE##16, FUNCTION, ARG_TYPE##16)
-
-#define _CLC_DEFINE_RELATIONAL_UNARY(RET_TYPE, FUNCTION, BUILTIN_FUNCTION, 
\
- ARG_TYPE) 
\
-  _CLC_DEFINE_RELATIONAL_UNARY_SCALAR(RET_TYPE, FUNCTION, BUILTIN_FUNCTION,
\
-  ARG_TYPE)
\
-  _CLC_DEFINE_RELATIO

[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

2025-01-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yanzuo Liu (zwuis)


Changes

In my PR #102581, elements of structured bindings is copy-initialized. 
They should be direct-initialized because the form of the initializer of the 
whole structured bindings is direct-list-initialization.

[[dcl.struct.bind]/1](https://eel.is/c++draft/dcl.struct.bind#1.sentence-8):
> ... and each element is copy-initialized or direct-initialized from the 
corresponding element of the assignment-expression as specified by the form of 
the initializer. ...

```cpp
int arr[2]{};
// elements of `[a, b]` should be direct-initialized
auto [a, b]{arr};
```

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaInit.cpp (+3-2) 
- (modified) clang/test/SemaCXX/cxx1z-decomposition.cpp (+10-11) 


``diff
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b95cbbf4222056..5552fce55f1310 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4861,8 +4861,9 @@ static void TryListInitialization(Sema &S,
 S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) 
&&
 "Deduced to other type?");
 TryArrayCopy(S,
- InitializationKind::CreateCopy(Kind.getLocation(),
-InitList->getLBraceLoc()),
+ InitializationKind::CreateDirect(Kind.getLocation(),
+  InitList->getLBraceLoc(),
+  
InitList->getRBraceLoc()),
  Entity, SubInit[0], DestType, Sequence,
  TreatUnavailableAsInvalid);
 if (Sequence)
diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index a8914fe4e9cd82..b3d98e44990f61 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -200,38 +200,37 @@ namespace lambdas {
 
 namespace by_value_array_copy {
   struct explicit_copy {
-explicit_copy() = default; // expected-note 2{{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
-explicit explicit_copy(const explicit_copy&) = default; // expected-note 
2{{explicit constructor is not a candidate}}
+explicit_copy() = default; // expected-note {{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
+explicit explicit_copy(const explicit_copy&) = default; // expected-note 
{{explicit constructor is not a candidate}}
   };
 
   constexpr int direct_initialization_for_elements() {
 explicit_copy ec_arr[2];
 auto [a1, b1](ec_arr);
+auto [a2, b2]{ec_arr};
 
 int arr[3]{1, 2, 3};
-auto [a2, b2, c2](arr);
+auto [a3, b3, c3](arr);
+auto [a4, b4, c4]{arr}; // GH31813
 arr[0]--;
-return a2 + b2 + c2 + arr[0];
+return a3 + b3 + c3 + a4 + b4 + c4 + arr[0];
   }
-  static_assert(direct_initialization_for_elements() == 6);
+  static_assert(direct_initialization_for_elements() == 12);
 
   constexpr int copy_initialization_for_elements() {
 int arr[2]{4, 5};
 auto [a1, b1] = arr;
-auto [a2, b2]{arr}; // GH31813
 arr[0] = 0;
-return a1 + b1 + a2 + b2 + arr[0];
+return a1 + b1 + arr[0];
   }
-  static_assert(copy_initialization_for_elements() == 18);
+  static_assert(copy_initialization_for_elements() == 9);
 
   void copy_initialization_for_elements_with_explicit_copy_ctor() {
 explicit_copy ec_arr[2];
 auto [a1, b1] = ec_arr; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
-auto [a2, b2]{ec_arr}; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
 
 // Test prvalue
 using T = explicit_copy[2];
-auto [a3, b3] = T{};
-auto [a4, b4]{T{}};
+auto [a2, b2] = T{};
   }
 } // namespace by_value_array_copy

``




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


[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

2025-01-28 Thread Yanzuo Liu via cfe-commits

https://github.com/zwuis created 
https://github.com/llvm/llvm-project/pull/124793

In my PR #102581, elements of structured bindings is copy-initialized. They 
should be direct-initialized because the form of the initializer of the whole 
structured bindings is direct-list-initialization.

[[dcl.struct.bind]/1](https://eel.is/c++draft/dcl.struct.bind#1.sentence-8):
> ... and each element is copy-initialized or direct-initialized from the 
> corresponding element of the assignment-expression as specified by the form 
> of the initializer. ...

```cpp
int arr[2]{};
// elements of `[a, b]` should be direct-initialized
auto [a, b]{arr};
```

>From 16596add29b63ee0282e026dec7b1d5946863113 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Wed, 29 Jan 2025 00:38:15 +0800
Subject: [PATCH] Fix wrong initialization kind

---
 clang/lib/Sema/SemaInit.cpp|  5 +++--
 clang/test/SemaCXX/cxx1z-decomposition.cpp | 21 ++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b95cbbf4222056..5552fce55f1310 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4861,8 +4861,9 @@ static void TryListInitialization(Sema &S,
 S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) 
&&
 "Deduced to other type?");
 TryArrayCopy(S,
- InitializationKind::CreateCopy(Kind.getLocation(),
-InitList->getLBraceLoc()),
+ InitializationKind::CreateDirect(Kind.getLocation(),
+  InitList->getLBraceLoc(),
+  
InitList->getRBraceLoc()),
  Entity, SubInit[0], DestType, Sequence,
  TreatUnavailableAsInvalid);
 if (Sequence)
diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index a8914fe4e9cd82..b3d98e44990f61 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -200,38 +200,37 @@ namespace lambdas {
 
 namespace by_value_array_copy {
   struct explicit_copy {
-explicit_copy() = default; // expected-note 2{{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
-explicit explicit_copy(const explicit_copy&) = default; // expected-note 
2{{explicit constructor is not a candidate}}
+explicit_copy() = default; // expected-note {{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
+explicit explicit_copy(const explicit_copy&) = default; // expected-note 
{{explicit constructor is not a candidate}}
   };
 
   constexpr int direct_initialization_for_elements() {
 explicit_copy ec_arr[2];
 auto [a1, b1](ec_arr);
+auto [a2, b2]{ec_arr};
 
 int arr[3]{1, 2, 3};
-auto [a2, b2, c2](arr);
+auto [a3, b3, c3](arr);
+auto [a4, b4, c4]{arr}; // GH31813
 arr[0]--;
-return a2 + b2 + c2 + arr[0];
+return a3 + b3 + c3 + a4 + b4 + c4 + arr[0];
   }
-  static_assert(direct_initialization_for_elements() == 6);
+  static_assert(direct_initialization_for_elements() == 12);
 
   constexpr int copy_initialization_for_elements() {
 int arr[2]{4, 5};
 auto [a1, b1] = arr;
-auto [a2, b2]{arr}; // GH31813
 arr[0] = 0;
-return a1 + b1 + a2 + b2 + arr[0];
+return a1 + b1 + arr[0];
   }
-  static_assert(copy_initialization_for_elements() == 18);
+  static_assert(copy_initialization_for_elements() == 9);
 
   void copy_initialization_for_elements_with_explicit_copy_ctor() {
 explicit_copy ec_arr[2];
 auto [a1, b1] = ec_arr; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
-auto [a2, b2]{ec_arr}; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
 
 // Test prvalue
 using T = explicit_copy[2];
-auto [a3, b3] = T{};
-auto [a4, b4]{T{}};
+auto [a2, b2] = T{};
   }
 } // namespace by_value_array_copy

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


[clang] [clang module] Current Working Directory Pruning (PR #124786)

2025-01-28 Thread Qiongsi Wu via cfe-commits

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


[clang] 822954b - [TySan] Add initial documentation for Type Sanitizer (#123595)

2025-01-28 Thread via cfe-commits

Author: gbMattN
Date: 2025-01-28T16:58:03Z
New Revision: 822954b4a97753b0c7accc606287529518e9d425

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

LOG: [TySan] Add initial documentation for Type Sanitizer (#123595)

Add some initial documentation for type sanitizer [From issue #122522]

Added: 
clang/docs/TypeSanitizer.rst

Modified: 
clang/docs/UsersManual.rst
clang/docs/index.rst

Removed: 




diff  --git a/clang/docs/TypeSanitizer.rst b/clang/docs/TypeSanitizer.rst
new file mode 100644
index 00..8b815d8804fa8f
--- /dev/null
+++ b/clang/docs/TypeSanitizer.rst
@@ -0,0 +1,205 @@
+=
+TypeSanitizer
+=
+
+.. contents::
+   :local:
+
+Introduction
+
+
+The TypeSanitizer is a detector for strict type aliasing violations. It 
consists of a compiler
+instrumentation module and a run-time library. C/C++ has type-based aliasing 
rules, and LLVM 
+can exploit these for optimizations given the TBAA metadata Clang emits. In 
general, a pointer 
+of a given type cannot access an object of a 
diff erent type, with only a few exceptions. 
+
+These rules aren't always apparent to users, which leads to code that violates 
these rules
+(e.g. for type punning). This can lead to optimization passes introducing bugs 
unless the 
+code is build with ``-fno-strict-aliasing``, sacrificing performance.
+
+TypeSanitizer is built to catch when these strict aliasing rules have been 
violated, helping 
+users find where such bugs originate in their code despite the code looking 
valid at first glance.
+
+As TypeSanitizer is still experimental, it can currently have a large impact 
on runtime speed, 
+memory use, and code size. It also has a large compile-time overhead. Work is 
being done to 
+reduce these impacts.
+
+The TypeSanitizer Algorithm
+===
+For each TBAA type-access descriptor, encoded in LLVM IR using TBAA Metadata, 
the instrumentation 
+pass generates descriptor tales. Thus there is a unique pointer to each type 
(and access descriptor).
+These tables are comdat (except for anonymous-namespace types), so the pointer 
values are unique 
+across the program.
+
+The descriptors refer to other descriptors to form a type aliasing tree, like 
how LLVM's TBAA data 
+does.
+
+The runtime uses 8 bytes of shadow memory, the size of the pointer to the type 
descriptor, for 
+every byte of accessed data in the program. The first byte of a type will have 
its shadow memory 
+be set to the pointer to its type descriptor. Aside from that, there are some 
other values it may be.
+
+* 0 is used to represent an unknown type
+* Negative numbers represent an interior byte: A byte inside a type that is 
not the first one. As an 
+  example, a value of -2 means you are in the third byte of a type.
+
+The Instrumentation first checks for an exact match between the type of the 
current access and the 
+type for that address in the shadow memory. This can quickly be done by 
checking pointer values. If 
+it matches, it checks the remaining shadow memory of the type to ensure they 
are the correct negative 
+numbers. If this fails, it calls the "slow path" check. If the exact match 
fails, we check to see if 
+the value, and the remainder of the shadow bytes, is 0. If they are, we can 
set the shadow memory to 
+the correct type descriptor pointer for the first byte, and the correct 
negative numbers for the rest 
+of the type's shadow.
+
+If the type in shadow memory is neither an exact match nor 0, we call the 
slower runtime check. It 
+uses the full TBAA algorithm, just as the compiler does, to determine when two 
types are permitted to 
+alias.
+
+The instrumentation pass inserts calls to the memset intrinsic to set the 
memory updated by memset, 
+memcpy, and memmove, as well as allocas/byval (and for lifetime.start/end) to 
reset the shadow memory 
+to reflect that the type is now unknown. The runtime intercepts memset, 
memcpy, etc. to perform the 
+same function for the library calls.
+
+How to build
+
+
+Build LLVM/Clang with `CMake `_ and enable
+the ``compiler-rt`` runtime. An example CMake configuration that will allow
+for the use/testing of TypeSanitizer:
+
+.. code-block:: console
+
+   $ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" 
-DLLVM_ENABLE_RUNTIMES="compiler-rt" /llvm
+
+Usage
+=
+
+Compile and link your program with ``-fsanitize=type`` flag. The
+TypeSanitizer run-time library should be linked to the final executable, so
+make sure to use ``clang`` (not ``ld``) for the final link step. To
+get a reasonable performance add ``-O1`` or higher.
+TypeSanitizer by default doesn't print the full stack trace in error messages. 
Use ``TYSAN_OPTIONS=print_sta

[clang] [Clang] Fixed UnresolvedLookupExpr propagating into the codegen phase (PR #124609)

2025-01-28 Thread via cfe-commits

https://github.com/TilakChad updated 
https://github.com/llvm/llvm-project/pull/124609

>From e97f2215394198b75fd6ebf6ef2cf5d63e7ea444 Mon Sep 17 00:00:00 2001
From: Tilak Chad 
Date: Tue, 28 Jan 2025 00:09:33 +0545
Subject: [PATCH 1/2] [Clang] Fixed UnresolvedLookupExpr propagating into the
 codegen phase

---
 clang/lib/Sema/SemaOverload.cpp   | 10 -
 .../SemaCXX/deduced-return-type-cxx14.cpp | 42 +++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6ae9c51c06b315..b6cb358eb71c8b 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14228,9 +14228,17 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, 
Expr *Fn,
 const FunctionDecl *FDecl = Best->Function;
 if (FDecl && FDecl->isTemplateInstantiation() &&
 FDecl->getReturnType()->isUndeducedType()) {
+
+  // UnresolvedLookupExpr will not be resolved again inside non-dependent
+  // function (i.e non-templated function in this case).
+  const FunctionDecl *EnclosingFn = getCurFunctionDecl();
+  const bool Resolvable =
+  EnclosingFn && EnclosingFn->getTemplatedKind() ==
+ FunctionDecl::TemplatedKind::TK_FunctionTemplate;
+
   if (const auto *TP =
   FDecl->getTemplateInstantiationPattern(/*ForDefinition=*/false);
-  TP && TP->willHaveBody()) {
+  TP && TP->willHaveBody() && Resolvable) {
 return CallExpr::Create(Context, Fn, Args, Context.DependentTy,
 VK_PRValue, RParenLoc, 
CurFPFeatureOverrides());
   }
diff --git a/clang/test/SemaCXX/deduced-return-type-cxx14.cpp 
b/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
index c33e07088ba32f..aa62c4a57a6366 100644
--- a/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
+++ b/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
@@ -703,6 +703,48 @@ auto f(auto x) { // cxx14-error {{'auto' not allowed in 
function prototype}}
   return f(1) + 1;
 }
 
+namespace GH122892 {
+  struct NonTemplate {
+void caller() {
+c1(int{}); // since-cxx20-error {{cannot be used before it is defined}}
+c2(int{}); // since-cxx14-error {{cannot be used before it is defined}}
+}
+
+static auto c1(auto x) { // since-cxx20-note {{declared here}} // 
cxx14-error {{'auto' not allowed in function prototype}}
+}
+
+template 
+static auto c2(T x) { // since-cxx14-note {{declared here}}
+return x;
+}
+  };
+
+  struct FunctionTemplateSpecialized {
+template 
+void specialized(){}
+
+template <>
+void specialized() {
+  c1(int{}); // since-cxx20-error {{cannot be used before it is defined}}
+  c2(int{}); // since-cxx14-error {{cannot be used before it is defined}}
+}
+
+static auto c1(auto x) { // since-cxx20-note {{declared here}} // 
cxx14-error {{'auto' not allowed in function prototype}}
+}
+
+template 
+static auto c2(T x) { // since-cxx14-note {{declared here}}
+return x;
+}
+  };
+
+  struct MemberInit {
+int x1 = c1(int{}); // since-cxx20-error {{cannot be used before it is 
defined}}
+
+static auto c1(auto x) { return x; } // since-cxx20-note {{declared here}} 
// cxx14-error {{'auto' not allowed in function prototype}}
+  };
+
+}
 }
 
 #if __cplusplus >= 202002L

>From 2204b252f3c0cb596fe52bd83f14fede5040dceb Mon Sep 17 00:00:00 2001
From: Tilak Chad 
Date: Tue, 28 Jan 2025 22:54:08 +0545
Subject: [PATCH 2/2] [Clang] Consider current DeclContext instead of enclosing
 function for checking dependence of UnresolvedLookupExpr

---
 clang/lib/Sema/SemaOverload.cpp | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index b6cb358eb71c8b..6fb68f186293e5 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14229,12 +14229,10 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, 
Expr *Fn,
 if (FDecl && FDecl->isTemplateInstantiation() &&
 FDecl->getReturnType()->isUndeducedType()) {
 
-  // UnresolvedLookupExpr will not be resolved again inside non-dependent
-  // function (i.e non-templated function in this case).
-  const FunctionDecl *EnclosingFn = getCurFunctionDecl();
-  const bool Resolvable =
-  EnclosingFn && EnclosingFn->getTemplatedKind() ==
- FunctionDecl::TemplatedKind::TK_FunctionTemplate;
+  // As there'll be no attempt to resolve UnresolvedLookupExpr again inside
+  // non-dependent context, skip considering it as type-dependent.
+  const DeclContext *DC = CurContext;
+  const bool Resolvable = DC && DC->isDependentContext();
 
   if (const auto *TP =
   FDecl->getTemplateInstantiationPattern(/*ForDefinition=*/false);

___
cfe-commits mailing list
cfe-co

[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

2025-01-28 Thread Yanzuo Liu via cfe-commits

zwuis wrote:

Release note is not needed if this PR is cherry-picked to `release/20.x` branch.

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


[clang] eb10e94 - NFC: convert clang/test/AST/HLSL/StructuredBuffers-AST.hlsl to unix line endings

2025-01-28 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2025-01-28T15:48:34-03:00
New Revision: eb10e94180dd722cf54cfaf1ed9d32aa0bb134a0

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

LOG: NFC: convert clang/test/AST/HLSL/StructuredBuffers-AST.hlsl to unix line 
endings

Added: 


Modified: 
clang/test/AST/HLSL/StructuredBuffers-AST.hlsl

Removed: 




diff  --git a/clang/test/AST/HLSL/StructuredBuffers-AST.hlsl 
b/clang/test/AST/HLSL/StructuredBuffers-AST.hlsl
index db3f2d405e686e..6bc2e9a3106630 100644
--- a/clang/test/AST/HLSL/StructuredBuffers-AST.hlsl
+++ b/clang/test/AST/HLSL/StructuredBuffers-AST.hlsl
@@ -1,222 +1,222 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY \
-// RUN:  -DRESOURCE=StructuredBuffer %s | FileCheck 
-DRESOURCE=StructuredBuffer \
-// RUN:  -check-prefix=EMPTY %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
-// RUN:   -DRESOURCE=StructuredBuffer %s | FileCheck 
-DRESOURCE=StructuredBuffer \
-// RUN:   -check-prefixes=CHECK,CHECK-SRV,CHECK-SUBSCRIPT,CHECK-LOAD %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY \
-// RUN:  -DRESOURCE=RWStructuredBuffer %s | FileCheck 
-DRESOURCE=RWStructuredBuffer \
-// RUN:  -check-prefix=EMPTY %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
-// RUN:   -DRESOURCE=RWStructuredBuffer %s | FileCheck 
-DRESOURCE=RWStructuredBuffer \
-// RUN:   
-check-prefixes=CHECK,CHECK-UAV,CHECK-SUBSCRIPT,CHECK-COUNTER,CHECK-LOAD %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY \
-// RUN:  -DRESOURCE=AppendStructuredBuffer %s | FileCheck 
-DRESOURCE=AppendStructuredBuffer \
-// RUN:  -check-prefix=EMPTY %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
-// RUN:   -DRESOURCE=AppendStructuredBuffer %s | FileCheck 
-DRESOURCE=AppendStructuredBuffer \
-// RUN:   -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-APPEND %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY \
-// RUN:  -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck 
-DRESOURCE=ConsumeStructuredBuffer \
-// RUN:  -check-prefix=EMPTY %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
-// RUN:   -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck 
-DRESOURCE=ConsumeStructuredBuffer \
-// RUN:   -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-CONSUME %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY \
-// RUN:  -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck 
-DRESOURCE=RasterizerOrderedStructuredBuffer \
-// RUN:  -check-prefix=EMPTY %s
-//
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
-// RUN:   -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck 
-DRESOURCE=RasterizerOrderedStructuredBuffer \
-// RUN:   -check-prefixes=CHECK,CHECK-UAV,CHECK-ROV,CHECK-SUBSCRIPT,CHECK-LOAD 
%s
-
-// This test tests two 
diff erent AST generations for each structured buffer.
-// The "EMPTY" test mode verifies the AST generated by forward declaration
-// of the HLSL types which happens on initializing the HLSL external AST with
-// an AST Context.
-
-// The non-empty mode has a use that requires the resource type be complete,
-// which results in the AST being populated by the external AST source. That
-// case covers the full implementation of the template declaration and the
-// instantiated specialization.
-
-// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit [[RESOURCE]]
-// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <> 
 typename depth 0 index 0 element_type
-// EMPTY-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <> 
'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_structured_resource_element_compatible'
-// EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <> 
-// EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0'
-// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' 
dependent depth 0 index 0
-// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
-// EMPTY-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0'
-// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' 
dependent depth 0 index 0
-// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type'
-// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit  class [[RESOURCE]]
-// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
-
-// There should be no more occurrences of [[RESOURCE]]
-// EMPTY-NOT: {{[^[:alnum:]]}}[[RESOURCE]]
-
-#ifndef EMPTY
-
-RESOURCE Buffer;
-
-#endif
-
-// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit [[RESOURCE]

[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

2025-01-28 Thread Vlad Serebrennikov via cfe-commits


@@ -4861,8 +4861,9 @@ static void TryListInitialization(Sema &S,
 S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) 
&&
 "Deduced to other type?");
 TryArrayCopy(S,
- InitializationKind::CreateCopy(Kind.getLocation(),
-InitList->getLBraceLoc()),
+ InitializationKind::CreateDirect(Kind.getLocation(),
+  InitList->getLBraceLoc(),
+  
InitList->getRBraceLoc()),

Endilll wrote:

I think your understanding is correct.

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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread Nick Desaulniers via cfe-commits


@@ -4352,19 +4352,11 @@ def stack_usage_file : Separate<["-"], 
"stack-usage-file">,
 def fextend_variable_liveness_EQ : Joined<["-"], "fextend-variable-liveness=">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Extend the liveness of user variables through optimizations to "
-   "prevent stale or optimized-out variable values when debugging. Can 
"
-   "be applied to all user variables, or just to the C++ 'this' ptr. "
-   "May choose not to extend the liveness of some variables, such as "
-   "non-scalars larger than 4 unsigned ints, or variables in any "
-   "inlined functions.">,
+   "prevent stale or optimized-out variable values when debugging."

nickdesaulniers wrote:

> I've fixed the build failure with 
> https://github.com/llvm/llvm-project/commit/8578b816fa9050c33561f06d631459e12645953a.

Thanks!

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


[clang] [CUDA] Make target intrinsics work with ptx 8.7 (PR #124818)

2025-01-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Artem Belevich (Artem-B)


Changes

Fixes build break with CUDA-12.8 introduced in #123398

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


2 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsNVPTX.td (+2-1) 
- (modified) clang/test/CodeGen/builtins-nvptx.c (+5) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsNVPTX.td 
b/clang/include/clang/Basic/BuiltinsNVPTX.td
index b43e8ba57f7a0b..9d24a992563a45 100644
--- a/clang/include/clang/Basic/BuiltinsNVPTX.td
+++ b/clang/include/clang/Basic/BuiltinsNVPTX.td
@@ -48,8 +48,9 @@ class PTX : PTXFeatures {
   let Features = !strconcat("ptx", version, "|", newer.Features);
 }
 
-let Features = "ptx86" in def PTX86 : PTXFeatures;
+let Features = "ptx87" in def PTX87 : PTXFeatures;
 
+def PTX86 : PTX<"86", PTX87>;
 def PTX85 : PTX<"85", PTX86>;
 def PTX84 : PTX<"84", PTX85>;
 def PTX83 : PTX<"83", PTX84>;
diff --git a/clang/test/CodeGen/builtins-nvptx.c 
b/clang/test/CodeGen/builtins-nvptx.c
index 26c465eef306a0..ffa41c85c2734f 100644
--- a/clang/test/CodeGen/builtins-nvptx.c
+++ b/clang/test/CodeGen/builtins-nvptx.c
@@ -28,6 +28,11 @@
 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown 
-target-cpu sm_89 -target-feature +ptx81 \
 // RUN:-fcuda-is-device -emit-llvm -o - -x cuda %s \
 // RUN:   | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM89 %s
+// ###  The last run to check with the highest SM and PTX version available
+// ###  to make sure target builtins are still accepted.
+// RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown 
-target-cpu sm_100a -target-feature +ptx87 \
+// RUN:-fcuda-is-device -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM89 %s
 
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))

``




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


[clang] [clang] fix template argument conversion (PR #124386)

2025-01-28 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] disallow narrowing when matching template template parameters (PR #124313)

2025-01-28 Thread Matheus Izvekov via cfe-commits

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


[clang] [CUDA] Make target intrinsics work with ptx 8.7 (PR #124818)

2025-01-28 Thread Artem Belevich via cfe-commits

https://github.com/Artem-B created 
https://github.com/llvm/llvm-project/pull/124818

Fixes build break with CUDA-12.8 introduced in #123398

>From ebb322550e72a4c7c58d990340701248d6f61c95 Mon Sep 17 00:00:00 2001
From: Artem Belevich 
Date: Tue, 28 Jan 2025 10:45:16 -0800
Subject: [PATCH] [CUDA] Make target intrinsics work with ptx 8.7

---
 clang/include/clang/Basic/BuiltinsNVPTX.td | 3 ++-
 clang/test/CodeGen/builtins-nvptx.c| 5 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/BuiltinsNVPTX.td 
b/clang/include/clang/Basic/BuiltinsNVPTX.td
index b43e8ba57f7a0b..9d24a992563a45 100644
--- a/clang/include/clang/Basic/BuiltinsNVPTX.td
+++ b/clang/include/clang/Basic/BuiltinsNVPTX.td
@@ -48,8 +48,9 @@ class PTX : PTXFeatures {
   let Features = !strconcat("ptx", version, "|", newer.Features);
 }
 
-let Features = "ptx86" in def PTX86 : PTXFeatures;
+let Features = "ptx87" in def PTX87 : PTXFeatures;
 
+def PTX86 : PTX<"86", PTX87>;
 def PTX85 : PTX<"85", PTX86>;
 def PTX84 : PTX<"84", PTX85>;
 def PTX83 : PTX<"83", PTX84>;
diff --git a/clang/test/CodeGen/builtins-nvptx.c 
b/clang/test/CodeGen/builtins-nvptx.c
index 26c465eef306a0..ffa41c85c2734f 100644
--- a/clang/test/CodeGen/builtins-nvptx.c
+++ b/clang/test/CodeGen/builtins-nvptx.c
@@ -28,6 +28,11 @@
 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown 
-target-cpu sm_89 -target-feature +ptx81 \
 // RUN:-fcuda-is-device -emit-llvm -o - -x cuda %s \
 // RUN:   | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM89 %s
+// ###  The last run to check with the highest SM and PTX version available
+// ###  to make sure target builtins are still accepted.
+// RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown 
-target-cpu sm_100a -target-feature +ptx87 \
+// RUN:-fcuda-is-device -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM89 %s
 
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))

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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread Nick Desaulniers via cfe-commits


@@ -4352,19 +4352,11 @@ def stack_usage_file : Separate<["-"], 
"stack-usage-file">,
 def fextend_variable_liveness_EQ : Joined<["-"], "fextend-variable-liveness=">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Extend the liveness of user variables through optimizations to "
-   "prevent stale or optimized-out variable values when debugging. Can 
"
-   "be applied to all user variables, or just to the C++ 'this' ptr. "
-   "May choose not to extend the liveness of some variables, such as "
-   "non-scalars larger than 4 unsigned ints, or variables in any "
-   "inlined functions.">,
+   "prevent stale or optimized-out variable values when debugging."

nickdesaulniers wrote:

```
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
```

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


[clang] [Clang] Fixed invalid virtual copy constructor assertion (PR #124819)

2025-01-28 Thread via cfe-commits

https://github.com/vortex73 created 
https://github.com/llvm/llvm-project/pull/124819

None

>From cee34e7727b0f8b9440b0d687a2da2f0b4734c15 Mon Sep 17 00:00:00 2001
From: Narayan Sreekumar 
Date: Wed, 29 Jan 2025 00:11:23 +0530
Subject: [PATCH] [Clang] Fixed invalid virtual copy constructor assertion

---
 clang/lib/Sema/SemaDeclCXX.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc9..d935292191ea58 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6697,6 +6697,10 @@ static bool canPassInRegisters(Sema &S, CXXRecordDecl *D,
   if (D->isDependentType() || D->isInvalidDecl())
 return false;
 
+  for (const CXXMethodDecl *MD : D->methods()) {
+if (MD->isInvalidDecl())
+  return false;
+  }
   // Clang <= 4 used the pre-C++11 rule, which ignores move operations.
   // The PS4 platform ABI follows the behavior of Clang 3.2.
   if (CCK == TargetInfo::CCK_ClangABI4OrPS4)

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


[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124674)

2025-01-28 Thread Kazu Hirata via cfe-commits

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


[clang] [Serialization] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124676)

2025-01-28 Thread Kazu Hirata via cfe-commits

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


[clang] [Sema] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124675)

2025-01-28 Thread Kazu Hirata via cfe-commits

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


[clang] 2ef497e - [Sema] Migrate away from PointerUnion::dyn_cast (NFC) (#124675)

2025-01-28 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-01-28T10:56:26-08:00
New Revision: 2ef497e5b02650c59aa71676b7d891a138519685

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

LOG: [Sema] Migrate away from PointerUnion::dyn_cast (NFC) (#124675)

Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect TransExpr to be nonnull.

Added: 


Modified: 
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index f04adf7fdf8ad2..15d199e7f63fec 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -14903,7 +14903,7 @@ 
TreeTransform::TransformExprRequirement(concepts::ExprRequirement *Req)
 TransRetReq.emplace(TPL);
   }
   assert(TransRetReq && "All code paths leading here must set TransRetReq");
-  if (Expr *E = TransExpr.dyn_cast())
+  if (Expr *E = dyn_cast(TransExpr))
 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
Req->getNoexceptLoc(),
std::move(*TransRetReq));



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


[clang] 69c9bed - [Serialization] Migrate away from PointerUnion::dyn_cast (NFC) (#124676)

2025-01-28 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-01-28T10:57:01-08:00
New Revision: 69c9bed21b902bf83828c78d69691925f5452c35

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

LOG: [Serialization] Migrate away from PointerUnion::dyn_cast (NFC) (#124676)

Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect FD->TemplateOrSpecialization to be nonnull.

Added: 


Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 87e1931ee47fd6..8210eb2143acf5 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4682,8 +4682,8 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
 MSInfo->setPointOfInstantiation(POI);
   } else {
 auto *FD = cast(D);
-if (auto *FTSInfo = FD->TemplateOrSpecialization
-.dyn_cast())
+if (auto *FTSInfo = dyn_cast(
+FD->TemplateOrSpecialization))
   FTSInfo->setPointOfInstantiation(POI);
 else
   cast(FD->TemplateOrSpecialization)



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


[clang] e29c085 - [clang] disallow narrowing when matching template template parameters (#124313)

2025-01-28 Thread via cfe-commits

Author: Matheus Izvekov
Date: 2025-01-28T15:51:17-03:00
New Revision: e29c085812e259910a3d8b6c2d2f471d1c3eede4

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

LOG: [clang] disallow narrowing when matching template template parameters 
(#124313)

This fixes the core issue described in P3579, following the design
intent of P0522 to not introduce any new cases where a template template
parameter match is allowed for a template which is not valid for all
possible uses.

With this patch, narrowing conversions are disallowed for TTP matching.

This reuses the existing machinery for diagnosing narrowing in a
converted constant expression.
Since P0522 is a DR and we apply it all the way back to C++98, this
brings that machinery to use in older standards, in this very narrow
scope of TTP matching.

This still doesn't solve the ambiguity when partial ordering NTTPs of
different integral types, this is blocked by a different bug which will
be fixed in a subsequent patch (but the test cases are added).

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/drs/cwg0xx.cpp
clang/test/CXX/drs/cwg12xx.cpp
clang/test/CXX/drs/cwg3xx.cpp
clang/test/CXX/expr/expr.const/p3-0x.cpp
clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
clang/test/Modules/cxx-templates.cpp
clang/test/SemaObjCXX/noescape.mm
clang/test/SemaTemplate/cwg2398.cpp
clang/test/SemaTemplate/default-arguments.cpp
clang/test/SemaTemplate/instantiate-template-template-parm.cpp
clang/test/SemaTemplate/instantiation-default-2.cpp
clang/test/SemaTemplate/nested-template.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
clang/test/SemaTemplate/temp_arg_template.cpp
clang/test/SemaTemplate/temp_arg_template_p0522.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 74b09025967afc..7b5562a80a35a6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -337,6 +337,9 @@ C++17 Feature Support
 ^
 - The implementation of the relaxed template template argument matching rules 
is
   more complete and reliable, and should provide more accurate diagnostics.
+  This implements:
+  - `P3310R5: Solving issues introduced by relaxed template template parameter 
matching `_.
+  - `P3579R0: Fix matching of non-type template parameters when matching 
template template parameters `_.
 
 Resolutions to C++ Defect Reports
 ^

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a09fe037fdeb9a..db911ed121e951 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -82,11 +82,11 @@ def err_typecheck_converted_constant_expression_indirect : 
Error<
   "conversion from %0 to %1 in converted constant expression would "
   "bind reference to a temporary">;
 def err_expr_not_cce : Error<
-  "%select{case value|enumerator value|non-type template argument|"
+  "%select{case value|enumerator value|non-type template argument|non-type 
parameter of template template parameter|"
   "array size|explicit specifier argument|noexcept specifier argument|"
   "call to 'size()'|call to 'data()'}0 is not a constant expression">;
 def ext_cce_narrowing : ExtWarn<
-  "%select{case value|enumerator value|non-type template argument|"
+  "%select{case value|enumerator value|non-type template argument|non-type 
parameter of template template parameter|"
   "array size|explicit specifier argument|noexcept specifier argument|"
   "call to 'size()'|call to 'data()'}0 %select{cannot be narrowed from "
   "type %2 to %3|evaluates to %2, which cannot be narrowed to type %3}1">,

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 528304409b8092..67fd7e396f1277 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1,6 +1,7 @@ class Sema final : public SemaBase {
 CCEK_CaseValue,///< Expression in a case label.
 CCEK_Enumerator,   ///< Enumerator value with fixed underlying type.
 CCEK_TemplateArg,  ///< Value of a non-type template parameter.
+CCEK_InjectedTTP,  ///< Injected parameter of a template template 
parameter.
 CC

[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `flang-aarch64-dylib` 
running on `linaro-flang-aarch64-dylib` while building `clang,llvm` at step 5 
"build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
...
32.412 [3993/21/2812] Building TestTransformDialectExtensionTypes.h.inc...
32.412 [3993/20/2813] Building TestTilingInterfaceTransformOps.cpp.inc...
32.412 [3993/19/2814] Generating ../../../../share/man/man1/scan-build.1
32.413 [3993/18/2815] Generating ../../../../lib/libscanbuild/compilation.py
32.413 [3993/17/2816] Generating ../../../../lib/libscanbuild/intercept.py
32.413 [3993/16/2817] Generating ../../../../lib/libscanbuild/report.py
32.413 [3993/15/2818] Building TestTilingInterfaceTransformOps.h.inc...
32.414 [3993/14/2819] Building CXX object 
tools/mlir/tools/tblgen-lsp-server/CMakeFiles/tblgen-lsp-server.dir/tblgen-lsp-server.cpp.o
32.414 [3993/13/2820] Generating 
../../../../lib/libscanbuild/resources/scanview.css
32.434 [3993/12/2821] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/clang/include/clang/Driver/Options.inc
 
cd /home/tcwg-buildbot/worker/flang-aarch64-dylib/build && 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/llvm-tblgen 
-gen-opt-parser-defs -I 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/clang/include/clang/Driver
 -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/clang/include 
-I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/clang/include 
-I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/include 
-I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/llvm/include 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
32.441 [3993/11/2822] Linking CXX static library lib/libLLVMDlltoolDriver.a
32.441 [3993/10/2823] Linking CXX static library lib/libLLVMInterfaceStub.a
32.443 [3993/9/2824] Linking CXX static library lib/libLLVMLibDriver.a
32.444 [3993/8/2825] Linking CXX static library lib/libLLVMDebugInfoDWARF.a
32.444 [3993/7/2826] Linking CXX static library lib/libLLVMObjCopy.a
32.445 [3993/6/2827] Linking CXX static library lib/libLLVMRuntimeDyld.a
32.446 [3993/5/2828] Linking CXX static library lib/libLLVMXRay.a
32.450 [3993/4/2829] Linking CXX static library lib/libLLVMObjectYAML.a
32.453 [3993/3/2830] Linking CXX static library lib/libLLVMDebugInfoPDB.a
32.458 [3993/2/2831] Linking CXX static library lib/libLLVMJITLink.a
32.651 [3993/1/2832] Linking CXX executable bin/clang-tblgen
ninja: build stopped: subcommand failed.

```



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


[clang] [Clang] [NFC] Introduce `ConstDynamicRecursiveASTVisitor` (reland) (PR #124821)

2025-01-28 Thread via cfe-commits

llvmbot wrote:




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

Author: None (Sirraide)


Changes

This relands #122991.

I candidly still have no idea what went wrong last time; a bunch of bots 
started complaining with a relatively obscure error (see below). I’ve updated 
the branch and tried bulding Clang using both Clang itself and GCC and 
encountered no problems.


```console
FAILED: 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o
 
ccache /usr/bin/c++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/lib/AST
 -I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/include 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/include
 -I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/include 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/llvm/include 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-fno-lifetime-dse -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 -Wdel
 ete-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  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o
 -MF 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o.d
 -o 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o
 -c 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:
 In member function ‘virtual bool 
clang::DynamicRecursiveASTVisitorBase::TraverseAST(clang::DynamicRecursiveASTVisitorBase::MaybeConst&)’:
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 error: expected ‘;’ before ‘::’ token
  284 | .template 
RecursiveASTVisitor>::Function(  \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template 
RecursiveASTVisitor>::Function(  \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:296:17:
 error: ‘::TraverseAST’ has not been declared
  296 | FORWARD_TO_BASE(TraverseAST, ASTContext, &)
  | ^~~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:53:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template 
RecursiveASTVisitor>::Function(  \
  | ^~~~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:
 In member function ‘virtual bool 
clang::DynamicRecursiveASTVisitorBase::TraverseAttr(clang::DynamicRecursiveASTVisitorBase::MaybeConst*)’:
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 error: expected ‘;’ before ‘::’ token
  284 | .template 
RecursiveASTVisitor>::Function(  \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template 
RecursiveASTVisitor>::Function(  \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:297:17:
 error: ‘::TraverseAttr’ has not been declared
  297 | FORWARD_TO_BASE(TraverseAttr, Attr, *)
  | ^~~~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:53:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template 
RecursiveASTVisitor>::Function(  \
  |  

[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-28 Thread Eli Friedman via cfe-commits


@@ -752,10 +780,13 @@ RValue ARMABIInfo::EmitVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
   CharUnits SlotSize = CharUnits::fromQuantity(4);
 
   // Empty records are ignored for parameter passing purposes.
-  if (isEmptyRecord(getContext(), Ty, true))
+  uint64_t Size = getContext().getTypeSize(Ty);
+  bool IsEmpty = isEmptyRecord(getContext(), Ty, true);
+  if ((IsEmpty || Size == 0) && shouldIgnoreEmptyArg(Ty))
 return Slot.asRValue();
 
-  CharUnits TySize = getContext().getTypeSizeInChars(Ty);
+  CharUnits TySize =
+  std::max(getContext().getTypeSizeInChars(Ty), 
CharUnits::fromQuantity(1));

efriedma-quic wrote:

If we get here, we know the size isn't zero, I think?

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


[clang] [clang] fix template argument conversion (PR #124386)

2025-01-28 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/124386

>From 8cf1056761d23fe3191d1ac3421da350b7404eb1 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 24 Jan 2025 19:25:38 -0300
Subject: [PATCH] [clang] fix template argument conversion

Converted template arguments need to be converted again, if
the corresponding template parameter changed, as different
conversions might apply in that case.
---
 clang/docs/ReleaseNotes.rst |   3 +
 clang/include/clang/Sema/Sema.h |   3 +
 clang/lib/Sema/SemaTemplate.cpp | 102 +++-
 clang/lib/Sema/TreeTransform.h  |   6 +-
 clang/test/SemaTemplate/cwg2398.cpp |  20 --
 5 files changed, 66 insertions(+), 68 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7b5562a80a35a6..9c4911476d0ac9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1033,6 +1033,9 @@ Bug Fixes to C++ Support
 - Fix immediate escalation not propagating through inherited constructors.  
(#GH112677)
 - Fixed assertions or false compiler diagnostics in the case of C++ modules for
   lambda functions or inline friend functions defined inside templates 
(#GH122493).
+- Fix template argument checking so that converted template arguments are
+  converted again. This fixes some issues with partial ordering involving
+  template template parameters with non-type template parameters.
 - Clang now rejects declaring an alias template with the same name as its 
template parameter. (#GH123423)
 - Fixed the rejection of valid code when referencing an enumerator of an 
unscoped enum member with a prior declaration. (#GH124405)
 - Fixed immediate escalation of non-dependent expressions. (#GH123405)
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 67fd7e396f1277..8a6dd4f6820bc7 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11780,6 +11780,9 @@ class Sema final : public SemaBase {
   /// declaration and the type of its corresponding non-type template
   /// parameter, produce an expression that properly refers to that
   /// declaration.
+  /// FIXME: This is used in some contexts where the resulting expression
+  /// doesn't need to live too long. It would be useful if this function
+  /// could return a temporary expression.
   ExprResult BuildExpressionFromDeclTemplateArgument(
   const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
   NamedDecl *TemplateParam = nullptr);
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 210df2836eeb07..cb9d78734e6bbf 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -5199,7 +5199,7 @@ convertTypeTemplateArgumentToTemplate(ASTContext 
&Context, TypeLoc TLoc) {
 }
 
 bool Sema::CheckTemplateArgument(
-NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template,
+NamedDecl *Param, TemplateArgumentLoc &ArgLoc, NamedDecl *Template,
 SourceLocation TemplateLoc, SourceLocation RAngleLoc,
 unsigned ArgumentPackIndex,
 SmallVectorImpl &SugaredConverted,
@@ -5208,9 +5208,10 @@ bool Sema::CheckTemplateArgument(
 bool PartialOrderingTTP, bool *MatchedPackOnParmToNonPackOnArg) {
   // Check template type parameters.
   if (TemplateTypeParmDecl *TTP = dyn_cast(Param))
-return CheckTemplateTypeArgument(TTP, Arg, SugaredConverted,
+return CheckTemplateTypeArgument(TTP, ArgLoc, SugaredConverted,
  CanonicalConverted);
 
+  const TemplateArgument &Arg = ArgLoc.getArgument();
   // Check non-type template parameters.
   if (NonTypeTemplateParmDecl *NTTP =dyn_cast(Param)) 
{
 // Do substitution on the type of the non-type template parameter
@@ -5252,63 +5253,73 @@ bool Sema::CheckTemplateArgument(
 return true;
 }
 
-switch (Arg.getArgument().getKind()) {
-case TemplateArgument::Null:
-  llvm_unreachable("Should never see a NULL template argument here");
-
-case TemplateArgument::Expression: {
-  Expr *E = Arg.getArgument().getAsExpr();
+auto checkExpr = [&](Expr *E) -> Expr * {
   TemplateArgument SugaredResult, CanonicalResult;
   unsigned CurSFINAEErrors = NumSFINAEErrors;
   ExprResult Res =
   CheckTemplateArgument(NTTP, NTTPType, E, SugaredResult,
 CanonicalResult, PartialOrderingTTP, CTAK);
-  if (Res.isInvalid())
-return true;
   // If the current template argument causes an error, give up now.
-  if (CurSFINAEErrors < NumSFINAEErrors)
-return true;
+  if (Res.isInvalid() || CurSFINAEErrors < NumSFINAEErrors)
+return nullptr;
+  SugaredConverted.push_back(SugaredResult);
+  CanonicalConverted.push_back(CanonicalResult);
+  return Res.get();
+};
+
+switch (Arg.getKind()) {
+case TemplateArgument::Null:
+  llvm_unreachable("Should never see a NULL 

[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-28 Thread Eli Friedman via cfe-commits


@@ -366,9 +387,15 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, 
bool isVariadic,
 return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
   }
 
-  // Ignore empty records.
-  if (isEmptyRecord(getContext(), Ty, true))
-return ABIArgInfo::getIgnore();
+  // Empty records are either ignored completely or passed as if they were a
+  // 1-byte object, depending on the ABI and language standard.
+  if (isEmptyRecord(getContext(), Ty, true) ||
+  getContext().getTypeSize(Ty) == 0) {
+if (shouldIgnoreEmptyArg(Ty))

efriedma-quic wrote:

I think I'd prefer to write this something like:

```
if (size == zero)
  return getIgnore();
if (isempty() && isWatchOS())
  return getIgnore();
```

This should be equivalent because an empty struct in C is size zero anyway.

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


[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-28 Thread Eli Friedman via cfe-commits


@@ -588,7 +615,8 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy, 
bool isVariadic,
 
   // Otherwise this is an AAPCS variant.
 
-  if (isEmptyRecord(getContext(), RetTy, true))
+  if (isEmptyRecord(getContext(), RetTy, true) ||
+  getContext().getTypeSize(RetTy) == 0)

efriedma-quic wrote:

Does this change actually have any effect?

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


[clang] [clang][bytecode] Fix dummy handling for p2280r4 (PR #124396)

2025-01-28 Thread via cfe-commits

cor3ntin wrote:

Is that a full P2280 implementation (I'm not familiar enough with the new 
constexpr engine to figure that out but going by the tests it seems to be)

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


[clang] [DNC] Break formatting to test clang-format (PR #124809)

2025-01-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Jacob Lambert (lamb-j)


Changes



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


1 Files Affected:

- (modified) clang/lib/Driver/Driver.cpp (+6-7) 


``diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 87855fdb799710..e484334fd02d79 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -18,8 +18,8 @@
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
 #include "ToolChains/Darwin.h"
-#include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
+#include "ToolChains/DragonFly.h"
 #include "ToolChains/Fuchsia.h"
 #include "ToolChains/Gnu.h"
 #include "ToolChains/HIPAMD.h"
@@ -107,7 +107,7 @@
 
 using namespace clang::driver;
 using namespace clang;
-using namespace llvm::opt;
+using namespace llvm::opt;
 
 static std::optional getOffloadTargetTriple(const Driver &D,
   const ArgList &Args) 
{
@@ -314,14 +314,14 @@ InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings,
   ContainsError = false;
 
   llvm::opt::Visibility VisibilityMask = 
getOptionVisibilityMask(UseDriverMode);
-  unsigned MissingArgIndex, MissingArgCount;
-  InputArgList Args = getOpts().ParseArgs(ArgStrings, MissingArgIndex,
+  unsigned missing_arg_index, MissingArgCount;
+  InputArgList Args = getOpts().ParseArgs(ArgStrings, missing_arg_index,
   MissingArgCount, VisibilityMask);
 
   // Check for missing argument error.
   if (MissingArgCount) {
 Diag(diag::err_drv_missing_argument)
-<< Args.getArgString(MissingArgIndex) << MissingArgCount;
+<< Args.getArgString(missing_arg_index) << MissingArgCount;
 ContainsError |=
 Diags.getDiagnosticLevel(diag::err_drv_missing_argument,
  SourceLocation()) > 
DiagnosticsEngine::Warning;
@@ -371,8 +371,7 @@ InputArgList Driver::ParseArgStrings(ArrayRef 
ArgStrings,
  DiagnosticsEngine::Warning;
   }
 
-  for (const Arg *A : Args.filtered(options::OPT_o)) {
-if (ArgStrings[A->getIndex()] == A->getSpelling())
+  for (const Arg *A : Args.filtered(options::OPT_o)) { if 
(ArgStrings[A->getIndex()] == A->getSpelling())
   continue;
 
 // Warn on joined arguments that are similar to a long argument.

``




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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Erich Keane via cfe-commits


@@ -44,7 +44,7 @@ class CIRGenerator : public clang::ASTConsumer {
   const clang::CodeGenOptions &codeGenOpts;
 
 protected:
-  std::unique_ptr mlirContext;
+  std::shared_ptr mlirContext;

erichkeane wrote:

Hmm... I don't think the shared pointer is the way here, we should have one of 
them own, and the other observe.  What are the lifetimes of these two objects?  
Is there one of these that has a lifetime that is clearly larger than the other 
that can be the owner, and the other be a reference to it?

@bcardosolopes 

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


[clang] [DNC] Break formatting to test clang-format (PR #124809)

2025-01-28 Thread Jacob Lambert via cfe-commits

https://github.com/lamb-j created 
https://github.com/llvm/llvm-project/pull/124809

None

>From 4ed0192fca412dcb801ea75ad0d086153fa5b531 Mon Sep 17 00:00:00 2001
From: Jacob Lambert 
Date: Tue, 28 Jan 2025 09:43:14 -0800
Subject: [PATCH] [DNC] Break formatting to test clang-format

---
 clang/lib/Driver/Driver.cpp | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 87855fdb799710..e484334fd02d79 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -18,8 +18,8 @@
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
 #include "ToolChains/Darwin.h"
-#include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
+#include "ToolChains/DragonFly.h"
 #include "ToolChains/Fuchsia.h"
 #include "ToolChains/Gnu.h"
 #include "ToolChains/HIPAMD.h"
@@ -107,7 +107,7 @@
 
 using namespace clang::driver;
 using namespace clang;
-using namespace llvm::opt;
+using namespace llvm::opt;
 
 static std::optional getOffloadTargetTriple(const Driver &D,
   const ArgList &Args) 
{
@@ -314,14 +314,14 @@ InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings,
   ContainsError = false;
 
   llvm::opt::Visibility VisibilityMask = 
getOptionVisibilityMask(UseDriverMode);
-  unsigned MissingArgIndex, MissingArgCount;
-  InputArgList Args = getOpts().ParseArgs(ArgStrings, MissingArgIndex,
+  unsigned missing_arg_index, MissingArgCount;
+  InputArgList Args = getOpts().ParseArgs(ArgStrings, missing_arg_index,
   MissingArgCount, VisibilityMask);
 
   // Check for missing argument error.
   if (MissingArgCount) {
 Diag(diag::err_drv_missing_argument)
-<< Args.getArgString(MissingArgIndex) << MissingArgCount;
+<< Args.getArgString(missing_arg_index) << MissingArgCount;
 ContainsError |=
 Diags.getDiagnosticLevel(diag::err_drv_missing_argument,
  SourceLocation()) > 
DiagnosticsEngine::Warning;
@@ -371,8 +371,7 @@ InputArgList Driver::ParseArgStrings(ArrayRef 
ArgStrings,
  DiagnosticsEngine::Warning;
   }
 
-  for (const Arg *A : Args.filtered(options::OPT_o)) {
-if (ArgStrings[A->getIndex()] == A->getSpelling())
+  for (const Arg *A : Args.filtered(options::OPT_o)) { if 
(ArgStrings[A->getIndex()] == A->getSpelling())
   continue;
 
 // Warn on joined arguments that are similar to a long argument.

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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 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,llvm` at step 5 
"build-clangd-clangd-index-server-clangd-indexer".

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


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

```
Step 5 (build-clangd-clangd-index-server-clangd-indexer) failure: build 
(failure)
...
78.441 [1852/18/2874] Building CXX object 
lib/TextAPI/CMakeFiles/LLVMTextAPI.dir/Symbol.cpp.o
78.452 [1851/18/2875] Building CXX object 
lib/TextAPI/CMakeFiles/LLVMTextAPI.dir/SymbolSet.cpp.o
78.459 [1850/18/2876] Building CXX object 
lib/TextAPI/CMakeFiles/LLVMTextAPI.dir/Target.cpp.o
78.462 [1849/18/2877] Building CXX object 
lib/TextAPI/CMakeFiles/LLVMTextAPI.dir/TextAPIError.cpp.o
78.469 [1848/18/2878] Building CXX object 
lib/TextAPI/CMakeFiles/LLVMTextAPI.dir/TextStubCommon.cpp.o
78.470 [1848/17/2879] Building CXX object 
lib/TextAPI/CMakeFiles/LLVMTextAPI.dir/TextStub.cpp.o
78.474 [1848/16/2880] Building CXX object 
lib/TextAPI/CMakeFiles/LLVMTextAPI.dir/Utils.cpp.o
78.482 [1848/15/2881] Building CXX object 
lib/WindowsDriver/CMakeFiles/LLVMWindowsDriver.dir/MSVCPaths.cpp.o
78.504 [1848/14/2882] Linking CXX static library lib/libLLVMTargetParser.a
78.514 [1846/15/2883] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/include/clang/Driver/Options.inc
 
cd /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build && 
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/NATIVE/bin/llvm-tblgen 
-gen-opt-parser-defs -I 
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include/clang/Driver
 
-I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include 
-I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/include 
-I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/include 
-I/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/llvm/include 
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
78.563 [1846/14/2884] Linking CXX static library lib/libLLVMWindowsDriver.a
78.570 [1846/13/2885] Linking CXX static library lib/libLLVMBinaryFormat.a
78.577 [1846/12/2886] Building RISCVGenInstrInfo.inc...
78.856 [1846/11/2887] Building X86GenRegisterInfo.inc...
79.048 [1846/10/2888] Building X86GenFastISel.inc...
79.055 [1846/9/2889] Building X86GenRegisterBank.inc...
79.129 [1846/8/2890] Building AMDGPUGenRegisterInfo.inc...
79.383 [1846/7/2891] Building X86GenGlobalISel.inc...
79.500 [1846/6/2892] Building X86GenMnemonicTables.inc...
80.272 [1846/5/2893] Building RISCVGenGlobalISel.inc...
80.503 [1846/4/2894] Building X86GenDAGISel.inc...
80.980 [1846/3/2895] Building RISCVGenDAGISel.inc...
82.724 [1846/2/2896] Building X86GenInstrInfo.inc...
82.779 [1846/1/2897] Building X86GenSubtargetInfo.inc...
ninja: build stopped: subcommand failed.

```



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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `flang-aarch64-libcxx` 
running on `linaro-flang-aarch64-libcxx` while building `clang,llvm` at step 5 
"build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
...
36.994 [4117/59/3173] Creating library symlink lib/libmlir_async_runtime.so
36.996 [4117/58/3174] Building TestTypeDefs.h.inc...
36.997 [4117/57/3175] Creating library symlink lib/libmlir_arm_runner_utils.so
36.997 [4117/56/3176] Copying clang's stdalign.h...
36.998 [4117/55/3177] Copying clang's __stdarg___gnuc_va_list.h...
36.998 [4117/54/3178] Building TestTypeDefs.cpp.inc...
37.002 [4117/53/3179] Building CXX object 
tools/mlir/lib/IR/CMakeFiles/obj.MLIRIR.dir/PatternMatch.cpp.o
37.004 [4117/52/3180] Building CXX object 
tools/mlir/lib/IR/CMakeFiles/obj.MLIRIR.dir/Verifier.cpp.o
37.005 [4117/51/3181] Copying clang's stdarg.h...
37.006 [4117/50/3182] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/clang/include/clang/Driver/Options.inc
 
cd /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build && 
/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/bin/llvm-tblgen 
-gen-opt-parser-defs -I 
/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/clang/include/clang/Driver
 -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/clang/include 
-I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/clang/include 
-I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/include 
-I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/include 
/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
37.006 [4117/49/3183] Copying clang's __stdarg___va_copy.h...
37.007 [4117/48/3184] Copying clang's __stdarg_header_macro.h...
37.011 [4117/47/3185] Building CXX object 
tools/mlir/lib/IR/CMakeFiles/obj.MLIRIR.dir/Operation.cpp.o
37.025 [4117/46/3186] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRDerivedAttributeOpInterface.dir/DerivedAttributeOpInterface.cpp.o
37.029 [4117/45/3187] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRDestinationStyleOpInterface.dir/DestinationStyleOpInterface.cpp.o
37.032 [4117/44/3188] Building CXX object 
tools/mlir/lib/IR/CMakeFiles/obj.MLIRIR.dir/TypeUtilities.cpp.o
37.033 [4117/43/3189] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRCastInterfaces.dir/CastInterfaces.cpp.o
37.035 [4117/42/3190] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRControlFlowInterfaces.dir/ControlFlowInterfaces.cpp.o
37.037 [4117/41/3191] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRMemorySlotInterfaces.dir/MemorySlotInterfaces.cpp.o
37.039 [4117/40/3192] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRFunctionInterfaces.dir/FunctionInterfaces.cpp.o
37.040 [4117/39/3193] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRFunctionInterfaces.dir/FunctionImplementation.cpp.o
37.042 [4117/38/3194] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRInferTypeOpInterface.dir/InferTypeOpInterface.cpp.o
37.043 [4117/37/3195] Building CXX object 
tools/mlir/lib/IR/CMakeFiles/obj.MLIRIR.dir/RegionKindInterface.cpp.o
37.045 [4117/36/3196] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRCopyOpInterface.dir/CopyOpInterface.cpp.o
37.046 [4117/35/3197] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRParallelCombiningOpInterface.dir/ParallelCombiningOpInterface.cpp.o
37.048 [4117/34/3198] Building CXX object 
tools/mlir/lib/Query/Matcher/CMakeFiles/obj.MLIRQueryMatcher.dir/Parser.cpp.o
37.050 [4117/33/3199] Building CXX object 
tools/mlir/lib/Query/Matcher/CMakeFiles/obj.MLIRQueryMatcher.dir/RegistryManager.cpp.o
37.051 [4117/32/3200] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRViewLikeInterface.dir/ViewLikeInterface.cpp.o
37.055 [4117/31/3201] Building CXX object 
tools/mlir/lib/IR/CMakeFiles/obj.MLIRIR.dir/Region.cpp.o
37.058 [4117/30/3202] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRInferIntRangeInterface.dir/InferIntRangeInterface.cpp.o
37.059 [4117/29/3203] Building CXX object 
tools/mlir/lib/Interfaces/CMakeFiles/obj.MLIRLoopLikeInterface.dir/LoopLikeInterface.cpp.o
37.061 [4117/28/3204] Building CXX object 
tools/mlir/tools/tblgen-lsp-server/CMakeFiles/tblgen-lsp-server.dir/tblgen-lsp-server.cpp.o
37.062 [4117/27/3205] Building CXX o

[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-win-fast` running on `as-builder-3` while building 
`clang,llvm` at step 6 "build-unified-tree".

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


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

```
Step 6 (build-unified-tree) failure: build (failure)
...
[929/4138] Building Opts.inc...
[930/4138] Building Opts.inc...
[931/4138] Building Opts.inc...
[932/4138] Building ARMGenGlobalISel.inc...
[933/4138] Building InstallNameToolOpts.inc...
[934/4138] Building OtoolOpts.inc...
[935/4138] Building CXX object 
tools\llvm-mt\CMakeFiles\llvm-mt.dir\llvm-mt.cpp.obj
[936/4138] Building CXX object 
tools\llvm-mt\CMakeFiles\llvm-mt.dir\llvm-mt-driver.cpp.obj
[937/4138] Building RC object 
tools\llvm-mt\CMakeFiles\llvm-mt.dir\__\__\resources\windows_version_resource.rc.res
[938/4138] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
C:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/build/tools/clang/include/clang/Driver/Options.inc
 
cmd.exe /C "cd /D C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build && 
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\bin\llvm-tblgen.exe 
-gen-opt-parser-defs -I 
C:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/llvm-project/clang/include/clang/Driver
 
-IC:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/llvm-project/clang/include
 
-IC:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/build/tools/clang/include 
-IC:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/build/include 
-IC:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/llvm-project/llvm/include 
--long-string-literals=0 
C:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d"
C:/buildbot/as-builder-3/llvm-clang-x86_64-win-fast/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
[939/4138] Building WindresOpts.inc...
[940/4138] Linking CXX executable bin\llvm-opt-report.exe
[941/4138] Building BitcodeStripOpts.inc...
[942/4138] Building ARMGenDAGISel.inc...
[943/4138] Linking CXX executable bin\llvm-remarkutil.exe
[944/4138] Building ARMGenSubtargetInfo.inc...
[945/4138] Linking CXX shared library bin\Remarks.dll
[946/4138] Linking CXX executable bin\llvm-mt.exe
[947/4138] Building ARMGenInstrInfo.inc...
[948/4138] Building RISCVTargetParserDef.inc...
ninja: build stopped: subcommand failed.

```



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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-amdgpu-runtime` running on `omp-vega20-0` while building 
`clang,llvm` at step 5 "compile-openmp".

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


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

```
Step 5 (compile-openmp) failure: build (failure)
...
6.499 [3452/32/891] Building X86GenAsmWriter1.inc...
6.552 [3451/32/892] Building X86GenInstrMapping.inc...
6.557 [3450/32/893] Building Options.inc...
6.562 [3449/32/894] Building Options.inc...
6.574 [3448/32/895] Building Options.inc...
6.591 [3447/32/896] Building Options.inc...
6.611 [3446/32/897] Building Options.inc...
6.620 [3445/32/898] Building Options.inc...
6.629 [3444/32/899] Building Options.inc...
6.691 [3443/32/900] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/include/clang/Driver/Options.inc
 
cd /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build && 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/bin/llvm-tblgen 
-gen-opt-parser-defs -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/include/clang/Driver
 -I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/include 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/include
 -I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/include 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/llvm/include 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
6.761 [3443/31/901] Building R600GenDAGISel.inc...
6.780 [3443/30/902] Building RISCVTargetParserDef.inc...
6.962 [3443/29/903] Building R600GenDFAPacketizer.inc...
7.048 [3443/28/904] Building X86GenAsmMatcher.inc...
7.097 [3443/27/905] Building R600GenMCCodeEmitter.inc...
7.328 [3443/26/906] Building R600GenRegisterInfo.inc...
7.407 [3443/25/907] Building R600GenSubtargetInfo.inc...
7.499 [3443/24/908] Building R600GenInstrInfo.inc...
7.606 [3443/23/909] Building X86GenDisassemblerTables.inc...
7.734 [3443/22/910] Building X86GenFoldTables.inc...
9.357 [3443/21/911] Building X86GenGlobalISel.inc...
9.793 [3443/20/912] Building X86GenFastISel.inc...
11.105 [3443/19/913] Building X86GenSubtargetInfo.inc...
11.538 [3443/18/914] Building X86GenDAGISel.inc...
14.187 [3443/17/915] Building X86GenInstrInfo.inc...
19.110 [3443/16/916] Building AMDGPUGenMCPseudoLowering.inc...
19.992 [3443/15/917] Building AMDGPUGenPostLegalizeGICombiner.inc...
20.120 [3443/14/918] Building AMDGPUGenPreLegalizeGICombiner.inc...
20.592 [3443/13/919] Building AMDGPUGenCallingConv.inc...
21.733 [3443/12/920] Building AMDGPUGenMCCodeEmitter.inc...
21.801 [3443/11/921] Building AMDGPUGenDisassemblerTables.inc...
21.949 [3443/10/922] Building AMDGPUGenSearchableTables.inc...
22.902 [3443/9/923] Building AMDGPUGenRegBankGICombiner.inc...
24.047 [3443/8/924] Building AMDGPUGenSubtargetInfo.inc...
29.677 [3443/7/925] Building AMDGPUGenGlobalISel.inc...
29.895 [3443/6/926] Building AMDGPUGenAsmMatcher.inc...
30.104 [3443/5/927] Building AMDGPUGenDAGISel.inc...
30.451 [3443/4/928] Building AMDGPUGenAsmWriter.inc...
31.415 [3443/3/929] Building AMDGPUGenInstrInfo.inc...
33.870 [3443/2/930] Building AMDGPUGenRegisterInfo.inc...
35.292 [3443/1/931] Building AMDGPUGenRegisterBank.inc...
ninja: build stopped: subcommand failed.

```



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


[clang] [AArch64] Enable vscale_range with +sme (PR #124466)

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


@@ -708,7 +708,7 @@ AArch64TargetInfo::getVScaleRange(const LangOptions 
&LangOpts) const {
 return std::pair(
 LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax);
 
-  if (hasFeature("sve"))
+  if (hasFeature("sve") || hasFeature("sme"))

davemgreen wrote:

I think the default range should still be the same - somewhere between 1 and 
16. SME doesn't increase that even if they VL and SVL are different.

(Currently if we have +sve+sme we will set the vscale_range to (1,16) already, 
so hopefully that part is already OK. In either case this adds the simple case, 
it doesn't alter the more complicated part :) )

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


[clang] 822f74a - [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (#124767)

2025-01-28 Thread via cfe-commits

Author: Stephen Tozer
Date: 2025-01-28T18:25:32Z
New Revision: 822f74a91106b7ca10e85508eb642e62ef945afa

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

LOG: [Clang] Cleanup docs and comments relating to -fextend-variable-liveness 
(#124767)

This patch contains a number of changes relating to the above flag;
primarily it updates comment references to the old flag names,
"-fextend-lifetimes" and "-fextend-this-ptr" to refer to the new names,
"-fextend-variable-liveness[={all,this}]". These changes are all NFC.

This patch also removes the explicit -fextend-this-ptr-liveness flag
alias, and shortens the help-text for the main flag; these are both
changes that were meant to be applied in the initial PR (#11), but
due to some user-error on my part they were not included in the merged
commit.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/fake-use-sanitizer.cpp
clang/test/CodeGen/fake-use-this.cpp
clang/test/Driver/extend-variable-liveness.c
llvm/test/CodeGen/MIR/X86/fake-use-tailcall.mir
llvm/test/CodeGen/X86/fake-use-simple-tail-call.ll
llvm/test/CodeGen/X86/fake-use-zero-length.ll
llvm/test/DebugInfo/AArch64/fake-use-global-isel.ll
llvm/test/DebugInfo/X86/fake-use.ll
llvm/test/Transforms/CodeGenPrepare/X86/fake-use-split-ret.ll
llvm/test/Transforms/GVN/fake-use-constprop.ll

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c5a5da5daf8f5e..74b09025967afc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -524,15 +524,15 @@ New Compiler Flags
   Clang to generate code that tries to preserve the liveness of source 
variables
   through optimizations, meaning that variables will typically be visible in a
   debugger more often. The flag has two levels: ``-fextend-variable-liveness``,
-  or ``-fextend-variable-liveness=all``, extendes the liveness of all user
-  variables and the ``this`` pointer. Alternatively ``-fextend-this-ptr``, or
-  ``-fextend-variable-liveness=this``, has the same behaviour but applies only
-  to the ``this`` variable in C++ class member functions, meaning its effect is
-  a strict subset of ``-fextend-variable-liveness``. Note that this flag
-  modifies the results of optimizations that Clang performs, which will result
-  in reduced performance in generated code; however, this feature will not
-  extend the liveness of some variables in cases where doing so would likely
-  have a severe impact on generated code performance.
+  or ``-fextend-variable-liveness=all``, extends the liveness of all user
+  variables and the ``this`` pointer. Alternatively
+  ``-fextend-variable-liveness=this`` has the same behaviour but applies only 
to
+  the ``this`` variable in C++ class member functions, meaning its effect is a
+  strict subset of ``-fextend-variable-liveness``. Note that this flag modifies
+  the results of optimizations that Clang performs, which will result in 
reduced
+  performance in generated code; however, this feature will not extend the
+  liveness of some variables in cases where doing so would likely have a severe
+  impact on generated code performance.
 
 - The ``-Warray-compare`` warning has been added to warn about array comparison
   on versions older than C++20.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6fa8a8273aca34..2bf687895db294 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4352,19 +4352,11 @@ def stack_usage_file : Separate<["-"], 
"stack-usage-file">,
 def fextend_variable_liveness_EQ : Joined<["-"], "fextend-variable-liveness=">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Extend the liveness of user variables through optimizations to "
-   "prevent stale or optimized-out variable values when debugging. Can 
"
-   "be applied to all user variables, or just to the C++ 'this' ptr. "
-   "May choose not to extend the liveness of some variables, such as "
-   "non-scalars larger than 4 unsigned ints, or variables in any "
-   "inlined functions.">,
+   "prevent stale or optimized-out variable values when debugging."
   Values<"all,this,none">,
   NormalizedValues<["All", "This", "None"]>,
   NormalizedValuesScope<"CodeGenOptions::ExtendVariableLivenessKind">,
   MarshallingInfoEnum, "None">;
-def fextend_this_ptr_liveness : Flag<["-"], "fextend-this-ptr-liveness">,
-  Visibility<[ClangOption, CC1Option]>,
-  Alias, AliasArgs<["this"]>,
-  HelpText<"Alias for -fextend-variable-liveness=this.">;
 def fextend_variable_li

[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

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

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


[clang] [DNC] Break formatting to test clang-format (PR #124809)

2025-01-28 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 0b80491cd5e7dcb6d5432727d0a2c746a9a9438e 
4ed0192fca412dcb801ea75ad0d086153fa5b531 --extensions cpp -- 
clang/lib/Driver/Driver.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e484334fd0..777d2d9992 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -18,8 +18,8 @@
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
 #include "ToolChains/Darwin.h"
-#include "ToolChains/FreeBSD.h"
 #include "ToolChains/DragonFly.h"
+#include "ToolChains/FreeBSD.h"
 #include "ToolChains/Fuchsia.h"
 #include "ToolChains/Gnu.h"
 #include "ToolChains/HIPAMD.h"
@@ -107,7 +107,7 @@
 
 using namespace clang::driver;
 using namespace clang;
-using namespace llvm::opt;
+using namespace llvm::opt;
 
 static std::optional getOffloadTargetTriple(const Driver &D,
   const ArgList &Args) 
{
@@ -371,7 +371,8 @@ InputArgList Driver::ParseArgStrings(ArrayRef 
ArgStrings,
  DiagnosticsEngine::Warning;
   }
 
-  for (const Arg *A : Args.filtered(options::OPT_o)) { if 
(ArgStrings[A->getIndex()] == A->getSpelling())
+  for (const Arg *A : Args.filtered(options::OPT_o)) {
+if (ArgStrings[A->getIndex()] == A->getSpelling())
   continue;
 
 // Warn on joined arguments that are similar to a long argument.

``




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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 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,llvm` at step 4 "annotate".

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


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)
...
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- success
-- Configuring done
-- Generating done
-- Build files have been written to: 
/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build
@@@BUILD_STEP build cmake config@@@
Running: ninja
[1/517] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
[2/517] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/tools/clang/include/clang/Driver/Options.inc
 
cd /home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build && 
/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/bin/llvm-tblgen
 -gen-opt-parser-defs -I 
/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/llvm-project/clang/include/clang/Driver
 
-I/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/llvm-project/clang/include
 
-I/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/tools/clang/include
 -I/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/include 
-I/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/llvm-project/llvm/include
 
/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
[3/517] Generating VCSRevision.h
[4/517] Linking CXX executable bin/llvm-config
ninja: build stopped: subcommand failed.
['ninja'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File 
"/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py",
 line 38, in step
yield
  File 
"/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py",
 line 29, in main
run_command(["ninja"])
  File 
"/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py",
 line 51, in run_command
util.report_run_cmd(cmd, cwd=directory)
  File 
"/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/llvm-zorg/zorg/buildbot/builders/annotated/util.py",
 line 49, in report_run_cmd
subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja']' returned non-zero exit 
status 1.
@@@STEP_FAILURE@@@

```



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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 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,llvm` at step 5 "build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
0.015 [299/3/1] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
0.016 [298/3/2] Generating VCSRevision.h
0.031 [295/5/3] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/clang/include/clang/Driver/Options.inc
 
cd /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build && 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/llvm-tblgen
 -gen-opt-parser-defs -I 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/clang/include/clang/Driver
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/clang/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/clang/include
 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/include 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include
 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
0.062 [295/4/4] Linking CXX executable bin/llvm-config
2.734 [295/3/5] Building CXX object 
lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
13.230 [295/2/6] Building CXX object 
lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
13.816 [295/1/7] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
ninja: build stopped: subcommand failed.

```



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


[clang] [clang-format] Fix annotating attrs in class/struct (PR #124634)

2025-01-28 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

> (Why drop the formatting test? Seems good to have an integration test for 
> this, no?)

Because the bug was a misannotation. The formatting, based on the annotations, 
should already be covered. Of course one can always add more tests, and I'm not 
demanding to remove it, I simply suggest it. The more test cases there are, the 
longer the duration of building and running the tests for all (clang-format) 
developers and CIs.

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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while 
building `clang,llvm` at step 5 "build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
0.012 [302/3/1] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
0.018 [301/3/2] Generating VCSRevision.h
0.031 [298/5/3] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/include/clang/Driver/Options.inc
 
cd /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build && 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/llvm-tblgen
 -gen-opt-parser-defs -I 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include/clang/Driver
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/include
 -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/include 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/include
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
0.050 [298/4/4] Linking CXX executable bin/llvm-config
2.317 [298/3/5] Building CXX object 
lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
11.118 [298/2/6] Building CXX object 
lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
11.620 [298/1/7] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
ninja: build stopped: subcommand failed.

```



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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-hip-vega20` running 
on `hip-vega20-0` while building `clang,llvm` at step 3 "annotate".

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


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

```
Step 3 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure)
...
-- Performing Test HAVE_PTHREAD_AFFINITY -- success
-- Configuring done
-- Generating done
-- Build files have been written to: 
/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm
+ build_step 'Building LLVM'
+ echo '@@@BUILD_STEP Building LLVM@@@'
+ ninja
@@@BUILD_STEP Building LLVM@@@
[1/325] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
[2/325] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/tools/clang/include/clang/Driver/Options.inc
 
cd /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm && 
/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/bin/llvm-tblgen
 -gen-opt-parser-defs -I 
/home/botworker/bbot/clang-hip-vega20/llvm-project/clang/include/clang/Driver 
-I/home/botworker/bbot/clang-hip-vega20/llvm-project/clang/include 
-I/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/tools/clang/include
 
-I/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/include 
-I/home/botworker/bbot/clang-hip-vega20/llvm-project/llvm/include 
/home/botworker/bbot/clang-hip-vega20/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/botworker/bbot/clang-hip-vega20/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
[3/325] Generating VCSRevision.h
[4/325] Linking CXX executable bin/llvm-config
ninja: build stopped: subcommand failed.
Step 6 (Configure LLVM Build) failure: Configure LLVM Build (failure)
@@@BUILD_STEP Configure LLVM Build@@@
+ cd /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm
+ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache 
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_VERBOSE_MAKEFILE=1 
'-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86' 
'-DLLVM_ENABLE_PROJECTS=clang;lld;clang-tools-extra' 
'-DLLVM_ENABLE_RUNTIMES=compiler-rt;libcxx;libcxxabi;libunwind' 
-DCLANG_DEFAULT_LINKER=lld -DLIBCXX_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_STATIC=ON 
-DLIBCXX_INSTALL_LIBRARY=OFF -DLIBCXX_INSTALL_HEADERS=OFF 
-DLIBCXXABI_ENABLE_SHARED=OFF -DLIBCXXABI_ENABLE_STATIC=ON 
-DLIBCXXABI_INSTALL_STATIC_LIBRARY=OFF 
-DCMAKE_INSTALL_PREFIX=/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/install
 -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_Z3_SOLVER=OFF -DLLVM_ENABLE_ZLIB=ON 
'-DLLVM_LIT_ARGS=-v -vv' /home/botworker/bbot/clang-hip-vega20/llvm-project/llvm
-- bolt project is disabled
-- clang project is enabled
-- clang-tools-extra project is enabled
-- compiler-rt project is disabled
-- cross-project-tests project is disabled
-- libc project is disabled
-- libclc project is disabled
-- lld project is enabled
-- lldb project is disabled
-- mlir project is disabled
-- openmp project is disabled
-- polly project is disabled
-- pstl project is disabled
-- flang project is disabled
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) 
-- LLVM host triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Ninja version: 1.10.1
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- OCaml bindings disabled.
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Building with -fPIC
-- Targeting AMDGPU
-- Targeting X86
-- LLD version: 20.0.0
-- Clang version: 20.0.0git
-- Registering ExampleIRTransforms as a pass plugin (static build: OFF)
-- Registering Bye as a pass plugin (static build: OFF)
-- Failed to find LLVM FileCheck
-- Google Benchmark version: v0.0.0, normalized to 0.0.0
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- success
-- Configuring done
-- Generating done
-- Build files have been written to: 
/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm
+ build_step 'Building LLVM'
+ echo '@@@BUILD_STEP Building LLVM@@@'
+ ninja

```



https://github.com/llvm/llvm-project/pull/124767
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://list

[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `ppc64le-flang-rhel-clang` 
running on `ppc64le-flang-rhel-test` while building `clang,llvm` at step 5 
"build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
...
18.787 [4984/36/1704] Building OtoolOpts.inc...
18.788 [4984/35/1705] Building WindresOpts.inc...
18.788 [4984/34/1706] Linking CXX static library lib/libMLIRPDLLODS.a
18.790 [4983/34/1707] Linking CXX static library lib/libFortranSupport.a
18.792 [4983/33/1708] Building CXX object 
tools/llvm-mt/CMakeFiles/llvm-mt.dir/llvm-mt.cpp.o
18.793 [4983/32/1709] Building CXX object 
tools/llvm-mt/CMakeFiles/llvm-mt.dir/llvm-mt-driver.cpp.o
18.794 [4982/32/1710] Creating library symlink lib/libmlir_arm_sme_abi_stubs.so
18.795 [4982/31/1711] Building BuiltinTypes.h.inc...
18.799 [4980/32/1712] Creating library symlink lib/libmlir_float16_utils.so
18.805 [4978/33/1713] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/clang/include/clang/Driver/Options.inc
 
cd 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build
 && 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/bin/llvm-tblgen
 -gen-opt-parser-defs -I 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/clang/include/clang/Driver
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include
 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
18.805 [4978/32/1714] Creating library symlink lib/libmlir_arm_runner_utils.so
18.808 [4978/31/1715] Building BitcodeStripOpts.inc...
18.846 [4978/30/1716] Linking CXX static library lib/libTableGenLspServerLib.a
18.853 [4978/29/1717] Linking CXX static library lib/libMLIRPDLLAST.a
18.858 [4978/28/1718] Linking CXX static library 
lib/libMLIRSparseTensorRuntime.a
18.869 [4978/27/1719] Building BuiltinTypeConstraints.h.inc...
18.872 [4978/26/1720] Building BuiltinTypeConstraints.cpp.inc...
18.874 [4978/25/1721] Building SPIRVSerialization.inc...
18.888 [4978/24/1722] Linking CXX shared library 
lib/libmlir_async_runtime.so.20.0git
18.928 [4978/23/1723] Building LLVMConversionEnumsFromLLVM.inc...
18.933 [4978/22/1724] Building LLVMConversionEnumsToLLVM.inc...
18.936 [4978/21/1725] Building LLVMConversions.inc...
18.947 [4978/20/1726] Building LLVMOpFromLLVMIRConversions.inc...
18.985 [4978/19/1727] Linking CXX executable bin/mlir-src-sharder
18.994 [4978/18/1728] Linking CXX shared library 
lib/libmlir_runner_utils.so.20.0git
19.010 [4978/17/1729] Building TestOpsSyntax.cpp.inc...
19.011 [4978/16/1730] Building TestOpsSyntax.h.inc...
19.054 [4978/15/1731] Linking CXX executable bin/llvm-mt
21.117 [4978/14/1732] Building PPCGenCallingConv.inc...
21.311 [4978/13/1733] Building PPCGenExegesis.inc...
21.322 [4978/12/1734] Building PPCGenRegisterBank.inc...
21.377 [4978/11/1735] Building PPCGenRegisterInfo.inc...
21.386 [4978/10/1736] Building PPCGenDisassemblerTables.inc...
21.412 [4978/9/1737] Building PPCGenAsmWriter.inc...
21.508 [4978/8/1738] Building PPCGenMCCodeEmitter.inc...
21.581 [4978/7/1739] Building PPCGenAsmMatcher.inc...
22.210 [4978/6/1740] Building PPCGenSubtargetInfo.inc...
22.750 [4978/5/1741] Building AArch64TargetParserDef.inc...
23.642 [4978/4/1742] Building PPCGenFastISel.inc...
24.240 [4978/3/1743] Building PPCGenGlobalISel.inc...
24.372 [4978/2/1744] Building PPCGenDAGISel.inc...
24.579 [4978/1/1745] Building PPCGenInstrInfo.inc...
ninja: build stopped: subcommand failed.

```



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

[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)

2025-01-28 Thread via cfe-commits

gulfemsavrun wrote:

This recently added tests failed on Windows like 
`extend-variable-liveness-except.cpp`, and 
https://github.com/llvm/llvm-project/commit/8ad9e1ecb7e565c2f99b4ef67517d1f37d1c80d0
 did not fix this issue. Could you please revert while investigating?
```
FAIL: Clang :: CodeGen/extend-variable-liveness-except.cpp (7227 of 21842)
 TEST 'Clang :: 
CodeGen/extend-variable-liveness-except.cpp' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem 
C:\b\s\w\ir\x\w\llvm_build\lib\clang\20\include -nostdsysteminc 
C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp
 -emit-llvm -fextend-variable-liveness -fcxx-exceptions -fexceptions -o - | 
c:\b\s\w\ir\x\w\llvm_build\bin\filecheck.exe 
C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp
# executed command: 'c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe' -cc1 
-internal-isystem 'C:\b\s\w\ir\x\w\llvm_build\lib\clang\20\include' 
-nostdsysteminc 
'C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp'
 -emit-llvm -fextend-variable-liveness -fcxx-exceptions -fexceptions -o -
# executed command: 'c:\b\s\w\ir\x\w\llvm_build\bin\filecheck.exe' 
'C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp'
# .---command stderr
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp:15:11:
 error: CHECK: expected string not found in input
# | // CHECK: [[CATCH_PTR:%[a-zA-Z0-9\.]+]] = call ptr @__cxa_begin_catch(
# |   ^
# | :1:1: note: scanning from here
# | ; ModuleID = 
'C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp'
# | ^
# | :25:1: note: possible intended match here
# | catch: ; preds = %catch.dispatch
# | ^
# | 
# | Input file: 
# | Check file: 
C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<
# | 1: ; ModuleID = 
'C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\CodeGen\extend-variable-liveness-except.cpp'
 
# | check:15'0 
X~~~
 error: no match found
# | 2: source_filename = 
"C:\\b\\s\\w\\ir\\x\\w\\llvm-llvm-project\\clang\\test\\CodeGen\\extend-variable-liveness-except.cpp"
 
# | check:15'0 

# | 3: target datalayout = 
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
 
# | check:15'0 
~~
# | 4: target triple = "x86_64-pc-windows-msvc" 
# | check:15'0 ~
# | 5:  
# | check:15'0 ~
# | 6: %rtti.TypeDescriptor2 = type { ptr, ptr, [3 x i8] } 
# | check:15'0 
# | .
# | .
# | .
# |20:  to label %invoke.cont unwind label %catch.dispatch 
# | check:15'0 
# |21:  
# | check:15'0 ~
# |22: catch.dispatch: ; preds = %entry 
# | check:15'0 ~
# |23:  %0 = catchswitch within none [label %catch] unwind to 
caller 
# | check:15'0 
~~
# |24:  
# | check:15'0 ~
# |25: catch: ; preds = %catch.dispatch 
# | check:15'0 ~
# | check:15'1 ? possible intended match
# |26:  %1 = catchpad within %0 [ptr @"??_R0H@8", i32 0, ptr %l] 
# | check:15'0 ~~
# |27:  store i32 8, ptr %m, align 4 
# | check:15'0 ~~
# |28:  %fake.use1 = load i32, ptr %m, align 4 
# | check:15'0 
# |29:  notail call void (...) @llvm.fake.use(i32 %fake.use1) #2 
# | check:15'0 ~~
# |30:  catchret from %1 to label %catchret.dest 
# | check:15'0 ~~
# | .
# | .
# | .
# | >>
# `-
# error: command failed with exit status: 1

--
```
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-windows-x64/b8724497761651154417/overview

https://github.com/llvm/llvm-project/pull/110102
__

[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

2025-01-28 Thread via cfe-commits


@@ -4861,8 +4861,9 @@ static void TryListInitialization(Sema &S,
 S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) 
&&
 "Deduced to other type?");
 TryArrayCopy(S,
- InitializationKind::CreateCopy(Kind.getLocation(),
-InitList->getLBraceLoc()),
+ InitializationKind::CreateDirect(Kind.getLocation(),
+  InitList->getLBraceLoc(),
+  
InitList->getRBraceLoc()),

cor3ntin wrote:

> and each element is copy-initialized or direct-initialized from the 
> corresponding element of the 
> [assignment-expression](https://eel.is/c++draft/expr.ass#nt:assignment-expression)
>  as specified by the form of the 
> [initializer](https://eel.is/c++draft/dcl.init.general#nt:initializer)[.](https://eel.is/c++draft/dcl.struct.bind#1.sentence-8)
>  Otherwise, e is defined as-if by

So I think 

```cpp
auto [_]{a}; // direct-initialization
auto [_](a); // copy-initializer
```

Is my understanding correct that we need that we need to look at 
`Kind.getKind()` and call either `CreateCopy` or CreateDirect?


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


[clang] [AArch64] Enable vscale_range with +sme (PR #124466)

2025-01-28 Thread Sander de Smalen via cfe-commits


@@ -708,7 +708,7 @@ AArch64TargetInfo::getVScaleRange(const LangOptions 
&LangOpts) const {
 return std::pair(
 LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax);
 
-  if (hasFeature("sve"))
+  if (hasFeature("sve") || hasFeature("sme"))

sdesmalen-arm wrote:

If the function only has `+sme`, then `vscale_range` should only apply to 
(locally) streaming functions, because non-streaming or streaming-compatible 
functions cannot use scalable vectors.

I guess the the thing to watch out for is that we don't propagate assumptions 
from using `-msve-vector-bits` to streaming[-compatible] functions, because 
that information may be incorrect.

The SME attributes tell which mode the statements of a function must be 
executed in, so `vscale_range` should apply to all LLVM IR operations in the 
body of that function. For targets that have both SVE and SME, this may no 
longer be true during CodeGen because the DAG introduces streaming-mode changes 
for calls, and in the prologue/epilogue of locally-streaming functions. If it 
assumes a certain vector width for the body, the DAG might end up with 
instructions that assume this width for operations executed in a different 
mode. I've not really thought this through, but it does need further 
investigation if we ever want to enable that. Anyway, that doesn't really apply 
to this patch.



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


[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-28 Thread Eli Friedman via cfe-commits


@@ -366,9 +387,15 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, 
bool isVariadic,
 return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
   }
 
-  // Ignore empty records.
-  if (isEmptyRecord(getContext(), Ty, true))
-return ABIArgInfo::getIgnore();
+  // Empty records are either ignored completely or passed as if they were a
+  // 1-byte object, depending on the ABI and language standard.
+  if (isEmptyRecord(getContext(), Ty, true) ||
+  getContext().getTypeSize(Ty) == 0) {
+if (shouldIgnoreEmptyArg(Ty))

efriedma-quic wrote:

Actually, hmm... do we want to add `fclang-abi-compat` support for this change, 
or do we think it's too niche to matter?

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


[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)

2025-01-28 Thread Zhengxing li via cfe-commits

lizhengxing wrote:

It's a name mangling issue on Windows (or maybe other OS). 

For example, the check  `// CHECK-LABEL: 
define{{.*}}**_ZN1C4testEi**(ptr{{[^,]*}} %this, i32{{.*}} %p)` in 
fake-use-this.cpp expects the string contains `_ZN1C4testEi`. 

However, the compiler on Windows outputs `define dso_local noundef zeroext i1 
@"?test@C@@QEAA_NH@Z"` 


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


[clang] 986581f - [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#124674)

2025-01-28 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-01-28T10:56:09-08:00
New Revision: 986581f6bcef8736c942a9fec9cf12bfbc57c1f6

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

LOG: [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#124674)

Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast

This patch migrates uses of PointerUnion::dyn_cast to
dyn_cast_if_present (see the definition of PointerUnion::dyn_cast).
Note that we already have dyn_cast_if_present(ExplicitInfo)
elsewhere in ClassTemplateSpecializationDecl and
VarTemplateSpecializationDecl, meaning that ExplicitInfo is not
guaranteed to be nonnull in those classes.

Added: 


Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/lib/AST/DeclTemplate.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index caaa47d0a297cf..9ecff2c898acd5 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2018,7 +2018,8 @@ class ClassTemplateSpecializationDecl : public 
CXXRecordDecl,
   /// Set the template argument list as written in the sources.
   void
   setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten) {
-if (auto *Info = ExplicitInfo.dyn_cast())
+if (auto *Info =
+dyn_cast_if_present(ExplicitInfo))
   Info->TemplateArgsAsWritten = ArgsWritten;
 else
   ExplicitInfo = ArgsWritten;
@@ -2032,7 +2033,8 @@ class ClassTemplateSpecializationDecl : public 
CXXRecordDecl,
 
   /// Gets the location of the extern keyword, if present.
   SourceLocation getExternKeywordLoc() const {
-if (auto *Info = ExplicitInfo.dyn_cast())
+if (auto *Info =
+dyn_cast_if_present(ExplicitInfo))
   return Info->ExternKeywordLoc;
 return SourceLocation();
   }
@@ -2780,7 +2782,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
   /// Retrieve the template argument list as written in the sources,
   /// if any.
   const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const {
-if (auto *Info = ExplicitInfo.dyn_cast())
+if (auto *Info =
+dyn_cast_if_present(ExplicitInfo))
   return Info->TemplateArgsAsWritten;
 return cast(ExplicitInfo);
   }
@@ -2803,7 +2806,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
 
   /// Gets the location of the extern keyword, if present.
   SourceLocation getExternKeywordLoc() const {
-if (auto *Info = ExplicitInfo.dyn_cast())
+if (auto *Info =
+dyn_cast_if_present(ExplicitInfo))
   return Info->ExternKeywordLoc;
 return SourceLocation();
   }
@@ -2813,7 +2817,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
 
   /// Gets the location of the template keyword, if present.
   SourceLocation getTemplateKeywordLoc() const {
-if (auto *Info = ExplicitInfo.dyn_cast())
+if (auto *Info =
+dyn_cast_if_present(ExplicitInfo))
   return Info->TemplateKeywordLoc;
 return SourceLocation();
   }

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index de81bc64106f18..2e1ed9e10713a8 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1496,7 +1496,7 @@ SourceRange 
VarTemplateSpecializationDecl::getSourceRange() const {
 }
 
 void VarTemplateSpecializationDecl::setExternKeywordLoc(SourceLocation Loc) {
-  auto *Info = ExplicitInfo.dyn_cast();
+  auto *Info = dyn_cast_if_present(ExplicitInfo);
   if (!Info) {
 // Don't allocate if the location is invalid.
 if (Loc.isInvalid())
@@ -1509,7 +1509,7 @@ void 
VarTemplateSpecializationDecl::setExternKeywordLoc(SourceLocation Loc) {
 }
 
 void VarTemplateSpecializationDecl::setTemplateKeywordLoc(SourceLocation Loc) {
-  auto *Info = ExplicitInfo.dyn_cast();
+  auto *Info = dyn_cast_if_present(ExplicitInfo);
   if (!Info) {
 // Don't allocate if the location is invalid.
 if (Loc.isInvalid())



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


[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2025-01-28 Thread via cfe-commits

https://github.com/4m4n-x-B4w4ne edited 
https://github.com/llvm/llvm-project/pull/120087
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] [NFC] Introduce `ConstDynamicRecursiveASTVisitor` (reland) (PR #124821)

2025-01-28 Thread via cfe-commits

https://github.com/Sirraide created 
https://github.com/llvm/llvm-project/pull/124821

This relands #122991.

I candidly still have no idea what went wrong last time; a bunch of bots 
started complaining with a relatively obscure error (see below). I’ve updated 
the branch and tried bulding Clang using both Clang itself and GCC and 
encountered no problems.


```console
FAILED: 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o
 
ccache /usr/bin/c++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/lib/AST
 -I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/include 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/tools/clang/include
 -I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/include 
-I/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/llvm/include 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-fno-lifetime-dse -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 -Wdel
 ete-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  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o
 -MF 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o.d
 -o 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DynamicRecursiveASTVisitor.cpp.o
 -c 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:
 In member function ‘virtual bool 
clang::DynamicRecursiveASTVisitorBase::TraverseAST(clang::DynamicRecursiveASTVisitorBase::MaybeConst&)’:
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 error: expected ‘;’ before ‘::’ token
  284 | .template RecursiveASTVisitor>::Function(   
   \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template RecursiveASTVisitor>::Function(   
   \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:296:17:
 error: ‘::TraverseAST’ has not been declared
  296 | FORWARD_TO_BASE(TraverseAST, ASTContext, &)
  | ^~~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:53:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template RecursiveASTVisitor>::Function(   
   \
  | ^~~~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:
 In member function ‘virtual bool 
clang::DynamicRecursiveASTVisitorBase::TraverseAttr(clang::DynamicRecursiveASTVisitorBase::MaybeConst*)’:
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 error: expected ‘;’ before ‘::’ token
  284 | .template RecursiveASTVisitor>::Function(   
   \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:51:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template RecursiveASTVisitor>::Function(   
   \
  |   ^~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:297:17:
 error: ‘::TraverseAttr’ has not been declared
  297 | FORWARD_TO_BASE(TraverseAttr, Attr, *)
  | ^~~~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveASTVisitor.cpp:284:53:
 note: in definition of macro ‘FORWARD_TO_BASE’
  284 | .template RecursiveASTVisitor>::Function(   
   \
  | ^~~~
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/AST/DynamicRecursiveAST

[clang] [AArch64] Match GCC behaviour for zero-size structs (PR #124760)

2025-01-28 Thread Eli Friedman via cfe-commits

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

LGTM

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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


@@ -44,7 +44,7 @@ class CIRGenerator : public clang::ASTConsumer {
   const clang::CodeGenOptions &codeGenOpts;
 
 protected:
-  std::unique_ptr mlirContext;
+  std::shared_ptr mlirContext;

andykaylor wrote:

Sorry, I thought shared pointer was what you were suggesting.

Here's what I'm seeing. CIRGenerator::Initialize creates the mlirContext and 
uses it. That function also passes it, as a raw pointer, to CIRGenModule, which 
keeps a copy of the pointer throughout its lifetime. CIRGenerator doesn't use 
it again, and was previously handing it off in 
CIRGenConsumer::handleTranslationUnit() via takeContext(). 
CIRGenConsumer::handleTranslationUnit(), in turn, passes it to a few calls as a 
raw pointer (in the incubator, not yet here) before handing it off, as a unique 
pointer, to lowerFromCIRToLLVMIR() which hands it, as a unique pointer, to 
lowerFromCIRToMLIRToLLVMIR() in the incubator implementation. There it is used 
as a raw pointer.

All of the uses after the call to takeContext() have lifetimes that should be 
limited to the scope of CIRGenConsumer::handleTranslationUnit(), so I think we 
should be able to just use it as a raw pointer here instead of taking it and 
leaving CIRGenerator with a null pointer, but CIRGenerator shouldn't need it 
again either.

@bcardosolopes Have I misunderstood anything here? What's your recommendation?

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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


@@ -55,6 +56,13 @@ class EmitCIRAction : public CIRGenAction {
   EmitCIRAction(mlir::MLIRContext *MLIRCtx = nullptr);
 };
 
+class EmitLLVMAction : public CIRGenAction {
+  virtual void anchor();
+
+public:
+  EmitLLVMAction(mlir::MLIRContext *MLIRCtx = nullptr);

AaronBallman wrote:

Under what circumstances does it make sense to pass a null MLIR context? 
(Mostly wondering why the pattern is to use a default parameter here rather 
than make the caller pass it explicitly.)

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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


@@ -66,6 +81,17 @@ class CIRGenConsumer : public clang::ASTConsumer {
 MlirModule->print(*OutputStream, Flags);
   }
   break;
+case CIRGenAction::OutputType::EmitLLVM: {
+  llvm::LLVMContext LLVMCtx;
+  auto LLVMModule = lowerFromCIRToLLVMIR(CI.getFrontendOpts(), MlirModule,

AaronBallman wrote:

Please spell out the type instead of using `auto`.

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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


@@ -0,0 +1,41 @@
+//- LowerToLLVM.cpp - Lowering from CIR to LLVMIR 
-===//
+//
+// 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
+//
+//===--===//
+//
+// This file implements lowering of CIR operations to LLVMIR.
+//
+//===--===//
+
+#include "clang/CIR/LowerToLLVM.h"
+
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Pass/PassManager.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/TimeProfiler.h"
+

AaronBallman wrote:

Is this from include what you use? (Code might be fine, I'm just surprised at 
how much is required to be included given the implementation.)

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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


@@ -7,42 +7,56 @@
 
//===--===//
 
 #include "clang/CIR/FrontendAction/CIRGenAction.h"
-#include "clang/CIR/CIRGenerator.h"
-#include "clang/Frontend/CompilerInstance.h"
-
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/OwningOpRef.h"
+#include "clang/CIR/CIRGenerator.h"
+#include "clang/CIR/LowerToLLVM.h"
+#include "clang/CodeGen/BackendUtil.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/IR/Module.h"
 
 using namespace cir;
 using namespace clang;
 
 namespace cir {
 
+static BackendAction
+getBackendActionFromOutputType(CIRGenAction::OutputType Action) {
+  switch (Action) {
+  case CIRGenAction::OutputType::EmitLLVM:
+return BackendAction::Backend_EmitLL;
+  default:
+llvm_unreachable("Unsupported action");

AaronBallman wrote:

Should we have an assertion earlier in the function that it's not 
`OutputType::EmitCIR`?

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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


@@ -55,6 +55,9 @@ class CIRGenerator : public clang::ASTConsumer {
   void Initialize(clang::ASTContext &astContext) override;
   bool HandleTopLevelDecl(clang::DeclGroupRef group) override;
   mlir::ModuleOp getModule() const;
+  std::shared_ptr getContext() {

AaronBallman wrote:

Should this be a `const` member function?

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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

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

SLTozer wrote:

Apologies, I didn't expect this PR to trigger a failure and didn't catch the 
triggered failures; thank you for catching this so quickly!

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


[clang] [NFC][docs][HIP] Update HIP docs around `hipstdpar` and SPIR-V (PR #124803)

2025-01-28 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx updated 
https://github.com/llvm/llvm-project/pull/124803

>From ed7ee56acc5434233191cfb1c556165f193c4005 Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Tue, 28 Jan 2025 17:45:07 +
Subject: [PATCH 1/2] Add missing `hipstdpar` documentation; remove reference
 to temporary SPIR-V limitation which got lifted.

---
 clang/docs/HIPSupport.rst | 402 +-
 1 file changed, 394 insertions(+), 8 deletions(-)

diff --git a/clang/docs/HIPSupport.rst b/clang/docs/HIPSupport.rst
index e830acd8dd85c0..34abd389b36fe4 100644
--- a/clang/docs/HIPSupport.rst
+++ b/clang/docs/HIPSupport.rst
@@ -27,7 +27,8 @@ AMD GPU Support
 Clang provides HIP support on AMD GPUs via the ROCm platform 
``_.
 The ROCm runtime forms the base for HIP host APIs, while HIP device APIs are 
realized through HIP header
 files and the ROCm device library. The Clang driver uses the HIPAMD toolchain 
to compile HIP device code
-to AMDGPU ISA via the AMDGPU backend. The compiled code is then bundled and 
embedded in the host executables.
+to AMDGPU ISA via the AMDGPU backend, or SPIR-V via the workflow outlined 
below.
+The compiled code is then bundled and embedded in the host executables.
 
 Intel GPU Support
 =
@@ -285,6 +286,398 @@ Example Usage
   basePtr->virtualFunction(); // Allowed since obj is constructed in 
device code
}
 
+C++ Standard Parallelism Offload Support: Compiler And Runtime
+==
+
+Introduction
+
+
+This section describes the implementation of support for offloading the
+execution of standard C++ algorithms to accelerators that can be targeted via
+HIP. Furthermore, it enumerates restrictions on user defined code, as well as
+the interactions with runtimes.
+
+Algorithm Offload: What, Why, Where
+===
+
+C++17 introduced overloads
+`for most algorithms in the standard library 
`_
+which allow the user to specify a desired
+`execution policy 
`_.
+The `parallel_unsequenced_policy 
`_
+maps relatively well to the execution model of AMD GPUs. This, coupled with the
+the availability and maturity of GPU accelerated algorithm libraries that
+implement most / all corresponding algorithms in the standard library
+(e.g. `rocThrust `_), makes
+it feasible to provide seamless accelerator offload for supported algorithms,
+when an accelerated version exists. Thus, it becomes possible to easily access
+the computational resources of an AMD accelerator, via a well specified,
+familiar, algorithmic interface, without having to delve into low-level 
hardware
+specific details. Putting it all together:
+
+- **What**: standard library algorithms, when invoked with the
+  ``parallel_unsequenced_policy``
+- **Why**: democratise AMDGPU accelerator programming, without loss of user
+  familiarity
+- **Where**: only AMDGPU accelerators targeted by Clang/LLVM via HIP
+
+Small Example
+=
+
+Given the following C++ code:
+
+.. code-block:: C++
+
+   bool has_the_answer(const std::vector& v) {
+ return std::find(std::execution::par_unseq, std::cbegin(v), std::cend(v), 
42) != std::cend(v);
+   }
+
+if Clang is invoked with the ``--hipstdpar --offload-arch=foo`` flags, the call
+to ``find`` will be offloaded to an accelerator that is part of the ``foo``
+target family. If either ``foo`` or its runtime environment do not support
+transparent on-demand paging (such as e.g. that provided in Linux via
+`HMM `_), it is necessary to also include
+the ``--hipstdpar-interpose-alloc`` flag. If the accelerator specific algorithm
+library ``foo`` uses doesn't have an implementation of a particular algorithm,
+execution seamlessly falls back to the host CPU. It is legal to specify 
multiple
+``--offload-arch``s. All the flags we introduce, as well as a thorough view of
+various restrictions and their implications will be provided below.
+
+Implementation - General View
+=
+
+We built support for Algorithm Offload support atop the pre-existing HIP
+infrastructure. More specifically, when one requests offload via 
``--hipstdpar``,
+compilation is switched to HIP compilation, as if ``-x hip`` was specified.
+Similarly, linking is also switched to HIP linking, as if ``--hip-link`` was
+specified. Note that these are implicit, and one should not assume that any
+interop with HIP specific language constructs is available e.g. ``__device__``
+annotations are neither necessary nor guaranteed to work.
+
+Since there are no language restriction mechanisms in place, it is necessary to
+relax HIP language specific semantic

[clang] [clang][SME] Account for C++ lambdas in SME builtin diagnostics (PR #124750)

2025-01-28 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Please add some tests for lambdas with streaming attributes, for example:

```
void f() { auto x = []__arm_locally_streaming {}; x(); }
```

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


[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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


@@ -7,42 +7,56 @@
 
//===--===//
 
 #include "clang/CIR/FrontendAction/CIRGenAction.h"
-#include "clang/CIR/CIRGenerator.h"
-#include "clang/Frontend/CompilerInstance.h"
-
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/IR/OwningOpRef.h"
+#include "clang/CIR/CIRGenerator.h"
+#include "clang/CIR/LowerToLLVM.h"
+#include "clang/CodeGen/BackendUtil.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/IR/Module.h"
 
 using namespace cir;
 using namespace clang;
 
 namespace cir {
 
+static BackendAction
+getBackendActionFromOutputType(CIRGenAction::OutputType Action) {
+  switch (Action) {
+  case CIRGenAction::OutputType::EmitLLVM:
+return BackendAction::Backend_EmitLL;
+  default:
+llvm_unreachable("Unsupported action");
+  }
+}
+
+static std::unique_ptr lowerFromCIRToLLVMIR(
+const clang::FrontendOptions &FEOpts, mlir::ModuleOp MLIRModule,
+std::shared_ptr MLIRCtx, llvm::LLVMContext &LLVMCtx) {

AaronBallman wrote:

Should we assume that `FEOpts` and `MLIRCtx` will be used in a follow-up? 
(Mostly wondering whether the params should be dropped until there's a use of 
them, otherwise this won't be -Werror clean for folks with -Wunused enabled.)

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


[clang] [llvm] [Clang] Cleanup docs and comments relating to -fextend-variable-liveness (PR #124767)

2025-01-28 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
0.016 [299/3/1] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
0.037 [298/3/2] Generating VCSRevision.h
0.048 [295/5/3] Building Options.inc...
FAILED: tools/clang/include/clang/Driver/Options.inc 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/clang/include/clang/Driver/Options.inc
 
cd /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build && 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/bin/llvm-tblgen
 -gen-opt-parser-defs -I 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/clang/include/clang/Driver
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/clang/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/clang/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/include
 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/clang/include/clang/Driver/Options.td
 --write-if-changed -o tools/clang/include/clang/Driver/Options.inc -d 
tools/clang/include/clang/Driver/Options.inc.d
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/clang/include/clang/Driver/Options.td:4356:3:
 error: Expected comma before next argument
  Values<"all,this,none">,
  ^
0.077 [295/4/4] Linking CXX executable bin/llvm-config
3.987 [295/3/5] Building CXX object 
lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
18.825 [295/2/6] Building CXX object 
lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
19.823 [295/1/7] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
ninja: build stopped: subcommand failed.

```



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


  1   2   3   4   5   6   >