https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/221291

>From e3116fa653a9dac54d2a58932130f2ec2d175c0c Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Fri, 4 Sep 2026 09:23:26 -0700
Subject: [PATCH 1/7] Enable ClangIR Build By Default-

This is subject to an RFC:

https://discourse.llvm.org/t/rfc-enable-clangir-build-by-default/91730

This patch enables building ClangIR (and thus MLIR) by default in clang
builds.  The project has hit a maturity level where we believe this is
a good time to do it.  See the RFC for details.
---
 clang/CMakeLists.txt       |  6 ++----
 clang/docs/ReleaseNotes.md |  5 +++++
 llvm/CMakeLists.txt        | 11 +++++++++++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index fc71cf45dbb34..3416e67eb7991 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -190,15 +190,13 @@ if(CLANG_ENABLE_LIBXML2)
   endif()
 endif()
 
+cmake_dependent_option(CLANG_ENABLE_CIR "Build ClangIR support into the 
compiler" ON "NOT CLANG_BUILT_STANDALONE" OFF)
+
 if(CLANG_ENABLE_CIR)
   if (CLANG_BUILT_STANDALONE)
     message(FATAL_ERROR
       "ClangIR is not yet supported in the standalone build.")
   endif()
-  if (NOT "${LLVM_ENABLE_PROJECTS}" MATCHES "MLIR|mlir")
-    message(FATAL_ERROR
-      "Cannot build ClangIR without MLIR in LLVM_ENABLE_PROJECTS")
-  endif()
 endif()
 
 include(CheckIncludeFile)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index ca5c63fbaa17d..ce458ce2e0ecc 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -837,6 +837,11 @@ The `alpha.cplusplus.UseAfterLifetimeEnd` checker was 
renamed to `alpha.core.Use
 
 #### Improvements
 
+### Clang IR Improvements
+
+- Clang IR has now been enabled in builds by default, and should work with 
most workloads. However this is still an experimental flag and a 
work-in-progress.
+
+
 ## Additional Information
 
 A wide variety of additional information is available on the [Clang web
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 44299d51d784a..7f0e8fc7a9915 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -201,6 +201,17 @@ if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
   endif ()
 endif()
 
+# Clang defaults to CLANG_ENABLE_CIR now, so we need to auto-add MLIR unless it
+# was explicitly disabled.
+if ("clang" IN_LIST LLVM_ENABLE_PROJECTS)
+  if (NOT DEFINED CLANG_ENABLE_CIR OR CLANG_ENABLE_CIR)
+    if (NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS)
+      message(STATUS "Enabling MLIR as a dependency of ClangIR")
+      list(APPEND LLVM_ENABLE_PROJECTS "mlir")
+    endif()
+  endif()
+endif()
+
 if ("lldb" IN_LIST LLVM_ENABLE_PROJECTS)
   if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS)
     message(STATUS "Enabling clang as a dependency of lldb")

>From 33e5ee57b3112cd62890b36419c22156ec338247 Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Mon, 14 Sep 2026 10:21:37 -0700
Subject: [PATCH 2/7] Add to release-notes-template, plus clarify release notes

---
 clang/docs/ReleaseNotes.md          | 2 +-
 clang/docs/ReleaseNotesTemplate.txt | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index cbe99b9a22b60..21d3be7313dcd 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -908,7 +908,7 @@ The `alpha.cplusplus.UseAfterLifetimeEnd` checker was 
renamed to `alpha.core.Use
 
 ### Clang IR Improvements
 
-- Clang IR has now been enabled in builds by default, and should work with 
most workloads. However this is still an experimental flag and a 
work-in-progress.
+- Clang builds now build Clang IR support by default. Clang IR is expected to 
work with most Linux/X86-64 workloads. Normal builds are unchanged, however 
those who wish to test out the experimental `-fclangir` flag can now do so with 
a Clang build.
 
 
 ## Additional Information
diff --git a/clang/docs/ReleaseNotesTemplate.txt 
b/clang/docs/ReleaseNotesTemplate.txt
index df98f9adc0338..b7920ab029d0e 100644
--- a/clang/docs/ReleaseNotesTemplate.txt
+++ b/clang/docs/ReleaseNotesTemplate.txt
@@ -193,6 +193,8 @@ latest release, please see the [Clang Web 
Site](https://clang.llvm.org) or the
 
 #### Improvements
 
+### Clang IR Improvements
+
 ## Additional Information
 
 A wide variety of additional information is available on the [Clang web

>From d6344487005c162f41859312b2be59dd5c412b86 Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Thu, 8 Oct 2026 13:59:35 -0700
Subject: [PATCH 3/7] add triple to test that failed due to lack of windows ABI

---
 clang/test/Driver/openacc-no-cir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/openacc-no-cir.c 
b/clang/test/Driver/openacc-no-cir.c
index 891f175a001bb..15d357330c582 100644
--- a/clang/test/Driver/openacc-no-cir.c
+++ b/clang/test/Driver/openacc-no-cir.c
@@ -1,6 +1,6 @@
 // RUN: %clang -fopenacc -S %s -o /dev/null 2>&1 | FileCheck %s 
-check-prefix=ERROR
-// RUN: %clang -fclangir -fopenacc -S %s -o /dev/null 2>&1 | FileCheck %s 
--allow-empty -check-prefix=NOERROR
-// RUN: %clang -fopenacc -fclangir -S %s -o /dev/null 2>&1 | FileCheck %s 
--allow-empty -check-prefix=NOERROR
+// RUN: %clang -fclangir -fopenacc -S -triple x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
+// RUN: %clang -fopenacc -fclangir -S -triple x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
 
 // ERROR: OpenACC directives will result in no runtime behavior; use -fclangir 
to enable runtime effect
 // NOERROR-NOT: OpenACC directives

>From c4729e4274060a2c3f08ccc536cff8510703f4d5 Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Thu, 8 Oct 2026 15:24:16 -0700
Subject: [PATCH 4/7] Fixup review comments frm Bruno

---
 clang/CMakeLists.txt               | 12 +++++++++++-
 clang/docs/ReleaseNotes.md         |  2 +-
 clang/test/Driver/openacc-no-cir.c |  4 ++--
 llvm/CMakeLists.txt                | 11 -----------
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 95ead02ddb9ce..4b9015542b400 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -190,7 +190,17 @@ if(CLANG_ENABLE_LIBXML2)
   endif()
 endif()
 
-cmake_dependent_option(CLANG_ENABLE_CIR "Build ClangIR support into the 
compiler" ON "NOT CLANG_BUILT_STANDALONE" OFF)
+# ClangIR is on by default, except in standalone builds where it is 
unsupported.
+# Use a plain option (rather than cmake_dependent_option) so an explicit
+# -DCLANG_ENABLE_CIR=ON in a standalone build reaches the error below instead 
of
+# being silently forced to OFF.
+if(CLANG_BUILT_STANDALONE)
+  set(CLANG_ENABLE_CIR_DEFAULT OFF)
+else()
+  set(CLANG_ENABLE_CIR_DEFAULT ON)
+endif()
+option(CLANG_ENABLE_CIR "Build ClangIR support into the compiler"
+       ${CLANG_ENABLE_CIR_DEFAULT})
 
 if(CLANG_ENABLE_CIR)
   if (CLANG_BUILT_STANDALONE)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 444e87f248514..07a78193b391e 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -1209,7 +1209,7 @@ The `alpha.cplusplus.UseAfterLifetimeEnd` checker was 
renamed to `alpha.core.Use
 
 ### Clang IR Improvements
 
-- Clang builds now build Clang IR support by default. Clang IR is expected to 
work with most Linux/X86-64 workloads. Normal builds are unchanged, however 
those who wish to test out the experimental `-fclangir` flag can now do so with 
a Clang build.
+- Clang builds now build ClangIR support by default. Clang IR is expected to 
work with most Linux/X86-64 workloads. Normal builds are unchanged, however 
those who wish to test out the experimental `-fclangir` flag can now do so with 
a Clang build.
 
 
 ## Additional Information
diff --git a/clang/test/Driver/openacc-no-cir.c 
b/clang/test/Driver/openacc-no-cir.c
index 15d357330c582..ddf1bf6d97c3f 100644
--- a/clang/test/Driver/openacc-no-cir.c
+++ b/clang/test/Driver/openacc-no-cir.c
@@ -1,6 +1,6 @@
 // RUN: %clang -fopenacc -S %s -o /dev/null 2>&1 | FileCheck %s 
-check-prefix=ERROR
-// RUN: %clang -fclangir -fopenacc -S -triple x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
-// RUN: %clang -fopenacc -fclangir -S -triple x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
+// RUN: %clang -fclangir -fopenacc -S -target=x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
+// RUN: %clang -fopenacc -fclangir -S -target=x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
 
 // ERROR: OpenACC directives will result in no runtime behavior; use -fclangir 
to enable runtime effect
 // NOERROR-NOT: OpenACC directives
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 33443f89a3ef4..28e96fc28b5aa 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -212,17 +212,6 @@ if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
   endif ()
 endif()
 
-# Clang defaults to CLANG_ENABLE_CIR now, so we need to auto-add MLIR unless it
-# was explicitly disabled.
-if ("clang" IN_LIST LLVM_ENABLE_PROJECTS)
-  if (NOT DEFINED CLANG_ENABLE_CIR OR CLANG_ENABLE_CIR)
-    if (NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS)
-      message(STATUS "Enabling MLIR as a dependency of ClangIR")
-      list(APPEND LLVM_ENABLE_PROJECTS "mlir")
-    endif()
-  endif()
-endif()
-
 if ("lldb" IN_LIST LLVM_ENABLE_PROJECTS)
   if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS)
     message(STATUS "Enabling clang as a dependency of lldb")

>From 0a8188f07ab65241c478b43f68e0a99a55227221 Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Fri, 9 Oct 2026 07:06:08 -0700
Subject: [PATCH 5/7] Move around the ENABLE_CIR_DEFAULT flag to before the
 MLIR dependencies are set so that we get the build right... I hope?

---
 clang/CMakeLists.txt | 12 +++---------
 llvm/CMakeLists.txt  |  1 +
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 4b9015542b400..a516c7a72ff06 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -190,17 +190,11 @@ if(CLANG_ENABLE_LIBXML2)
   endif()
 endif()
 
-# ClangIR is on by default, except in standalone builds where it is 
unsupported.
-# Use a plain option (rather than cmake_dependent_option) so an explicit
-# -DCLANG_ENABLE_CIR=ON in a standalone build reaches the error below instead 
of
-# being silently forced to OFF.
+# Standalone builds don't inherit this flag from the llvm/CMakeLists, so set it
+# here.
 if(CLANG_BUILT_STANDALONE)
-  set(CLANG_ENABLE_CIR_DEFAULT OFF)
-else()
-  set(CLANG_ENABLE_CIR_DEFAULT ON)
+  option(CLANG_ENABLE_CIR "Build ClangIR support into the compiler" OFF)
 endif()
-option(CLANG_ENABLE_CIR "Build ClangIR support into the compiler"
-       ${CLANG_ENABLE_CIR_DEFAULT})
 
 if(CLANG_ENABLE_CIR)
   if (CLANG_BUILT_STANDALONE)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 28e96fc28b5aa..2e45b9d8a5e60 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -219,6 +219,7 @@ if ("lldb" IN_LIST LLVM_ENABLE_PROJECTS)
   endif()
 endif ()
 
+option(CLANG_ENABLE_CIR "Build ClangIR support into the compiler" ON)
 if (CLANG_ENABLE_CIR AND "clang" IN_LIST LLVM_ENABLE_PROJECTS AND
     NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS)
   message(STATUS "Enabling MLIR as a dependency of ClangIR")

>From 0fbe7d2201f0e472ba23674bdb0fee78ccb95087 Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Fri, 9 Oct 2026 07:13:48 -0700
Subject: [PATCH 6/7] Update release note to add additional information at the
 'top' as suggested

---
 clang/docs/ReleaseNotes.md | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 07a78193b391e..d65feb68f5ac9 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -48,6 +48,13 @@ The previous behavior can be restored with 
`-Wno-error=unicode-whitespace`.
 Clang will stop accepting non-ascii whitespaces as token separators
 in a future version of Clang.
 
+- The experimental ClangIR code generator is now built into Clang by default, 
so
+`-fclangir` can be used without any additional CMake options. While ClangIR 
will
+work for many workloads in some narrow configurations (ie, Itanium only), it
+should prove useful for MLIR experimentation in Clang. This does however have a
+measureable and significant impact on the build-time of clang itself. It can be
+disabled with the CMake option `-DCLANG_ENABLE_CIR=Off`.
+
 ### C++ Specific Potentially Breaking Changes
 
 - The `[[carries_dependency]]` attribute is no longer recognized, in any 
language

>From 4d717d7a36795affbc08bd89ae1a9ae17ab5aeda Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Fri, 9 Oct 2026 07:26:32 -0700
Subject: [PATCH 7/7] Fix to be --target vs -target in the openacc-cir test

---
 clang/test/Driver/openacc-no-cir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/openacc-no-cir.c 
b/clang/test/Driver/openacc-no-cir.c
index ddf1bf6d97c3f..9f1a66204261f 100644
--- a/clang/test/Driver/openacc-no-cir.c
+++ b/clang/test/Driver/openacc-no-cir.c
@@ -1,6 +1,6 @@
 // RUN: %clang -fopenacc -S %s -o /dev/null 2>&1 | FileCheck %s 
-check-prefix=ERROR
-// RUN: %clang -fclangir -fopenacc -S -target=x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
-// RUN: %clang -fopenacc -fclangir -S -target=x86_64-linux-gnu %s -o /dev/null 
2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
+// RUN: %clang -fclangir -fopenacc -S --target=x86_64-linux-gnu %s -o 
/dev/null 2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
+// RUN: %clang -fopenacc -fclangir -S --target=x86_64-linux-gnu %s -o 
/dev/null 2>&1 | FileCheck %s --allow-empty -check-prefix=NOERROR
 
 // ERROR: OpenACC directives will result in no runtime behavior; use -fclangir 
to enable runtime effect
 // NOERROR-NOT: OpenACC directives

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to