[clang] [clang][analyzer] Correctly handle lambda-converted function pointers (PR #144906)

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

steakhal wrote:

Hey, looks like a nice patch!

I only have one question. Have you considered overriding some other 
`getRuntimeDefinition` too? When I'm looking at the [CallEvent 
](https://clang.llvm.org/doxygen/classclang_1_1ento_1_1CallEvent.html) 
inheritance graph, there could be a couple other options too.
Don't get me wrong, the `SimpleFunctionCall::getRuntimeDefinition` looks like 
the right place. I'm just curious.

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


[clang] [llvm] [LLVM][Clang] Add and enable strict mode for `getTrailingObjects` (PR #144930)

2025-06-19 Thread Rahul Joshi via cfe-commits

https://github.com/jurahul created 
https://github.com/llvm/llvm-project/pull/144930

Under strict mode, the templated `getTrailingObjects` can be called only when 
there is > 1 trailing types. The strict mode can be disabled on a per-call 
basis when its not possible to know statically if there will be a single or 
multiple trailing types (like in OpenMPClause.h).

>From 3648af7d6dd8d92f7a6549c101b0710ae014c57d Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Thu, 19 Jun 2025 10:25:12 -0700
Subject: [PATCH] [LLVM][Clang] Add and enable strict mode for
 `getTrailingObjects`

Under strict mode, the templated `getTrailingObjects` can be called
only when there is > 1 trailing types. The strict mode can be disabled
on a per-call basis when its not possible to know statically if there
will be a single or multiple trailing types (like in OpenMPClause.h).
---
 clang/include/clang/AST/OpenMPClause.h  | 46 +
 clang/lib/AST/Expr.cpp  |  3 +-
 llvm/include/llvm/Support/TrailingObjects.h | 21 ++
 3 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 2fa8fa529741e..b62ebd614e4c7 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -295,7 +295,8 @@ template  class OMPVarListClause : public 
OMPClause {
 
   /// Fetches list of variables associated with this clause.
   MutableArrayRef getVarRefs() {
-return static_cast(this)->template getTrailingObjects(NumVars);
+return static_cast(this)
+->template getTrailingObjects(NumVars);
   }
 
   /// Sets the list of variables for this clause.
@@ -334,8 +335,8 @@ template  class OMPVarListClause : public 
OMPClause {
 
   /// Fetches list of all variables in the clause.
   ArrayRef getVarRefs() const {
-return static_cast(this)->template getTrailingObjects(
-NumVars);
+return static_cast(this)
+->template getTrailingObjects(NumVars);
   }
 };
 
@@ -380,7 +381,8 @@ template  class OMPDirectiveListClause : public 
OMPClause {
 
   MutableArrayRef getDirectiveKinds() {
 return static_cast(this)
-->template getTrailingObjects(NumKinds);
+->template getTrailingObjects(
+NumKinds);
   }
 
   void setDirectiveKinds(ArrayRef DK) {
@@ -5901,15 +5903,17 @@ class OMPMappableExprListClause : public 
OMPVarListClause,
   /// Get the unique declarations that are in the trailing objects of the
   /// class.
   MutableArrayRef getUniqueDeclsRef() {
-return static_cast(this)->template getTrailingObjects(
-NumUniqueDeclarations);
+return static_cast(this)
+->template getTrailingObjects(
+NumUniqueDeclarations);
   }
 
   /// Get the unique declarations that are in the trailing objects of the
   /// class.
   ArrayRef getUniqueDeclsRef() const {
 return static_cast(this)
-->template getTrailingObjects(NumUniqueDeclarations);
+->template getTrailingObjects(
+NumUniqueDeclarations);
   }
 
   /// Set the unique declarations that are in the trailing objects of the
@@ -5923,15 +5927,17 @@ class OMPMappableExprListClause : public 
OMPVarListClause,
   /// Get the number of lists per declaration that are in the trailing
   /// objects of the class.
   MutableArrayRef getDeclNumListsRef() {
-return static_cast(this)->template getTrailingObjects(
-NumUniqueDeclarations);
+return static_cast(this)
+->template getTrailingObjects(
+NumUniqueDeclarations);
   }
 
   /// Get the number of lists per declaration that are in the trailing
   /// objects of the class.
   ArrayRef getDeclNumListsRef() const {
-return static_cast(this)->template getTrailingObjects(
-NumUniqueDeclarations);
+return static_cast(this)
+->template getTrailingObjects(
+NumUniqueDeclarations);
   }
 
   /// Set the number of lists per declaration that are in the trailing
@@ -5946,7 +5952,8 @@ class OMPMappableExprListClause : public 
OMPVarListClause,
   /// objects of the class. They are appended after the number of lists.
   MutableArrayRef getComponentListSizesRef() {
 return MutableArrayRef(
-static_cast(this)->template getTrailingObjects() +
+static_cast(this)
+->template getTrailingObjects() +
 NumUniqueDeclarations,
 NumComponentLists);
   }
@@ -5955,7 +5962,8 @@ class OMPMappableExprListClause : public 
OMPVarListClause,
   /// objects of the class. They are appended after the number of lists.
   ArrayRef getComponentListSizesRef() const {
 return ArrayRef(
-static_cast(this)->template getTrailingObjects() +
+static_cast(this)
+->template getTrailingObjects() +
 NumUniqueDeclarations,
 NumComponentLists);
   }
@@ -5971,13 +5979,15 @@ class OMPMappableExprListClause : public 
OMPVarListClause,
   /// Get the components 

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

2025-06-19 Thread Reid Kleckner via cfe-commits

https://github.com/rnk updated https://github.com/llvm/llvm-project/pull/144428

>From afb050103754e6b4656c68da8ddfb6b1a4e03e5d Mon Sep 17 00:00:00 2001
From: Reid Kleckner 
Date: Mon, 16 Jun 2025 20:08:12 +
Subject: [PATCH 1/5] [clang] Register all LLVM targets in AllClangUnitTest
 main

Addresses feedback in 
https://github.com/llvm/llvm-project/pull/134196#issuecomment-2970715875

Makes the tests less sensitive to target registration from unrelated
test fixtures by registering everything up front.
---
 clang/unittests/AllClangUnitTests.cpp | 24 
 clang/unittests/CMakeLists.txt|  1 +
 2 files changed, 25 insertions(+)
 create mode 100644 clang/unittests/AllClangUnitTests.cpp

diff --git a/clang/unittests/AllClangUnitTests.cpp 
b/clang/unittests/AllClangUnitTests.cpp
new file mode 100644
index 0..1726cabc8107c
--- /dev/null
+++ b/clang/unittests/AllClangUnitTests.cpp
@@ -0,0 +1,24 @@
+//===- clang/unittests/AllClangUnitTests.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/TargetSelect.h"
+
+// This custom main entry point for the AllClangUnitTests binary registers all
+// tests on startup, so the tests don't become sensitive to target registration
+// within the test suite.
+int main(int argc, char **argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  llvm::cl::ParseCommandLineOptions(argc, argv);
+
+  llvm::InitializeAllTargets();
+  llvm::InitializeAllTargetMCs();
+
+  return RUN_ALL_TESTS();
+}
diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index aef28f914b640..54c781a35c20c 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -117,6 +117,7 @@ get_property(LINK_LIBS GLOBAL PROPERTY 
CLANG_UNITTEST_LINK_LIBS)
 get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
 add_distinct_clang_unittest(AllClangUnitTests
   ${SRCS}
+  AllClangUnitTests.cpp
   CLANG_LIBS
   ${CLANG_LIBS}
   LINK_LIBS

>From f5accc33950191c2e6eebe8327e247e2a4177d3e Mon Sep 17 00:00:00 2001
From: Reid Kleckner 
Date: Mon, 16 Jun 2025 20:15:11 +
Subject: [PATCH 2/5] reorder headers to pacify format checker

---
 clang/unittests/AllClangUnitTests.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/unittests/AllClangUnitTests.cpp 
b/clang/unittests/AllClangUnitTests.cpp
index 1726cabc8107c..d1c8da12d5c84 100644
--- a/clang/unittests/AllClangUnitTests.cpp
+++ b/clang/unittests/AllClangUnitTests.cpp
@@ -6,9 +6,9 @@
 //
 
//===--===//
 
-#include "gtest/gtest.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/TargetSelect.h"
+#include "gtest/gtest.h"
 
 // This custom main entry point for the AllClangUnitTests binary registers all
 // tests on startup, so the tests don't become sensitive to target registration

>From 1f57ce24f87a22a2975beb928892f4aa6b983f81 Mon Sep 17 00:00:00 2001
From: Reid Kleckner 
Date: Tue, 17 Jun 2025 23:37:25 +
Subject: [PATCH 3/5] Add additional target registration hooks to match cc1

---
 clang/unittests/AllClangUnitTests.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/clang/unittests/AllClangUnitTests.cpp 
b/clang/unittests/AllClangUnitTests.cpp
index d1c8da12d5c84..279e51b41d5bf 100644
--- a/clang/unittests/AllClangUnitTests.cpp
+++ b/clang/unittests/AllClangUnitTests.cpp
@@ -17,8 +17,14 @@ int main(int argc, char **argv) {
   ::testing::InitGoogleTest(&argc, argv);
   llvm::cl::ParseCommandLineOptions(argc, argv);
 
+  // Initialize all levels of target components. Keep this in sync with
+  // cc1_main.
+  llvm::InitializeAllTargetInfos();
   llvm::InitializeAllTargets();
   llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllAsmPrinters();
+  llvm::InitializeAllAsmParsers();
+
 
   return RUN_ALL_TESTS();
 }

>From 5d9b64763f367f5fe0b5544ea50705e6872d2386 Mon Sep 17 00:00:00 2001
From: Reid Kleckner 
Date: Tue, 17 Jun 2025 23:48:56 +
Subject: [PATCH 4/5] pacify formatter

---
 clang/unittests/AllClangUnitTests.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/unittests/AllClangUnitTests.cpp 
b/clang/unittests/AllClangUnitTests.cpp
index 279e51b41d5bf..71d3ec32aa054 100644
--- a/clang/unittests/AllClangUnitTests.cpp
+++ b/clang/unittests/AllClangUnitTests.cpp
@@ -25,6 +25,5 @@ int main(int argc, char **argv) {
   llvm::InitializeAllAsmPrinters();
   llvm::InitializeAllAsmParsers();
 
-
   return RUN_ALL_TESTS();
 }

>From 893096a66e661879988e13735bf3b7e2680f9be8 Mon Sep 17 00:00:00 2001
From: Reid Kleckner 
Date: Thu, 19 Jun 2025 17:15:36 +
Subject: [PATCH 5

[clang] 633e740 - [Clang][AMDGPU][Driver] Add `avail-extern-gv-in-addrspace-to-local` option when ThinTLO is enabled (#144914)

2025-06-19 Thread via cfe-commits

Author: Shilei Tian
Date: 2025-06-19T14:32:20-04:00
New Revision: 633e740e3453bab06bf535830174c759100257f9

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

LOG: [Clang][AMDGPU][Driver] Add `avail-extern-gv-in-addrspace-to-local` option 
when ThinTLO is enabled (#144914)

On AMDGPU, we need an extra argument
`-avail-extern-gv-in-addrspace-to-local=3`
to privatize LDS global variables when ThinLTO is enabled.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/test/Driver/hip-thinlto.hip
clang/test/Driver/openmp-offload-gpu.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5a3c09e3a343a..e910a2bedeeb1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9192,6 +9192,9 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back(
   Args.MakeArgString("--device-linker=" + TC->getTripleString() +
  "=-plugin-opt=-avail-extern-to-local"));
+  CmdArgs.push_back(Args.MakeArgString(
+  "--device-linker=" + TC->getTripleString() +
+  "=-plugin-opt=-avail-extern-gv-in-addrspace-to-local=3"));
   if (Kind == Action::OFK_OpenMP) {
 CmdArgs.push_back(
 Args.MakeArgString("--device-linker=" + TC->getTripleString() +

diff  --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp 
b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index 74ac8306e7cc1..b8f3a70ee827e 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -102,6 +102,8 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, 
const JobAction &JA,
   if (IsThinLTO) {
 LldArgs.push_back(Args.MakeArgString("-plugin-opt=-force-import-all"));
 
LldArgs.push_back(Args.MakeArgString("-plugin-opt=-avail-extern-to-local"));
+LldArgs.push_back(Args.MakeArgString(
+"-plugin-opt=-avail-extern-gv-in-addrspace-to-local=3"));
   }
 
   for (const Arg *A : Args.filtered(options::OPT_mllvm)) {

diff  --git a/clang/test/Driver/hip-thinlto.hip 
b/clang/test/Driver/hip-thinlto.hip
index 4227cd3f2e9f9..bcb7d4e6cb52e 100644
--- a/clang/test/Driver/hip-thinlto.hip
+++ b/clang/test/Driver/hip-thinlto.hip
@@ -3,6 +3,7 @@
 // CHECK: -plugin-opt=thinlto
 // CHECK-SAME: -plugin-opt=-force-import-all
 // CHECK-SAME: -plugin-opt=-avail-extern-to-local
+// CHECK-SAME: -plugin-opt=-avail-extern-gv-in-addrspace-to-local=3
 int main(int, char *[]) {
   return 0;
 }

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index f67c2173cb144..2af3e2da3b21c 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -388,6 +388,7 @@
 // THINLTO-GFX906: --device-compiler=amdgcn-amd-amdhsa=-flto=thin
 // THINLTO-GFX906-SAME: 
--device-linker=amdgcn-amd-amdhsa=-plugin-opt=-force-import-all
 // THINLTO-GFX906-SAME: 
--device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-to-local
+// THINLTO-GFX906-SAME: 
--device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-gv-in-addrspace-to-local=3
 // THINLTO-GFX906-SAME: 
--device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols
 //
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \



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


[clang] [Clang][AMDGPU][Driver] Add `avail-extern-gv-in-addrspace-to-local` option when ThinTLO is enabled (PR #144914)

2025-06-19 Thread Shilei Tian via cfe-commits

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


[clang] [Clang] Diagnose unsatisfied `std::is_assignable`. (PR #144836)

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


@@ -99,6 +127,14 @@ static_assert(std::is_trivially_copyable_v);
 // expected-note@-1 {{'int &' is not trivially copyable}} \
 // expected-note@-1 {{because it is a reference type}}
 
+static_assert(std::is_assignable::value);
+
+static_assert(std::is_assignable::value);
+// expected-error-re@-1 {{static assertion failed due to requirement 
'std::{{.*}}is_assignable::value'}} \
+// expected-error@-1 {{assigning to 'int' from incompatible type 'void'}}

efriedma-quic wrote:

Unlike the other DiagnoseTypeTraitDetails diagnostics, this is an "error", not 
a "note".  I'm not sure that actually causes any serious issues right now, but 
it's a bit confusing, and could cause issues in the future.

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


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

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

mizvekov wrote:

> Just noticed that this is not using `std::optional`. If this is 
> good, why don't we put this to `llvm/ADT`? I feel that is a better place.

I don't disagree in principle, we just don't need to preempt making this 
available for all of llvm, if no one has the time to make a patch to use it 
outside of clang.

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


[clang] [clang][analyzer] Correctly handle lambda-converted function pointers (PR #144906)

2025-06-19 Thread Oliver Stöneberg via cfe-commits

firewave wrote:

The same occurs with assigning to `auto`: https://godbolt.org/z/nofG6cehf

Will this also be handled by this change?

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


[clang-tools-extra] [llvm] [clang-tools-extra] Add clang-omp-pr-desc wrapper for OpenMP PR summarization (PR #144935)

2025-06-19 Thread Aviral Singh via cfe-commits

https://github.com/aviralsingh2004 created 
https://github.com/llvm/llvm-project/pull/144935

This patch introduces a new Clang-compatible wrapper tool `clang-omp-pr-desc`, 
which forwards arguments to `omp-pr-summary describe`. This tool simplifies 
generation of structured OpenMP pull request summaries.

It is intended to be used as part of Clang tooling for OpenMP-related 
development workflows.

Usage:
  clang-omp-pr-desc  [--spec-path ]
![output2](https://github.com/user-attachments/assets/91f18357-bf50-421a-a677-8d65dc6bc48d)
![output1](https://github.com/user-attachments/assets/398fafca-657b-45e1-ab19-b342da3fb7b3)


>From 5ea5be4751e2c8a0650f91205983cb1891d5888e Mon Sep 17 00:00:00 2001
From: Aviral Singh 
Date: Thu, 19 Jun 2025 23:25:04 +0530
Subject: [PATCH] [clang-tools-extra] Add clang-omp-pr-desc wrapper for OpenMP
 PR summarization

---
 CLI_CLANG_TOOL3.py| 153 ++
 .../clang-omp-pr-desc/CMakeLists.txt  |   3 +
 .../clang-omp-pr-desc/ClangOMPPRDesc.cpp  |  21 +++
 setup.py  |  21 +++
 4 files changed, 198 insertions(+)
 create mode 100644 CLI_CLANG_TOOL3.py
 create mode 100644 clang-tools-extra/clang-omp-pr-desc/CMakeLists.txt
 create mode 100644 clang-tools-extra/clang-omp-pr-desc/ClangOMPPRDesc.cpp
 create mode 100644 setup.py

diff --git a/CLI_CLANG_TOOL3.py b/CLI_CLANG_TOOL3.py
new file mode 100644
index 0..1e3833f9fdf2c
--- /dev/null
+++ b/CLI_CLANG_TOOL3.py
@@ -0,0 +1,153 @@
+# CLI_CLANG_TOOL2.py
+
+import typer
+import requests
+import os
+import torch
+import numpy as np
+from sentence_transformers import SentenceTransformer
+import faiss
+from pathlib import Path
+from typing import List
+
+app = typer.Typer()
+
+# -- CONFIG --
+GITHUB_TOKEN = os.getenv("GITHUB_TOKEN") 
+GROQ_API_KEY = os.getenv("GROQ_API_KEY") 
+HEADERS = {"Authorization": f"token {GITHUB_TOKEN}"}
+REPO = "llvm/llvm-project"
+MODEL = SentenceTransformer("all-MiniLM-L6-v2")
+
+# -- UTILS --
+def fetch_pr_diff(pr_number: int) -> str:
+url = f"https://api.github.com/repos/{REPO}/pulls/{pr_number}";
+diff_url = requests.get(url, headers=HEADERS).json().get("diff_url")
+diff = requests.get(diff_url, headers=HEADERS).text
+return diff
+
+def fetch_pr_title(pr_number: int) -> str:
+url = f"https://api.github.com/repos/{REPO}/pulls/{pr_number}";
+return requests.get(url, headers=HEADERS).json().get("title", "")
+
+def load_spec_sections(path: str) -> List[str]:
+return Path(path).read_text(encoding="utf-8").split("\n\n")
+
+def index_spec(sections: List[str]):
+embeddings = MODEL.encode(sections)
+index = faiss.IndexFlatL2(embeddings.shape[1])
+index.add(np.array(embeddings))
+return index, embeddings, sections
+
+def retrieve_spec(query: str, index, sections, embeddings, k=3):
+q_emb = MODEL.encode([query])
+D, I = index.search(np.array(q_emb), k)
+return [sections[i] for i in I[0]]
+
+def extract_openmp_pragmas_from_diff(diff: str) -> List[str]:
+return [line.strip() for line in diff.splitlines() if "#pragma omp" in 
line]
+
+def build_prompt(diff: str, spec_snippets: List[str], pragmas: List[str] = []):
+prompt = f"""
+You are an assistant summarizing OpenMP Pull Requests. Given the code diff and 
relevant sections of the OpenMP specification, write a structured summary for 
the PR.
+
+## Diff:
+{diff}
+
+## Relevant Spec Sections:
+{''.join(spec_snippets)}
+
+## OpenMP Directives Detected:
+{''.join(pragmas)}
+
+## Summary:
+"""
+return prompt
+
+def generate_summary(prompt):
+response = requests.post(
+"https://api.groq.com/openai/v1/chat/completions";,
+headers={
+"Authorization": f"Bearer {GROQ_API_KEY}",
+"Content-Type": "application/json"
+},
+json={
+"model": "llama3-70b-8192",
+"messages": [
+{"role": "system", "content": "You are a helpful assistant for 
code reviewers."},
+{"role": "user", "content": prompt},
+]
+}
+)
+response.raise_for_status()
+return response.json()['choices'][0]['message']['content'].strip()
+
+SECTION_LINKS = {
+"parallel": "https://www.openmp.org/spec-html/6.0/openmpsu35.html";,
+"worksharing": "https://www.openmp.org/spec-html/6.0/openmpsu46.html";,
+}
+
+def build_markdown_output(summary_text: str, spec_snippets: List[str]) -> str:
+linked_snippets = []
+for snippet in spec_snippets:
+for title, url in SECTION_LINKS.items():
+if title.lower() in snippet.lower():
+snippet += f"\n\n🔗 [Spec Link]({url})"
+break
+linked_snippets.append(snippet)
+
+return f"""## 📝 Pull Request Summary
+
+{summary_text}
+
+---
+
+## 📚 Related OpenMP Spec Sections
+{''.join(f"```text\n{snippet}\n```\n\n" for snippet in linked_snippets)}"""
+
+# -

[clang-tools-extra] [llvm] [clang-tools-extra] Add clang-omp-pr-desc wrapper for OpenMP PR summarization (PR #144935)

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


[clang-tools-extra] [llvm] [clang-tools-extra] Add clang-omp-pr-desc wrapper for OpenMP PR summarization (PR #144935)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Aviral Singh (aviralsingh2004)


Changes

This patch introduces a new Clang-compatible wrapper tool `clang-omp-pr-desc`, 
which forwards arguments to `omp-pr-summary describe`. This tool simplifies 
generation of structured OpenMP pull request summaries.

It is intended to be used as part of Clang tooling for OpenMP-related 
development workflows.

Usage:
  clang-omp-pr-desc  [--spec-path ]
![output2](https://github.com/user-attachments/assets/91f18357-bf50-421a-a677-8d65dc6bc48d)
![output1](https://github.com/user-attachments/assets/398fafca-657b-45e1-ab19-b342da3fb7b3)


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


4 Files Affected:

- (added) CLI_CLANG_TOOL3.py (+153) 
- (added) clang-tools-extra/clang-omp-pr-desc/CMakeLists.txt (+3) 
- (added) clang-tools-extra/clang-omp-pr-desc/ClangOMPPRDesc.cpp (+21) 
- (added) setup.py (+21) 


``diff
diff --git a/CLI_CLANG_TOOL3.py b/CLI_CLANG_TOOL3.py
new file mode 100644
index 0..1e3833f9fdf2c
--- /dev/null
+++ b/CLI_CLANG_TOOL3.py
@@ -0,0 +1,153 @@
+# CLI_CLANG_TOOL2.py
+
+import typer
+import requests
+import os
+import torch
+import numpy as np
+from sentence_transformers import SentenceTransformer
+import faiss
+from pathlib import Path
+from typing import List
+
+app = typer.Typer()
+
+# -- CONFIG --
+GITHUB_TOKEN = os.getenv("GITHUB_TOKEN") 
+GROQ_API_KEY = os.getenv("GROQ_API_KEY") 
+HEADERS = {"Authorization": f"token {GITHUB_TOKEN}"}
+REPO = "llvm/llvm-project"
+MODEL = SentenceTransformer("all-MiniLM-L6-v2")
+
+# -- UTILS --
+def fetch_pr_diff(pr_number: int) -> str:
+url = f"https://api.github.com/repos/{REPO}/pulls/{pr_number}";
+diff_url = requests.get(url, headers=HEADERS).json().get("diff_url")
+diff = requests.get(diff_url, headers=HEADERS).text
+return diff
+
+def fetch_pr_title(pr_number: int) -> str:
+url = f"https://api.github.com/repos/{REPO}/pulls/{pr_number}";
+return requests.get(url, headers=HEADERS).json().get("title", "")
+
+def load_spec_sections(path: str) -> List[str]:
+return Path(path).read_text(encoding="utf-8").split("\n\n")
+
+def index_spec(sections: List[str]):
+embeddings = MODEL.encode(sections)
+index = faiss.IndexFlatL2(embeddings.shape[1])
+index.add(np.array(embeddings))
+return index, embeddings, sections
+
+def retrieve_spec(query: str, index, sections, embeddings, k=3):
+q_emb = MODEL.encode([query])
+D, I = index.search(np.array(q_emb), k)
+return [sections[i] for i in I[0]]
+
+def extract_openmp_pragmas_from_diff(diff: str) -> List[str]:
+return [line.strip() for line in diff.splitlines() if "#pragma omp" in 
line]
+
+def build_prompt(diff: str, spec_snippets: List[str], pragmas: List[str] = []):
+prompt = f"""
+You are an assistant summarizing OpenMP Pull Requests. Given the code diff and 
relevant sections of the OpenMP specification, write a structured summary for 
the PR.
+
+## Diff:
+{diff}
+
+## Relevant Spec Sections:
+{''.join(spec_snippets)}
+
+## OpenMP Directives Detected:
+{''.join(pragmas)}
+
+## Summary:
+"""
+return prompt
+
+def generate_summary(prompt):
+response = requests.post(
+"https://api.groq.com/openai/v1/chat/completions";,
+headers={
+"Authorization": f"Bearer {GROQ_API_KEY}",
+"Content-Type": "application/json"
+},
+json={
+"model": "llama3-70b-8192",
+"messages": [
+{"role": "system", "content": "You are a helpful assistant for 
code reviewers."},
+{"role": "user", "content": prompt},
+]
+}
+)
+response.raise_for_status()
+return response.json()['choices'][0]['message']['content'].strip()
+
+SECTION_LINKS = {
+"parallel": "https://www.openmp.org/spec-html/6.0/openmpsu35.html";,
+"worksharing": "https://www.openmp.org/spec-html/6.0/openmpsu46.html";,
+}
+
+def build_markdown_output(summary_text: str, spec_snippets: List[str]) -> str:
+linked_snippets = []
+for snippet in spec_snippets:
+for title, url in SECTION_LINKS.items():
+if title.lower() in snippet.lower():
+snippet += f"\n\n🔗 [Spec Link]({url})"
+break
+linked_snippets.append(snippet)
+
+return f"""## 📝 Pull Request Summary
+
+{summary_text}
+
+---
+
+## 📚 Related OpenMP Spec Sections
+{''.join(f"```text\n{snippet}\n```\n\n" for snippet in linked_snippets)}"""
+
+# -- COMMANDS --
+@app.command()
+def describe(pr_number: int, spec_path: str = r"D:\Web 
Development\CD_LAB\openmp_6_0_sections.txt"):
+"""Generate structured PR summary from GitHub PR number."""
+title = fetch_pr_title(pr_number)
+diff = fetch_pr_diff(pr_number)
+sections = load_spec_sections(spec_path)
+index, emb, sec = index_spec(sect

[clang] [TableGen] Use ListSeparator (NFC) (PR #144936)

2025-06-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/144936

Note that an instance of ListSeparator evaluates to the empty string
for the first time and then ", " for subsequent references.


>From f0907a039a6de8fe305a5eac1b4e41fd1adff7bd Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Mon, 16 Jun 2025 00:35:25 -0700
Subject: [PATCH] [TableGen] Use ListSeparator (NFC)

Note that an instance of ListSeparator evaluates to the empty string
for the first time and then ", " for subsequent references.
---
 clang/utils/TableGen/ClangAttrEmitter.cpp| 6 ++
 clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 9 +++--
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index f892626a447e5..dfeb6b1b1ec19 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -5482,14 +5482,12 @@ void EmitTestPragmaAttributeSupportedAttributes(const 
RecordKeeper &Records,
 }
 const Record *SubjectObj = I.second->getValueAsDef("Subjects");
 OS << " (";
-bool PrintComma = false;
+ListSeparator LS;
 for (const auto &Subject :
  enumerate(SubjectObj->getValueAsListOfDefs("Subjects"))) {
   if (!isSupportedPragmaClangAttributeSubject(*Subject.value()))
 continue;
-  if (PrintComma)
-OS << ", ";
-  PrintComma = true;
+  OS << LS;
   PragmaClangAttributeSupport::RuleOrAggregateRuleSet &RuleSet =
   Support.SubjectsToRules.find(Subject.value())->getSecond();
   if (RuleSet.isRule()) {
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index bfc60f485cd32..b28cb2c09ac5c 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -2225,13 +2225,10 @@ void clang::EmitClangDiagDocs(const RecordKeeper 
&Records, raw_ostream &OS) {
   else
 OS << "Also controls ";
 
-  bool First = true;
   sort(GroupInfo.SubGroups);
-  for (StringRef Name : GroupInfo.SubGroups) {
-if (!First) OS << ", ";
-OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
-First = false;
-  }
+  ListSeparator LS;
+  for (StringRef Name : GroupInfo.SubGroups)
+OS << LS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
   OS << ".\n\n";
 }
 

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


[clang] [TableGen] Use ListSeparator (NFC) (PR #144936)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes

Note that an instance of ListSeparator evaluates to the empty string
for the first time and then ", " for subsequent references.


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


2 Files Affected:

- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+2-4) 
- (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+3-6) 


``diff
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index f892626a447e5..dfeb6b1b1ec19 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -5482,14 +5482,12 @@ void EmitTestPragmaAttributeSupportedAttributes(const 
RecordKeeper &Records,
 }
 const Record *SubjectObj = I.second->getValueAsDef("Subjects");
 OS << " (";
-bool PrintComma = false;
+ListSeparator LS;
 for (const auto &Subject :
  enumerate(SubjectObj->getValueAsListOfDefs("Subjects"))) {
   if (!isSupportedPragmaClangAttributeSubject(*Subject.value()))
 continue;
-  if (PrintComma)
-OS << ", ";
-  PrintComma = true;
+  OS << LS;
   PragmaClangAttributeSupport::RuleOrAggregateRuleSet &RuleSet =
   Support.SubjectsToRules.find(Subject.value())->getSecond();
   if (RuleSet.isRule()) {
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index bfc60f485cd32..b28cb2c09ac5c 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -2225,13 +2225,10 @@ void clang::EmitClangDiagDocs(const RecordKeeper 
&Records, raw_ostream &OS) {
   else
 OS << "Also controls ";
 
-  bool First = true;
   sort(GroupInfo.SubGroups);
-  for (StringRef Name : GroupInfo.SubGroups) {
-if (!First) OS << ", ";
-OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
-First = false;
-  }
+  ListSeparator LS;
+  for (StringRef Name : GroupInfo.SubGroups)
+OS << LS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
   OS << ".\n\n";
 }
 

``




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


[clang] [llvm] [ObjCARC] Delete empty autoreleasepools with no autoreleases in them (PR #144788)

2025-06-19 Thread via cfe-commits

https://github.com/AZero13 updated 
https://github.com/llvm/llvm-project/pull/144788

>From e63c64bb71e99e822557b2d80b26d21648e3e0ec Mon Sep 17 00:00:00 2001
From: Rose 
Date: Wed, 18 Jun 2025 16:05:44 -0400
Subject: [PATCH 1/2] [ObjCARC] Delete empty autoreleasepools with no
 autoreleases in them

Erase empty autorelease pools that have no autorelease in them
---
 .../ObjCARC/ARCRuntimeEntryPoints.h   |  16 +++
 llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp   | 123 +-
 .../ObjCARC/test_autorelease_pool.ll  | 118 +
 3 files changed, 252 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/Transforms/ObjCARC/test_autorelease_pool.ll

diff --git a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h 
b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
index 3fa844eda21cf..6135c7b938a3e 100644
--- a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
+++ b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
@@ -46,6 +46,8 @@ enum class ARCRuntimeEntryPointKind {
   UnsafeClaimRV,
   RetainAutorelease,
   RetainAutoreleaseRV,
+  AutoreleasePoolPush,
+  AutoreleasePoolPop,
 };
 
 /// Declarations for ObjC runtime functions and constants. These are 
initialized
@@ -67,6 +69,8 @@ class ARCRuntimeEntryPoints {
 UnsafeClaimRV = nullptr;
 RetainAutorelease = nullptr;
 RetainAutoreleaseRV = nullptr;
+AutoreleasePoolPush = nullptr;
+AutoreleasePoolPop = nullptr;
   }
 
   Function *get(ARCRuntimeEntryPointKind kind) {
@@ -101,6 +105,12 @@ class ARCRuntimeEntryPoints {
 case ARCRuntimeEntryPointKind::RetainAutoreleaseRV:
   return getIntrinsicEntryPoint(RetainAutoreleaseRV,
 Intrinsic::objc_retainAutoreleaseReturnValue);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPush:
+  return getIntrinsicEntryPoint(AutoreleasePoolPush,
+Intrinsic::objc_autoreleasePoolPush);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPop:
+  return getIntrinsicEntryPoint(AutoreleasePoolPop,
+Intrinsic::objc_autoreleasePoolPop);
 }
 
 llvm_unreachable("Switch should be a covered switch.");
@@ -143,6 +153,12 @@ class ARCRuntimeEntryPoints {
   /// Declaration for objc_retainAutoreleaseReturnValue().
   Function *RetainAutoreleaseRV = nullptr;
 
+  /// Declaration for objc_autoreleasePoolPush().
+  Function *AutoreleasePoolPush = nullptr;
+
+  /// Declaration for objc_autoreleasePoolPop().
+  Function *AutoreleasePoolPop = nullptr;
+
   Function *getIntrinsicEntryPoint(Function *&Decl, Intrinsic::ID IntID) {
 if (Decl)
   return Decl;
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 5eb3f51d38945..deec643532c5d 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Analysis/ObjCARCAnalysisUtils.h"
 #include "llvm/Analysis/ObjCARCInstKind.h"
 #include "llvm/Analysis/ObjCARCUtil.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constant.h"
@@ -132,11 +133,8 @@ static const Value *FindSingleUseIdentifiedObject(const 
Value *Arg) {
 //
 // The second retain and autorelease can be deleted.
 
-// TODO: It should be possible to delete
-// objc_autoreleasePoolPush and objc_autoreleasePoolPop
-// pairs if nothing is actually autoreleased between them. Also, autorelease
-// calls followed by objc_autoreleasePoolPop calls (perhaps in ObjC++ code
-// after inlining) can be turned into plain release calls.
+// TODO: Autorelease calls followed by objc_autoreleasePoolPop calls (perhaps 
in
+// ObjC++ code after inlining) can be turned into plain release calls.
 
 // TODO: Critical-edge splitting. If the optimial insertion point is
 // a critical edge, the current algorithm has to fail, because it doesn't
@@ -566,6 +564,8 @@ class ObjCARCOpt {
 
   void OptimizeReturns(Function &F);
 
+  void OptimizeAutoreleasePools(Function &F);
+
   template 
   static void cloneOpBundlesIf(CallBase *CI,
SmallVectorImpl &OpBundles,
@@ -2473,6 +2473,11 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
 (1 << unsigned(ARCInstKind::AutoreleaseRV
 OptimizeReturns(F);
 
+  // Optimizations for autorelease pools.
+  if (UsedInThisFunction & ((1 << unsigned(ARCInstKind::AutoreleasepoolPush)) |
+(1 << unsigned(ARCInstKind::AutoreleasepoolPop
+OptimizeAutoreleasePools(F);
+
   // Gather statistics after optimization.
 #ifndef NDEBUG
   if (AreStatisticsEnabled()) {
@@ -2485,6 +2490,114 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
   return Changed;
 }
 
+/// Optimize autorelease pools by eliminating empty push/pop pairs.
+void ObjCARCOpt::OptimizeAutoreleasePools(Function &F) {
+  LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::Optimiz

[clang] [llvm] [ObjCARC] Delete empty autoreleasepools with no autoreleases in them (PR #144788)

2025-06-19 Thread via cfe-commits

https://github.com/AZero13 updated 
https://github.com/llvm/llvm-project/pull/144788

>From e63c64bb71e99e822557b2d80b26d21648e3e0ec Mon Sep 17 00:00:00 2001
From: Rose 
Date: Wed, 18 Jun 2025 16:05:44 -0400
Subject: [PATCH 1/2] [ObjCARC] Delete empty autoreleasepools with no
 autoreleases in them

Erase empty autorelease pools that have no autorelease in them
---
 .../ObjCARC/ARCRuntimeEntryPoints.h   |  16 +++
 llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp   | 123 +-
 .../ObjCARC/test_autorelease_pool.ll  | 118 +
 3 files changed, 252 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/Transforms/ObjCARC/test_autorelease_pool.ll

diff --git a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h 
b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
index 3fa844eda21cf..6135c7b938a3e 100644
--- a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
+++ b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
@@ -46,6 +46,8 @@ enum class ARCRuntimeEntryPointKind {
   UnsafeClaimRV,
   RetainAutorelease,
   RetainAutoreleaseRV,
+  AutoreleasePoolPush,
+  AutoreleasePoolPop,
 };
 
 /// Declarations for ObjC runtime functions and constants. These are 
initialized
@@ -67,6 +69,8 @@ class ARCRuntimeEntryPoints {
 UnsafeClaimRV = nullptr;
 RetainAutorelease = nullptr;
 RetainAutoreleaseRV = nullptr;
+AutoreleasePoolPush = nullptr;
+AutoreleasePoolPop = nullptr;
   }
 
   Function *get(ARCRuntimeEntryPointKind kind) {
@@ -101,6 +105,12 @@ class ARCRuntimeEntryPoints {
 case ARCRuntimeEntryPointKind::RetainAutoreleaseRV:
   return getIntrinsicEntryPoint(RetainAutoreleaseRV,
 Intrinsic::objc_retainAutoreleaseReturnValue);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPush:
+  return getIntrinsicEntryPoint(AutoreleasePoolPush,
+Intrinsic::objc_autoreleasePoolPush);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPop:
+  return getIntrinsicEntryPoint(AutoreleasePoolPop,
+Intrinsic::objc_autoreleasePoolPop);
 }
 
 llvm_unreachable("Switch should be a covered switch.");
@@ -143,6 +153,12 @@ class ARCRuntimeEntryPoints {
   /// Declaration for objc_retainAutoreleaseReturnValue().
   Function *RetainAutoreleaseRV = nullptr;
 
+  /// Declaration for objc_autoreleasePoolPush().
+  Function *AutoreleasePoolPush = nullptr;
+
+  /// Declaration for objc_autoreleasePoolPop().
+  Function *AutoreleasePoolPop = nullptr;
+
   Function *getIntrinsicEntryPoint(Function *&Decl, Intrinsic::ID IntID) {
 if (Decl)
   return Decl;
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 5eb3f51d38945..deec643532c5d 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Analysis/ObjCARCAnalysisUtils.h"
 #include "llvm/Analysis/ObjCARCInstKind.h"
 #include "llvm/Analysis/ObjCARCUtil.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constant.h"
@@ -132,11 +133,8 @@ static const Value *FindSingleUseIdentifiedObject(const 
Value *Arg) {
 //
 // The second retain and autorelease can be deleted.
 
-// TODO: It should be possible to delete
-// objc_autoreleasePoolPush and objc_autoreleasePoolPop
-// pairs if nothing is actually autoreleased between them. Also, autorelease
-// calls followed by objc_autoreleasePoolPop calls (perhaps in ObjC++ code
-// after inlining) can be turned into plain release calls.
+// TODO: Autorelease calls followed by objc_autoreleasePoolPop calls (perhaps 
in
+// ObjC++ code after inlining) can be turned into plain release calls.
 
 // TODO: Critical-edge splitting. If the optimial insertion point is
 // a critical edge, the current algorithm has to fail, because it doesn't
@@ -566,6 +564,8 @@ class ObjCARCOpt {
 
   void OptimizeReturns(Function &F);
 
+  void OptimizeAutoreleasePools(Function &F);
+
   template 
   static void cloneOpBundlesIf(CallBase *CI,
SmallVectorImpl &OpBundles,
@@ -2473,6 +2473,11 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
 (1 << unsigned(ARCInstKind::AutoreleaseRV
 OptimizeReturns(F);
 
+  // Optimizations for autorelease pools.
+  if (UsedInThisFunction & ((1 << unsigned(ARCInstKind::AutoreleasepoolPush)) |
+(1 << unsigned(ARCInstKind::AutoreleasepoolPop
+OptimizeAutoreleasePools(F);
+
   // Gather statistics after optimization.
 #ifndef NDEBUG
   if (AreStatisticsEnabled()) {
@@ -2485,6 +2490,114 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
   return Changed;
 }
 
+/// Optimize autorelease pools by eliminating empty push/pop pairs.
+void ObjCARCOpt::OptimizeAutoreleasePools(Function &F) {
+  LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::Optimiz

[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Finn Plummer via cfe-commits

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Finn Plummer via cfe-commits

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Finn Plummer via cfe-commits

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

>From 6ee2563c4b2d69b252467b9896a1d8b943af384d Mon Sep 17 00:00:00 2001
From: Finn Plummer 
Date: Tue, 20 May 2025 19:47:29 +
Subject: [PATCH 1/2] rebased original version

---
 .../clang/Basic/DiagnosticSemaKinds.td|   5 +
 clang/include/clang/Sema/SemaHLSL.h   |   2 +
 clang/lib/Sema/SemaHLSL.cpp   | 113 +-
 .../RootSignature-resource-ranges-err.hlsl|  26 
 .../RootSignature-resource-ranges.hlsl|  22 
 .../Frontend/HLSL/HLSLRootSignatureUtils.h|  10 +-
 6 files changed, 174 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/SemaHLSL/RootSignature-resource-ranges-err.hlsl
 create mode 100644 clang/test/SemaHLSL/RootSignature-resource-ranges.hlsl

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 34b798a09c216..f2f2152b8bbbe 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -13054,6 +13054,11 @@ def err_invalid_hlsl_resource_type: Error<
 def err_hlsl_spirv_only: Error<"%0 is only available for the SPIR-V target">;
 def err_hlsl_vk_literal_must_contain_constant: Error<"the argument to 
vk::Literal must be a vk::integral_constant">;
 
+def err_hlsl_resource_range_overlap: Error<
+  "resource ranges %select{t|u|b|s}0[%1;%2] and %select{t|u|b|s}3[%4;%5] "
+  "overlap within space = %6 and visibility = "
+  "%select{All|Vertex|Hull|Domain|Geometry|Pixel|Amplification|Mesh}7">;
+
 // Layout randomization diagnostics.
 def err_non_designated_init_used : Error<
   "a randomized struct can only be initialized with a designated initializer">;
diff --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index 97091792ba236..7d7eae4db532c 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -134,6 +134,8 @@ class SemaHLSL : public SemaBase {
   SourceLocation Loc, IdentifierInfo *DeclIdent,
   SmallVector &Elements);
 
+  // Returns true when D is invalid and a diagnostic was produced
+  bool handleRootSignatureDecl(HLSLRootSignatureDecl *D, SourceLocation Loc);
   void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL);
   void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL);
   void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL);
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 9b43ee00810b2..650fd733b71a9 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -39,6 +39,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Frontend/HLSL/HLSLRootSignatureUtils.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/DXILABI.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1068,10 +1069,121 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
   SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
   DeclIdent, Elements);
 
+  // Perform validation of constructs here
+  if (handleRootSignatureDecl(SignatureDecl, Loc))
+return;
+
   SignatureDecl->setImplicit();
   SemaRef.PushOnScopeChains(SignatureDecl, SemaRef.getCurScope());
 }
 
+namespace {
+
+// A resource range overlaps with another resource range if they have:
+// - equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
+// - equivalent resource space
+// - overlapping visbility
+class ResourceRanges {
+public:
+  // KeyT: 32-lsb denotes resource space, and 32-msb denotes ResourceClass enum
+  using KeyT = std::pair;
+
+  static const size_t NumVisEnums = 8;
+
+private:
+  llvm::hlsl::rootsig::ResourceRange::MapT::Allocator Allocator;
+
+  // Denotes a mapping of a unique combination of ResourceClass and register
+  // space to a ResourceRange
+  using MapT = llvm::SmallDenseMap;
+
+  // Denotes a mapping for each unique visibility
+  MapT RangeMaps[NumVisEnums];
+
+  constexpr static KeyT getKey(const llvm::hlsl::rootsig::RangeInfo &Info) {
+return {Info.Class, Info.Space};
+  }
+
+public:
+  // Returns std::nullopt if there was no collision. Otherwise, it will
+  // return the RangeInfo of the collision
+  std::optional
+  addRange(const llvm::hlsl::rootsig::RangeInfo &Info) {
+MapT &VisRangeMap = RangeMaps[llvm::to_underlying(Info.Vis)];
+auto [It, _] = VisRangeMap.insert(
+{getKey(Info), llvm::hlsl::rootsig::ResourceRange(Allocator)});
+auto Res = It->second.insert(Info);
+if (Res.has_value())
+  return Res;
+
+// If the range that we are inserting has ShaderVisiblity::All it needs to
+// check for an overlap in all other visibility types as well.
+// Otherwise, the range that is inserted needs to check that it does not
+// overlap with ShaderVisibility::All.
+//
+// Maps will be an ArrayRef to all non-all visibility RangeMaps in the
+// former case and it will be an 

[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Finn Plummer via cfe-commits


@@ -1068,10 +1069,139 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
   SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
   DeclIdent, Elements);
 
+  // Perform validation of constructs here
+  if (handleRootSignatureDecl(SignatureDecl, Loc))
+return;
+
   SignatureDecl->setImplicit();
   SemaRef.PushOnScopeChains(SignatureDecl, SemaRef.getCurScope());
 }
 
+bool SemaHLSL::handleRootSignatureDecl(HLSLRootSignatureDecl *D,
+   SourceLocation Loc) {
+  auto Elements = D->getRootElements();
+
+  // The following conducts analysis on resource ranges to detect and report
+  // any overlaps in resource ranges.
+  //
+  // A resource range overlaps with another resource range if they have:
+  // - equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
+  // - equivalent resource space
+  // - overlapping visbility
+  //
+  // The following algorithm is implemented in the following steps:
+  //
+  // 1. Collect RangeInfo from relevant RootElements:
+  //   - RangeInfo will retain the interval, ResourceClass, Space and 
Visibility
+  // 2. Sort the RangeInfo's such that they are grouped together by
+  //  ResourceClass and Space (GroupT defined below)
+  // 3. Iterate through the collected RangeInfos by their groups
+  //   - For each group we will have a ResourceRange for each visibility
+  //   - As we iterate through we will:
+  //  A: Insert the current RangeInfo into the corresponding Visibility
+  //   ResourceRange
+  //  B: Check for overlap with any overlapping Visibility ResourceRange
+  using RangeInfo = llvm::hlsl::rootsig::RangeInfo;
+  using ResourceRange = llvm::hlsl::rootsig::ResourceRange;
+  using GroupT = std::pair;
+
+  // 1. Collect RangeInfos
+  llvm::SmallVector Infos;
+  for (const auto &Elem : Elements) {
+if (const auto *Descriptor =
+std::get_if(&Elem)) {
+  RangeInfo Info;
+  Info.LowerBound = Descriptor->Reg.Number;
+  Info.UpperBound = Info.LowerBound; // use inclusive ranges []
+
+  Info.Class =
+  llvm::dxil::ResourceClass(llvm::to_underlying(Descriptor->Type));
+  Info.Space = Descriptor->Space;
+  Info.Vis = Descriptor->Visibility;
+  Infos.push_back(Info);
+}
+  }
+
+  // 2. Sort the RangeInfo's by their GroupT to form groupings
+  std::sort(Infos.begin(), Infos.end(), [](RangeInfo A, RangeInfo B) {
+return std::tie(A.Class, A.Space) < std::tie(B.Class, B.Space);
+  });
+
+  // 3. First we will init our state to track:
+  if (Infos.size() == 0)
+return false; // No ranges to overlap
+  GroupT CurGroup = {Infos[0].Class, Infos[0].Space};
+  bool HadOverlap = false;
+
+  // Create a ResourceRange for each Visibility
+  ResourceRange::MapT::Allocator Allocator;
+  SmallVector Ranges = {
+  ResourceRange(Allocator), // All
+  ResourceRange(Allocator), // Vertex
+  ResourceRange(Allocator), // Hull
+  ResourceRange(Allocator), // Domain
+  ResourceRange(Allocator), // Geometry
+  ResourceRange(Allocator), // Pixel
+  ResourceRange(Allocator), // Amplification
+  ResourceRange(Allocator), // Mesh
+  };
+
+  // Reset the ResourceRanges for when we iterate through a new group
+  auto ClearRanges = [&Ranges]() {
+for (ResourceRange &Range : Ranges)
+  Range.clear();
+  };
+
+  // Helper to report diagnostics
+  auto ReportOverlap = [this, Loc, &HadOverlap](const RangeInfo *Info,
+const RangeInfo *OInfo) {
+HadOverlap = true;
+auto CommonVis = Info->Vis == llvm::hlsl::rootsig::ShaderVisibility::All
+ ? OInfo->Vis
+ : Info->Vis;
+this->Diag(Loc, diag::err_hlsl_resource_range_overlap)
+<< llvm::to_underlying(Info->Class) << Info->LowerBound
+<< Info->UpperBound << llvm::to_underlying(OInfo->Class)
+<< OInfo->LowerBound << OInfo->UpperBound << Info->Space << CommonVis;
+  };
+
+  // 3: Iterate throught collected RangeInfos
+  for (const RangeInfo &Info : Infos) {
+GroupT InfoGroup = {Info.Class, Info.Space};
+// Reset our ResourceRanges when we enter a new group
+if (CurGroup != InfoGroup) {
+  ClearRanges();
+  CurGroup = InfoGroup;
+}
+
+// 3A: Insert range info into corresponding Visibility ResourceRange
+ResourceRange &VisRange = Ranges[llvm::to_underlying(Info.Vis)];
+if (auto Overlapping = VisRange.insert(Info))
+  ReportOverlap(&Info, Overlapping.value());
+
+// 3B: Check for overlap in all overlapping Visibility ResourceRanges
+//
+// If the range that we are inserting has ShaderVisiblity::All it needs to
+// check for an overlap in all other visibility types as well.
+// Otherwise, the range that is inserted needs to check that it does not
+// overlap with ShaderVisibility::All.
+//
+// Maps will be an ArrayRef to all non-all visibility RangeMaps in the

inbelic wrote:

```sug

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits


@@ -181,42 +160,105 @@ void ConfusableIdentifierCheck::check(
   if (!ND)
 return;
 
-  IdentifierInfo *NDII = ND->getIdentifier();
+  addDeclToCheck(ND, cast(ND->getDeclContext()
+->getNonTransparentContext()));
+
+  // Associate template parameters with this declaration of this template.
+  if (const auto *TD = dyn_cast(ND)) {
+for (const NamedDecl *Param : *TD->getTemplateParameters())
+  addDeclToCheck(Param, TD->getTemplatedDecl());
+  }
+
+  // Associate function parameters with this declaration of this function.
+  if (const auto *FD = dyn_cast(ND)) {
+for (const NamedDecl *Param : FD->parameters())
+  addDeclToCheck(Param, ND);
+  }
+}
+
+void ConfusableIdentifierCheck::addDeclToCheck(const NamedDecl *ND,
+   const Decl *Parent) {
+  const IdentifierInfo *NDII = ND->getIdentifier();
   if (!NDII)
 return;
 
   StringRef NDName = NDII->getName();
   if (NDName.empty())
 return;
 
-  const ContextInfo *Info = getContextInfo(ND->getDeclContext());
+  NameToDecls[NDII].push_back({ND, Parent});
+}
+
+void ConfusableIdentifierCheck::onEndOfTranslationUnit() {
+  llvm::StringMap> 
SkeletonToNames;
+  // Compute the skeleton for each identifier.
+  for (auto &[Ident, Decls] : NameToDecls) {
+SkeletonToNames[skeleton(Ident->getName())].push_back(Ident);
+  }
 
-  llvm::SmallVector &Mapped = Mapper[skeleton(NDName)];
-  for (const Entry &E : Mapped) {
-if (!mayShadow(ND, Info, E.Declaration, E.Info))
+  // Visit each skeleton with more than one identifier.
+  for (auto &[Skel, Idents] : SkeletonToNames) {
+if (Idents.size() < 2) {
   continue;
+}
 
-const IdentifierInfo *ONDII = E.Declaration->getIdentifier();
-StringRef ONDName = ONDII->getName();
-if (ONDName == NDName)
-  continue;
+// Find the declaration contexts that transitively contain each identifier.
+DeclsWithinContextMap DeclsWithinContext;

5chmidti wrote:

nit: speaking of performance, you could keep this map outside the `for (auto 
&[Skel, Idents] : SkeletonToNames) {`  loop and clear the map so that there are 
not too many allocations. While this is almost a micro optimization at this 
level, the `for (auto &[Skel, Idents] : SkeletonToNames) {` will be executed 
quite a lot, so it might shave off the tiniest bit of additional time. If you 
do choose to look at this and compare the numbers and this does not really 
matter, then I'd keep it as-is for the smaller var scope.

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


[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.

LGTM. Thanks for the quite big performance improvement, and sorry this took a 
bit until it was reviewed.

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


[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits


@@ -181,42 +160,105 @@ void ConfusableIdentifierCheck::check(
   if (!ND)
 return;
 
-  IdentifierInfo *NDII = ND->getIdentifier();
+  addDeclToCheck(ND, cast(ND->getDeclContext()
+->getNonTransparentContext()));
+
+  // Associate template parameters with this declaration of this template.
+  if (const auto *TD = dyn_cast(ND)) {
+for (const NamedDecl *Param : *TD->getTemplateParameters())
+  addDeclToCheck(Param, TD->getTemplatedDecl());
+  }
+
+  // Associate function parameters with this declaration of this function.
+  if (const auto *FD = dyn_cast(ND)) {
+for (const NamedDecl *Param : FD->parameters())
+  addDeclToCheck(Param, ND);
+  }
+}
+
+void ConfusableIdentifierCheck::addDeclToCheck(const NamedDecl *ND,

5chmidti wrote:

Thinking about clangd and incomplete code, I think this is the only part in 
your changes I would suggest adding additional `nullptr` handling (for `ND` and 
`Parent`), just to be on the safe side.

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


[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-19 Thread Julian Schmidt via cfe-commits

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


[clang] a9d175f - [CodeGen] Use range-based for loops (NFC) (#144939)

2025-06-19 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-06-19T14:57:58-07:00
New Revision: a9d175f1735a508ac05ab48d83a99071ba97c10e

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

LOG: [CodeGen] Use range-based for loops (NFC) (#144939)

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCleanup.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGException.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGObjCRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 729758ddce560..f3ddf7bf9a463 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1415,10 +1415,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(
   // Arrange for local static and local extern declarations to appear
   // to be local to this function as well, in case they're directly
   // referenced in a block.
-  for (DeclMapTy::const_iterator i = ldm.begin(), e = ldm.end(); i != e; ++i) {
-const auto *var = dyn_cast(i->first);
+  for (const auto &KV : ldm) {
+const auto *var = dyn_cast(KV.first);
 if (var && !var->hasLocalStorage())
-  setAddrOfLocalVar(var, i->second);
+  setAddrOfLocalVar(var, KV.second);
   }
 
   // Begin building the function declaration.

diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 4ed2c5183c47e..28ac9bf396356 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -962,8 +962,8 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough,
 
   // Append the prepared cleanup prologue from above.
   llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
-  for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
-InstsToAppend[I]->insertInto(NormalExit, NormalExit->end());
+  for (llvm::Instruction *Inst : InstsToAppend)
+Inst->insertInto(NormalExit, NormalExit->end());
 
   // Optimistically hope that any fixups will continue falling through.
   for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 69d77f283db3b..7ae99935c8ad3 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1121,9 +1121,9 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function 
*Fn,
   EmitObjCAutoreleasePoolCleanup(token);
 }
 
-for (unsigned i = 0, e = Decls.size(); i != e; ++i)
-  if (Decls[i])
-EmitRuntimeCall(Decls[i]);
+for (llvm::Function *Decl : Decls)
+  if (Decl)
+EmitRuntimeCall(Decl);
 
 Scope.ForceCleanup();
 

diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index e0367282355cf..ad138b9876e8c 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -319,9 +319,9 @@ static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) {
 llvm::Function *F = dyn_cast(U);
 if (!F) return false;
 
-for (auto BB = F->begin(), E = F->end(); BB != E; ++BB) {
-  if (BB->isLandingPad())
-if (!LandingPadHasOnlyCXXUses(BB->getLandingPadInst()))
+for (llvm::BasicBlock &BB : *F) {
+  if (BB.isLandingPad())
+if (!LandingPadHasOnlyCXXUses(BB.getLandingPadInst()))
   return false;
 }
   }
@@ -937,8 +937,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {
  filterTypes[0]->getType() : Int8PtrTy,
filterTypes.size());
 
-for (unsigned i = 0, e = filterTypes.size(); i != e; ++i)
-  Filters.push_back(cast(filterTypes[i]));
+for (llvm::Value *filterType : filterTypes)
+  Filters.push_back(cast(filterType));
 llvm::Constant *FilterArray = llvm::ConstantArray::get(AType, Filters);
 LPadInst->addClause(FilterArray);
 

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6cb348ffdf55f..85c768807572f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3801,8 +3801,8 @@ void CodeGenFunction::EmitCheck(
   ArgTypes.push_back(Args.back()->getType());
 }
 
-for (size_t i = 0, n = DynamicArgs.size(); i != n; ++i) {
-  Args.push_back(EmitCheckValue(DynamicArgs[i]));
+for (llvm::Value *DynamicArg : DynamicArgs) {
+  Args.push_back(EmitCheckValue(DynamicArg));
   ArgTypes.push_back(IntPtrTy);
 }
   }
@@ -4932,8 +4932,8 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
   llvm::Constant *BaseElts = Base.getExtVectorElts();
   SmallVector CElts;
 
-  for (unsigned

[clang] [CodeGen] Use range-based for loops (NFC) (PR #144939)

2025-06-19 Thread Kazu Hirata via cfe-commits

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


[clang] [llvm] [HLSL][RootSignature] Add `hlsl-rootsig-ver` option to specify root signature version (PR #144813)

2025-06-19 Thread Finn Plummer via cfe-commits




inbelic wrote:

Going through the commits 1 by 1 should be easier to read then from top to 
bottom of this diff.

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


[clang] [AArch64] Add option -msve-streaming-vector-bits= . (PR #144611)

2025-06-19 Thread Pengcheng Wang via cfe-commits


@@ -1034,9 +1034,16 @@ class TargetInfo : public TransferrableTargetInfo,
   /// set of primary and secondary targets.
   virtual llvm::SmallVector getTargetBuiltins() const = 0;
 
+  enum class ArmStreamingKind {
+NotStreaming,
+StreamingCompatible,
+Streaming,
+  };
+
   /// Returns target-specific min and max values VScale_Range.
   virtual std::optional>
-  getVScaleRange(const LangOptions &LangOpts, bool IsArmStreamingFunction,
+  getVScaleRange(const LangOptions &LangOpts,
+ ArmStreamingKind IsArmStreamingFunction,

wangpc-pp wrote:

Okay I didn't how it is used. Please go ahead.

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


[clang] [llvm] [HLSL][RootSignature] Add `hlsl-rootsig-ver` option to specify root signature version (PR #144813)

2025-06-19 Thread Justin Bogner via cfe-commits

https://github.com/bogner commented:

The implementation all looks fairly straightforward here, but shouldn't we be 
naming the `clang-dxc` flag to match `dxc`'s flag that does this? That is, 
`-force-rootsig-ver`.

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


[clang] [llvm] [HLSL][RootSignature] Add `hlsl-rootsig-ver` option to specify root signature version (PR #144813)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -5179,6 +5179,8 @@ class HLSLRootSignatureDecl final
 llvm::hlsl::rootsig::RootElement> {
   friend TrailingObjects;
 
+  llvm::dxil::RootSignatureVersion RootSigVer;

bogner wrote:

This is a member of a HLSLRootSignatureDecl - it can probably just be called 
Version.

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


[clang] [llvm] [HLSL][RootSignature] Add `hlsl-rootsig-ver` option to specify root signature version (PR #144813)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -99,6 +99,12 @@ enum class SamplerFeedbackType : uint32_t {
 const unsigned MinWaveSize = 4;
 const unsigned MaxWaveSize = 128;
 
+// D3D_ROOT_SIGNATURE_VERSION
+enum class RootSignatureVersion {
+  rootsig_1_0 = 0x1,
+  rootsig_1_1 = 0x2,
+};

bogner wrote:

Should these be defined in BinaryFormat/DXContainer.h with the other d3d12 
constants? They don't seem like they belong in DXILABI to me.

Also the naming here feels a bit awkward - we're kind of repeating ourselves 
with `RootSignatureVersion::rootsig_1_0` - Should it just be 
`RootSignatureVersion::V1_0` or something like that?

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


[clang] [llvm] [HLSL][RootSignature] Add `hlsl-rootsig-ver` option to specify root signature version (PR #144813)

2025-06-19 Thread Justin Bogner via cfe-commits

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


[clang] [clang] Migrate away from ArrayRef(std::nullopt) (NFC) (PR #144982)

2025-06-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/144982

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the clang side of the migration.


>From e4e64ca614a08b2c642e8089e489c405610e96eb Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Thu, 19 Jun 2025 21:34:13 -0700
Subject: [PATCH] [clang] Migrate away from ArrayRef(std::nullopt) (NFC)

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the clang side of the migration.
---
 clang/include/clang/AST/TypeProperties.td | 2 +-
 clang/lib/AST/ASTContext.cpp  | 4 ++--
 clang/lib/AST/ASTDiagnostic.cpp   | 4 ++--
 clang/lib/AST/ASTImporter.cpp | 2 +-
 clang/lib/AST/DeclTemplate.cpp| 2 +-
 clang/lib/AST/QualTypeNames.cpp   | 5 ++---
 clang/lib/Basic/Targets/Xtensa.h  | 2 +-
 clang/lib/CodeGen/CGBuiltin.cpp   | 2 +-
 clang/lib/Driver/ToolChains/Clang.cpp | 4 ++--
 clang/lib/Sema/SemaConcept.cpp| 4 ++--
 clang/lib/Sema/SemaExpr.cpp   | 2 +-
 clang/lib/Sema/TreeTransform.h| 2 +-
 12 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 6e44bce893e79..d7dbf1b43df26 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -753,7 +753,7 @@ let Class = TemplateSpecializationType in {
   }
 
   def : Creator<[{
-return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, 
UnderlyingType);
+return ctx.getTemplateSpecializationType(templateName, args, {}, 
UnderlyingType);
   }]>;
 }
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 189e67e4eed0d..74be2871f270c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14283,7 +14283,7 @@ static QualType getCommonNonSugarTypeNode(ASTContext 
&Ctx, const Type *X,
 ::getCommonTemplateNameChecked(Ctx, TX->getTemplateName(),
TY->getTemplateName(),
/*IgnoreDeduced=*/true),
-As, /*CanonicalArgs=*/std::nullopt, X->getCanonicalTypeInternal());
+As, /*CanonicalArgs=*/{}, X->getCanonicalTypeInternal());
   }
   case Type::Decltype: {
 const auto *DX = cast(X);
@@ -14529,7 +14529,7 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, 
const Type *X,
TY->template_arguments()))
   return QualType();
 return Ctx.getTemplateSpecializationType(CTN, As,
- /*CanonicalArgs=*/std::nullopt,
+ /*CanonicalArgs=*/{},
  Ctx.getQualifiedType(Underlying));
   }
   case Type::Typedef: {
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index a00d5801f054b..522abd5912dbd 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -130,7 +130,7 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, 
QualType QT,
 if (DesugarArgument) {
   ShouldAKA = true;
   QT = Context.getTemplateSpecializationType(
-  TST->getTemplateName(), Args, /*CanonicalArgs=*/std::nullopt, 
QT);
+  TST->getTemplateName(), Args, /*CanonicalArgs=*/{}, QT);
 }
 break;
   }
@@ -1143,7 +1143,7 @@ class TemplateDiff {
 
 Ty = Context.getTemplateSpecializationType(
 TemplateName(CTSD->getSpecializedTemplate()),
-CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/std::nullopt,
+CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/{},
 Ty.getLocalUnqualifiedType().getCanonicalType());
 
 return Ty->getAs();
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 96a5e2eeaa4d7..4621ebb854d8e 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1664,7 +1664,7 @@ ExpectedType 
ASTNodeImporter::VisitTemplateSpecializationType(
   if (!ToUnderlyingOrErr)
 return ToUnderlyingOrErr.takeError();
   return Importer.getToContext().getTemplateSpecializationType(
-  *ToTemplateOrErr, ToTemplateArgs, std::nullopt, *ToUnderlyingOrErr);
+  *ToTemplateOrErr, ToTemplateArgs, {}, *ToUnderlyingOrErr);
 }
 
 ExpectedType ASTNodeImporter::Vi

[clang] [clang] Migrate away from ArrayRef(std::nullopt) (NFC) (PR #144982)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Kazu Hirata (kazutakahirata)


Changes

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the clang side of the migration.


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


12 Files Affected:

- (modified) clang/include/clang/AST/TypeProperties.td (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+2-2) 
- (modified) clang/lib/AST/ASTDiagnostic.cpp (+2-2) 
- (modified) clang/lib/AST/ASTImporter.cpp (+1-1) 
- (modified) clang/lib/AST/DeclTemplate.cpp (+1-1) 
- (modified) clang/lib/AST/QualTypeNames.cpp (+2-3) 
- (modified) clang/lib/Basic/Targets/Xtensa.h (+1-1) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaConcept.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+1-1) 
- (modified) clang/lib/Sema/TreeTransform.h (+1-1) 


``diff
diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 6e44bce893e79..d7dbf1b43df26 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -753,7 +753,7 @@ let Class = TemplateSpecializationType in {
   }
 
   def : Creator<[{
-return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, 
UnderlyingType);
+return ctx.getTemplateSpecializationType(templateName, args, {}, 
UnderlyingType);
   }]>;
 }
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 189e67e4eed0d..74be2871f270c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14283,7 +14283,7 @@ static QualType getCommonNonSugarTypeNode(ASTContext 
&Ctx, const Type *X,
 ::getCommonTemplateNameChecked(Ctx, TX->getTemplateName(),
TY->getTemplateName(),
/*IgnoreDeduced=*/true),
-As, /*CanonicalArgs=*/std::nullopt, X->getCanonicalTypeInternal());
+As, /*CanonicalArgs=*/{}, X->getCanonicalTypeInternal());
   }
   case Type::Decltype: {
 const auto *DX = cast(X);
@@ -14529,7 +14529,7 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, 
const Type *X,
TY->template_arguments()))
   return QualType();
 return Ctx.getTemplateSpecializationType(CTN, As,
- /*CanonicalArgs=*/std::nullopt,
+ /*CanonicalArgs=*/{},
  Ctx.getQualifiedType(Underlying));
   }
   case Type::Typedef: {
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index a00d5801f054b..522abd5912dbd 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -130,7 +130,7 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, 
QualType QT,
 if (DesugarArgument) {
   ShouldAKA = true;
   QT = Context.getTemplateSpecializationType(
-  TST->getTemplateName(), Args, /*CanonicalArgs=*/std::nullopt, 
QT);
+  TST->getTemplateName(), Args, /*CanonicalArgs=*/{}, QT);
 }
 break;
   }
@@ -1143,7 +1143,7 @@ class TemplateDiff {
 
 Ty = Context.getTemplateSpecializationType(
 TemplateName(CTSD->getSpecializedTemplate()),
-CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/std::nullopt,
+CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/{},
 Ty.getLocalUnqualifiedType().getCanonicalType());
 
 return Ty->getAs();
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 96a5e2eeaa4d7..4621ebb854d8e 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1664,7 +1664,7 @@ ExpectedType 
ASTNodeImporter::VisitTemplateSpecializationType(
   if (!ToUnderlyingOrErr)
 return ToUnderlyingOrErr.takeError();
   return Importer.getToContext().getTemplateSpecializationType(
-  *ToTemplateOrErr, ToTemplateArgs, std::nullopt, *ToUnderlyingOrErr);
+  *ToTemplateOrErr, ToTemplateArgs, {}, *ToUnderlyingOrErr);
 }
 
 ExpectedType ASTNodeImporter::VisitElaboratedType(const ElaboratedType *T) {
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index e1ef2188dbdbe..5035f2d33b0a1 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -669,7 +669,7 @@ ClassTemplateDecl::getInjectedClassNameSpecialization() {
   CommonPtr->InjectedClassNameType =
   Context.getTemplateSpecializationType(Name,
 /*SpecifiedArgs=*/TemplateArgs,
-

[clang] [clang] Migrate away from ArrayRef(std::nullopt) (NFC) (PR #144982)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-xtensa

Author: Kazu Hirata (kazutakahirata)


Changes

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the clang side of the migration.


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


12 Files Affected:

- (modified) clang/include/clang/AST/TypeProperties.td (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+2-2) 
- (modified) clang/lib/AST/ASTDiagnostic.cpp (+2-2) 
- (modified) clang/lib/AST/ASTImporter.cpp (+1-1) 
- (modified) clang/lib/AST/DeclTemplate.cpp (+1-1) 
- (modified) clang/lib/AST/QualTypeNames.cpp (+2-3) 
- (modified) clang/lib/Basic/Targets/Xtensa.h (+1-1) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaConcept.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+1-1) 
- (modified) clang/lib/Sema/TreeTransform.h (+1-1) 


``diff
diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 6e44bce893e79..d7dbf1b43df26 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -753,7 +753,7 @@ let Class = TemplateSpecializationType in {
   }
 
   def : Creator<[{
-return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, 
UnderlyingType);
+return ctx.getTemplateSpecializationType(templateName, args, {}, 
UnderlyingType);
   }]>;
 }
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 189e67e4eed0d..74be2871f270c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14283,7 +14283,7 @@ static QualType getCommonNonSugarTypeNode(ASTContext 
&Ctx, const Type *X,
 ::getCommonTemplateNameChecked(Ctx, TX->getTemplateName(),
TY->getTemplateName(),
/*IgnoreDeduced=*/true),
-As, /*CanonicalArgs=*/std::nullopt, X->getCanonicalTypeInternal());
+As, /*CanonicalArgs=*/{}, X->getCanonicalTypeInternal());
   }
   case Type::Decltype: {
 const auto *DX = cast(X);
@@ -14529,7 +14529,7 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, 
const Type *X,
TY->template_arguments()))
   return QualType();
 return Ctx.getTemplateSpecializationType(CTN, As,
- /*CanonicalArgs=*/std::nullopt,
+ /*CanonicalArgs=*/{},
  Ctx.getQualifiedType(Underlying));
   }
   case Type::Typedef: {
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index a00d5801f054b..522abd5912dbd 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -130,7 +130,7 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, 
QualType QT,
 if (DesugarArgument) {
   ShouldAKA = true;
   QT = Context.getTemplateSpecializationType(
-  TST->getTemplateName(), Args, /*CanonicalArgs=*/std::nullopt, 
QT);
+  TST->getTemplateName(), Args, /*CanonicalArgs=*/{}, QT);
 }
 break;
   }
@@ -1143,7 +1143,7 @@ class TemplateDiff {
 
 Ty = Context.getTemplateSpecializationType(
 TemplateName(CTSD->getSpecializedTemplate()),
-CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/std::nullopt,
+CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/{},
 Ty.getLocalUnqualifiedType().getCanonicalType());
 
 return Ty->getAs();
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 96a5e2eeaa4d7..4621ebb854d8e 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1664,7 +1664,7 @@ ExpectedType 
ASTNodeImporter::VisitTemplateSpecializationType(
   if (!ToUnderlyingOrErr)
 return ToUnderlyingOrErr.takeError();
   return Importer.getToContext().getTemplateSpecializationType(
-  *ToTemplateOrErr, ToTemplateArgs, std::nullopt, *ToUnderlyingOrErr);
+  *ToTemplateOrErr, ToTemplateArgs, {}, *ToUnderlyingOrErr);
 }
 
 ExpectedType ASTNodeImporter::VisitElaboratedType(const ElaboratedType *T) {
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index e1ef2188dbdbe..5035f2d33b0a1 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -669,7 +669,7 @@ ClassTemplateDecl::getInjectedClassNameSpecialization() {
   CommonPtr->InjectedClassNameType =
   Context.getTemplateSpecializationType(Name,
 /*SpecifiedArgs=*/TemplateArgs,
-   

[clang] [clang] Migrate away from ArrayRef(std::nullopt) (NFC) (PR #144982)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Kazu Hirata (kazutakahirata)


Changes

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the clang side of the migration.


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


12 Files Affected:

- (modified) clang/include/clang/AST/TypeProperties.td (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+2-2) 
- (modified) clang/lib/AST/ASTDiagnostic.cpp (+2-2) 
- (modified) clang/lib/AST/ASTImporter.cpp (+1-1) 
- (modified) clang/lib/AST/DeclTemplate.cpp (+1-1) 
- (modified) clang/lib/AST/QualTypeNames.cpp (+2-3) 
- (modified) clang/lib/Basic/Targets/Xtensa.h (+1-1) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaConcept.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+1-1) 
- (modified) clang/lib/Sema/TreeTransform.h (+1-1) 


``diff
diff --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 6e44bce893e79..d7dbf1b43df26 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -753,7 +753,7 @@ let Class = TemplateSpecializationType in {
   }
 
   def : Creator<[{
-return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, 
UnderlyingType);
+return ctx.getTemplateSpecializationType(templateName, args, {}, 
UnderlyingType);
   }]>;
 }
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 189e67e4eed0d..74be2871f270c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14283,7 +14283,7 @@ static QualType getCommonNonSugarTypeNode(ASTContext 
&Ctx, const Type *X,
 ::getCommonTemplateNameChecked(Ctx, TX->getTemplateName(),
TY->getTemplateName(),
/*IgnoreDeduced=*/true),
-As, /*CanonicalArgs=*/std::nullopt, X->getCanonicalTypeInternal());
+As, /*CanonicalArgs=*/{}, X->getCanonicalTypeInternal());
   }
   case Type::Decltype: {
 const auto *DX = cast(X);
@@ -14529,7 +14529,7 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, 
const Type *X,
TY->template_arguments()))
   return QualType();
 return Ctx.getTemplateSpecializationType(CTN, As,
- /*CanonicalArgs=*/std::nullopt,
+ /*CanonicalArgs=*/{},
  Ctx.getQualifiedType(Underlying));
   }
   case Type::Typedef: {
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index a00d5801f054b..522abd5912dbd 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -130,7 +130,7 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, 
QualType QT,
 if (DesugarArgument) {
   ShouldAKA = true;
   QT = Context.getTemplateSpecializationType(
-  TST->getTemplateName(), Args, /*CanonicalArgs=*/std::nullopt, 
QT);
+  TST->getTemplateName(), Args, /*CanonicalArgs=*/{}, QT);
 }
 break;
   }
@@ -1143,7 +1143,7 @@ class TemplateDiff {
 
 Ty = Context.getTemplateSpecializationType(
 TemplateName(CTSD->getSpecializedTemplate()),
-CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/std::nullopt,
+CTSD->getTemplateArgs().asArray(), /*CanonicalArgs=*/{},
 Ty.getLocalUnqualifiedType().getCanonicalType());
 
 return Ty->getAs();
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 96a5e2eeaa4d7..4621ebb854d8e 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1664,7 +1664,7 @@ ExpectedType 
ASTNodeImporter::VisitTemplateSpecializationType(
   if (!ToUnderlyingOrErr)
 return ToUnderlyingOrErr.takeError();
   return Importer.getToContext().getTemplateSpecializationType(
-  *ToTemplateOrErr, ToTemplateArgs, std::nullopt, *ToUnderlyingOrErr);
+  *ToTemplateOrErr, ToTemplateArgs, {}, *ToUnderlyingOrErr);
 }
 
 ExpectedType ASTNodeImporter::VisitElaboratedType(const ElaboratedType *T) {
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index e1ef2188dbdbe..5035f2d33b0a1 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -669,7 +669,7 @@ ClassTemplateDecl::getInjectedClassNameSpecialization() {
   CommonPtr->InjectedClassNameType =
   Context.getTemplateSpecializationType(Name,
 /*SpecifiedArgs=*/TemplateArgs,
-

[clang] [clang] Migrate away from ArrayRef(std::nullopt) (NFC) (PR #144982)

2025-06-19 Thread Matt Arsenault via cfe-commits

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


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


[clang] [llvm] [AMDGPU] Initial support for gfx1250 target. (PR #144965)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Stanislav Mekhanoshin (rampitec)


Changes

This is just a stub for now.

---

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


25 Files Affected:

- (modified) clang/include/clang/Basic/OffloadArch.h (+1) 
- (modified) clang/lib/Basic/OffloadArch.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-features.cl (+2) 
- (modified) clang/test/Driver/amdgpu-macros.cl (+9-2) 
- (modified) clang/test/Driver/amdgpu-mcpu.cl (+2) 
- (modified) clang/test/Misc/target-invalid-cpu-note/amdgcn.c (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note/nvptx.c (+1) 
- (modified) llvm/docs/AMDGPUUsage.rst (+8-1) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+1-1) 
- (modified) llvm/include/llvm/TargetParser/TargetParser.h (+2-1) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+2) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+53) 
- (modified) llvm/lib/Target/AMDGPU/GCNProcessors.td (+4) 
- (modified) llvm/lib/Target/AMDGPU/GCNSubtarget.h (+1) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+2) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+30) 
- (modified) llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll (+2) 
- (modified) llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml (+7) 
- (modified) llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll (+5) 
- (modified) llvm/test/tools/llvm-readobj/ELF/AMDGPU/elf-headers.test (+9) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 


``diff
diff --git a/clang/include/clang/Basic/OffloadArch.h 
b/clang/include/clang/Basic/OffloadArch.h
index 99b1024b9d0d4..4dda3ec2216fa 100644
--- a/clang/include/clang/Basic/OffloadArch.h
+++ b/clang/include/clang/Basic/OffloadArch.h
@@ -98,6 +98,7 @@ enum class OffloadArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  GFX1250,
   AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
index a019f0ac18c84..dce9ffaedb905 100644
--- a/clang/lib/Basic/OffloadArch.cpp
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -86,6 +86,7 @@ static const OffloadArchToStringMap ArchNames[] = {
 {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
 GFX(1200), // gfx1200
 GFX(1201), // gfx1201
+GFX(1250), // gfx1250
 {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
 // Intel CPUs
 {OffloadArch::GRANITERAPIDS, "graniterapids", ""},
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 3235bf2e710da..54b39fd072a89 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -238,6 +238,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 9e27e634676dc..2bc9cd549f01f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2331,6 +2331,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index b94e1e76c7a2c..730ed47f0b0c8 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -52,6 +52,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1153 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1153 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1200 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1201 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1201 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1250 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1250 %s
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature 
+wavefrontsize64 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103-W64 %s
 
@@ -107,6 +108,7 @@
 // GFX1153: 
"target-features"="+16-bit-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot10-insts,+dot12-insts,+dot5-insts,+dot7-i

[clang] [llvm] [AMDGPU] Initial support for gfx1250 target. (PR #144965)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Stanislav Mekhanoshin (rampitec)


Changes

This is just a stub for now.

---

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


25 Files Affected:

- (modified) clang/include/clang/Basic/OffloadArch.h (+1) 
- (modified) clang/lib/Basic/OffloadArch.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-features.cl (+2) 
- (modified) clang/test/Driver/amdgpu-macros.cl (+9-2) 
- (modified) clang/test/Driver/amdgpu-mcpu.cl (+2) 
- (modified) clang/test/Misc/target-invalid-cpu-note/amdgcn.c (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note/nvptx.c (+1) 
- (modified) llvm/docs/AMDGPUUsage.rst (+8-1) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+1-1) 
- (modified) llvm/include/llvm/TargetParser/TargetParser.h (+2-1) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+2) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+53) 
- (modified) llvm/lib/Target/AMDGPU/GCNProcessors.td (+4) 
- (modified) llvm/lib/Target/AMDGPU/GCNSubtarget.h (+1) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+2) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+30) 
- (modified) llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll (+2) 
- (modified) llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml (+7) 
- (modified) llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll (+5) 
- (modified) llvm/test/tools/llvm-readobj/ELF/AMDGPU/elf-headers.test (+9) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 


``diff
diff --git a/clang/include/clang/Basic/OffloadArch.h 
b/clang/include/clang/Basic/OffloadArch.h
index 99b1024b9d0d4..4dda3ec2216fa 100644
--- a/clang/include/clang/Basic/OffloadArch.h
+++ b/clang/include/clang/Basic/OffloadArch.h
@@ -98,6 +98,7 @@ enum class OffloadArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  GFX1250,
   AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
index a019f0ac18c84..dce9ffaedb905 100644
--- a/clang/lib/Basic/OffloadArch.cpp
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -86,6 +86,7 @@ static const OffloadArchToStringMap ArchNames[] = {
 {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
 GFX(1200), // gfx1200
 GFX(1201), // gfx1201
+GFX(1250), // gfx1250
 {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
 // Intel CPUs
 {OffloadArch::GRANITERAPIDS, "graniterapids", ""},
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 3235bf2e710da..54b39fd072a89 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -238,6 +238,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 9e27e634676dc..2bc9cd549f01f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2331,6 +2331,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index b94e1e76c7a2c..730ed47f0b0c8 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -52,6 +52,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1153 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1153 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1200 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1201 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1201 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1250 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1250 %s
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature 
+wavefrontsize64 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103-W64 %s
 
@@ -107,6 +108,7 @@
 // GFX1153: 
"target-features"="+16-bit-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot10-insts,+dot12-insts,+dot5-insts,+dot7-in

[clang] [llvm] [AMDGPU] Initial support for gfx1250 target. (PR #144965)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Stanislav Mekhanoshin (rampitec)


Changes

This is just a stub for now.

---

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


25 Files Affected:

- (modified) clang/include/clang/Basic/OffloadArch.h (+1) 
- (modified) clang/lib/Basic/OffloadArch.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-features.cl (+2) 
- (modified) clang/test/Driver/amdgpu-macros.cl (+9-2) 
- (modified) clang/test/Driver/amdgpu-mcpu.cl (+2) 
- (modified) clang/test/Misc/target-invalid-cpu-note/amdgcn.c (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note/nvptx.c (+1) 
- (modified) llvm/docs/AMDGPUUsage.rst (+8-1) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+1-1) 
- (modified) llvm/include/llvm/TargetParser/TargetParser.h (+2-1) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+2) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+53) 
- (modified) llvm/lib/Target/AMDGPU/GCNProcessors.td (+4) 
- (modified) llvm/lib/Target/AMDGPU/GCNSubtarget.h (+1) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+2) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+30) 
- (modified) llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll (+2) 
- (modified) llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml (+7) 
- (modified) llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll (+5) 
- (modified) llvm/test/tools/llvm-readobj/ELF/AMDGPU/elf-headers.test (+9) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 


``diff
diff --git a/clang/include/clang/Basic/OffloadArch.h 
b/clang/include/clang/Basic/OffloadArch.h
index 99b1024b9d0d4..4dda3ec2216fa 100644
--- a/clang/include/clang/Basic/OffloadArch.h
+++ b/clang/include/clang/Basic/OffloadArch.h
@@ -98,6 +98,7 @@ enum class OffloadArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  GFX1250,
   AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
index a019f0ac18c84..dce9ffaedb905 100644
--- a/clang/lib/Basic/OffloadArch.cpp
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -86,6 +86,7 @@ static const OffloadArchToStringMap ArchNames[] = {
 {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
 GFX(1200), // gfx1200
 GFX(1201), // gfx1201
+GFX(1250), // gfx1250
 {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
 // Intel CPUs
 {OffloadArch::GRANITERAPIDS, "graniterapids", ""},
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 3235bf2e710da..54b39fd072a89 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -238,6 +238,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 9e27e634676dc..2bc9cd549f01f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2331,6 +2331,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index b94e1e76c7a2c..730ed47f0b0c8 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -52,6 +52,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1153 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1153 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1200 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1201 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1201 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1250 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1250 %s
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature 
+wavefrontsize64 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103-W64 %s
 
@@ -107,6 +108,7 @@
 // GFX1153: 
"target-features"="+16-bit-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot10-insts,+dot12-insts,+dot5-insts,+dot7-ins

[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -1068,10 +1069,139 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
   SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
   DeclIdent, Elements);
 
+  // Perform validation of constructs here
+  if (handleRootSignatureDecl(SignatureDecl, Loc))
+return;
+
   SignatureDecl->setImplicit();
   SemaRef.PushOnScopeChains(SignatureDecl, SemaRef.getCurScope());
 }
 
+bool SemaHLSL::handleRootSignatureDecl(HLSLRootSignatureDecl *D,
+   SourceLocation Loc) {
+  auto Elements = D->getRootElements();
+
+  // The following conducts analysis on resource ranges to detect and report
+  // any overlaps in resource ranges.
+  //
+  // A resource range overlaps with another resource range if they have:
+  // - equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
+  // - equivalent resource space
+  // - overlapping visbility
+  //
+  // The following algorithm is implemented in the following steps:
+  //
+  // 1. Collect RangeInfo from relevant RootElements:
+  //   - RangeInfo will retain the interval, ResourceClass, Space and 
Visibility
+  // 2. Sort the RangeInfo's such that they are grouped together by
+  //  ResourceClass and Space (GroupT defined below)
+  // 3. Iterate through the collected RangeInfos by their groups
+  //   - For each group we will have a ResourceRange for each visibility
+  //   - As we iterate through we will:
+  //  A: Insert the current RangeInfo into the corresponding Visibility
+  //   ResourceRange
+  //  B: Check for overlap with any overlapping Visibility ResourceRange
+  using RangeInfo = llvm::hlsl::rootsig::RangeInfo;
+  using ResourceRange = llvm::hlsl::rootsig::ResourceRange;
+  using GroupT = std::pair;
+
+  // 1. Collect RangeInfos
+  llvm::SmallVector Infos;
+  for (const auto &Elem : Elements) {
+if (const auto *Descriptor =
+std::get_if(&Elem)) {
+  RangeInfo Info;
+  Info.LowerBound = Descriptor->Reg.Number;
+  Info.UpperBound = Info.LowerBound; // use inclusive ranges []
+
+  Info.Class =
+  llvm::dxil::ResourceClass(llvm::to_underlying(Descriptor->Type));
+  Info.Space = Descriptor->Space;
+  Info.Vis = Descriptor->Visibility;
+  Infos.push_back(Info);
+}
+  }
+
+  // 2. Sort the RangeInfo's by their GroupT to form groupings
+  std::sort(Infos.begin(), Infos.end(), [](RangeInfo A, RangeInfo B) {
+return std::tie(A.Class, A.Space) < std::tie(B.Class, B.Space);
+  });
+
+  // 3. First we will init our state to track:
+  if (Infos.size() == 0)
+return false; // No ranges to overlap
+  GroupT CurGroup = {Infos[0].Class, Infos[0].Space};
+  bool HadOverlap = false;
+
+  // Create a ResourceRange for each Visibility
+  ResourceRange::MapT::Allocator Allocator;
+  SmallVector Ranges = {
+  ResourceRange(Allocator), // All
+  ResourceRange(Allocator), // Vertex
+  ResourceRange(Allocator), // Hull
+  ResourceRange(Allocator), // Domain
+  ResourceRange(Allocator), // Geometry
+  ResourceRange(Allocator), // Pixel
+  ResourceRange(Allocator), // Amplification
+  ResourceRange(Allocator), // Mesh
+  };
+
+  // Reset the ResourceRanges for when we iterate through a new group
+  auto ClearRanges = [&Ranges]() {
+for (ResourceRange &Range : Ranges)
+  Range.clear();
+  };
+
+  // Helper to report diagnostics
+  auto ReportOverlap = [this, Loc, &HadOverlap](const RangeInfo *Info,
+const RangeInfo *OInfo) {
+HadOverlap = true;
+auto CommonVis = Info->Vis == llvm::hlsl::rootsig::ShaderVisibility::All
+ ? OInfo->Vis
+ : Info->Vis;
+this->Diag(Loc, diag::err_hlsl_resource_range_overlap)
+<< llvm::to_underlying(Info->Class) << Info->LowerBound
+<< Info->UpperBound << llvm::to_underlying(OInfo->Class)
+<< OInfo->LowerBound << OInfo->UpperBound << Info->Space << CommonVis;
+  };
+
+  // 3: Iterate throught collected RangeInfos
+  for (const RangeInfo &Info : Infos) {
+GroupT InfoGroup = {Info.Class, Info.Space};
+// Reset our ResourceRanges when we enter a new group
+if (CurGroup != InfoGroup) {
+  ClearRanges();
+  CurGroup = InfoGroup;
+}
+
+// 3A: Insert range info into corresponding Visibility ResourceRange
+ResourceRange &VisRange = Ranges[llvm::to_underlying(Info.Vis)];
+if (auto Overlapping = VisRange.insert(Info))
+  ReportOverlap(&Info, Overlapping.value());
+
+// 3B: Check for overlap in all overlapping Visibility ResourceRanges
+//
+// If the range that we are inserting has ShaderVisiblity::All it needs to
+// check for an overlap in all other visibility types as well.
+// Otherwise, the range that is inserted needs to check that it does not
+// overlap with ShaderVisibility::All.
+//
+// Maps will be an ArrayRef to all non-all visibility RangeMaps in the
+// former case and it will be an A

[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -1068,10 +1069,139 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
   SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
   DeclIdent, Elements);
 
+  // Perform validation of constructs here
+  if (handleRootSignatureDecl(SignatureDecl, Loc))
+return;
+
   SignatureDecl->setImplicit();
   SemaRef.PushOnScopeChains(SignatureDecl, SemaRef.getCurScope());
 }
 
+bool SemaHLSL::handleRootSignatureDecl(HLSLRootSignatureDecl *D,
+   SourceLocation Loc) {
+  auto Elements = D->getRootElements();
+
+  // The following conducts analysis on resource ranges to detect and report
+  // any overlaps in resource ranges.
+  //
+  // A resource range overlaps with another resource range if they have:
+  // - equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
+  // - equivalent resource space
+  // - overlapping visbility
+  //
+  // The following algorithm is implemented in the following steps:
+  //
+  // 1. Collect RangeInfo from relevant RootElements:
+  //   - RangeInfo will retain the interval, ResourceClass, Space and 
Visibility
+  // 2. Sort the RangeInfo's such that they are grouped together by
+  //  ResourceClass and Space (GroupT defined below)
+  // 3. Iterate through the collected RangeInfos by their groups
+  //   - For each group we will have a ResourceRange for each visibility
+  //   - As we iterate through we will:
+  //  A: Insert the current RangeInfo into the corresponding Visibility
+  //   ResourceRange
+  //  B: Check for overlap with any overlapping Visibility ResourceRange
+  using RangeInfo = llvm::hlsl::rootsig::RangeInfo;
+  using ResourceRange = llvm::hlsl::rootsig::ResourceRange;
+  using GroupT = std::pair;
+
+  // 1. Collect RangeInfos
+  llvm::SmallVector Infos;
+  for (const auto &Elem : Elements) {

bogner wrote:

Better to spell out the type here. Also, `Elements` is only used once, we 
probably don't need to name it.
```suggestion
  for (const llvm::hlsl::rootsig::RootElement &Elem : D->getRootElements()) {
```

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -1068,10 +1069,139 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
   SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
   DeclIdent, Elements);
 
+  // Perform validation of constructs here
+  if (handleRootSignatureDecl(SignatureDecl, Loc))
+return;
+
   SignatureDecl->setImplicit();
   SemaRef.PushOnScopeChains(SignatureDecl, SemaRef.getCurScope());
 }
 
+bool SemaHLSL::handleRootSignatureDecl(HLSLRootSignatureDecl *D,
+   SourceLocation Loc) {
+  auto Elements = D->getRootElements();
+
+  // The following conducts analysis on resource ranges to detect and report
+  // any overlaps in resource ranges.
+  //
+  // A resource range overlaps with another resource range if they have:
+  // - equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
+  // - equivalent resource space
+  // - overlapping visbility
+  //
+  // The following algorithm is implemented in the following steps:
+  //
+  // 1. Collect RangeInfo from relevant RootElements:
+  //   - RangeInfo will retain the interval, ResourceClass, Space and 
Visibility
+  // 2. Sort the RangeInfo's such that they are grouped together by
+  //  ResourceClass and Space (GroupT defined below)
+  // 3. Iterate through the collected RangeInfos by their groups
+  //   - For each group we will have a ResourceRange for each visibility
+  //   - As we iterate through we will:
+  //  A: Insert the current RangeInfo into the corresponding Visibility
+  //   ResourceRange
+  //  B: Check for overlap with any overlapping Visibility ResourceRange
+  using RangeInfo = llvm::hlsl::rootsig::RangeInfo;
+  using ResourceRange = llvm::hlsl::rootsig::ResourceRange;
+  using GroupT = std::pair;
+
+  // 1. Collect RangeInfos
+  llvm::SmallVector Infos;
+  for (const auto &Elem : Elements) {
+if (const auto *Descriptor =
+std::get_if(&Elem)) {
+  RangeInfo Info;
+  Info.LowerBound = Descriptor->Reg.Number;
+  Info.UpperBound = Info.LowerBound; // use inclusive ranges []
+
+  Info.Class =
+  llvm::dxil::ResourceClass(llvm::to_underlying(Descriptor->Type));
+  Info.Space = Descriptor->Space;
+  Info.Vis = Descriptor->Visibility;
+  Infos.push_back(Info);
+}
+  }
+
+  // 2. Sort the RangeInfo's by their GroupT to form groupings
+  std::sort(Infos.begin(), Infos.end(), [](RangeInfo A, RangeInfo B) {
+return std::tie(A.Class, A.Space) < std::tie(B.Class, B.Space);
+  });
+
+  // 3. First we will init our state to track:
+  if (Infos.size() == 0)
+return false; // No ranges to overlap
+  GroupT CurGroup = {Infos[0].Class, Infos[0].Space};
+  bool HadOverlap = false;
+
+  // Create a ResourceRange for each Visibility
+  ResourceRange::MapT::Allocator Allocator;
+  SmallVector Ranges = {
+  ResourceRange(Allocator), // All
+  ResourceRange(Allocator), // Vertex
+  ResourceRange(Allocator), // Hull
+  ResourceRange(Allocator), // Domain
+  ResourceRange(Allocator), // Geometry
+  ResourceRange(Allocator), // Pixel
+  ResourceRange(Allocator), // Amplification
+  ResourceRange(Allocator), // Mesh
+  };
+
+  // Reset the ResourceRanges for when we iterate through a new group
+  auto ClearRanges = [&Ranges]() {
+for (ResourceRange &Range : Ranges)
+  Range.clear();
+  };
+
+  // Helper to report diagnostics
+  auto ReportOverlap = [this, Loc, &HadOverlap](const RangeInfo *Info,
+const RangeInfo *OInfo) {
+HadOverlap = true;
+auto CommonVis = Info->Vis == llvm::hlsl::rootsig::ShaderVisibility::All
+ ? OInfo->Vis
+ : Info->Vis;
+this->Diag(Loc, diag::err_hlsl_resource_range_overlap)
+<< llvm::to_underlying(Info->Class) << Info->LowerBound
+<< Info->UpperBound << llvm::to_underlying(OInfo->Class)
+<< OInfo->LowerBound << OInfo->UpperBound << Info->Space << CommonVis;
+  };
+
+  // 3: Iterate throught collected RangeInfos
+  for (const RangeInfo &Info : Infos) {
+GroupT InfoGroup = {Info.Class, Info.Space};
+// Reset our ResourceRanges when we enter a new group
+if (CurGroup != InfoGroup) {
+  ClearRanges();
+  CurGroup = InfoGroup;
+}
+
+// 3A: Insert range info into corresponding Visibility ResourceRange
+ResourceRange &VisRange = Ranges[llvm::to_underlying(Info.Vis)];
+if (auto Overlapping = VisRange.insert(Info))

bogner wrote:

I'd probably spell the type out here.
```suggestion
if (std::optional Overlapping = VisRange.insert(Info))
```

Same below where we call `getOverlapping`.

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits

https://github.com/bogner commented:

Looks pretty good. Mostly stylistic comments.

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -71,13 +71,17 @@ class MetadataBuilder {
   SmallVector GeneratedMetadata;
 };
 
-// RangeInfo holds the information to correctly construct a ResourceRange
-// and retains this information to be used for displaying a better diagnostic
 struct RangeInfo {
-  const static uint32_t Unbounded = ~0u;
+  const static uint32_t Unbounded = static_cast(-1);
 
+  // Interval information
   uint32_t LowerBound;
   uint32_t UpperBound;
+
+  // Information retained for diagnostics
+  llvm::dxil::ResourceClass Class;
+  uint32_t Space;
+  ShaderVisibility Vis;

bogner wrote:

Probably better to call it `Visibility`.

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -1068,10 +1069,139 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
   SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
   DeclIdent, Elements);
 
+  // Perform validation of constructs here
+  if (handleRootSignatureDecl(SignatureDecl, Loc))
+return;
+
   SignatureDecl->setImplicit();
   SemaRef.PushOnScopeChains(SignatureDecl, SemaRef.getCurScope());
 }
 
+bool SemaHLSL::handleRootSignatureDecl(HLSLRootSignatureDecl *D,
+   SourceLocation Loc) {
+  auto Elements = D->getRootElements();
+
+  // The following conducts analysis on resource ranges to detect and report
+  // any overlaps in resource ranges.
+  //
+  // A resource range overlaps with another resource range if they have:
+  // - equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
+  // - equivalent resource space
+  // - overlapping visbility
+  //
+  // The following algorithm is implemented in the following steps:
+  //
+  // 1. Collect RangeInfo from relevant RootElements:
+  //   - RangeInfo will retain the interval, ResourceClass, Space and 
Visibility
+  // 2. Sort the RangeInfo's such that they are grouped together by
+  //  ResourceClass and Space (GroupT defined below)
+  // 3. Iterate through the collected RangeInfos by their groups
+  //   - For each group we will have a ResourceRange for each visibility
+  //   - As we iterate through we will:
+  //  A: Insert the current RangeInfo into the corresponding Visibility
+  //   ResourceRange
+  //  B: Check for overlap with any overlapping Visibility ResourceRange
+  using RangeInfo = llvm::hlsl::rootsig::RangeInfo;
+  using ResourceRange = llvm::hlsl::rootsig::ResourceRange;
+  using GroupT = std::pair;
+
+  // 1. Collect RangeInfos
+  llvm::SmallVector Infos;
+  for (const auto &Elem : Elements) {
+if (const auto *Descriptor =
+std::get_if(&Elem)) {
+  RangeInfo Info;
+  Info.LowerBound = Descriptor->Reg.Number;
+  Info.UpperBound = Info.LowerBound; // use inclusive ranges []
+
+  Info.Class =
+  llvm::dxil::ResourceClass(llvm::to_underlying(Descriptor->Type));
+  Info.Space = Descriptor->Space;
+  Info.Vis = Descriptor->Visibility;
+  Infos.push_back(Info);
+}
+  }
+
+  // 2. Sort the RangeInfo's by their GroupT to form groupings
+  std::sort(Infos.begin(), Infos.end(), [](RangeInfo A, RangeInfo B) {
+return std::tie(A.Class, A.Space) < std::tie(B.Class, B.Space);
+  });
+
+  // 3. First we will init our state to track:
+  if (Infos.size() == 0)
+return false; // No ranges to overlap
+  GroupT CurGroup = {Infos[0].Class, Infos[0].Space};
+  bool HadOverlap = false;
+
+  // Create a ResourceRange for each Visibility
+  ResourceRange::MapT::Allocator Allocator;
+  SmallVector Ranges = {

bogner wrote:

This has a fixed size, you can just use `std::array`.
```suggestion
  std::array Ranges = {
```

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -71,13 +71,17 @@ class MetadataBuilder {
   SmallVector GeneratedMetadata;
 };
 
-// RangeInfo holds the information to correctly construct a ResourceRange
-// and retains this information to be used for displaying a better diagnostic
 struct RangeInfo {
-  const static uint32_t Unbounded = ~0u;
+  const static uint32_t Unbounded = static_cast(-1);

bogner wrote:

Why change this? I certainly find `~0U` clearer, but if you want to avoid that 
for some reason it's better to use `std::numeric_limits::max()` 
rather than casting negative one.

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - %s 
-verify
+
+#define Overlap0 "CBV(b42), CBV(b42)"
+
+[RootSignature(Overlap0)] // expected-error {{resource ranges b[42;42] and 
b[42;42] overlap within space = 0 and visibility = All}}

bogner wrote:

I suspect this test will be slightly more readable if we skip the defines. You 
can use `expected-error@+1` to say the error is expected on the next line so 
that the attribute and error message don't need to be on the same line.

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


[clang] [llvm] [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (PR #140962)

2025-06-19 Thread Justin Bogner via cfe-commits


@@ -1068,10 +1069,139 @@ void SemaHLSL::ActOnFinishRootSignatureDecl(
   SemaRef.getASTContext(), /*DeclContext=*/SemaRef.CurContext, Loc,
   DeclIdent, Elements);
 
+  // Perform validation of constructs here

bogner wrote:

I don't think this comment is helpful (the old comment seemed like a 
placeholder for where to add validations, but now that this is doing validation 
it seems clear enough from the code)

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


[clang] [llvm] [AMDGPU] Initial support for gfx1250 target. (PR #144965)

2025-06-19 Thread Stanislav Mekhanoshin via cfe-commits

https://github.com/rampitec created 
https://github.com/llvm/llvm-project/pull/144965

This is just a stub for now.

>From a176e3547079ded67ce4b3ed91ca9de6751a920b Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Thu, 19 Jun 2025 15:57:29 -0700
Subject: [PATCH] [AMDGPU] Initial support for gfx1250 target.

This is just a stub for now.
---
 clang/include/clang/Basic/OffloadArch.h   |  1 +
 clang/lib/Basic/OffloadArch.cpp   |  1 +
 clang/lib/Basic/Targets/NVPTX.cpp |  1 +
 clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp  |  1 +
 clang/test/CodeGenOpenCL/amdgpu-features.cl   |  2 +
 clang/test/Driver/amdgpu-macros.cl| 11 +++-
 clang/test/Driver/amdgpu-mcpu.cl  |  2 +
 .../Misc/target-invalid-cpu-note/amdgcn.c |  1 +
 .../test/Misc/target-invalid-cpu-note/nvptx.c |  1 +
 llvm/docs/AMDGPUUsage.rst |  9 +++-
 llvm/include/llvm/BinaryFormat/ELF.h  |  2 +-
 llvm/include/llvm/TargetParser/TargetParser.h |  3 +-
 llvm/lib/Object/ELFObjectFile.cpp |  2 +
 llvm/lib/ObjectYAML/ELFYAML.cpp   |  1 +
 llvm/lib/Target/AMDGPU/AMDGPU.td  | 53 +++
 llvm/lib/Target/AMDGPU/GCNProcessors.td   |  4 ++
 llvm/lib/Target/AMDGPU/GCNSubtarget.h |  1 +
 .../MCTargetDesc/AMDGPUTargetStreamer.cpp |  2 +
 llvm/lib/TargetParser/TargetParser.cpp| 30 +++
 .../CodeGen/AMDGPU/directive-amdgcn-target.ll |  2 +
 .../CodeGen/AMDGPU/elf-header-flags-mach.ll   |  2 +
 .../Object/AMDGPU/elf-header-flags-mach.yaml  |  7 +++
 .../llvm-objdump/ELF/AMDGPU/subtarget.ll  |  5 ++
 .../llvm-readobj/ELF/AMDGPU/elf-headers.test  |  9 
 llvm/tools/llvm-readobj/ELFDumper.cpp |  1 +
 25 files changed, 149 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/Basic/OffloadArch.h 
b/clang/include/clang/Basic/OffloadArch.h
index 99b1024b9d0d4..4dda3ec2216fa 100644
--- a/clang/include/clang/Basic/OffloadArch.h
+++ b/clang/include/clang/Basic/OffloadArch.h
@@ -98,6 +98,7 @@ enum class OffloadArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  GFX1250,
   AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
index a019f0ac18c84..dce9ffaedb905 100644
--- a/clang/lib/Basic/OffloadArch.cpp
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -86,6 +86,7 @@ static const OffloadArchToStringMap ArchNames[] = {
 {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
 GFX(1200), // gfx1200
 GFX(1201), // gfx1201
+GFX(1250), // gfx1250
 {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
 // Intel CPUs
 {OffloadArch::GRANITERAPIDS, "graniterapids", ""},
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 3235bf2e710da..54b39fd072a89 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -238,6 +238,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 9e27e634676dc..2bc9cd549f01f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2331,6 +2331,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const 
OMPRequiresDecl *D) {
   case OffloadArch::GFX12_GENERIC:
   case OffloadArch::GFX1200:
   case OffloadArch::GFX1201:
+  case OffloadArch::GFX1250:
   case OffloadArch::AMDGCNSPIRV:
   case OffloadArch::Generic:
   case OffloadArch::GRANITERAPIDS:
diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index b94e1e76c7a2c..730ed47f0b0c8 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -52,6 +52,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1153 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1153 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1200 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1201 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1201 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1250 -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1250 %s
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -target-feature 
+wavefrontsize64 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103-W64 %s
 
@@ -107,6 +108,7 @@
 // GFX1153: 
"target-features"="+16-bit-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot10-insts,+dot12-insts,+dot5-insts,+dot7-insts,+dot8-insts,+dot9-insts,+

[clang] [llvm] [AMDGPU] Initial support for gfx1250 target. (PR #144965)

2025-06-19 Thread Stanislav Mekhanoshin via cfe-commits

rampitec wrote:

* **#144965** https://app.graphite.dev/github/pr/llvm/llvm-project/144965?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/144965?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


[clang] [llvm] [AMDGPU] Initial support for gfx1250 target. (PR #144965)

2025-06-19 Thread Stanislav Mekhanoshin via cfe-commits

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


[clang] [BUG] Fix : #139514 (PR #144956)

2025-06-19 Thread Yanzuo Liu via cfe-commits

zwuis wrote:

Where is the fix? Only test file is modified currently.

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


[clang] [clang][analyzer] Correctly handle lambda-converted function pointers (PR #144906)

2025-06-19 Thread via cfe-commits

flovent wrote:

> I only have one question. Have you considered overriding some other 
> `getRuntimeDefinition` too? When I'm looking at the [CallEvent 
> ](https://clang.llvm.org/doxygen/classclang_1_1ento_1_1CallEvent.html) 
> inheritance graph, there could be a couple other options too. Don't get me 
> wrong, the `SimpleFunctionCall::getRuntimeDefinition` looks like the right 
> place. I'm just curious.

As far as i know, `__invoke` will always be a normal static member method for 
lambda, and static member method will be modeled as `SimpleFunctionCall` in 
analyzer, other derived classes of same level seems to   for memory-allocation 
related (`CXXAllocatorCall`, `CXXDeallocatorCall`), or class-instance related 
(`AnyCXXConstructorCall`, `CXXInstanceCall`)


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


[clang] [lld] Use the Windows SDK arguments over the environment (PR #144805)

2025-06-19 Thread Saleem Abdulrasool via cfe-commits

compnerd wrote:

> Just to confirm, does this make clang-cl line up with cl's behavior?

I suspect not; these options are clang-cl specific.

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


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

2025-06-19 Thread Chuanqi Xu via cfe-commits


@@ -195,6 +196,10 @@ class ExternalASTSource : public 
RefCountedBase {
   /// module.
   virtual bool wasThisDeclarationADefinition(const FunctionDecl *FD);
 
+  virtual bool hasInitializerWithSideEffects(const VarDecl *VD) const {

ChuanqiXu9 wrote:

Generally, every time we add an interface to ExternalASTSource, we need to add 
one for `MultiplexExternalSemaSource`.

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


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

2025-06-19 Thread Chuanqi Xu via cfe-commits


@@ -1442,6 +1442,10 @@ class ASTReader
 const StringRef &operator*() && = delete;
   };
 
+  /// VarDecls with initializers containing side effects must be emitted,
+  /// but DeclMustBeEmitted is not allowed to deserialize the intializer.
+  llvm::SmallPtrSet InitSideEffectVars;

ChuanqiXu9 wrote:

I think we can erase elements from `InitSideEffectVars` if the initializer of 
the variable got loaded. This is helpful for memory. But given I feel it might 
not be significant, so if you don't want to do it right now, please leave a 
FIXME.

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


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

2025-06-19 Thread Chuanqi Xu via cfe-commits


@@ -1632,6 +1632,10 @@ RedeclarableResult 
ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
 VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope =
 VarDeclBits.getNextBit();
 
+bool HasInitWithSideEffect = VarDeclBits.getNextBit();
+if (HasInitWithSideEffect)
+  Reader.InitSideEffectVars.insert(VD);

ChuanqiXu9 wrote:

```suggestion
if (VarDeclBits.getNextBit())
  Reader.InitSideEffectVars.insert(VD);
```

nit:

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


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

2025-06-19 Thread Chuanqi Xu via cfe-commits


@@ -2434,6 +2434,31 @@ VarDecl *VarDecl::getInitializingDeclaration() {
   return Def;
 }
 
+bool VarDecl::hasInitWithSideEffects() const {
+  if (!hasInit())
+return false;
+
+  // Check if we can get the initializer without deserializing
+  const Expr *E = nullptr;
+  if (auto *S = dyn_cast(Init)) {
+E = cast(S);
+  } else {
+auto *Eval = getEvaluatedStmt();
+if (!Eval->Value.isOffset())
+  E = cast(Eval->Value.get(nullptr));
+  }
+
+  if (E)
+return E->HasSideEffects(getASTContext()) &&
+   // We can get a value-dependent initializer during error recovery.
+   (E->isValueDependent() || !evaluateValue());
+
+  assert(getEvaluatedStmt()->Value.isOffset());
+  // ASTReader tracks this without having to deserialize the initializer
+  return getASTContext().getExternalSource()->hasInitializerWithSideEffects(

ChuanqiXu9 wrote:

We don't assume `getASTContext().getExternalSource()` exists generally. So,

```
if (getASTContext().getExternalSource())
   return getASTContext().getExternalSource()->hasInitializerWithSideEffects(

return false;
```

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


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

2025-06-19 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 commented:

I just found I forgot pushing pending comments.

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


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

2025-06-19 Thread Chuanqi Xu via cfe-commits


@@ -2434,6 +2434,31 @@ VarDecl *VarDecl::getInitializingDeclaration() {
   return Def;
 }
 
+bool VarDecl::hasInitWithSideEffects() const {
+  if (!hasInit())
+return false;
+
+  // Check if we can get the initializer without deserializing
+  const Expr *E = nullptr;
+  if (auto *S = dyn_cast(Init)) {
+E = cast(S);
+  } else {
+auto *Eval = getEvaluatedStmt();
+if (!Eval->Value.isOffset())
+  E = cast(Eval->Value.get(nullptr));

ChuanqiXu9 wrote:

It might be better to add comments here to explain `get` will trigger 
deserialization.

Or maybe it has better readability to add a method `noload_get` in LazyOffsetPtr

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


[libclc] [libclc] Declare workitem built-ins in clc, move ptx-nvidiacl workitem built-ins into clc (PR #144333)

2025-06-19 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> Moving them into clc should resolve the concern, but I don't know where is 
> destination directory in clc. I don't know how to map `opencl/lib/amdgcn` and 
> `opencl/lib/r600` to `clc/lib/amdgcn` and `clc/lib/amdgpu`. Do you have 
> suggestions about the mapping?

r600 and amdgcn should be treated as separate targets. we should stop trying to 
have common code under an "amdgpu" name

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


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

2025-06-19 Thread Chuanqi Xu via cfe-commits

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


[clang] [clang] Handle consteval constructors with default initialization. (PR #144970)

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

https://github.com/efriedma-quic created 
https://github.com/llvm/llvm-project/pull/144970

This is a simple extension of 443377a9d1a8d4a69a317a1a892184c59dd0aec6 to also 
handle the implicit expressions created by default initialization.  This 
usually doesn't matter, but it's relevant if the constructor stores "this" as a 
member.

Fixes #135281 .

>From ef713152a6fb5d2321330d8fbaa77970e8666b13 Mon Sep 17 00:00:00 2001
From: Eli Friedman 
Date: Thu, 19 Jun 2025 18:29:49 -0700
Subject: [PATCH] [clang] Handle consteval constructors with default
 initialization.

This is a simple extension of 443377a9d1a8d4a69a317a1a892184c59dd0aec6
to also handle the implicit expressions created by default
initialization.  This usually doesn't matter, but it's relevant if the
constructor stores "this" as a member.

Fixes #135281 .
---
 clang/lib/Sema/SemaDecl.cpp|  6 ++
 .../test/SemaCXX/cxx2b-consteval-propagate.cpp | 18 ++
 2 files changed, 24 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index bbd63372c168b..e10dc65897b8a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14423,6 +14423,9 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
 Var->getType().getAddressSpace() == LangAS::hlsl_input)
   return;
 
+if (getLangOpts().CPlusPlus)
+  ActOnCXXEnterDeclInitializer(nullptr, Var);
+
 // C++03 [dcl.init]p9:
 //   If no initializer is specified for an object, and the
 //   object is of (possibly cv-qualified) non-POD class type (or
@@ -14458,6 +14461,9 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
 }
 
 CheckCompleteVariableDeclaration(Var);
+
+if (getLangOpts().CPlusPlus)
+  ActOnCXXExitDeclInitializer(nullptr, Var);
   }
 }
 
diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp 
b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
index dd5063cb29c5b..aa5d79af589ca 100644
--- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -576,3 +576,21 @@ int f() {
   //expected-note@-2 {{read of non-const variable 'a' is not allowed in a 
constant expression}}
 }
 }
+
+#if __cplusplus >= 202302L
+namespace GH135281 {
+  struct B {
+const void* p;
+consteval B() : p{this} {}
+  };
+  B b;
+  B b2{};
+  B &&b3{};
+  void f() {
+static B b4;
+B b5; // expected-error {{call to consteval function 'GH135281::B::B' is 
not a constant expression}} \
+  // expected-note {{pointer to temporary is not a constant 
expression}} \
+  // expected-note {{temporary created here}}
+  }
+}
+#endif

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


[clang] [clang] Handle consteval constructors with default initialization. (PR #144970)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Eli Friedman (efriedma-quic)


Changes

This is a simple extension of 443377a9d1a8d4a69a317a1a892184c59dd0aec6 to also 
handle the implicit expressions created by default initialization.  This 
usually doesn't matter, but it's relevant if the constructor stores "this" as a 
member.

Fixes #135281 .

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaDecl.cpp (+6) 
- (modified) clang/test/SemaCXX/cxx2b-consteval-propagate.cpp (+18) 


``diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index bbd63372c168b..e10dc65897b8a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14423,6 +14423,9 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
 Var->getType().getAddressSpace() == LangAS::hlsl_input)
   return;
 
+if (getLangOpts().CPlusPlus)
+  ActOnCXXEnterDeclInitializer(nullptr, Var);
+
 // C++03 [dcl.init]p9:
 //   If no initializer is specified for an object, and the
 //   object is of (possibly cv-qualified) non-POD class type (or
@@ -14458,6 +14461,9 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
 }
 
 CheckCompleteVariableDeclaration(Var);
+
+if (getLangOpts().CPlusPlus)
+  ActOnCXXExitDeclInitializer(nullptr, Var);
   }
 }
 
diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp 
b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
index dd5063cb29c5b..aa5d79af589ca 100644
--- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -576,3 +576,21 @@ int f() {
   //expected-note@-2 {{read of non-const variable 'a' is not allowed in a 
constant expression}}
 }
 }
+
+#if __cplusplus >= 202302L
+namespace GH135281 {
+  struct B {
+const void* p;
+consteval B() : p{this} {}
+  };
+  B b;
+  B b2{};
+  B &&b3{};
+  void f() {
+static B b4;
+B b5; // expected-error {{call to consteval function 'GH135281::B::B' is 
not a constant expression}} \
+  // expected-note {{pointer to temporary is not a constant 
expression}} \
+  // expected-note {{temporary created here}}
+  }
+}
+#endif

``




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


[clang] [llvm] [AMDGPU] Initial support for gfx1250 target. (PR #144965)

2025-06-19 Thread Matt Arsenault via cfe-commits

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


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


[clang] 50c5ecd - [NFC] [Serialization] Remove a useless comment

2025-06-19 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2025-06-20T10:33:35+08:00
New Revision: 50c5ecd35402dc734f2a462df5532e77a5ce12b2

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

LOG: [NFC] [Serialization] Remove a useless comment

The comments belongs to other WIP patches.

Added: 


Modified: 
clang/include/clang/Serialization/ASTReader.h

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 866986dcbf76e..be1c6e0817593 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -379,8 +379,7 @@ struct VisibleLookupBlockOffsets {
   uint64_t TULocalOffset = 0;
 
   operator bool() const {
-return VisibleOffset || ModuleLocalOffset || // ModuleUnitLocalOffset ||
-   TULocalOffset;
+return VisibleOffset || ModuleLocalOffset || TULocalOffset;
   }
 };
 



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


[clang] [HLSL][SPIRV] Allow large z value in numthreads (PR #144934)

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

https://github.com/s-perron created 
https://github.com/llvm/llvm-project/pull/144934

The current validation checks for numthreads assume that the target is
DXIL so the version checks inadvertently issue error when targeting
SPIR-V.


>From 0b809d5a51a76ef76a68574b8dc447de10d4654a Mon Sep 17 00:00:00 2001
From: Steven Perron 
Date: Thu, 19 Jun 2025 13:56:27 -0400
Subject: [PATCH] [HLSL][SPIRV] Allow large z value in numthreads

The current validation checks for numthreads assume that the target is
DXIL so the version checks inadvertently issue error when targeting
SPIR-V.
---
 clang/lib/Sema/SemaHLSL.cpp  |  7 +--
 clang/test/SemaHLSL/num_threads.hlsl | 16 
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index b55f4fd786b58..9f39c077cea7a 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1033,12 +1033,15 @@ void SemaHLSL::handleRootSignatureAttr(Decl *D, const 
ParsedAttr &AL) {
 void SemaHLSL::handleNumThreadsAttr(Decl *D, const ParsedAttr &AL) {
   llvm::VersionTuple SMVersion =
   getASTContext().getTargetInfo().getTriple().getOSVersion();
+  bool IsDXIL = getASTContext().getTargetInfo().getTriple().getArch() ==
+llvm::Triple::dxil;
+
   uint32_t ZMax = 1024;
   uint32_t ThreadMax = 1024;
-  if (SMVersion.getMajor() <= 4) {
+  if (IsDXIL && SMVersion.getMajor() <= 4) {
 ZMax = 1;
 ThreadMax = 768;
-  } else if (SMVersion.getMajor() == 5) {
+  } else if (IsDXIL && SMVersion.getMajor() == 5) {
 ZMax = 64;
 ThreadMax = 1024;
   }
diff --git a/clang/test/SemaHLSL/num_threads.hlsl 
b/clang/test/SemaHLSL/num_threads.hlsl
index b5f9ad6c33cd6..96200312bbf69 100644
--- a/clang/test/SemaHLSL/num_threads.hlsl
+++ b/clang/test/SemaHLSL/num_threads.hlsl
@@ -10,6 +10,8 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel5.0-compute -x hlsl -ast-dump -o 
- %s -DFAIL -verify
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel4.0-compute -x hlsl -ast-dump -o 
- %s -DFAIL -verify
 
+// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-compute -x hlsl -ast-dump -o - 
%s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV
+
 #if __SHADER_TARGET_STAGE == __SHADER_STAGE_COMPUTE || __SHADER_TARGET_STAGE 
== __SHADER_STAGE_MESH || __SHADER_TARGET_STAGE == __SHADER_STAGE_AMPLIFICATION 
|| __SHADER_TARGET_STAGE == __SHADER_STAGE_LIBRARY
 #ifdef FAIL
 
@@ -88,24 +90,30 @@ int entry() {
 
 // Because these two attributes match, they should both appear in the AST
 [numthreads(2,2,1)]
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 
2 1
 int secondFn();
 
 [numthreads(2,2,1)]
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 
2 1
 int secondFn() {
   return 1;
 }
 
 [numthreads(4,2,1)]
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  4 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  4 
2 1
 int onlyOnForwardDecl();
 
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  Inherited 
4 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  
Inherited 4 2 1
 int onlyOnForwardDecl() {
   return 1;
 }
 
+#ifdef __spirv__ 
+[numthreads(4,2,128)]
+// CHECK-SPIRV: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  4 2 128
+int largeZ();
+#endif 
+
 #else // Vertex and Pixel only beyond here
 // expected-error-re@+1 {{attribute 'numthreads' is unsupported in 
'{{[A-Za-z]+}}' shaders, requires one of the following: compute, amplification, 
mesh}}
 [numthreads(1,1,1)]

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


[clang] [HLSL][SPIRV] Allow large z value in numthreads (PR #144934)

2025-06-19 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-hlsl

@llvm/pr-subscribers-clang

Author: Steven Perron (s-perron)


Changes

The current validation checks for numthreads assume that the target is
DXIL so the version checks inadvertently issue error when targeting
SPIR-V.


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


2 Files Affected:

- (modified) clang/lib/Sema/SemaHLSL.cpp (+5-2) 
- (modified) clang/test/SemaHLSL/num_threads.hlsl (+12-4) 


``diff
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index b55f4fd786b58..9f39c077cea7a 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1033,12 +1033,15 @@ void SemaHLSL::handleRootSignatureAttr(Decl *D, const 
ParsedAttr &AL) {
 void SemaHLSL::handleNumThreadsAttr(Decl *D, const ParsedAttr &AL) {
   llvm::VersionTuple SMVersion =
   getASTContext().getTargetInfo().getTriple().getOSVersion();
+  bool IsDXIL = getASTContext().getTargetInfo().getTriple().getArch() ==
+llvm::Triple::dxil;
+
   uint32_t ZMax = 1024;
   uint32_t ThreadMax = 1024;
-  if (SMVersion.getMajor() <= 4) {
+  if (IsDXIL && SMVersion.getMajor() <= 4) {
 ZMax = 1;
 ThreadMax = 768;
-  } else if (SMVersion.getMajor() == 5) {
+  } else if (IsDXIL && SMVersion.getMajor() == 5) {
 ZMax = 64;
 ThreadMax = 1024;
   }
diff --git a/clang/test/SemaHLSL/num_threads.hlsl 
b/clang/test/SemaHLSL/num_threads.hlsl
index b5f9ad6c33cd6..96200312bbf69 100644
--- a/clang/test/SemaHLSL/num_threads.hlsl
+++ b/clang/test/SemaHLSL/num_threads.hlsl
@@ -10,6 +10,8 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel5.0-compute -x hlsl -ast-dump -o 
- %s -DFAIL -verify
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel4.0-compute -x hlsl -ast-dump -o 
- %s -DFAIL -verify
 
+// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-compute -x hlsl -ast-dump -o - 
%s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV
+
 #if __SHADER_TARGET_STAGE == __SHADER_STAGE_COMPUTE || __SHADER_TARGET_STAGE 
== __SHADER_STAGE_MESH || __SHADER_TARGET_STAGE == __SHADER_STAGE_AMPLIFICATION 
|| __SHADER_TARGET_STAGE == __SHADER_STAGE_LIBRARY
 #ifdef FAIL
 
@@ -88,24 +90,30 @@ int entry() {
 
 // Because these two attributes match, they should both appear in the AST
 [numthreads(2,2,1)]
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 
2 1
 int secondFn();
 
 [numthreads(2,2,1)]
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  2 
2 1
 int secondFn() {
   return 1;
 }
 
 [numthreads(4,2,1)]
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  4 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  4 
2 1
 int onlyOnForwardDecl();
 
-// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  Inherited 
4 2 1
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  
Inherited 4 2 1
 int onlyOnForwardDecl() {
   return 1;
 }
 
+#ifdef __spirv__ 
+[numthreads(4,2,128)]
+// CHECK-SPIRV: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  4 2 128
+int largeZ();
+#endif 
+
 #else // Vertex and Pixel only beyond here
 // expected-error-re@+1 {{attribute 'numthreads' is unsupported in 
'{{[A-Za-z]+}}' shaders, requires one of the following: compute, amplification, 
mesh}}
 [numthreads(1,1,1)]

``




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


[clang-tools-extra] [clang-tidy] Add option to keep virtual in 'modernize-use-override' (PR #144916)

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


@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: {modernize-use-override.AllowVirtual: true}}"
+
+struct Base {
+  virtual ~Base();
+  virtual void a();
+  virtual void b();
+  virtual void c();
+};
+
+struct Derived : public Base {
+  virtual ~Derived() override;
+
+  virtual void a() override;
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^}}  virtual void a() override;

vbvictor wrote:

You should just write nothing. By default, tests will fail if there will be a 
message

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


[clang] [HLSL][SPIRV] Boolean in a RawBuffer should be i32 and Boolean vector in a RawBuffer should be (PR #144929)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Sarah Spall (spall)


Changes

Instead of converting the type in a RawBuffer to its HLSL type using 
'ConvertType', use 'ConvertTypeForMem'.
ConvertTypeForMem handles booleans being i32 and boolean vectors being < N x 
i32 >.
Add tests to show booleans and boolean vectors in RawBuffers now have the 
correct type of i32, and respectively.
Closes #141089 

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


5 Files Affected:

- (modified) clang/lib/CodeGen/Targets/SPIR.cpp (+1-1) 
- (modified) 
clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl (+3) 
- (modified) 
clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl (+3) 
- (modified) 
clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl (+4-1) 
- (modified) clang/test/CodeGenHLSL/builtins/StructuredBuffer-elementtype.hlsl 
(+4-1) 


``diff
diff --git a/clang/lib/CodeGen/Targets/SPIR.cpp 
b/clang/lib/CodeGen/Targets/SPIR.cpp
index afa23bffcd073..23b85adb08c32 100644
--- a/clang/lib/CodeGen/Targets/SPIR.cpp
+++ b/clang/lib/CodeGen/Targets/SPIR.cpp
@@ -483,7 +483,7 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
 assert(!ResAttrs.IsROV &&
"Rasterizer order views not implemented for SPIR-V yet");
 
-llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy);
+llvm::Type *ElemType = CGM.getTypes().ConvertTypeForMem(ContainedTy);
 if (!ResAttrs.RawBuffer) {
   // convert element type
   return getSPIRVImageTypeFromHLSLResource(ResAttrs, ElemType, Ctx);
diff --git 
a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
index 55cc57fadf080..28d9a4b8e596c 100644
--- a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::AppendStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 AppendStructuredBuffer BufI16;
 AppendStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
index 94fdd3cd9d0b3..70fe8670c59af 100644
--- a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 ConsumeStructuredBuffer BufI16;
 ConsumeStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
index e23859ee83d15..f7cdc5d4d39f5 100644
--- a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shad

[clang] [HLSL][SPIRV] Boolean in a RawBuffer should be i32 and Boolean vector in a RawBuffer should be (PR #144929)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Sarah Spall (spall)


Changes

Instead of converting the type in a RawBuffer to its HLSL type using 
'ConvertType', use 'ConvertTypeForMem'.
ConvertTypeForMem handles booleans being i32 and boolean vectors being < N x 
i32 >.
Add tests to show booleans and boolean vectors in RawBuffers now have the 
correct type of i32, and respectively.
Closes #141089 

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


5 Files Affected:

- (modified) clang/lib/CodeGen/Targets/SPIR.cpp (+1-1) 
- (modified) 
clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl (+3) 
- (modified) 
clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl (+3) 
- (modified) 
clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl (+4-1) 
- (modified) clang/test/CodeGenHLSL/builtins/StructuredBuffer-elementtype.hlsl 
(+4-1) 


``diff
diff --git a/clang/lib/CodeGen/Targets/SPIR.cpp 
b/clang/lib/CodeGen/Targets/SPIR.cpp
index afa23bffcd073..23b85adb08c32 100644
--- a/clang/lib/CodeGen/Targets/SPIR.cpp
+++ b/clang/lib/CodeGen/Targets/SPIR.cpp
@@ -483,7 +483,7 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
 assert(!ResAttrs.IsROV &&
"Rasterizer order views not implemented for SPIR-V yet");
 
-llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy);
+llvm::Type *ElemType = CGM.getTypes().ConvertTypeForMem(ContainedTy);
 if (!ResAttrs.RawBuffer) {
   // convert element type
   return getSPIRVImageTypeFromHLSLResource(ResAttrs, ElemType, Ctx);
diff --git 
a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
index 55cc57fadf080..28d9a4b8e596c 100644
--- a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::AppendStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 AppendStructuredBuffer BufI16;
 AppendStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
index 94fdd3cd9d0b3..70fe8670c59af 100644
--- a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 ConsumeStructuredBuffer BufI16;
 ConsumeStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
index e23859ee83d15..f7cdc5d4d39f5 100644
--- a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.

[clang] [HLSL][SPIRV] Boolean in a RawBuffer should be i32 and Boolean vector in a RawBuffer should be (PR #144929)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Sarah Spall (spall)


Changes

Instead of converting the type in a RawBuffer to its HLSL type using 
'ConvertType', use 'ConvertTypeForMem'.
ConvertTypeForMem handles booleans being i32 and boolean vectors being < N x 
i32 >.
Add tests to show booleans and boolean vectors in RawBuffers now have the 
correct type of i32, and respectively.
Closes #141089 

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


5 Files Affected:

- (modified) clang/lib/CodeGen/Targets/SPIR.cpp (+1-1) 
- (modified) 
clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl (+3) 
- (modified) 
clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl (+3) 
- (modified) 
clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl (+4-1) 
- (modified) clang/test/CodeGenHLSL/builtins/StructuredBuffer-elementtype.hlsl 
(+4-1) 


``diff
diff --git a/clang/lib/CodeGen/Targets/SPIR.cpp 
b/clang/lib/CodeGen/Targets/SPIR.cpp
index afa23bffcd073..23b85adb08c32 100644
--- a/clang/lib/CodeGen/Targets/SPIR.cpp
+++ b/clang/lib/CodeGen/Targets/SPIR.cpp
@@ -483,7 +483,7 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
 assert(!ResAttrs.IsROV &&
"Rasterizer order views not implemented for SPIR-V yet");
 
-llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy);
+llvm::Type *ElemType = CGM.getTypes().ConvertTypeForMem(ContainedTy);
 if (!ResAttrs.RawBuffer) {
   // convert element type
   return getSPIRVImageTypeFromHLSLResource(ResAttrs, ElemType, Ctx);
diff --git 
a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
index 55cc57fadf080..28d9a4b8e596c 100644
--- a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::AppendStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 AppendStructuredBuffer BufI16;
 AppendStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
index 94fdd3cd9d0b3..70fe8670c59af 100644
--- a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 ConsumeStructuredBuffer BufI16;
 ConsumeStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
index e23859ee83d15..f7cdc5d4d39f5 100644
--- a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6

[clang] [lld] Use the Windows SDK arguments over the environment (PR #144805)

2025-06-19 Thread Daniel Paoliello via cfe-commits

dpaoliello wrote:

Just to confirm, does this make clang-cl line up with cl's behavior?

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


[clang] [HLSL][SPIRV] Boolean in a RawBuffer should be i32 and Boolean vector in a RawBuffer should be (PR #144929)

2025-06-19 Thread Sarah Spall via cfe-commits

https://github.com/spall created 
https://github.com/llvm/llvm-project/pull/144929

Instead of converting the type in a RawBuffer to its HLSL type using 
'ConvertType', use 'ConvertTypeForMem'.
ConvertTypeForMem handles booleans being i32 and boolean vectors being < N x 
i32 >.
Add tests to show booleans and boolean vectors in RawBuffers now have the 
correct type of i32, and respectively.
Closes #141089 

>From bb1b35422a5d25dd2481ec004b5d7b3056304745 Mon Sep 17 00:00:00 2001
From: Sarah Spall 
Date: Thu, 19 Jun 2025 10:17:51 -0700
Subject: [PATCH] call convertTypeForMem instead of convertType

---
 clang/lib/CodeGen/Targets/SPIR.cpp   | 2 +-
 .../builtins/AppendStructuredBuffer-elementtype.hlsl | 3 +++
 .../builtins/ConsumeStructuredBuffer-elementtype.hlsl| 3 +++
 .../CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl | 5 -
 .../CodeGenHLSL/builtins/StructuredBuffer-elementtype.hlsl   | 5 -
 5 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/SPIR.cpp 
b/clang/lib/CodeGen/Targets/SPIR.cpp
index afa23bffcd073..23b85adb08c32 100644
--- a/clang/lib/CodeGen/Targets/SPIR.cpp
+++ b/clang/lib/CodeGen/Targets/SPIR.cpp
@@ -483,7 +483,7 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
 assert(!ResAttrs.IsROV &&
"Rasterizer order views not implemented for SPIR-V yet");
 
-llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy);
+llvm::Type *ElemType = CGM.getTypes().ConvertTypeForMem(ContainedTy);
 if (!ResAttrs.RawBuffer) {
   // convert element type
   return getSPIRVImageTypeFromHLSLResource(ResAttrs, ElemType, Ctx);
diff --git 
a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
index 55cc57fadf080..28d9a4b8e596c 100644
--- a/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/AppendStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::AppendStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::AppendStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 AppendStructuredBuffer BufI16;
 AppendStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
index 94fdd3cd9d0b3..70fe8670c59af 100644
--- a/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ConsumeStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=DXIL
+// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute 
-finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=SPV
 
 struct MyStruct {
   float4 a;
@@ -21,7 +22,9 @@ struct MyStruct {
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.12" = type { 
target("dx.RawBuffer", %struct.MyStruct, 1, 0)
 // DXIL: %struct.MyStruct = type <{ <4 x float>, <2 x i32> }>
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("dx.RawBuffer", i32, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.13" = type { 
target("spirv.VulkanBuffer", [0 x i32], 12, 1)
 // DXIL: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("dx.RawBuffer", <4 x i32>, 1, 0)
+// SPV: %"class.hlsl::ConsumeStructuredBuffer.14" = type { 
target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1)
 
 ConsumeStructuredBuffer BufI16;
 ConsumeStructuredBuffer BufU16;
diff --git 
a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
index e23859ee83d15..f7cdc5d4d39f5 100644
--- a/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute 
-finclude-default-header -fnative-half-type -emit-ll

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation directive and "looprange" clause (PR #139293)

2025-06-19 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions h,c,cpp -- 
clang/test/OpenMP/fuse_ast_print.cpp clang/test/OpenMP/fuse_codegen.cpp 
clang/test/OpenMP/fuse_messages.cpp 
openmp/runtime/test/transform/fuse/foreach.cpp 
openmp/runtime/test/transform/fuse/intfor.c 
openmp/runtime/test/transform/fuse/iterfor.cpp 
openmp/runtime/test/transform/fuse/parallel-wsloop-collapse-foreach.cpp 
openmp/runtime/test/transform/fuse/parallel-wsloop-collapse-intfor.c 
clang/include/clang-c/Index.h clang/include/clang/AST/OpenMPClause.h 
clang/include/clang/AST/RecursiveASTVisitor.h 
clang/include/clang/AST/StmtOpenMP.h clang/include/clang/Parse/Parser.h 
clang/include/clang/Sema/SemaOpenMP.h 
clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/OpenMPClause.cpp 
clang/lib/AST/StmtOpenMP.cpp clang/lib/AST/StmtPrinter.cpp 
clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp 
clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGStmt.cpp 
clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenFunction.h 
clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaExceptionSpec.cpp 
clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h 
clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderStmt.cpp 
clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterStmt.cpp 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp clang/tools/libclang/CIndex.cpp 
clang/tools/libclang/CXCursor.cpp flang/include/flang/Parser/dump-parse-tree.h 
flang/include/flang/Parser/parse-tree.h flang/lib/Lower/OpenMP/Clauses.cpp 
flang/lib/Lower/OpenMP/Clauses.h flang/lib/Parser/openmp-parsers.cpp 
flang/lib/Parser/unparse.cpp flang/lib/Semantics/check-omp-structure.cpp 
llvm/include/llvm/Frontend/OpenMP/ClauseT.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 08bee0078..9364007f3 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -6737,7 +6737,7 @@ private:
 
   /// Parses the 'looprange' clause of a '#pragma omp fuse' directive.
   OMPClause *ParseOpenMPLoopRangeClause();
-  
+
   /// Parses the 'sizes' clause of a '#pragma omp tile' directive.
   OMPClause *ParseOpenMPSizesClause();
 
diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index f527e6361..1f49e9f2a 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -522,15 +522,15 @@ OMPFuseDirective *OMPFuseDirective::Create(
   NumLoops);
   Dir->setTransformedStmt(TransformedStmt);
   Dir->setPreInits(PreInits);
-  // The number of top level canonical nests could 
+  // The number of top level canonical nests could
   // not match the total number of generated loops
   // Example:
   // Before fusion:
-  //   for (int i = 0; i < N; ++i)   
-  // for (int j = 0; j < M; ++j) 
+  //   for (int i = 0; i < N; ++i)
+  // for (int j = 0; j < M; ++j)
   //   A[i][j] = i + j;
-  //   
-  //   for (int k = 0; k < P; ++k) 
+  //
+  //   for (int k = 0; k < P; ++k)
   // B[k] = k * 2;
   // Here, NumLoopNests = 2, but NumLoops = 3.
   Dir->setNumGeneratedLoopNests(NumLoopNests);
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 2d6d624c1..48d9c1841 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3520,7 +3520,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind 
DKind,
 break;
   case OMPC_looprange:
 Clause = ParseOpenMPLoopRangeClause();
-break;  
+break;
   default:
 break;
   }
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index a38249bf2..c94d56cb5 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -998,7 +998,7 @@ Link make(const parser::OmpClause::Link &inp,
 }
 
 LoopRange make(const parser::OmpClause::Looprange &inp,
-semantics::SemanticsContext &semaCtx) {
+   semantics::SemanticsContext &semaCtx) {
   llvm_unreachable("Unimplemented: looprange");
 }
 
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index d53389746..39978e402 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -847,10 +847,8 @@ TYPE_PARSER(
 maybe(":"_tok >> nonemptyList(Parser{})),
 /*PostModified=*/pure(true)))
 
-TYPE_PARSER(
-  construct(scalarIntConstantExpr,
-"," >> scalarIntConstantExpr)
-)
+TYPE_PARSER(construct(
+scalarIntConstantExpr, "," >> scalarIntConstantExpr))
 
 // OpenMPv5.2 12.5.2 detach-clause -> DETACH (event-handle)
 TYPE_PARSER(construct(Parser{}))
@@ -1026,7 +1024,7 @@ TYPE_PARSER( //
 "LINK" >> construct(construct(
 

[clang] [Clang] Diagnose unsatisfied `std::is_assignable`. (PR #144836)

2025-06-19 Thread Ross Kirsling via cfe-commits


@@ -99,6 +127,14 @@ static_assert(std::is_trivially_copyable_v);
 // expected-note@-1 {{'int &' is not trivially copyable}} \
 // expected-note@-1 {{because it is a reference type}}
 
+static_assert(std::is_assignable::value);
+
+static_assert(std::is_assignable::value);
+// expected-error-re@-1 {{static assertion failed due to requirement 
'std::{{.*}}is_assignable::value'}} \
+// expected-error@-1 {{assigning to 'int' from incompatible type 'void'}}

rkirsling wrote:

Right, at first I wondered if I needed to recapitulate all of these existing 
diagnostic messages somehow, just to ensure that it would all be `note`s 
against a single `error`. But it 
[appears](https://github.com/llvm/llvm-project/pull/144220/files#diff-9e681885bce5b9efd3dba53a469fb788e863d7d5f76c657232ea4c62a4147ab4)
 that `is_constructible` is also incurring a second `error` (via 
`InitializationSequence::Diagnose`).

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


[clang] [Clang] Diagnose unsatisfied `std::is_assignable`. (PR #144836)

2025-06-19 Thread Ross Kirsling via cfe-commits

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


[clang] [llvm] Fix Windows EH IP2State tables (remove +1 bias) (PR #144745)

2025-06-19 Thread via cfe-commits

namazso wrote:

> For an SEH exception that occurs within a function due to a CALL (such as a 
> bogus indirect call), the IP should point to the beginning of the CALL 
> instruction, so the IP2State tables should point to the correct region.

Yes, I was just pointing out that same-frame catch isn't supposed to be 
supported in LLVM per the docs. By that rule, this code:

```
void test1(void(*a)()) {
__try {
a();
} __except(1) {
printf("throw in call!\n");
}
}

void test2(void(*a)()) {
__try {
test1(a);
} __except (1) {
printf("throw from call!\n");
}
}

void int3() {
__debugbreak();
}

int main() {
test2(&int3);
test2((void(*)())0x8FFF);
return 0;
}
```

Should result in this:

```
throw in call!
throw from call!
```

Which indeed would probably work like that if the start labels were also offset 
by 1 all the time. Of course it's way different from MSVC, but it sounded at 
least *consistent* even if slightly insane. However when I tested it on the 
current LLVM release, it was not consistent at all already, so that's why I 
commented to just disregard this observation - it already didn't conform 
whatever the docs were saying, it's not going to be any more broken that it 
currently is.

>  I'd be happy to improve the state of things for SEH, as well as ensuring 
> that this PR doesn't regress support for GNU's EH support on Windows. If 
> GNU's C++ EH support is based on SEH, then I think I will need to change this 
> PR so that a CALL aligned to .seh_startepilogue always inserts a NOP call. 
> That's easy to do. Do you have pointers to any info on GNU C++ exception 
> dispatch?

Sorry, no clue on GNU EH, my observations were purely about the current state 
of SEH and the docs (incorrectly) describing the "rules" on how exactly it is 
partially supported.

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


[clang-tools-extra] [clang-tidy] Add option to keep virtual in 'modernize-use-override' (PR #144916)

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


@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: {modernize-use-override.AllowVirtual: true}}"
+
+struct Base {
+  virtual ~Base();
+  virtual void a();
+  virtual void b();
+  virtual void c();
+};
+
+struct Derived : public Base {
+  virtual ~Derived() override;
+
+  virtual void a() override;
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^}}  virtual void a() override;
+
+  virtual void b();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: add 'override'
+  // CHECK-FIXES: {{^}}  virtual void b() override;
+
+  void c();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate
+  // CHECK-FIXES: {{^}}  void c() override;

vbvictor wrote:

ditto `{{^}}`

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


[clang-tools-extra] [clang-tidy] Add option to keep virtual in 'modernize-use-override' (PR #144916)

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


@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: {modernize-use-override.AllowVirtual: true}}"
+
+struct Base {
+  virtual ~Base();
+  virtual void a();
+  virtual void b();
+  virtual void c();
+};
+
+struct Derived : public Base {
+  virtual ~Derived() override;
+
+  virtual void a() override;
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^}}  virtual void a() override;
+
+  virtual void b();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: add 'override'
+  // CHECK-FIXES: {{^}}  virtual void b() override;

vbvictor wrote:

don't use `{{^}}`, just match string as a whole

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


[clang-tools-extra] [clang-tidy] Add option to keep virtual in 'modernize-use-override' (PR #144916)

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

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


[clang-tools-extra] [clang-tidy] Add option to keep virtual in 'modernize-use-override' (PR #144916)

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

https://github.com/vbvictor requested changes to this pull request.

Please add your change to ReleaseNotes.rst 

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


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

2025-06-19 Thread Reid Kleckner via cfe-commits


@@ -117,6 +117,7 @@ get_property(LINK_LIBS GLOBAL PROPERTY 
CLANG_UNITTEST_LINK_LIBS)
 get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
 add_distinct_clang_unittest(AllClangUnitTests
   ${SRCS}
+  AllClangUnitTests.cpp

rnk wrote:

Yeah, on second thought, there's a lot more going on in UnitTestMain than I 
thought. I rewrote this to use a dynamic initializer to register the targets 
instead. Those will reliably run before test fixtures. The only risk here is 
that we encounter intialization-order-fiasco issues, but I spot-checked x86, 
and it seems to be resilient to that... I will test with ASan locally to build 
confidence, but PTAL at the new approach.

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


[clang] [llvm] Add support for Windows Secure Hot-Patching (PR #138972)

2025-06-19 Thread via cfe-commits

https://github.com/sivadeilra updated 
https://github.com/llvm/llvm-project/pull/138972

>From 7382ec9923a6ab96cc6c82782dda33ec78c0bc2e Mon Sep 17 00:00:00 2001
From: Arlie Davis 
Date: Thu, 3 Apr 2025 16:10:50 -0700
Subject: [PATCH 1/2] Windows hotpatching support

move hotpatch tests to X86 subdir

move llvm hotpatch tests to X86 dir

switch to strbool attributes
---
 clang/include/clang/Basic/CodeGenOptions.h|   7 +
 clang/include/clang/Driver/Options.td |  18 +
 clang/lib/CodeGen/CGCall.cpp  |   7 +
 clang/lib/CodeGen/CodeGenModule.cpp   |  29 +
 clang/lib/CodeGen/CodeGenModule.h |   5 +
 clang/lib/Driver/ToolChains/Clang.cpp |   8 +
 .../CodeGen/X86/ms-secure-hotpatch-bad-file.c |  16 +
 .../CodeGen/X86/ms-secure-hotpatch-cpp.cpp|  22 +
 .../CodeGen/X86/ms-secure-hotpatch-eh.cpp |  24 +
 .../CodeGen/X86/ms-secure-hotpatch-globals.c  | 133 
 .../test/CodeGen/X86/ms-secure-hotpatch-lto.c |  24 +
 clang/test/CodeGen/X86/ms-secure-hotpatch.c   |  21 +
 llvm/include/llvm/CodeGen/Passes.h|   3 +
 .../DebugInfo/CodeView/CodeViewSymbols.def|   2 +
 .../llvm/DebugInfo/CodeView/SymbolRecord.h|  15 +
 llvm/include/llvm/IR/Attributes.td|  10 +
 llvm/include/llvm/InitializePasses.h  |   1 +
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |   4 +
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp |   4 +
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp |  24 +
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h   |   2 +
 llvm/lib/CodeGen/CMakeLists.txt   |   1 +
 llvm/lib/CodeGen/TargetPassConfig.cpp |   3 +
 llvm/lib/CodeGen/WindowsSecureHotPatching.cpp | 617 ++
 llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp  |   7 +
 .../CodeView/SymbolRecordMapping.cpp  |   7 +
 llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp   |   5 +
 llvm/lib/Transforms/Utils/CodeExtractor.cpp   |   2 +
 .../CodeGen/X86/ms-secure-hotpatch-attr.ll|  38 ++
 .../X86/ms-secure-hotpatch-bad-file.ll|  16 +
 ...ms-secure-hotpatch-direct-global-access.ll |  39 ++
 .../X86/ms-secure-hotpatch-functions-file.ll  |  39 ++
 .../X86/ms-secure-hotpatch-functions-list.ll  |  38 ++
 .../llvm-pdbutil/MinimalSymbolDumper.cpp  |   8 +
 34 files changed, 1199 insertions(+)
 create mode 100644 clang/test/CodeGen/X86/ms-secure-hotpatch-bad-file.c
 create mode 100644 clang/test/CodeGen/X86/ms-secure-hotpatch-cpp.cpp
 create mode 100644 clang/test/CodeGen/X86/ms-secure-hotpatch-eh.cpp
 create mode 100644 clang/test/CodeGen/X86/ms-secure-hotpatch-globals.c
 create mode 100644 clang/test/CodeGen/X86/ms-secure-hotpatch-lto.c
 create mode 100644 clang/test/CodeGen/X86/ms-secure-hotpatch.c
 create mode 100644 llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
 create mode 100644 llvm/test/CodeGen/X86/ms-secure-hotpatch-attr.ll
 create mode 100644 llvm/test/CodeGen/X86/ms-secure-hotpatch-bad-file.ll
 create mode 100644 
llvm/test/CodeGen/X86/ms-secure-hotpatch-direct-global-access.ll
 create mode 100644 llvm/test/CodeGen/X86/ms-secure-hotpatch-functions-file.ll
 create mode 100644 llvm/test/CodeGen/X86/ms-secure-hotpatch-functions-list.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 7ba21fca6dd6b..77a0c559f7689 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -495,6 +495,13 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
   /// A list of functions that are replacable by the loader.
   std::vector LoaderReplaceableFunctionNames;
+  /// The name of a file that contains functions which will be compiled for
+  /// hotpatching. See -fms-secure-hotpatch-functions-file.
+  std::string MSSecureHotPatchFunctionsFile;
+
+  /// A list of functions which will be compiled for hotpatching.
+  /// See -fms-secure-hotpatch-functions-list.
+  std::vector MSSecureHotPatchFunctionsList;
 
 public:
   // Define accessors/mutators for code generation options of enumeration type.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0ffd8c40da7da..5ba09232cff5a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3837,6 +3837,24 @@ def fms_hotpatch : Flag<["-"], "fms-hotpatch">, 
Group,
   Visibility<[ClangOption, CC1Option, CLOption]>,
   HelpText<"Ensure that all functions can be hotpatched at runtime">,
   MarshallingInfoFlag>;
+
+// See llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
+def fms_secure_hotpatch_functions_file
+: Joined<["-"], "fms-secure-hotpatch-functions-file=">,
+  Group,
+  Visibility<[ClangOption, CC1Option, CLOption]>,
+  MarshallingInfoString>,
+  HelpText<"Path to a file that contains a list of mangled names of "
+   "functions that should be hot-patched for Windows Secure "
+   "Hot-Patching">;
+def fms_secure_hotpatch_functions_list
+: CommaJoined<["-"], "fms-se

[clang] [CodeGen] Use range-based for loops (NFC) (PR #144939)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


10 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+3-3) 
- (modified) clang/lib/CodeGen/CGCleanup.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+3-3) 
- (modified) clang/lib/CodeGen/CGException.cpp (+5-5) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+6-6) 
- (modified) clang/lib/CodeGen/CGExprConstant.cpp (+1-3) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGObjCGNU.cpp (+8-11) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+8-12) 
- (modified) clang/lib/CodeGen/CGObjCRuntime.cpp (+1-3) 


``diff
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 729758ddce560..f3ddf7bf9a463 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1415,10 +1415,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(
   // Arrange for local static and local extern declarations to appear
   // to be local to this function as well, in case they're directly
   // referenced in a block.
-  for (DeclMapTy::const_iterator i = ldm.begin(), e = ldm.end(); i != e; ++i) {
-const auto *var = dyn_cast(i->first);
+  for (const auto &KV : ldm) {
+const auto *var = dyn_cast(KV.first);
 if (var && !var->hasLocalStorage())
-  setAddrOfLocalVar(var, i->second);
+  setAddrOfLocalVar(var, KV.second);
   }
 
   // Begin building the function declaration.
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 4ed2c5183c47e..28ac9bf396356 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -962,8 +962,8 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough,
 
   // Append the prepared cleanup prologue from above.
   llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
-  for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
-InstsToAppend[I]->insertInto(NormalExit, NormalExit->end());
+  for (llvm::Instruction *Inst : InstsToAppend)
+Inst->insertInto(NormalExit, NormalExit->end());
 
   // Optimistically hope that any fixups will continue falling through.
   for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 69d77f283db3b..7ae99935c8ad3 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1121,9 +1121,9 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function 
*Fn,
   EmitObjCAutoreleasePoolCleanup(token);
 }
 
-for (unsigned i = 0, e = Decls.size(); i != e; ++i)
-  if (Decls[i])
-EmitRuntimeCall(Decls[i]);
+for (llvm::Function *Decl : Decls)
+  if (Decl)
+EmitRuntimeCall(Decl);
 
 Scope.ForceCleanup();
 
diff --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index e0367282355cf..ad138b9876e8c 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -319,9 +319,9 @@ static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) {
 llvm::Function *F = dyn_cast(U);
 if (!F) return false;
 
-for (auto BB = F->begin(), E = F->end(); BB != E; ++BB) {
-  if (BB->isLandingPad())
-if (!LandingPadHasOnlyCXXUses(BB->getLandingPadInst()))
+for (llvm::BasicBlock &BB : *F) {
+  if (BB.isLandingPad())
+if (!LandingPadHasOnlyCXXUses(BB.getLandingPadInst()))
   return false;
 }
   }
@@ -937,8 +937,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {
  filterTypes[0]->getType() : Int8PtrTy,
filterTypes.size());
 
-for (unsigned i = 0, e = filterTypes.size(); i != e; ++i)
-  Filters.push_back(cast(filterTypes[i]));
+for (llvm::Value *filterType : filterTypes)
+  Filters.push_back(cast(filterType));
 llvm::Constant *FilterArray = llvm::ConstantArray::get(AType, Filters);
 LPadInst->addClause(FilterArray);
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6cb348ffdf55f..85c768807572f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3801,8 +3801,8 @@ void CodeGenFunction::EmitCheck(
   ArgTypes.push_back(Args.back()->getType());
 }
 
-for (size_t i = 0, n = DynamicArgs.size(); i != n; ++i) {
-  Args.push_back(EmitCheckValue(DynamicArgs[i]));
+for (llvm::Value *DynamicArg : DynamicArgs) {
+  Args.push_back(EmitCheckValue(DynamicArg));
   ArgTypes.push_back(IntPtrTy);
 }
   }
@@ -4932,8 +4932,8 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
   llvm::Constant *BaseElts = Base.getExtVectorElts();
   SmallVector CElts;
 
-  for (unsigned i = 0, e = Indices.size(); i != e; ++i)
-CElts.push_back(BaseElts->getAggregateElement(Indices[i]));
+  fo

[clang] [CodeGen] Use range-based for loops (NFC) (PR #144939)

2025-06-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/144939

None

>From 2b6ab2eb7a999f2f56ef637b00048388be00a6db Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 15 Jun 2025 21:53:53 -0700
Subject: [PATCH] [CodeGen] Use range-based for loops (NFC)

---
 clang/lib/CodeGen/CGBlocks.cpp   |  6 +++---
 clang/lib/CodeGen/CGCleanup.cpp  |  4 ++--
 clang/lib/CodeGen/CGDeclCXX.cpp  |  6 +++---
 clang/lib/CodeGen/CGException.cpp| 10 +-
 clang/lib/CodeGen/CGExpr.cpp | 12 ++--
 clang/lib/CodeGen/CGExprConstant.cpp |  4 +---
 clang/lib/CodeGen/CGObjC.cpp |  4 ++--
 clang/lib/CodeGen/CGObjCGNU.cpp  | 19 ---
 clang/lib/CodeGen/CGObjCMac.cpp  | 20 
 clang/lib/CodeGen/CGObjCRuntime.cpp  |  4 +---
 10 files changed, 39 insertions(+), 50 deletions(-)

diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 729758ddce560..f3ddf7bf9a463 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1415,10 +1415,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(
   // Arrange for local static and local extern declarations to appear
   // to be local to this function as well, in case they're directly
   // referenced in a block.
-  for (DeclMapTy::const_iterator i = ldm.begin(), e = ldm.end(); i != e; ++i) {
-const auto *var = dyn_cast(i->first);
+  for (const auto &KV : ldm) {
+const auto *var = dyn_cast(KV.first);
 if (var && !var->hasLocalStorage())
-  setAddrOfLocalVar(var, i->second);
+  setAddrOfLocalVar(var, KV.second);
   }
 
   // Begin building the function declaration.
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 4ed2c5183c47e..28ac9bf396356 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -962,8 +962,8 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough,
 
   // Append the prepared cleanup prologue from above.
   llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
-  for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
-InstsToAppend[I]->insertInto(NormalExit, NormalExit->end());
+  for (llvm::Instruction *Inst : InstsToAppend)
+Inst->insertInto(NormalExit, NormalExit->end());
 
   // Optimistically hope that any fixups will continue falling through.
   for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 69d77f283db3b..7ae99935c8ad3 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1121,9 +1121,9 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function 
*Fn,
   EmitObjCAutoreleasePoolCleanup(token);
 }
 
-for (unsigned i = 0, e = Decls.size(); i != e; ++i)
-  if (Decls[i])
-EmitRuntimeCall(Decls[i]);
+for (llvm::Function *Decl : Decls)
+  if (Decl)
+EmitRuntimeCall(Decl);
 
 Scope.ForceCleanup();
 
diff --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index e0367282355cf..ad138b9876e8c 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -319,9 +319,9 @@ static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) {
 llvm::Function *F = dyn_cast(U);
 if (!F) return false;
 
-for (auto BB = F->begin(), E = F->end(); BB != E; ++BB) {
-  if (BB->isLandingPad())
-if (!LandingPadHasOnlyCXXUses(BB->getLandingPadInst()))
+for (llvm::BasicBlock &BB : *F) {
+  if (BB.isLandingPad())
+if (!LandingPadHasOnlyCXXUses(BB.getLandingPadInst()))
   return false;
 }
   }
@@ -937,8 +937,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {
  filterTypes[0]->getType() : Int8PtrTy,
filterTypes.size());
 
-for (unsigned i = 0, e = filterTypes.size(); i != e; ++i)
-  Filters.push_back(cast(filterTypes[i]));
+for (llvm::Value *filterType : filterTypes)
+  Filters.push_back(cast(filterType));
 llvm::Constant *FilterArray = llvm::ConstantArray::get(AType, Filters);
 LPadInst->addClause(FilterArray);
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6cb348ffdf55f..85c768807572f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3801,8 +3801,8 @@ void CodeGenFunction::EmitCheck(
   ArgTypes.push_back(Args.back()->getType());
 }
 
-for (size_t i = 0, n = DynamicArgs.size(); i != n; ++i) {
-  Args.push_back(EmitCheckValue(DynamicArgs[i]));
+for (llvm::Value *DynamicArg : DynamicArgs) {
+  Args.push_back(EmitCheckValue(DynamicArg));
   ArgTypes.push_back(IntPtrTy);
 }
   }
@@ -4932,8 +4932,8 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
   llvm::Constant *BaseElts = Base.getExtVectorElts();
   SmallVector CE

[clang] [CodeGen] Use range-based for loops (NFC) (PR #144939)

2025-06-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Kazu Hirata (kazutakahirata)


Changes



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


10 Files Affected:

- (modified) clang/lib/CodeGen/CGBlocks.cpp (+3-3) 
- (modified) clang/lib/CodeGen/CGCleanup.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+3-3) 
- (modified) clang/lib/CodeGen/CGException.cpp (+5-5) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+6-6) 
- (modified) clang/lib/CodeGen/CGExprConstant.cpp (+1-3) 
- (modified) clang/lib/CodeGen/CGObjC.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGObjCGNU.cpp (+8-11) 
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+8-12) 
- (modified) clang/lib/CodeGen/CGObjCRuntime.cpp (+1-3) 


``diff
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 729758ddce560..f3ddf7bf9a463 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1415,10 +1415,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(
   // Arrange for local static and local extern declarations to appear
   // to be local to this function as well, in case they're directly
   // referenced in a block.
-  for (DeclMapTy::const_iterator i = ldm.begin(), e = ldm.end(); i != e; ++i) {
-const auto *var = dyn_cast(i->first);
+  for (const auto &KV : ldm) {
+const auto *var = dyn_cast(KV.first);
 if (var && !var->hasLocalStorage())
-  setAddrOfLocalVar(var, i->second);
+  setAddrOfLocalVar(var, KV.second);
   }
 
   // Begin building the function declaration.
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 4ed2c5183c47e..28ac9bf396356 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -962,8 +962,8 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough,
 
   // Append the prepared cleanup prologue from above.
   llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
-  for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
-InstsToAppend[I]->insertInto(NormalExit, NormalExit->end());
+  for (llvm::Instruction *Inst : InstsToAppend)
+Inst->insertInto(NormalExit, NormalExit->end());
 
   // Optimistically hope that any fixups will continue falling through.
   for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 69d77f283db3b..7ae99935c8ad3 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1121,9 +1121,9 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function 
*Fn,
   EmitObjCAutoreleasePoolCleanup(token);
 }
 
-for (unsigned i = 0, e = Decls.size(); i != e; ++i)
-  if (Decls[i])
-EmitRuntimeCall(Decls[i]);
+for (llvm::Function *Decl : Decls)
+  if (Decl)
+EmitRuntimeCall(Decl);
 
 Scope.ForceCleanup();
 
diff --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index e0367282355cf..ad138b9876e8c 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -319,9 +319,9 @@ static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) {
 llvm::Function *F = dyn_cast(U);
 if (!F) return false;
 
-for (auto BB = F->begin(), E = F->end(); BB != E; ++BB) {
-  if (BB->isLandingPad())
-if (!LandingPadHasOnlyCXXUses(BB->getLandingPadInst()))
+for (llvm::BasicBlock &BB : *F) {
+  if (BB.isLandingPad())
+if (!LandingPadHasOnlyCXXUses(BB.getLandingPadInst()))
   return false;
 }
   }
@@ -937,8 +937,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {
  filterTypes[0]->getType() : Int8PtrTy,
filterTypes.size());
 
-for (unsigned i = 0, e = filterTypes.size(); i != e; ++i)
-  Filters.push_back(cast(filterTypes[i]));
+for (llvm::Value *filterType : filterTypes)
+  Filters.push_back(cast(filterType));
 llvm::Constant *FilterArray = llvm::ConstantArray::get(AType, Filters);
 LPadInst->addClause(FilterArray);
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6cb348ffdf55f..85c768807572f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3801,8 +3801,8 @@ void CodeGenFunction::EmitCheck(
   ArgTypes.push_back(Args.back()->getType());
 }
 
-for (size_t i = 0, n = DynamicArgs.size(); i != n; ++i) {
-  Args.push_back(EmitCheckValue(DynamicArgs[i]));
+for (llvm::Value *DynamicArg : DynamicArgs) {
+  Args.push_back(EmitCheckValue(DynamicArg));
   ArgTypes.push_back(IntPtrTy);
 }
   }
@@ -4932,8 +4932,8 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
   llvm::Constant *BaseElts = Base.getExtVectorElts();
   SmallVector CElts;
 
-  for (unsigned i = 0, e = Indices.size(); i != e; ++i)
-CElts.push_back(BaseElts->getAggregateElement(Indices[i])

[clang-tools-extra] [llvm] [clang-tools-extra] Add clang-omp-pr-desc wrapper for OpenMP PR summarization (PR #144935)

2025-06-19 Thread Aviral Singh via cfe-commits

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


[clang-tools-extra] [llvm] [clang-tools-extra] Add clang-omp-pr-desc wrapper for OpenMP PR summarization (PR #144935)

2025-06-19 Thread Aviral Singh via cfe-commits

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


[clang] [TableGen] Use ListSeparator (NFC) (PR #144936)

2025-06-19 Thread Rahul Joshi via cfe-commits

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


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


[clang] [clang][bytecode] Allocate IntegralAP and Floating types using an allocator (PR #144246)

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


tbaederr wrote:

Can you try applying

```diff
diff --git i/clang/lib/AST/ByteCode/IntegralAP.h 
w/clang/lib/AST/ByteCode/IntegralAP.h
index 0280ea072ca9..4c1fb61e3e15 100644
--- i/clang/lib/AST/ByteCode/IntegralAP.h
+++ w/clang/lib/AST/ByteCode/IntegralAP.h
@@ -92,7 +92,10 @@ public:

   // Constructors.
   IntegralAP() = default;
-  IntegralAP(unsigned BitWidth) : BitWidth(BitWidth) {}
+  IntegralAP(unsigned BitWidth) : Val(0), BitWidth(BitWidth) {
+assert(singleWord());
+Val = 0;
+  }
   IntegralAP(uint64_t *Memory, unsigned BitWidth)
   : Memory(Memory), BitWidth(BitWidth) {}
   IntegralAP(const APInt &V) : BitWidth(V.getBitWidth()) {
```
(or the equivalent) and re-checking?

In the single-word case, we're not explicitly setting `Val` to `0` and since 
the `Memory` Pointer only partially overlaps with it, the resulting value is 
garbage.

(I with ubsan would catch reads from inactive union members but alas)

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


[clang] [llvm] [ObjCARC] Delete empty autoreleasepools with no autoreleases in them (PR #144788)

2025-06-19 Thread via cfe-commits

https://github.com/AZero13 updated 
https://github.com/llvm/llvm-project/pull/144788

>From 32b8b89591596f5ddf467c96311fc431656d6cd1 Mon Sep 17 00:00:00 2001
From: Rose 
Date: Wed, 18 Jun 2025 16:05:44 -0400
Subject: [PATCH 1/2] [ObjCARC] Delete empty autoreleasepools with no
 autoreleases in them

Erase empty autorelease pools that have no autorelease in them
---
 .../ObjCARC/ARCRuntimeEntryPoints.h   |  16 +++
 llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp   | 123 +-
 .../ObjCARC/test_autorelease_pool.ll  | 118 +
 3 files changed, 252 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/Transforms/ObjCARC/test_autorelease_pool.ll

diff --git a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h 
b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
index 3fa844eda21cf..6135c7b938a3e 100644
--- a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
+++ b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
@@ -46,6 +46,8 @@ enum class ARCRuntimeEntryPointKind {
   UnsafeClaimRV,
   RetainAutorelease,
   RetainAutoreleaseRV,
+  AutoreleasePoolPush,
+  AutoreleasePoolPop,
 };
 
 /// Declarations for ObjC runtime functions and constants. These are 
initialized
@@ -67,6 +69,8 @@ class ARCRuntimeEntryPoints {
 UnsafeClaimRV = nullptr;
 RetainAutorelease = nullptr;
 RetainAutoreleaseRV = nullptr;
+AutoreleasePoolPush = nullptr;
+AutoreleasePoolPop = nullptr;
   }
 
   Function *get(ARCRuntimeEntryPointKind kind) {
@@ -101,6 +105,12 @@ class ARCRuntimeEntryPoints {
 case ARCRuntimeEntryPointKind::RetainAutoreleaseRV:
   return getIntrinsicEntryPoint(RetainAutoreleaseRV,
 Intrinsic::objc_retainAutoreleaseReturnValue);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPush:
+  return getIntrinsicEntryPoint(AutoreleasePoolPush,
+Intrinsic::objc_autoreleasePoolPush);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPop:
+  return getIntrinsicEntryPoint(AutoreleasePoolPop,
+Intrinsic::objc_autoreleasePoolPop);
 }
 
 llvm_unreachable("Switch should be a covered switch.");
@@ -143,6 +153,12 @@ class ARCRuntimeEntryPoints {
   /// Declaration for objc_retainAutoreleaseReturnValue().
   Function *RetainAutoreleaseRV = nullptr;
 
+  /// Declaration for objc_autoreleasePoolPush().
+  Function *AutoreleasePoolPush = nullptr;
+
+  /// Declaration for objc_autoreleasePoolPop().
+  Function *AutoreleasePoolPop = nullptr;
+
   Function *getIntrinsicEntryPoint(Function *&Decl, Intrinsic::ID IntID) {
 if (Decl)
   return Decl;
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 5eb3f51d38945..deec643532c5d 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Analysis/ObjCARCAnalysisUtils.h"
 #include "llvm/Analysis/ObjCARCInstKind.h"
 #include "llvm/Analysis/ObjCARCUtil.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constant.h"
@@ -132,11 +133,8 @@ static const Value *FindSingleUseIdentifiedObject(const 
Value *Arg) {
 //
 // The second retain and autorelease can be deleted.
 
-// TODO: It should be possible to delete
-// objc_autoreleasePoolPush and objc_autoreleasePoolPop
-// pairs if nothing is actually autoreleased between them. Also, autorelease
-// calls followed by objc_autoreleasePoolPop calls (perhaps in ObjC++ code
-// after inlining) can be turned into plain release calls.
+// TODO: Autorelease calls followed by objc_autoreleasePoolPop calls (perhaps 
in
+// ObjC++ code after inlining) can be turned into plain release calls.
 
 // TODO: Critical-edge splitting. If the optimial insertion point is
 // a critical edge, the current algorithm has to fail, because it doesn't
@@ -566,6 +564,8 @@ class ObjCARCOpt {
 
   void OptimizeReturns(Function &F);
 
+  void OptimizeAutoreleasePools(Function &F);
+
   template 
   static void cloneOpBundlesIf(CallBase *CI,
SmallVectorImpl &OpBundles,
@@ -2473,6 +2473,11 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
 (1 << unsigned(ARCInstKind::AutoreleaseRV
 OptimizeReturns(F);
 
+  // Optimizations for autorelease pools.
+  if (UsedInThisFunction & ((1 << unsigned(ARCInstKind::AutoreleasepoolPush)) |
+(1 << unsigned(ARCInstKind::AutoreleasepoolPop
+OptimizeAutoreleasePools(F);
+
   // Gather statistics after optimization.
 #ifndef NDEBUG
   if (AreStatisticsEnabled()) {
@@ -2485,6 +2490,114 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
   return Changed;
 }
 
+/// Optimize autorelease pools by eliminating empty push/pop pairs.
+void ObjCARCOpt::OptimizeAutoreleasePools(Function &F) {
+  LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::Optimiz

[clang] [llvm] [ObjCARC] Delete empty autoreleasepools with no autoreleases in them (PR #144788)

2025-06-19 Thread via cfe-commits

https://github.com/AZero13 updated 
https://github.com/llvm/llvm-project/pull/144788

>From 32b8b89591596f5ddf467c96311fc431656d6cd1 Mon Sep 17 00:00:00 2001
From: Rose 
Date: Wed, 18 Jun 2025 16:05:44 -0400
Subject: [PATCH 1/2] [ObjCARC] Delete empty autoreleasepools with no
 autoreleases in them

Erase empty autorelease pools that have no autorelease in them
---
 .../ObjCARC/ARCRuntimeEntryPoints.h   |  16 +++
 llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp   | 123 +-
 .../ObjCARC/test_autorelease_pool.ll  | 118 +
 3 files changed, 252 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/Transforms/ObjCARC/test_autorelease_pool.ll

diff --git a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h 
b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
index 3fa844eda21cf..6135c7b938a3e 100644
--- a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
+++ b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
@@ -46,6 +46,8 @@ enum class ARCRuntimeEntryPointKind {
   UnsafeClaimRV,
   RetainAutorelease,
   RetainAutoreleaseRV,
+  AutoreleasePoolPush,
+  AutoreleasePoolPop,
 };
 
 /// Declarations for ObjC runtime functions and constants. These are 
initialized
@@ -67,6 +69,8 @@ class ARCRuntimeEntryPoints {
 UnsafeClaimRV = nullptr;
 RetainAutorelease = nullptr;
 RetainAutoreleaseRV = nullptr;
+AutoreleasePoolPush = nullptr;
+AutoreleasePoolPop = nullptr;
   }
 
   Function *get(ARCRuntimeEntryPointKind kind) {
@@ -101,6 +105,12 @@ class ARCRuntimeEntryPoints {
 case ARCRuntimeEntryPointKind::RetainAutoreleaseRV:
   return getIntrinsicEntryPoint(RetainAutoreleaseRV,
 Intrinsic::objc_retainAutoreleaseReturnValue);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPush:
+  return getIntrinsicEntryPoint(AutoreleasePoolPush,
+Intrinsic::objc_autoreleasePoolPush);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPop:
+  return getIntrinsicEntryPoint(AutoreleasePoolPop,
+Intrinsic::objc_autoreleasePoolPop);
 }
 
 llvm_unreachable("Switch should be a covered switch.");
@@ -143,6 +153,12 @@ class ARCRuntimeEntryPoints {
   /// Declaration for objc_retainAutoreleaseReturnValue().
   Function *RetainAutoreleaseRV = nullptr;
 
+  /// Declaration for objc_autoreleasePoolPush().
+  Function *AutoreleasePoolPush = nullptr;
+
+  /// Declaration for objc_autoreleasePoolPop().
+  Function *AutoreleasePoolPop = nullptr;
+
   Function *getIntrinsicEntryPoint(Function *&Decl, Intrinsic::ID IntID) {
 if (Decl)
   return Decl;
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 5eb3f51d38945..deec643532c5d 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Analysis/ObjCARCAnalysisUtils.h"
 #include "llvm/Analysis/ObjCARCInstKind.h"
 #include "llvm/Analysis/ObjCARCUtil.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constant.h"
@@ -132,11 +133,8 @@ static const Value *FindSingleUseIdentifiedObject(const 
Value *Arg) {
 //
 // The second retain and autorelease can be deleted.
 
-// TODO: It should be possible to delete
-// objc_autoreleasePoolPush and objc_autoreleasePoolPop
-// pairs if nothing is actually autoreleased between them. Also, autorelease
-// calls followed by objc_autoreleasePoolPop calls (perhaps in ObjC++ code
-// after inlining) can be turned into plain release calls.
+// TODO: Autorelease calls followed by objc_autoreleasePoolPop calls (perhaps 
in
+// ObjC++ code after inlining) can be turned into plain release calls.
 
 // TODO: Critical-edge splitting. If the optimial insertion point is
 // a critical edge, the current algorithm has to fail, because it doesn't
@@ -566,6 +564,8 @@ class ObjCARCOpt {
 
   void OptimizeReturns(Function &F);
 
+  void OptimizeAutoreleasePools(Function &F);
+
   template 
   static void cloneOpBundlesIf(CallBase *CI,
SmallVectorImpl &OpBundles,
@@ -2473,6 +2473,11 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
 (1 << unsigned(ARCInstKind::AutoreleaseRV
 OptimizeReturns(F);
 
+  // Optimizations for autorelease pools.
+  if (UsedInThisFunction & ((1 << unsigned(ARCInstKind::AutoreleasepoolPush)) |
+(1 << unsigned(ARCInstKind::AutoreleasepoolPop
+OptimizeAutoreleasePools(F);
+
   // Gather statistics after optimization.
 #ifndef NDEBUG
   if (AreStatisticsEnabled()) {
@@ -2485,6 +2490,114 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
   return Changed;
 }
 
+/// Optimize autorelease pools by eliminating empty push/pop pairs.
+void ObjCARCOpt::OptimizeAutoreleasePools(Function &F) {
+  LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::Optimiz

[clang] dc058a3 - [TableGen] Use ListSeparator (NFC) (#144936)

2025-06-19 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-06-19T13:17:23-07:00
New Revision: dc058a3d84ed1bc4006416023e8b336f3214bdc7

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

LOG: [TableGen] Use ListSeparator (NFC) (#144936)

Note that an instance of ListSeparator evaluates to the empty string
for the first time and then ", " for subsequent references.

Added: 


Modified: 
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index f892626a447e5..dfeb6b1b1ec19 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -5482,14 +5482,12 @@ void EmitTestPragmaAttributeSupportedAttributes(const 
RecordKeeper &Records,
 }
 const Record *SubjectObj = I.second->getValueAsDef("Subjects");
 OS << " (";
-bool PrintComma = false;
+ListSeparator LS;
 for (const auto &Subject :
  enumerate(SubjectObj->getValueAsListOfDefs("Subjects"))) {
   if (!isSupportedPragmaClangAttributeSubject(*Subject.value()))
 continue;
-  if (PrintComma)
-OS << ", ";
-  PrintComma = true;
+  OS << LS;
   PragmaClangAttributeSupport::RuleOrAggregateRuleSet &RuleSet =
   Support.SubjectsToRules.find(Subject.value())->getSecond();
   if (RuleSet.isRule()) {

diff  --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index bfc60f485cd32..b28cb2c09ac5c 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -2225,13 +2225,10 @@ void clang::EmitClangDiagDocs(const RecordKeeper 
&Records, raw_ostream &OS) {
   else
 OS << "Also controls ";
 
-  bool First = true;
   sort(GroupInfo.SubGroups);
-  for (StringRef Name : GroupInfo.SubGroups) {
-if (!First) OS << ", ";
-OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
-First = false;
-  }
+  ListSeparator LS;
+  for (StringRef Name : GroupInfo.SubGroups)
+OS << LS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
   OS << ".\n\n";
 }
 



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


[clang] [TableGen] Use ListSeparator (NFC) (PR #144936)

2025-06-19 Thread Kazu Hirata via cfe-commits

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


[clang] [llvm] [ObjCARC] Delete empty autoreleasepools with no autoreleases in them (PR #144788)

2025-06-19 Thread via cfe-commits

https://github.com/AZero13 updated 
https://github.com/llvm/llvm-project/pull/144788

>From dcf0054fbfecdf0bede93de8fe526ac2ecfc246b Mon Sep 17 00:00:00 2001
From: Rose 
Date: Wed, 18 Jun 2025 16:05:44 -0400
Subject: [PATCH 1/2] [ObjCARC] Delete empty autoreleasepools with no
 autoreleases in them

Erase empty autorelease pools that have no autorelease in them
---
 .../ObjCARC/ARCRuntimeEntryPoints.h   |  16 +++
 llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp   | 123 +-
 .../ObjCARC/test_autorelease_pool.ll  | 118 +
 3 files changed, 252 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/Transforms/ObjCARC/test_autorelease_pool.ll

diff --git a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h 
b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
index 3fa844eda21cf..6135c7b938a3e 100644
--- a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
+++ b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
@@ -46,6 +46,8 @@ enum class ARCRuntimeEntryPointKind {
   UnsafeClaimRV,
   RetainAutorelease,
   RetainAutoreleaseRV,
+  AutoreleasePoolPush,
+  AutoreleasePoolPop,
 };
 
 /// Declarations for ObjC runtime functions and constants. These are 
initialized
@@ -67,6 +69,8 @@ class ARCRuntimeEntryPoints {
 UnsafeClaimRV = nullptr;
 RetainAutorelease = nullptr;
 RetainAutoreleaseRV = nullptr;
+AutoreleasePoolPush = nullptr;
+AutoreleasePoolPop = nullptr;
   }
 
   Function *get(ARCRuntimeEntryPointKind kind) {
@@ -101,6 +105,12 @@ class ARCRuntimeEntryPoints {
 case ARCRuntimeEntryPointKind::RetainAutoreleaseRV:
   return getIntrinsicEntryPoint(RetainAutoreleaseRV,
 Intrinsic::objc_retainAutoreleaseReturnValue);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPush:
+  return getIntrinsicEntryPoint(AutoreleasePoolPush,
+Intrinsic::objc_autoreleasePoolPush);
+case ARCRuntimeEntryPointKind::AutoreleasePoolPop:
+  return getIntrinsicEntryPoint(AutoreleasePoolPop,
+Intrinsic::objc_autoreleasePoolPop);
 }
 
 llvm_unreachable("Switch should be a covered switch.");
@@ -143,6 +153,12 @@ class ARCRuntimeEntryPoints {
   /// Declaration for objc_retainAutoreleaseReturnValue().
   Function *RetainAutoreleaseRV = nullptr;
 
+  /// Declaration for objc_autoreleasePoolPush().
+  Function *AutoreleasePoolPush = nullptr;
+
+  /// Declaration for objc_autoreleasePoolPop().
+  Function *AutoreleasePoolPop = nullptr;
+
   Function *getIntrinsicEntryPoint(Function *&Decl, Intrinsic::ID IntID) {
 if (Decl)
   return Decl;
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 5eb3f51d38945..deec643532c5d 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Analysis/ObjCARCAnalysisUtils.h"
 #include "llvm/Analysis/ObjCARCInstKind.h"
 #include "llvm/Analysis/ObjCARCUtil.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constant.h"
@@ -132,11 +133,8 @@ static const Value *FindSingleUseIdentifiedObject(const 
Value *Arg) {
 //
 // The second retain and autorelease can be deleted.
 
-// TODO: It should be possible to delete
-// objc_autoreleasePoolPush and objc_autoreleasePoolPop
-// pairs if nothing is actually autoreleased between them. Also, autorelease
-// calls followed by objc_autoreleasePoolPop calls (perhaps in ObjC++ code
-// after inlining) can be turned into plain release calls.
+// TODO: Autorelease calls followed by objc_autoreleasePoolPop calls (perhaps 
in
+// ObjC++ code after inlining) can be turned into plain release calls.
 
 // TODO: Critical-edge splitting. If the optimial insertion point is
 // a critical edge, the current algorithm has to fail, because it doesn't
@@ -566,6 +564,8 @@ class ObjCARCOpt {
 
   void OptimizeReturns(Function &F);
 
+  void OptimizeAutoreleasePools(Function &F);
+
   template 
   static void cloneOpBundlesIf(CallBase *CI,
SmallVectorImpl &OpBundles,
@@ -2473,6 +2473,11 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
 (1 << unsigned(ARCInstKind::AutoreleaseRV
 OptimizeReturns(F);
 
+  // Optimizations for autorelease pools.
+  if (UsedInThisFunction & ((1 << unsigned(ARCInstKind::AutoreleasepoolPush)) |
+(1 << unsigned(ARCInstKind::AutoreleasepoolPop
+OptimizeAutoreleasePools(F);
+
   // Gather statistics after optimization.
 #ifndef NDEBUG
   if (AreStatisticsEnabled()) {
@@ -2485,6 +2490,114 @@ bool ObjCARCOpt::run(Function &F, AAResults &AA) {
   return Changed;
 }
 
+/// Optimize autorelease pools by eliminating empty push/pop pairs.
+void ObjCARCOpt::OptimizeAutoreleasePools(Function &F) {
+  LLVM_DEBUG(dbgs() << "\n== ObjCARCOpt::Optimiz

[libclc] [libclc] Declare workitem built-ins in clc, move ptx-nvidiacl workitem built-ins into clc (PR #144333)

2025-06-19 Thread Wenju He via cfe-commits

wenju-he wrote:

> Is an issue here perhaps that downstream users may have implemented (e.g.) 
> `get_global_offset` in their toolchains, but after this change they'll 
> suddenly see a definition of this function that they're not expecting?
> 
> I suppose they would have to implement CLC functions, like 
> `__clc_get_global_offset` to work with this approach. Or they could have 
> their libclc target not call into `__clc_get_global_offset`, or just not 
> provide a definition of `get_global_offset` as before. Either way this has 
> the potential to be a breaking change.
> 
> I'm not sure about leaving dangling CLC declarations in OpenCL libraries. It 
> feels like an implementation detail we're exposing to users.

thanks @frasercrmck. As to get_work_dim and above mentioned get_global_offset, 
I see there are amdgpu implementations 
https://github.com/llvm/llvm-project/blob/main/libclc/opencl/lib/amdgcn/workitem/get_global_offset.cl
 and 
https://github.com/llvm/llvm-project/blob/main/libclc/opencl/lib/r600/workitem/get_global_offset.cl.
 Moving them into clc should resolve the concern, but I don't know where is 
destination directory in clc. I don't know how to map `opencl/lib/amdgcn` and 
`opencl/lib/r600` to `clc/lib/amdgcn` and `clc/lib/amdgpu`. Do you have 
suggestions about the mapping?

As to clc_get_enqueued_num_sub_groups and clc_get_enqueued_local_size that 
there is definition in this repo, I'll delete them from this PR. The motivation 
of adding them in the first commit is to avoid adding them in the downstream 
only since they are shared code.

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


[clang] [clang][analyzer] Correctly handle lambda-converted function pointers (PR #144906)

2025-06-19 Thread via cfe-commits

flovent wrote:

> The same occurs with assigning to `auto`: https://godbolt.org/z/nofG6cehf
> 
> Will this also be handled by this change?

If you mean directly calling this lambda, analyzer can already analyze 
`operator()` correctly before this patch, because neither `CXXConversionDecl` 
and `__invoke` is used here.

This patch fix the situation like this: https://godbolt.org/z/4YWPP6939
```
void f()
{
auto f = []() { return 0; };
int (*ptr)() = f;
1 / ptr();
}
```
lambda `f` should be called and produce divzero.

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


[clang] 5cbed34 - [X86] Remove CLDEMOTE from Arrowlake and later hybrid processors (#144833)

2025-06-19 Thread via cfe-commits

Author: Phoebe Wang
Date: 2025-06-20T08:57:37+08:00
New Revision: 5cbed34404a3862c2d7f18e4b4b24f5ce1516a8d

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

LOG: [X86] Remove CLDEMOTE from Arrowlake and later hybrid processors (#144833)

Decouple Arrowlake from Sierraforest because the later has CLDEMOTE
feature.

Added: 


Modified: 
clang/test/Preprocessor/predefined-arch-macros.c
llvm/lib/Target/X86/X86.td
llvm/lib/TargetParser/X86TargetParser.cpp

Removed: 




diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 9dfeddbd4d5ac..86d51820ae5b5 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2556,209 +2556,211 @@
 
 // RUN: %clang -march=sierraforest -m32 -E -dM %s -o - 2>&1 \
 // RUN: --target=i386 \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SRF_M32
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_ARL_M32,CHECK_SRF_M32
 // RUN: %clang -march=grandridge -m32 -E -dM %s -o - 2>&1 \
 // RUN: --target=i386 \
-// RUN:   | FileCheck -match-full-lines %s -check-prefixes=CHECK_SRF_M32
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_ARL_M32,CHECK_SRF_M32
 // RUN: %clang -march=arrowlake -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SRF_M32
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_ARL_M32
 // RUN: %clang -march=arrowlake-s -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_SRF_M32,CHECK_ARLS_M32
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_ARL_M32,CHECK_ARLS_M32
 // RUN: %clang -march=lunarlake -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_SRF_M32,CHECK_ARLS_M32
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_ARL_M32,CHECK_ARLS_M32
 // RUN: %clang -march=pantherlake -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_SRF_M32,CHECK_ARLS_M32,CHECK_PTL_M32
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_ARL_M32,CHECK_ARLS_M32,CHECK_PTL_M32
 // RUN: %clang -march=clearwaterforest -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_SRF_M32,CHECK_ARLS_M32,CHECK_PTL_M32,CHECK_CWF_M32
-// CHECK_SRF_M32: #define __ADX__ 1
-// CHECK_SRF_M32: #define __AES__ 1
-// CHECK_SRF_M32: #define __AVX2__ 1
-// CHECK_SRF_M32-NOT: AVX512
-// CHECK_SRF_M32: #define __AVXIFMA__ 1
-// CHECK_SRF_M32: #define __AVXNECONVERT__ 1
-// CHECK_SRF_M32-NOT: #define __AVXVNNIINT16__ 1
+// CHECK_ARL_M32: #define __ADX__ 1
+// CHECK_ARL_M32: #define __AES__ 1
+// CHECK_ARL_M32: #define __AVX2__ 1
+// CHECK_ARL_M32-NOT: AVX512
+// CHECK_ARL_M32: #define __AVXIFMA__ 1
+// CHECK_ARL_M32: #define __AVXNECONVERT__ 1
+// CHECK_ARL_M32-NOT: #define __AVXVNNIINT16__ 1
 // CHECK_ARLS_M32: #define __AVXVNNIINT16__ 1
-// CHECK_SRF_M32: #define __AVXVNNIINT8__ 1
-// CHECK_SRF_M32: #define __AVXVNNI__ 1
-// CHECK_SRF_M32: #define __AVX__ 1
-// CHECK_SRF_M32: #define __BMI2__ 1
-// CHECK_SRF_M32: #define __BMI__ 1
+// CHECK_ARL_M32: #define __AVXVNNIINT8__ 1
+// CHECK_ARL_M32: #define __AVXVNNI__ 1
+// CHECK_ARL_M32: #define __AVX__ 1
+// CHECK_ARL_M32: #define __BMI2__ 1
+// CHECK_ARL_M32: #define __BMI__ 1
+// CHECK_ARLS_M32-NOT: __CLDEMOTE__
 // CHECK_SRF_M32: #define __CLDEMOTE__ 1
-// CHECK_SRF_M32: #define __CLFLUSHOPT__ 1
-// CHECK_SRF_M32: #define __CLWB__ 1
-// CHECK_SRF_M32: #define __CMPCCXADD__ 1
-// CHECK_SRF_M32: #define __ENQCMD__ 1
-// CHECK_SRF_M32: #define __F16C__ 1
-// CHECK_SRF_M32: #define __FMA__ 1
-// CHECK_SRF_M32: #define __FSGSBASE__ 1
-// CHECK_SRF_M32: #define __FXSR__ 1
-// CHECK_SRF_M32: #define __GFNI__ 1
-// CHECK_SRF_M32: #define __HRESET__ 1
-// CHECK_SRF_M32: #define __INVPCID__ 1
-// CHECK_SRF_M32: #define __KL__ 1
-// CHECK_SRF_M32: #define __LZCNT__ 1
-// CHECK_SRF_M32: #define __MMX__ 1
-// CHECK_SRF_M32: #define __MOVBE__ 1
-// CHECK_SRF_M32: #define __MOVDIR64B__ 1
-// CHECK_SRF_M32: #define __MOVDIRI__ 1
-// CHECK_SRF_M32: #define __PCLMUL__ 1
-// CHECK_SRF_M32: #define __PCONFIG__ 1
-// CHECK_SRF_M32: #define __PKU__ 1
-// CHECK_SRF_M32: #define __POPCNT__ 1
-// CHECK_SRF_M32-NOT: #define __PREFETCHI__ 1
+// CHECK_ARL_M32: #define __CLFLUSHOPT__ 1
+// CHECK_ARL_M32: #define __CLWB__ 1
+// CHECK_ARL_M32: #define __CMPCCXADD__ 1
+// CHECK_ARL_M32: #define __ENQCMD__ 1
+// CHECK_AR

  1   2   3   >