[clang-tools-extra] [clang-tidy] fix false negatives with type aliases in `cppcoreguidlines-pro-bounds-pointer-arithmetic` check (PR #139430)

2025-06-18 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor updated 
https://github.com/llvm/llvm-project/pull/139430

>From a5e4fbcf644279ad002f55f9f6ed506d7ab764a4 Mon Sep 17 00:00:00 2001
From: Baranov Victor 
Date: Sun, 11 May 2025 05:22:55 +0300
Subject: [PATCH] [clang-tidy] fix false positives with type aliases in
 pro-bounds-pointer-arithmetic

---
 .../ProBoundsPointerArithmeticCheck.cpp   | 13 +
 .../ProBoundsPointerArithmeticCheck.h |  3 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 +++
 .../pro-bounds-pointer-arithmetic-pr36489.cpp |  9 ++
 .../pro-bounds-pointer-arithmetic.cpp | 29 +++
 5 files changed, 52 insertions(+), 6 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
index a1494a095f5b6..4c48fc923fa87 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
@@ -15,16 +15,13 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::cppcoreguidelines {
 
 void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
-  if (!getLangOpts().CPlusPlus)
-return;
-
   const auto AllPointerTypes =
-  anyOf(hasType(pointerType()),
+  anyOf(hasType(hasUnqualifiedDesugaredType(pointerType())),
 hasType(autoType(
 hasDeducedType(hasUnqualifiedDesugaredType(pointerType(),
 hasType(decltypeType(hasUnderlyingType(pointerType();
 
-  // Flag all operators +, -, +=, -=, ++, -- that result in a pointer
+  // Flag all operators +, -, +=, -= that result in a pointer
   Finder->addMatcher(
   binaryOperator(
   hasAnyOperatorName("+", "-", "+=", "-="), AllPointerTypes,
@@ -32,8 +29,12 @@ void 
ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
   .bind("expr"),
   this);
 
+  // Flag all operators ++, -- that result in a pointer
   Finder->addMatcher(
-  unaryOperator(hasAnyOperatorName("++", "--"), hasType(pointerType()))
+  unaryOperator(hasAnyOperatorName("++", "--"),
+hasType(hasUnqualifiedDesugaredType(pointerType())),
+unless(hasUnaryOperand(
+ignoringImpCasts(declRefExpr(to(isImplicit()))
   .bind("expr"),
   this);
 
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
index 67f7d1bf9dd69..3466c72a769e9 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
@@ -23,6 +23,9 @@ class ProBoundsPointerArithmeticCheck : public ClangTidyCheck 
{
 public:
   ProBoundsPointerArithmeticCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context) {}
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;
+  }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 3c1ca2f929044..863a547d38dac 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -191,6 +191,10 @@ Changes in existing checks
   ` check by fixing a false positive
   where ``strerror`` was flagged as MT-unsafe.
 
+- Improved :doc:`cppcoreguidelines-pro-bounds-pointer-arithmetic
+  ` check by
+  fixing false negatives when pointer arithmetic was used through type aliases.
+
 - Improved :doc:`google-readability-namespace-comments
   ` check by adding
   the option `AllowOmittingNamespaceComments` to accept if a namespace comment
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-pointer-arithmetic-pr36489.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-pointer-arithmetic-pr36489.cpp
index faab2a1ccf0e1..b3d3fab9c5409 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-pointer-arithmetic-pr36489.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-pointer-arithmetic-pr36489.cpp
@@ -1,11 +1,14 @@
 // RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-pro-bounds-pointer-arithmetic %t
 
 // Fix PR36489 and detect auto-deduced value correctly.
+typedef char* charPtr;
+
 char *getPtr();
 auto getPtrAuto() { return getPtr(); }
 decltype(getPtr()) getPtrDeclType();
 decltype(auto) getPtrDeclTypeAuto() { return getPtr(); }
 auto getPtrWithTrailingReturnType() -> char *;
+charPtr getCharPtr() { return getPtr(); }
 
 void auto_deduction_b

[clang] HIPSPV: Unbundle SDL (PR #136412)

2025-06-18 Thread Henry Linjamäki via cfe-commits


@@ -0,0 +1,38 @@
+// Test HIPSPV static device library linking
+// REQUIRES: system-linux
+// UNSUPPORTED: system-windows
+
+// Create a dummy archive to test SDL linking
+// RUN: rm -rf %t && mkdir %t
+// RUN: touch %t/dummy.bc  
+// RUN: llvm-ar cr %t/libSDL.a %t/dummy.bc
+
+// Test that -l options are passed to llvm-link for --offload=spirv64
+// RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN:   -L%t -lSDL \
+// RUN: 2>&1 | FileCheck -check-prefix=SDL-LINK %s
+
+// Test that .a files are properly unbundled and passed to llvm-link  
+// RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN:   %t/libSDL.a \
+// RUN: 2>&1 | FileCheck -check-prefix=SDL-ARCHIVE %s
+
+// Verify that the input files are added before the SDL files in llvm-link 
command
+// This tests the ordering fix to match HIPAMD behavior
+// SDL-LINK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libSDL.a" "-targets=hip-spirv64-unknown-unknown-unknown-generic" 
"-output=[[SDL_A:.*\.a]]" "-allow-missing-bundles"
+// SDL-LINK: "{{.*}}llvm-link" "{{.*}}.bc" "[[SDL_A]]" "-o"
+
+// SDL-ARCHIVE: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libSDL.a" "-targets=hip-spirv64-unknown-unknown-unknown-generic" 
"-output=[[SDL_A:.*\.a]]" "-allow-missing-bundles"  
+// SDL-ARCHIVE: "{{.*}}llvm-link" "{{.*}}.bc" "[[SDL_A]]" "-o"
+
+// Test that no SDL linking occurs when --no-offloadlib is used
+// RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc --no-offloadlib %s \
+// RUN:   -L%t -lSDL \
+// RUN: 2>&1 | FileCheck -check-prefix=NO-SDL %s
+
+// NO-SDL-NOT: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libSDL.a"
+
+__global__ void kernel() {} 

linehill wrote:

FYI, this line is not needed. This file won't be compiled because of `-###` 
option which just prints commands but doesn't run them.

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


[clang-tools-extra] [clang-tidy] fix false negatives with type aliases in `cppcoreguidlines-pro-bounds-pointer-arithmetic` check (PR #139430)

2025-06-18 Thread Baranov Victor via cfe-commits

vbvictor wrote:

rebased + ping

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


[clang] HIPSPV: Unbundle SDL (PR #136412)

2025-06-18 Thread Henry Linjamäki via cfe-commits


@@ -0,0 +1,38 @@
+// Test HIPSPV static device library linking
+// REQUIRES: system-linux
+// UNSUPPORTED: system-windows
+
+// Create a dummy archive to test SDL linking
+// RUN: rm -rf %t && mkdir %t
+// RUN: touch %t/dummy.bc  
+// RUN: llvm-ar cr %t/libSDL.a %t/dummy.bc
+
+// Test that -l options are passed to llvm-link for --offload=spirv64
+// RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN:   -L%t -lSDL \
+// RUN: 2>&1 | FileCheck -check-prefix=SDL-LINK %s
+
+// Test that .a files are properly unbundled and passed to llvm-link  
+// RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN:   %t/libSDL.a \
+// RUN: 2>&1 | FileCheck -check-prefix=SDL-ARCHIVE %s
+
+// Verify that the input files are added before the SDL files in llvm-link 
command
+// This tests the ordering fix to match HIPAMD behavior
+// SDL-LINK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libSDL.a" "-targets=hip-spirv64-unknown-unknown-unknown-generic" 
"-output=[[SDL_A:.*\.a]]" "-allow-missing-bundles"
+// SDL-LINK: "{{.*}}llvm-link" "{{.*}}.bc" "[[SDL_A]]" "-o"
+
+// SDL-ARCHIVE: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libSDL.a" "-targets=hip-spirv64-unknown-unknown-unknown-generic" 
"-output=[[SDL_A:.*\.a]]" "-allow-missing-bundles"  
+// SDL-ARCHIVE: "{{.*}}llvm-link" "{{.*}}.bc" "[[SDL_A]]" "-o"
+
+// Test that no SDL linking occurs when --no-offloadlib is used
+// RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc --no-offloadlib %s \
+// RUN:   -L%t -lSDL \
+// RUN: 2>&1 | FileCheck -check-prefix=NO-SDL %s
+

linehill wrote:

As mentioned before, the `--no-offloadlib` is not meant for disabling SDL and 
there doesn't seem to be an option for that either.

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


[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-18 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/139566

>From 1b0b6242e5749e776f02581ba8600d853bfef322 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Mon, 12 May 2025 07:25:57 -0700
Subject: [PATCH 01/10] [win][clang] Align scalar deleting destructors with
 MSABI

While working on vector deleting destructors support (GH19772), I
noticed that MSVC produces different code in scalar deleting destructor
body depending on whether class defined its own operator delete.
In MSABI deleting destructors accept an additional implicit flag
parameter allowing some sort of flexibility. The mismatch I noticed is
that whenever a global operator delete is called, i.e. ::delete, in the
code produced by MSVC the implicit flag argument has a value that makes
the 3rd bit set, i.e. "5" for scalar deleting destructors "7" for vector
deleting destructors.
Prior to this patch, clang handled ::delete via calling global operator
delete direct after the destructor call and not calling class operator
delete in scalar deleting destructor body by passing "0" as implicit
flag argument value. This is fine until there is an attempt to link binaries
compiled with clang with binaries compiled with MSVC. The problem is that in
binaries produced by MSVC the callsite of the destructor won't call global
operator delete because it is assumed that the destructor will do that and a
destructor body generated by clang will never do.
This patch removes call to global operator delete from the callsite and
add additional check of the 3rd bit of the implicit parameter inside of
scalar deleting destructor body.
---
 clang/include/clang/AST/DeclCXX.h | 11 +++
 clang/include/clang/Sema/Sema.h   | 10 ++-
 clang/lib/CodeGen/CGClass.cpp | 77 +++
 clang/lib/CodeGen/MicrosoftCXXABI.cpp | 11 +--
 clang/lib/Sema/SemaDeclCXX.cpp| 15 
 clang/lib/Sema/SemaExprCXX.cpp| 19 +++--
 .../CodeGenCXX/cxx2a-destroying-delete.cpp| 59 --
 .../CodeGenCXX/microsoft-abi-structors.cpp| 44 ++-
 8 files changed, 202 insertions(+), 44 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index b7980137002aa..cc2832ea99d4a 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2855,6 +2855,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
   // FIXME: Don't allocate storage for these except in the first declaration
   // of a virtual destructor.
   FunctionDecl *OperatorDelete = nullptr;
+  FunctionDecl *OperatorGlobalDelete = nullptr;
   Expr *OperatorDeleteThisArg = nullptr;
 
   CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
@@ -2885,6 +2886,16 @@ class CXXDestructorDecl : public CXXMethodDecl {
 return getCanonicalDecl()->OperatorDelete;
   }
 
+  const FunctionDecl *getOperatorGlobalDelete() const {
+return getCanonicalDecl()->OperatorGlobalDelete;
+  }
+
+  void setOperatorGlobalDelete(FunctionDecl *OD) {
+auto *First = cast(getFirstDecl());
+if (OD && !First->OperatorGlobalDelete)
+  First->OperatorGlobalDelete = OD;
+  }
+
   Expr *getOperatorDeleteThisArg() const {
 return getCanonicalDecl()->OperatorDeleteThisArg;
   }
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6ea7ee281e14d..5f2ceebcd42e3 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -8495,10 +8495,12 @@ class Sema final : public SemaBase {
 bool Diagnose = true);
   FunctionDecl *FindUsualDeallocationFunction(SourceLocation StartLoc,
   ImplicitDeallocationParameters,
-  DeclarationName Name);
-  FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
-  CXXRecordDecl *RD,
-  bool Diagnose = true);
+  DeclarationName Name,
+  bool Diagnose = true);
+  FunctionDecl *
+  FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
+CXXRecordDecl *RD, bool Diagnose = 
true,
+bool LookForGlobal = false);
 
   /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
   /// @code ::delete ptr; @endcode
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index befbfc64a680c..360876244cad9 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1589,25 +1589,74 @@ namespace {
   void EmitConditionalDtorDeleteCall(CodeGenFunction &CGF,
  llvm::Value *ShouldDeleteCondition,
  bool ReturnAfterDelete) {

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits


@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
-  uint64_t  getIP() const { return _registers.__pc; }
-  void  setIP(uint64_t value) { _registers.__pc = value; }
-  uint64_t  getFP() const { return _registers.__fp; }
-  void  setFP(uint64_t value) { _registers.__fp = value; }
+  uint64_t getIP() const {
+uint64_t value = _registers.__pc;
+#if __has_feature(ptrauth_calls)
+// Note the value of the PC was signed to its address in the register state
+// but everyone else expects it to be sign by the SP, so convert on return.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)_registers.__pc, ptrauth_key_return_address, &_registers.__pc,
+ptrauth_key_return_address, getSP());
+#endif
+return value;
+  }
+  void setIP(uint64_t value) {
+#if __has_feature(ptrauth_calls)
+// Note the value which was set should have been signed with the SP.
+// We then resign with the slot we are being stored in to so that both SP
+// and LR can't be spoofed at the same time.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)value, ptrauth_key_return_address, getSP(),
+ptrauth_key_return_address, &_registers.__pc);
+#endif
+_registers.__pc = value;
+  }
+  uint64_t getFP() const { return _registers.__fp; }
+  void setFP(uint64_t value) { _registers.__fp = value; }
+
+  typedef uint64_t reg_t;
+  typedef uint64_t
+  __LIBUNWIND_PTRAUTH_RI_PDC("Registers_arm64::link_reg_t") link_reg_t;
+  void
+  loadAndAuthenticateLinkRegister(reg_t inplaceAuthedLinkRegister,
+  link_reg_t *referenceAuthedLinkRegister) {
+#if __has_feature(ptrauth_calls)
+// If we are in an arm64e frame, then the PC should have been signed
+// with the SP
+*referenceAuthedLinkRegister = (uint64_t)ptrauth_auth_data(
+(void *)inplaceAuthedLinkRegister, ptrauth_key_return_address,
+_registers.__sp);

kovdan01 wrote:

It looks like that we need to use `&_registers.__pc` instead of 
`_registers.__sp` because the address was resigned in `setIP`. Locally, I had 
an auth failure with this code, and this was resolved by using 
`&_registers.__pc`

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits


@@ -541,7 +554,33 @@ struct scan_results
 };
 
 }  // unnamed namespace
+}
 
+namespace {
+// The logical model for casting authenticated function pointers makes
+// it impossible to directly cast them without breaking the authentication,
+// as a result we need this pair of helpers.
+template 
+void set_landing_pad_as_ptr(scan_results& results, const PtrType& out) {

kovdan01 wrote:

`PtrType` seems to always be a ... pointer type :) So, probably, you can just 
pass by value instead of using const l-value reference.

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


[clang-tools-extra] 669627d - Add check 'cppcoreguidelines-use-enum-class' (#138282)

2025-06-18 Thread via cfe-commits

Author: Philipp Jung
Date: 2025-06-18T11:02:53+02:00
New Revision: 669627d0c77ed8408358bc8c5973255fe28a36ea

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

LOG: Add check 'cppcoreguidelines-use-enum-class' (#138282)

Warn on non-class enum definitions as suggested by the Core Guidelines:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-class

Added: 
clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.h

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/use-enum-class.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/use-enum-class.cpp

Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index b023f76a25432..2fb4d7f1d7349 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -33,6 +33,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule STATIC
   RvalueReferenceParamNotMovedCheck.cpp
   SlicingCheck.cpp
   SpecialMemberFunctionsCheck.cpp
+  UseEnumClassCheck.cpp
   VirtualClassDestructorCheck.cpp
 
   LINK_LIBS

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
index 4dd9b0904f075..4b3b7bf963fdc 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -48,6 +48,7 @@
 #include "RvalueReferenceParamNotMovedCheck.h"
 #include "SlicingCheck.h"
 #include "SpecialMemberFunctionsCheck.h"
+#include "UseEnumClassCheck.h"
 #include "VirtualClassDestructorCheck.h"
 
 namespace clang::tidy {
@@ -131,6 +132,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
 CheckFactories.registerCheck("cppcoreguidelines-slicing");
 CheckFactories.registerCheck(
 "cppcoreguidelines-use-default-member-init");
+CheckFactories.registerCheck(
+"cppcoreguidelines-use-enum-class");
 CheckFactories.registerCheck(
 "cppcoreguidelines-c-copy-assignment-signature");
 CheckFactories.registerCheck(

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
new file mode 100644
index 0..ec7d9237afa3c
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
@@ -0,0 +1,42 @@
+//===--- UseEnumClassCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UseEnumClassCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::cppcoreguidelines {
+
+UseEnumClassCheck::UseEnumClassCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IgnoreUnscopedEnumsInClasses(
+  Options.get("IgnoreUnscopedEnumsInClasses", false)) {}
+
+void UseEnumClassCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreUnscopedEnumsInClasses",
+IgnoreUnscopedEnumsInClasses);
+}
+
+void UseEnumClassCheck::registerMatchers(MatchFinder *Finder) {
+  auto EnumDecl =
+  IgnoreUnscopedEnumsInClasses
+  ? enumDecl(unless(isScoped()), unless(hasParent(recordDecl(
+  : enumDecl(unless(isScoped()));
+  Finder->addMatcher(EnumDecl.bind("unscoped_enum"), this);
+}
+
+void UseEnumClassCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *UnscopedEnum = Result.Nodes.getNodeAs("unscoped_enum");
+
+  diag(UnscopedEnum->getLocation(),
+   "enum %0 is unscoped, use 'enum class' instead")
+  << UnscopedEnum;
+}
+
+} // namespace clang::tidy::cppcoreguidelines

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.h
new file mode 100644
index 0..dfa4b7e3fda62
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumCla

[clang] 8e157fd - [CIR] Add support for __builtin_assume (#144376)

2025-06-18 Thread via cfe-commits

Author: Sirui Mu
Date: 2025-06-18T17:10:29+08:00
New Revision: 8e157fdbb7b4af9f67b139a9f05feaa9b338d3f5

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

LOG: [CIR] Add support for __builtin_assume (#144376)

This patch adds support for the `__builtin_assume` builtin function.

Added: 


Modified: 
clang/include/clang/CIR/Dialect/IR/CIROps.td
clang/include/clang/CIR/MissingFeatures.h
clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
clang/lib/CIR/CodeGen/CIRGenFunction.h
clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h
clang/test/CIR/CodeGen/builtin_call.cpp

Removed: 




diff  --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 8dd1f0ce361d7..4655cebc82ee7 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -2387,4 +2387,26 @@ def ComplexCreateOp : CIR_Op<"complex.create", [Pure, 
SameTypeOperands]> {
   let hasFolder = 1;
 }
 
+//===--===//
+// Assume Operations
+//===--===//
+
+def AssumeOp : CIR_Op<"assume"> {
+  let summary = "Tell the optimizer that a boolean value is true";
+  let description = [{
+The `cir.assume` operation takes a single boolean prediate as its only
+argument and does not have any results. The operation tells the optimizer
+that the predicate is always true.
+
+This operation corresponds to the `__assume` and the `__builtin_assume`
+builtin functions.
+  }];
+
+  let arguments = (ins CIR_BoolType:$predicate);
+
+  let assemblyFormat = [{
+$predicate `:` type($predicate) attr-dict
+  }];
+}
+
 #endif // CLANG_CIR_DIALECT_IR_CIROPS_TD

diff  --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3dc28e6f2e5bf..3d120903dea19 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -237,6 +237,9 @@ struct MissingFeatures {
   static bool lowerAggregateLoadStore() { return false; }
   static bool dataLayoutTypeAllocSize() { return false; }
   static bool asmLabelAttr() { return false; }
+  static bool builtinCall() { return false; }
+  static bool builtinCallF128() { return false; }
+  static bool builtinCallMathErrno() { return false; }
 
   // Missing types
   static bool dataMemberType() { return false; }

diff  --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index 19fac00ab8736..83825f0835a1e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "CIRGenCall.h"
+#include "CIRGenConstantEmitter.h"
 #include "CIRGenFunction.h"
 #include "CIRGenModule.h"
 #include "CIRGenValue.h"
@@ -66,6 +67,32 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, 
unsigned builtinID,
 return emitLibraryCall(*this, fd, e,
cgm.getBuiltinLibFunction(fd, builtinID));
 
+  assert(!cir::MissingFeatures::builtinCallF128());
+
+  // If the builtin has been declared explicitly with an assembler label,
+  // disable the specialized emitting below. Ideally we should communicate the
+  // rename in IR, or at least avoid generating the intrinsic calls that are
+  // likely to get lowered to the renamed library functions.
+  unsigned builtinIDIfNoAsmLabel = fd->hasAttr() ? 0 : builtinID;
+
+  assert(!cir::MissingFeatures::builtinCallMathErrno());
+  assert(!cir::MissingFeatures::builtinCall());
+
+  switch (builtinIDIfNoAsmLabel) {
+  default:
+break;
+
+  case Builtin::BI__assume:
+  case Builtin::BI__builtin_assume: {
+if (e->getArg(0)->HasSideEffects(getContext()))
+  return RValue::get(nullptr);
+
+mlir::Value argValue = emitCheckedArgForAssume(e->getArg(0));
+builder.create(getLoc(e->getExprLoc()), argValue);
+return RValue::get(nullptr);
+  }
+  }
+
   cgm.errorNYI(e->getSourceRange(), "unimplemented builtin call");
   return getUndefRValue(e->getType());
 }
@@ -88,3 +115,14 @@ cir::FuncOp CIRGenModule::getBuiltinLibFunction(const 
FunctionDecl *fd,
   mlir::Type type = convertType(fd->getType());
   return getOrCreateCIRFunction(name, type, d, /*forVTable=*/false);
 }
+
+mlir::Value CIRGenFunction::emitCheckedArgForAssume(const Expr *e) {
+  mlir::Value argValue = evaluateExprAsBool(e);
+  if (!sanOpts.has(SanitizerKind::Builtin))
+return argValue;
+
+  assert(!cir::MissingFeatures::sanitizers());
+  cgm.errorNYI(e->getSourceRange(),
+   "emitCheckedArgForAssume: sanitize

[clang] [clang][headers]Remove unnecessary guard of !defined(__SCE__). (PR #144522)

2025-06-18 Thread Ying Yi via cfe-commits

https://github.com/MaggieYingYi updated 
https://github.com/llvm/llvm-project/pull/144522

>From 80d8a8ed4705cbfd24f473e484a0c0546a9e665d Mon Sep 17 00:00:00 2001
From: Ying Yi 
Date: Mon, 9 Jun 2025 20:01:21 +0100
Subject: [PATCH] Remove unnecessary guard of !defined(__SCE__).

Sony PlayStation now supports C++20, and we wish to change the default C++ mode 
to C++20 sometime in the future. As such, the !defined(__SCE__) guards are 
redundant and we want to remove them. This in turn makes the entire guard lines 
redundant (always true), so this patch removes them entirely.
---
 clang/lib/Headers/bmiintrin.h   |   4 -
 clang/lib/Headers/immintrin.h   | 224 
 clang/lib/Headers/keylockerintrin.h |   9 --
 clang/lib/Headers/x86gprintrin.h|  14 --
 clang/lib/Headers/x86intrin.h   |  18 ---
 5 files changed, 269 deletions(-)

diff --git a/clang/lib/Headers/bmiintrin.h b/clang/lib/Headers/bmiintrin.h
index 59c5ece3977f3..8024da55379ca 100644
--- a/clang/lib/Headers/bmiintrin.h
+++ b/clang/lib/Headers/bmiintrin.h
@@ -161,8 +161,6 @@ _mm_tzcnt_64(unsigned long long __X) {
 
 #undef __RELAXED_FN_ATTRS
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI__)
-
 /* Define the default attributes for the functions in this file. */
 #if defined(__cplusplus) && (__cplusplus >= 201103L)
 #define __DEFAULT_FN_ATTRS 
\
@@ -603,6 +601,4 @@ __blsr_u64(unsigned long long __X) {
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* !defined(__SCE__) || __has_feature(modules) || defined(__BMI__) */
-
 #endif /* __BMIINTRIN_H */
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 19c5987257a27..35f012cc70043 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -16,231 +16,112 @@
 
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__MMX__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE3__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSSE3__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AES__) || defined(__PCLMUL__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__CLFLUSHOPT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__CLWB__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__F16C__)
 #include 
-#endif
 
-/* No feature check desired due to internal checks */
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__LZCNT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__POPCNT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__FMA__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512F__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VL__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BW__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BITALG__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512CD__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512VPOPCNTDQ__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VNNI__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512VNNI__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVXVNNI__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512DQ__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512BITALG__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512BW__))
 

[clang] [CIR] Add support for __builtin_assume (PR #144376)

2025-06-18 Thread Sirui Mu via cfe-commits

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


[clang] fe42d34 - [clang][headers]Remove unnecessary guard of !defined(__SCE__). (#144522)

2025-06-18 Thread via cfe-commits

Author: Ying Yi
Date: 2025-06-18T10:13:46+01:00
New Revision: fe42d34274cac79794637bf2f69f85537dde8b74

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

LOG: [clang][headers]Remove unnecessary guard of !defined(__SCE__). (#144522)

Sony PlayStation now supports C++20, and we wish to change the default
C++ mode to C++20 sometime in the future. As such, the !defined(__SCE__)
guards are redundant and we want to remove them. This in turn makes the
entire guard lines redundant (always true), so this patch removes them
entirely.

Added: 


Modified: 
clang/lib/Headers/bmiintrin.h
clang/lib/Headers/immintrin.h
clang/lib/Headers/keylockerintrin.h
clang/lib/Headers/x86gprintrin.h
clang/lib/Headers/x86intrin.h

Removed: 




diff  --git a/clang/lib/Headers/bmiintrin.h b/clang/lib/Headers/bmiintrin.h
index 59c5ece3977f3..8024da55379ca 100644
--- a/clang/lib/Headers/bmiintrin.h
+++ b/clang/lib/Headers/bmiintrin.h
@@ -161,8 +161,6 @@ _mm_tzcnt_64(unsigned long long __X) {
 
 #undef __RELAXED_FN_ATTRS
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI__)
-
 /* Define the default attributes for the functions in this file. */
 #if defined(__cplusplus) && (__cplusplus >= 201103L)
 #define __DEFAULT_FN_ATTRS 
\
@@ -603,6 +601,4 @@ __blsr_u64(unsigned long long __X) {
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* !defined(__SCE__) || __has_feature(modules) || defined(__BMI__) */
-
 #endif /* __BMIINTRIN_H */

diff  --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 19c5987257a27..35f012cc70043 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -16,231 +16,112 @@
 
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__MMX__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE3__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSSE3__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AES__) || defined(__PCLMUL__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__CLFLUSHOPT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__CLWB__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__F16C__)
 #include 
-#endif
 
-/* No feature check desired due to internal checks */
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__LZCNT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__POPCNT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__FMA__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512F__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VL__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BW__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BITALG__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512CD__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512VPOPCNTDQ__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VNNI__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512VNNI__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVXVNNI__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512DQ__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512BITALG__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_featur

[clang] [clang] Register all LLVM targets in AllClangUnitTest main (PR #144428)

2025-06-18 Thread kadir çetinkaya via cfe-commits

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


[clang] [REAPPLY][Clang-Repl] Add support for out-of-process execution. #110418 (PR #144064)

2025-06-18 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,267 @@
+//===-- RemoteJITUtils.cpp - Utilities for remote-JITing *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// FIXME: Unify this code with similar functionality in llvm-jitlink.
+//
+//===--===//
+
+#include "clang/Interpreter/RemoteJITUtils.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
+#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
+#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
+#include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
+#include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
+#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+#ifdef LLVM_ON_UNIX
+#include 
+#include 
+#include 
+#include 
+#endif // LLVM_ON_UNIX
+
+using namespace llvm;
+using namespace llvm::orc;
+
+Expected getSlabAllocSize(StringRef SizeString) {
+  SizeString = SizeString.trim();
+
+  uint64_t Units = 1024;
+
+  if (SizeString.ends_with_insensitive("kb"))
+SizeString = SizeString.drop_back(2).rtrim();
+  else if (SizeString.ends_with_insensitive("mb")) {
+Units = 1024 * 1024;
+SizeString = SizeString.drop_back(2).rtrim();
+  } else if (SizeString.ends_with_insensitive("gb")) {
+Units = 1024 * 1024 * 1024;
+SizeString = SizeString.drop_back(2).rtrim();
+  }
+
+  uint64_t SlabSize = 0;
+  if (SizeString.getAsInteger(10, SlabSize))
+return make_error("Invalid numeric format for slab size",
+   inconvertibleErrorCode());
+
+  return SlabSize * Units;
+}
+
+Expected>
+createSharedMemoryManager(SimpleRemoteEPC &SREPC,
+  StringRef SlabAllocateSizeString) {
+  SharedMemoryMapper::SymbolAddrs SAs;
+  if (auto Err = SREPC.getBootstrapSymbols(
+  {{SAs.Instance, rt::ExecutorSharedMemoryMapperServiceInstanceName},
+   {SAs.Reserve,
+rt::ExecutorSharedMemoryMapperServiceReserveWrapperName},
+   {SAs.Initialize,
+rt::ExecutorSharedMemoryMapperServiceInitializeWrapperName},
+   {SAs.Deinitialize,
+rt::ExecutorSharedMemoryMapperServiceDeinitializeWrapperName},
+   {SAs.Release,
+rt::ExecutorSharedMemoryMapperServiceReleaseWrapperName}}))
+return std::move(Err);
+
+#ifdef _WIN32
+  size_t SlabSize = 1024 * 1024;
+#else
+  size_t SlabSize = 1024 * 1024 * 1024;
+#endif
+
+  if (!SlabAllocateSizeString.empty()) {
+if (auto S = getSlabAllocSize(SlabAllocateSizeString))
+  SlabSize = *S;
+else
+  return S.takeError();
+  }
+
+  return MapperJITLinkMemoryManager::CreateWithMapper(
+  SlabSize, SREPC, SAs);
+}
+
+Expected>
+launchExecutor(StringRef ExecutablePath, bool UseSharedMemory,
+   llvm::StringRef SlabAllocateSizeString) {
+#ifndef LLVM_ON_UNIX
+  // FIXME: Add support for Windows.
+  return make_error("-" + ExecutablePath +
+ " not supported on non-unix platforms",
+ inconvertibleErrorCode());
+#elif !LLVM_ENABLE_THREADS
+  // Out of process mode using SimpleRemoteEPC depends on threads.
+  return make_error(
+  "-" + ExecutablePath +
+  " requires threads, but LLVM was built with "
+  "LLVM_ENABLE_THREADS=Off",
+  inconvertibleErrorCode());
+#else
+
+  if (!sys::fs::can_execute(ExecutablePath))
+return make_error(
+formatv("Specified executor invalid: {0}", ExecutablePath),
+inconvertibleErrorCode());
+
+  constexpr int ReadEnd = 0;
+  constexpr int WriteEnd = 1;
+
+  // Pipe FDs.
+  int ToExecutor[2];
+  int FromExecutor[2];
+
+  pid_t ChildPID;
+
+  // Create pipes to/from the executor..
+  if (pipe(ToExecutor) != 0 || pipe(FromExecutor) != 0)
+return make_error("Unable to create pipe for executor",
+   inconvertibleErrorCode());
+
+  ChildPID = fork();
+
+  if (ChildPID == 0) {
+// In the child...
+
+// Close the parent ends of the pipes
+close(ToExecutor[WriteEnd]);
+close(FromExecutor[ReadEnd]);
+
+// Execute the child process.
+std::unique_ptr ExecutorPath, FDSpecifier;
+{
+  ExecutorPath = std::make_unique(ExecutablePath.size() + 1);
+  strcpy(ExecutorPath.get(), ExecutablePath.data());
+
+  std::string FDSpecifierStr("filedescs=");
+  FDSpecifierStr += utostr(ToExecutor[ReadEnd]);
+  FDSpecifierStr += ',';
+  FDSpecifierStr += utostr(FromExecutor[WriteEnd]);
+  FDSpecifier = std::make_unique(FD

[clang] [REAPPLY][Clang-Repl] Add support for out-of-process execution. #110418 (PR #144064)

2025-06-18 Thread Vassil Vassilev via cfe-commits


@@ -756,11 +777,11 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char 
*name) {
   if (!EE)
 return EE.takeError();
 
-  auto &DL = EE->getDataLayout();
-
-  if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
-  name, DL.getGlobalPrefix()))
-EE->getMainJITDylib().addGenerator(std::move(*DLSG));
+  if (auto DLSG = llvm::orc::EPCDynamicLibrarySearchGenerator::Load(

vgvassilev wrote:

Can we spell out the type here?

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


[clang] [REAPPLY][Clang-Repl] Add support for out-of-process execution. #110418 (PR #144064)

2025-06-18 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,267 @@
+//===-- RemoteJITUtils.cpp - Utilities for remote-JITing *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// FIXME: Unify this code with similar functionality in llvm-jitlink.
+//
+//===--===//
+
+#include "clang/Interpreter/RemoteJITUtils.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
+#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
+#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
+#include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
+#include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
+#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+
+#ifdef LLVM_ON_UNIX
+#include 
+#include 
+#include 
+#include 
+#endif // LLVM_ON_UNIX
+
+using namespace llvm;
+using namespace llvm::orc;
+
+Expected getSlabAllocSize(StringRef SizeString) {
+  SizeString = SizeString.trim();
+
+  uint64_t Units = 1024;
+
+  if (SizeString.ends_with_insensitive("kb"))
+SizeString = SizeString.drop_back(2).rtrim();
+  else if (SizeString.ends_with_insensitive("mb")) {
+Units = 1024 * 1024;
+SizeString = SizeString.drop_back(2).rtrim();
+  } else if (SizeString.ends_with_insensitive("gb")) {
+Units = 1024 * 1024 * 1024;
+SizeString = SizeString.drop_back(2).rtrim();
+  }
+
+  uint64_t SlabSize = 0;
+  if (SizeString.getAsInteger(10, SlabSize))
+return make_error("Invalid numeric format for slab size",
+   inconvertibleErrorCode());
+
+  return SlabSize * Units;
+}
+
+Expected>
+createSharedMemoryManager(SimpleRemoteEPC &SREPC,
+  StringRef SlabAllocateSizeString) {
+  SharedMemoryMapper::SymbolAddrs SAs;
+  if (auto Err = SREPC.getBootstrapSymbols(
+  {{SAs.Instance, rt::ExecutorSharedMemoryMapperServiceInstanceName},
+   {SAs.Reserve,
+rt::ExecutorSharedMemoryMapperServiceReserveWrapperName},
+   {SAs.Initialize,
+rt::ExecutorSharedMemoryMapperServiceInitializeWrapperName},
+   {SAs.Deinitialize,
+rt::ExecutorSharedMemoryMapperServiceDeinitializeWrapperName},
+   {SAs.Release,
+rt::ExecutorSharedMemoryMapperServiceReleaseWrapperName}}))
+return std::move(Err);
+
+#ifdef _WIN32
+  size_t SlabSize = 1024 * 1024;
+#else
+  size_t SlabSize = 1024 * 1024 * 1024;
+#endif
+
+  if (!SlabAllocateSizeString.empty()) {
+if (auto S = getSlabAllocSize(SlabAllocateSizeString))

vgvassilev wrote:

Can we spell out the type?

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


[clang] Fix tests failing on fuchsia clang x86_64 builders (PR #144655)

2025-06-18 Thread Garvit Gupta via cfe-commits

https://github.com/quic-garvgupt created 
https://github.com/llvm/llvm-project/pull/144655

Fuchsia sets CLANG_DEFAULT_UNWINDLIB to libunwind. As a result, when rtlib is 
set to libgcc and unwindlib is not explicitly specified, tests using Fuchsia as 
the default platform will fail. To address this, the affected tests are now 
marked as unsupported on the Fuchsia platform.

This change fixes the following tests introduced in 
https://github.com/llvm/llvm-project/commit/45ea46c44636094e9fcdbbeabfd11f9d0fad5e38:

clang/test/Driver/aarch64-toolchain-extra.c
clang/test/Driver/arm-toolchain-extra.c
clang/test/Driver/aarch64-toolchain.c
clang/test/Driver/arm-toolchain.c

>From 5041a43ba895f1dc49e02b894a535976671124fe Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Wed, 18 Jun 2025 01:57:27 -0700
Subject: [PATCH] Fix tests failing on fuchsia clang x86_64 builders

Change-Id: I18c76810d7a58770ab4883d29c2da544730ade62
---
 clang/test/Driver/aarch64-toolchain-extra.c | 2 +-
 clang/test/Driver/aarch64-toolchain.c   | 2 +-
 clang/test/Driver/arm-toolchain-extra.c | 2 +-
 clang/test/Driver/arm-toolchain.c   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/test/Driver/aarch64-toolchain-extra.c 
b/clang/test/Driver/aarch64-toolchain-extra.c
index 2610e962bd690..d8ba0556167ab 100644
--- a/clang/test/Driver/aarch64-toolchain-extra.c
+++ b/clang/test/Driver/aarch64-toolchain-extra.c
@@ -4,7 +4,7 @@
 // these tests need to create symlinks to test directory trees in order to
 // set up the environment and therefore shell support is required.
 // REQUIRES: shell
-// UNSUPPORTED: system-windows
+// UNSUPPORTED: system-windows, target={{.*}}-fuchsia{{.*}}
 
 // If there is no GCC install detected then the driver searches for executables
 // and runtime starting from the directory tree above the driver itself.
diff --git a/clang/test/Driver/aarch64-toolchain.c 
b/clang/test/Driver/aarch64-toolchain.c
index 7f2c01d928e43..dfa63bfff4d1c 100644
--- a/clang/test/Driver/aarch64-toolchain.c
+++ b/clang/test/Driver/aarch64-toolchain.c
@@ -1,4 +1,4 @@
-// UNSUPPORTED: system-windows
+// UNSUPPORTED: system-windows, target={{.*}}-fuchsia{{.*}}
 
 // RUN: %clang -### %s -fuse-ld= \
 // RUN:   --target=aarch64-none-elf --rtlib=libgcc \
diff --git a/clang/test/Driver/arm-toolchain-extra.c 
b/clang/test/Driver/arm-toolchain-extra.c
index 114de0a8154ab..f3e4f5f368d38 100644
--- a/clang/test/Driver/arm-toolchain-extra.c
+++ b/clang/test/Driver/arm-toolchain-extra.c
@@ -4,7 +4,7 @@
 // these tests need to create symlinks to test directory trees in order to
 // set up the environment and therefore shell support is required.
 // REQUIRES: shell
-// UNSUPPORTED: system-windows
+// UNSUPPORTED: system-windows, target={{.*}}-fuchsia{{.*}}
 
 // If there is no GCC install detected then the driver searches for executables
 // and runtime starting from the directory tree above the driver itself.
diff --git a/clang/test/Driver/arm-toolchain.c 
b/clang/test/Driver/arm-toolchain.c
index 2e38461fb7a3e..8cd6c5e96b7a0 100644
--- a/clang/test/Driver/arm-toolchain.c
+++ b/clang/test/Driver/arm-toolchain.c
@@ -1,4 +1,4 @@
-// UNSUPPORTED: system-windows
+// UNSUPPORTED: system-windows, target={{.*}}-fuchsia{{.*}}
 
 // RUN: %clang -### %s -fuse-ld= \
 // RUN:   --target=armv6m-none-eabi --rtlib=libgcc \

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


[clang-tools-extra] Add check 'cppcoreguidelines-use-enum-class' (PR #138282)

2025-06-18 Thread Carlos Galvez via cfe-commits

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Anatoly Trosinenko via cfe-commits

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits


@@ -207,7 +211,8 @@ bool DwarfInstructions::isReturnAddressSignedWithPC(A 
&addressSpace,
 #endif
 
 template 
-int DwarfInstructions::stepWithDwarf(A &addressSpace, pint_t pc,
+int DwarfInstructions::stepWithDwarf(A &addressSpace,
+   typename R::link_reg_t &pc,

kovdan01 wrote:

Could you please clarify the reason why `pc` became an out-parameter? I do not 
see any other changes in the function

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits


@@ -207,7 +211,8 @@ bool DwarfInstructions::isReturnAddressSignedWithPC(A 
&addressSpace,
 #endif
 
 template 
-int DwarfInstructions::stepWithDwarf(A &addressSpace, pint_t pc,
+int DwarfInstructions::stepWithDwarf(A &addressSpace,

kovdan01 wrote:

In this function, we have `newRegisters.setIP(returnAddress);`. The 
`returnAddress` there is unsigned, which causes an error when trying to auth 
and resign in `setIP` (at least, this is the case for me locally).

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


[clang] [clang][headers]Remove unnecessary guard of !defined(__SCE__). (PR #144522)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Ying Yi (MaggieYingYi)


Changes

Sony PlayStation now supports C++20, and we wish to change the default C++ mode 
to C++20 sometime in the future. As such, the !defined(__SCE__) guards are 
redundant and we want to remove them. This in turn makes the entire guard lines 
redundant (always true), so this patch removes them entirely.

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


5 Files Affected:

- (modified) clang/lib/Headers/bmiintrin.h (-4) 
- (modified) clang/lib/Headers/immintrin.h (-224) 
- (modified) clang/lib/Headers/keylockerintrin.h (-9) 
- (modified) clang/lib/Headers/x86gprintrin.h (-14) 
- (modified) clang/lib/Headers/x86intrin.h (-18) 


``diff
diff --git a/clang/lib/Headers/bmiintrin.h b/clang/lib/Headers/bmiintrin.h
index 59c5ece3977f3..8024da55379ca 100644
--- a/clang/lib/Headers/bmiintrin.h
+++ b/clang/lib/Headers/bmiintrin.h
@@ -161,8 +161,6 @@ _mm_tzcnt_64(unsigned long long __X) {
 
 #undef __RELAXED_FN_ATTRS
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI__)
-
 /* Define the default attributes for the functions in this file. */
 #if defined(__cplusplus) && (__cplusplus >= 201103L)
 #define __DEFAULT_FN_ATTRS 
\
@@ -603,6 +601,4 @@ __blsr_u64(unsigned long long __X) {
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* !defined(__SCE__) || __has_feature(modules) || defined(__BMI__) */
-
 #endif /* __BMIINTRIN_H */
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 19c5987257a27..35f012cc70043 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -16,231 +16,112 @@
 
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__MMX__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSE3__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__SSSE3__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AES__) || defined(__PCLMUL__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__CLFLUSHOPT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__CLWB__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__F16C__)
 #include 
-#endif
 
-/* No feature check desired due to internal checks */
 #include 
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__BMI2__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__LZCNT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__POPCNT__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__FMA__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512F__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VL__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BW__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512BITALG__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512CD__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512VPOPCNTDQ__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512VNNI__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512VNNI__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVXVNNI__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || defined(__AVX512DQ__)
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512BITALG__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(defined(__AVX512VL__) && defined(__AVX512BW__))
 #include 
-#endif
 
-#if !defined(__SCE__) || __has_feature(modules) || 
\
-(define

[clang-tools-extra] Add check 'cppcoreguidelines-use-enum-class' (PR #138282)

2025-06-18 Thread via cfe-commits

github-actions[bot] wrote:



@JungPhilipp Congratulations on having your first Pull Request (PR) merged into 
the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[clang] [Clang] Verify data layout consistency (PR #144720)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikita Popov (nikic)


Changes

Verify that the alignments specified by clang TargetInfo match the alignments 
specified by LLVM data layout, which will hopefully prevent accidental 
mismatches in the future.

This currently contains opt-outs for a lot of existing mismatches.

I'm also skipping the verification if options like `-malign-double` are used, 
or a language that mandates sizes/alignments that differ from C.

The verification happens in CodeGen, as we can't have an IR dependency in Basic.

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


1 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+73) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c27168e4c4bfe..aabc872e22df1 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -332,6 +332,76 @@ const TargetCodeGenInfo 
&CodeGenModule::getTargetCodeGenInfo() {
   return *TheTargetCodeGenInfo;
 }
 
+static void checkDataLayoutConsistency(const TargetInfo &Target,
+   llvm::LLVMContext &Context,
+   const LangOptions &Opts) {
+#ifndef NDEBUG
+  // Don't verify non-standard ABI configurations.
+  if (Opts.AlignDouble || Opts.OpenCL || Opts.HLSL)
+return;
+
+  llvm::Triple Triple = Target.getTriple();
+  llvm::DataLayout DL(Target.getDataLayoutString());
+  auto Check = [&](const char *Name, llvm::Type *Ty, unsigned Alignment) {
+llvm::Align DLAlign = DL.getABITypeAlign(Ty);
+llvm::Align ClangAlign(Alignment / 8);
+if (DLAlign != ClangAlign) {
+  llvm::errs() << "For target " << Triple.str() << " type " << Name
+   << " mapping to " << *Ty << " has data layout alignment "
+   << DLAlign.value() << " while clang specifies "
+   << ClangAlign.value() << "\n";
+  abort();
+}
+  };
+
+  Check("bool", llvm::Type::getIntNTy(Context, Target.BoolWidth),
+Target.BoolAlign);
+  Check("short", llvm::Type::getIntNTy(Context, Target.ShortWidth),
+Target.ShortAlign);
+  // FIXME: M68k specifies incorrect wrong int and long alignments in Clang
+  // and incorrect long long alignment in both LLVM and Clang.
+  if (Triple.getArch() != llvm::Triple::m68k) {
+Check("int", llvm::Type::getIntNTy(Context, Target.IntWidth),
+  Target.IntAlign);
+Check("long", llvm::Type::getIntNTy(Context, Target.LongWidth),
+  Target.LongAlign);
+Check("long long", llvm::Type::getIntNTy(Context, Target.LongLongWidth),
+  Target.LongLongAlign);
+  }
+  // FIXME: There are int128 alignment mismatches on multiple targets.
+  if (Target.hasInt128Type() && !Target.getTargetOpts().ForceEnableInt128 &&
+  !Triple.isAMDGPU() && !Triple.isSPIRV() &&
+  Triple.getArch() != llvm::Triple::ve)
+Check("__int128", llvm::Type::getIntNTy(Context, 128), Target.Int128Align);
+
+  if (Target.hasFloat16Type())
+Check("half", llvm::Type::getFloatingPointTy(Context, *Target.HalfFormat),
+  Target.HalfAlign);
+  if (Target.hasBFloat16Type())
+Check("bfloat", llvm::Type::getBFloatTy(Context), Target.BFloat16Align);
+  Check("float", llvm::Type::getFloatingPointTy(Context, *Target.FloatFormat),
+Target.FloatAlign);
+  // FIXME: AIX specifies wrong double alignment in DataLayout
+  if (!Triple.isOSAIX()) {
+Check("double",
+  llvm::Type::getFloatingPointTy(Context, *Target.DoubleFormat),
+  Target.DoubleAlign);
+Check("long double",
+  llvm::Type::getFloatingPointTy(Context, *Target.LongDoubleFormat),
+  Target.LongDoubleAlign);
+  }
+  // FIXME: Wasm has a mismatch in f128 alignment between Clang and LLVM.
+  if (Target.hasFloat128Type() && !Triple.isWasm())
+Check("__float128", llvm::Type::getFP128Ty(Context), Target.Float128Align);
+  if (Target.hasIbm128Type())
+Check("__ibm128", llvm::Type::getPPC_FP128Ty(Context), Target.Ibm128Align);
+
+  // FIXME: Clang specifies incorrect pointer alignment for m68k.
+  if (Triple.getArch() != llvm::Triple::m68k)
+Check("void*", llvm::PointerType::getUnqual(Context), Target.PointerAlign);
+#endif
+}
+
 CodeGenModule::CodeGenModule(ASTContext &C,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions &HSO,
@@ -458,6 +528,9 @@ CodeGenModule::CodeGenModule(ASTContext &C,
   if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
 getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters",
   CodeGenOpts.NumRegisterParameters);
+
+  if (!Context.getAuxTargetInfo())
+checkDataLayoutConsistency(Context.getTargetInfo(), LLVMContext, LangOpts);
 }
 
 CodeGenModule::~CodeGenModule() {}

``




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

[clang] [clang-tools-extra] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)

2025-06-18 Thread via cfe-commits

YexuanXiao wrote:

CI shows that it passed all tests on Linux, but there were 4 tests failed on 
Windows, which seem unrelated to this PR.

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


[clang] [Modules] Record whether VarDecl initializers contain side effects (PR #143739)

2025-06-18 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn updated 
https://github.com/llvm/llvm-project/pull/143739

>From 89179c0d4ebcbc5311af73ce293d9297e196b786 Mon Sep 17 00:00:00 2001
From: "Henrik G. Olsson" 
Date: Wed, 11 Jun 2025 17:36:29 +0200
Subject: [PATCH] [Modules] Record whether VarDecl initializers contain side
 effects

Calling `DeclMustBeEmitted` should not lead to more deserialization, as
it may occur before previous deserialization has finished.
When passed a `VarDecl` with an initializer however, `DeclMustBeEmitted`
needs to know whether that initializer contains side effects. When the
`VarDecl` is deserialized but the initializer is not, this triggers
deserialization of the initializer. To avoid this we add a bit to the
serialization format for `VarDecl`s, indicating whether its initializer
contains side effects or not, so that the `ASTReader` can query this
information directly without deserializing the initializer.

rdar://153085264
---
 clang/include/clang/AST/Decl.h|  5 +++
 clang/include/clang/AST/ExternalASTSource.h   |  5 +++
 clang/include/clang/Serialization/ASTReader.h |  6 +++
 clang/lib/AST/ASTContext.cpp  |  4 +-
 clang/lib/AST/Decl.cpp| 25 +
 clang/lib/Serialization/ASTReader.cpp |  4 ++
 clang/lib/Serialization/ASTReaderDecl.cpp |  4 ++
 clang/lib/Serialization/ASTWriterDecl.cpp |  1 +
 clang/test/Modules/var-init-side-effects.cpp  | 37 +++
 9 files changed, 88 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Modules/var-init-side-effects.cpp

diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 3faf63e395a08..008c97c18d63a 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1351,6 +1351,11 @@ class VarDecl : public DeclaratorDecl, public 
Redeclarable {
 return const_cast(this)->getInitializingDeclaration();
   }
 
+  /// Checks whether this declaration has an initializer with side effects,
+  /// without triggering deserialization if the initializer is not yet
+  /// deserialized.
+  bool hasInitWithSideEffects() const;
+
   /// Determine whether this variable's value might be usable in a
   /// constant expression, according to the relevant language standard.
   /// This only checks properties of the declaration, and does not check
diff --git a/clang/include/clang/AST/ExternalASTSource.h 
b/clang/include/clang/AST/ExternalASTSource.h
index f45e3af7602c1..4d0812b158a19 100644
--- a/clang/include/clang/AST/ExternalASTSource.h
+++ b/clang/include/clang/AST/ExternalASTSource.h
@@ -51,6 +51,7 @@ class RecordDecl;
 class Selector;
 class Stmt;
 class TagDecl;
+class VarDecl;
 
 /// Abstract interface for external sources of AST nodes.
 ///
@@ -195,6 +196,10 @@ class ExternalASTSource : public 
RefCountedBase {
   /// module.
   virtual bool wasThisDeclarationADefinition(const FunctionDecl *FD);
 
+  virtual bool hasInitializerWithSideEffects(const VarDecl *VD) const {
+return false;
+  }
+
   /// Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 2765c827ece2b..bbbf3a9c369c9 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1442,6 +1442,10 @@ class ASTReader
 const StringRef &operator*() && = delete;
   };
 
+  /// VarDecls with initializers containing side effects must be emitted,
+  /// but DeclMustBeEmitted is not allowed to deserialize the intializer.
+  llvm::SmallPtrSet InitSideEffectVars;
+
 public:
   /// Get the buffer for resolving paths.
   SmallString<0> &getPathBuf() { return PathBuf; }
@@ -2392,6 +2396,8 @@ class ASTReader
 
   bool wasThisDeclarationADefinition(const FunctionDecl *FD) override;
 
+  bool hasInitializerWithSideEffects(const VarDecl *VD) const override;
+
   /// Retrieve a selector from the given module with its local ID
   /// number.
   Selector getLocalSelector(ModuleFile &M, unsigned LocalID);
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 2836d68b05ff6..16530c560a28b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12889,9 +12889,7 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
 return true;
 
   // Variables that have initialization with side-effects are required.
-  if (VD->getInit() && VD->getInit()->HasSideEffects(*this) &&
-  // We can get a value-dependent initializer during error recovery.
-  (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
+  if (VD->hasInitWithSideEffects())
 return true;
 
   // Likewise, variables with tuple-like bindings are required if their
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 1d9208f0e1c72..93c8abcb894e1 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@

[clang] [Modules] Record whether VarDecl initializers contain side effects (PR #143739)

2025-06-18 Thread Henrik G. Olsson via cfe-commits

hnrklssn wrote:

> > The direction meets my expectation. I think you already have an existing 
> > test for swift. Maybe you can try to reduce a lit test from it.
> 
> Yeah, I've tried reducing a lit test, but my reduced case doesn't trigger the 
> original assert because the initializer is already deserialized. I'm trying 
> to figure out what the difference is.

Managed to create a reduced test case now that triggered the original assert, 
but doesn't with the current patch.

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


[clang] [Modules] Record whether VarDecl initializers contain side effects (PR #143739)

2025-06-18 Thread Henrik G. Olsson via cfe-commits

hnrklssn wrote:

> I think this new function should be called from 
> `ASTContext::DeclMustBeEmitted`, no?

Of course, yes! Fixed now.

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


[clang] [CIR] Add Minimal Destructor Definition Support (PR #144719)

2025-06-18 Thread Morris Hafner via cfe-commits

https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/144719

>From 278750574dd72831347bbba144bd49ded9daaa3c Mon Sep 17 00:00:00 2001
From: Morris Hafner 
Date: Wed, 18 Jun 2025 15:09:21 +0100
Subject: [PATCH 1/2] [CIR] Add Minimal Destructor Definition Support

This patch upstreams support for writing inline and out of line C++ destructor 
definitions. Calling a destructor implcitly or explicitly is left for a future 
patch.

Because of that restriction complete destructors (D2 in Itanium mangling) do 
not call into the base (D1) destructors yet but simply behave like a base 
destructor. Deleting (D0) destructor support is not part of this patch.

Destructor aliases aren't supported, either. Because of this compilation with 
-mno-constructor-aliases may be required to avoid running into NYI errors.
---
 clang/include/clang/CIR/MissingFeatures.h |   4 +
 clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp|   7 ++
 clang/lib/CIR/CodeGen/CIRGenCXXABI.h  |  13 +++
 clang/lib/CIR/CodeGen/CIRGenFunction.cpp  | 100 +-
 clang/lib/CIR/CodeGen/CIRGenFunction.h|   1 +
 clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp |  31 --
 clang/lib/CIR/CodeGen/CIRGenModule.cpp|  29 -
 clang/lib/CIR/CodeGen/CIRGenModule.h  |   2 +-
 .../CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp |   3 +-
 clang/test/CIR/CodeGen/destructors.cpp|  50 +
 10 files changed, 230 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/CIR/CodeGen/destructors.cpp

diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3d120903dea19..174b1ccfd27f9 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -240,6 +240,10 @@ struct MissingFeatures {
   static bool builtinCall() { return false; }
   static bool builtinCallF128() { return false; }
   static bool builtinCallMathErrno() { return false; }
+  static bool appleKext() { return false; }
+  static bool dtorCleanups() { return false; }
+  static bool completeDtors() { return false; }
+  static bool vtableInitialization() { return false; }
 
   // Missing types
   static bool dataMemberType() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
index 6cf4e5c658fb6..33b812ac81f6e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
@@ -41,6 +41,13 @@ void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
   assert(!cir::MissingFeatures::cxxabiThisAlignment());
 }
 
+cir::GlobalLinkageKind CIRGenCXXABI::getCXXDestructorLinkage(
+GVALinkage linkage, const CXXDestructorDecl *dtor, CXXDtorType dt) const {
+  // Delegate back to cgm by default.
+  return cgm.getCIRLinkageForDeclarator(dtor, linkage,
+/*isConstantVariable=*/false);
+}
+
 mlir::Value CIRGenCXXABI::loadIncomingCXXThis(CIRGenFunction &cgf) {
   ImplicitParamDecl *vd = getThisDecl(cgf);
   Address addr = cgf.getAddrOfLocalVar(vd);
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
index 2d967fd307e01..eb079b877b7ff 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
@@ -72,6 +72,19 @@ class CIRGenCXXABI {
   /// Emit constructor variants required by this ABI.
   virtual void emitCXXConstructors(const clang::CXXConstructorDecl *d) = 0;
 
+  /// Emit dtor variants required by this ABI.
+  virtual void emitCXXDestructors(const clang::CXXDestructorDecl *d) = 0;
+
+  /// Returns true if the given destructor type should be emitted as a linkonce
+  /// delegating thunk, regardless of whether the dtor is defined in this TU or
+  /// not.
+  virtual bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
+  CXXDtorType dt) const = 0;
+
+  virtual cir::GlobalLinkageKind
+  getCXXDestructorLinkage(GVALinkage linkage, const CXXDestructorDecl *dtor,
+  CXXDtorType dt) const;
+
   /// Returns true if the given constructor or destructor is one of the kinds
   /// that the ABI says returns 'this' (only applies when called non-virtually
   /// for destructors).
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp 
b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
index fd413fe86383a..e7f91480cc0f7 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
@@ -463,7 +463,7 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl 
gd, cir::FuncOp fn,
 startFunction(gd, retTy, fn, funcType, args, loc, bodyRange.getBegin());
 
 if (isa(funcDecl))
-  getCIRGenModule().errorNYI(bodyRange, "C++ destructor definition");
+  emitDestructorBody(args);
 else if (isa(funcDecl))
   emitConstructorBody(args);
 else if (getLangOpts().CUDA && !getLangOpts().CUDAIsDevice &&
@@ -538,6 +538,104 @@ void CIRGenFunction::emitConstructorBody

[clang] [llvm] [HLSL][SPIR-V] Fix LinkageAttribute emission for BuiltIn (PR #144701)

2025-06-18 Thread Steven Perron via cfe-commits

https://github.com/s-perron approved this pull request.


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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits


@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) 
{
 /* This method is only used in value profiler mock testing.  */
 COMPILER_RT_VISIBILITY void *
 __llvm_get_function_addr(const __llvm_profile_data *Data) {
-  return Data->FunctionPointer;
+  void *FP = Data->FunctionPointer;
+#if __has_feature(ptrauth_calls)
+  // This is only used for tests where we compare against what happens to be
+  // signed pointers.
+  FP = ptrauth_sign_unauthenticated(FP, VALID_CODE_KEY, 0);

kovdan01 wrote:

> @kovdan01 @asl do you folk have a vm setup you can test on? I realize I'm 
> currently limited to building for darwin so it's easy for me to luck out on 
> implicit/transitive includes from other places.

@ojhunt Yeah, we have that and we can run llvm-test-suite and some other 
private pauth-specific tests. And, of course, we have a build of pauth-enabled 
linux toolchain configured.

Basically, having these is the reason why I'm able to add such comments in this 
PR :)

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits


@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void 
*registers) {
   memcpy(_vectorHalfRegisters,
  static_cast(registers) + sizeof(GPRs),
  sizeof(_vectorHalfRegisters));
+#if __has_feature(ptrauth_calls)
+  uint64_t pcRegister = 0;
+  memcpy(&pcRegister, ((uint8_t *)&_registers) + offsetof(GPRs, __pc),
+ sizeof(pcRegister));
+  setIP(pcRegister);
+  uint64_t fpRegister = 0;
+  memcpy(&fpRegister, ((uint8_t *)&_registers) + offsetof(GPRs, __fp),
+ sizeof(fpRegister));
+  setFP(fpRegister);
+#endif
+}
+
+inline Registers_arm64::Registers_arm64(const Registers_arm64 &other) {

kovdan01 wrote:

I've just revealed that at least `operator=` is not dead code. It's called from 
`stepWithDwarf`. So yeah, you probably just need to add declarations.

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


[clang-tools-extra] [clang-tidy] add 'IgnoreMarcos' option to 'avoid-goto' check (PR #143554)

2025-06-18 Thread Carlos Galvez via cfe-commits

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

LGTM!

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


[clang] [analyzer] Conversion to CheckerFamily: DynamicTypePropagation (PR #144735)

2025-06-18 Thread Balazs Benics via cfe-commits

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


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


[clang] [Clang] Partially fix m68k alignments (PR #144740)

2025-06-18 Thread Nikita Popov via cfe-commits

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

As the data layout a few lines further up specifies, the int, long and pointer 
alignment should be 16 instead of the default of 32.

The long long alignment is also incorrect, but that would require a change to 
the data layout as well.

Comparison with GCC, which consistently uses 2 byte alignment: 
https://gcc.godbolt.org/z/K3x6a7dEf At least based on some spot checks, the 
changes to bit field layout also make use match GCC now.

This was found by https://github.com/llvm/llvm-project/pull/144720.

>From 05fac2f808f5eae4e4f213212af2cc782535318c Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 18 Jun 2025 17:04:29 +0200
Subject: [PATCH] [Clang] Partially fix m68k alignments

As the data layout specifies, the int, long and pointer alignment
should be 16 instead of the default of 32.

The long long alignment is also incorrect, but that would require
a change to the data layout as well.
---
 clang/lib/Basic/Targets/M68k.cpp  |  1 +
 clang/test/CodeGen/bitfield-access-pad.c  | 52 ++-
 .../test/CodeGenCXX/bitfield-access-empty.cpp | 22 +++-
 3 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index f0c77f027858f..3988cb5294560 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -56,6 +56,7 @@ M68kTargetInfo::M68kTargetInfo(const llvm::Triple &Triple,
   SizeType = UnsignedInt;
   PtrDiffType = SignedInt;
   IntPtrType = SignedInt;
+  IntAlign = LongAlign = PointerAlign = 16;
 }
 
 bool M68kTargetInfo::setCPU(const std::string &Name) {
diff --git a/clang/test/CodeGen/bitfield-access-pad.c 
b/clang/test/CodeGen/bitfield-access-pad.c
index 8608c5bd8be11..2044746118add 100644
--- a/clang/test/CodeGen/bitfield-access-pad.c
+++ b/clang/test/CodeGen/bitfield-access-pad.c
@@ -18,7 +18,7 @@
 // RUN: %clang_cc1 -triple=hexagon-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-T %s
 
 // Big endian
-// RUN: %clang_cc1 -triple=m68k-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-T %s
+// RUN: %clang_cc1 -triple=m68k-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-M68K %s
 // RUN: %clang_cc1 -triple=mips-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-T %s
 
 // And now a few with -fno-bitfield-type-align. Precisely how this behaves is
@@ -45,6 +45,7 @@ struct P1 {
 // CHECK-LABEL: LLVMType:%struct.P1 =
 // LAYOUT-T-SAME: type { i8, i8, [2 x i8] }
 // LAYOUT-ARM64-T-SAME: type { i8, i8 }
+// LAYOUT-M68K-SAME: type { i8, i8 }
 // LAYOUT-NT-SAME: type { i8, i8 }
 // LAYOUT-STRICT-NT-SAME: type { i8, i8 }
 // LAYOUT-DWN32-SAME: type { i8, [3 x i8], i8, [3 x i8] }
@@ -60,6 +61,9 @@ struct P1 {
 
 // LAYOUT-ARM64-T-NEXT: 
 
 struct P2 {
@@ -68,6 +72,7 @@ struct P2 {
 // CHECK-LABEL: LLVMType:%struct.P2 =
 // LAYOUT-SAME: type { i16, i16 }
 // LAYOUT-DWN32-SAME: type { i16, i16 }
+// LAYOUT-M68K-SAME: type { i16, i16 }
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P2 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 
 
 struct P3 {
@@ -85,6 +93,7 @@ struct P3 {
 // CHECK-LABEL: LLVMType:%struct.P3 =
 // LAYOUT-SAME: type { i16, [2 x i8], i16, [2 x i8] }
 // LAYOUT-DWN32-SAME: type <{ i16, i8, i16 }>
+// LAYOUT-M68K-SAME: type <{ i16, i8, i16, i8 }>
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P3 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 
 
 struct P4 {
@@ -121,6 +133,7 @@ struct P6 {
 // CHECK-LABEL: LLVMType:%struct.P6 =
 // LAYOUT-SAME: type { i32, i32 }
 // LAYOUT-DWN32-SAME: type { i32, i32 }
+// LAYOUT-M68K-SAME: type { i32, i32 }
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P6 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 
 
 struct P7 {
@@ -139,6 +155,7 @@ struct P7 {
 // CHECK-LABEL: LLVMType:%struct.P7 =
 // LAYOUT-SAME: type { i32, i32 }
 // LAYOUT-DWN32-SAME: type { i32, i32 }
+// LAYOUT-M68K-SAME: type { i32, i32 }
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P7 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 

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


[clang] [Clang] Fix the clang/test/PCH/ignored-pch.c test. (PR #144737)

2025-06-18 Thread Ying Yi via cfe-commits

https://github.com/MaggieYingYi created 
https://github.com/llvm/llvm-project/pull/144737

Change the test to check the exit status of the 'ls' command line (instead of 
error message) since the error message is different when running 'ls' command 
on the different Host machine.

>From 6d3bd2fb459394c20f15aa3a13816060dc7a3a24 Mon Sep 17 00:00:00 2001
From: Ying Yi 
Date: Wed, 18 Jun 2025 16:45:33 +0100
Subject: [PATCH] [Clang] Fix the clang/test/PCH/ignored-pch.c test.

Change the test to check the exit status of the 'ls' command line (instead of 
error message) since the error message is different when running 'ls' command 
on the
different Host machine.
---
 clang/test/PCH/ignored-pch.c | 58 +---
 1 file changed, 27 insertions(+), 31 deletions(-)

diff --git a/clang/test/PCH/ignored-pch.c b/clang/test/PCH/ignored-pch.c
index 5b64582cba618..c6ef3fe74cee9 100644
--- a/clang/test/PCH/ignored-pch.c
+++ b/clang/test/PCH/ignored-pch.c
@@ -1,96 +1,96 @@
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: ls %t.pch
+// RUN: ls %t.ll
 
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
 // RUN: %clang %s -emit-ast -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: ls %t.pch
+// RUN: ls %t.ll
 
 // Check that -ignore-pch causes -emit-pch and -include-pch options to be 
ignored.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -emit-ast %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ-ERROR %s
+// RUN: not ls %t.ll
 
 // Check that -ignore-pch works for multiple PCH related options.
 // Test with -building-pch-with-obj.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-building-pch-with-obj -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang 
-building-pch-with-obj -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fallow-pch-with-compiler-errors.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-fallow-pch-with-compiler-errors -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang 
-fallow-pch-with-compiler-errors -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fallow-pch-with-different-modules-cache-path.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-fallow-pch-with-different-modules-cache-path -o %t.pch
 // RUN: %clang -S -emit-llvm %s -ignore-pch -include-pch %t.pch -Xclang 
-fallow-pch-with-different-modules-cache-path -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-codegen.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-codegen 
-o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-codegen 
-o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-debuginfo.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-debuginfo 
-o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch 
-fpch-debuginfo -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-instantiate-templates.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch 
-fpch-instantiate-templates -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch 
-fpch-instantiate-templates -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ 

[clang] [analyzer] Conversion to CheckerFamily: DynamicTypePropagation (PR #144735)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




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

Author: Donát Nagy (NagyDonat)


Changes

This commit converts the class DynamicTypePropagation to a very simple checker 
family, which has only one checker frontend -- but also supports enabling the 
backend ("modeling checker") without the frontend.

As a tangentially related change, this commit adds the backend of 
DynamicTypePropagation as a dependency of alpha.core.DynamicTypeChecker, in 
Checkers.td, because the header comment of DynamicTypeChecker.cpp claims that 
it depends on DynamicTypePropagation and a cursory reading of the source code 
seems to confirm this.

(The lack of this dependency relationship didn't cause problems, because 
'core.DynamicTypePropagation' is in the group 'core', so it is practically 
always active. However, explicitly declaring the dependency clarifies the fact 
that the separate existence of the modeling checker is warranted.)

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


2 Files Affected:

- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+6-4) 
- (modified) clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp 
(+24-27) 


``diff
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 2a96df80d1001..789a18ff11043 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -294,10 +294,12 @@ def TestAfterDivZeroChecker : Checker<"TestAfterDivZero">,
"Either the comparison is useless or there is division by zero.">,
   Documentation;
 
-def DynamicTypeChecker : Checker<"DynamicTypeChecker">,
-  HelpText<"Check for cases where the dynamic and the static type of an object 
"
-   "are unrelated.">,
-  Documentation;
+def DynamicTypeChecker
+: Checker<"DynamicTypeChecker">,
+  HelpText<"Check for cases where the dynamic and the static type of an "
+   "object are unrelated.">,
+  Dependencies<[DynamicTypePropagation]>,
+  Documentation;
 
 def StackAddrAsyncEscapeChecker : Checker<"StackAddressAsyncEscape">,
   HelpText<"Check that addresses to stack memory do not escape the function">,
diff --git a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
index 344be0b176c54..87fa233a94413 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -49,15 +49,19 @@ REGISTER_MAP_WITH_PROGRAMSTATE(MostSpecializedTypeArgsMap, 
SymbolRef,
const ObjCObjectPointerType *)
 
 namespace {
-class DynamicTypePropagation:
-public Checker< check::PreCall,
-check::PostCall,
-check::DeadSymbols,
-check::PostStmt,
-check::PostStmt,
-check::PreObjCMessage,
-check::PostObjCMessage > {
+class DynamicTypePropagation
+: public CheckerFamily,
+   check::PostStmt, check::PreObjCMessage,
+   check::PostObjCMessage> {
+public:
+  // This checker family implements only one frontend, but -- unlike a simple
+  // Checker -- its backend can be enabled (by the checker DynamicTypeChecker
+  // which depends on it) without enabling the frontend.
+  CheckerFrontendWithBugType ObjCGenericsChecker{
+  "Generics", categories::CoreFoundationObjectiveC};
 
+private:
   /// Return a better dynamic type if one can be derived from the cast.
   const ObjCObjectPointerType *getBetterObjCType(const Expr *CastE,
  CheckerContext &C) const;
@@ -66,13 +70,6 @@ class DynamicTypePropagation:
   ProgramStateRef &State,
   CheckerContext &C) const;
 
-  mutable std::unique_ptr ObjCGenericsBugType;
-  void initBugType() const {
-if (!ObjCGenericsBugType)
-  ObjCGenericsBugType.reset(new BugType(
-  GenericCheckName, "Generics", categories::CoreFoundationObjectiveC));
-  }
-
   class GenericsBugVisitor : public BugReporterVisitor {
   public:
 GenericsBugVisitor(SymbolRef S) : Sym(S) {}
@@ -106,9 +103,8 @@ class DynamicTypePropagation:
   void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
 
-  /// This value is set to true, when the Generics checker is turned on.
-  bool CheckGenerics = false;
-  CheckerNameRef GenericCheckName;
+  /// Identifies this checker family for debugging purposes.
+  StringRef getDebugTag() const override { return "DynamicTypePropagation"; }
 };
 
 bool isObjCClassType(QualType Type) {
@@ -1026,10 +1022,9 @@ void DynamicTypePropagation::reportGenericsBug(
 const 

[clang] [Clang] Partially fix m68k alignments (PR #144740)

2025-06-18 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-m68k

Author: Nikita Popov (nikic)


Changes

As the data layout a few lines further up specifies, the int, long and pointer 
alignment should be 16 instead of the default of 32.

The long long alignment is also incorrect, but that would require a change to 
the data layout as well.

Comparison with GCC, which consistently uses 2 byte alignment: 
https://gcc.godbolt.org/z/K3x6a7dEf At least based on some spot checks, the 
changes to bit field layout also make use match GCC now.

This was found by https://github.com/llvm/llvm-project/pull/144720.

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


3 Files Affected:

- (modified) clang/lib/Basic/Targets/M68k.cpp (+1) 
- (modified) clang/test/CodeGen/bitfield-access-pad.c (+51-1) 
- (modified) clang/test/CodeGenCXX/bitfield-access-empty.cpp (+21-1) 


``diff
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index f0c77f027858f..3988cb5294560 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -56,6 +56,7 @@ M68kTargetInfo::M68kTargetInfo(const llvm::Triple &Triple,
   SizeType = UnsignedInt;
   PtrDiffType = SignedInt;
   IntPtrType = SignedInt;
+  IntAlign = LongAlign = PointerAlign = 16;
 }
 
 bool M68kTargetInfo::setCPU(const std::string &Name) {
diff --git a/clang/test/CodeGen/bitfield-access-pad.c 
b/clang/test/CodeGen/bitfield-access-pad.c
index 8608c5bd8be11..2044746118add 100644
--- a/clang/test/CodeGen/bitfield-access-pad.c
+++ b/clang/test/CodeGen/bitfield-access-pad.c
@@ -18,7 +18,7 @@
 // RUN: %clang_cc1 -triple=hexagon-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-T %s
 
 // Big endian
-// RUN: %clang_cc1 -triple=m68k-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-T %s
+// RUN: %clang_cc1 -triple=m68k-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-M68K %s
 // RUN: %clang_cc1 -triple=mips-elf %s -emit-llvm -o /dev/null 
-fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-T %s
 
 // And now a few with -fno-bitfield-type-align. Precisely how this behaves is
@@ -45,6 +45,7 @@ struct P1 {
 // CHECK-LABEL: LLVMType:%struct.P1 =
 // LAYOUT-T-SAME: type { i8, i8, [2 x i8] }
 // LAYOUT-ARM64-T-SAME: type { i8, i8 }
+// LAYOUT-M68K-SAME: type { i8, i8 }
 // LAYOUT-NT-SAME: type { i8, i8 }
 // LAYOUT-STRICT-NT-SAME: type { i8, i8 }
 // LAYOUT-DWN32-SAME: type { i8, [3 x i8], i8, [3 x i8] }
@@ -60,6 +61,9 @@ struct P1 {
 
 // LAYOUT-ARM64-T-NEXT: 
 
 struct P2 {
@@ -68,6 +72,7 @@ struct P2 {
 // CHECK-LABEL: LLVMType:%struct.P2 =
 // LAYOUT-SAME: type { i16, i16 }
 // LAYOUT-DWN32-SAME: type { i16, i16 }
+// LAYOUT-M68K-SAME: type { i16, i16 }
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P2 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 
 
 struct P3 {
@@ -85,6 +93,7 @@ struct P3 {
 // CHECK-LABEL: LLVMType:%struct.P3 =
 // LAYOUT-SAME: type { i16, [2 x i8], i16, [2 x i8] }
 // LAYOUT-DWN32-SAME: type <{ i16, i8, i16 }>
+// LAYOUT-M68K-SAME: type <{ i16, i8, i16, i8 }>
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P3 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 
 
 struct P4 {
@@ -121,6 +133,7 @@ struct P6 {
 // CHECK-LABEL: LLVMType:%struct.P6 =
 // LAYOUT-SAME: type { i32, i32 }
 // LAYOUT-DWN32-SAME: type { i32, i32 }
+// LAYOUT-M68K-SAME: type { i32, i32 }
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P6 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 
 
 struct P7 {
@@ -139,6 +155,7 @@ struct P7 {
 // CHECK-LABEL: LLVMType:%struct.P7 =
 // LAYOUT-SAME: type { i32, i32 }
 // LAYOUT-DWN32-SAME: type { i32, i32 }
+// LAYOUT-M68K-SAME: type { i32, i32 }
 // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P7 =
 // CHECK: BitFields:[
 // LAYOUT-NEXT: 

``




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


[clang] [Clang] Fix the clang/test/PCH/ignored-pch.c test. (PR #144737)

2025-06-18 Thread Matheus Izvekov via cfe-commits

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


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


[clang] 6d785ca - [Clang] Fix the clang/test/PCH/ignored-pch.c test. (#144737)

2025-06-18 Thread via cfe-commits

Author: Ying Yi
Date: 2025-06-18T17:14:33+01:00
New Revision: 6d785ca4218b18e77e39320bea7f8973c3ea2764

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

LOG: [Clang] Fix the clang/test/PCH/ignored-pch.c test. (#144737)

Change the test to check the exit status of the 'ls' command line
(instead of error message) since the error message is different when
running 'ls' command on the different Host machine.

Added: 


Modified: 
clang/test/PCH/ignored-pch.c

Removed: 




diff  --git a/clang/test/PCH/ignored-pch.c b/clang/test/PCH/ignored-pch.c
index 5b64582cba618..c6ef3fe74cee9 100644
--- a/clang/test/PCH/ignored-pch.c
+++ b/clang/test/PCH/ignored-pch.c
@@ -1,96 +1,96 @@
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: ls %t.pch
+// RUN: ls %t.ll
 
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
 // RUN: %clang %s -emit-ast -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: ls %t.pch
+// RUN: ls %t.ll
 
 // Check that -ignore-pch causes -emit-pch and -include-pch options to be 
ignored.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -emit-ast %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ-ERROR %s
+// RUN: not ls %t.ll
 
 // Check that -ignore-pch works for multiple PCH related options.
 // Test with -building-pch-with-obj.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-building-pch-with-obj -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang 
-building-pch-with-obj -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fallow-pch-with-compiler-errors.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-fallow-pch-with-compiler-errors -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang 
-fallow-pch-with-compiler-errors -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fallow-pch-with-
diff erent-modules-cache-path.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-fallow-pch-with-
diff erent-modules-cache-path -o %t.pch
 // RUN: %clang -S -emit-llvm %s -ignore-pch -include-pch %t.pch -Xclang 
-fallow-pch-with-
diff erent-modules-cache-path -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-codegen.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-codegen 
-o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-codegen 
-o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-debuginfo.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-debuginfo 
-o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch 
-fpch-debuginfo -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-instantiate-templates.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch 
-fpch-instantiate-templates -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch 
-fpch-instantiate-templates -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fno-pch-timestamp.

[clang] [Clang] Fix the clang/test/PCH/ignored-pch.c test. (PR #144737)

2025-06-18 Thread Ying Yi via cfe-commits

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


[clang] [llvm] [PowerPC][AIX] Specify correct ABI alignment for double (PR #144673)

2025-06-18 Thread Eli Friedman via cfe-commits

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

This all makes sense to me, but needs an PPC reviewer to approve.

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


[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-06-18 Thread Nikita Popov via cfe-commits

nikic wrote:

To make the question more precise, would it make sense to change AMDGPUs 
unaligned access hook such that https://godbolt.org/z/Gv1j4vjqE will look the 
same as on X86?

That should also fix the motivating problem here.

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


[clang] let Neon builtin function accept a const variable (PR #144625)

2025-06-18 Thread Eli Friedman via cfe-commits

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

Needs regression tests (in clang/test/Sema/).  For NEON intrinsics, and 
whatever other classes of intrinsics are affected by this.

Please add a reference to the issue in the commit message, like "fixes #144625" 
(the initial comment on the pull request will become the commit message when 
it's merged).

https://github.com/llvm/llvm-project/issues/139033#issuecomment-2868006401 
suggested we want to warn when we do non-standard folding like this.

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


[clang] 45ea46c - Reland [Driver] Add support for GCC installation detection in Baremetal toolchain (#144640)

2025-06-18 Thread via cfe-commits

Author: Garvit Gupta
Date: 2025-06-18T12:50:48+05:30
New Revision: 45ea46c44636094e9fcdbbeabfd11f9d0fad5e38

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

LOG: Reland [Driver] Add support for GCC installation detection in Baremetal 
toolchain (#144640)

This patch introduces enhancements to the Baremetal toolchain to support
GCC toolchain detection.
- If the --gcc-install-dir or --gcc-toolchain options are provided and
point to valid paths, the sysroot is derived from those locations.
- If not, the logic falls back to the existing sysroot inference
mechanism already present in the Baremetal toolchain.
- Support for adding include paths for the libstdc++ library has also
been added.

Additionally, the restriction to always use the integrated assembler has
been removed. With a valid GCC installation, the GNU assembler can now
be used as well.

This patch currently updates and adds tests for the ARM target only.
RISC-V-specific tests will be introduced in a later patch, once the
RISCVToolChain is fully merged into the Baremetal toolchain. At this
stage, there is no way to test the RISC-V target within this PR.

RFC:

https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Added: 

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/.keep
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/.keep
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/bin/aarch64-none-elf-ld

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o

clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crt0.o

clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crtbegin.o

clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crtend.o
clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/bin/aarch64-none-elf-ld

clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include/c++/8.2.1/.keep
clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/lib/.keep
clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/lib/crt0.o
clang/test/Driver/Inputs/basic_arm_gcc_tree/bin/armv6m-none-eabi-ld

clang/test/Driver/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/crtbegin.o

clang/test/Driver/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/crtend.o
clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crt0.o

clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crtbegin.o
clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crtend.o
clang/test/Driver/Inputs/basic_arm_nogcc_tree/bin/armv6m-none-eabi-ld
clang/test/Driver/aarch64-gnutools.c
clang/test/Driver/aarch64-toolchain-extra.c
clang/test/Driver/aarch64-toolchain.c
clang/test/Driver/arm-gnutools.c
clang/test/Driver/arm-toolchain-extra.c
clang/test/Driver/arm-toolchain.c
clang/test/Driver/check-no-multlib-warning.c

Modified: 
clang/docs/Toolchain.rst
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/docs/Toolchain.rst b/clang/docs/Toolchain.rst
index 958199eb7a2e2..d56b21d74c7e3 100644
--- a/clang/docs/Toolchain.rst
+++ b/clang/docs/Toolchain.rst
@@ -347,3 +347,8 @@ workarounds for issues discovered in libstdc++, and these 
are removed
 as fixed libstdc++ becomes sufficiently old.
 
 You can instruct Clang to use libstdc++ with the ``-stdlib=libstdc++`` flag.
+
+GCC Installation
+=
+Users can point to their GCC installation by using the ``-gcc-toolchain`` or by
+using ``-gcc-install-dir`` flag.

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 29f6480ba935c..94224e1038758 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -847,6 +847,9 @@ def note_drv_available_multilibs : Note<
   "available multilibs are:%0">;
 def err_drv_multilib_custom_error : Error<
   "multilib configuration error: %0">;
+def warn_drv_multilib_not_available_for_target: Warning<
+  "no multilib structure encoded for Arm, Aarch64 and PPC targets">,
+  InGroup>;
 
 def err_drv_experimental_crel : Error<
   "-Wa,--allow-experimental-crel must be specified to use -Wa,--crel. "

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-18 Thread John McCall via cfe-commits

rjmccall wrote:

It is very common for type traits to factor into the ABI of a template 
specialization, such that `my_variant` has a different layout depending on 
`is_amazing_v`. That is why changing the value of a type trait generally has 
to be considered an ABI break.

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


[clang] Reland [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #144649)

2025-06-18 Thread Garvit Gupta via cfe-commits

https://github.com/quic-garvgupt created 
https://github.com/llvm/llvm-project/pull/144649

This patch conditionalise the addition of crt{begin,end}.o object files
along with addition of -lgloss lib based on whether libc selected is newlib or
llvm libc. Since there is no way a user can specify which libc it wants to
link against, currently passing valid GCCInstallation to driver will select
newlib otherwise it will default to llvm libc.

Moreover, this patch makes gnuld the default linker for baremetal
toolchain object. User need to pass `-fuse-ld=lld` explicitly to driver to 
select
lld

This is the 2nd patch in the series of patches of merging RISCVToolchain
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

>From 43ea078f3a000f4d13c76115284219937c8f1ef7 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Tue, 17 Jun 2025 22:49:55 +0530
Subject: [PATCH] [Driver] Add support for crtbegin.o, crtend.o and libgloss
 lib to BareMetal toolchain object (#121830)

This patch conditionalise the addition of crt{begin,end}.o object files
along
with addition of -lgloss lib based on whether libc selected is newlib or
llvm
libc. Since there is no way a user can specify which libc it wants to
link
against, currently passing valid GCCInstallation to driver will select
newlib
otherwise it will default to llvm libc.

Moreover, this patch makes gnuld the default linker for baremetal
toolchain
object. User need to pass `-fuse-ld=lld` explicitly to driver to select
lld

This is the 2nd patch in the series of patches of merging RISCVToolchain
into
BareMetal toolchain object.

RFC:

https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524
---
 clang/lib/Driver/ToolChains/BareMetal.cpp   | 37 +++-
 clang/lib/Driver/ToolChains/BareMetal.h |  3 +-
 clang/test/Driver/aarch64-toolchain-extra.c | 13 ++-
 clang/test/Driver/aarch64-toolchain.c   | 95 
 clang/test/Driver/arm-toolchain-extra.c |  7 ++
 clang/test/Driver/arm-toolchain.c   | 99 -
 clang/test/Driver/baremetal.cpp |  3 +-
 clang/test/Driver/sanitizer-ld.c|  2 +-
 8 files changed, 246 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 0fbfe6c77f342..a08bb588dd764 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -584,9 +584,31 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool NeedCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *CRTBegin, *CRTEnd;
+  if (NeedCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  switch (RuntimeLib) {
+  case (ToolChain::RLT_Libgcc): {
+CRTBegin = "crtbegin.o";
+CRTEnd = "crtend.o";
+break;
+  }
+  case (ToolChain::RLT_CompilerRT): {
+CRTBegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+CRTEnd =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+break;
+  }
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTBegin)));
+}
   }
 
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
@@ -609,15 +631,22 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+CmdArgs.push_back("--start-group");
 AddRunTimeLibs(TC, D, CmdArgs, Args);
-
 CmdArgs.push_back("-lc");
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D))
+  CmdArgs.push_back("-lgloss");
+CmdArgs.push_back("--end-group");
   }
 
   if (D.isUsingLTO())
 addLTOOptions(TC, Args, CmdArgs, Output, Inputs,
   D.getLTOMode() == LTOK_Thin);
 
+  if ((TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) &&
+  NeedCRTs)
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTEnd)));
+
   if (TC.getTriple().isRISCV())
 CmdArgs.push_back("-X");
 
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 930f8584e6435..54805530bae82 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -38,6 +38,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 public:
   bool initGCCInstallation(const llvm::Tripl

[clang] Reland [Driver] Add support for GCC installation detection in Baremetal toolchain (PR #144640)

2025-06-18 Thread Garvit Gupta via cfe-commits

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


[clang] [libcxx] [libc++][Clang] Added explanation why is_constructible evaluated to false. Updated the diagnostics checks in libc++ tests. (PR #144220)

2025-06-18 Thread Shamshura Egor via cfe-commits

egorshamshura wrote:

@philnik777 Is it my fault that tests fail with ```Error: Process completed 
with exit code 255```?

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


[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-18 Thread Oliver Hunt via cfe-commits

ojhunt wrote:

> It is very common for type traits to factor into the ABI of a template 
> specialization, such that `my_variant` has a different layout depending on 
> `is_amazing_v`. That is why changing the value of a type trait generally 
> has to be considered an ABI break.

ah right, it's not that the instantiated symbol directly references the trait 
in mangling or similar, it's that the layout differs based on the query even 
though the symbol name does not reference the trait.

@cor3ntin I think the correct call is to revert the removal of support for 
explicit qualifiers even though it does mean we'll need to do more work on perf 
design in future - do you agree with @rjmccall's rationale?


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


[clang] Reland [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #144649)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Garvit Gupta (quic-garvgupt)


Changes

This patch conditionalise the addition of crt{begin,end}.o object files
along with addition of -lgloss lib based on whether libc selected is newlib or
llvm libc. Since there is no way a user can specify which libc it wants to
link against, currently passing valid GCCInstallation to driver will select
newlib otherwise it will default to llvm libc.

Moreover, this patch makes gnuld the default linker for baremetal
toolchain object. User need to pass `-fuse-ld=lld` explicitly to driver to 
select
lld

This is the 2nd patch in the series of patches of merging RISCVToolchain
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

---

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


8 Files Affected:

- (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+33-4) 
- (modified) clang/lib/Driver/ToolChains/BareMetal.h (+1-2) 
- (modified) clang/test/Driver/aarch64-toolchain-extra.c (+10-3) 
- (modified) clang/test/Driver/aarch64-toolchain.c (+95) 
- (modified) clang/test/Driver/arm-toolchain-extra.c (+7) 
- (modified) clang/test/Driver/arm-toolchain.c (+97-2) 
- (modified) clang/test/Driver/baremetal.cpp (+2-1) 
- (modified) clang/test/Driver/sanitizer-ld.c (+1-1) 


``diff
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 0fbfe6c77f342..a08bb588dd764 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -584,9 +584,31 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool NeedCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *CRTBegin, *CRTEnd;
+  if (NeedCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  switch (RuntimeLib) {
+  case (ToolChain::RLT_Libgcc): {
+CRTBegin = "crtbegin.o";
+CRTEnd = "crtend.o";
+break;
+  }
+  case (ToolChain::RLT_CompilerRT): {
+CRTBegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+CRTEnd =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+break;
+  }
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTBegin)));
+}
   }
 
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
@@ -609,15 +631,22 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+CmdArgs.push_back("--start-group");
 AddRunTimeLibs(TC, D, CmdArgs, Args);
-
 CmdArgs.push_back("-lc");
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D))
+  CmdArgs.push_back("-lgloss");
+CmdArgs.push_back("--end-group");
   }
 
   if (D.isUsingLTO())
 addLTOOptions(TC, Args, CmdArgs, Output, Inputs,
   D.getLTOMode() == LTOK_Thin);
 
+  if ((TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) &&
+  NeedCRTs)
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTEnd)));
+
   if (TC.getTriple().isRISCV())
 CmdArgs.push_back("-X");
 
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 930f8584e6435..54805530bae82 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -38,6 +38,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 public:
   bool initGCCInstallation(const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
+  bool hasValidGCCInstallation() const { return IsGCCInstallationValid; }
   bool isBareMetal() const override { return true; }
   bool isCrossCompiling() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
@@ -63,8 +64,6 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 return ToolChain::CST_Libcxx;
   }
 
-  const char *getDefaultLinker() const override { return "ld.lld"; }
-
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
diff --git a/clang/test/Driver/aarch64-toolchain-extra.c 
b/clang/test/Driver/aarch64-toolchain-extra.c
index 2610e962bd690..2a930e35acd45 100644
--- a/clang/test/Drive

[clang] Reland [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #144649)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Garvit Gupta (quic-garvgupt)


Changes

This patch conditionalise the addition of crt{begin,end}.o object files
along with addition of -lgloss lib based on whether libc selected is newlib or
llvm libc. Since there is no way a user can specify which libc it wants to
link against, currently passing valid GCCInstallation to driver will select
newlib otherwise it will default to llvm libc.

Moreover, this patch makes gnuld the default linker for baremetal
toolchain object. User need to pass `-fuse-ld=lld` explicitly to driver to 
select
lld

This is the 2nd patch in the series of patches of merging RISCVToolchain
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

---

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


8 Files Affected:

- (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+33-4) 
- (modified) clang/lib/Driver/ToolChains/BareMetal.h (+1-2) 
- (modified) clang/test/Driver/aarch64-toolchain-extra.c (+10-3) 
- (modified) clang/test/Driver/aarch64-toolchain.c (+95) 
- (modified) clang/test/Driver/arm-toolchain-extra.c (+7) 
- (modified) clang/test/Driver/arm-toolchain.c (+97-2) 
- (modified) clang/test/Driver/baremetal.cpp (+2-1) 
- (modified) clang/test/Driver/sanitizer-ld.c (+1-1) 


``diff
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 0fbfe6c77f342..a08bb588dd764 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -584,9 +584,31 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool NeedCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *CRTBegin, *CRTEnd;
+  if (NeedCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  switch (RuntimeLib) {
+  case (ToolChain::RLT_Libgcc): {
+CRTBegin = "crtbegin.o";
+CRTEnd = "crtend.o";
+break;
+  }
+  case (ToolChain::RLT_CompilerRT): {
+CRTBegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+CRTEnd =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+break;
+  }
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTBegin)));
+}
   }
 
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
@@ -609,15 +631,22 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+CmdArgs.push_back("--start-group");
 AddRunTimeLibs(TC, D, CmdArgs, Args);
-
 CmdArgs.push_back("-lc");
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D))
+  CmdArgs.push_back("-lgloss");
+CmdArgs.push_back("--end-group");
   }
 
   if (D.isUsingLTO())
 addLTOOptions(TC, Args, CmdArgs, Output, Inputs,
   D.getLTOMode() == LTOK_Thin);
 
+  if ((TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) &&
+  NeedCRTs)
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTEnd)));
+
   if (TC.getTriple().isRISCV())
 CmdArgs.push_back("-X");
 
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 930f8584e6435..54805530bae82 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -38,6 +38,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 public:
   bool initGCCInstallation(const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
+  bool hasValidGCCInstallation() const { return IsGCCInstallationValid; }
   bool isBareMetal() const override { return true; }
   bool isCrossCompiling() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
@@ -63,8 +64,6 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 return ToolChain::CST_Libcxx;
   }
 
-  const char *getDefaultLinker() const override { return "ld.lld"; }
-
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
diff --git a/clang/test/Driver/aarch64-toolchain-extra.c 
b/clang/test/Driver/aarch64-toolchain-extra.c
index 2610e962bd690..2a930e35acd45 100644
--- a/clang/tes

[clang-tools-extra] [clang-tidy] Improve `readability-function-size`: count class member initializers as statements (PR #131669)

2025-06-18 Thread Baranov Victor via cfe-commits

vbvictor wrote:

Ping @HerrCai0907 @PiotrZSL @carlosgalvezp 

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


[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-18 Thread Oliver Hunt via cfe-commits

ojhunt wrote:

Converting to draft so I don't accidentally hit the big green commit button 
(that is big and green despite no approvals ?!?!)

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


[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-18 Thread Oliver Hunt via cfe-commits

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
-  uint64_t  getIP() const { return _registers.__pc; }
-  void  setIP(uint64_t value) { _registers.__pc = value; }
-  uint64_t  getFP() const { return _registers.__fp; }
-  void  setFP(uint64_t value) { _registers.__fp = value; }
+  uint64_t getIP() const {
+uint64_t value = _registers.__pc;
+#if __has_feature(ptrauth_calls)
+// Note the value of the PC was signed to its address in the register state
+// but everyone else expects it to be sign by the SP, so convert on return.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)_registers.__pc, ptrauth_key_return_address, &_registers.__pc,
+ptrauth_key_return_address, getSP());
+#endif
+return value;
+  }
+  void setIP(uint64_t value) {
+#if __has_feature(ptrauth_calls)
+// Note the value which was set should have been signed with the SP.
+// We then resign with the slot we are being stored in to so that both SP
+// and LR can't be spoofed at the same time.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)value, ptrauth_key_return_address, getSP(),
+ptrauth_key_return_address, &_registers.__pc);
+#endif
+_registers.__pc = value;
+  }
+  uint64_t getFP() const { return _registers.__fp; }
+  void setFP(uint64_t value) { _registers.__fp = value; }
+
+  typedef uint64_t reg_t;
+  typedef uint64_t
+  __LIBUNWIND_PTRAUTH_RI_PDC("Registers_arm64::link_reg_t") link_reg_t;
+  void
+  loadAndAuthenticateLinkRegister(reg_t inplaceAuthedLinkRegister,
+  link_reg_t *referenceAuthedLinkRegister) {

ojhunt wrote:

I vastly prefer using pointers for out parameters as it makes it much clearer 
at the call site that it's an out parameter.

Ideally we'd just return the pointer but the problem is we can't have 
ptrauth-qualified return values and as a result it's a foot gun for an oracle.

Alternatively I could create a struct wrapper to force the authentication, but 
the problem there is that I think the design would want to construct a 
dependent ptrauth qualifier and we don't yet support that.

Or I guess we could just make a 
```cpp
template  PointerAuthQualifierPointer = is_pointer && 
(!ptrauth_available || ptrauth_schema_query_has_pointer_auth(T));
template < PointerAuthQualifierPointer T> struct PtrauthQualifiedPointer {
  T thePointer;
  ...
 }
```

To use for parameters and return values we consider important enough to require 
constant protection.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
-  uint64_t  getIP() const { return _registers.__pc; }
-  void  setIP(uint64_t value) { _registers.__pc = value; }
-  uint64_t  getFP() const { return _registers.__fp; }
-  void  setFP(uint64_t value) { _registers.__fp = value; }
+  uint64_t getIP() const {
+uint64_t value = _registers.__pc;
+#if __has_feature(ptrauth_calls)
+// Note the value of the PC was signed to its address in the register state
+// but everyone else expects it to be sign by the SP, so convert on return.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)_registers.__pc, ptrauth_key_return_address, &_registers.__pc,
+ptrauth_key_return_address, getSP());
+#endif
+return value;
+  }
+  void setIP(uint64_t value) {
+#if __has_feature(ptrauth_calls)
+// Note the value which was set should have been signed with the SP.
+// We then resign with the slot we are being stored in to so that both SP
+// and LR can't be spoofed at the same time.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)value, ptrauth_key_return_address, getSP(),
+ptrauth_key_return_address, &_registers.__pc);
+#endif
+_registers.__pc = value;
+  }
+  uint64_t getFP() const { return _registers.__fp; }
+  void setFP(uint64_t value) { _registers.__fp = value; }
+
+  typedef uint64_t reg_t;
+  typedef uint64_t
+  __LIBUNWIND_PTRAUTH_RI_PDC("Registers_arm64::link_reg_t") link_reg_t;
+  void
+  loadAndAuthenticateLinkRegister(reg_t inplaceAuthedLinkRegister,
+  link_reg_t *referenceAuthedLinkRegister) {
+#if __has_feature(ptrauth_calls)

ojhunt wrote:

We use a wide array of ptrauth_returns and ptrauth_calls, do we just want a 
single flag/define we should use?

I think the variation we see here is the outcome of changes over time, but it 
would seem reasonable to maybe just have a single mode flag at this point?

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -93,6 +98,13 @@ class _LIBUNWIND_HIDDEN Registers_x86 {
   uint32_t  getEDI() const { return _registers.__edi; }
   void  setEDI(uint32_t value) { _registers.__edi = value; }
 
+  typedef uint32_t reg_t;
+  typedef uint32_t link_reg_t;
+  void loadAndAuthenticateLinkRegister(reg_t srcLinkRegister,

ojhunt wrote:

yeah, especially as it's clearly difficult to ensure with local builds that 
you've got every other platform correct, and then it's make-work for every 
other platform.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -694,7 +705,12 @@ 
DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto)
   gcspushm x30
 Lnogcs:
 #endif
+
+#if __has_feature(ptrauth_calls)
+  retab
+#else

ojhunt wrote:

see earlier comment - do we want to just adopt a single flag instead of the 
current mix of ptrauth_calls and ptrauth_returns ?

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
-  uint64_t  getIP() const { return _registers.__pc; }
-  void  setIP(uint64_t value) { _registers.__pc = value; }
-  uint64_t  getFP() const { return _registers.__fp; }
-  void  setFP(uint64_t value) { _registers.__fp = value; }
+  uint64_t getIP() const {
+uint64_t value = _registers.__pc;
+#if __has_feature(ptrauth_calls)
+// Note the value of the PC was signed to its address in the register state
+// but everyone else expects it to be sign by the SP, so convert on return.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)_registers.__pc, ptrauth_key_return_address, &_registers.__pc,
+ptrauth_key_return_address, getSP());
+#endif
+return value;
+  }
+  void setIP(uint64_t value) {
+#if __has_feature(ptrauth_calls)
+// Note the value which was set should have been signed with the SP.
+// We then resign with the slot we are being stored in to so that both SP
+// and LR can't be spoofed at the same time.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)value, ptrauth_key_return_address, getSP(),
+ptrauth_key_return_address, &_registers.__pc);
+#endif
+_registers.__pc = value;
+  }
+  uint64_t getFP() const { return _registers.__fp; }
+  void setFP(uint64_t value) { _registers.__fp = value; }
+
+  typedef uint64_t reg_t;
+  typedef uint64_t
+  __LIBUNWIND_PTRAUTH_RI_PDC("Registers_arm64::link_reg_t") link_reg_t;
+  void
+  loadAndAuthenticateLinkRegister(reg_t inplaceAuthedLinkRegister,
+  link_reg_t *referenceAuthedLinkRegister) {
+#if __has_feature(ptrauth_calls)
+// If we are in an arm64e frame, then the PC should have been signed
+// with the SP
+*referenceAuthedLinkRegister = (uint64_t)ptrauth_auth_data(
+(void *)inplaceAuthedLinkRegister, ptrauth_key_return_address,
+_registers.__sp);
+#else
+*referenceAuthedLinkRegister = inplaceAuthedLinkRegister;
+#endif
+  }
+
+  // arm64_32 and i386 simulator hack
+  void loadAndAuthenticateLinkRegister(uint32_t srcLinkRegister,

ojhunt wrote:

This is code we had downstream, I'm not sure of the reason for it, however if 
we switch to a model where we just gate the use of these functions on targeting 
arm64e and don't require every arch provide stub funcs I think that becomes 
moot?

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) 
{
 /* This method is only used in value profiler mock testing.  */
 COMPILER_RT_VISIBILITY void *
 __llvm_get_function_addr(const __llvm_profile_data *Data) {
-  return Data->FunctionPointer;
+  void *FP = Data->FunctionPointer;
+#if __has_feature(ptrauth_calls)
+  // This is only used for tests where we compare against what happens to be
+  // signed pointers.
+  FP = ptrauth_sign_unauthenticated(FP, VALID_CODE_KEY, 0);

ojhunt wrote:

hmmm, I'll see if this actually caused any of the bot failures, and if it's not 
responsible for any I'll try to work out why

@kovdan01 @asl do you folk have a vm setup you can test on? I realize I'm 
currently limited to building for darwin so it's easy for me to luck out on 
implicit/transitive includes from other places.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void 
*registers) {
   memcpy(_vectorHalfRegisters,
  static_cast(registers) + sizeof(GPRs),
  sizeof(_vectorHalfRegisters));
+#if __has_feature(ptrauth_calls)

ojhunt wrote:

- [ ] seems reasonable

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) 
{
 /* This method is only used in value profiler mock testing.  */
 COMPILER_RT_VISIBILITY void *
 __llvm_get_function_addr(const __llvm_profile_data *Data) {
-  return Data->FunctionPointer;
+  void *FP = Data->FunctionPointer;
+#if __has_feature(ptrauth_calls)
+  // This is only used for tests where we compare against what happens to be
+  // signed pointers.
+  FP = ptrauth_sign_unauthenticated(FP, VALID_CODE_KEY, 0);

ojhunt wrote:

It's possible this is a mis-merge/copy - I'll try to work out where 
VALID_CODE_KEY is expected to come from and ensure that I pull that def in.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits


@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void 
*registers) {
   memcpy(_vectorHalfRegisters,
  static_cast(registers) + sizeof(GPRs),
  sizeof(_vectorHalfRegisters));
+#if __has_feature(ptrauth_calls)
+  uint64_t pcRegister = 0;
+  memcpy(&pcRegister, ((uint8_t *)&_registers) + offsetof(GPRs, __pc),
+ sizeof(pcRegister));
+  setIP(pcRegister);
+  uint64_t fpRegister = 0;
+  memcpy(&fpRegister, ((uint8_t *)&_registers) + offsetof(GPRs, __fp),
+ sizeof(fpRegister));
+  setFP(fpRegister);
+#endif
+}
+
+inline Registers_arm64::Registers_arm64(const Registers_arm64 &other) {

ojhunt wrote:

H, I'll need to do some hunting to work out if this code is dead, or if I 
missed some declaration from

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


[clang] [llvm] [X86] Remove CLDEMOTE from Alderlake and later hybrid processors (PR #144662)

2025-06-18 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/144662

SDM doesn't list any hybrid processors in this feature. Besides, physical 
machine also reports not supported.

>From 353fbfc93faa2c1bad26261b566d3f797b6d1a72 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Wed, 18 Jun 2025 16:04:22 +0800
Subject: [PATCH] [X86] Remove CLDEMOTE from Alderlake and later hybrid
 processors

SDM doesn't list any hybrid processors in this feature. Besides,
physical machine also reports not supported.
---
 clang/test/Preprocessor/predefined-arch-macros.c | 4 ++--
 llvm/lib/Target/X86/X86.td   | 2 +-
 llvm/lib/TargetParser/X86TargetParser.cpp| 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 2d17891071aae..9dfeddbd4d5ac 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2102,7 +2102,7 @@
 // CHECK_ADL_M32: #define __AVX__ 1
 // CHECK_ADL_M32: #define __BMI2__ 1
 // CHECK_ADL_M32: #define __BMI__ 1
-// CHECK_ADL_M32: #define __CLDEMOTE__ 1
+// CHECK_ADL_M32-NOT: #define __CLDEMOTE__ 1
 // CHECK_ADL_M32: #define __CLFLUSHOPT__ 1
 // CHECK_ADL_M32: #define __CLWB__ 1
 // CHECK_ADL_M32: #define __F16C__ 1
@@ -2173,7 +2173,7 @@
 // CHECK_ADL_M64: #define __AVX__ 1
 // CHECK_ADL_M64: #define __BMI2__ 1
 // CHECK_ADL_M64: #define __BMI__ 1
-// CHECK_ADL_M64: #define __CLDEMOTE__ 1
+// CHECK_ADL_M64-NOT: #define __CLDEMOTE__ 1
 // CHECK_ADL_M64: #define __CLFLUSHOPT__ 1
 // CHECK_ADL_M64: #define __CLWB__ 1
 // CHECK_ADL_M64: #define __F16C__ 1
diff --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 2d635835e3ff7..b09891652ad99 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -1284,7 +1284,6 @@ def ProcessorFeatures {
   FeatureAVXVNNI,
   FeaturePKU,
   FeatureHRESET,
-  FeatureCLDEMOTE,
   FeatureMOVDIRI,
   FeatureMOVDIR64B,
   FeatureWAITPKG];
@@ -1311,6 +1310,7 @@ def ProcessorFeatures {
   FeatureAVXNECONVERT,
   FeatureENQCMD,
   FeatureUINTR,
+  FeatureCLDEMOTE,
   FeatureAVXVNNIINT8];
   list SRFFeatures =
 !listconcat(ADLFeatures, SRFAdditionalFeatures);
diff --git a/llvm/lib/TargetParser/X86TargetParser.cpp 
b/llvm/lib/TargetParser/X86TargetParser.cpp
index 21d05ee389e64..4947b05cd0370 100644
--- a/llvm/lib/TargetParser/X86TargetParser.cpp
+++ b/llvm/lib/TargetParser/X86TargetParser.cpp
@@ -165,11 +165,11 @@ constexpr FeatureBitset FeaturesAlderlake =
 FeaturesTremont | FeatureADX | FeatureBMI | FeatureBMI2 | FeatureF16C |
 FeatureFMA | FeatureINVPCID | FeatureLZCNT | FeaturePCONFIG | FeaturePKU |
 FeatureSERIALIZE | FeatureSHSTK | FeatureVAES | FeatureVPCLMULQDQ |
-FeatureCLDEMOTE | FeatureMOVDIR64B | FeatureMOVDIRI | FeatureWAITPKG |
-FeatureAVXVNNI | FeatureHRESET | FeatureWIDEKL;
+FeatureMOVDIR64B | FeatureMOVDIRI | FeatureWAITPKG | FeatureAVXVNNI |
+FeatureHRESET | FeatureWIDEKL;
 constexpr FeatureBitset FeaturesSierraforest =
 FeaturesAlderlake | FeatureCMPCCXADD | FeatureAVXIFMA | FeatureUINTR |
-FeatureENQCMD | FeatureAVXNECONVERT | FeatureAVXVNNIINT8;
+FeatureCLDEMOTE | FeatureENQCMD | FeatureAVXNECONVERT | FeatureAVXVNNIINT8;
 constexpr FeatureBitset FeaturesArrowlakeS = FeaturesSierraforest |
 FeatureAVXVNNIINT16 | FeatureSHA512 | FeatureSM3 | FeatureSM4;
 constexpr FeatureBitset FeaturesPantherlake =

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


[clang] [llvm] [X86] Remove CLDEMOTE from Alderlake and later hybrid processors (PR #144662)

2025-06-18 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Phoebe Wang (phoebewang)


Changes

SDM doesn't list any hybrid processors in this feature. Besides, physical 
machine also reports not supported.

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


3 Files Affected:

- (modified) clang/test/Preprocessor/predefined-arch-macros.c (+2-2) 
- (modified) llvm/lib/Target/X86/X86.td (+1-1) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+3-3) 


``diff
diff --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 2d17891071aae..9dfeddbd4d5ac 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2102,7 +2102,7 @@
 // CHECK_ADL_M32: #define __AVX__ 1
 // CHECK_ADL_M32: #define __BMI2__ 1
 // CHECK_ADL_M32: #define __BMI__ 1
-// CHECK_ADL_M32: #define __CLDEMOTE__ 1
+// CHECK_ADL_M32-NOT: #define __CLDEMOTE__ 1
 // CHECK_ADL_M32: #define __CLFLUSHOPT__ 1
 // CHECK_ADL_M32: #define __CLWB__ 1
 // CHECK_ADL_M32: #define __F16C__ 1
@@ -2173,7 +2173,7 @@
 // CHECK_ADL_M64: #define __AVX__ 1
 // CHECK_ADL_M64: #define __BMI2__ 1
 // CHECK_ADL_M64: #define __BMI__ 1
-// CHECK_ADL_M64: #define __CLDEMOTE__ 1
+// CHECK_ADL_M64-NOT: #define __CLDEMOTE__ 1
 // CHECK_ADL_M64: #define __CLFLUSHOPT__ 1
 // CHECK_ADL_M64: #define __CLWB__ 1
 // CHECK_ADL_M64: #define __F16C__ 1
diff --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 2d635835e3ff7..b09891652ad99 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -1284,7 +1284,6 @@ def ProcessorFeatures {
   FeatureAVXVNNI,
   FeaturePKU,
   FeatureHRESET,
-  FeatureCLDEMOTE,
   FeatureMOVDIRI,
   FeatureMOVDIR64B,
   FeatureWAITPKG];
@@ -1311,6 +1310,7 @@ def ProcessorFeatures {
   FeatureAVXNECONVERT,
   FeatureENQCMD,
   FeatureUINTR,
+  FeatureCLDEMOTE,
   FeatureAVXVNNIINT8];
   list SRFFeatures =
 !listconcat(ADLFeatures, SRFAdditionalFeatures);
diff --git a/llvm/lib/TargetParser/X86TargetParser.cpp 
b/llvm/lib/TargetParser/X86TargetParser.cpp
index 21d05ee389e64..4947b05cd0370 100644
--- a/llvm/lib/TargetParser/X86TargetParser.cpp
+++ b/llvm/lib/TargetParser/X86TargetParser.cpp
@@ -165,11 +165,11 @@ constexpr FeatureBitset FeaturesAlderlake =
 FeaturesTremont | FeatureADX | FeatureBMI | FeatureBMI2 | FeatureF16C |
 FeatureFMA | FeatureINVPCID | FeatureLZCNT | FeaturePCONFIG | FeaturePKU |
 FeatureSERIALIZE | FeatureSHSTK | FeatureVAES | FeatureVPCLMULQDQ |
-FeatureCLDEMOTE | FeatureMOVDIR64B | FeatureMOVDIRI | FeatureWAITPKG |
-FeatureAVXVNNI | FeatureHRESET | FeatureWIDEKL;
+FeatureMOVDIR64B | FeatureMOVDIRI | FeatureWAITPKG | FeatureAVXVNNI |
+FeatureHRESET | FeatureWIDEKL;
 constexpr FeatureBitset FeaturesSierraforest =
 FeaturesAlderlake | FeatureCMPCCXADD | FeatureAVXIFMA | FeatureUINTR |
-FeatureENQCMD | FeatureAVXNECONVERT | FeatureAVXVNNIINT8;
+FeatureCLDEMOTE | FeatureENQCMD | FeatureAVXNECONVERT | FeatureAVXVNNIINT8;
 constexpr FeatureBitset FeaturesArrowlakeS = FeaturesSierraforest |
 FeatureAVXVNNIINT16 | FeatureSHA512 | FeatureSM3 | FeatureSM4;
 constexpr FeatureBitset FeaturesPantherlake =

``




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


[clang] [analyzer] Conversion to CheckerFamily: DynamicTypePropagation (PR #144735)

2025-06-18 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat created 
https://github.com/llvm/llvm-project/pull/144735

This commit converts the class DynamicTypePropagation to a very simple checker 
family, which has only one checker frontend -- but also supports enabling the 
backend ("modeling checker") without the frontend.

As a tangentially related change, this commit adds the backend of 
DynamicTypePropagation as a dependency of alpha.core.DynamicTypeChecker, in 
Checkers.td, because the header comment of DynamicTypeChecker.cpp claims that 
it depends on DynamicTypePropagation and a cursory reading of the source code 
seems to confirm this.

(The lack of this dependency relationship didn't cause problems, because 
'core.DynamicTypePropagation' is in the group 'core', so it is practically 
always active. However, explicitly declaring the dependency clarifies the fact 
that the separate existence of the modeling checker is warranted.)

From b52f4a65849ab4262f1ded6b48ed30eec0e9724d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Tue, 17 Jun 2025 15:56:54 +0200
Subject: [PATCH] [analyzer] Conversion to CheckerFamily:
 DynamicTypePropagation

This commit converts the class DynamicTypePropagation to a very simple
checker family, which has only one checker frontend -- but also supports
enabling the backend ("modeling checker") without the frontend.

As a tangentially related change, this commit adds the backend of
DynamicTypePropagation as a dependency of alpha.core.DynamicTypeChecker,
in Checkers.td, because the header comment of DynamicTypeChecker.cpp
claims that it depends on DynamicTypePropagation and a cursory reading
of the source code seems to confirm this.

(The lack of this dependency relationship didn't cause problems, because
'core.DynamicTypePropagation' is in the group 'core', so it is
practically always active. However, explicitly declaring the dependency
clarifies the fact that the separate existence of the modeling checker
is warranted.)
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td | 10 ++--
 .../Checkers/DynamicTypePropagation.cpp   | 51 +--
 2 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 2a96df80d1001..789a18ff11043 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -294,10 +294,12 @@ def TestAfterDivZeroChecker : Checker<"TestAfterDivZero">,
"Either the comparison is useless or there is division by zero.">,
   Documentation;
 
-def DynamicTypeChecker : Checker<"DynamicTypeChecker">,
-  HelpText<"Check for cases where the dynamic and the static type of an object 
"
-   "are unrelated.">,
-  Documentation;
+def DynamicTypeChecker
+: Checker<"DynamicTypeChecker">,
+  HelpText<"Check for cases where the dynamic and the static type of an "
+   "object are unrelated.">,
+  Dependencies<[DynamicTypePropagation]>,
+  Documentation;
 
 def StackAddrAsyncEscapeChecker : Checker<"StackAddressAsyncEscape">,
   HelpText<"Check that addresses to stack memory do not escape the function">,
diff --git a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
index 344be0b176c54..87fa233a94413 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -49,15 +49,19 @@ REGISTER_MAP_WITH_PROGRAMSTATE(MostSpecializedTypeArgsMap, 
SymbolRef,
const ObjCObjectPointerType *)
 
 namespace {
-class DynamicTypePropagation:
-public Checker< check::PreCall,
-check::PostCall,
-check::DeadSymbols,
-check::PostStmt,
-check::PostStmt,
-check::PreObjCMessage,
-check::PostObjCMessage > {
+class DynamicTypePropagation
+: public CheckerFamily,
+   check::PostStmt, check::PreObjCMessage,
+   check::PostObjCMessage> {
+public:
+  // This checker family implements only one frontend, but -- unlike a simple
+  // Checker -- its backend can be enabled (by the checker DynamicTypeChecker
+  // which depends on it) without enabling the frontend.
+  CheckerFrontendWithBugType ObjCGenericsChecker{
+  "Generics", categories::CoreFoundationObjectiveC};
 
+private:
   /// Return a better dynamic type if one can be derived from the cast.
   const ObjCObjectPointerType *getBetterObjCType(const Expr *CastE,
  CheckerContext &C) const;
@@ -66,13 +70,6 @@ class DynamicTypePropagation:
   ProgramStateRef &State,
   CheckerContext &C) const;
 
-  mutable std::unique_ptr Obj

[clang] [Clang] Fix the clang/test/PCH/ignored-pch.c test. (PR #144737)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ying Yi (MaggieYingYi)


Changes

Change the test to check the exit status of the 'ls' command line (instead of 
error message) since the error message is different when running 'ls' command 
on the different Host machine.

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


1 Files Affected:

- (modified) clang/test/PCH/ignored-pch.c (+27-31) 


``diff
diff --git a/clang/test/PCH/ignored-pch.c b/clang/test/PCH/ignored-pch.c
index 5b64582cba618..c6ef3fe74cee9 100644
--- a/clang/test/PCH/ignored-pch.c
+++ b/clang/test/PCH/ignored-pch.c
@@ -1,96 +1,96 @@
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: ls %t.pch
+// RUN: ls %t.ll
 
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
 // RUN: %clang %s -emit-ast -include-pch %t.pch -o %t.ll
-// RUN: ls %t.pch | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: ls %t.pch
+// RUN: ls %t.ll
 
 // Check that -ignore-pch causes -emit-pch and -include-pch options to be 
ignored.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -emit-ast %s -include-pch %t.pch -ignore-pch -o %t.ll
-// RUN: not ls %t.ll 2>&1 | FileCheck --check-prefix=CHECK-OBJ-ERROR %s
+// RUN: not ls %t.ll
 
 // Check that -ignore-pch works for multiple PCH related options.
 // Test with -building-pch-with-obj.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-building-pch-with-obj -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang 
-building-pch-with-obj -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fallow-pch-with-compiler-errors.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-fallow-pch-with-compiler-errors -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang 
-fallow-pch-with-compiler-errors -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fallow-pch-with-different-modules-cache-path.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-fallow-pch-with-different-modules-cache-path -o %t.pch
 // RUN: %clang -S -emit-llvm %s -ignore-pch -include-pch %t.pch -Xclang 
-fallow-pch-with-different-modules-cache-path -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-codegen.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-codegen 
-o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-codegen 
-o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH-ERROR %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-debuginfo.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-debuginfo 
-o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch 
-fpch-debuginfo -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fpch-instantiate-templates.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch 
-fpch-instantiate-templates -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch 
-fpch-instantiate-templates -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck --check-prefix=CHECK-PCH %s
-// RUN: ls %t.ll | FileCheck --check-prefix=CHECK-OBJ %s
+// RUN: not ls %t.pch
+// RUN: ls %t.ll
 
 // Test with -fno-pch-timestamp.
 // RUN: rm -rf %t.pch %t.ll
 // RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang 
-fno-pch-timestamp -o %t.pch
 // RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang 
-fno-pch-timestamp -o %t.ll
-// RUN: not ls %t.pch 2>&1 | FileCheck -

[clang] [Clang] Fix the clang/test/PCH/ignored-pch.c test. (PR #144737)

2025-06-18 Thread via cfe-commits

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

LGTM!

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


[clang] Reland: "[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). (#142409)" (PR #143614)

2025-06-18 Thread Ying Yi via cfe-commits

MaggieYingYi wrote:

I had created https://github.com/llvm/llvm-project/pull/144737 for code review.

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


[clang] [clang][NFCI] Use TargetInfo to determine device kernel calling convention (PR #144728)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Nick Sarnie (sarnex)


Changes

We should abstract this logic away to `TargetInfo`. See 
https://github.com/llvm/llvm-project/pull/137882 for more information.

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


6 Files Affected:

- (modified) clang/lib/CodeGen/CGCall.cpp (+2-11) 
- (modified) clang/lib/CodeGen/TargetInfo.cpp (+4-4) 
- (modified) clang/lib/CodeGen/TargetInfo.h (+2-2) 
- (modified) clang/lib/CodeGen/Targets/AMDGPU.cpp (+2-2) 
- (modified) clang/lib/CodeGen/Targets/NVPTX.cpp (+1-1) 
- (modified) clang/lib/CodeGen/Targets/SPIR.cpp (+2-2) 


``diff
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a06455d25b1ef..fd75de42515da 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -83,17 +83,8 @@ unsigned 
CodeGenTypes::ClangCallConvToLLVMCallConv(CallingConv CC) {
 return llvm::CallingConv::AArch64_SVE_VectorCall;
   case CC_SpirFunction:
 return llvm::CallingConv::SPIR_FUNC;
-  case CC_DeviceKernel: {
-if (CGM.getLangOpts().OpenCL)
-  return CGM.getTargetCodeGenInfo().getOpenCLKernelCallingConv();
-if (CGM.getTriple().isSPIROrSPIRV())
-  return llvm::CallingConv::SPIR_KERNEL;
-if (CGM.getTriple().isAMDGPU())
-  return llvm::CallingConv::AMDGPU_KERNEL;
-if (CGM.getTriple().isNVPTX())
-  return llvm::CallingConv::PTX_Kernel;
-llvm_unreachable("Unknown kernel calling convention");
-  }
+  case CC_DeviceKernel:
+return CGM.getTargetCodeGenInfo().getDeviceKernelCallingConv();
   case CC_PreserveMost:
 return llvm::CallingConv::PreserveMost;
   case CC_PreserveAll:
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index f3df92c44bb6b..bc771c45951b3 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -103,11 +103,11 @@ 
TargetCodeGenInfo::getDependentLibraryOption(llvm::StringRef Lib,
   Opt += Lib;
 }
 
-unsigned TargetCodeGenInfo::getOpenCLKernelCallingConv() const {
-  // OpenCL kernels are called via an explicit runtime API with arguments
-  // set with clSetKernelArg(), not as normal sub-functions.
+unsigned TargetCodeGenInfo::getDeviceKernelCallingConv() const {
+  // Device kernels are called via an explicit runtime API with arguments,
+  // such as set with clSetKernelArg() for OpenCL, not as normal sub-functions.
   // Return SPIR_KERNEL by default as the kernel calling convention to
-  // ensure the fingerprint is fixed such way that each OpenCL argument
+  // ensure the fingerprint is fixed such way that each kernel argument
   // gets one matching argument in the produced kernel function argument
   // list to enable feasible implementation of clSetKernelArg() with
   // aggregates etc. In case we would use the default C calling conv here,
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index 2783e222eb802..b4057d369f988 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -298,8 +298,8 @@ class TargetCodeGenInfo {
llvm::StringRef Value,
llvm::SmallString<32> &Opt) const {}
 
-  /// Get LLVM calling convention for OpenCL kernel.
-  virtual unsigned getOpenCLKernelCallingConv() const;
+  /// Get LLVM calling convention for device kernels.
+  virtual unsigned getDeviceKernelCallingConv() const;
 
   /// Get target specific null pointer.
   /// \param T is the LLVM type of the null pointer.
diff --git a/clang/lib/CodeGen/Targets/AMDGPU.cpp 
b/clang/lib/CodeGen/Targets/AMDGPU.cpp
index 8660373c3927f..47a552a7bf495 100644
--- a/clang/lib/CodeGen/Targets/AMDGPU.cpp
+++ b/clang/lib/CodeGen/Targets/AMDGPU.cpp
@@ -304,7 +304,7 @@ class AMDGPUTargetCodeGenInfo : public TargetCodeGenInfo {
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;
-  unsigned getOpenCLKernelCallingConv() const override;
+  unsigned getDeviceKernelCallingConv() const override;
 
   llvm::Constant *getNullPointer(const CodeGen::CodeGenModule &CGM,
   llvm::PointerType *T, QualType QT) const override;
@@ -431,7 +431,7 @@ void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 F->addFnAttr("amdgpu-ieee", "false");
 }
 
-unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
+unsigned AMDGPUTargetCodeGenInfo::getDeviceKernelCallingConv() const {
   return llvm::CallingConv::AMDGPU_KERNEL;
 }
 
diff --git a/clang/lib/CodeGen/Targets/NVPTX.cpp 
b/clang/lib/CodeGen/Targets/NVPTX.cpp
index ad802c9131de0..82bdfe2666b52 100644
--- a/clang/lib/CodeGen/Targets/NVPTX.cpp
+++ b/clang/lib/CodeGen/Targets/NVPTX.cpp
@@ -78,7 +78,7 @@ class NVPTXTargetCodeGenInfo : public TargetCodeGenInfo {
 return true;
   }
 
-  unsigned getOpenCLKernelCallingConv() const override {
+  unsigned getDeviceKernelCallingConv() const override {
 re

[clang] [clang-tools-extra] [llvm] [clang] Simplify device kernel attributes (PR #137882)

2025-06-18 Thread Nick Sarnie via cfe-commits


@@ -80,12 +80,19 @@ unsigned 
CodeGenTypes::ClangCallConvToLLVMCallConv(CallingConv CC) {
 return llvm::CallingConv::AArch64_VectorCall;
   case CC_AArch64SVEPCS:
 return llvm::CallingConv::AArch64_SVE_VectorCall;
-  case CC_AMDGPUKernelCall:
-return llvm::CallingConv::AMDGPU_KERNEL;
   case CC_SpirFunction:
 return llvm::CallingConv::SPIR_FUNC;
-  case CC_OpenCLKernel:
-return CGM.getTargetCodeGenInfo().getOpenCLKernelCallingConv();
+  case CC_DeviceKernel: {
+if (CGM.getLangOpts().OpenCL)
+  return CGM.getTargetCodeGenInfo().getOpenCLKernelCallingConv();
+if (CGM.getTriple().isSPIROrSPIRV())
+  return llvm::CallingConv::SPIR_KERNEL;
+if (CGM.getTriple().isAMDGPU())
+  return llvm::CallingConv::AMDGPU_KERNEL;
+if (CGM.getTriple().isNVPTX())
+  return llvm::CallingConv::PTX_Kernel;
+llvm_unreachable("Unknown kernel calling convention");
+  }

sarnex wrote:

https://github.com/llvm/llvm-project/pull/144728

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


[clang] [clang][NFCI] Use TargetInfo to determine device kernel calling convention (PR #144728)

2025-06-18 Thread Nick Sarnie via cfe-commits

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


[clang] [flang] [llvm] [flang][AArch64] Always link compiler-rt to flang after libgcc (PR #144710)

2025-06-18 Thread David Truby via cfe-commits

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


[clang] [flang] [llvm] [flang][AArch64] Always link compiler-rt to flang after libgcc (PR #144710)

2025-06-18 Thread Paul Osmialowski via cfe-commits


@@ -653,6 +653,13 @@ if(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD STREQUAL "all")
   set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${LLVM_ALL_EXPERIMENTAL_TARGETS})
 endif()
 
+if("flang" IN_LIST LLVM_ENABLE_PROJECTS AND 
+   "AArch64" IN_LIST LLVM_TARGETS_TO_BUILD AND
+   NOT "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+  message(STATUS "Enabling Flang-RT as a dependency of Flang")
+  list(APPEND LLVM_ENABLE_RUNTIMES "compiler-rt")

pawosm-arm wrote:

I wonder, if we need the builtins part of compiler-rt, shouldn't we enforce 
setting `COMPILER_RT_BUILD_BUILTINS` to `ON` here?

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


[clang] [clang][NFCI] Use TargetInfo to determine device kernel calling convention (PR #144728)

2025-06-18 Thread Nick Sarnie via cfe-commits

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


[clang] [llvm] [RISCV] Add Andes XAndesVBFHCvt (Andes Vector BFLOAT16 Conversion) extension (PR #144320)

2025-06-18 Thread Jim Lin via cfe-commits

tclin914 wrote:

> LLVM Buildbot has detected a new failure on builder `arc-builder` running on 
> `arc-worker` while building `clang,llvm` at step 6 
> "test-build-unified-tree-check-all".
> 
> Full details are available at: 
> https://lab.llvm.org/buildbot/#/builders/3/builds/17667
> 
> Here is the relevant piece of the build log for the reference

This failure might be related to 
https://github.com/llvm/llvm-project/issues/144639

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits


@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
-  uint64_t  getIP() const { return _registers.__pc; }
-  void  setIP(uint64_t value) { _registers.__pc = value; }
-  uint64_t  getFP() const { return _registers.__fp; }
-  void  setFP(uint64_t value) { _registers.__fp = value; }
+  uint64_t getIP() const {
+uint64_t value = _registers.__pc;
+#if __has_feature(ptrauth_calls)
+// Note the value of the PC was signed to its address in the register state
+// but everyone else expects it to be sign by the SP, so convert on return.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)_registers.__pc, ptrauth_key_return_address, &_registers.__pc,
+ptrauth_key_return_address, getSP());
+#endif
+return value;
+  }
+  void setIP(uint64_t value) {
+#if __has_feature(ptrauth_calls)
+// Note the value which was set should have been signed with the SP.
+// We then resign with the slot we are being stored in to so that both SP
+// and LR can't be spoofed at the same time.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)value, ptrauth_key_return_address, getSP(),
+ptrauth_key_return_address, &_registers.__pc);
+#endif
+_registers.__pc = value;
+  }
+  uint64_t getFP() const { return _registers.__fp; }
+  void setFP(uint64_t value) { _registers.__fp = value; }
+
+  typedef uint64_t reg_t;
+  typedef uint64_t
+  __LIBUNWIND_PTRAUTH_RI_PDC("Registers_arm64::link_reg_t") link_reg_t;
+  void
+  loadAndAuthenticateLinkRegister(reg_t inplaceAuthedLinkRegister,
+  link_reg_t *referenceAuthedLinkRegister) {

kovdan01 wrote:

OK, let's just stick with current approach as for now, thanks for explanation

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


[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-06-18 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,63 @@
+
+Query Based Custom Clang-Tidy Checks
+
+
+Introduction
+
+
+This page provides examples of how to add query based custom checks for
+:program:`clang-tidy`.
+
+Custom checks are based on :program:`clang-query` syntax. Every custom checks

vbvictor wrote:

Yeah, we could make an issue to track this after merging this PR

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


[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-18 Thread Mariya Podchishchaeva via cfe-commits


@@ -1590,25 +1590,70 @@ namespace {
   void EmitConditionalDtorDeleteCall(CodeGenFunction &CGF,

Fznamznon wrote:

Added a comment.

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


[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-18 Thread Mariya Podchishchaeva via cfe-commits


@@ -194,9 +217,31 @@ I::~I() { call_in_dtor(); }
 // CHECK-MSABI32-LABEL: define {{.*}} @"??_GI@@UAEPAXI@Z"(
 // CHECK-MSABI-NOT: call{{ }}
 // CHECK-MSABI: load i32
-// CHECK-MSABI: icmp eq i32 {{.*}}, 0
-// CHECK-MSABI: br i1
+// CHECK-MSABI-NEXT: and i32 %[[IMP_PARAM:.*]], 4
+// CHECK-MSABI-NEXT: icmp eq i32 {{.*}}, 0
+// CHECK-MSABI-NEXT: br i1 %[[CHCK]], label %dtor.entry_cont, label 
%dtor.call_dtor
+//
+// CHECK-MSABI: dtor.call_dtor:
+// CHECK-MSABI64-NEXT: call void @"??1I@@UEAA@XZ"({{.*}})
+// CHECK-MSABI32-NEXT: call x86_thiscallcc void @"??1I@@UAE@XZ"({{.*}})
+// CHECK-MSABI-NEXT: br label %dtor.entry_cont
+//
+// CHECK-MSABI: dtor.entry_cont:
+// CHECK-MSABI-NEXT: and i32 %[[IMP_PARAM]], 1
+// CHECK-MSABI-NEXT: icmp eq i32 %{{.*}}, 0
+// CHECK-MSABI-NEXT: br i1 %{{.*}}, label %dtor.continue, label 
%dtor.call_delete
+//
+// CHECK-MSABI: dtor.call_delete:
+// CHECK-MSABI-NEXT: %[[THIRDBIT1:.*]] = and i32 %[[IMP_PARAM]], 4
+// CHECK-MSABI-NEXT: %[[CHCK2:.*]] = icmp eq i32 %[[THIRDBIT1]], 0
+// CHECK-MSABI-NEXT: br i1 %[[CHCK2]], label %dtor.call_class_delete, label 
%dtor.call_glob_delete
+//
+// CHECK-MSABI-LABEL: dtor.call_glob_delete:
+// CHECK-MSABI64: call void @"??3@YAXPEAX_KW4align_val_t@std@@@Z"(ptr noundef 
%{{.*}}, i64 noundef 96, i64 noundef 32)
+// CHECK-MSABI32: call void @"??3@YAXPAXIW4align_val_t@std@@@Z"(ptr noundef 
%{{.*}}, i32 noundef 64, i32 noundef 32)
+// CHECK-MSABI-NEXT: br label %[[RETURN:.*]]
 //
+// CHECK_MSABI: dtor.call_class_delete:

Fznamznon wrote:

Added the test. I noticed though that MSVC always calls scalar deleting dtor 
even when class declares non-virtual destructor. clang doesn't even generate 
deleting destructors when class destructor is not virtual. I'm not yet sure 
which implications it has, need more experimenting. At least unlike the virtual 
case the wrong operator delete is not called.

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


[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Daniil Kovalev via cfe-commits

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


[clang] [llvm] [X86] Remove CLDEMOTE from Alderlake and later hybrid processors (PR #144662)

2025-06-18 Thread Evgenii Kudriashov via cfe-commits

https://github.com/e-kud approved this pull request.

LGTM. Thanks!

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


[clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-18 Thread Lei Huang via cfe-commits


@@ -2,12 +2,110 @@
 // RUN:   -target-cpu pwr10 %s -verify

lei137 wrote:

maybe we should move these to a different test file -> ppc-dmr-types.c

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


[clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-18 Thread Lei Huang via cfe-commits


@@ -0,0 +1,94 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN:  -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O3 -triple powerpc64-ibm-aix -target-cpu future \
+// RUN: -emit-llvm %s -o - | FileCheck %s

lei137 wrote:

do we need testing for aix 32bit?

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


[clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-18 Thread Lei Huang via cfe-commits

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


[clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-18 Thread Lei Huang via cfe-commits

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

In general this LGTM.
Just a few nits.  Please also update your descripton and PR title as it says 
you are dding `__dmr` type, but you are actually adding type `__dmr1024`.
Thx!

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


[clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-18 Thread Lei Huang via cfe-commits


@@ -3455,6 +3455,7 @@ static void encodeTypeForFunctionPointerAuth(const 
ASTContext &Ctx,
 case BuiltinType::BFloat16:
 case BuiltinType::VectorQuad:
 case BuiltinType::VectorPair:
+case BuiltinType::VectorDmr1024:

lei137 wrote:

nit: Maybe we can do this since DMR is an acronym and to match the actual new 
type name defined?
```suggestion
case BuiltinType::DMR1024:
```

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


[clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-18 Thread Lei Huang via cfe-commits


@@ -0,0 +1,184 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple powerpc64le-linux-unknown -target-cpu future \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-linux-unknown -target-cpu pwr10 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-linux-unknown -target-cpu pwr9 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-linux-unknown -target-cpu pwr8 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s

lei137 wrote:

Since DMR is future specific, do we need run lines on cpu targets that it won't 
be valid for?

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


[clang] [CIR] Add Minimal Destructor Definition Support (PR #144719)

2025-06-18 Thread Morris Hafner via cfe-commits

https://github.com/mmha created https://github.com/llvm/llvm-project/pull/144719

This patch upstreams support for writing inline and out of line C++ destructor 
definitions. Calling a destructor implcitly or explicitly is left for a future 
patch.

Because of that restriction complete destructors (D2 in Itanium mangling) do 
not call into the base (D1) destructors yet but simply behave like a base 
destructor. Deleting (D0) destructor support is not part of this patch.

Destructor aliases aren't supported, either. Because of this compilation with 
-mno-constructor-aliases may be required to avoid running into NYI errors.

>From 278750574dd72831347bbba144bd49ded9daaa3c Mon Sep 17 00:00:00 2001
From: Morris Hafner 
Date: Wed, 18 Jun 2025 15:09:21 +0100
Subject: [PATCH] [CIR] Add Minimal Destructor Definition Support

This patch upstreams support for writing inline and out of line C++ destructor 
definitions. Calling a destructor implcitly or explicitly is left for a future 
patch.

Because of that restriction complete destructors (D2 in Itanium mangling) do 
not call into the base (D1) destructors yet but simply behave like a base 
destructor. Deleting (D0) destructor support is not part of this patch.

Destructor aliases aren't supported, either. Because of this compilation with 
-mno-constructor-aliases may be required to avoid running into NYI errors.
---
 clang/include/clang/CIR/MissingFeatures.h |   4 +
 clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp|   7 ++
 clang/lib/CIR/CodeGen/CIRGenCXXABI.h  |  13 +++
 clang/lib/CIR/CodeGen/CIRGenFunction.cpp  | 100 +-
 clang/lib/CIR/CodeGen/CIRGenFunction.h|   1 +
 clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp |  31 --
 clang/lib/CIR/CodeGen/CIRGenModule.cpp|  29 -
 clang/lib/CIR/CodeGen/CIRGenModule.h  |   2 +-
 .../CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp |   3 +-
 clang/test/CIR/CodeGen/destructors.cpp|  50 +
 10 files changed, 230 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/CIR/CodeGen/destructors.cpp

diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3d120903dea19..174b1ccfd27f9 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -240,6 +240,10 @@ struct MissingFeatures {
   static bool builtinCall() { return false; }
   static bool builtinCallF128() { return false; }
   static bool builtinCallMathErrno() { return false; }
+  static bool appleKext() { return false; }
+  static bool dtorCleanups() { return false; }
+  static bool completeDtors() { return false; }
+  static bool vtableInitialization() { return false; }
 
   // Missing types
   static bool dataMemberType() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
index 6cf4e5c658fb6..33b812ac81f6e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
@@ -41,6 +41,13 @@ void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
   assert(!cir::MissingFeatures::cxxabiThisAlignment());
 }
 
+cir::GlobalLinkageKind CIRGenCXXABI::getCXXDestructorLinkage(
+GVALinkage linkage, const CXXDestructorDecl *dtor, CXXDtorType dt) const {
+  // Delegate back to cgm by default.
+  return cgm.getCIRLinkageForDeclarator(dtor, linkage,
+/*isConstantVariable=*/false);
+}
+
 mlir::Value CIRGenCXXABI::loadIncomingCXXThis(CIRGenFunction &cgf) {
   ImplicitParamDecl *vd = getThisDecl(cgf);
   Address addr = cgf.getAddrOfLocalVar(vd);
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
index 2d967fd307e01..eb079b877b7ff 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
@@ -72,6 +72,19 @@ class CIRGenCXXABI {
   /// Emit constructor variants required by this ABI.
   virtual void emitCXXConstructors(const clang::CXXConstructorDecl *d) = 0;
 
+  /// Emit dtor variants required by this ABI.
+  virtual void emitCXXDestructors(const clang::CXXDestructorDecl *d) = 0;
+
+  /// Returns true if the given destructor type should be emitted as a linkonce
+  /// delegating thunk, regardless of whether the dtor is defined in this TU or
+  /// not.
+  virtual bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
+  CXXDtorType dt) const = 0;
+
+  virtual cir::GlobalLinkageKind
+  getCXXDestructorLinkage(GVALinkage linkage, const CXXDestructorDecl *dtor,
+  CXXDtorType dt) const;
+
   /// Returns true if the given constructor or destructor is one of the kinds
   /// that the ABI says returns 'this' (only applies when called non-virtually
   /// for destructors).
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp 
b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
index fd413fe86383a..e7f91480cc0f7 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
+++ b/

[clang] [CIR] Add Minimal Destructor Definition Support (PR #144719)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Morris Hafner (mmha)


Changes

This patch upstreams support for writing inline and out of line C++ destructor 
definitions. Calling a destructor implcitly or explicitly is left for a future 
patch.

Because of that restriction complete destructors (D2 in Itanium mangling) do 
not call into the base (D1) destructors yet but simply behave like a base 
destructor. Deleting (D0) destructor support is not part of this patch.

Destructor aliases aren't supported, either. Because of this compilation with 
-mno-constructor-aliases may be required to avoid running into NYI errors.

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


10 Files Affected:

- (modified) clang/include/clang/CIR/MissingFeatures.h (+4) 
- (modified) clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp (+7) 
- (modified) clang/lib/CIR/CodeGen/CIRGenCXXABI.h (+13) 
- (modified) clang/lib/CIR/CodeGen/CIRGenFunction.cpp (+99-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenFunction.h (+1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp (+25-6) 
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+28-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.h (+1-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp (+2-1) 
- (added) clang/test/CIR/CodeGen/destructors.cpp (+50) 


``diff
diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3d120903dea19..174b1ccfd27f9 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -240,6 +240,10 @@ struct MissingFeatures {
   static bool builtinCall() { return false; }
   static bool builtinCallF128() { return false; }
   static bool builtinCallMathErrno() { return false; }
+  static bool appleKext() { return false; }
+  static bool dtorCleanups() { return false; }
+  static bool completeDtors() { return false; }
+  static bool vtableInitialization() { return false; }
 
   // Missing types
   static bool dataMemberType() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
index 6cf4e5c658fb6..33b812ac81f6e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.cpp
@@ -41,6 +41,13 @@ void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
   assert(!cir::MissingFeatures::cxxabiThisAlignment());
 }
 
+cir::GlobalLinkageKind CIRGenCXXABI::getCXXDestructorLinkage(
+GVALinkage linkage, const CXXDestructorDecl *dtor, CXXDtorType dt) const {
+  // Delegate back to cgm by default.
+  return cgm.getCIRLinkageForDeclarator(dtor, linkage,
+/*isConstantVariable=*/false);
+}
+
 mlir::Value CIRGenCXXABI::loadIncomingCXXThis(CIRGenFunction &cgf) {
   ImplicitParamDecl *vd = getThisDecl(cgf);
   Address addr = cgf.getAddrOfLocalVar(vd);
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
index 2d967fd307e01..eb079b877b7ff 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
@@ -72,6 +72,19 @@ class CIRGenCXXABI {
   /// Emit constructor variants required by this ABI.
   virtual void emitCXXConstructors(const clang::CXXConstructorDecl *d) = 0;
 
+  /// Emit dtor variants required by this ABI.
+  virtual void emitCXXDestructors(const clang::CXXDestructorDecl *d) = 0;
+
+  /// Returns true if the given destructor type should be emitted as a linkonce
+  /// delegating thunk, regardless of whether the dtor is defined in this TU or
+  /// not.
+  virtual bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
+  CXXDtorType dt) const = 0;
+
+  virtual cir::GlobalLinkageKind
+  getCXXDestructorLinkage(GVALinkage linkage, const CXXDestructorDecl *dtor,
+  CXXDtorType dt) const;
+
   /// Returns true if the given constructor or destructor is one of the kinds
   /// that the ABI says returns 'this' (only applies when called non-virtually
   /// for destructors).
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp 
b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
index fd413fe86383a..e7f91480cc0f7 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
@@ -463,7 +463,7 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl 
gd, cir::FuncOp fn,
 startFunction(gd, retTy, fn, funcType, args, loc, bodyRange.getBegin());
 
 if (isa(funcDecl))
-  getCIRGenModule().errorNYI(bodyRange, "C++ destructor definition");
+  emitDestructorBody(args);
 else if (isa(funcDecl))
   emitConstructorBody(args);
 else if (getLangOpts().CUDA && !getLangOpts().CUDAIsDevice &&
@@ -538,6 +538,104 @@ void CIRGenFunction::emitConstructorBody(FunctionArgList 
&args) {
   }
 }
 
+/// Emits the body of the current destructor.
+void CIRGenFunction::emitDestructorBody(FunctionArgList &args) {
+  const CXXDestructorDecl *dto

[clang] [Clang] Verify data layout consistency (PR #144720)

2025-06-18 Thread Nikita Popov via cfe-commits

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

Verify that the alignments specified by clang TargetInfo match the alignments 
specified by LLVM data layout, which will hopefully prevent accidental 
mismatches in the future.

This currently contains opt-outs for a lot of existing mismatches.

I'm also skipping the verification if options like `-malign-double` are used, 
or a language that mandates sizes/alignments that differ from C.

The verification happens in CodeGen, as we can't have an IR dependency in Basic.

>From c4082c425c8100913c0bf0334875d015f9bcfc9a Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 18 Jun 2025 14:48:19 +0200
Subject: [PATCH] [Clang] Verify data layout consistency

Verify that the alignments specified by clang TargetInfo match
the alignments specified by LLVM data layout, which will hopefully
prevent accidental mismatches in the future.

This currently contains opt-outs for a lot of existing mismatches.

I'm also skipping the verification if options like `-malign-double`
are used, or a language that mandates sizes/alignments that differ
from C.
---
 clang/lib/CodeGen/CodeGenModule.cpp | 73 +
 1 file changed, 73 insertions(+)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c27168e4c4bfe..aabc872e22df1 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -332,6 +332,76 @@ const TargetCodeGenInfo 
&CodeGenModule::getTargetCodeGenInfo() {
   return *TheTargetCodeGenInfo;
 }
 
+static void checkDataLayoutConsistency(const TargetInfo &Target,
+   llvm::LLVMContext &Context,
+   const LangOptions &Opts) {
+#ifndef NDEBUG
+  // Don't verify non-standard ABI configurations.
+  if (Opts.AlignDouble || Opts.OpenCL || Opts.HLSL)
+return;
+
+  llvm::Triple Triple = Target.getTriple();
+  llvm::DataLayout DL(Target.getDataLayoutString());
+  auto Check = [&](const char *Name, llvm::Type *Ty, unsigned Alignment) {
+llvm::Align DLAlign = DL.getABITypeAlign(Ty);
+llvm::Align ClangAlign(Alignment / 8);
+if (DLAlign != ClangAlign) {
+  llvm::errs() << "For target " << Triple.str() << " type " << Name
+   << " mapping to " << *Ty << " has data layout alignment "
+   << DLAlign.value() << " while clang specifies "
+   << ClangAlign.value() << "\n";
+  abort();
+}
+  };
+
+  Check("bool", llvm::Type::getIntNTy(Context, Target.BoolWidth),
+Target.BoolAlign);
+  Check("short", llvm::Type::getIntNTy(Context, Target.ShortWidth),
+Target.ShortAlign);
+  // FIXME: M68k specifies incorrect wrong int and long alignments in Clang
+  // and incorrect long long alignment in both LLVM and Clang.
+  if (Triple.getArch() != llvm::Triple::m68k) {
+Check("int", llvm::Type::getIntNTy(Context, Target.IntWidth),
+  Target.IntAlign);
+Check("long", llvm::Type::getIntNTy(Context, Target.LongWidth),
+  Target.LongAlign);
+Check("long long", llvm::Type::getIntNTy(Context, Target.LongLongWidth),
+  Target.LongLongAlign);
+  }
+  // FIXME: There are int128 alignment mismatches on multiple targets.
+  if (Target.hasInt128Type() && !Target.getTargetOpts().ForceEnableInt128 &&
+  !Triple.isAMDGPU() && !Triple.isSPIRV() &&
+  Triple.getArch() != llvm::Triple::ve)
+Check("__int128", llvm::Type::getIntNTy(Context, 128), Target.Int128Align);
+
+  if (Target.hasFloat16Type())
+Check("half", llvm::Type::getFloatingPointTy(Context, *Target.HalfFormat),
+  Target.HalfAlign);
+  if (Target.hasBFloat16Type())
+Check("bfloat", llvm::Type::getBFloatTy(Context), Target.BFloat16Align);
+  Check("float", llvm::Type::getFloatingPointTy(Context, *Target.FloatFormat),
+Target.FloatAlign);
+  // FIXME: AIX specifies wrong double alignment in DataLayout
+  if (!Triple.isOSAIX()) {
+Check("double",
+  llvm::Type::getFloatingPointTy(Context, *Target.DoubleFormat),
+  Target.DoubleAlign);
+Check("long double",
+  llvm::Type::getFloatingPointTy(Context, *Target.LongDoubleFormat),
+  Target.LongDoubleAlign);
+  }
+  // FIXME: Wasm has a mismatch in f128 alignment between Clang and LLVM.
+  if (Target.hasFloat128Type() && !Triple.isWasm())
+Check("__float128", llvm::Type::getFP128Ty(Context), Target.Float128Align);
+  if (Target.hasIbm128Type())
+Check("__ibm128", llvm::Type::getPPC_FP128Ty(Context), Target.Ibm128Align);
+
+  // FIXME: Clang specifies incorrect pointer alignment for m68k.
+  if (Triple.getArch() != llvm::Triple::m68k)
+Check("void*", llvm::PointerType::getUnqual(Context), Target.PointerAlign);
+#endif
+}
+
 CodeGenModule::CodeGenModule(ASTContext &C,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions &HSO,
@@ -458,6 +528,9 @@ CodeGenModule::

[clang] [Clang] Verify data layout consistency (PR #144720)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Nikita Popov (nikic)


Changes

Verify that the alignments specified by clang TargetInfo match the alignments 
specified by LLVM data layout, which will hopefully prevent accidental 
mismatches in the future.

This currently contains opt-outs for a lot of existing mismatches.

I'm also skipping the verification if options like `-malign-double` are used, 
or a language that mandates sizes/alignments that differ from C.

The verification happens in CodeGen, as we can't have an IR dependency in Basic.

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


1 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+73) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c27168e4c4bfe..aabc872e22df1 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -332,6 +332,76 @@ const TargetCodeGenInfo 
&CodeGenModule::getTargetCodeGenInfo() {
   return *TheTargetCodeGenInfo;
 }
 
+static void checkDataLayoutConsistency(const TargetInfo &Target,
+   llvm::LLVMContext &Context,
+   const LangOptions &Opts) {
+#ifndef NDEBUG
+  // Don't verify non-standard ABI configurations.
+  if (Opts.AlignDouble || Opts.OpenCL || Opts.HLSL)
+return;
+
+  llvm::Triple Triple = Target.getTriple();
+  llvm::DataLayout DL(Target.getDataLayoutString());
+  auto Check = [&](const char *Name, llvm::Type *Ty, unsigned Alignment) {
+llvm::Align DLAlign = DL.getABITypeAlign(Ty);
+llvm::Align ClangAlign(Alignment / 8);
+if (DLAlign != ClangAlign) {
+  llvm::errs() << "For target " << Triple.str() << " type " << Name
+   << " mapping to " << *Ty << " has data layout alignment "
+   << DLAlign.value() << " while clang specifies "
+   << ClangAlign.value() << "\n";
+  abort();
+}
+  };
+
+  Check("bool", llvm::Type::getIntNTy(Context, Target.BoolWidth),
+Target.BoolAlign);
+  Check("short", llvm::Type::getIntNTy(Context, Target.ShortWidth),
+Target.ShortAlign);
+  // FIXME: M68k specifies incorrect wrong int and long alignments in Clang
+  // and incorrect long long alignment in both LLVM and Clang.
+  if (Triple.getArch() != llvm::Triple::m68k) {
+Check("int", llvm::Type::getIntNTy(Context, Target.IntWidth),
+  Target.IntAlign);
+Check("long", llvm::Type::getIntNTy(Context, Target.LongWidth),
+  Target.LongAlign);
+Check("long long", llvm::Type::getIntNTy(Context, Target.LongLongWidth),
+  Target.LongLongAlign);
+  }
+  // FIXME: There are int128 alignment mismatches on multiple targets.
+  if (Target.hasInt128Type() && !Target.getTargetOpts().ForceEnableInt128 &&
+  !Triple.isAMDGPU() && !Triple.isSPIRV() &&
+  Triple.getArch() != llvm::Triple::ve)
+Check("__int128", llvm::Type::getIntNTy(Context, 128), Target.Int128Align);
+
+  if (Target.hasFloat16Type())
+Check("half", llvm::Type::getFloatingPointTy(Context, *Target.HalfFormat),
+  Target.HalfAlign);
+  if (Target.hasBFloat16Type())
+Check("bfloat", llvm::Type::getBFloatTy(Context), Target.BFloat16Align);
+  Check("float", llvm::Type::getFloatingPointTy(Context, *Target.FloatFormat),
+Target.FloatAlign);
+  // FIXME: AIX specifies wrong double alignment in DataLayout
+  if (!Triple.isOSAIX()) {
+Check("double",
+  llvm::Type::getFloatingPointTy(Context, *Target.DoubleFormat),
+  Target.DoubleAlign);
+Check("long double",
+  llvm::Type::getFloatingPointTy(Context, *Target.LongDoubleFormat),
+  Target.LongDoubleAlign);
+  }
+  // FIXME: Wasm has a mismatch in f128 alignment between Clang and LLVM.
+  if (Target.hasFloat128Type() && !Triple.isWasm())
+Check("__float128", llvm::Type::getFP128Ty(Context), Target.Float128Align);
+  if (Target.hasIbm128Type())
+Check("__ibm128", llvm::Type::getPPC_FP128Ty(Context), Target.Ibm128Align);
+
+  // FIXME: Clang specifies incorrect pointer alignment for m68k.
+  if (Triple.getArch() != llvm::Triple::m68k)
+Check("void*", llvm::PointerType::getUnqual(Context), Target.PointerAlign);
+#endif
+}
+
 CodeGenModule::CodeGenModule(ASTContext &C,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions &HSO,
@@ -458,6 +528,9 @@ CodeGenModule::CodeGenModule(ASTContext &C,
   if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
 getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters",
   CodeGenOpts.NumRegisterParameters);
+
+  if (!Context.getAuxTargetInfo())
+checkDataLayoutConsistency(Context.getTargetInfo(), LLVMContext, LangOpts);
 }
 
 CodeGenModule::~CodeGenModule() {}

``




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

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-18 Thread Aaron Ballman via cfe-commits


@@ -9102,6 +9102,15 @@ bool InitializationSequence::Diagnose(Sema &S,
 
   case FK_ConversionFailed: {
 QualType FromType = OnlyArg->getType();
+// __amdgpu_feature_predicate_t can be explicitly cast to the logical op
+// type, although this is almost always an error and we advise against it

AaronBallman wrote:

Thank you!

Wouldn't a cleaner design be: use the `__attribute__((target_clones))` 
attribute on a function declaration and call that function? e.g.,
```
// Original code:
void foo() {
  if (__builtin_amdgcn_processor_is("gfx900")) {
do_gfx900_stuff();
  }
}

// New code:
__attribute__((target_clones("gfx900")) inline void func() {
  do_gfx900_stuff();
}

__attribute__((target_clones("default")) inline void func() {
  do_fallback_stuff();
}

void foo() {
  func();
}
```
(If you can't tell, I'm still trying to find some way to accomplish what you 
need but without introducing a novel behavior for a builtin; I'm worried about 
the usability of the current design because the feature really only works if 
you hold it just right.)

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


[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-06-18 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/139566

>From 1b0b6242e5749e776f02581ba8600d853bfef322 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Mon, 12 May 2025 07:25:57 -0700
Subject: [PATCH 1/8] [win][clang] Align scalar deleting destructors with MSABI

While working on vector deleting destructors support (GH19772), I
noticed that MSVC produces different code in scalar deleting destructor
body depending on whether class defined its own operator delete.
In MSABI deleting destructors accept an additional implicit flag
parameter allowing some sort of flexibility. The mismatch I noticed is
that whenever a global operator delete is called, i.e. ::delete, in the
code produced by MSVC the implicit flag argument has a value that makes
the 3rd bit set, i.e. "5" for scalar deleting destructors "7" for vector
deleting destructors.
Prior to this patch, clang handled ::delete via calling global operator
delete direct after the destructor call and not calling class operator
delete in scalar deleting destructor body by passing "0" as implicit
flag argument value. This is fine until there is an attempt to link binaries
compiled with clang with binaries compiled with MSVC. The problem is that in
binaries produced by MSVC the callsite of the destructor won't call global
operator delete because it is assumed that the destructor will do that and a
destructor body generated by clang will never do.
This patch removes call to global operator delete from the callsite and
add additional check of the 3rd bit of the implicit parameter inside of
scalar deleting destructor body.
---
 clang/include/clang/AST/DeclCXX.h | 11 +++
 clang/include/clang/Sema/Sema.h   | 10 ++-
 clang/lib/CodeGen/CGClass.cpp | 77 +++
 clang/lib/CodeGen/MicrosoftCXXABI.cpp | 11 +--
 clang/lib/Sema/SemaDeclCXX.cpp| 15 
 clang/lib/Sema/SemaExprCXX.cpp| 19 +++--
 .../CodeGenCXX/cxx2a-destroying-delete.cpp| 59 --
 .../CodeGenCXX/microsoft-abi-structors.cpp| 44 ++-
 8 files changed, 202 insertions(+), 44 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index b7980137002aa..cc2832ea99d4a 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2855,6 +2855,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
   // FIXME: Don't allocate storage for these except in the first declaration
   // of a virtual destructor.
   FunctionDecl *OperatorDelete = nullptr;
+  FunctionDecl *OperatorGlobalDelete = nullptr;
   Expr *OperatorDeleteThisArg = nullptr;
 
   CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
@@ -2885,6 +2886,16 @@ class CXXDestructorDecl : public CXXMethodDecl {
 return getCanonicalDecl()->OperatorDelete;
   }
 
+  const FunctionDecl *getOperatorGlobalDelete() const {
+return getCanonicalDecl()->OperatorGlobalDelete;
+  }
+
+  void setOperatorGlobalDelete(FunctionDecl *OD) {
+auto *First = cast(getFirstDecl());
+if (OD && !First->OperatorGlobalDelete)
+  First->OperatorGlobalDelete = OD;
+  }
+
   Expr *getOperatorDeleteThisArg() const {
 return getCanonicalDecl()->OperatorDeleteThisArg;
   }
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6ea7ee281e14d..5f2ceebcd42e3 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -8495,10 +8495,12 @@ class Sema final : public SemaBase {
 bool Diagnose = true);
   FunctionDecl *FindUsualDeallocationFunction(SourceLocation StartLoc,
   ImplicitDeallocationParameters,
-  DeclarationName Name);
-  FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
-  CXXRecordDecl *RD,
-  bool Diagnose = true);
+  DeclarationName Name,
+  bool Diagnose = true);
+  FunctionDecl *
+  FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
+CXXRecordDecl *RD, bool Diagnose = 
true,
+bool LookForGlobal = false);
 
   /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
   /// @code ::delete ptr; @endcode
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index befbfc64a680c..360876244cad9 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1589,25 +1589,74 @@ namespace {
   void EmitConditionalDtorDeleteCall(CodeGenFunction &CGF,
  llvm::Value *ShouldDeleteCondition,
  bool ReturnAfterDelete) {
+  

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Anatoly Trosinenko via cfe-commits


@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
-  uint64_t  getIP() const { return _registers.__pc; }
-  void  setIP(uint64_t value) { _registers.__pc = value; }
-  uint64_t  getFP() const { return _registers.__fp; }
-  void  setFP(uint64_t value) { _registers.__fp = value; }
+  uint64_t getIP() const {
+uint64_t value = _registers.__pc;
+#if __has_feature(ptrauth_calls)
+// Note the value of the PC was signed to its address in the register state
+// but everyone else expects it to be sign by the SP, so convert on return.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)_registers.__pc, ptrauth_key_return_address, &_registers.__pc,
+ptrauth_key_return_address, getSP());
+#endif
+return value;
+  }
+  void setIP(uint64_t value) {
+#if __has_feature(ptrauth_calls)
+// Note the value which was set should have been signed with the SP.
+// We then resign with the slot we are being stored in to so that both SP
+// and LR can't be spoofed at the same time.
+value = (uint64_t)ptrauth_auth_and_resign(
+(void *)value, ptrauth_key_return_address, getSP(),
+ptrauth_key_return_address, &_registers.__pc);
+#endif
+_registers.__pc = value;
+  }
+  uint64_t getFP() const { return _registers.__fp; }
+  void setFP(uint64_t value) { _registers.__fp = value; }
+
+  typedef uint64_t reg_t;
+  typedef uint64_t
+  __LIBUNWIND_PTRAUTH_RI_PDC("Registers_arm64::link_reg_t") link_reg_t;
+  void
+  loadAndAuthenticateLinkRegister(reg_t inplaceAuthedLinkRegister,
+  link_reg_t *referenceAuthedLinkRegister) {
+#if __has_feature(ptrauth_calls)

atrosinenko wrote:

If I get it right, ptrauth_returns do not influence the ABI and ptrauth_calls 
do, thus it may be trivial to enable pac-ret in one's own build, but 
ptrauth_calls have to be consistently enabled for the whole runtime.

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


[clang] [CIR] Add support for __builtin_expect (PR #144726)

2025-06-18 Thread Sirui Mu via cfe-commits

https://github.com/Lancern created 
https://github.com/llvm/llvm-project/pull/144726

This patch adds support for the `__builtin_expect` and 
`__builtin_expect_with_probability` builtin functions.

>From 684994022716f10c83aadeaa8985d6842064bb9e Mon Sep 17 00:00:00 2001
From: Sirui Mu 
Date: Wed, 18 Jun 2025 23:25:10 +0800
Subject: [PATCH] [CIR] Add support for __builtin_expect

This patch adds support for the __builtin_expect and
__builtin_expect_with_probability builtin functions.
---
 clang/include/clang/CIR/Dialect/IR/CIROps.td  | 37 +++
 clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp   | 33 ++
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 14 +
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.h   | 10 +++
 clang/test/CIR/CodeGen/builtin-o1.cpp | 62 +++
 clang/test/CIR/CodeGen/builtin_call.cpp   | 16 +
 6 files changed, 172 insertions(+)
 create mode 100644 clang/test/CIR/CodeGen/builtin-o1.cpp

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 4655cebc82ee7..f98929d96c79c 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -2409,4 +2409,41 @@ def AssumeOp : CIR_Op<"assume"> {
   }];
 }
 
+//===--===//
+// Branch Probability Operations
+//===--===//
+
+def ExpectOp : CIR_Op<"expect",
+  [Pure, AllTypesMatch<["result", "val", "expected"]>]> {
+  let summary = "Tell the optimizer that two values are likely to be equal.";
+  let description = [{
+The `cir.expect` operation may take 2 or 3 arguments.
+
+When the argument `prob` is missing, this operation effectively models the
+`__builtin_expect` builtin function. It tells the optimizer that `val` and
+`expected` are likely to be equal.
+
+When the argumen `prob` is present, this operation effectively models the
+`__builtin_expect_with_probability` builtin function. It tells the
+optimizer that `val` and `expected` are equal to each other with a certain
+probability.
+
+`val` and `expected` must be integers and their types must match.
+
+The result of this operation is always equal to `val`.
+  }];
+
+  let arguments = (ins
+CIR_AnyFundamentalIntType:$val,
+CIR_AnyFundamentalIntType:$expected,
+OptionalAttr:$prob
+  );
+
+  let results = (outs CIR_AnyFundamentalIntType:$result);
+
+  let assemblyFormat = [{
+`(` $val`,` $expected (`,` $prob^)? `)` `:` type($val) attr-dict
+  }];
+}
+
 #endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index 83825f0835a1e..33f10ea05d2a3 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -91,6 +91,39 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, 
unsigned builtinID,
 builder.create(getLoc(e->getExprLoc()), argValue);
 return RValue::get(nullptr);
   }
+
+  case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability: {
+mlir::Value argValue = emitScalarExpr(e->getArg(0));
+mlir::Value expectedValue = emitScalarExpr(e->getArg(1));
+
+// Don't generate cir.expect on -O0 as the backend won't use it for
+// anything. Note, we still generate expectedValue because it could have
+// side effects.
+if (cgm.getCodeGenOpts().OptimizationLevel == 0)
+  return RValue::get(argValue);
+
+mlir::FloatAttr probAttr;
+if (builtinIDIfNoAsmLabel == Builtin::BI__builtin_expect_with_probability) 
{
+  llvm::APFloat probability(0.0);
+  const Expr *probArg = e->getArg(2);
+  bool evalSucceeded =
+  probArg->EvaluateAsFloat(probability, cgm.getASTContext());
+  assert(evalSucceeded &&
+ "probability should be able to evaluate as float");
+  (void)evalSucceeded;
+  bool loseInfo = false;
+  probability.convert(llvm::APFloat::IEEEdouble(),
+  llvm::RoundingMode::Dynamic, &loseInfo);
+  probAttr = 
mlir::FloatAttr::get(mlir::Float64Type::get(&getMLIRContext()),
+  probability);
+}
+
+auto result = builder.create(getLoc(e->getSourceRange()),
+argValue.getType(), argValue,
+expectedValue, probAttr);
+return RValue::get(result);
+  }
   }
 
   cgm.errorNYI(e->getSourceRange(), "unimplemented builtin call");
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index a96501ab2c384..9ca726e315baf 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -948,6 +948,19 @@ mlir::LogicalResult 
CIRToLLVMConstantOpLowering::matchAndRewrite(

[clang] [CIR] Add support for __builtin_expect (PR #144726)

2025-06-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Sirui Mu (Lancern)


Changes

This patch adds support for the `__builtin_expect` and 
`__builtin_expect_with_probability` builtin functions.

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


6 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+37) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+33) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+14) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+10) 
- (added) clang/test/CIR/CodeGen/builtin-o1.cpp (+62) 
- (modified) clang/test/CIR/CodeGen/builtin_call.cpp (+16) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 4655cebc82ee7..f98929d96c79c 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -2409,4 +2409,41 @@ def AssumeOp : CIR_Op<"assume"> {
   }];
 }
 
+//===--===//
+// Branch Probability Operations
+//===--===//
+
+def ExpectOp : CIR_Op<"expect",
+  [Pure, AllTypesMatch<["result", "val", "expected"]>]> {
+  let summary = "Tell the optimizer that two values are likely to be equal.";
+  let description = [{
+The `cir.expect` operation may take 2 or 3 arguments.
+
+When the argument `prob` is missing, this operation effectively models the
+`__builtin_expect` builtin function. It tells the optimizer that `val` and
+`expected` are likely to be equal.
+
+When the argumen `prob` is present, this operation effectively models the
+`__builtin_expect_with_probability` builtin function. It tells the
+optimizer that `val` and `expected` are equal to each other with a certain
+probability.
+
+`val` and `expected` must be integers and their types must match.
+
+The result of this operation is always equal to `val`.
+  }];
+
+  let arguments = (ins
+CIR_AnyFundamentalIntType:$val,
+CIR_AnyFundamentalIntType:$expected,
+OptionalAttr:$prob
+  );
+
+  let results = (outs CIR_AnyFundamentalIntType:$result);
+
+  let assemblyFormat = [{
+`(` $val`,` $expected (`,` $prob^)? `)` `:` type($val) attr-dict
+  }];
+}
+
 #endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index 83825f0835a1e..33f10ea05d2a3 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -91,6 +91,39 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, 
unsigned builtinID,
 builder.create(getLoc(e->getExprLoc()), argValue);
 return RValue::get(nullptr);
   }
+
+  case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability: {
+mlir::Value argValue = emitScalarExpr(e->getArg(0));
+mlir::Value expectedValue = emitScalarExpr(e->getArg(1));
+
+// Don't generate cir.expect on -O0 as the backend won't use it for
+// anything. Note, we still generate expectedValue because it could have
+// side effects.
+if (cgm.getCodeGenOpts().OptimizationLevel == 0)
+  return RValue::get(argValue);
+
+mlir::FloatAttr probAttr;
+if (builtinIDIfNoAsmLabel == Builtin::BI__builtin_expect_with_probability) 
{
+  llvm::APFloat probability(0.0);
+  const Expr *probArg = e->getArg(2);
+  bool evalSucceeded =
+  probArg->EvaluateAsFloat(probability, cgm.getASTContext());
+  assert(evalSucceeded &&
+ "probability should be able to evaluate as float");
+  (void)evalSucceeded;
+  bool loseInfo = false;
+  probability.convert(llvm::APFloat::IEEEdouble(),
+  llvm::RoundingMode::Dynamic, &loseInfo);
+  probAttr = 
mlir::FloatAttr::get(mlir::Float64Type::get(&getMLIRContext()),
+  probability);
+}
+
+auto result = builder.create(getLoc(e->getSourceRange()),
+argValue.getType(), argValue,
+expectedValue, probAttr);
+return RValue::get(result);
+  }
   }
 
   cgm.errorNYI(e->getSourceRange(), "unimplemented builtin call");
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index a96501ab2c384..9ca726e315baf 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -948,6 +948,19 @@ mlir::LogicalResult 
CIRToLLVMConstantOpLowering::matchAndRewrite(
   return mlir::success();
 }
 
+mlir::LogicalResult CIRToLLVMExpectOpLowering::matchAndRewrite(
+cir::ExpectOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+  std::optional prob = op.getProb();
+  if (prob)
+rewriter.replaceO

[clang] 3af4d4e - [HLSL][SPIR-V] Fix LinkageAttribute emission for BuiltIn (#144701)

2025-06-18 Thread via cfe-commits

Author: Nathan Gauër
Date: 2025-06-18T17:26:40+02:00
New Revision: 3af4d4e8100fda2a7e1bd0dbbe0914b584ad08d6

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

LOG: [HLSL][SPIR-V] Fix LinkageAttribute emission for BuiltIn (#144701)

BuiltIn variables were missing the visibility attribute, which caused
the Linkage capability to be emitted by the backend.

Added: 
llvm/test/CodeGen/SPIRV/linkage/link-attribute-vk.ll

Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 585411bc59e16..34960c34e109f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -375,6 +375,7 @@ static llvm::Value *createSPIRVBuiltinLoad(IRBuilder<> &B, 
llvm::Module &M,
   llvm::GlobalVariable::GeneralDynamicTLSModel,
   /* AddressSpace */ 7, /* isExternallyInitialized= */ true);
   addSPIRVBuiltinDecoration(GV, BuiltInID);
+  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
   return B.CreateLoad(Ty, GV);
 }
 

diff  --git a/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl 
b/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl
index 58b91fc9264dd..bdba38e028edd 100644
--- a/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-pixel -x hlsl -emit-llvm 
-finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s
 
-// CHECK: @sv_position = external thread_local addrspace(7) 
externally_initialized constant <4 x float>, !spirv.Decorations !0
+// CHECK: @sv_position = external hidden thread_local addrspace(7) 
externally_initialized constant <4 x float>, !spirv.Decorations !0
 
 // CHECK: define void @main() {{.*}} {
 float4 main(float4 p : SV_Position) {

diff  --git a/llvm/test/CodeGen/SPIRV/linkage/link-attribute-vk.ll 
b/llvm/test/CodeGen/SPIRV/linkage/link-attribute-vk.ll
new file mode 100644
index 0..d4ba61ff58d32
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/linkage/link-attribute-vk.ll
@@ -0,0 +1,23 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-vulkan1.3-pixel %s 
-o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan1.3-pixel %s -o 
- -filetype=obj | spirv-val --target-env vulkan1.3 %}
+
+@sv_position = external hidden thread_local local_unnamed_addr addrspace(7) 
externally_initialized constant <4 x float>, !spirv.Decorations !0
+
+; CHECK-NOT: OpDecorate %[[#var]] LinkageAttributes "sv_position" Import
+
+; CHECK-DAG: %[[#float:]] = OpTypeFloat 32
+; CHECK-DAG: %[[#float4:]] = OpTypeVector %[[#float]]
+; CHECK-DAG: %[[#type:]] = OpTypePointer Input %[[#float4]]
+; CHECK-DAG: %[[#var:]] = OpVariable %[[#type]] Input
+
+; CHECK-NOT: OpDecorate %[[#var]] LinkageAttributes "sv_position" Import
+
+define void @main() #1 {
+entry:
+  ret void
+}
+
+attributes #1 = { "hlsl.shader"="pixel" }
+
+!0 = !{!1}
+!1 = !{i32 11, i32 0}



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


[clang] [llvm] [HLSL][SPIR-V] Fix LinkageAttribute emission for BuiltIn (PR #144701)

2025-06-18 Thread Nathan Gauër via cfe-commits

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


  1   2   3   4   >