[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread via cfe-commits

https://github.com/charan-003 updated 
https://github.com/llvm/llvm-project/pull/117953



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread via cfe-commits

https://github.com/charan-003 updated 
https://github.com/llvm/llvm-project/pull/117953



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [Cygwin] Global symbols should be external by default (PR #139797)

2025-05-13 Thread Tomohiro Kashiwada via cfe-commits

https://github.com/kikairoya created 
https://github.com/llvm/llvm-project/pull/139797

Behaves as same as both of Clang and GCC targetting MinGW. Required for 
compatibility for Cygwin-GCC.

Divided from https://github.com/llvm/llvm-project/pull/138773


>From 8bb0b61112d68f6cecbc15411f5080c413a494a3 Mon Sep 17 00:00:00 2001
From: kikairoya 
Date: Sat, 19 Apr 2025 16:06:37 +0900
Subject: [PATCH] [Cygwin] Global symbols should be external by default

Behaves as same as both of Clang and GCC targetting MinGW.
Required for compatibility for Cygwin-GCC.
---
 clang/lib/CodeGen/CodeGenModule.cpp   |   2 +-
 clang/test/CodeGen/dllexport.c|   2 +
 clang/test/CodeGen/dllimport.c|   3 +
 clang/test/CodeGen/dso-local-executable.c |   3 +
 clang/test/CodeGenCXX/dllexport.cpp   |  30 -
 clang/test/CodeGenCXX/dllimport-members.cpp   | 104 +-
 clang/test/CodeGenCXX/dllimport.cpp   |  30 -
 .../test/CodeGenCXX/dso-local-executable.cpp  |   1 +
 8 files changed, 164 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 50041f883cfe5..16e010adbeb5f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1689,7 +1689,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
 
   const llvm::Triple &TT = CGM.getTriple();
   const auto &CGOpts = CGM.getCodeGenOpts();
-  if (TT.isWindowsGNUEnvironment()) {
+  if (TT.isOSCygMing()) {
 // In MinGW, variables without DLLImport can still be automatically
 // imported from a DLL by the linker; don't mark variables that
 // potentially could come from another DLL as DSO local.
diff --git a/clang/test/CodeGen/dllexport.c b/clang/test/CodeGen/dllexport.c
index 4c1143cf5ca48..f64bcb5393005 100644
--- a/clang/test/CodeGen/dllexport.c
+++ b/clang/test/CodeGen/dllexport.c
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 
 
 
diff --git a/clang/test/CodeGen/dllimport.c b/clang/test/CodeGen/dllimport.c
index 6170c8c4a66a3..1631c6dc56805 100644
--- a/clang/test/CodeGen/dllimport.c
+++ b/clang/test/CodeGen/dllimport.c
@@ -2,8 +2,11 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
 // RUN: %clang_cc1 -triple i686-windows-msvc   -fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=MO1 %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=GO1 %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=GO1 %s
 
 #define JOIN2(x, y) x##y
 #define JOIN(x, y) JOIN2(x, y)
diff --git a/clang/test/CodeGen/dso-local-executable.c 
b/clang/test/CodeGen/dso-local-executable.c
index 15575d3927f23..880273df137d7 100644
--- a/clang/test/CodeGen/dso-local-executable.c
+++ b/clang/test/CodeGen/dso-local-executable.c
@@ -12,6 +12,9 @@
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-AUTO-IMPORT %s
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - 
-fno-auto-import | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-NO-AUTO-IMPORT %s
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - 
-femulated-tls | FileCheck 
--check-prefixes=MINGW,MINGW-EMUTLS,MINGW-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - 
-fno-auto-import | FileCheck 
--check-prefixes=MINGW,

[clang] [Cygwin] Global symbols should be external by default (PR #139797)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Tomohiro Kashiwada (kikairoya)


Changes

Behaves as same as both of Clang and GCC targetting MinGW. Required for 
compatibility for Cygwin-GCC.

Divided from https://github.com/llvm/llvm-project/pull/138773


---

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


8 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) 
- (modified) clang/test/CodeGen/dllexport.c (+2) 
- (modified) clang/test/CodeGen/dllimport.c (+3) 
- (modified) clang/test/CodeGen/dso-local-executable.c (+3) 
- (modified) clang/test/CodeGenCXX/dllexport.cpp (+27-3) 
- (modified) clang/test/CodeGenCXX/dllimport-members.cpp (+101-3) 
- (modified) clang/test/CodeGenCXX/dllimport.cpp (+26-4) 
- (modified) clang/test/CodeGenCXX/dso-local-executable.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 50041f883cfe5..16e010adbeb5f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1689,7 +1689,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
 
   const llvm::Triple &TT = CGM.getTriple();
   const auto &CGOpts = CGM.getCodeGenOpts();
-  if (TT.isWindowsGNUEnvironment()) {
+  if (TT.isOSCygMing()) {
 // In MinGW, variables without DLLImport can still be automatically
 // imported from a DLL by the linker; don't mark variables that
 // potentially could come from another DLL as DSO local.
diff --git a/clang/test/CodeGen/dllexport.c b/clang/test/CodeGen/dllexport.c
index 4c1143cf5ca48..f64bcb5393005 100644
--- a/clang/test/CodeGen/dllexport.c
+++ b/clang/test/CodeGen/dllexport.c
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 
 
 
diff --git a/clang/test/CodeGen/dllimport.c b/clang/test/CodeGen/dllimport.c
index 6170c8c4a66a3..1631c6dc56805 100644
--- a/clang/test/CodeGen/dllimport.c
+++ b/clang/test/CodeGen/dllimport.c
@@ -2,8 +2,11 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
 // RUN: %clang_cc1 -triple i686-windows-msvc   -fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=MO1 %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=GO1 %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=GO1 %s
 
 #define JOIN2(x, y) x##y
 #define JOIN(x, y) JOIN2(x, y)
diff --git a/clang/test/CodeGen/dso-local-executable.c 
b/clang/test/CodeGen/dso-local-executable.c
index 15575d3927f23..880273df137d7 100644
--- a/clang/test/CodeGen/dso-local-executable.c
+++ b/clang/test/CodeGen/dso-local-executable.c
@@ -12,6 +12,9 @@
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-AUTO-IMPORT %s
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - 
-fno-auto-import | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-NO-AUTO-IMPORT %s
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - 
-femulated-tls | FileCheck 
--check-prefixes=MINGW,MINGW-EMUTLS,MINGW-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - 
-fno-auto-import | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-NO-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - 
-femulated-tls | FileCheck 
--check-prefixes=MINGW,MINGW-EMUTLS,MINGW-A

[clang] [Cygwin] Global symbols should be external by default (PR #139797)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Tomohiro Kashiwada (kikairoya)


Changes

Behaves as same as both of Clang and GCC targetting MinGW. Required for 
compatibility for Cygwin-GCC.

Divided from https://github.com/llvm/llvm-project/pull/138773


---

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


8 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) 
- (modified) clang/test/CodeGen/dllexport.c (+2) 
- (modified) clang/test/CodeGen/dllimport.c (+3) 
- (modified) clang/test/CodeGen/dso-local-executable.c (+3) 
- (modified) clang/test/CodeGenCXX/dllexport.cpp (+27-3) 
- (modified) clang/test/CodeGenCXX/dllimport-members.cpp (+101-3) 
- (modified) clang/test/CodeGenCXX/dllimport.cpp (+26-4) 
- (modified) clang/test/CodeGenCXX/dso-local-executable.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 50041f883cfe5..16e010adbeb5f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1689,7 +1689,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
 
   const llvm::Triple &TT = CGM.getTriple();
   const auto &CGOpts = CGM.getCodeGenOpts();
-  if (TT.isWindowsGNUEnvironment()) {
+  if (TT.isOSCygMing()) {
 // In MinGW, variables without DLLImport can still be automatically
 // imported from a DLL by the linker; don't mark variables that
 // potentially could come from another DLL as DSO local.
diff --git a/clang/test/CodeGen/dllexport.c b/clang/test/CodeGen/dllexport.c
index 4c1143cf5ca48..f64bcb5393005 100644
--- a/clang/test/CodeGen/dllexport.c
+++ b/clang/test/CodeGen/dllexport.c
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck %s
 
 
 
diff --git a/clang/test/CodeGen/dllimport.c b/clang/test/CodeGen/dllimport.c
index 6170c8c4a66a3..1631c6dc56805 100644
--- a/clang/test/CodeGen/dllimport.c
+++ b/clang/test/CodeGen/dllimport.c
@@ -2,8 +2,11 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin-fms-extensions -emit-llvm 
-std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
 // RUN: %clang_cc1 -triple i686-windows-msvc   -fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=MO1 %s
 // RUN: %clang_cc1 -triple i686-windows-gnu-fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=GO1 %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin  -fms-extensions -emit-llvm 
-std=c11 -O1 -fno-inline -o - %s | FileCheck --check-prefix=O1 
--check-prefix=GO1 %s
 
 #define JOIN2(x, y) x##y
 #define JOIN(x, y) JOIN2(x, y)
diff --git a/clang/test/CodeGen/dso-local-executable.c 
b/clang/test/CodeGen/dso-local-executable.c
index 15575d3927f23..880273df137d7 100644
--- a/clang/test/CodeGen/dso-local-executable.c
+++ b/clang/test/CodeGen/dso-local-executable.c
@@ -12,6 +12,9 @@
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-AUTO-IMPORT %s
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - 
-fno-auto-import | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-NO-AUTO-IMPORT %s
 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - 
-femulated-tls | FileCheck 
--check-prefixes=MINGW,MINGW-EMUTLS,MINGW-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - 
-fno-auto-import | FileCheck 
--check-prefixes=MINGW,MINGW-NATIVE_TLS,MINGW-NO-AUTO-IMPORT %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm %s -o - 
-femulated-tls | FileCheck 
--check-prefixes=MINGW,MINGW-EMUTLS,MINGW-AUTO-IMPO

[clang] [Cygwin] RTTI and VTable should be dllexport-ed (PR #139798)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Tomohiro Kashiwada (kikairoya)


Changes

Behaves as same as both of Clang and GCC targetting MinGW. Required for 
compatibility for Cygwin-GCC.

Divided from https://github.com/llvm/llvm-project/pull/138773


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


8 Files Affected:

- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+2-5) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/dllexport-missing-key.cpp (+1) 
- (modified) clang/test/CodeGenCXX/dllimport-missing-key.cpp (+1) 
- (modified) clang/test/CodeGenCXX/dllimport-rtti.cpp (+5-2) 
- (modified) clang/test/CodeGenCXX/rtti-mingw64.cpp (+2) 
- (modified) clang/test/CodeGenCXX/virt-dtor-key.cpp (+6-2) 
- (modified) clang/test/CodeGenCXX/vtable-key-function-ios.cpp (+2) 


``diff
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 70b53be7e77a3..8826085c596da 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3754,7 +3754,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule 
&CGM,
 bool IsDLLImport = RD->hasAttr();
 
 // Don't import the RTTI but emit it locally.
-if (CGM.getTriple().isWindowsGNUEnvironment())
+if (CGM.getTriple().isOSCygMing())
   return false;
 
 if (CGM.getVTables().isVTableExternal(RD)) {
@@ -4041,10 +4041,7 @@ static llvm::GlobalVariable::LinkageTypes 
getTypeInfoLinkage(CodeGenModule &CGM,
   return llvm::GlobalValue::ExternalLinkage;
   // MinGW always uses LinkOnceODRLinkage for type info.
   if (RD->isDynamicClass() &&
-  !CGM.getContext()
-   .getTargetInfo()
-   .getTriple()
-   .isWindowsGNUEnvironment())
+  !CGM.getContext().getTargetInfo().getTriple().isOSCygMing())
 return CGM.getVTableLinkage(RD);
 }
 
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index cbccb567e2adf..aee77c5ada0ba 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6274,7 +6274,7 @@ static void ReferenceDllExportedMembers(Sema &S, 
CXXRecordDecl *Class) {
 }
   } MarkingDllexportedContext(S, Class, ClassAttr->getLocation());
 
-  if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
+  if (S.Context.getTargetInfo().getTriple().isOSCygMing())
 S.MarkVTableUsed(Class->getLocation(), Class, true);
 
   for (Decl *Member : Class->decls()) {
diff --git a/clang/test/CodeGenCXX/dllexport-missing-key.cpp 
b/clang/test/CodeGenCXX/dllexport-missing-key.cpp
index 90e736f6fad3a..505679f315331 100644
--- a/clang/test/CodeGenCXX/dllexport-missing-key.cpp
+++ b/clang/test/CodeGenCXX/dllexport-missing-key.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | 
FileCheck --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm -std=c++11 -o - %s | 
FileCheck --check-prefix=GNU %s
 
 class __declspec(dllexport) QAbstractLayoutStyleInfo {
 public:
diff --git a/clang/test/CodeGenCXX/dllimport-missing-key.cpp 
b/clang/test/CodeGenCXX/dllimport-missing-key.cpp
index d8ef7aa7ea680..9eb9e7b5bbb0d 100644
--- a/clang/test/CodeGenCXX/dllimport-missing-key.cpp
+++ b/clang/test/CodeGenCXX/dllimport-missing-key.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -O0 -o - %s 
-w | FileCheck --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple i686-pc-cygwin   -emit-llvm -std=c++1y -O0 -o - %s 
-w | FileCheck --check-prefix=GNU %s
 
 class __declspec(dllimport) QObjectData {
 public:
diff --git a/clang/test/CodeGenCXX/dllimport-rtti.cpp 
b/clang/test/CodeGenCXX/dllimport-rtti.cpp
index f23a242c4bedc..046bf5020398d 100644
--- a/clang/test/CodeGenCXX/dllimport-rtti.cpp
+++ b/clang/test/CodeGenCXX/dllimport-rtti.cpp
@@ -1,5 +1,8 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y 
-fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefix=MSVC
-// RUN: %clang_cc1 -triple i686-windows-gnu  -emit-llvm -std=c++1y 
-fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefix=GNU
+// RUN: %clang_cc1 -triple i686-windows-msvc  -emit-llvm -std=c++1y 
-fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefix=MSVC
+// RUN: %clang_cc1 -triple i686-windows-gnu   -emit-llvm -std=c++1y 
-fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefix=GNU
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++1y 
-fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefix=GNU
+// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm -std=c++1y 
-fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefix=GNU
+// RUN: %clang_cc1 -triple x86_64-pc-cygwin   -emit-llvm -std=c++1y 
-fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefix=GNU

[clang] [Cygwin] RTTI and VTable should be dllexport-ed (PR #139798)

2025-05-13 Thread Tomohiro Kashiwada via cfe-commits

https://github.com/kikairoya created 
https://github.com/llvm/llvm-project/pull/139798

Behaves as same as both of Clang and GCC targetting MinGW. Required for 
compatibility for Cygwin-GCC.

Divided from https://github.com/llvm/llvm-project/pull/138773




  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ashley Coleman (V-FEXrt)


Changes

Partial implementation of https://github.com/llvm/wg-hlsl/issues/264

Adds several overloads to various intrinsic functions used by MiniEngine

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


5 Files Affected:

- (modified) clang/lib/Headers/hlsl/hlsl_compat_overloads.h (+59-45) 
- (modified) clang/test/CodeGenHLSL/builtins/clamp-overloads.hlsl (+6) 
- (added) clang/test/CodeGenHLSL/builtins/dot-overloads.hlsl (+29) 
- (modified) clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl (+38) 
- (modified) clang/test/CodeGenHLSL/builtins/pow-overloads.hlsl (+13) 


``diff
diff --git a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h 
b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
index 4874206d349c0..a2f8f658b292e 100644
--- a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
+++ b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
@@ -158,6 +158,42 @@ namespace hlsl {
 return fn((float4)V1, (float4)V2, (float4)V3); 
\
   }
 
+#define _DXC_COMPAT_BINARY_VECTOR_SCALAR_OVERLOADS(fn) 
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, T V2) { 
\
+return fn(V1, (vector)V2);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  T V1, vector V2) { 
\
+return fn((vector)V1, V2);   
\
+  }
+
+#define _DXC_COMPAT_TERNARY_VECTOR_SCALAR_OVERLOADS(fn)
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  T V1, vector V2, vector V3) {
\
+return fn((vector)V1, V2, V3);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, T V2, vector V3) {
\
+return fn(V1, (vector)V2, V3);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, vector V2, T V3) {
\
+return fn(V1, V2, (vector)V3);   
\
+  }
+
+#define _DXC_COMPAT_TERNARY_SINGLE_VECTOR_SCALAR_OVERLOADS(fn) 
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, T V2, T V3) {   
\
+return fn(V1, (vector)V2, (vector)V3); 
\
+  }
+
 
//===--===//
 // acos builtins overloads
 
//===--===//
@@ -197,23 +233,8 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(ceil)
 // clamp builtins overloads
 
//===--===//
 
-template 
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector>
-clamp(vector p0, vector p1, T p2) {
-  return clamp(p0, p1, (vector)p2);
-}
-
-template 
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector>
-clamp(vector p0, T p1, vector p2) {
-  return clamp(p0, (vector)p1, p2);
-}
-
-template 
-constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector>
-clamp(vector p0, T p1, T p2) {
-  return clamp(p0, (vector)p1, (vector)p2);
-}
+_DXC_COMPAT_TERNARY_VECTOR_SCALAR_OVERLOADS(clamp)
+_DXC_COMPAT_TERNARY_SINGLE_VECTOR_SCALAR_OVERLOADS(clamp)
 
 
//===--===//
 // cos builtins overloads
@@ -236,6 +257,22 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(cosh)
 _DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(degrees)
 _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(degrees)
 
+//===--===//
+// dot builtins overloads
+//===--===//
+
+template 
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), T> dot(vector V1,
+  T V2) {
+  return dot(V1, (vector)V2);
+}
+
+template 
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), T> dot(T V1,
+   

[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread Ashley Coleman via cfe-commits

https://github.com/V-FEXrt created 
https://github.com/llvm/llvm-project/pull/139800

Partial implementation of https://github.com/llvm/wg-hlsl/issues/264

Adds several overloads to various intrinsic functions used by MiniEngine



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [Cygwin] Template instantiations should be exported by default (PR #139799)

2025-05-13 Thread Tomohiro Kashiwada via cfe-commits

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


[clang] [clang] Compound Literal Statement Constant Expression Assertion Fix (PR #139479)

2025-05-13 Thread via cfe-commits

https://github.com/Mr-Anyone updated 
https://github.com/llvm/llvm-project/pull/139479



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [Cygwin] Export global symbols, template instantiations, RTTI and VTable are exported correctly (PR #138773)

2025-05-13 Thread Tomohiro Kashiwada via cfe-commits

kikairoya wrote:

Thank you. I have divided into separated PRs. They don't have conflict each.

https://github.com/llvm/llvm-project/pull/139797
https://github.com/llvm/llvm-project/pull/139798
https://github.com/llvm/llvm-project/pull/139799



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


[clang] [llvm] [HLSL][RootSignature] Add metadata generation for descriptor tables (PR #139633)

2025-05-13 Thread via cfe-commits


@@ -160,6 +163,75 @@ void dumpRootElements(raw_ostream &OS, 
ArrayRef Elements) {
   OS << "}";
 }
 
+static MDString *ClauseTypeToName(LLVMContext &Ctx, ClauseType Type) {
+  StringRef Name;
+  switch (Type) {
+  case ClauseType::CBuffer:
+Name = "CBV";
+break;
+  case ClauseType::SRV:
+Name = "SRV";
+break;
+  case ClauseType::UAV:
+Name = "UAV";
+break;
+  case ClauseType::Sampler:
+Name = "Sampler";
+break;
+  }
+  return MDString::get(Ctx, Name);
+}
+
+MDNode *MetadataBuilder::BuildRootSignature() {
+  for (const RootElement &Element : Elements) {
+MDNode *ElementMD = nullptr;
+if (const auto &Clause = std::get_if(&Element))
+  ElementMD = BuildDescriptorTableClause(*Clause);
+if (const auto &Table = std::get_if(&Element))
+  ElementMD = BuildDescriptorTable(*Table);
+GeneratedMetadata.push_back(ElementMD);
+  }
+
+  return MDNode::get(Ctx, GeneratedMetadata);
+}
+
+MDNode *MetadataBuilder::BuildDescriptorTable(const DescriptorTable &Table) {
+  IRBuilder<> B(Ctx);
+  SmallVector TableOperands;
+  // Set the mandatory arguments
+  TableOperands.push_back(MDString::get(Ctx, "DescriptorTable"));
+  TableOperands.push_back(ConstantAsMetadata::get(
+  B.getInt32(llvm::to_underlying(Table.Visibility;
+
+  // Remaining operands are references to the table's clauses. The in-memory
+  // representation of the Root Elements created from parsing will ensure that
+  // the previous N elements are the clauses for this table.
+  assert(Table.NumClauses <= GeneratedMetadata.size() &&
+ "Table expected all owned clauses to be generated already");
+  // So, add a refence to each clause to our operands
+  TableOperands.append(GeneratedMetadata.end() - Table.NumClauses,
+   GeneratedMetadata.end());

joaosaffran wrote:

So we ensure those ranges are being written in the correct order?

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


[clang] [llvm] [HLSL][RootSignature] Add metadata generation for descriptor tables (PR #139633)

2025-05-13 Thread via cfe-commits


@@ -160,6 +163,75 @@ void dumpRootElements(raw_ostream &OS, 
ArrayRef Elements) {
   OS << "}";
 }
 
+static MDString *ClauseTypeToName(LLVMContext &Ctx, ClauseType Type) {
+  StringRef Name;
+  switch (Type) {
+  case ClauseType::CBuffer:
+Name = "CBV";
+break;
+  case ClauseType::SRV:
+Name = "SRV";
+break;
+  case ClauseType::UAV:
+Name = "UAV";
+break;
+  case ClauseType::Sampler:
+Name = "Sampler";
+break;
+  }
+  return MDString::get(Ctx, Name);
+}
+
+MDNode *MetadataBuilder::BuildRootSignature() {
+  for (const RootElement &Element : Elements) {
+MDNode *ElementMD = nullptr;
+if (const auto &Clause = std::get_if(&Element))
+  ElementMD = BuildDescriptorTableClause(*Clause);
+if (const auto &Table = std::get_if(&Element))
+  ElementMD = BuildDescriptorTable(*Table);
+GeneratedMetadata.push_back(ElementMD);
+  }
+
+  return MDNode::get(Ctx, GeneratedMetadata);
+}
+
+MDNode *MetadataBuilder::BuildDescriptorTable(const DescriptorTable &Table) {
+  IRBuilder<> B(Ctx);
+  SmallVector TableOperands;
+  // Set the mandatory arguments
+  TableOperands.push_back(MDString::get(Ctx, "DescriptorTable"));
+  TableOperands.push_back(ConstantAsMetadata::get(
+  B.getInt32(llvm::to_underlying(Table.Visibility;
+
+  // Remaining operands are references to the table's clauses. The in-memory
+  // representation of the Root Elements created from parsing will ensure that
+  // the previous N elements are the clauses for this table.
+  assert(Table.NumClauses <= GeneratedMetadata.size() &&
+ "Table expected all owned clauses to be generated already");

joaosaffran wrote:

Not sure if that assert would really help, since it could easily be mislead by 
the generation of other parameters.

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


[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-13 Thread via cfe-commits


@@ -971,6 +971,52 @@ def SwitchOp : CIR_Op<"switch",
   }];
 }
 
+//===--===//
+// SwitchFlatOp
+//===--===//
+
+def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments,
+  Terminator]> {
+
+  let description = [{
+The `cir.switch.flat` operation is a region-less and simplified
+version of the `cir.switch`.
+It's representation is closer to LLVM IR dialect
+than the C/C++ language feature.
+  }];
+
+  let arguments = (ins
+CIR_IntType:$condition,
+Variadic:$defaultOperands,
+VariadicOfVariadic:$caseOperands,
+ArrayAttr:$case_values,

Andres-Salamanca wrote:

I'm going to leave it as caseValues

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


[clang] [Cygwin] Template instantiations should be exported by default (PR #139799)

2025-05-13 Thread Tomohiro Kashiwada via cfe-commits

https://github.com/kikairoya created 
https://github.com/llvm/llvm-project/pull/139799

Behaves as same as both of Clang and GCC targetting MinGW. Required for 
compatibility for Cygwin-GCC.

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




  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [Cygwin] Template instantiations should be exported by default (PR #139799)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Tomohiro Kashiwada (kikairoya)


Changes

Behaves as same as both of Clang and GCC targetting MinGW. Required for 
compatibility for Cygwin-GCC.

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


---

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


6 Files Affected:

- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+4-5) 
- (modified) clang/test/CodeGenCXX/dllexport-members.cpp (+68-2) 
- (modified) clang/test/CodeGenCXX/mingw-template-dllexport.cpp (+3) 
- (modified) clang/test/SemaCXX/dllexport.cpp (+2) 
- (modified) clang/test/SemaCXX/dllimport.cpp (+3) 


``diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index cbccb567e2adf..9610feb5b8820 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6576,7 +6576,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
   // declarations, except in MinGW mode.
   if (ClassExported && !ClassAttr->isInherited() &&
   TSK == TSK_ExplicitInstantiationDeclaration &&
-  !Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
+  !Context.getTargetInfo().getTriple().isOSCygMing()) {
 Class->dropAttr();
 return;
   }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 7940340064eda..64fbe435d9789 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8987,8 +8987,7 @@ 
Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
 // The declaration itself has not actually been instantiated, so it is
 // still okay to specialize it.
 StripImplicitInstantiation(
-PrevDecl,
-Context.getTargetInfo().getTriple().isWindowsGNUEnvironment());
+PrevDecl, Context.getTargetInfo().getTriple().isOSCygMing());
 return false;
   }
   // Fall through
@@ -9855,7 +9854,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
: TSK_ExplicitInstantiationDeclaration;
 
   if (TSK == TSK_ExplicitInstantiationDeclaration &&
-  !Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
+  !Context.getTargetInfo().getTriple().isOSCygMing()) {
 // Check for dllexport class template instantiation declarations,
 // except for MinGW mode.
 for (const ParsedAttr &AL : Attr) {
@@ -9920,7 +9919,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
 = PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
 
   if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
-  Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
+  Context.getTargetInfo().getTriple().isOSCygMing()) {
 // Check for dllexport class template instantiation definitions in MinGW
 // mode, if a previous declaration of the instantiation was seen.
 for (const ParsedAttr &AL : Attr) {
@@ -10088,7 +10087,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
 // In MinGW mode, export the template instantiation if the declaration
 // was marked dllexport.
 if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
-Context.getTargetInfo().getTriple().isWindowsGNUEnvironment() &&
+Context.getTargetInfo().getTriple().isOSCygMing() &&
 PrevDecl->hasAttr()) {
   dllExportImportClassTemplateSpecialization(*this, Def);
 }
diff --git a/clang/test/CodeGenCXX/dllexport-members.cpp 
b/clang/test/CodeGenCXX/dllexport-members.cpp
index e4effa4c72c72..3753050cbf7d5 100644
--- a/clang/test/CodeGenCXX/dllexport-members.cpp
+++ b/clang/test/CodeGenCXX/dllexport-members.cpp
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc 
-fms-compatibility -fms-compatibility-version=19 -emit-llvm -std=c++1y -O0 -o - 
%s | FileCheck --check-prefix=M64VS2015 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-gnu
   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU 
--check-prefix=G32 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-gnu  
   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU 
--check-prefix=G64 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-pc-cygwin  
   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU 
--check-prefix=C32 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-pc-cygwin
   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU 
--check-prefix=G64 %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Exported {};
@@ -35,12 +37,16 @@ struct ExportMembers {
   // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void 
@"?normalInlineDecl@ExportMembers@@QAEXXZ"(ptr {{[^,

[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread Sarah Spall via cfe-commits


@@ -179,3 +179,41 @@ half3 test_lerp_half_scalar(half3 x, half3 y, half s) { 
return lerp(x, y, s); }
 float3 test_lerp_float_scalar(float3 x, float3 y, float s) {
   return lerp(x, y, s);
 }
+
+// CHECK: define [[FNATTRS]] <2 x float> @_Z23test_lerp_float_scalar1Dv2_ff(
+// CHECK:[[SPLATINSERT:%.*]] = insertelement <2 x float> poison, float 
%{{.*}}, i64 0
+// CHECK:[[SPLAT:%.*]] = shufflevector <2 x float> [[SPLATINSERT]], <2 x 
float> poison, <2 x i32> zeroinitializer
+// CHECK:[[LERP:%.*]] = call {{.*}} <2 x float> 
@llvm.[[TARGET]].lerp.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, <2 x float> 
[[SPLAT]])
+// CHECK:ret <2 x float> [[LERP]]
+float2 test_lerp_float_scalar1(float2 v, float s) {

spall wrote:

is this test worth adding since its a duplicate of the one above, just uses 
float2 instead of float3?

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


[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread Sarah Spall via cfe-commits


@@ -158,6 +158,42 @@ namespace hlsl {
 return fn((float4)V1, (float4)V2, (float4)V3); 
\
   }
 
+#define _DXC_COMPAT_BINARY_VECTOR_SCALAR_OVERLOADS(fn) 
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, T V2) { 
\
+return fn(V1, (vector)V2);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  T V1, vector V2) { 
\
+return fn((vector)V1, V2);   
\
+  }
+
+#define _DXC_COMPAT_TERNARY_VECTOR_SCALAR_OVERLOADS(fn)
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  T V1, vector V2, vector V3) {
\
+return fn((vector)V1, V2, V3);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, T V2, vector V3) {
\
+return fn(V1, (vector)V2, V3);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, vector V2, T V3) {
\
+return fn(V1, V2, (vector)V3);   
\
+  }
+
+#define _DXC_COMPAT_TERNARY_SINGLE_VECTOR_SCALAR_OVERLOADS(fn) 
\

spall wrote:

why did you put this overload in its own macro and not in the previous one?

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


[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread Sarah Spall via cfe-commits


@@ -236,6 +257,22 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(cosh)
 _DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(degrees)
 _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(degrees)
 
+//===--===//
+// dot builtins overloads
+//===--===//
+
+template 

spall wrote:

you can use your '_DXC_COMPAT_BINARY_VECTOR_SCALAR_OVERLOADS' macro here right?

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


[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-13 Thread Hood Chatham via cfe-commits

https://github.com/hoodmane updated 
https://github.com/llvm/llvm-project/pull/139580

>From 2ca282f0a20088bef15289a8ce5167d1e23595c3 Mon Sep 17 00:00:00 2001
From: Hood Chatham 
Date: Fri, 9 May 2025 00:16:26 -0400
Subject: [PATCH 1/3] [Wasm][Clang] Add  __builtin_wasm_ref_is_null_extern

I also fixed __builtin_wasm_ref_null_extern() to generate a diagnostic
when it gets an argument. It seems like `SemaRef.checkArgCount()` has a
bug that makes it unable to check for 0 args.
---
 .../clang/Basic/BuiltinsWebAssembly.def   |  1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 ++
 clang/include/clang/Sema/SemaWasm.h   |  1 +
 .../CodeGen/TargetBuiltins/WebAssembly.cpp|  5 
 clang/lib/Sema/SemaWasm.cpp   | 26 +--
 clang/test/CodeGen/builtins-wasm.c|  6 +
 clang/test/Sema/builtins-wasm.c   |  4 +++
 7 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index ab480369b3820..e2afcc08064b2 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -192,6 +192,7 @@ TARGET_BUILTIN(__builtin_wasm_replace_lane_f16x8, 
"V8hV8hIif", "nc", "fp16")
 // in which case the argument spec (second argument) is unused.
 
 TARGET_BUILTIN(__builtin_wasm_ref_null_extern, "i", "nct", "reference-types")
+TARGET_BUILTIN(__builtin_wasm_ref_is_null_extern, "ii", "nct", 
"reference-types")
 
 // A funcref represented as a function pointer with the funcref attribute
 // attached to the type, therefore SemaChecking will check for the right
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e5a7cdc14a737..d4abc46ae58ee 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12991,6 +12991,8 @@ def err_wasm_reftype_multidimensional_array : Error<
   "multi-dimensional arrays of WebAssembly references are not allowed">;
 def err_wasm_builtin_arg_must_be_table_type : Error <
   "%ordinal0 argument must be a WebAssembly table">;
+def err_wasm_builtin_arg_must_be_externref_type : Error <
+  "%ordinal0 argument must be an externref">;
 def err_wasm_builtin_arg_must_match_table_element_type : Error <
   "%ordinal0 argument must match the element type of the WebAssembly table in 
the %ordinal1 argument">;
 def err_wasm_builtin_arg_must_be_integer_type : Error <
diff --git a/clang/include/clang/Sema/SemaWasm.h 
b/clang/include/clang/Sema/SemaWasm.h
index 8841fdff23035..2123e073516cb 100644
--- a/clang/include/clang/Sema/SemaWasm.h
+++ b/clang/include/clang/Sema/SemaWasm.h
@@ -29,6 +29,7 @@ class SemaWasm : public SemaBase {
CallExpr *TheCall);
 
   bool BuiltinWasmRefNullExtern(CallExpr *TheCall);
+  bool BuiltinWasmRefIsNullExtern(CallExpr *TheCall);
   bool BuiltinWasmRefNullFunc(CallExpr *TheCall);
   bool BuiltinWasmTableGet(CallExpr *TheCall);
   bool BuiltinWasmTableSet(CallExpr *TheCall);
diff --git a/clang/lib/CodeGen/TargetBuiltins/WebAssembly.cpp 
b/clang/lib/CodeGen/TargetBuiltins/WebAssembly.cpp
index 698f43215a1be..b7fd70e855d40 100644
--- a/clang/lib/CodeGen/TargetBuiltins/WebAssembly.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/WebAssembly.cpp
@@ -209,6 +209,11 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_ref_null_extern);
 return Builder.CreateCall(Callee);
   }
+  case WebAssembly::BI__builtin_wasm_ref_is_null_extern: {
+Value *Src = EmitScalarExpr(E->getArg(0));
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_ref_is_null_extern);
+return Builder.CreateCall(Callee, {Src});
+  }
   case WebAssembly::BI__builtin_wasm_ref_null_func: {
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_ref_null_func);
 return Builder.CreateCall(Callee);
diff --git a/clang/lib/Sema/SemaWasm.cpp b/clang/lib/Sema/SemaWasm.cpp
index c0fa05bc17609..4157e179c97d6 100644
--- a/clang/lib/Sema/SemaWasm.cpp
+++ b/clang/lib/Sema/SemaWasm.cpp
@@ -52,14 +52,34 @@ static bool CheckWasmBuiltinArgIsInteger(Sema &S, CallExpr 
*E,
 }
 
 bool SemaWasm::BuiltinWasmRefNullExtern(CallExpr *TheCall) {
-  if (TheCall->getNumArgs() != 0)
+  if (TheCall->getNumArgs() != 0) {
+Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_many_args)
+<< 0 /*function call*/ << /*expected*/ 0 << TheCall->getNumArgs()
+<< /*is non object*/ 0;
 return true;
-
+  }
   TheCall->setType(getASTContext().getWebAssemblyExternrefType());
 
   return false;
 }
 
+bool SemaWasm::BuiltinWasmRefIsNullExtern(CallExpr *TheCall) {
+  if (SemaRef.checkArgCount(TheCall, 1)) {
+return true;
+  }
+
+  Expr *ArgExpr = TheCall->getArg(0);
+  if (!ArgExpr->getType().isWebAssemblyExternrefType()) {
+SemaRef.Diag(ArgExpr->getBeginLoc(

[clang] [Clang] Link libgcc_s.1.dylib when building for macOS 10.5 and older (PR #124651)

2025-05-13 Thread via cfe-commits

https://github.com/Un1q32 updated 
https://github.com/llvm/llvm-project/pull/124651



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-13 Thread Tom Honermann via cfe-commits


@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++20 -Wconversion %s
+
+void c8(char8_t);
+void c16(char16_t);
+void c32(char32_t);
+
+void test(char8_t u8, char16_t u16, char32_t u32) {
+c8(u8);
+c8(u16); // expected-warning {{implicit conversion from 'char16_t' to 
'char8_t' may lose precision and change the meaning of the represented code 
unit}}
+c8(u32); // expected-warning {{implicit conversion from 'char32_t' to 
'char8_t' may lose precision and change the meaning of the represented code 
unit}}
+
+c16(u8);  // expected-warning {{implicit conversion from 'char8_t' to 
'char16_t' may change the meaning of the represented code unit}}
+c16(u16);
+c16(u32); // expected-warning {{implicit conversion from 'char32_t' to 
'char16_t' may lose precision and change the meaning of the represented code 
unit}}
+
+c32(u8);  // expected-warning {{implicit conversion from 'char8_t' to 
'char32_t' may change the meaning of the represented code unit}}
+c32(u16); // expected-warning {{implicit conversion from 'char16_t' to 
'char32_t' may change the meaning of the represented code unit}}
+c32(u32);
+
+
+c8(char32_t(0x7f));
+c8(char32_t(0x80));   // expected-warning {{implicit conversion from 
'char32_t' to 'char8_t' changes the meaning of the codepoint ''}}
+
+c8(char16_t(0x7f));
+c8(char16_t(0x80));   // expected-warning {{implicit conversion from 
'char16_t' to 'char8_t' changes the meaning of the codepoint ''}}
+c8(char16_t(0xD800)); // expected-warning {{implicit conversion from 
'char16_t' to 'char8_t' changes the meaning of the code unit '<0xD800>'}}
+c8(char16_t(0xE000)); // expected-warning {{implicit conversion from 
'char16_t' to 'char8_t' changes the meaning of the codepoint ''}}
+
+
+c16(char32_t(0x7f));
+c16(char32_t(0x80));
+c16(char32_t(0xD7FF));
+c16(char32_t(0xD800)); // expected-warning {{implicit conversion from 
'char32_t' to 'char16_t' changes the meaning of the code unit '<0xD800>'}}
+c16(char32_t(0xE000));
+c16(char32_t(U'🐉')); // expected-warning {{implicit conversion from 
'char32_t' to 'char16_t' changes the meaning of the codepoint '🐉'}}

tahonermann wrote:

Agreed. In my mind, the term "code point" always designates an integer type or 
value. "Character" is more fluid; it could mean a glyph or the character 
designated by a code point. But it doesn't work for an invalid code point, so, 
hmm, ok. This isn't a new concern introduced with this change anyway. Let's 
just move on.

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


[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-13 Thread Tom Honermann via cfe-commits


@@ -1567,15 +1568,81 @@ void Sema::checkEnumArithmeticConversions(Expr *LHS, 
Expr *RHS,
   }
 }
 
+static void CheckUnicodeArithmeticConversions(Sema &SemaRef, Expr *LHS,
+  Expr *RHS, SourceLocation Loc,
+  ArithConvKind ACK) {
+  QualType LHSType = LHS->getType().getUnqualifiedType();
+  QualType RHSType = RHS->getType().getUnqualifiedType();
+
+  if (!SemaRef.getLangOpts().CPlusPlus || !LHSType->isUnicodeCharacterType() ||
+  !RHSType->isUnicodeCharacterType())
+return;
+
+  if (ACK == ArithConvKind::Comparison) {
+if (SemaRef.getASTContext().hasSameType(LHSType, RHSType))
+  return;
+
+Expr::EvalResult LHSRes, RHSRes;
+bool Success = LHS->EvaluateAsInt(LHSRes, SemaRef.getASTContext(),
+  Expr::SE_AllowSideEffects,
+  SemaRef.isConstantEvaluatedContext());
+if (Success)
+  Success = RHS->EvaluateAsInt(RHSRes, SemaRef.getASTContext(),
+   Expr::SE_AllowSideEffects,
+   SemaRef.isConstantEvaluatedContext());
+if (Success) {
+  llvm::APSInt LHSValue(32);
+  LHSValue = LHSRes.Val.getInt();
+  llvm::APSInt RHSValue(32);
+  RHSValue = RHSRes.Val.getInt();
+
+  auto IsSingleCodeUnitCP = [](const QualType &T,
+   const llvm::APSInt &Value) {
+if (T->isChar8Type())
+  return llvm::IsSingleCodeUnitUTF8Codepoint(Value.getExtValue());
+if (T->isChar16Type())
+  return llvm::IsSingleCodeUnitUTF16Codepoint(Value.getExtValue());
+return llvm::IsSingleCodeUnitUTF32Codepoint(Value.getExtValue());
+  };

tahonermann wrote:

No, I don't feel particularly strongly about it. Maybe revisit if you find 
yourself needing it again down the road (and you happen to remember this 
discussion then).

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


[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-13 Thread Tom Honermann via cfe-commits


@@ -11810,6 +11811,46 @@ static void DiagnoseIntInBoolContext(Sema &S, Expr *E) 
{
   }
 }
 
+static void DiagnoseMixedUnicodeImplicitConversion(Sema &S, const Type *Source,
+   const Type *Target, Expr *E,
+   QualType T,
+   SourceLocation CC) {
+  assert(Source->isUnicodeCharacterType() && Target->isUnicodeCharacterType() 
&&
+ Source != Target);
+  Expr::EvalResult Result;
+  if (E->EvaluateAsInt(Result, S.getASTContext(), Expr::SE_AllowSideEffects,
+   S.isConstantEvaluatedContext())) {
+llvm::APSInt Value(32);
+Value = Result.Val.getInt();
+bool IsASCII = Value <= 0x7F;
+bool IsBMP = Value <= 0xD7FF || (Value >= 0xE000 && Value <= 0x);
+bool ConversionPreservesSemantics =
+IsASCII || (!Source->isChar8Type() && !Target->isChar8Type() && IsBMP);

tahonermann wrote:

Ah, right! Thanks!

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


[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-13 Thread Tom Honermann via cfe-commits

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

Thanks @cor3ntin, this looks good to me!

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


[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-13 Thread Tom Honermann via cfe-commits

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


[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #137250)

2025-05-13 Thread Bill Wendling via cfe-commits

https://github.com/bwendling updated 
https://github.com/llvm/llvm-project/pull/137250



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] 9ae3bce - [Clang][counted_by] Add support for 'counted_by' on struct pointers (#137250)

2025-05-13 Thread via cfe-commits

Author: Bill Wendling
Date: 2025-05-13T16:01:36-07:00
New Revision: 9ae3bce17543f92ce0237597cc66503d58cce317

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

LOG: [Clang][counted_by] Add support for 'counted_by' on struct pointers 
(#137250)

The 'counted_by' attribute is now available for pointers in structs.
It generates code for sanity checks as well as
__builtin_dynamic_object_size()
calculations. For example:

  struct annotated_ptr {
int count;
char *buf __attribute__((counted_by(count)));
  };

If the pointer's type is 'void *', use the 'sized_by' attribute, which
works similarly to 'counted_by', but can handle the 'void' base type:

  struct annotated_ptr {
int count;
void *buf __attribute__((sized_by(count)));
  };

If the 'count' field member occurs after the pointer, use the
'-fexperimental-late-parse-attributes' flag during compilation.

Note that 'counted_by' cannot be applied to a pointer to an incomplete
type, because the size isn't known.

  struct foo;
  struct annotated_ptr {
int count;
struct foo *buf __attribute__((counted_by(count))); /* invalid */
  };

Signed-off-by: Bill Wendling 

Added: 
clang/test/CodeGen/attr-counted-by-for-pointers.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/attr-counted-by.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 45e0f69c46902..4fdf2113cb9dc 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -909,7 +909,8 @@ class StructFieldAccess
   bool AddrOfSeen = false;
 
 public:
-  const ArraySubscriptExpr *ASE = nullptr;
+  const Expr *ArrayIndex = nullptr;
+  QualType ArrayElementTy;
 
   const Expr *VisitMemberExpr(const MemberExpr *E) {
 if (AddrOfSeen && E->getType()->isArrayType())
@@ -919,12 +920,13 @@ class StructFieldAccess
   }
 
   const Expr *VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
-if (ASE)
+if (ArrayIndex)
   // We don't support multiple subscripts.
   return nullptr;
 
 AddrOfSeen = false; // '&ptr->array[idx]' is okay.
-ASE = E;
+ArrayIndex = E->getIdx();
+ArrayElementTy = E->getBase()->getType();
 return Visit(E->getBase());
   }
   const Expr *VisitCastExpr(const CastExpr *E) {
@@ -1016,12 +1018,10 @@ GetFieldOffset(ASTContext &Ctx, const RecordDecl *RD, 
const FieldDecl *FD) {
   return std::nullopt;
 }
 
-llvm::Value *
-CodeGenFunction::emitCountedByMemberSize(const Expr *E, llvm::Value *EmittedE,
- unsigned Type,
- llvm::IntegerType *ResType) {
-  ASTContext &Ctx = getContext();
-
+llvm::Value *CodeGenFunction::emitCountedBySize(const Expr *E,
+llvm::Value *EmittedE,
+unsigned Type,
+llvm::IntegerType *ResType) {
   // Note: If the whole struct is specificed in the __bdos (i.e. Visitor
   // returns a DeclRefExpr). The calculation of the whole size of the structure
   // with a flexible array member can be done in two ways:
@@ -1040,14 +1040,224 @@ CodeGenFunction::emitCountedByMemberSize(const Expr 
*E, llvm::Value *EmittedE,
   // GCC does for consistency's sake.
 
   StructFieldAccess Visitor;
-  const MemberExpr *ME = dyn_cast_if_present(Visitor.Visit(E));
+  E = Visitor.Visit(E);
+  if (!E)
+return nullptr;
+
+  const Expr *Idx = Visitor.ArrayIndex;
+  if (Idx) {
+if (Idx->HasSideEffects(getContext()))
+  // We can't have side-effects.
+  return getDefaultBuiltinObjectSizeResult(Type, ResType);
+
+if (const auto *IL = dyn_cast(Idx)) {
+  int64_t Val = IL->getValue().getSExtValue();
+  if (Val < 0)
+return getDefaultBuiltinObjectSizeResult(Type, ResType);
+
+  // The index is 0, so we don't need to take it into account.
+  if (Val == 0)
+Idx = nullptr;
+}
+  }
+
+  // __counted_by on either a flexible array member or a pointer into a struct
+  // with a flexible array member.
+  if (const auto *ME = dyn_cast(E))
+return emitCountedByMemberSize(ME, Idx, EmittedE, Visitor.ArrayElementTy,
+   Type, ResType);
+
+  // __counted_by on a pointer in a struct.
+  if (const auto *ICE = dyn_cast(E);
+  ICE && ICE->getCastKind() == CK_LValueToRValue)
+return emitCountedByPointerSize(ICE, Idx, EmittedE, Visitor.ArrayElementTy,
+Type, ResType);
+
+  return nullptr;
+}
+
+static llvm::Value *EmitPositiveResultOrZero(CodeGenFunction &CGF,
+ llvm::Value *Res,
+  

[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread Ashley Coleman via cfe-commits


@@ -158,6 +158,42 @@ namespace hlsl {
 return fn((float4)V1, (float4)V2, (float4)V3); 
\
   }
 
+#define _DXC_COMPAT_BINARY_VECTOR_SCALAR_OVERLOADS(fn) 
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, T V2) { 
\
+return fn(V1, (vector)V2);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  T V1, vector V2) { 
\
+return fn((vector)V1, V2);   
\
+  }
+
+#define _DXC_COMPAT_TERNARY_VECTOR_SCALAR_OVERLOADS(fn)
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  T V1, vector V2, vector V3) {
\
+return fn((vector)V1, V2, V3);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, T V2, vector V3) {
\
+return fn(V1, (vector)V2, V3);   
\
+  }
\
+  template 
\
+  constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector> fn( 
\
+  vector V1, vector V2, T V3) {
\
+return fn(V1, V2, (vector)V3);   
\
+  }
+
+#define _DXC_COMPAT_TERNARY_SINGLE_VECTOR_SCALAR_OVERLOADS(fn) 
\

V-FEXrt wrote:

Some intrinsics didn't need both so I didn't want to unnecessarily add extra 
overloads

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


[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #137250)

2025-05-13 Thread Bill Wendling via cfe-commits

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


[clang] [WebAssembly][Clang] Add __builtin_wasm_ref_is_null_extern (PR #139580)

2025-05-13 Thread Sam Clegg via cfe-commits

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


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


[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread Ashley Coleman via cfe-commits


@@ -236,6 +257,22 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(cosh)
 _DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(degrees)
 _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(degrees)
 
+//===--===//
+// dot builtins overloads
+//===--===//
+
+template 

V-FEXrt wrote:

its subtle, but no (I actually made that mistake myself).

`_DXC_COMPAT_BINARY_VECTOR_SCALAR_OVERLOADS` creates type `vector 
fn(vector x, T y` but `dot` requires `T fn(vector x, T y)` (return 
types are different shape)

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


[clang] [HLSL] Add various overloads for MiniEngine (PR #139800)

2025-05-13 Thread Ashley Coleman via cfe-commits


@@ -179,3 +179,41 @@ half3 test_lerp_half_scalar(half3 x, half3 y, half s) { 
return lerp(x, y, s); }
 float3 test_lerp_float_scalar(float3 x, float3 y, float s) {
   return lerp(x, y, s);
 }
+
+// CHECK: define [[FNATTRS]] <2 x float> @_Z23test_lerp_float_scalar1Dv2_ff(
+// CHECK:[[SPLATINSERT:%.*]] = insertelement <2 x float> poison, float 
%{{.*}}, i64 0
+// CHECK:[[SPLAT:%.*]] = shufflevector <2 x float> [[SPLATINSERT]], <2 x 
float> poison, <2 x i32> zeroinitializer
+// CHECK:[[LERP:%.*]] = call {{.*}} <2 x float> 
@llvm.[[TARGET]].lerp.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, <2 x float> 
[[SPLAT]])
+// CHECK:ret <2 x float> [[LERP]]
+float2 test_lerp_float_scalar1(float2 v, float s) {

V-FEXrt wrote:

Not directly no, I was on the fence, but I couldn't quite figure out how to 
group them. I suppose I can just move up and rename the params

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


[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Thurston Dang (thurstond)


Changes

This connects the -fsanitize-annotate-debug-info plumbing 
(https://github.com/llvm/llvm-project/pull/138577) to CFI check codegen.

Updates the tests from https://github.com/llvm/llvm-project/pull/139149.

A side effect is that "__ubsan_check_array_bounds" is renamed to 
"__ubsan_check_array-bounds". This affects 
clang/test/CodeGen/bounds-checking-debuginfo.c from 
https://github.com/llvm/llvm-project/pull/128977

---

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


8 Files Affected:

- (modified) clang/lib/CodeGen/CGClass.cpp (+42-11) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+32-10) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+11) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+6-1) 
- (modified) clang/test/CodeGen/bounds-checking-debuginfo.c (+2-2) 
- (modified) clang/test/CodeGen/cfi-check-fail-debuginfo.c (+13-10) 
- (modified) clang/test/CodeGen/cfi-icall-generalize-debuginfo.c (+26-20) 
- (modified) clang/test/CodeGen/cfi-icall-normalize2-debuginfo.c (+66-61) 


``diff
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index befbfc64a680c..232965f8f0a84 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2779,6 +2779,36 @@ void CodeGenFunction::EmitTypeMetadataCodeForVCall(const 
CXXRecordDecl *RD,
   }
 }
 
+void CodeGenFunction::ParseCFITypeCheckKind(CFITypeCheckKind TCK,
+SanitizerKind::SanitizerOrdinal &M,
+llvm::SanitizerStatKind &SSK) {
+  switch (TCK) {
+  case CFITCK_VCall:
+M = SanitizerKind::SO_CFIVCall;
+SSK = llvm::SanStat_CFI_VCall;
+break;
+  case CFITCK_NVCall:
+M = SanitizerKind::SO_CFINVCall;
+SSK = llvm::SanStat_CFI_NVCall;
+break;
+  case CFITCK_DerivedCast:
+M = SanitizerKind::SO_CFIDerivedCast;
+SSK = llvm::SanStat_CFI_DerivedCast;
+break;
+  case CFITCK_UnrelatedCast:
+M = SanitizerKind::SO_CFIUnrelatedCast;
+SSK = llvm::SanStat_CFI_UnrelatedCast;
+break;
+  case CFITCK_ICall:
+M = SanitizerKind::SO_CFIICall;
+SSK = llvm::SanStat_CFI_ICall;
+break;
+  case CFITCK_NVMFCall:
+  case CFITCK_VMFCall:
+llvm_unreachable("unexpected sanitizer kind");
+  }
+}
+
 void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
 llvm::Value *VTable,
 CFITypeCheckKind TCK,
@@ -2786,6 +2816,10 @@ void CodeGenFunction::EmitVTablePtrCheckForCall(const 
CXXRecordDecl *RD,
   if (!SanOpts.has(SanitizerKind::CFICastStrict))
 RD = LeastDerivedClassWithSameLayout(RD);
 
+  SanitizerKind::SanitizerOrdinal Ordinal;
+  llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, Ordinal, SSK);
+  ApplyDebugLocation ApplyTrapDI(*this, SanitizerAnnotateDebugInfo(Ordinal));
   EmitVTablePtrCheck(RD, VTable, TCK, Loc);
 }
 
@@ -2808,6 +2842,11 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType 
T, Address Derived,
   if (!SanOpts.has(SanitizerKind::CFICastStrict))
 ClassDecl = LeastDerivedClassWithSameLayout(ClassDecl);
 
+  SanitizerKind::SanitizerOrdinal Ordinal;
+  llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, Ordinal, SSK);
+  ApplyDebugLocation ApplyTrapDI(*this, SanitizerAnnotateDebugInfo(Ordinal));
+
   llvm::BasicBlock *ContBlock = nullptr;
 
   if (MayBeNull) {
@@ -2844,22 +2883,12 @@ void CodeGenFunction::EmitVTablePtrCheck(const 
CXXRecordDecl *RD,
 
   SanitizerKind::SanitizerOrdinal M;
   llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, M, SSK);
   switch (TCK) {
   case CFITCK_VCall:
-M = SanitizerKind::SO_CFIVCall;
-SSK = llvm::SanStat_CFI_VCall;
-break;
   case CFITCK_NVCall:
-M = SanitizerKind::SO_CFINVCall;
-SSK = llvm::SanStat_CFI_NVCall;
-break;
   case CFITCK_DerivedCast:
-M = SanitizerKind::SO_CFIDerivedCast;
-SSK = llvm::SanStat_CFI_DerivedCast;
-break;
   case CFITCK_UnrelatedCast:
-M = SanitizerKind::SO_CFIUnrelatedCast;
-SSK = llvm::SanStat_CFI_UnrelatedCast;
 break;
   case CFITCK_ICall:
   case CFITCK_NVMFCall:
@@ -2932,6 +2961,8 @@ llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
   SanitizerScope SanScope(this);
 
   EmitSanitizerStatReport(llvm::SanStat_CFI_VCall);
+  ApplyDebugLocation ApplyTrapDI(
+  *this, SanitizerAnnotateDebugInfo(SanitizerKind::SO_CFIVCall));
 
   llvm::Metadata *MD =
   CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 0d03923951a16..8519584c1f081 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1217,6 +1217,30 @@ void CodeGenFunction::EmitBoundsCheck(const Expr *E, 
const Expr *Base,
   EmitBoundsCheckImpl(E, Bound, Index, Inde

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Thurston Dang (thurstond)


Changes

This connects the -fsanitize-annotate-debug-info plumbing 
(https://github.com/llvm/llvm-project/pull/138577) to CFI check codegen.

Updates the tests from https://github.com/llvm/llvm-project/pull/139149.

A side effect is that "__ubsan_check_array_bounds" is renamed to 
"__ubsan_check_array-bounds". This affects 
clang/test/CodeGen/bounds-checking-debuginfo.c from 
https://github.com/llvm/llvm-project/pull/128977

---

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


8 Files Affected:

- (modified) clang/lib/CodeGen/CGClass.cpp (+42-11) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+32-10) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+11) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+6-1) 
- (modified) clang/test/CodeGen/bounds-checking-debuginfo.c (+2-2) 
- (modified) clang/test/CodeGen/cfi-check-fail-debuginfo.c (+13-10) 
- (modified) clang/test/CodeGen/cfi-icall-generalize-debuginfo.c (+26-20) 
- (modified) clang/test/CodeGen/cfi-icall-normalize2-debuginfo.c (+66-61) 


``diff
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index befbfc64a680c..232965f8f0a84 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2779,6 +2779,36 @@ void CodeGenFunction::EmitTypeMetadataCodeForVCall(const 
CXXRecordDecl *RD,
   }
 }
 
+void CodeGenFunction::ParseCFITypeCheckKind(CFITypeCheckKind TCK,
+SanitizerKind::SanitizerOrdinal &M,
+llvm::SanitizerStatKind &SSK) {
+  switch (TCK) {
+  case CFITCK_VCall:
+M = SanitizerKind::SO_CFIVCall;
+SSK = llvm::SanStat_CFI_VCall;
+break;
+  case CFITCK_NVCall:
+M = SanitizerKind::SO_CFINVCall;
+SSK = llvm::SanStat_CFI_NVCall;
+break;
+  case CFITCK_DerivedCast:
+M = SanitizerKind::SO_CFIDerivedCast;
+SSK = llvm::SanStat_CFI_DerivedCast;
+break;
+  case CFITCK_UnrelatedCast:
+M = SanitizerKind::SO_CFIUnrelatedCast;
+SSK = llvm::SanStat_CFI_UnrelatedCast;
+break;
+  case CFITCK_ICall:
+M = SanitizerKind::SO_CFIICall;
+SSK = llvm::SanStat_CFI_ICall;
+break;
+  case CFITCK_NVMFCall:
+  case CFITCK_VMFCall:
+llvm_unreachable("unexpected sanitizer kind");
+  }
+}
+
 void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
 llvm::Value *VTable,
 CFITypeCheckKind TCK,
@@ -2786,6 +2816,10 @@ void CodeGenFunction::EmitVTablePtrCheckForCall(const 
CXXRecordDecl *RD,
   if (!SanOpts.has(SanitizerKind::CFICastStrict))
 RD = LeastDerivedClassWithSameLayout(RD);
 
+  SanitizerKind::SanitizerOrdinal Ordinal;
+  llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, Ordinal, SSK);
+  ApplyDebugLocation ApplyTrapDI(*this, SanitizerAnnotateDebugInfo(Ordinal));
   EmitVTablePtrCheck(RD, VTable, TCK, Loc);
 }
 
@@ -2808,6 +2842,11 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType 
T, Address Derived,
   if (!SanOpts.has(SanitizerKind::CFICastStrict))
 ClassDecl = LeastDerivedClassWithSameLayout(ClassDecl);
 
+  SanitizerKind::SanitizerOrdinal Ordinal;
+  llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, Ordinal, SSK);
+  ApplyDebugLocation ApplyTrapDI(*this, SanitizerAnnotateDebugInfo(Ordinal));
+
   llvm::BasicBlock *ContBlock = nullptr;
 
   if (MayBeNull) {
@@ -2844,22 +2883,12 @@ void CodeGenFunction::EmitVTablePtrCheck(const 
CXXRecordDecl *RD,
 
   SanitizerKind::SanitizerOrdinal M;
   llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, M, SSK);
   switch (TCK) {
   case CFITCK_VCall:
-M = SanitizerKind::SO_CFIVCall;
-SSK = llvm::SanStat_CFI_VCall;
-break;
   case CFITCK_NVCall:
-M = SanitizerKind::SO_CFINVCall;
-SSK = llvm::SanStat_CFI_NVCall;
-break;
   case CFITCK_DerivedCast:
-M = SanitizerKind::SO_CFIDerivedCast;
-SSK = llvm::SanStat_CFI_DerivedCast;
-break;
   case CFITCK_UnrelatedCast:
-M = SanitizerKind::SO_CFIUnrelatedCast;
-SSK = llvm::SanStat_CFI_UnrelatedCast;
 break;
   case CFITCK_ICall:
   case CFITCK_NVMFCall:
@@ -2932,6 +2961,8 @@ llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
   SanitizerScope SanScope(this);
 
   EmitSanitizerStatReport(llvm::SanStat_CFI_VCall);
+  ApplyDebugLocation ApplyTrapDI(
+  *this, SanitizerAnnotateDebugInfo(SanitizerKind::SO_CFIVCall));
 
   llvm::Metadata *MD =
   CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 0d03923951a16..8519584c1f081 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1217,6 +1217,30 @@ void CodeGenFunction::EmitBoundsCheck(const Expr *E, 
const Expr *Base,
   EmitBoundsCheckImpl(E, Bound, Ind

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

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

https://github.com/thurstond created 
https://github.com/llvm/llvm-project/pull/139809

This connects the -fsanitize-annotate-debug-info plumbing 
(https://github.com/llvm/llvm-project/pull/138577) to CFI check codegen.

Updates the tests from https://github.com/llvm/llvm-project/pull/139149.

A side effect is that __ubsan_check_array_bounds is renamed to 
__ubsan_check_array-bounds. This affects 
clang/test/CodeGen/bounds-checking-debuginfo.c from 
https://github.com/llvm/llvm-project/pull/128977



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

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

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


[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

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

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

>From ead256dfd33d04877766ddb26830f264682e9b48 Mon Sep 17 00:00:00 2001
From: Thurston Dang 
Date: Wed, 7 May 2025 23:33:21 +
Subject: [PATCH 1/2] [cfi] Enable -fsanitize-annotate-debug-info functionality
 for CFI checks

This connects the -fsanitize-annotate-debug-info plumbing
(https://github.com/llvm/llvm-project/pull/138577) to CFI check codegen.

Updates the tests from https://github.com/llvm/llvm-project/pull/139149.

A side effect is that __ubsan_check_array_bounds is renamed to 
__ubsan_check_array-bounds.
This affects clang/test/CodeGen/bounds-checking-debuginfo.c
from https://github.com/llvm/llvm-project/pull/128977
---
 clang/lib/CodeGen/CGClass.cpp |  53 ++--
 clang/lib/CodeGen/CGExpr.cpp  |  42 --
 clang/lib/CodeGen/CodeGenFunction.h   |  11 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |   7 +-
 .../test/CodeGen/bounds-checking-debuginfo.c  |   4 +-
 clang/test/CodeGen/cfi-check-fail-debuginfo.c |  23 ++--
 .../CodeGen/cfi-icall-generalize-debuginfo.c  |  46 ---
 .../CodeGen/cfi-icall-normalize2-debuginfo.c  | 127 +-
 8 files changed, 198 insertions(+), 115 deletions(-)

diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index befbfc64a680c..232965f8f0a84 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2779,6 +2779,36 @@ void CodeGenFunction::EmitTypeMetadataCodeForVCall(const 
CXXRecordDecl *RD,
   }
 }
 
+void CodeGenFunction::ParseCFITypeCheckKind(CFITypeCheckKind TCK,
+SanitizerKind::SanitizerOrdinal &M,
+llvm::SanitizerStatKind &SSK) {
+  switch (TCK) {
+  case CFITCK_VCall:
+M = SanitizerKind::SO_CFIVCall;
+SSK = llvm::SanStat_CFI_VCall;
+break;
+  case CFITCK_NVCall:
+M = SanitizerKind::SO_CFINVCall;
+SSK = llvm::SanStat_CFI_NVCall;
+break;
+  case CFITCK_DerivedCast:
+M = SanitizerKind::SO_CFIDerivedCast;
+SSK = llvm::SanStat_CFI_DerivedCast;
+break;
+  case CFITCK_UnrelatedCast:
+M = SanitizerKind::SO_CFIUnrelatedCast;
+SSK = llvm::SanStat_CFI_UnrelatedCast;
+break;
+  case CFITCK_ICall:
+M = SanitizerKind::SO_CFIICall;
+SSK = llvm::SanStat_CFI_ICall;
+break;
+  case CFITCK_NVMFCall:
+  case CFITCK_VMFCall:
+llvm_unreachable("unexpected sanitizer kind");
+  }
+}
+
 void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
 llvm::Value *VTable,
 CFITypeCheckKind TCK,
@@ -2786,6 +2816,10 @@ void CodeGenFunction::EmitVTablePtrCheckForCall(const 
CXXRecordDecl *RD,
   if (!SanOpts.has(SanitizerKind::CFICastStrict))
 RD = LeastDerivedClassWithSameLayout(RD);
 
+  SanitizerKind::SanitizerOrdinal Ordinal;
+  llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, Ordinal, SSK);
+  ApplyDebugLocation ApplyTrapDI(*this, SanitizerAnnotateDebugInfo(Ordinal));
   EmitVTablePtrCheck(RD, VTable, TCK, Loc);
 }
 
@@ -2808,6 +2842,11 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType 
T, Address Derived,
   if (!SanOpts.has(SanitizerKind::CFICastStrict))
 ClassDecl = LeastDerivedClassWithSameLayout(ClassDecl);
 
+  SanitizerKind::SanitizerOrdinal Ordinal;
+  llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, Ordinal, SSK);
+  ApplyDebugLocation ApplyTrapDI(*this, SanitizerAnnotateDebugInfo(Ordinal));
+
   llvm::BasicBlock *ContBlock = nullptr;
 
   if (MayBeNull) {
@@ -2844,22 +2883,12 @@ void CodeGenFunction::EmitVTablePtrCheck(const 
CXXRecordDecl *RD,
 
   SanitizerKind::SanitizerOrdinal M;
   llvm::SanitizerStatKind SSK;
+  ParseCFITypeCheckKind(TCK, M, SSK);
   switch (TCK) {
   case CFITCK_VCall:
-M = SanitizerKind::SO_CFIVCall;
-SSK = llvm::SanStat_CFI_VCall;
-break;
   case CFITCK_NVCall:
-M = SanitizerKind::SO_CFINVCall;
-SSK = llvm::SanStat_CFI_NVCall;
-break;
   case CFITCK_DerivedCast:
-M = SanitizerKind::SO_CFIDerivedCast;
-SSK = llvm::SanStat_CFI_DerivedCast;
-break;
   case CFITCK_UnrelatedCast:
-M = SanitizerKind::SO_CFIUnrelatedCast;
-SSK = llvm::SanStat_CFI_UnrelatedCast;
 break;
   case CFITCK_ICall:
   case CFITCK_NVMFCall:
@@ -2932,6 +2961,8 @@ llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
   SanitizerScope SanScope(this);
 
   EmitSanitizerStatReport(llvm::SanStat_CFI_VCall);
+  ApplyDebugLocation ApplyTrapDI(
+  *this, SanitizerAnnotateDebugInfo(SanitizerKind::SO_CFIVCall));
 
   llvm::Metadata *MD =
   CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 0d03923951a16..8519584c1f081 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1217,6 +1217,30 @@ void CodeGenFunction::EmitBou

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-13 Thread Florian Mayer via cfe-commits

fmayer wrote:

I am not a fan of the change to the function used for array-bounds.

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


[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-13 Thread via cfe-commits

https://github.com/Andres-Salamanca updated 
https://github.com/llvm/llvm-project/pull/139154

>From f77464dbe1de51c89fbde5e5decfc2314cd7dba6 Mon Sep 17 00:00:00 2001
From: Andres Salamanca 
Date: Thu, 8 May 2025 15:39:49 -0500
Subject: [PATCH 1/2] Add support for FlattenCFG switch and introduce
 SwitchFlatOp

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  46 +++
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp   |  97 ++
 .../Dialect/Transforms/CIRCanonicalize.cpp|  15 +-
 .../lib/CIR/Dialect/Transforms/FlattenCFG.cpp | 235 ++-
 clang/test/CIR/IR/switch-flat.cir |  68 +
 clang/test/CIR/Transforms/switch.cir  | 278 ++
 6 files changed, 734 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/CIR/IR/switch-flat.cir
 create mode 100644 clang/test/CIR/Transforms/switch.cir

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 7ffa10464dcd3..914af6d1dc6bd 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -971,6 +971,52 @@ def SwitchOp : CIR_Op<"switch",
   }];
 }
 
+//===--===//
+// SwitchFlatOp
+//===--===//
+
+def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments,
+  Terminator]> {
+
+  let description = [{
+The `cir.switch.flat` operation is a region-less and simplified
+version of the `cir.switch`.
+It's representation is closer to LLVM IR dialect
+than the C/C++ language feature.
+  }];
+
+  let arguments = (ins
+CIR_IntType:$condition,
+Variadic:$defaultOperands,
+VariadicOfVariadic:$caseOperands,
+ArrayAttr:$case_values,
+DenseI32ArrayAttr:$case_operand_segments
+  );
+
+  let successors = (successor
+AnySuccessor:$defaultDestination,
+VariadicSuccessor:$caseDestinations
+  );
+
+  let assemblyFormat = [{
+$condition `:` type($condition) `,`
+$defaultDestination (`(` $defaultOperands^ `:` type($defaultOperands) `)`)?
+custom(ref(type($condition)), $case_values,
+  $caseDestinations, $caseOperands,
+  type($caseOperands))
+attr-dict
+  }];
+
+  let builders = [
+OpBuilder<(ins "mlir::Value":$condition,
+  "mlir::Block *":$defaultDestination,
+  "mlir::ValueRange":$defaultOperands,
+  CArg<"llvm::ArrayRef", "{}">:$caseValues,
+  CArg<"mlir::BlockRange", "{}">:$caseDestinations,
+  CArg<"llvm::ArrayRef", "{}">:$caseOperands)>
+  ];
+}
+
 
//===--===//
 // BrOp
 
//===--===//
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index b131edaf403ed..ca03013edb485 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -22,6 +22,7 @@
 #include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc"
 #include "clang/CIR/Dialect/IR/CIROpsEnums.cpp.inc"
 #include "clang/CIR/MissingFeatures.h"
+#include 
 
 using namespace mlir;
 using namespace cir;
@@ -962,6 +963,102 @@ bool 
cir::SwitchOp::isSimpleForm(llvm::SmallVectorImpl &cases) {
   });
 }
 
+//===--===//
+// SwitchFlatOp
+//===--===//
+
+void cir::SwitchFlatOp::build(OpBuilder &builder, OperationState &result,
+  Value value, Block *defaultDestination,
+  ValueRange defaultOperands,
+  ArrayRef caseValues,
+  BlockRange caseDestinations,
+  ArrayRef caseOperands) {
+
+  std::vector caseValuesAttrs;
+  for (auto &val : caseValues) {
+caseValuesAttrs.push_back(cir::IntAttr::get(value.getType(), val));
+  }
+  mlir::ArrayAttr attrs = ArrayAttr::get(builder.getContext(), 
caseValuesAttrs);
+
+  build(builder, result, value, defaultOperands, caseOperands, attrs,
+defaultDestination, caseDestinations);
+}
+
+///  ::= `[` (case (`,` case )* )? `]`
+///   ::= integer `:` bb-id (`(` ssa-use-and-type-list `)`)?
+static ParseResult parseSwitchFlatOpCases(
+OpAsmParser &parser, Type flagType, mlir::ArrayAttr &caseValues,
+SmallVectorImpl &caseDestinations,
+SmallVectorImpl>
+&caseOperands,
+SmallVectorImpl> &caseOperandTypes) {
+  if (failed(parser.parseLSquare()))
+return failure();
+  if (succeeded(parser.parseOptionalRSquare()))
+return success();
+  llvm::SmallVector values;
+
+  auto parseCase = [&]() {
+int64_t value = 0;
+if (failed(parser.parseInteger(value)))
+  return failure();
+
+values.push_back(cir::In

[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-13 Thread via cfe-commits

https://github.com/Andres-Salamanca updated 
https://github.com/llvm/llvm-project/pull/139154

>From f77464dbe1de51c89fbde5e5decfc2314cd7dba6 Mon Sep 17 00:00:00 2001
From: Andres Salamanca 
Date: Thu, 8 May 2025 15:39:49 -0500
Subject: [PATCH 1/3] Add support for FlattenCFG switch and introduce
 SwitchFlatOp

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  46 +++
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp   |  97 ++
 .../Dialect/Transforms/CIRCanonicalize.cpp|  15 +-
 .../lib/CIR/Dialect/Transforms/FlattenCFG.cpp | 235 ++-
 clang/test/CIR/IR/switch-flat.cir |  68 +
 clang/test/CIR/Transforms/switch.cir  | 278 ++
 6 files changed, 734 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/CIR/IR/switch-flat.cir
 create mode 100644 clang/test/CIR/Transforms/switch.cir

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 7ffa10464dcd3..914af6d1dc6bd 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -971,6 +971,52 @@ def SwitchOp : CIR_Op<"switch",
   }];
 }
 
+//===--===//
+// SwitchFlatOp
+//===--===//
+
+def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments,
+  Terminator]> {
+
+  let description = [{
+The `cir.switch.flat` operation is a region-less and simplified
+version of the `cir.switch`.
+It's representation is closer to LLVM IR dialect
+than the C/C++ language feature.
+  }];
+
+  let arguments = (ins
+CIR_IntType:$condition,
+Variadic:$defaultOperands,
+VariadicOfVariadic:$caseOperands,
+ArrayAttr:$case_values,
+DenseI32ArrayAttr:$case_operand_segments
+  );
+
+  let successors = (successor
+AnySuccessor:$defaultDestination,
+VariadicSuccessor:$caseDestinations
+  );
+
+  let assemblyFormat = [{
+$condition `:` type($condition) `,`
+$defaultDestination (`(` $defaultOperands^ `:` type($defaultOperands) `)`)?
+custom(ref(type($condition)), $case_values,
+  $caseDestinations, $caseOperands,
+  type($caseOperands))
+attr-dict
+  }];
+
+  let builders = [
+OpBuilder<(ins "mlir::Value":$condition,
+  "mlir::Block *":$defaultDestination,
+  "mlir::ValueRange":$defaultOperands,
+  CArg<"llvm::ArrayRef", "{}">:$caseValues,
+  CArg<"mlir::BlockRange", "{}">:$caseDestinations,
+  CArg<"llvm::ArrayRef", "{}">:$caseOperands)>
+  ];
+}
+
 
//===--===//
 // BrOp
 
//===--===//
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index b131edaf403ed..ca03013edb485 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -22,6 +22,7 @@
 #include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc"
 #include "clang/CIR/Dialect/IR/CIROpsEnums.cpp.inc"
 #include "clang/CIR/MissingFeatures.h"
+#include 
 
 using namespace mlir;
 using namespace cir;
@@ -962,6 +963,102 @@ bool 
cir::SwitchOp::isSimpleForm(llvm::SmallVectorImpl &cases) {
   });
 }
 
+//===--===//
+// SwitchFlatOp
+//===--===//
+
+void cir::SwitchFlatOp::build(OpBuilder &builder, OperationState &result,
+  Value value, Block *defaultDestination,
+  ValueRange defaultOperands,
+  ArrayRef caseValues,
+  BlockRange caseDestinations,
+  ArrayRef caseOperands) {
+
+  std::vector caseValuesAttrs;
+  for (auto &val : caseValues) {
+caseValuesAttrs.push_back(cir::IntAttr::get(value.getType(), val));
+  }
+  mlir::ArrayAttr attrs = ArrayAttr::get(builder.getContext(), 
caseValuesAttrs);
+
+  build(builder, result, value, defaultOperands, caseOperands, attrs,
+defaultDestination, caseDestinations);
+}
+
+///  ::= `[` (case (`,` case )* )? `]`
+///   ::= integer `:` bb-id (`(` ssa-use-and-type-list `)`)?
+static ParseResult parseSwitchFlatOpCases(
+OpAsmParser &parser, Type flagType, mlir::ArrayAttr &caseValues,
+SmallVectorImpl &caseDestinations,
+SmallVectorImpl>
+&caseOperands,
+SmallVectorImpl> &caseOperandTypes) {
+  if (failed(parser.parseLSquare()))
+return failure();
+  if (succeeded(parser.parseOptionalRSquare()))
+return success();
+  llvm::SmallVector values;
+
+  auto parseCase = [&]() {
+int64_t value = 0;
+if (failed(parser.parseInteger(value)))
+  return failure();
+
+values.push_back(cir::In

[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-13 Thread via cfe-commits

https://github.com/Andres-Salamanca updated 
https://github.com/llvm/llvm-project/pull/139154

>From f77464dbe1de51c89fbde5e5decfc2314cd7dba6 Mon Sep 17 00:00:00 2001
From: Andres Salamanca 
Date: Thu, 8 May 2025 15:39:49 -0500
Subject: [PATCH 1/4] Add support for FlattenCFG switch and introduce
 SwitchFlatOp

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  46 +++
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp   |  97 ++
 .../Dialect/Transforms/CIRCanonicalize.cpp|  15 +-
 .../lib/CIR/Dialect/Transforms/FlattenCFG.cpp | 235 ++-
 clang/test/CIR/IR/switch-flat.cir |  68 +
 clang/test/CIR/Transforms/switch.cir  | 278 ++
 6 files changed, 734 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/CIR/IR/switch-flat.cir
 create mode 100644 clang/test/CIR/Transforms/switch.cir

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 7ffa10464dcd3..914af6d1dc6bd 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -971,6 +971,52 @@ def SwitchOp : CIR_Op<"switch",
   }];
 }
 
+//===--===//
+// SwitchFlatOp
+//===--===//
+
+def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments,
+  Terminator]> {
+
+  let description = [{
+The `cir.switch.flat` operation is a region-less and simplified
+version of the `cir.switch`.
+It's representation is closer to LLVM IR dialect
+than the C/C++ language feature.
+  }];
+
+  let arguments = (ins
+CIR_IntType:$condition,
+Variadic:$defaultOperands,
+VariadicOfVariadic:$caseOperands,
+ArrayAttr:$case_values,
+DenseI32ArrayAttr:$case_operand_segments
+  );
+
+  let successors = (successor
+AnySuccessor:$defaultDestination,
+VariadicSuccessor:$caseDestinations
+  );
+
+  let assemblyFormat = [{
+$condition `:` type($condition) `,`
+$defaultDestination (`(` $defaultOperands^ `:` type($defaultOperands) `)`)?
+custom(ref(type($condition)), $case_values,
+  $caseDestinations, $caseOperands,
+  type($caseOperands))
+attr-dict
+  }];
+
+  let builders = [
+OpBuilder<(ins "mlir::Value":$condition,
+  "mlir::Block *":$defaultDestination,
+  "mlir::ValueRange":$defaultOperands,
+  CArg<"llvm::ArrayRef", "{}">:$caseValues,
+  CArg<"mlir::BlockRange", "{}">:$caseDestinations,
+  CArg<"llvm::ArrayRef", "{}">:$caseOperands)>
+  ];
+}
+
 
//===--===//
 // BrOp
 
//===--===//
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index b131edaf403ed..ca03013edb485 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -22,6 +22,7 @@
 #include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc"
 #include "clang/CIR/Dialect/IR/CIROpsEnums.cpp.inc"
 #include "clang/CIR/MissingFeatures.h"
+#include 
 
 using namespace mlir;
 using namespace cir;
@@ -962,6 +963,102 @@ bool 
cir::SwitchOp::isSimpleForm(llvm::SmallVectorImpl &cases) {
   });
 }
 
+//===--===//
+// SwitchFlatOp
+//===--===//
+
+void cir::SwitchFlatOp::build(OpBuilder &builder, OperationState &result,
+  Value value, Block *defaultDestination,
+  ValueRange defaultOperands,
+  ArrayRef caseValues,
+  BlockRange caseDestinations,
+  ArrayRef caseOperands) {
+
+  std::vector caseValuesAttrs;
+  for (auto &val : caseValues) {
+caseValuesAttrs.push_back(cir::IntAttr::get(value.getType(), val));
+  }
+  mlir::ArrayAttr attrs = ArrayAttr::get(builder.getContext(), 
caseValuesAttrs);
+
+  build(builder, result, value, defaultOperands, caseOperands, attrs,
+defaultDestination, caseDestinations);
+}
+
+///  ::= `[` (case (`,` case )* )? `]`
+///   ::= integer `:` bb-id (`(` ssa-use-and-type-list `)`)?
+static ParseResult parseSwitchFlatOpCases(
+OpAsmParser &parser, Type flagType, mlir::ArrayAttr &caseValues,
+SmallVectorImpl &caseDestinations,
+SmallVectorImpl>
+&caseOperands,
+SmallVectorImpl> &caseOperandTypes) {
+  if (failed(parser.parseLSquare()))
+return failure();
+  if (succeeded(parser.parseOptionalRSquare()))
+return success();
+  llvm::SmallVector values;
+
+  auto parseCase = [&]() {
+int64_t value = 0;
+if (failed(parser.parseInteger(value)))
+  return failure();
+
+values.push_back(cir::In

[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-13 Thread via cfe-commits


@@ -171,6 +171,232 @@ class CIRScopeOpFlattening : public 
mlir::OpRewritePattern {
   }
 };
 
+class CIRSwitchOpFlattening : public mlir::OpRewritePattern {
+public:
+  using OpRewritePattern::OpRewritePattern;
+
+  inline void rewriteYieldOp(mlir::PatternRewriter &rewriter,
+ cir::YieldOp yieldOp,
+ mlir::Block *destination) const {
+rewriter.setInsertionPoint(yieldOp);
+rewriter.replaceOpWithNewOp(yieldOp, yieldOp.getOperands(),
+   destination);
+  }
+
+  // Return the new defaultDestination block.
+  Block *condBrToRangeDestination(cir::SwitchOp op,
+  mlir::PatternRewriter &rewriter,
+  mlir::Block *rangeDestination,
+  mlir::Block *defaultDestination,
+  const APInt &lowerBound,
+  const APInt &upperBound) const {
+assert(lowerBound.sle(upperBound) && "Invalid range");
+mlir::Block *resBlock = rewriter.createBlock(defaultDestination);
+cir::IntType sIntType = cir::IntType::get(op.getContext(), 32, true);
+cir::IntType uIntType = cir::IntType::get(op.getContext(), 32, false);
+
+cir::ConstantOp rangeLength = rewriter.create(
+op.getLoc(), cir::IntAttr::get(sIntType, upperBound - lowerBound));
+
+cir::ConstantOp lowerBoundValue = rewriter.create(
+op.getLoc(), cir::IntAttr::get(sIntType, lowerBound));
+cir::BinOp diffValue =
+rewriter.create(op.getLoc(), sIntType, cir::BinOpKind::Sub,
+op.getCondition(), lowerBoundValue);
+
+// Use unsigned comparison to check if the condition is in the range.
+cir::CastOp uDiffValue = rewriter.create(
+op.getLoc(), uIntType, CastKind::integral, diffValue);
+cir::CastOp uRangeLength = rewriter.create(
+op.getLoc(), uIntType, CastKind::integral, rangeLength);
+
+cir::CmpOp cmpResult = rewriter.create(
+op.getLoc(), cir::BoolType::get(op.getContext()), cir::CmpOpKind::le,
+uDiffValue, uRangeLength);
+rewriter.create(op.getLoc(), cmpResult, rangeDestination,
+   defaultDestination);
+return resBlock;
+  }
+
+  mlir::LogicalResult
+  matchAndRewrite(cir::SwitchOp op,
+  mlir::PatternRewriter &rewriter) const override {
+llvm::SmallVector cases;
+op.collectCases(cases);
+
+// Empty switch statement: just erase it.
+if (cases.empty()) {
+  rewriter.eraseOp(op);
+  return mlir::success();
+}
+
+// Create exit block from the next node of cir.switch op.
+mlir::Block *exitBlock = rewriter.splitBlock(
+rewriter.getBlock(), op->getNextNode()->getIterator());
+
+// We lower cir.switch op in the following process:
+// 1. Inline the region from the switch op after switch op.
+// 2. Traverse each cir.case op:
+//a. Record the entry block, block arguments and condition for every
+//case. b. Inline the case region after the case op.
+// 3. Replace the empty cir.switch.op with the new cir.switchflat op by the
+//recorded block and conditions.
+
+// inline everything from switch body between the switch op and the exit
+// block.
+{
+  cir::YieldOp switchYield = nullptr;
+  // Clear switch operation.
+  for (auto &block : llvm::make_early_inc_range(op.getBody().getBlocks()))
+if (auto yieldOp = dyn_cast(block.getTerminator()))
+  switchYield = yieldOp;
+
+  assert(!op.getBody().empty());
+  mlir::Block *originalBlock = op->getBlock();
+  mlir::Block *swopBlock =
+  rewriter.splitBlock(originalBlock, op->getIterator());
+  rewriter.inlineRegionBefore(op.getBody(), exitBlock);
+
+  if (switchYield)
+rewriteYieldOp(rewriter, switchYield, exitBlock);
+
+  rewriter.setInsertionPointToEnd(originalBlock);
+  rewriter.create(op.getLoc(), swopBlock);
+}
+
+// Allocate required data structures (disconsider default case in
+// vectors).
+llvm::SmallVector caseValues;
+llvm::SmallVector caseDestinations;
+llvm::SmallVector caseOperands;
+
+llvm::SmallVector> rangeValues;
+llvm::SmallVector rangeDestinations;
+llvm::SmallVector rangeOperands;
+
+// Initialize default case as optional.
+mlir::Block *defaultDestination = exitBlock;
+mlir::ValueRange defaultOperands = exitBlock->getArguments();
+
+// Digest the case statements values and bodies.
+for (auto caseOp : cases) {
+  mlir::Region ®ion = caseOp.getCaseRegion();
+
+  // Found default case: save destination and operands.
+  switch (caseOp.getKind()) {
+  case cir::CaseOpKind::Default:
+defaultDestination = ®ion.front();
+defaultOperands = defaultDestination->getArguments();
+break;
+  case cir::CaseOpKind::Range:
+ 

[clang] [Clang] Remove workaround for libstdc++4.7 (PR #139693)

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

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

The changes should come with a release note mentioning that we've removed the 
hack because it's no longer a supported libstdc++ (for the few users still 
relying on the hack).

Otherwise, LGTM!

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


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

2025-05-13 Thread Jeremy Morse via cfe-commits

jmorse wrote:

It sounds like there's agreement that the "before" approach was 
better/acceptable, i.e. having a CU-level variable that refers by 
`DW_AT_specification` to a variable in the class type. Doing so would also 
avoid the customisation for vtable-addresses in the latest patch with the 
`createGlobalVariableVTableDIE` method, which'd be neater. With that in mind, 
we'll head back in that direction.

It's also worth noting that this has spawned some DWARF issues such as 
https://dwarfstd.org/issues/250506.2.html , but I feel that's "future work".

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


[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

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


@@ -238,6 +238,25 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 else
   Builder.defineMacro("__riscv_32e");
   }
+
+  if (Opts.CFProtectionBranch) {
+auto Scheme = Opts.getCFBranchLabelScheme();
+if (Scheme == CFBranchLabelSchemeKind::Default)
+  Scheme = getDefaultCFBranchLabelScheme();
+
+Builder.defineMacro("__riscv_landing_pad");
+switch (Scheme) {
+case CFBranchLabelSchemeKind::Unlabeled:
+  Builder.defineMacro("__riscv_landing_pad_unlabeled");
+  break;
+case CFBranchLabelSchemeKind::FuncSig:
+  Builder.defineMacro("__riscv_landing_pad_func_sig");
+  break;

mylai-mtk wrote:

Used Option 1 to drop the func-sig part for now

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


[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

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

https://github.com/mylai-mtk updated 
https://github.com/llvm/llvm-project/pull/109600

>From 3bb0b659009ade3dcd04d7bbb88b57e7b072fac5 Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai 
Date: Fri, 10 May 2024 14:16:59 +0800
Subject: [PATCH 1/7] [clang][RISCV] Add Zicfilp CFI scheme preprocessor macros

These macros allow assembly files to know which CFI label to use when the target
has Zicfilp enabled.
---
 clang/lib/Basic/Targets/RISCV.cpp | 19 +
 .../test/CodeGen/RISCV/riscv-cf-protection.c  | 79 +++
 2 files changed, 98 insertions(+)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index b4aa3206fcfab..f00fa6bf3904f 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -238,6 +238,25 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 else
   Builder.defineMacro("__riscv_32e");
   }
+
+  if (Opts.CFProtectionBranch) {
+auto Scheme = Opts.getCFBranchLabelScheme();
+if (Scheme == CFBranchLabelSchemeKind::Default)
+  Scheme = getDefaultCFBranchLabelScheme();
+
+Builder.defineMacro("__riscv_landing_pad", "1");
+switch (Scheme) {
+case CFBranchLabelSchemeKind::Unlabeled:
+  Builder.defineMacro("__riscv_landing_pad_unlabeled", "1");
+  break;
+case CFBranchLabelSchemeKind::FuncSig:
+  Builder.defineMacro("__riscv_landing_pad_func_sig", "1");
+  break;
+case CFBranchLabelSchemeKind::Default:
+  llvm_unreachable("default cf-branch-label scheme should already be "
+   "transformed to other scheme");
+}
+  }
 }
 
 static constexpr int NumRVVBuiltins =
diff --git a/clang/test/CodeGen/RISCV/riscv-cf-protection.c 
b/clang/test/CodeGen/RISCV/riscv-cf-protection.c
index 3a9855a3d2f01..db7b65061658c 100644
--- a/clang/test/CodeGen/RISCV/riscv-cf-protection.c
+++ b/clang/test/CodeGen/RISCV/riscv-cf-protection.c
@@ -1,71 +1,143 @@
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=unlabeled -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,UNLABELED-FLAG %s
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=func-sig -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,FUNC-SIG-MACRO %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=func-sig -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,FUNC-SIG-FLAG %s
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=unlabeled -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck \
+// RUN: --check-prefixes=NO-MACRO,UNLABELED-SCHEME-UNUSED %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=unlabeled -S \
 // RUN: -emit-llvm %s -o - 2>&1 | FileCheck \
 // RUN: --check-prefixes=NO-FLAG,UNLABELED-SCHEME-UNUSED %s
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=func-sig -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck \
+// RUN: --check-prefixes=NO-MACRO,FUNC-SIG-SCHEME-UNUSED %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=func-sig -S \
 // RUN: -emit-llvm %s -o - 2>&1 | FileCheck \
 // RUN: --check-prefixes=NO-FLAG,FUNC-SIG-SCHEME-UNUSED %s
 
+// RUN: %clang --target=riscv32 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
 // RUN: %clang --target=riscv32 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=unlabeled -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,UNLABELED-FLAG %s
 
+// RUN: %clang --target=riscv32 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=func-sig -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,FUNC-SIG-MACRO %s
+
 // RUN: %clang --target=riscv32 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=func-sig -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,FUNC-SIG-FLAG %s
 
+// RUN: %clang --target=riscv32 -mcf-branch-label-scheme=unlabeled -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck \
+// RUN: --check-prefixes=NO-MACRO,UNLABELED-SCHEME-UNUSED %s
+
 // RUN: %clang --target=riscv32 -mcf-branch-label-sch

[clang] [lld] [llvm] [mlir] [NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates (PR #137393)

2025-05-13 Thread Longsheng Mou via cfe-commits

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


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


[clang] [clang] Save ShuffleVectorExpr args as ConstantExpr (PR #139709)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Timm Baeder (tbaederr)


Changes

The passed indices have to be constant integers anyway, which we verify before 
creating the ShuffleVectorExpr. Use the value we create there and save the 
indices using a ConstantExpr instead. This way, we don't have to evaluate the 
args every time we call getShuffleMaskIdx().

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


5 Files Affected:

- (modified) clang/include/clang/AST/Expr.h (+4-2) 
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1-1) 
- (modified) clang/lib/AST/ExprConstant.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+11-11) 


``diff
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index a83320a7ddec2..1e6749dda71fe 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4566,9 +4566,11 @@ class ShuffleVectorExpr : public Expr {
 
   void setExprs(const ASTContext &C, ArrayRef Exprs);
 
-  llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const {
+  llvm::APSInt getShuffleMaskIdx(unsigned N) const {
 assert((N < NumExprs - 2) && "Shuffle idx out of range!");
-return getExpr(N+2)->EvaluateKnownConstInt(Ctx);
+assert(isa(getExpr(N + 2)) &&
+   "Index expression must be a ConstantExpr");
+return cast(getExpr(N + 2))->getAPValueResult().getInt();
   }
 
   // Iterators
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c7fb5e8466686..2702fc87b8235 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -3883,7 +3883,7 @@ bool Compiler::VisitShuffleVectorExpr(const 
ShuffleVectorExpr *E) {
   return false;
   }
   for (unsigned I = 0; I != NumOutputElems; ++I) {
-APSInt ShuffleIndex = E->getShuffleMaskIdx(Ctx.getASTContext(), I);
+APSInt ShuffleIndex = E->getShuffleMaskIdx(I);
 assert(ShuffleIndex >= -1);
 if (ShuffleIndex == -1)
   return this->emitInvalidShuffleVectorIndex(I, E);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 500d43accb082..251508eb5f4c0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11558,7 +11558,7 @@ static bool handleVectorShuffle(EvalInfo &Info, const 
ShuffleVectorExpr *E,
   unsigned const TotalElementsInInputVector1 = VecVal1.getVectorLength();
   unsigned const TotalElementsInInputVector2 = VecVal2.getVectorLength();
 
-  APSInt IndexVal = E->getShuffleMaskIdx(Info.Ctx, EltNum);
+  APSInt IndexVal = E->getShuffleMaskIdx(EltNum);
   int64_t index = IndexVal.getExtValue();
   // The spec says that -1 should be treated as undef for optimizations,
   // but in constexpr we'd have to produce an APValue::Indeterminate,
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 6765008c99c4a..7fe3a1660326b 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1906,7 +1906,7 @@ Value 
*ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
 
   SmallVector Indices;
   for (unsigned i = 2; i < E->getNumSubExprs(); ++i) {
-llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
+llvm::APSInt Idx = E->getShuffleMaskIdx(i - 2);
 // Check for -1 and output it as undef in the IR.
 if (Idx.isSigned() && Idx.isAllOnes())
   Indices.push_back(-1);
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5a0cec3d112db..969709927ca8f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5342,29 +5342,29 @@ ExprResult Sema::BuiltinShuffleVector(CallExpr 
*TheCall) {
   }
 
   for (unsigned i = 2; i < TheCall->getNumArgs(); i++) {
-if (TheCall->getArg(i)->isTypeDependent() ||
-TheCall->getArg(i)->isValueDependent())
+Expr *Arg = TheCall->getArg(i);
+if (Arg->isTypeDependent() || Arg->isValueDependent())
   continue;
 
 std::optional Result;
-if (!(Result = TheCall->getArg(i)->getIntegerConstantExpr(Context)))
+if (!(Result = Arg->getIntegerConstantExpr(Context)))
   return ExprError(Diag(TheCall->getBeginLoc(),
 diag::err_shufflevector_nonconstant_argument)
-   << TheCall->getArg(i)->getSourceRange());
+   << Arg->getSourceRange());
 
 // Allow -1 which will be translated to undef in the IR.
 if (Result->isSigned() && Result->isAllOnes())
-  continue;
-
-if (Result->getActiveBits() > 64 ||
-Result->getZExtValue() >= numElements * 2)
+  ;
+else if (Result->getActiveBits() > 64 ||
+ Result->getZExtValue() >= numElements * 2)
   return ExprError(Diag(TheCall->getBeginLoc(),
 diag::err_shufflevector_argument_too_large)
-   << TheCall->getArg(i)->getSource

[clang] [Clang] Remove workaround for libstdc++4.7 (PR #139693)

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

AaronBallman wrote:

> We document libstdc++4.8 as the minimum supported version

It took me quite a while to find that documentation, we probably should make 
this a bit more prominent from the getting started page at some point: 
https://github.com/llvm/llvm-project/blob/c14acb74423a577e10bbb635109851742e77444f/clang/docs/Toolchain.rst?plain=1#L343

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


[clang] c14acb7 - [clang][bytecode] Save Immediate bit in Function (#139671)

2025-05-13 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-05-13T12:56:08+02:00
New Revision: c14acb74423a577e10bbb635109851742e77444f

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

LOG: [clang][bytecode] Save Immediate bit in Function (#139671)

Otherwise, we have to look at the FunctionDecl at every function call.

Added: 


Modified: 
clang/lib/AST/ByteCode/Function.cpp
clang/lib/AST/ByteCode/Function.h
clang/lib/AST/ByteCode/Interp.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Function.cpp 
b/clang/lib/AST/ByteCode/Function.cpp
index 8a4e089d9ecd0..d3e7e1ffc63d5 100644
--- a/clang/lib/AST/ByteCode/Function.cpp
+++ b/clang/lib/AST/ByteCode/Function.cpp
@@ -22,10 +22,12 @@ Function::Function(Program &P, FunctionDeclTy Source, 
unsigned ArgSize,
bool HasThisPointer, bool HasRVO, bool 
IsLambdaStaticInvoker)
 : P(P), Kind(FunctionKind::Normal), Source(Source), ArgSize(ArgSize),
   ParamTypes(std::move(ParamTypes)), Params(std::move(Params)),
-  ParamOffsets(std::move(ParamOffsets)), HasThisPointer(HasThisPointer),
-  HasRVO(HasRVO) {
+  ParamOffsets(std::move(ParamOffsets)), IsValid(false),
+  IsFullyCompiled(false), HasThisPointer(HasThisPointer), HasRVO(HasRVO),
+  Defined(false) {
   if (const auto *F = dyn_cast(Source)) {
 Variadic = F->isVariadic();
+Immediate = F->isImmediateFunction();
 if (const auto *CD = dyn_cast(F)) {
   Virtual = CD->isVirtual();
   Kind = FunctionKind::Ctor;
@@ -40,7 +42,13 @@ Function::Function(Program &P, FunctionDeclTy Source, 
unsigned ArgSize,
 Kind = FunctionKind::LambdaCallOperator;
   else if (MD->isCopyAssignmentOperator() || 
MD->isMoveAssignmentOperator())
 Kind = FunctionKind::CopyOrMoveOperator;
+} else {
+  Virtual = false;
 }
+  } else {
+Variadic = false;
+Virtual = false;
+Immediate = false;
   }
 }
 

diff  --git a/clang/lib/AST/ByteCode/Function.h 
b/clang/lib/AST/ByteCode/Function.h
index 436574dd3a4c7..45a1c1bf9f839 100644
--- a/clang/lib/AST/ByteCode/Function.h
+++ b/clang/lib/AST/ByteCode/Function.h
@@ -155,6 +155,7 @@ class Function final {
 
   /// Checks if the function is virtual.
   bool isVirtual() const { return Virtual; };
+  bool isImmediate() const { return Immediate; }
 
   /// Checks if the function is a constructor.
   bool isConstructor() const { return Kind == FunctionKind::Ctor; }
@@ -276,22 +277,32 @@ class Function final {
   /// List of parameter offsets.
   llvm::SmallVector ParamOffsets;
   /// Flag to indicate if the function is valid.
-  bool IsValid = false;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned IsValid : 1;
   /// Flag to indicate if the function is done being
   /// compiled to bytecode.
-  bool IsFullyCompiled = false;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned IsFullyCompiled : 1;
   /// Flag indicating if this function takes the this pointer
   /// as the first implicit argument
-  bool HasThisPointer = false;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned HasThisPointer : 1;
   /// Whether this function has Return Value Optimization, i.e.
   /// the return value is constructed in the caller's stack frame.
   /// This is done for functions that return non-primive values.
-  bool HasRVO = false;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned HasRVO : 1;
   /// If we've already compiled the function's body.
-  bool HasBody = false;
-  bool Defined = false;
-  bool Variadic = false;
-  bool Virtual = false;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned HasBody : 1;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned Defined : 1;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned Variadic : 1;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned Virtual : 1;
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned Immediate : 1;
 
 public:
   /// Dumps the disassembled bytecode to \c llvm::errs().

diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 91930c016c985..bc860185fea21 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1501,7 +1501,7 @@ bool Call(InterpState &S, CodePtr OpPC, const Function 
*Func,
   InterpFrame *FrameBefore = S.Current;
   S.Current = NewFrame.get();
 
-  InterpStateCCOverride CCOverride(S, Func->getDecl()->isImmediateFunction());
+  InterpStateCCOverride CCOverride(S, Func->isImmediate());
   // Note that we cannot assert(CallResult.hasValue()) here since
   // Ret() above only sets the APValue if the curent frame doesn't
   // have a caller set.



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


[clang] [clang][bytecode] Save Immediate bit in Function (PR #139671)

2025-05-13 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


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


[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

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

https://github.com/mylai-mtk updated 
https://github.com/llvm/llvm-project/pull/109600



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [clang] Save ShuffleVectorExpr args as ConstantExpr (PR #139709)

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

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

The passed indices have to be constant integers anyway, which we verify before 
creating the ShuffleVectorExpr. Use the value we create there and save the 
indices using a ConstantExpr instead. This way, we don't have to evaluate the 
args every time we call getShuffleMaskIdx().

>From d9e99ff9e1d2a49161e4b583aec72025ff0f9106 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 13 May 2025 11:59:56 +0200
Subject: [PATCH] [clang] Save ShuffleVectorExpr args as ConstantExpr

The passed indices have to be constant integers anyway, which we verify
before creating the ShuffleVectorExpr. Use the value we create there and
save the indices using a ConstantExpr instead. This way, we don't have
to evaluate the args every time we call getShuffleMaskIdx().
---
 clang/include/clang/AST/Expr.h  |  6 --
 clang/lib/AST/ByteCode/Compiler.cpp |  2 +-
 clang/lib/AST/ExprConstant.cpp  |  2 +-
 clang/lib/CodeGen/CGExprScalar.cpp  |  2 +-
 clang/lib/Sema/SemaChecking.cpp | 22 +++---
 5 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index a83320a7ddec2..1e6749dda71fe 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4566,9 +4566,11 @@ class ShuffleVectorExpr : public Expr {
 
   void setExprs(const ASTContext &C, ArrayRef Exprs);
 
-  llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const {
+  llvm::APSInt getShuffleMaskIdx(unsigned N) const {
 assert((N < NumExprs - 2) && "Shuffle idx out of range!");
-return getExpr(N+2)->EvaluateKnownConstInt(Ctx);
+assert(isa(getExpr(N + 2)) &&
+   "Index expression must be a ConstantExpr");
+return cast(getExpr(N + 2))->getAPValueResult().getInt();
   }
 
   // Iterators
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c7fb5e8466686..2702fc87b8235 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -3883,7 +3883,7 @@ bool Compiler::VisitShuffleVectorExpr(const 
ShuffleVectorExpr *E) {
   return false;
   }
   for (unsigned I = 0; I != NumOutputElems; ++I) {
-APSInt ShuffleIndex = E->getShuffleMaskIdx(Ctx.getASTContext(), I);
+APSInt ShuffleIndex = E->getShuffleMaskIdx(I);
 assert(ShuffleIndex >= -1);
 if (ShuffleIndex == -1)
   return this->emitInvalidShuffleVectorIndex(I, E);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 500d43accb082..251508eb5f4c0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11558,7 +11558,7 @@ static bool handleVectorShuffle(EvalInfo &Info, const 
ShuffleVectorExpr *E,
   unsigned const TotalElementsInInputVector1 = VecVal1.getVectorLength();
   unsigned const TotalElementsInInputVector2 = VecVal2.getVectorLength();
 
-  APSInt IndexVal = E->getShuffleMaskIdx(Info.Ctx, EltNum);
+  APSInt IndexVal = E->getShuffleMaskIdx(EltNum);
   int64_t index = IndexVal.getExtValue();
   // The spec says that -1 should be treated as undef for optimizations,
   // but in constexpr we'd have to produce an APValue::Indeterminate,
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 6765008c99c4a..7fe3a1660326b 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1906,7 +1906,7 @@ Value 
*ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
 
   SmallVector Indices;
   for (unsigned i = 2; i < E->getNumSubExprs(); ++i) {
-llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
+llvm::APSInt Idx = E->getShuffleMaskIdx(i - 2);
 // Check for -1 and output it as undef in the IR.
 if (Idx.isSigned() && Idx.isAllOnes())
   Indices.push_back(-1);
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5a0cec3d112db..969709927ca8f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5342,29 +5342,29 @@ ExprResult Sema::BuiltinShuffleVector(CallExpr 
*TheCall) {
   }
 
   for (unsigned i = 2; i < TheCall->getNumArgs(); i++) {
-if (TheCall->getArg(i)->isTypeDependent() ||
-TheCall->getArg(i)->isValueDependent())
+Expr *Arg = TheCall->getArg(i);
+if (Arg->isTypeDependent() || Arg->isValueDependent())
   continue;
 
 std::optional Result;
-if (!(Result = TheCall->getArg(i)->getIntegerConstantExpr(Context)))
+if (!(Result = Arg->getIntegerConstantExpr(Context)))
   return ExprError(Diag(TheCall->getBeginLoc(),
 diag::err_shufflevector_nonconstant_argument)
-   << TheCall->getArg(i)->getSourceRange());
+   << Arg->getSourceRange());
 
 // Allow -1 which will be translated to undef in the IR.
 if (Result->isSigned() && Result->isAllOne

[clang] [clang] Save ShuffleVectorExpr args as ConstantExpr (PR #139709)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

The passed indices have to be constant integers anyway, which we verify before 
creating the ShuffleVectorExpr. Use the value we create there and save the 
indices using a ConstantExpr instead. This way, we don't have to evaluate the 
args every time we call getShuffleMaskIdx().

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


5 Files Affected:

- (modified) clang/include/clang/AST/Expr.h (+4-2) 
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1-1) 
- (modified) clang/lib/AST/ExprConstant.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+11-11) 


``diff
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index a83320a7ddec2..1e6749dda71fe 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4566,9 +4566,11 @@ class ShuffleVectorExpr : public Expr {
 
   void setExprs(const ASTContext &C, ArrayRef Exprs);
 
-  llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const {
+  llvm::APSInt getShuffleMaskIdx(unsigned N) const {
 assert((N < NumExprs - 2) && "Shuffle idx out of range!");
-return getExpr(N+2)->EvaluateKnownConstInt(Ctx);
+assert(isa(getExpr(N + 2)) &&
+   "Index expression must be a ConstantExpr");
+return cast(getExpr(N + 2))->getAPValueResult().getInt();
   }
 
   // Iterators
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c7fb5e8466686..2702fc87b8235 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -3883,7 +3883,7 @@ bool Compiler::VisitShuffleVectorExpr(const 
ShuffleVectorExpr *E) {
   return false;
   }
   for (unsigned I = 0; I != NumOutputElems; ++I) {
-APSInt ShuffleIndex = E->getShuffleMaskIdx(Ctx.getASTContext(), I);
+APSInt ShuffleIndex = E->getShuffleMaskIdx(I);
 assert(ShuffleIndex >= -1);
 if (ShuffleIndex == -1)
   return this->emitInvalidShuffleVectorIndex(I, E);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 500d43accb082..251508eb5f4c0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11558,7 +11558,7 @@ static bool handleVectorShuffle(EvalInfo &Info, const 
ShuffleVectorExpr *E,
   unsigned const TotalElementsInInputVector1 = VecVal1.getVectorLength();
   unsigned const TotalElementsInInputVector2 = VecVal2.getVectorLength();
 
-  APSInt IndexVal = E->getShuffleMaskIdx(Info.Ctx, EltNum);
+  APSInt IndexVal = E->getShuffleMaskIdx(EltNum);
   int64_t index = IndexVal.getExtValue();
   // The spec says that -1 should be treated as undef for optimizations,
   // but in constexpr we'd have to produce an APValue::Indeterminate,
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 6765008c99c4a..7fe3a1660326b 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1906,7 +1906,7 @@ Value 
*ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
 
   SmallVector Indices;
   for (unsigned i = 2; i < E->getNumSubExprs(); ++i) {
-llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
+llvm::APSInt Idx = E->getShuffleMaskIdx(i - 2);
 // Check for -1 and output it as undef in the IR.
 if (Idx.isSigned() && Idx.isAllOnes())
   Indices.push_back(-1);
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5a0cec3d112db..969709927ca8f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5342,29 +5342,29 @@ ExprResult Sema::BuiltinShuffleVector(CallExpr 
*TheCall) {
   }
 
   for (unsigned i = 2; i < TheCall->getNumArgs(); i++) {
-if (TheCall->getArg(i)->isTypeDependent() ||
-TheCall->getArg(i)->isValueDependent())
+Expr *Arg = TheCall->getArg(i);
+if (Arg->isTypeDependent() || Arg->isValueDependent())
   continue;
 
 std::optional Result;
-if (!(Result = TheCall->getArg(i)->getIntegerConstantExpr(Context)))
+if (!(Result = Arg->getIntegerConstantExpr(Context)))
   return ExprError(Diag(TheCall->getBeginLoc(),
 diag::err_shufflevector_nonconstant_argument)
-   << TheCall->getArg(i)->getSourceRange());
+   << Arg->getSourceRange());
 
 // Allow -1 which will be translated to undef in the IR.
 if (Result->isSigned() && Result->isAllOnes())
-  continue;
-
-if (Result->getActiveBits() > 64 ||
-Result->getZExtValue() >= numElements * 2)
+  ;
+else if (Result->getActiveBits() > 64 ||
+ Result->getZExtValue() >= numElements * 2)
   return ExprError(Diag(TheCall->getBeginLoc(),
 diag::err_shufflevector_argument_too_large)
-   << TheCall->getArg(i)->getSourceRange())

[clang] [clang][bytecode][NFC] Delete DynamicAllocator copy/move ctors (PR #139710)

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

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

They should never be needed.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [clang][bytecode][NFC] Delete DynamicAllocator copy/move ctors (PR #139710)

2025-05-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

They should never be needed.

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


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/DynamicAllocator.h (+2) 


``diff
diff --git a/clang/lib/AST/ByteCode/DynamicAllocator.h 
b/clang/lib/AST/ByteCode/DynamicAllocator.h
index 51829403d7322..cff09bf4f6a6e 100644
--- a/clang/lib/AST/ByteCode/DynamicAllocator.h
+++ b/clang/lib/AST/ByteCode/DynamicAllocator.h
@@ -59,6 +59,8 @@ class DynamicAllocator final {
 
 public:
   DynamicAllocator() = default;
+  DynamicAllocator(DynamicAllocator &) = delete;
+  DynamicAllocator(DynamicAllocator &&) = delete;
   ~DynamicAllocator();
 
   void cleanup();

``




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


[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-13 Thread Donát Nagy via cfe-commits


@@ -3411,12 +3411,12 @@ 
PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
 }
 
 void BugReporter::EmitBasicReport(const Decl *DeclWithIssue,
-  const CheckerBase *Checker, StringRef Name,
+  const CheckerFrontend *CP, StringRef Name,

NagyDonat wrote:

Ok, then I'll do so.

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


[clang] [clang] Save ShuffleVectorExpr args as ConstantExpr (PR #139709)

2025-05-13 Thread via cfe-commits

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

LGTM but it looks like some unit tests still need updating.

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


[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-13 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat updated 
https://github.com/llvm/llvm-project/pull/139256

From 3bead14691a29482705c76951eaed176bfbfc996 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Thu, 8 May 2025 18:46:41 +0200
Subject: [PATCH 1/2] [analyzer][NFC] Introduce framework for checker families

The checker classes (i.e. classes derived from `CheckerBase` via the
utility template `Checker<...>`) act as intermediates between the user
and the analyzer engine, so they have two interfaces:
- On the frontend side, they have a public name, can be enabled or
  disabled, can accept checker options and can be reported as the source
  of bug reports.
- On the backend side, they can handle various checker callbacks and
  they "leave a mark" on the `ExplodedNode`s that are created by them.
  (These `ProgramPointTag` marks are internal: they appear in debug logs
  and can be queried by checker logic; but the user doesn't see them.)

In a significant majority of the checkers there is 1:1 correspondence
between these sides, but there are also many checker classes where
several related user-facing checkers share the same backend class.
Historically each of these "multi-part checker" classes had its own
hacks to juggle its multiple names, which led to lots of ugliness like
lazy initialization of `mutable std::unique_ptr` members and
redundant data members (when a checker used its custom `CheckNames`
array and ignored the inherited single `Name`).

My recent commit 27099982da2f5a6c2d282d6b385e79d080669546 tried to
unify and standardize these existing solutions to get rid of some of the
technical debt, but it still used enum values to identify the checker
parts within a "multi-part" checker class, which led to some ugliness.

This commit introduces a new framework which takes a more direct,
object-oriented approach: instead of identifying checker parts with
`{parent checker object, index of part}` pairs, the parts of a
multi-part checker become stand-alone objects that store their own name
(and enabled/disabled status) as a data member.

This is implemented by separating the functionality of `CheckerBase`
into two new classes: `CheckerFrontend` and `CheckerBackend`. The name
`CheckerBase` is kept (as a class derived from both `CheckerFrontend`
and `CheckerBackend`), so "simple" checkers that use `CheckerBase` and
`Checker<...>` continues to work without changes. However we also get
first-class support for the "many frontends - one backend" situation:
- The class `CheckerFamily<...>` works exactly like `Checker<...>` but
  inherits from `CheckerBackend` instead of `CheckerBase`, so it won't
  have a superfluous single `Name` member.
- Classes deriving from `CheckerFamily` can freely own multiple
  `CheckerFrontend` data members, which are enabled within the
  registration methods corresponding to their name and can be used to
  initialize the `BugType`s that they can emit.

In this scheme each `CheckerFamily` needs to override the pure virtual
method `ProgramPointTag::getTagDescription()` which returns a string
which represents that class for debugging purposes. (Previously this
used the name of one arbitrary sub-checker, which was passable for
debugging purposes, but not too elegant.)

I'm planning to implement follow-up commits that convert all the
"multi-part" checkers to this `CheckerFamily` framework.
---
 clang/include/clang/Analysis/ProgramPoint.h   |   4 +-
 .../Core/BugReporter/BugReporter.h|   7 +-
 .../StaticAnalyzer/Core/BugReporter/BugType.h |  44 +++---
 .../clang/StaticAnalyzer/Core/Checker.h   | 132 ++
 .../StaticAnalyzer/Core/CheckerManager.h  |  80 ---
 .../Checkers/DivZeroChecker.cpp   |  34 +++--
 .../Checkers/ObjCSelfInitChecker.cpp  |   2 +-
 .../Checkers/VirtualCallChecker.cpp   |  29 ++--
 clang/lib/StaticAnalyzer/Core/BugReporter.cpp |   4 +-
 clang/lib/StaticAnalyzer/Core/Checker.cpp |  14 +-
 .../StaticAnalyzer/Core/CheckerManager.cpp|  22 +--
 11 files changed, 180 insertions(+), 192 deletions(-)

diff --git a/clang/include/clang/Analysis/ProgramPoint.h 
b/clang/include/clang/Analysis/ProgramPoint.h
index c40aa3d8ffb72..d81b8e845cb48 100644
--- a/clang/include/clang/Analysis/ProgramPoint.h
+++ b/clang/include/clang/Analysis/ProgramPoint.h
@@ -40,8 +40,8 @@ class ProgramPointTag {
   ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
   virtual ~ProgramPointTag();
 
-  /// The description of this program point which will be displayed when the
-  /// ExplodedGraph is dumped in DOT format for debugging.
+  /// The description of this program point which will be dumped for debugging
+  /// purposes. Do not use in user-facing output!
   virtual StringRef getTagDescription() const = 0;
 
   /// Used to implement 'isKind' in subclasses.
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 8e1d25b3eef

[clang] [C] Add -Wtentative-definition-compat (PR #137967)

2025-05-13 Thread via cfe-commits

asmok-g wrote:

Or even simpler:
```
extern const int x;
const int x = 0;
```

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


[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-13 Thread Donát Nagy via cfe-commits


@@ -3411,12 +3411,12 @@ 
PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
 }
 
 void BugReporter::EmitBasicReport(const Decl *DeclWithIssue,
-  const CheckerBase *Checker, StringRef Name,
+  const CheckerFrontend *CP, StringRef Name,

NagyDonat wrote:

Oops, I forgot to push the fixup commit 
https://github.com/llvm/llvm-project/pull/139256/commits/23d128c05699489e3c06cd299ea1863e15720984
  which changes the variable name to `CF` for `CheckerFrontend`. (By the way 
`CP` comes from an old draft version of this change when I was using the class 
name `CheckerPart`.)

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


[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-13 Thread Donát Nagy via cfe-commits


@@ -50,11 +50,11 @@ bool CheckerManager::hasPathSensitiveCheckers() const {
 }
 
 void CheckerManager::reportInvalidCheckerOptionValue(
-const CheckerBase *C, CheckerPartIdx Idx, StringRef OptionName,
+const CheckerFrontend *CP, StringRef OptionName,

NagyDonat wrote:

https://github.com/llvm/llvm-project/pull/139256/commits/23d128c05699489e3c06cd299ea1863e15720984
 should fix all variables named `CP`; see my comment above for details.

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


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

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

https://github.com/CarlosAlbertoEnciso updated 
https://github.com/llvm/llvm-project/pull/130255



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] Revert "[Clang][Sema] Handle invalid variable template specialization whose type depends on itself (#134522)" (PR #139539)

2025-05-13 Thread Yanzuo Liu via cfe-commits

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


[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-13 Thread Donát Nagy via cfe-commits


@@ -56,11 +54,11 @@ static const Expr *getDenomExpr(const ExplodedNode *N) {
 
 void DivZeroChecker::reportBug(StringRef Msg, ProgramStateRef StateZero,
CheckerContext &C) const {
-  if (!isPartEnabled(DivideZeroChecker))
+  if (!DivideZeroChecker.isEnabled())
 return;
   if (ExplodedNode *N = C.generateErrorNode(StateZero)) {
-auto R = std::make_unique(
-BugTypes[DivideZeroChecker], Msg, N);
+auto R = 
std::make_unique(DivideZeroChecker.getBT(),
+  Msg, N);

NagyDonat wrote:

I felt that this implicit conversion would be a bit "too magical", but it would 
be _very_ easy to declare that `CheckerFrontendWithBugType` derives from both 
`CheckerFrontend` and `BugType`, and I'm not opposed if you prefer it.

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


[clang] [Clang] Remove workaround for libstdc++4.7 (PR #139693)

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

AaronBallman wrote:

> @AaronBallman We previously removed other such hacks, do you think a release 
> note is still useful 
> [6ad7e87](https://github.com/llvm/llvm-project/commit/6ad7e87806c0af774cf2f8880694f79259925979)
>  ?

Yeah, I think a release note is still handy, just so users aren't surprised.

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


[clang] [OpenCL] No need to check array of struct for kernel arguments (PR #138894)

2025-05-13 Thread Sven van Haastregt via cfe-commits

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

LGTM, thanks!

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


[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread via cfe-commits

MolecularMatters wrote:

> This is very interesting!
> 
> Initially I also assumed this was about Edit&Continue. As users may have the 
> same idea, I'd suggest adding `DocBrief`s to the new Clang options, and a 
> comment at the top of llvm/lib/CodeGen/WindowsHotPatch.cpp that explain in 
> more detail what they do.

Seconded.
I'd even vote for renaming the command-line options entirely.

We already have `/HOTPATCH` or rather `-fms-hotpatch` that does something 
different, so `-fms-hotpatch-functions-file` and `-fms-hotpatch-functions-list` 
might be confusing, because they don't have anything to do with `-fms-hotpatch` 
at all.

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


[clang] [Clang] Remove workaround for libstdc++4.7 (PR #139693)

2025-05-13 Thread via cfe-commits

cor3ntin wrote:

@AaronBallman We previously removed other such hacks, do you think a release 
note
is still useful 
https://github.com/llvm/llvm-project/commit/6ad7e87806c0af774cf2f8880694f79259925979
 ?

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


[clang] 8aaac80 - [NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates (#137393)

2025-05-13 Thread via cfe-commits

Author: Max Graey
Date: 2025-05-13T22:34:42+08:00
New Revision: 8aaac80ddde6a23527d3caa98ec998ebe402e0d9

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

LOG: [NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates 
(#137393)

Also fix some typos in comments

-

Co-authored-by: Mehdi Amini 

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
lld/MachO/SymbolTable.cpp
llvm/include/llvm/Analysis/LoopInfo.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp
mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
mlir/lib/Dialect/AMDGPU/Transforms/TransferReadToLoad.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Arith/Utils/Utils.cpp
mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
mlir/lib/IR/Diagnostics.cpp
mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5a0cec3d112db..59eb6d16f482c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10052,9 +10052,10 @@ void CheckFreeArgumentsAddressof(Sema &S, const 
std::string &CalleeName,
  const UnaryOperator *UnaryExpr) {
   if (const auto *Lvalue = dyn_cast(UnaryExpr->getSubExpr())) {
 const Decl *D = Lvalue->getDecl();
-if (isa(D))
-  if (!dyn_cast(D)->getType()->isReferenceType())
+if (auto *DD = dyn_cast(D)) {
+  if (!DD->getType()->isReferenceType())
 return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
+}
   }
 
   if (const auto *Lvalue = dyn_cast(UnaryExpr->getSubExpr()))

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index bf1b76b52e1fc..6c4df0aa35af5 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -942,7 +942,7 @@ static bool checkExportedDecl(Sema &S, Decl *D, 
SourceLocation BlockStart) {
   // HLSL: export declaration is valid only on functions
   if (S.getLangOpts().HLSL) {
 // Export-within-export was already diagnosed in ActOnStartExportDecl
-if (!dyn_cast(D) && !dyn_cast(D)) {
+if (!isa(D)) {
   S.Diag(D->getBeginLoc(), diag::err_hlsl_export_not_on_function);
   D->setInvalidDecl();
   return false;

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index be6ce97d838f3..fcb556f8f2b9f 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2307,7 +2307,7 @@ bool SemaOpenMP::isInOpenMPTargetExecutionDirective() 
const {
 
 bool SemaOpenMP::isOpenMPRebuildMemberExpr(ValueDecl *D) {
   // Only rebuild for Field.
-  if (!dyn_cast(D))
+  if (!isa(D))
 return false;
   DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(
   D,

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
index a23f3aa356cb0..4fb47703e3984 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
@@ -356,7 +356,7 @@ class RawPtrRefLocalVarsChecker
 SmallString<100> Buf;
 llvm::raw_svector_ostream Os(Buf);
 
-if (dyn_cast(V)) {
+if (isa(V)) {
   Os << "Assignment to an " << ptrKind() << " parameter ";
   printQuotedQualifiedName(Os, V);
   Os << " is unsafe.";

diff  --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index ad48e909903b5..bacb76fbf 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -518,7 +518,7 @@ static const Symbol *getAlternativeSpelling(const Undefined 
&sym,
 
 // If in the symbol table and not undefined.
 if (const Symbol *s = symtab->find(newName))
-  if (dyn_cast(s) == nullptr)
+  if (!isa(s))
 return s;
 
 return nullptr;
@@ -567,8 +567,7 @@ static const Symbol *getAlternativeSpelling(cons

[clang] [llvm] Revert "[lit][clang] Avoid realpath on Windows due to MAX_PATH limitations" (PR #139739)

2025-05-13 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [llvm] Revert "[lit][clang] Avoid realpath on Windows due to MAX_PATH limitations" (PR #139739)

2025-05-13 Thread via cfe-commits

https://github.com/guillem-bartrina-sonarsource created 
https://github.com/llvm/llvm-project/pull/139739

This reverts commit 05d613ea931b6de1b46dfe04b8e55285359047f4.

Only **one single** test has been added after the reverted patch that makes use 
of the _functionality_ it introduced.
* The macro `%{/t:real}` in `case-insensitive-include-absolute.c` has been 
replaced by the good ol' `%/t`.

Original discussion: https://reviews.llvm.org/D154130

---

Although it has been almost two years since the patch was merged and apparently 
no major problems associated with it have arisen, we still believe that the 
patch is _unsound_ overall.

**Rationale:**

The whole point of **canonical** paths is to be unique for a given entity 
(directory or file), so that they can be directly compared to determine whether 
or not two entities are the same.

This patch outright renders this fundamental property useless by allowing the 
same entity to have more than one canonical path on a Windows machine, 
depending on whether it is accessed via the real path or a substituted path.

And the only motivation behind these deceptively innocuous changes seems to be 
to help circumvent a platform-dependent limitation (MAX_PATH on Windows) that 
apparently makes it difficult for some users (?) to run on lit tests. This 
limitation has workarounds (using directory junctions, enabling long paths or 
using UNC) that do not require changing llvm at all but simply some settings on 
the host machine. Furthermore, this limitation may no longer be relevant two 
years later.

We also believe that the original patch was a bit incomplete. It indirectly 
affected the resolution of canonical paths used by certain parts of other llvm 
subsystems (module maps, frameworks, ...), and were not thoroughly tested for 
regressions.
> In reality, it is not easy to find a regression in llvm itself because the 
> fundamental property of canonical paths is not widely exploited, except in 
> some form of caches. But it is certainly exploited by many of the “users” of 
> llvm.

Also, some simplifications in the resolution of canonical paths in 
`(Text|SARIF)Diagnostic.cpp` may have been overlooked.

But the biggest concern, aside from breaking the fundamental property, is that 
the patch also inadvertently changes the way certain symbolic links are 
resolved in Windows, particularly those between different drives. [If the path 
contains a symbolic link to another drive, the absolute and real paths have 
different drive letters, even though they are not substituted drives... ] This 
behavior change is not documented in the patch description so it is definitely 
a regression.

Finally, the last comment in the original discussion, which was posted after 
the merge, also raised concerns about the changes introduced by the patch.

In summary, we believe that this patch is more detrimental than beneficial and 
should be reverted.

_As for the original patch, it is not easy to create any kind of test for this 
change in behavior. Since we are reverting a change, the need for tests is not 
so relevant._



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://g

[clang] [lld] [llvm] [mlir] [NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates (PR #137393)

2025-05-13 Thread via cfe-commits

github-actions[bot] wrote:



@MaxGraey 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/137393
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] [mlir] [NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates (PR #137393)

2025-05-13 Thread Longsheng Mou via cfe-commits

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


[clang] [C] Add -Wtentative-definition-compat (PR #137967)

2025-05-13 Thread via cfe-commits

asmok-g wrote:

Thanks a lot for the quick fix!

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


[clang] [NFC][analyzer] Document configuration options (PR #135169)

2025-05-13 Thread Donát Nagy via cfe-commits


@@ -0,0 +1,286 @@
+#!/usr/bin/env python3
+# A tool to automatically generate documentation for the config options of the
+# clang static analyzer by reading `AnalyzerOptions.def`.
+
+import argparse
+from collections import namedtuple
+from enum import Enum, auto
+import re
+import sys
+import textwrap
+
+
+# The following code implements a trivial parser for the narrow subset of C++
+# which is used in AnalyzerOptions.def. This supports the following features:
+# - ignores preprocessor directives, even if they are continued with \ at EOL
+# - ignores comments: both /* ... */ and // ...
+# - parses string literals (even if they contain \" escapes)
+# - concatenates adjacent string literals
+# - parses numbers even if they contain ' as a thousands separator
+# - recognizes MACRO(arg1, arg2, ..., argN) calls
+
+
+class TT(Enum):
+"Token type enum."
+number = auto()
+ident = auto()
+string = auto()
+punct = auto()
+
+
+TOKENS = [
+(re.compile(r"-?[0-9']+"), TT.number),
+(re.compile(r"\w+"), TT.ident),
+(re.compile(r'"([^\\"]|\\.)*"'), TT.string),
+(re.compile(r"[(),]"), TT.punct),
+(re.compile(r"/\*((?!\*/).)*\*/", re.S), None),  # C-style comment
+(re.compile(r"//.*\n"), None),  # C++ style oneline comment
+(re.compile(r"#.*(\\\n.*)*(?", which is
+# OK for a terse command line printout, but should be prettified for web
+# documentation.
+# Moreover, the option ctu-invocation-list shows some example file content
+# which is formatted as a preformatted block.
+paragraphs = [desc]
+extra = ""
+if m := re.search(r"(^|\s)Value:", desc):
+err_handler.record_use_of_tweak("accepted values")
+paragraphs = [desc[: m.start()], "Accepted values:" + desc[m.end() :]]
+elif m := re.search(r"\s*Example file.content:", desc):
+err_handler.record_use_of_tweak("example file content")
+paragraphs = [desc[: m.start()]]
+extra = "Example file content::\n\n  " + desc[m.end() :] + "\n\n"

NagyDonat wrote:

`Value:` lists are only relevant and present in a minority of the descriptions, 
while currently there is just one option that specifies `Example file content`, 
so we cannot mandate that these should be present in _each_ description. The 
`record_use_of_tweak` calls only validate that _at least one description_ uses 
that particular tweak.

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


[clang] [flang] [llvm] [openmp] [Flang][OpenMP] Move builtin .mod generation into runtimes (PR #137828)

2025-05-13 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/137828



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] 69ce681 - [Serialization] Use StringRef::substr (NFC) (#139678)

2025-05-13 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-13T07:12:57-07:00
New Revision: 69ce68109a3df221b507eb2308d5984ee7a71e22

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

LOG: [Serialization] Use StringRef::substr (NFC) (#139678)

StringRef::substr is shorter here because we can rely on its default
second parameter.

Added: 


Modified: 
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index c4c0603839c62..7de510c85bfed 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1237,7 +1237,7 @@ ASTWriter::createSignature() const {
   Hasher.update(
   AllBytes.slice(UnhashedControlBlockRange.second, ASTBlockRange.first));
   //  3. After the AST block.
-  Hasher.update(AllBytes.slice(ASTBlockRange.second, StringRef::npos));
+  Hasher.update(AllBytes.substr(ASTBlockRange.second));
   ASTFileSignature Signature = ASTFileSignature::create(Hasher.result());
 
   return std::make_pair(ASTBlockHash, Signature);



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


[clang] [RISC-V] Allow intrinsics to be used with any pointer type. (PR #139634)

2025-05-13 Thread Luke Lau via cfe-commits

lukel97 wrote:

Linking some context here, IIUC the use case for this is for OpenCL where 
device code would use a non-default address space: 
https://github.com/llvm/llvm-project/pull/137045#issuecomment-2872208568



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


[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits

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


[clang] [RISC-V] Allow intrinsics to be used with any pointer type. (PR #139634)

2025-05-13 Thread Luke Lau via cfe-commits

lukel97 wrote:

> I don't know how many users are requiring this change, but I do know some 
> people are developing RVV-based heterogeneous hardware/software. I am happy 
> to see this and we should make more people be aware of this change, so I 
> suggest to post it on Discourse as well.

I think [Halide will emit RISC-V LLVM IR 
intrinsics](https://github.com/halide/Halide/blob/bf9c55dd1392b87cfc82371ee40157786eb4ec78/src/CodeGen_RISCV.cpp#L357-L366),
 so it would be good to double check that the code it emits still works fine 
with these new intrinsics. 



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


[clang] [Preprocessor] Do not expand macros if the input is already preprocessed (PR #137665)

2025-05-13 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez updated 
https://github.com/llvm/llvm-project/pull/137665



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-13 Thread Donát Nagy via cfe-commits

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


[clang] [Clang][Sema] Disable checking invalid template id in initializer of primary variable template `std::format_kind` with libstdc++ (PR #139560)

2025-05-13 Thread Erich Keane via cfe-commits

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


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


[clang] [clang-tools-extra] [Clang] Add __builtin_type_pack_dedup template to deduplicate types in template arguments (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

I have made quite a bit of progress here, but we also need the deduplication 
builting urgently to help ease the pain for
some of the big compilations that started hitting our infrastructure limits 
internally.

I have created #139730 with the initial and simple version of the builtin that 
I would really love to land ASAP as I expect this PR to take more time to cook 
(see open questions below, I'm sure there will be a few more comments). I fully 
understand the desire to have a better version of the builtin in the long term 
and I am happy to continue working on this until it lands. But we also need the 
build time savings at a shorter timeframe, so I hope that having a simpler 
version in the meantime would not be  a particularly contentious point. Let me 
know, though. 

With that out of the way, @cor3ntin could you take a look at the new version 
here?
It still has a few rough edges, but I want to make sure the choices made here 
make sense to you, in particular:
- using `TemplateSpecializationType` for dependent instantiations and for sugar 
after we have a template pack after substitution,
- doing a second run during template instantiations when we need to expand the 
packs that are delayed,
- a new type (that shares a common base class with `SubstTemplateParmPackType`) 
to represent the pack after substitution.

Also eager to hear feedback from others, just calling out @cor3ntin as someone 
who has been the author of the relevant standard proposals that this PR is 
trying to mimic.

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


[clang] [Preprocessor] Do not expand macros if the input is already preprocessed (PR #137665)

2025-05-13 Thread Juan Manuel Martinez Caamaño via cfe-commits

jmmartinez wrote:

I fixed the `Modules/initializers.cpp` test by moving the preprocessor 
directives outside of the module contents (the module contents should be 
already preprocessed and not contain preproc directives).

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


[clang] [C] Add -Wtentative-definition-compat (PR #137967)

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

AaronBallman wrote:

> Is there maybe a quick fix or should we add a revert (to revert to green)?

I'm still investigating, so unclear on a quick fix. But to make sure I 
understand correctly, things *are* green (no bots are failing, right?), this is 
just a false positive? Or am I missing something about the severity?

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


[clang] [Clang] Add a builtin for efficient type deduplication (PR #139730)

2025-05-13 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

This is a simple initial version of a builtin in #106730 that does **not** 
introduce new kind of packs that can be produced by builtins rather than 
variadic template parameters and instead relies on features already available 
in C++.

This makes the implementation much simpler and it would allow us to rip the 
compile-time benefits while #106730 cooks. After it's done, the builting 
provided here can be either removed or replaced with a version wrapping the 
more efficient one, i.e. the equivalent of:

```cpp
template  class Templ, class ...Ts>
using __builtin_dedup_types = Templ<__builtin_dedup_pack...>;
```

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


[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov updated 
https://github.com/llvm/llvm-project/pull/106730

>From e2d345d490d73f46d969b9a5945d9bfe11e148f9 Mon Sep 17 00:00:00 2001
From: Ilya Biryukov 
Date: Fri, 23 Aug 2024 17:27:26 +0200
Subject: [PATCH 1/2] [Clang] Add builtins that deduplicate and sort types

The two new additions are:
- `__builtin_dedup_pack` removes duplicates from list of types.
- `__builtin_sort_pack` sorts types by mangled name.

The added builtins are special in that they produce an unexpanded pack
in the spirit of CWG #YYY proposal.

Produced packs can be used directly in template argument lists and get
immediately expanded as soon as results of the computation are
available.
It allows easily combining them, e.g.:

```cpp
template 
struct Normalize {
  using result = std::tuple<
  __builtin_sort_pack<
__builtin_dedup_pack...
  >...>;
}
;
```

Limitations:
- only supported in template arguments (e.g. no bases, etc),
- can only be used inside the templates, even if non-dependent,
- the builtins cannot be assigned to template template parameters.

The actual implementation proceeds as follows:
- When the compiler encounters a `__builtin_dedup_pack` or other type-producing
  builtin with dependent arguments, it creates a dependent
  `TemplateSpecializationType`.
- During substitution, if the template arguments are non-dependent, we
  will produce: a new type `SubstBuiltinTemplatePackType`, which stores
  an argument pack that needs to be substituted. This type is similar to
  the existing `SubstTemplateParmPack` in that it carries the argument
  pack that needs to be expanded further. The relevant code is shared.
- On top of that, we also wrap the resulting type into
  `TemplateSpecializationType`, but this time only as a sugar.
- To actually expand those packs, we collect the produced
  `SubstBuiltinTemplatePackType` inside `CollectUnexpandedPacks`.
  Because we know the size of the produces packs only after the initial
  substitution, places that do the actual expansion will need to have a
  second run over the substituted type to finalize the expansions (in
  this patch we only support this for template arguments, see
  `ExpandTemplateArgument`).

TODO before commiting:
- produce an error when builtins packs are used outside templates,
- add release notes and documentation,
- update tests in FindTarget (and any other tooling-related bits)
---
 .../clangd/unittests/FindTargetTests.cpp  |   6 +
 clang/include/clang/AST/ASTContext.h  |   4 +
 clang/include/clang/AST/DeclTemplate.h|   3 +
 clang/include/clang/AST/RecursiveASTVisitor.h |  30 ++-
 clang/include/clang/AST/Type.h|  88 ++--
 clang/include/clang/AST/TypeLoc.h |  22 +-
 clang/include/clang/AST/TypeProperties.td |  19 +-
 clang/include/clang/Basic/BuiltinTemplates.td |   6 +
 .../clang/Basic/DiagnosticSemaKinds.td|   6 +
 clang/include/clang/Basic/TypeNodes.td|   4 +-
 clang/include/clang/Sema/Sema.h   |   6 +-
 .../clang/Serialization/TypeBitCodes.def  |   1 +
 clang/lib/AST/ASTContext.cpp  |  32 ++-
 clang/lib/AST/ASTImporter.cpp |   8 +
 clang/lib/AST/ASTStructuralEquivalence.cpp|   8 +
 clang/lib/AST/DeclTemplate.cpp|  16 +-
 clang/lib/AST/ItaniumMangle.cpp   |   9 +
 clang/lib/AST/MicrosoftMangle.cpp |   5 +
 clang/lib/AST/Type.cpp|  82 +--
 clang/lib/AST/TypePrinter.cpp |  10 +
 clang/lib/Parse/ParseTemplate.cpp |  14 ++
 clang/lib/Sema/SemaTemplate.cpp   |  76 +++
 clang/lib/Sema/SemaTemplateDeduction.cpp  |   6 +
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  48 
 clang/lib/Sema/SemaTemplateVariadic.cpp   |  83 ++-
 clang/lib/Sema/SemaType.cpp   |  19 ++
 clang/lib/Sema/TreeTransform.h| 209 --
 clang/lib/Serialization/ASTReader.cpp |   5 +
 clang/lib/Serialization/ASTWriter.cpp |   6 +
 .../test/Import/builtin-template/Inputs/S.cpp |   7 +
 clang/test/Import/builtin-template/test.cpp   |  10 +-
 clang/test/PCH/dedup_types.cpp|  20 ++
 .../test/SemaTemplate/dedup-types-builtin.cpp |  81 +++
 .../test/SemaTemplate/sort-types-builtin.cpp  |  42 
 clang/tools/libclang/CIndex.cpp   |   1 +
 35 files changed, 864 insertions(+), 128 deletions(-)
 create mode 100644 clang/test/PCH/dedup_types.cpp
 create mode 100644 clang/test/SemaTemplate/dedup-types-builtin.cpp
 create mode 100644 clang/test/SemaTemplate/sort-types-builtin.cpp

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 602f61d9ecb41..125b9002d1d22 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -731,6 +731,12 @@ TEST_F(TargetDeclTest, BuiltinTemplates) {
 using 

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

Note to people reviewing this: please ensure you "hide whitespace" via `git 
diff -w` or the corresponding setting on GitHub. For your own sanity when 
looking at changes in `TreeTransform.h`, which are otherwise really complicated 
to validate. I've deliberately kept the code at the same place to have 
reasonable diffs.

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


[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

2025-05-13 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

I handled all the inline comments.

I have one minor architectural question: we should standardize a way to assign 
a single tag description (that is, identifiers that can be used in debug dumps) 
to each checker family. The old code automatically used the name of the first 
checker part as the tag description (which was not very elegant...); while in 
the current version of this patch subclasses of `CheckerFamily<>` override 
`getTagDescription()` and return their class name as a hardcoded string 
literal. I think this approach is acceptable, and if we keep it then I'll add a 
comment in `CheckerFamily` which says that subclasses must override 
`getTagDescription()` this way. However, I also feel that there might be a 
better solution -- @steakhal what do you think.

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


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

2025-05-13 Thread Devon Loehr via cfe-commits

DKLoehr wrote:

I've only had ad-hoc discussions on the matter, but everyone I've talked to 
seems to fall in the latter camp. As mentioned in #138741, I didn't see any 
other project with a similar policy among chromium and all of its dependencies. 
I'd have no problem if we decided to do away with it altogether, but I don't 
know what that involves. It's worth noting that the instance in Sema.h is even 
more unusual, per the comment above it.

In the meantime, this gets us back to the status quo, and lets us use the 
warning to detect truly-accidental `virtual` specifiers.

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


[clang] [Serialization] Use StringRef::substr (NFC) (PR #139678)

2025-05-13 Thread Kazu Hirata via cfe-commits

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


[clang-tools-extra] ac583df - [include-cleaner] Use heterogeneous lookups (NFC) (#139685)

2025-05-13 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-13T07:13:25-07:00
New Revision: ac583df03b3c1b2cc3ef7ececbeca697f3449bec

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

LOG: [include-cleaner] Use heterogeneous lookups (NFC) (#139685)

Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.

Added: 


Modified: 
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 9431211b03e71..372ab5fa2706e 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -312,11 +312,11 @@ std::function headerFilter() {
 
 // Maps absolute path of each files of each compilation commands to the
 // absolute path of the input file.
-llvm::Expected>
+llvm::Expected>>
 mapInputsToAbsPaths(clang::tooling::CompilationDatabase &CDB,
 llvm::IntrusiveRefCntPtr VFS,
 const std::vector &Inputs) {
-  std::map CDBToAbsPaths;
+  std::map> CDBToAbsPaths;
   // Factory.editedFiles()` will contain the final code, along with the
   // path given in the compilation database. That path can be
   // absolute or relative, and if it is relative, it is relative to the
@@ -395,8 +395,7 @@ int main(int argc, const char **argv) {
   if (Edit) {
 for (const auto &NameAndContent : Factory.editedFiles()) {
   llvm::StringRef FileName = NameAndContent.first();
-  if (auto It = CDBToAbsPaths->find(FileName.str());
-  It != CDBToAbsPaths->end())
+  if (auto It = CDBToAbsPaths->find(FileName); It != CDBToAbsPaths->end())
 FileName = It->second;
 
   const std::string &FinalCode = NameAndContent.second;



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


[clang-tools-extra] [include-cleaner] Use heterogeneous lookups (NFC) (PR #139685)

2025-05-13 Thread Kazu Hirata via cfe-commits

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


[clang] [lld] [llvm] [mlir] [NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates (PR #137393)

2025-05-13 Thread Max Graey via cfe-commits

MaxGraey wrote:

Ok, it looks like ci successfully passed

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


[clang] [Clang] Stop changing DC when instantiating dependent friend specializations (PR #139436)

2025-05-13 Thread Matheus Izvekov via cfe-commits

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

Perfect, thanks!

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


[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)

2025-05-13 Thread Feng Zou via cfe-commits

fzou1 wrote:

> We should avoid introducing a new cmake config for changes like this. You 
> could utilize clang config file to specify the option.
> 
> lld change should have been separated

Sorry for late reply. The related cmake and LLD changes were reverted. Only a 
backend pass and option were added to suppress APX features for relocation. 
Thanks.

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


  1   2   3   4   5   6   >