https://github.com/Priyanshu3820 updated 
https://github.com/llvm/llvm-project/pull/171615

>From ea26e94f1ab429798860705ddd65d4e8f58c4103 Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Wed, 10 Dec 2025 18:34:52 +0530
Subject: [PATCH 01/10] Implement convert_half builtin

---
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp    | 41 +++++++--
 .../CodeGenBuiltins/X86/cir-convert-half.c    | 84 +++++++++++++++++++
 2 files changed, 119 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c

diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index f9e1f75a51143..852a7b9299e96 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -1662,12 +1662,41 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, 
const CallExpr *expr) {
   case X86::BI__builtin_ia32_cmpnltsd:
   case X86::BI__builtin_ia32_cmpnlesd:
   case X86::BI__builtin_ia32_cmpordsd:
-  case X86::BI__builtin_ia32_vcvtph2ps_mask:
-  case X86::BI__builtin_ia32_vcvtph2ps256_mask:
-  case X86::BI__builtin_ia32_vcvtph2ps512_mask:
-  case X86::BI__builtin_ia32_cvtneps2bf16_128_mask:
-  case X86::BI__builtin_ia32_cvtneps2bf16_256_mask:
-  case X86::BI__builtin_ia32_cvtneps2bf16_512_mask:
+    cgm.errorNYI(expr->getSourceRange(),
+                 std::string("unimplemented X86 builtin call: ") +
+                     getContext().BuiltinInfo.getName(builtinID));
+    return {};
+  case X86::BI__builtin_ia32_vcvtph2ps_mask: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+    return emitIntrinsicCallOp(builder, loc, "x86.avx512.mask.vcvtph2ps.128",
+                               convertType(expr->getType()), ops);
+  }
+  case X86::BI__builtin_ia32_vcvtph2ps256_mask: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+    return emitIntrinsicCallOp(builder, loc, "x86.avx512.mask.vcvtph2ps.256",
+                               convertType(expr->getType()), ops);
+  }
+  case X86::BI__builtin_ia32_vcvtph2ps512_mask: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+    return emitIntrinsicCallOp(builder, loc, "x86.avx512.mask.vcvtph2ps.512",
+                               convertType(expr->getType()), ops);
+  }
+  case X86::BI__builtin_ia32_cvtneps2bf16_128_mask: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+    return emitIntrinsicCallOp(builder, loc,
+                               "x86.avx512bf16.mask.cvtneps2bf16.128",
+                               convertType(expr->getType()), ops);
+  }
+  case X86::BI__builtin_ia32_cvtneps2bf16_256_mask: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+    return emitIntrinsicCallOp(builder, loc, "x86.avx512bf16.cvtneps2bf16.256",
+                               convertType(expr->getType()), ops);
+  }
+  case X86::BI__builtin_ia32_cvtneps2bf16_512_mask: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+    return emitIntrinsicCallOp(builder, loc, "x86.avx512bf16.cvtneps2bf16.512",
+                               convertType(expr->getType()), ops);
+  }
   case X86::BI__cpuid:
   case X86::BI__cpuidex:
   case X86::BI__emul:
diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c 
b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
new file mode 100644
index 0000000000000..8c6837a2e4e4a
--- /dev/null
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
@@ -0,0 +1,84 @@
+// Test X86-specific convert_half builtins
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
+
+typedef float __m512 __attribute__((__vector_size__(64), __aligned__(64)));
+typedef float __m256 __attribute__((__vector_size__(32), __aligned__(32)));
+typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
+typedef int __m256i __attribute__((__vector_size__(32), __aligned__(32)));
+typedef int __m128i __attribute__((__vector_size__(16), __aligned__(16)));
+typedef int __mmask16;
+typedef unsigned char __mmask8;
+typedef __bf16 __m256bh __attribute__((__vector_size__(32), __aligned__(32)));
+typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
+
+// Test __builtin_ia32_vcvtph2ps512_mask
+__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k) {
+  return __builtin_ia32_vcvtph2ps512_mask(a, src, k);
+}
+// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps512_mask
+// CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.512
+// LLVM-LABEL: define {{.*}} @test_vcvtph2ps512_mask
+// LLVM: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
+// OGCG-LABEL: define {{.*}} @test_vcvtph2ps512_mask
+// OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
+
+// Test __builtin_ia32_vcvtph2ps256_mask
+__m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k) {
+  return __builtin_ia32_vcvtph2ps256_mask(a, src, k);
+}
+// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps256_mask
+// CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.256
+// LLVM-LABEL: define {{.*}} @test_vcvtph2ps256_mask
+// LLVM: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
+// OGCG-LABEL: define {{.*}} @test_vcvtph2ps256_mask
+// OGCG: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
+
+// Test __builtin_ia32_vcvtph2ps_mask
+__m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) {
+  return __builtin_ia32_vcvtph2ps_mask(a, src, k);
+}
+// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps_mask
+// CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.128
+// LLVM-LABEL: define {{.*}} @test_vcvtph2ps_mask
+// LLVM: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
+// OGCG-LABEL: define {{.*}} @test_vcvtph2ps_mask
+// OGCG: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
+
+// Test __builtin_ia32_cvtneps2bf16_512_mask
+__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u) {
+  return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u);
+}
+// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_512_mask
+// CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.512
+// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
+// LLVM: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
+// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
+// OGCG: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
+
+// Test __builtin_ia32_cvtneps2bf16_256_mask
+__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u) {
+  return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u);
+}
+// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_256_mask
+// CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.256
+// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
+// LLVM: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
+// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
+// OGCG: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
+
+// Test __builtin_ia32_cvtneps2bf16_128_mask
+__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u) {
+  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u);
+}
+// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_128_mask
+// CIR: cir.call @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
+// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
+// LLVM: call <8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
+// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
+// OGCG: call <8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
\ No newline at end of file

>From 342dc426223a3c70ebee91a35cff4e7f75972991 Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Thu, 11 Dec 2025 00:55:19 +0530
Subject: [PATCH 02/10] Update
 clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c

---
 .../CodeGenBuiltins/X86/cir-convert-half.c    | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c 
b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
index 8c6837a2e4e4a..9f4571cc49d09 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
@@ -18,8 +18,8 @@ typedef __bf16 __m256bh __attribute__((__vector_size__(32), 
__aligned__(32)));
 typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
 
 // Test __builtin_ia32_vcvtph2ps512_mask
-__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k) {
-  return __builtin_ia32_vcvtph2ps512_mask(a, src, k);
+__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k, __m512 
passthru) {
+  return __builtin_ia32_vcvtph2ps512_mask(a, src, k, passthru);
 }
 // CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps512_mask
 // CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.512
@@ -29,8 +29,8 @@ __m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, 
__mmask16 k) {
 // OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
 
 // Test __builtin_ia32_vcvtph2ps256_mask
-__m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k) {
-  return __builtin_ia32_vcvtph2ps256_mask(a, src, k);
+__m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k, __m256 
passthru) {
+  return __builtin_ia32_vcvtph2ps256_mask(a, src, k, passthru);
 }
 // CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps256_mask
 // CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.256
@@ -40,8 +40,8 @@ __m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 
k) {
 // OGCG: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
 
 // Test __builtin_ia32_vcvtph2ps_mask
-__m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) {
-  return __builtin_ia32_vcvtph2ps_mask(a, src, k);
+__m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k, __m128 passthru) 
{
+  return __builtin_ia32_vcvtph2ps_mask(a, src, k, passthru);
 }
 // CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps_mask
 // CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.128
@@ -51,8 +51,8 @@ __m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) 
{
 // OGCG: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
 
 // Test __builtin_ia32_cvtneps2bf16_512_mask
-__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u) {
-  return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u);
+__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u, 
__m256bh passthru) {
+  return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u, passthru);
 }
 // CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_512_mask
 // CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.512
@@ -62,8 +62,8 @@ __m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, 
__mmask16 u) {
 // OGCG: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
 
 // Test __builtin_ia32_cvtneps2bf16_256_mask
-__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u) {
-  return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u);
+__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u, __m128bh 
passthru) {
+  return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u, passthru);
 }
 // CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_256_mask
 // CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.256
@@ -73,8 +73,8 @@ __m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, 
__mmask8 u) {
 // OGCG: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
 
 // Test __builtin_ia32_cvtneps2bf16_128_mask
-__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u) {
-  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u);
+__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u, __m128bh 
passthru) {
+  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u, passthru);
 }
 // CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_128_mask
 // CIR: cir.call @llvm.x86.avx512bf16.mask.cvtneps2bf16.128

>From 0b40cb83ab0f4cb23872d95f69cfa1f4138ed123 Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Thu, 11 Dec 2025 01:15:13 +0530
Subject: [PATCH 03/10] Update test and fix formatting

---
 .../CIR/CodeGenBuiltins/X86/cir-convert-half.c   | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c 
b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
index 9f4571cc49d09..e9c2404f48df6 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
@@ -40,8 +40,8 @@ __m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 
k, __m256 passthru
 // OGCG: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
 
 // Test __builtin_ia32_vcvtph2ps_mask
-__m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k, __m128 passthru) 
{
-  return __builtin_ia32_vcvtph2ps_mask(a, src, k, passthru);
+__m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) {
+  return __builtin_ia32_vcvtph2ps_mask(a, src, k);
 }
 // CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps_mask
 // CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.128
@@ -51,8 +51,8 @@ __m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k, 
__m128 passthru) {
 // OGCG: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
 
 // Test __builtin_ia32_cvtneps2bf16_512_mask
-__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u, 
__m256bh passthru) {
-  return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u, passthru);
+__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u) {
+  return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u);
 }
 // CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_512_mask
 // CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.512
@@ -62,8 +62,8 @@ __m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, 
__mmask16 u, __m256bh
 // OGCG: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
 
 // Test __builtin_ia32_cvtneps2bf16_256_mask
-__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u, __m128bh 
passthru) {
-  return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u, passthru);
+__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u) {
+  return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u);
 }
 // CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_256_mask
 // CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.256
@@ -73,8 +73,8 @@ __m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, 
__mmask8 u, __m128bh p
 // OGCG: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
 
 // Test __builtin_ia32_cvtneps2bf16_128_mask
-__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u, __m128bh 
passthru) {
-  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u, passthru);
+__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u) {
+  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u);
 }
 // CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_128_mask
 // CIR: cir.call @llvm.x86.avx512bf16.mask.cvtneps2bf16.128

>From da4f0523b38f0f596fbc53b8cdb31b7d265e62fa Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Thu, 11 Dec 2025 01:38:55 +0530
Subject: [PATCH 04/10] Update
 clang\test\CIR\CodeGenBuiltins\X86\cir-convert-half.c

---
 clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c 
b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
index e9c2404f48df6..8c6837a2e4e4a 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
@@ -18,8 +18,8 @@ typedef __bf16 __m256bh __attribute__((__vector_size__(32), 
__aligned__(32)));
 typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
 
 // Test __builtin_ia32_vcvtph2ps512_mask
-__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k, __m512 
passthru) {
-  return __builtin_ia32_vcvtph2ps512_mask(a, src, k, passthru);
+__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k) {
+  return __builtin_ia32_vcvtph2ps512_mask(a, src, k);
 }
 // CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps512_mask
 // CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.512
@@ -29,8 +29,8 @@ __m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, 
__mmask16 k, __m512 passthr
 // OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
 
 // Test __builtin_ia32_vcvtph2ps256_mask
-__m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k, __m256 
passthru) {
-  return __builtin_ia32_vcvtph2ps256_mask(a, src, k, passthru);
+__m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k) {
+  return __builtin_ia32_vcvtph2ps256_mask(a, src, k);
 }
 // CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps256_mask
 // CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.256

>From 4b3f3415835a7c682ce5b27ddae7f90963919a00 Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Thu, 11 Dec 2025 09:02:57 +0530
Subject: [PATCH 05/10] Update
 clang\test\CIR\CodeGenBuiltins\X86\cir-convert-half.c

---
 clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c 
b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
index 8c6837a2e4e4a..5e5060e1da1bf 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
@@ -18,8 +18,8 @@ typedef __bf16 __m256bh __attribute__((__vector_size__(32), 
__aligned__(32)));
 typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
 
 // Test __builtin_ia32_vcvtph2ps512_mask
-__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k) {
-  return __builtin_ia32_vcvtph2ps512_mask(a, src, k);
+__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k, _m512 dst) {
+  return __builtin_ia32_vcvtph2ps512_mask(a, src, k, dst);
 }
 // CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps512_mask
 // CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.512

>From 584276b2804ba38f3fd7be7fbc01e51e54c31f6d Mon Sep 17 00:00:00 2001
From: Priyanshu Kumar <[email protected]>
Date: Thu, 11 Dec 2025 06:16:55 +0000
Subject: [PATCH 06/10] Update test

---
 .../CodeGenBuiltins/X86/cir-convert-half.c    | 166 +++++++++---------
 1 file changed, 83 insertions(+), 83 deletions(-)

diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c 
b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
index 5e5060e1da1bf..09c08ef06a133 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
@@ -1,84 +1,84 @@
-// Test X86-specific convert_half builtins
-
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-llvm %s -o %t-cir.ll
-// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -emit-llvm %s -o %t.ll
-// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
-
-typedef float __m512 __attribute__((__vector_size__(64), __aligned__(64)));
-typedef float __m256 __attribute__((__vector_size__(32), __aligned__(32)));
-typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
-typedef int __m256i __attribute__((__vector_size__(32), __aligned__(32)));
-typedef int __m128i __attribute__((__vector_size__(16), __aligned__(16)));
-typedef int __mmask16;
-typedef unsigned char __mmask8;
-typedef __bf16 __m256bh __attribute__((__vector_size__(32), __aligned__(32)));
-typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
-
-// Test __builtin_ia32_vcvtph2ps512_mask
-__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k, _m512 dst) {
-  return __builtin_ia32_vcvtph2ps512_mask(a, src, k, dst);
-}
-// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps512_mask
-// CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.512
-// LLVM-LABEL: define {{.*}} @test_vcvtph2ps512_mask
-// LLVM: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
-// OGCG-LABEL: define {{.*}} @test_vcvtph2ps512_mask
-// OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
-
-// Test __builtin_ia32_vcvtph2ps256_mask
-__m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k) {
-  return __builtin_ia32_vcvtph2ps256_mask(a, src, k);
-}
-// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps256_mask
-// CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.256
-// LLVM-LABEL: define {{.*}} @test_vcvtph2ps256_mask
-// LLVM: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
-// OGCG-LABEL: define {{.*}} @test_vcvtph2ps256_mask
-// OGCG: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
-
-// Test __builtin_ia32_vcvtph2ps_mask
-__m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) {
-  return __builtin_ia32_vcvtph2ps_mask(a, src, k);
-}
-// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps_mask
-// CIR: cir.call @llvm.x86.avx512.mask.vcvtph2ps.128
-// LLVM-LABEL: define {{.*}} @test_vcvtph2ps_mask
-// LLVM: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
-// OGCG-LABEL: define {{.*}} @test_vcvtph2ps_mask
-// OGCG: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
-
-// Test __builtin_ia32_cvtneps2bf16_512_mask
-__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u) {
-  return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u);
-}
-// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_512_mask
-// CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.512
-// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
-// LLVM: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
-// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
-// OGCG: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
-
-// Test __builtin_ia32_cvtneps2bf16_256_mask
-__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u) {
-  return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u);
-}
-// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_256_mask
-// CIR: cir.call @llvm.x86.avx512bf16.cvtneps2bf16.256
-// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
-// LLVM: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
-// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
-// OGCG: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
-
-// Test __builtin_ia32_cvtneps2bf16_128_mask
-__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u) {
-  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u);
-}
-// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_128_mask
-// CIR: cir.call @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
-// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
-// LLVM: call <8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
-// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
+// Test X86-specific convert_half builtins
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
+
+typedef float __m512 __attribute__((__vector_size__(64), __aligned__(64)));
+typedef float __m256 __attribute__((__vector_size__(32), __aligned__(32)));
+typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
+typedef int __m256i __attribute__((__vector_size__(32), __aligned__(32)));
+typedef int __m128i __attribute__((__vector_size__(16), __aligned__(16)));
+typedef int __mmask16;
+typedef unsigned char __mmask8;
+typedef __bf16 __m256bh __attribute__((__vector_size__(32), __aligned__(32)));
+typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
+
+// Test __builtin_ia32_vcvtph2ps512_mask
+__m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k) {
+  return __builtin_ia32_vcvtph2ps512_mask(a, src, k, 4);
+}
+// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps512_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.512"
+// LLVM-LABEL: define {{.*}} @test_vcvtph2ps512_mask
+// LLVM: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
+// OGCG-LABEL: define {{.*}} @test_vcvtph2ps512_mask
+// OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
+
+// Test __builtin_ia32_vcvtph2ps256_mask
+__m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k) {
+  return __builtin_ia32_vcvtph2ps256_mask(a, src, k);
+}
+// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps256_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.256"
+// LLVM-LABEL: define {{.*}} @test_vcvtph2ps256_mask
+// LLVM: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
+// OGCG-LABEL: define {{.*}} @test_vcvtph2ps256_mask
+// OGCG: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
+
+// Test __builtin_ia32_vcvtph2ps_mask
+__m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) {
+  return __builtin_ia32_vcvtph2ps_mask(a, src, k);
+}
+// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.128"
+// LLVM-LABEL: define {{.*}} @test_vcvtph2ps_mask
+// LLVM: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
+// OGCG-LABEL: define {{.*}} @test_vcvtph2ps_mask
+// OGCG: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
+
+// Test __builtin_ia32_cvtneps2bf16_512_mask
+__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u) {
+  return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u);
+}
+// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_512_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512bf16.cvtneps2bf16.512"
+// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
+// LLVM: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
+// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
+// OGCG: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
+
+// Test __builtin_ia32_cvtneps2bf16_256_mask
+__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u) {
+  return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u);
+}
+// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_256_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512bf16.cvtneps2bf16.256"
+// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
+// LLVM: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
+// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
+// OGCG: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
+
+// Test __builtin_ia32_cvtneps2bf16_128_mask
+__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u) {
+  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u);
+}
+// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_128_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512bf16.mask.cvtneps2bf16.128"
+// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
+// LLVM: call <8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
+// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
 // OGCG: call <8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
\ No newline at end of file

>From 16ba37f08b3d70d6899dc2c600d0bc268dded41e Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Thu, 11 Dec 2025 12:55:15 +0530
Subject: [PATCH 07/10] Update test and lit.cfg.py

---
 clang/test/lit.cfg.py | 890 +++++++++++++++++++++---------------------
 1 file changed, 446 insertions(+), 444 deletions(-)

diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 52b275c095475..093400b0d708a 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -1,444 +1,446 @@
-# -*- Python -*-
-
-import os
-import platform
-import re
-import subprocess
-import tempfile
-
-import lit.formats
-import lit.util
-
-from lit.llvm import llvm_config
-from lit.llvm.subst import ToolSubst
-from lit.llvm.subst import FindTool
-
-# Configuration file for the 'lit' test runner.
-
-# name: The name of this test suite.
-config.name = "Clang"
-
-# TODO: Consolidate the logic for turning on the internal shell by default for 
all LLVM test suites.
-# See https://github.com/llvm/llvm-project/issues/106636 for more details.
-#
-# We prefer the lit internal shell which provides a better user experience on 
failures
-# and is faster unless the user explicitly disables it with 
LIT_USE_INTERNAL_SHELL=0
-# env var.
-use_lit_shell = True
-lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
-if lit_shell_env:
-    use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
-
-# testFormat: The test format to use to interpret tests.
-#
-# For now we require '&&' between commands, until they get globally killed and
-# the test runner updated.
-config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)
-
-# suffixes: A list of file extensions to treat as test files.
-config.suffixes = [
-    ".c",
-    ".cpp",
-    ".i",
-    ".cir",
-    ".cppm",
-    ".m",
-    ".mm",
-    ".cu",
-    ".cuh",
-    ".hip",
-    ".hlsl",
-    ".ll",
-    ".cl",
-    ".clcpp",
-    ".s",
-    ".S",
-    ".modulemap",
-    ".test",
-    ".rs",
-    ".ifs",
-    ".rc",
-]
-
-# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
-# subdirectories contain auxiliary inputs for various tests in their parent
-# directories.
-config.excludes = [
-    "Inputs",
-    "CMakeLists.txt",
-    "README.txt",
-    "LICENSE.txt",
-    "debuginfo-tests",
-]
-
-# test_source_root: The root path where tests are located.
-config.test_source_root = os.path.dirname(__file__)
-
-# test_exec_root: The root path where tests should be run.
-config.test_exec_root = os.path.join(config.clang_obj_root, "test")
-
-llvm_config.use_default_substitutions()
-
-llvm_config.use_clang()
-
-config.substitutions.append(("%src_dir", config.clang_src_dir))
-
-config.substitutions.append(("%src_include_dir", config.clang_src_dir + 
"/include"))
-
-config.substitutions.append(("%target_triple", config.target_triple))
-
-config.substitutions.append(("%PATH%", config.environment["PATH"]))
-
-
-# For each occurrence of a clang tool name, replace it with the full path to
-# the build directory holding that tool.  We explicitly specify the directories
-# to search to ensure that we get the tools just built and not some random
-# tools that might happen to be in the user's PATH.
-tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
-
-tools = [
-    "apinotes-test",
-    "c-index-test",
-    "cir-opt",
-    "clang-diff",
-    "clang-format",
-    "clang-repl",
-    "llvm-offload-binary",
-    "clang-tblgen",
-    "clang-scan-deps",
-    "clang-installapi",
-    "opt",
-    "llvm-ifs",
-    "yaml2obj",
-    "clang-linker-wrapper",
-    "clang-nvlink-wrapper",
-    "clang-sycl-linker",
-    "llvm-lto",
-    "llvm-lto2",
-    "llvm-profdata",
-    "llvm-readtapi",
-    ToolSubst(
-        "%clang_extdef_map",
-        command=FindTool("clang-extdef-mapping"),
-        unresolved="ignore",
-    ),
-]
-
-if config.clang_examples:
-    config.available_features.add("examples")
-
-
-def have_host_out_of_process_jit_feature_support():
-    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
-
-    if not clang_repl_exe:
-        return False
-
-    testcode = b"\n".join([b"int i = 0;", b"%quit"])
-
-    try:
-        clang_repl_cmd = subprocess.run(
-            [clang_repl_exe, "-orc-runtime", "-oop-executor"],
-            stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE,
-            input=testcode,
-        )
-    except OSError:
-        return False
-
-    if clang_repl_cmd.returncode == 0:
-        return True
-
-    return False
-
-
-def run_clang_repl(args):
-    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
-
-    if not clang_repl_exe:
-        return ""
-
-    try:
-        clang_repl_cmd = subprocess.Popen(
-            [clang_repl_exe, args], stdout=subprocess.PIPE
-        )
-    except OSError:
-        print("could not exec clang-repl")
-        return ""
-
-    clang_repl_out = clang_repl_cmd.stdout.read().decode("ascii")
-    clang_repl_cmd.wait()
-
-    return clang_repl_out
-
-
-def have_host_jit_feature_support(feature_name):
-    return "true" in run_clang_repl("--host-supports-" + feature_name)
-
-def have_host_clang_repl_cuda():
-    clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir)
-
-    if not clang_repl_exe:
-        return False
-
-    testcode = b'\n'.join([
-        b"__global__ void test_func() {}",
-        b"test_func<<<1,1>>>();",
-        b"extern \"C\" int puts(const char *s);",
-        b"puts(cudaGetLastError() ? \"failure\" : \"success\");",
-        b"%quit"
-    ])
-    try:
-        clang_repl_cmd = subprocess.run([clang_repl_exe, '--cuda'],
-                                        stdout=subprocess.PIPE,
-                                        stderr=subprocess.PIPE,
-                                        input=testcode)
-    except OSError:
-        return False
-
-    if clang_repl_cmd.returncode == 0:
-        if clang_repl_cmd.stdout.find(b"success") != -1:
-            return True
-
-    return False
-
-if have_host_jit_feature_support('jit'):
-    config.available_features.add('host-supports-jit')
-
-    if have_host_clang_repl_cuda():
-        config.available_features.add('host-supports-cuda')
-    hosttriple = run_clang_repl("--host-jit-triple")
-    config.substitutions.append(("%host-jit-triple", hosttriple.strip()))
-
-    if have_host_out_of_process_jit_feature_support():
-        config.available_features.add("host-supports-out-of-process-jit")
-
-if config.clang_staticanalyzer:
-    config.available_features.add("staticanalyzer")
-    tools.append("clang-check")
-
-    if config.clang_staticanalyzer_z3:
-        config.available_features.add("z3")
-        if config.clang_staticanalyzer_z3_mock:
-            config.available_features.add("z3-mock")
-    else:
-        config.available_features.add("no-z3")
-
-    check_analyzer_fixit_path = os.path.join(
-        config.test_source_root, "Analysis", "check-analyzer-fixit.py"
-    )
-    config.substitutions.append(
-        (
-            "%check_analyzer_fixit",
-            '"%s" %s' % (config.python_executable, check_analyzer_fixit_path),
-        )
-    )
-
-    csv2json_path = os.path.join(config.test_source_root, "Analysis", 
"csv2json.py")
-    config.substitutions.append(
-        (
-            "%csv2json",
-            '"%s" %s' % (config.python_executable, csv2json_path),
-        )
-    )
-
-# ClangIR support
-if config.clang_enable_cir:
-    config.available_features.add("cir-support")
-
-llvm_config.add_tool_substitutions(tools, tool_dirs)
-
-config.substitutions.append(
-    (
-        "%hmaptool",
-        "'%s' %s"
-        % (
-            config.python_executable,
-            os.path.join(config.clang_src_dir, "utils", "hmaptool", 
"hmaptool"),
-        ),
-    )
-)
-
-config.substitutions.append(
-    (
-        "%deps-to-rsp",
-        '"%s" %s'
-        % (
-            config.python_executable,
-            os.path.join(config.clang_src_dir, "utils", 
"module-deps-to-rsp.py"),
-        ),
-    )
-)
-
-# Determine whether the test target is compatible with execution on the host.
-if "aarch64" in config.host_arch:
-    config.available_features.add("aarch64-host")
-
-# Some tests are sensitive to whether clang is statically or dynamically linked
-# to other libraries.
-if not (config.build_shared_libs or config.link_llvm_dylib or 
config.link_clang_dylib):
-    config.available_features.add("static-libs")
-
-# Plugins (loadable modules)
-if config.has_plugins and config.llvm_plugin_ext:
-    config.available_features.add("plugins")
-
-if config.clang_default_pie_on_linux:
-    config.available_features.add("default-pie-on-linux")
-
-# Set available features we allow tests to conditionalize on.
-#
-if config.clang_default_cxx_stdlib != "":
-    config.available_features.add(
-        "default-cxx-stdlib={}".format(config.clang_default_cxx_stdlib)
-    )
-
-# As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
-if platform.system() not in ["FreeBSD"]:
-    config.available_features.add("crash-recovery")
-
-# ANSI escape sequences in non-dumb terminal
-if platform.system() not in ["Windows"]:
-    config.available_features.add("ansi-escape-sequences")
-
-# Capability to print utf8 to the terminal.
-# Windows expects codepage, unless Wide API.
-if platform.system() not in ["Windows"]:
-    config.available_features.add("utf8-capable-terminal")
-
-# Support for libgcc runtime. Used to rule out tests that require
-# clang to run with -rtlib=libgcc.
-if platform.system() not in ["Darwin", "Fuchsia"]:
-    config.available_features.add("libgcc")
-
-# Case-insensitive file system
-
-
-def is_filesystem_case_insensitive():
-    os.makedirs(config.test_exec_root, exist_ok=True)
-    handle, path = tempfile.mkstemp(prefix="case-test", 
dir=config.test_exec_root)
-    isInsensitive = os.path.exists(
-        os.path.join(os.path.dirname(path), os.path.basename(path).upper())
-    )
-    os.close(handle)
-    os.remove(path)
-    return isInsensitive
-
-
-if is_filesystem_case_insensitive():
-    config.available_features.add("case-insensitive-filesystem")
-
-# Tests that require the /dev/fd filesystem.
-if os.path.exists("/dev/fd/0") and sys.platform not in ["cygwin"]:
-    config.available_features.add("dev-fd-fs")
-
-# Set on native MS environment.
-if re.match(r".*-(windows-msvc)$", config.target_triple):
-    config.available_features.add("ms-sdk")
-
-# [PR8833] LLP64-incompatible tests
-if not re.match(
-    r"^(aarch64|arm64ec|x86_64).*-(windows-msvc|windows-gnu)$", 
config.target_triple
-):
-    config.available_features.add("LP64")
-
-# Tests that are specific to the Apple Silicon macOS.
-if re.match(r"^arm64(e)?-apple-(macos|darwin)", config.target_triple):
-    config.available_features.add("apple-silicon-mac")
-
-# [PR18856] Depends to remove opened file. On win32, a file could be removed
-# only if all handles were closed.
-if platform.system() not in ["Windows"]:
-    config.available_features.add("can-remove-opened-file")
-
-# Features
-known_arches = ["x86_64", "mips64", "ppc64", "aarch64"]
-if any(config.target_triple.startswith(x) for x in known_arches):
-    config.available_features.add("clang-target-64-bits")
-
-
-def calculate_arch_features(arch_string):
-    features = []
-    for arch in arch_string.split():
-        features.append(arch.lower() + "-registered-target")
-    return features
-
-
-llvm_config.feature_config(
-    [
-        ("--assertion-mode", {"ON": "asserts"}),
-        ("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),
-        ("--targets-built", calculate_arch_features),
-    ]
-)
-
-if lit.util.which("xmllint"):
-    config.available_features.add("xmllint")
-
-if config.enable_backtrace:
-    config.available_features.add("backtrace")
-
-if config.enable_threads:
-    config.available_features.add("thread_support")
-
-# Check if we should allow outputs to console.
-run_console_tests = int(lit_config.params.get("enable_console", "0"))
-if run_console_tests != 0:
-    config.available_features.add("console")
-
-lit.util.usePlatformSdkOnDarwin(config, lit_config)
-macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
-if macOSSDKVersion is not None:
-    config.available_features.add("macos-sdk-" + str(macOSSDKVersion))
-
-if os.path.exists("/etc/gentoo-release"):
-    config.available_features.add("gentoo")
-
-if config.enable_shared:
-    config.available_features.add("enable_shared")
-
-# Add a vendor-specific feature.
-if config.clang_vendor_uti:
-    config.available_features.add("clang-vendor=" + config.clang_vendor_uti)
-
-if config.have_llvm_driver:
-    config.available_features.add("llvm-driver")
-
-
-# Some tests perform deep recursion, which requires a larger pthread stack size
-# than the relatively low default of 192 KiB for 64-bit processes on AIX. The
-# `AIXTHREAD_STK` environment variable provides a non-intrusive way to request
-# a larger pthread stack size for the tests. Various applications and runtime
-# libraries on AIX use a default pthread stack size of 4 MiB, so we will use
-# that as a default value here.
-if "AIXTHREAD_STK" in os.environ:
-    config.environment["AIXTHREAD_STK"] = os.environ["AIXTHREAD_STK"]
-elif platform.system() == "AIX":
-    config.environment["AIXTHREAD_STK"] = "4194304"
-
-# Some tools support an environment variable "OBJECT_MODE" on AIX OS, which
-# controls the kind of objects they will support. If there is no "OBJECT_MODE"
-# environment variable specified, the default behaviour is to support 32-bit
-# objects only. In order to not affect most test cases, which expect to support
-# 32-bit and 64-bit objects by default, set the environment variable
-# "OBJECT_MODE" to "any" by default on AIX OS.
-
-if "system-aix" in config.available_features:
-   config.substitutions.append(("llvm-nm", "env OBJECT_MODE=any llvm-nm"))
-   config.substitutions.append(("llvm-ar", "env OBJECT_MODE=any llvm-ar"))
-   config.substitutions.append(("llvm-ranlib", "env OBJECT_MODE=any 
llvm-ranlib"))
-
-# It is not realistically possible to account for all options that could
-# possibly be present in system and user configuration files, so disable
-# default configs for the test runs.
-config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
-
-if lit_config.update_tests:
-    import sys
-    import os
-
-    utilspath = os.path.join(config.llvm_src_root, "utils")
-    sys.path.append(utilspath)
-    from update_any_test_checks import utc_lit_plugin
-
-    lit_config.test_updaters.append(utc_lit_plugin)
+# -*- Python -*-
+
+import os
+import platform
+import re
+import subprocess
+import tempfile
+
+import lit.formats
+import lit.util
+
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst
+from lit.llvm.subst import FindTool
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = "Clang"
+
+# TODO: Consolidate the logic for turning on the internal shell by default for 
all LLVM test suites.
+# See https://github.com/llvm/llvm-project/issues/106636 for more details.
+#
+# We prefer the lit internal shell which provides a better user experience on 
failures
+# and is faster unless the user explicitly disables it with 
LIT_USE_INTERNAL_SHELL=0
+# env var.
+use_lit_shell = True
+lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
+if lit_shell_env:
+    use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
+
+# testFormat: The test format to use to interpret tests.
+#
+# For now we require '&&' between commands, until they get globally killed and
+# the test runner updated.
+config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = [
+    ".c",
+    ".cpp",
+    ".i",
+    ".cir",
+    ".cppm",
+    ".m",
+    ".mm",
+    ".cu",
+    ".cuh",
+    ".hip",
+    ".hlsl",
+    ".ll",
+    ".cl",
+    ".clcpp",
+    ".s",
+    ".S",
+    ".modulemap",
+    ".test",
+    ".rs",
+    ".ifs",
+    ".rc",
+]
+
+# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
+# subdirectories contain auxiliary inputs for various tests in their parent
+# directories.
+config.excludes = [
+    "Inputs",
+    "CMakeLists.txt",
+    "README.txt",
+    "LICENSE.txt",
+    "debuginfo-tests",
+]
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = os.path.join(config.clang_obj_root, "test")
+
+llvm_config.use_default_substitutions()
+
+llvm_config.use_clang()
+
+config.substitutions.append(('%clang_cir', 
os.path.join(config.clang_tools_dir, 'clang')))
+
+config.substitutions.append(("%src_dir", config.clang_src_dir))
+
+config.substitutions.append(("%src_include_dir", config.clang_src_dir + 
"/include"))
+
+config.substitutions.append(("%target_triple", config.target_triple))
+
+config.substitutions.append(("%PATH%", config.environment["PATH"]))
+
+
+# For each occurrence of a clang tool name, replace it with the full path to
+# the build directory holding that tool.  We explicitly specify the directories
+# to search to ensure that we get the tools just built and not some random
+# tools that might happen to be in the user's PATH.
+tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
+
+tools = [
+    "apinotes-test",
+    "c-index-test",
+    "cir-opt",
+    "clang-diff",
+    "clang-format",
+    "clang-repl",
+    "llvm-offload-binary",
+    "clang-tblgen",
+    "clang-scan-deps",
+    "clang-installapi",
+    "opt",
+    "llvm-ifs",
+    "yaml2obj",
+    "clang-linker-wrapper",
+    "clang-nvlink-wrapper",
+    "clang-sycl-linker",
+    "llvm-lto",
+    "llvm-lto2",
+    "llvm-profdata",
+    "llvm-readtapi",
+    ToolSubst(
+        "%clang_extdef_map",
+        command=FindTool("clang-extdef-mapping"),
+        unresolved="ignore",
+    ),
+]
+
+if config.clang_examples:
+    config.available_features.add("examples")
+
+
+def have_host_out_of_process_jit_feature_support():
+    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
+
+    if not clang_repl_exe:
+        return False
+
+    testcode = b"\n".join([b"int i = 0;", b"%quit"])
+
+    try:
+        clang_repl_cmd = subprocess.run(
+            [clang_repl_exe, "-orc-runtime", "-oop-executor"],
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            input=testcode,
+        )
+    except OSError:
+        return False
+
+    if clang_repl_cmd.returncode == 0:
+        return True
+
+    return False
+
+
+def run_clang_repl(args):
+    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
+
+    if not clang_repl_exe:
+        return ""
+
+    try:
+        clang_repl_cmd = subprocess.Popen(
+            [clang_repl_exe, args], stdout=subprocess.PIPE
+        )
+    except OSError:
+        print("could not exec clang-repl")
+        return ""
+
+    clang_repl_out = clang_repl_cmd.stdout.read().decode("ascii")
+    clang_repl_cmd.wait()
+
+    return clang_repl_out
+
+
+def have_host_jit_feature_support(feature_name):
+    return "true" in run_clang_repl("--host-supports-" + feature_name)
+
+def have_host_clang_repl_cuda():
+    clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir)
+
+    if not clang_repl_exe:
+        return False
+
+    testcode = b'\n'.join([
+        b"__global__ void test_func() {}",
+        b"test_func<<<1,1>>>();",
+        b"extern \"C\" int puts(const char *s);",
+        b"puts(cudaGetLastError() ? \"failure\" : \"success\");",
+        b"%quit"
+    ])
+    try:
+        clang_repl_cmd = subprocess.run([clang_repl_exe, '--cuda'],
+                                        stdout=subprocess.PIPE,
+                                        stderr=subprocess.PIPE,
+                                        input=testcode)
+    except OSError:
+        return False
+
+    if clang_repl_cmd.returncode == 0:
+        if clang_repl_cmd.stdout.find(b"success") != -1:
+            return True
+
+    return False
+
+if have_host_jit_feature_support('jit'):
+    config.available_features.add('host-supports-jit')
+
+    if have_host_clang_repl_cuda():
+        config.available_features.add('host-supports-cuda')
+    hosttriple = run_clang_repl("--host-jit-triple")
+    config.substitutions.append(("%host-jit-triple", hosttriple.strip()))
+
+    if have_host_out_of_process_jit_feature_support():
+        config.available_features.add("host-supports-out-of-process-jit")
+
+if config.clang_staticanalyzer:
+    config.available_features.add("staticanalyzer")
+    tools.append("clang-check")
+
+    if config.clang_staticanalyzer_z3:
+        config.available_features.add("z3")
+        if config.clang_staticanalyzer_z3_mock:
+            config.available_features.add("z3-mock")
+    else:
+        config.available_features.add("no-z3")
+
+    check_analyzer_fixit_path = os.path.join(
+        config.test_source_root, "Analysis", "check-analyzer-fixit.py"
+    )
+    config.substitutions.append(
+        (
+            "%check_analyzer_fixit",
+            '"%s" %s' % (config.python_executable, check_analyzer_fixit_path),
+        )
+    )
+
+    csv2json_path = os.path.join(config.test_source_root, "Analysis", 
"csv2json.py")
+    config.substitutions.append(
+        (
+            "%csv2json",
+            '"%s" %s' % (config.python_executable, csv2json_path),
+        )
+    )
+
+# ClangIR support
+if config.clang_enable_cir:
+    config.available_features.add("cir-support")
+
+llvm_config.add_tool_substitutions(tools, tool_dirs)
+
+config.substitutions.append(
+    (
+        "%hmaptool",
+        "'%s' %s"
+        % (
+            config.python_executable,
+            os.path.join(config.clang_src_dir, "utils", "hmaptool", 
"hmaptool"),
+        ),
+    )
+)
+
+config.substitutions.append(
+    (
+        "%deps-to-rsp",
+        '"%s" %s'
+        % (
+            config.python_executable,
+            os.path.join(config.clang_src_dir, "utils", 
"module-deps-to-rsp.py"),
+        ),
+    )
+)
+
+# Determine whether the test target is compatible with execution on the host.
+if "aarch64" in config.host_arch:
+    config.available_features.add("aarch64-host")
+
+# Some tests are sensitive to whether clang is statically or dynamically linked
+# to other libraries.
+if not (config.build_shared_libs or config.link_llvm_dylib or 
config.link_clang_dylib):
+    config.available_features.add("static-libs")
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+    config.available_features.add("plugins")
+
+if config.clang_default_pie_on_linux:
+    config.available_features.add("default-pie-on-linux")
+
+# Set available features we allow tests to conditionalize on.
+#
+if config.clang_default_cxx_stdlib != "":
+    config.available_features.add(
+        "default-cxx-stdlib={}".format(config.clang_default_cxx_stdlib)
+    )
+
+# As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
+if platform.system() not in ["FreeBSD"]:
+    config.available_features.add("crash-recovery")
+
+# ANSI escape sequences in non-dumb terminal
+if platform.system() not in ["Windows"]:
+    config.available_features.add("ansi-escape-sequences")
+
+# Capability to print utf8 to the terminal.
+# Windows expects codepage, unless Wide API.
+if platform.system() not in ["Windows"]:
+    config.available_features.add("utf8-capable-terminal")
+
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ["Darwin", "Fuchsia"]:
+    config.available_features.add("libgcc")
+
+# Case-insensitive file system
+
+
+def is_filesystem_case_insensitive():
+    os.makedirs(config.test_exec_root, exist_ok=True)
+    handle, path = tempfile.mkstemp(prefix="case-test", 
dir=config.test_exec_root)
+    isInsensitive = os.path.exists(
+        os.path.join(os.path.dirname(path), os.path.basename(path).upper())
+    )
+    os.close(handle)
+    os.remove(path)
+    return isInsensitive
+
+
+if is_filesystem_case_insensitive():
+    config.available_features.add("case-insensitive-filesystem")
+
+# Tests that require the /dev/fd filesystem.
+if os.path.exists("/dev/fd/0") and sys.platform not in ["cygwin"]:
+    config.available_features.add("dev-fd-fs")
+
+# Set on native MS environment.
+if re.match(r".*-(windows-msvc)$", config.target_triple):
+    config.available_features.add("ms-sdk")
+
+# [PR8833] LLP64-incompatible tests
+if not re.match(
+    r"^(aarch64|arm64ec|x86_64).*-(windows-msvc|windows-gnu)$", 
config.target_triple
+):
+    config.available_features.add("LP64")
+
+# Tests that are specific to the Apple Silicon macOS.
+if re.match(r"^arm64(e)?-apple-(macos|darwin)", config.target_triple):
+    config.available_features.add("apple-silicon-mac")
+
+# [PR18856] Depends to remove opened file. On win32, a file could be removed
+# only if all handles were closed.
+if platform.system() not in ["Windows"]:
+    config.available_features.add("can-remove-opened-file")
+
+# Features
+known_arches = ["x86_64", "mips64", "ppc64", "aarch64"]
+if any(config.target_triple.startswith(x) for x in known_arches):
+    config.available_features.add("clang-target-64-bits")
+
+
+def calculate_arch_features(arch_string):
+    features = []
+    for arch in arch_string.split():
+        features.append(arch.lower() + "-registered-target")
+    return features
+
+
+llvm_config.feature_config(
+    [
+        ("--assertion-mode", {"ON": "asserts"}),
+        ("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),
+        ("--targets-built", calculate_arch_features),
+    ]
+)
+
+if lit.util.which("xmllint"):
+    config.available_features.add("xmllint")
+
+if config.enable_backtrace:
+    config.available_features.add("backtrace")
+
+if config.enable_threads:
+    config.available_features.add("thread_support")
+
+# Check if we should allow outputs to console.
+run_console_tests = int(lit_config.params.get("enable_console", "0"))
+if run_console_tests != 0:
+    config.available_features.add("console")
+
+lit.util.usePlatformSdkOnDarwin(config, lit_config)
+macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
+if macOSSDKVersion is not None:
+    config.available_features.add("macos-sdk-" + str(macOSSDKVersion))
+
+if os.path.exists("/etc/gentoo-release"):
+    config.available_features.add("gentoo")
+
+if config.enable_shared:
+    config.available_features.add("enable_shared")
+
+# Add a vendor-specific feature.
+if config.clang_vendor_uti:
+    config.available_features.add("clang-vendor=" + config.clang_vendor_uti)
+
+if config.have_llvm_driver:
+    config.available_features.add("llvm-driver")
+
+
+# Some tests perform deep recursion, which requires a larger pthread stack size
+# than the relatively low default of 192 KiB for 64-bit processes on AIX. The
+# `AIXTHREAD_STK` environment variable provides a non-intrusive way to request
+# a larger pthread stack size for the tests. Various applications and runtime
+# libraries on AIX use a default pthread stack size of 4 MiB, so we will use
+# that as a default value here.
+if "AIXTHREAD_STK" in os.environ:
+    config.environment["AIXTHREAD_STK"] = os.environ["AIXTHREAD_STK"]
+elif platform.system() == "AIX":
+    config.environment["AIXTHREAD_STK"] = "4194304"
+
+# Some tools support an environment variable "OBJECT_MODE" on AIX OS, which
+# controls the kind of objects they will support. If there is no "OBJECT_MODE"
+# environment variable specified, the default behaviour is to support 32-bit
+# objects only. In order to not affect most test cases, which expect to support
+# 32-bit and 64-bit objects by default, set the environment variable
+# "OBJECT_MODE" to "any" by default on AIX OS.
+
+if "system-aix" in config.available_features:
+   config.substitutions.append(("llvm-nm", "env OBJECT_MODE=any llvm-nm"))
+   config.substitutions.append(("llvm-ar", "env OBJECT_MODE=any llvm-ar"))
+   config.substitutions.append(("llvm-ranlib", "env OBJECT_MODE=any 
llvm-ranlib"))
+
+# It is not realistically possible to account for all options that could
+# possibly be present in system and user configuration files, so disable
+# default configs for the test runs.
+config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
+
+if lit_config.update_tests:
+    import sys
+    import os
+
+    utilspath = os.path.join(config.llvm_src_root, "utils")
+    sys.path.append(utilspath)
+    from update_any_test_checks import utc_lit_plugin
+
+    lit_config.test_updaters.append(utc_lit_plugin)

>From d320ee632551a191a064e10514537e45295e1203 Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Thu, 11 Dec 2025 13:24:49 +0530
Subject: [PATCH 08/10] update lit.cfg.py

---
 clang/test/lit.cfg.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 093400b0d708a..78f74039ff862 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -81,8 +81,6 @@
 
 llvm_config.use_clang()
 
-config.substitutions.append(('%clang_cir', 
os.path.join(config.clang_tools_dir, 'clang')))
-
 config.substitutions.append(("%src_dir", config.clang_src_dir))
 
 config.substitutions.append(("%src_include_dir", config.clang_src_dir + 
"/include"))

>From dd5108ba2c65d3cbd4506f5bffd964e7ee90cce7 Mon Sep 17 00:00:00 2001
From: Priyanshu3820 <[email protected]>
Date: Thu, 11 Dec 2025 19:03:47 +0530
Subject: [PATCH 09/10] Update lit.cfg.py

---
 clang/test/lit.cfg.py | 888 +++++++++++++++++++++---------------------
 1 file changed, 444 insertions(+), 444 deletions(-)

diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 78f74039ff862..52b275c095475 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -1,444 +1,444 @@
-# -*- Python -*-
-
-import os
-import platform
-import re
-import subprocess
-import tempfile
-
-import lit.formats
-import lit.util
-
-from lit.llvm import llvm_config
-from lit.llvm.subst import ToolSubst
-from lit.llvm.subst import FindTool
-
-# Configuration file for the 'lit' test runner.
-
-# name: The name of this test suite.
-config.name = "Clang"
-
-# TODO: Consolidate the logic for turning on the internal shell by default for 
all LLVM test suites.
-# See https://github.com/llvm/llvm-project/issues/106636 for more details.
-#
-# We prefer the lit internal shell which provides a better user experience on 
failures
-# and is faster unless the user explicitly disables it with 
LIT_USE_INTERNAL_SHELL=0
-# env var.
-use_lit_shell = True
-lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
-if lit_shell_env:
-    use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
-
-# testFormat: The test format to use to interpret tests.
-#
-# For now we require '&&' between commands, until they get globally killed and
-# the test runner updated.
-config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)
-
-# suffixes: A list of file extensions to treat as test files.
-config.suffixes = [
-    ".c",
-    ".cpp",
-    ".i",
-    ".cir",
-    ".cppm",
-    ".m",
-    ".mm",
-    ".cu",
-    ".cuh",
-    ".hip",
-    ".hlsl",
-    ".ll",
-    ".cl",
-    ".clcpp",
-    ".s",
-    ".S",
-    ".modulemap",
-    ".test",
-    ".rs",
-    ".ifs",
-    ".rc",
-]
-
-# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
-# subdirectories contain auxiliary inputs for various tests in their parent
-# directories.
-config.excludes = [
-    "Inputs",
-    "CMakeLists.txt",
-    "README.txt",
-    "LICENSE.txt",
-    "debuginfo-tests",
-]
-
-# test_source_root: The root path where tests are located.
-config.test_source_root = os.path.dirname(__file__)
-
-# test_exec_root: The root path where tests should be run.
-config.test_exec_root = os.path.join(config.clang_obj_root, "test")
-
-llvm_config.use_default_substitutions()
-
-llvm_config.use_clang()
-
-config.substitutions.append(("%src_dir", config.clang_src_dir))
-
-config.substitutions.append(("%src_include_dir", config.clang_src_dir + 
"/include"))
-
-config.substitutions.append(("%target_triple", config.target_triple))
-
-config.substitutions.append(("%PATH%", config.environment["PATH"]))
-
-
-# For each occurrence of a clang tool name, replace it with the full path to
-# the build directory holding that tool.  We explicitly specify the directories
-# to search to ensure that we get the tools just built and not some random
-# tools that might happen to be in the user's PATH.
-tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
-
-tools = [
-    "apinotes-test",
-    "c-index-test",
-    "cir-opt",
-    "clang-diff",
-    "clang-format",
-    "clang-repl",
-    "llvm-offload-binary",
-    "clang-tblgen",
-    "clang-scan-deps",
-    "clang-installapi",
-    "opt",
-    "llvm-ifs",
-    "yaml2obj",
-    "clang-linker-wrapper",
-    "clang-nvlink-wrapper",
-    "clang-sycl-linker",
-    "llvm-lto",
-    "llvm-lto2",
-    "llvm-profdata",
-    "llvm-readtapi",
-    ToolSubst(
-        "%clang_extdef_map",
-        command=FindTool("clang-extdef-mapping"),
-        unresolved="ignore",
-    ),
-]
-
-if config.clang_examples:
-    config.available_features.add("examples")
-
-
-def have_host_out_of_process_jit_feature_support():
-    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
-
-    if not clang_repl_exe:
-        return False
-
-    testcode = b"\n".join([b"int i = 0;", b"%quit"])
-
-    try:
-        clang_repl_cmd = subprocess.run(
-            [clang_repl_exe, "-orc-runtime", "-oop-executor"],
-            stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE,
-            input=testcode,
-        )
-    except OSError:
-        return False
-
-    if clang_repl_cmd.returncode == 0:
-        return True
-
-    return False
-
-
-def run_clang_repl(args):
-    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
-
-    if not clang_repl_exe:
-        return ""
-
-    try:
-        clang_repl_cmd = subprocess.Popen(
-            [clang_repl_exe, args], stdout=subprocess.PIPE
-        )
-    except OSError:
-        print("could not exec clang-repl")
-        return ""
-
-    clang_repl_out = clang_repl_cmd.stdout.read().decode("ascii")
-    clang_repl_cmd.wait()
-
-    return clang_repl_out
-
-
-def have_host_jit_feature_support(feature_name):
-    return "true" in run_clang_repl("--host-supports-" + feature_name)
-
-def have_host_clang_repl_cuda():
-    clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir)
-
-    if not clang_repl_exe:
-        return False
-
-    testcode = b'\n'.join([
-        b"__global__ void test_func() {}",
-        b"test_func<<<1,1>>>();",
-        b"extern \"C\" int puts(const char *s);",
-        b"puts(cudaGetLastError() ? \"failure\" : \"success\");",
-        b"%quit"
-    ])
-    try:
-        clang_repl_cmd = subprocess.run([clang_repl_exe, '--cuda'],
-                                        stdout=subprocess.PIPE,
-                                        stderr=subprocess.PIPE,
-                                        input=testcode)
-    except OSError:
-        return False
-
-    if clang_repl_cmd.returncode == 0:
-        if clang_repl_cmd.stdout.find(b"success") != -1:
-            return True
-
-    return False
-
-if have_host_jit_feature_support('jit'):
-    config.available_features.add('host-supports-jit')
-
-    if have_host_clang_repl_cuda():
-        config.available_features.add('host-supports-cuda')
-    hosttriple = run_clang_repl("--host-jit-triple")
-    config.substitutions.append(("%host-jit-triple", hosttriple.strip()))
-
-    if have_host_out_of_process_jit_feature_support():
-        config.available_features.add("host-supports-out-of-process-jit")
-
-if config.clang_staticanalyzer:
-    config.available_features.add("staticanalyzer")
-    tools.append("clang-check")
-
-    if config.clang_staticanalyzer_z3:
-        config.available_features.add("z3")
-        if config.clang_staticanalyzer_z3_mock:
-            config.available_features.add("z3-mock")
-    else:
-        config.available_features.add("no-z3")
-
-    check_analyzer_fixit_path = os.path.join(
-        config.test_source_root, "Analysis", "check-analyzer-fixit.py"
-    )
-    config.substitutions.append(
-        (
-            "%check_analyzer_fixit",
-            '"%s" %s' % (config.python_executable, check_analyzer_fixit_path),
-        )
-    )
-
-    csv2json_path = os.path.join(config.test_source_root, "Analysis", 
"csv2json.py")
-    config.substitutions.append(
-        (
-            "%csv2json",
-            '"%s" %s' % (config.python_executable, csv2json_path),
-        )
-    )
-
-# ClangIR support
-if config.clang_enable_cir:
-    config.available_features.add("cir-support")
-
-llvm_config.add_tool_substitutions(tools, tool_dirs)
-
-config.substitutions.append(
-    (
-        "%hmaptool",
-        "'%s' %s"
-        % (
-            config.python_executable,
-            os.path.join(config.clang_src_dir, "utils", "hmaptool", 
"hmaptool"),
-        ),
-    )
-)
-
-config.substitutions.append(
-    (
-        "%deps-to-rsp",
-        '"%s" %s'
-        % (
-            config.python_executable,
-            os.path.join(config.clang_src_dir, "utils", 
"module-deps-to-rsp.py"),
-        ),
-    )
-)
-
-# Determine whether the test target is compatible with execution on the host.
-if "aarch64" in config.host_arch:
-    config.available_features.add("aarch64-host")
-
-# Some tests are sensitive to whether clang is statically or dynamically linked
-# to other libraries.
-if not (config.build_shared_libs or config.link_llvm_dylib or 
config.link_clang_dylib):
-    config.available_features.add("static-libs")
-
-# Plugins (loadable modules)
-if config.has_plugins and config.llvm_plugin_ext:
-    config.available_features.add("plugins")
-
-if config.clang_default_pie_on_linux:
-    config.available_features.add("default-pie-on-linux")
-
-# Set available features we allow tests to conditionalize on.
-#
-if config.clang_default_cxx_stdlib != "":
-    config.available_features.add(
-        "default-cxx-stdlib={}".format(config.clang_default_cxx_stdlib)
-    )
-
-# As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
-if platform.system() not in ["FreeBSD"]:
-    config.available_features.add("crash-recovery")
-
-# ANSI escape sequences in non-dumb terminal
-if platform.system() not in ["Windows"]:
-    config.available_features.add("ansi-escape-sequences")
-
-# Capability to print utf8 to the terminal.
-# Windows expects codepage, unless Wide API.
-if platform.system() not in ["Windows"]:
-    config.available_features.add("utf8-capable-terminal")
-
-# Support for libgcc runtime. Used to rule out tests that require
-# clang to run with -rtlib=libgcc.
-if platform.system() not in ["Darwin", "Fuchsia"]:
-    config.available_features.add("libgcc")
-
-# Case-insensitive file system
-
-
-def is_filesystem_case_insensitive():
-    os.makedirs(config.test_exec_root, exist_ok=True)
-    handle, path = tempfile.mkstemp(prefix="case-test", 
dir=config.test_exec_root)
-    isInsensitive = os.path.exists(
-        os.path.join(os.path.dirname(path), os.path.basename(path).upper())
-    )
-    os.close(handle)
-    os.remove(path)
-    return isInsensitive
-
-
-if is_filesystem_case_insensitive():
-    config.available_features.add("case-insensitive-filesystem")
-
-# Tests that require the /dev/fd filesystem.
-if os.path.exists("/dev/fd/0") and sys.platform not in ["cygwin"]:
-    config.available_features.add("dev-fd-fs")
-
-# Set on native MS environment.
-if re.match(r".*-(windows-msvc)$", config.target_triple):
-    config.available_features.add("ms-sdk")
-
-# [PR8833] LLP64-incompatible tests
-if not re.match(
-    r"^(aarch64|arm64ec|x86_64).*-(windows-msvc|windows-gnu)$", 
config.target_triple
-):
-    config.available_features.add("LP64")
-
-# Tests that are specific to the Apple Silicon macOS.
-if re.match(r"^arm64(e)?-apple-(macos|darwin)", config.target_triple):
-    config.available_features.add("apple-silicon-mac")
-
-# [PR18856] Depends to remove opened file. On win32, a file could be removed
-# only if all handles were closed.
-if platform.system() not in ["Windows"]:
-    config.available_features.add("can-remove-opened-file")
-
-# Features
-known_arches = ["x86_64", "mips64", "ppc64", "aarch64"]
-if any(config.target_triple.startswith(x) for x in known_arches):
-    config.available_features.add("clang-target-64-bits")
-
-
-def calculate_arch_features(arch_string):
-    features = []
-    for arch in arch_string.split():
-        features.append(arch.lower() + "-registered-target")
-    return features
-
-
-llvm_config.feature_config(
-    [
-        ("--assertion-mode", {"ON": "asserts"}),
-        ("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),
-        ("--targets-built", calculate_arch_features),
-    ]
-)
-
-if lit.util.which("xmllint"):
-    config.available_features.add("xmllint")
-
-if config.enable_backtrace:
-    config.available_features.add("backtrace")
-
-if config.enable_threads:
-    config.available_features.add("thread_support")
-
-# Check if we should allow outputs to console.
-run_console_tests = int(lit_config.params.get("enable_console", "0"))
-if run_console_tests != 0:
-    config.available_features.add("console")
-
-lit.util.usePlatformSdkOnDarwin(config, lit_config)
-macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
-if macOSSDKVersion is not None:
-    config.available_features.add("macos-sdk-" + str(macOSSDKVersion))
-
-if os.path.exists("/etc/gentoo-release"):
-    config.available_features.add("gentoo")
-
-if config.enable_shared:
-    config.available_features.add("enable_shared")
-
-# Add a vendor-specific feature.
-if config.clang_vendor_uti:
-    config.available_features.add("clang-vendor=" + config.clang_vendor_uti)
-
-if config.have_llvm_driver:
-    config.available_features.add("llvm-driver")
-
-
-# Some tests perform deep recursion, which requires a larger pthread stack size
-# than the relatively low default of 192 KiB for 64-bit processes on AIX. The
-# `AIXTHREAD_STK` environment variable provides a non-intrusive way to request
-# a larger pthread stack size for the tests. Various applications and runtime
-# libraries on AIX use a default pthread stack size of 4 MiB, so we will use
-# that as a default value here.
-if "AIXTHREAD_STK" in os.environ:
-    config.environment["AIXTHREAD_STK"] = os.environ["AIXTHREAD_STK"]
-elif platform.system() == "AIX":
-    config.environment["AIXTHREAD_STK"] = "4194304"
-
-# Some tools support an environment variable "OBJECT_MODE" on AIX OS, which
-# controls the kind of objects they will support. If there is no "OBJECT_MODE"
-# environment variable specified, the default behaviour is to support 32-bit
-# objects only. In order to not affect most test cases, which expect to support
-# 32-bit and 64-bit objects by default, set the environment variable
-# "OBJECT_MODE" to "any" by default on AIX OS.
-
-if "system-aix" in config.available_features:
-   config.substitutions.append(("llvm-nm", "env OBJECT_MODE=any llvm-nm"))
-   config.substitutions.append(("llvm-ar", "env OBJECT_MODE=any llvm-ar"))
-   config.substitutions.append(("llvm-ranlib", "env OBJECT_MODE=any 
llvm-ranlib"))
-
-# It is not realistically possible to account for all options that could
-# possibly be present in system and user configuration files, so disable
-# default configs for the test runs.
-config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
-
-if lit_config.update_tests:
-    import sys
-    import os
-
-    utilspath = os.path.join(config.llvm_src_root, "utils")
-    sys.path.append(utilspath)
-    from update_any_test_checks import utc_lit_plugin
-
-    lit_config.test_updaters.append(utc_lit_plugin)
+# -*- Python -*-
+
+import os
+import platform
+import re
+import subprocess
+import tempfile
+
+import lit.formats
+import lit.util
+
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst
+from lit.llvm.subst import FindTool
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = "Clang"
+
+# TODO: Consolidate the logic for turning on the internal shell by default for 
all LLVM test suites.
+# See https://github.com/llvm/llvm-project/issues/106636 for more details.
+#
+# We prefer the lit internal shell which provides a better user experience on 
failures
+# and is faster unless the user explicitly disables it with 
LIT_USE_INTERNAL_SHELL=0
+# env var.
+use_lit_shell = True
+lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
+if lit_shell_env:
+    use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
+
+# testFormat: The test format to use to interpret tests.
+#
+# For now we require '&&' between commands, until they get globally killed and
+# the test runner updated.
+config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = [
+    ".c",
+    ".cpp",
+    ".i",
+    ".cir",
+    ".cppm",
+    ".m",
+    ".mm",
+    ".cu",
+    ".cuh",
+    ".hip",
+    ".hlsl",
+    ".ll",
+    ".cl",
+    ".clcpp",
+    ".s",
+    ".S",
+    ".modulemap",
+    ".test",
+    ".rs",
+    ".ifs",
+    ".rc",
+]
+
+# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
+# subdirectories contain auxiliary inputs for various tests in their parent
+# directories.
+config.excludes = [
+    "Inputs",
+    "CMakeLists.txt",
+    "README.txt",
+    "LICENSE.txt",
+    "debuginfo-tests",
+]
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = os.path.join(config.clang_obj_root, "test")
+
+llvm_config.use_default_substitutions()
+
+llvm_config.use_clang()
+
+config.substitutions.append(("%src_dir", config.clang_src_dir))
+
+config.substitutions.append(("%src_include_dir", config.clang_src_dir + 
"/include"))
+
+config.substitutions.append(("%target_triple", config.target_triple))
+
+config.substitutions.append(("%PATH%", config.environment["PATH"]))
+
+
+# For each occurrence of a clang tool name, replace it with the full path to
+# the build directory holding that tool.  We explicitly specify the directories
+# to search to ensure that we get the tools just built and not some random
+# tools that might happen to be in the user's PATH.
+tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
+
+tools = [
+    "apinotes-test",
+    "c-index-test",
+    "cir-opt",
+    "clang-diff",
+    "clang-format",
+    "clang-repl",
+    "llvm-offload-binary",
+    "clang-tblgen",
+    "clang-scan-deps",
+    "clang-installapi",
+    "opt",
+    "llvm-ifs",
+    "yaml2obj",
+    "clang-linker-wrapper",
+    "clang-nvlink-wrapper",
+    "clang-sycl-linker",
+    "llvm-lto",
+    "llvm-lto2",
+    "llvm-profdata",
+    "llvm-readtapi",
+    ToolSubst(
+        "%clang_extdef_map",
+        command=FindTool("clang-extdef-mapping"),
+        unresolved="ignore",
+    ),
+]
+
+if config.clang_examples:
+    config.available_features.add("examples")
+
+
+def have_host_out_of_process_jit_feature_support():
+    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
+
+    if not clang_repl_exe:
+        return False
+
+    testcode = b"\n".join([b"int i = 0;", b"%quit"])
+
+    try:
+        clang_repl_cmd = subprocess.run(
+            [clang_repl_exe, "-orc-runtime", "-oop-executor"],
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            input=testcode,
+        )
+    except OSError:
+        return False
+
+    if clang_repl_cmd.returncode == 0:
+        return True
+
+    return False
+
+
+def run_clang_repl(args):
+    clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir)
+
+    if not clang_repl_exe:
+        return ""
+
+    try:
+        clang_repl_cmd = subprocess.Popen(
+            [clang_repl_exe, args], stdout=subprocess.PIPE
+        )
+    except OSError:
+        print("could not exec clang-repl")
+        return ""
+
+    clang_repl_out = clang_repl_cmd.stdout.read().decode("ascii")
+    clang_repl_cmd.wait()
+
+    return clang_repl_out
+
+
+def have_host_jit_feature_support(feature_name):
+    return "true" in run_clang_repl("--host-supports-" + feature_name)
+
+def have_host_clang_repl_cuda():
+    clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir)
+
+    if not clang_repl_exe:
+        return False
+
+    testcode = b'\n'.join([
+        b"__global__ void test_func() {}",
+        b"test_func<<<1,1>>>();",
+        b"extern \"C\" int puts(const char *s);",
+        b"puts(cudaGetLastError() ? \"failure\" : \"success\");",
+        b"%quit"
+    ])
+    try:
+        clang_repl_cmd = subprocess.run([clang_repl_exe, '--cuda'],
+                                        stdout=subprocess.PIPE,
+                                        stderr=subprocess.PIPE,
+                                        input=testcode)
+    except OSError:
+        return False
+
+    if clang_repl_cmd.returncode == 0:
+        if clang_repl_cmd.stdout.find(b"success") != -1:
+            return True
+
+    return False
+
+if have_host_jit_feature_support('jit'):
+    config.available_features.add('host-supports-jit')
+
+    if have_host_clang_repl_cuda():
+        config.available_features.add('host-supports-cuda')
+    hosttriple = run_clang_repl("--host-jit-triple")
+    config.substitutions.append(("%host-jit-triple", hosttriple.strip()))
+
+    if have_host_out_of_process_jit_feature_support():
+        config.available_features.add("host-supports-out-of-process-jit")
+
+if config.clang_staticanalyzer:
+    config.available_features.add("staticanalyzer")
+    tools.append("clang-check")
+
+    if config.clang_staticanalyzer_z3:
+        config.available_features.add("z3")
+        if config.clang_staticanalyzer_z3_mock:
+            config.available_features.add("z3-mock")
+    else:
+        config.available_features.add("no-z3")
+
+    check_analyzer_fixit_path = os.path.join(
+        config.test_source_root, "Analysis", "check-analyzer-fixit.py"
+    )
+    config.substitutions.append(
+        (
+            "%check_analyzer_fixit",
+            '"%s" %s' % (config.python_executable, check_analyzer_fixit_path),
+        )
+    )
+
+    csv2json_path = os.path.join(config.test_source_root, "Analysis", 
"csv2json.py")
+    config.substitutions.append(
+        (
+            "%csv2json",
+            '"%s" %s' % (config.python_executable, csv2json_path),
+        )
+    )
+
+# ClangIR support
+if config.clang_enable_cir:
+    config.available_features.add("cir-support")
+
+llvm_config.add_tool_substitutions(tools, tool_dirs)
+
+config.substitutions.append(
+    (
+        "%hmaptool",
+        "'%s' %s"
+        % (
+            config.python_executable,
+            os.path.join(config.clang_src_dir, "utils", "hmaptool", 
"hmaptool"),
+        ),
+    )
+)
+
+config.substitutions.append(
+    (
+        "%deps-to-rsp",
+        '"%s" %s'
+        % (
+            config.python_executable,
+            os.path.join(config.clang_src_dir, "utils", 
"module-deps-to-rsp.py"),
+        ),
+    )
+)
+
+# Determine whether the test target is compatible with execution on the host.
+if "aarch64" in config.host_arch:
+    config.available_features.add("aarch64-host")
+
+# Some tests are sensitive to whether clang is statically or dynamically linked
+# to other libraries.
+if not (config.build_shared_libs or config.link_llvm_dylib or 
config.link_clang_dylib):
+    config.available_features.add("static-libs")
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+    config.available_features.add("plugins")
+
+if config.clang_default_pie_on_linux:
+    config.available_features.add("default-pie-on-linux")
+
+# Set available features we allow tests to conditionalize on.
+#
+if config.clang_default_cxx_stdlib != "":
+    config.available_features.add(
+        "default-cxx-stdlib={}".format(config.clang_default_cxx_stdlib)
+    )
+
+# As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
+if platform.system() not in ["FreeBSD"]:
+    config.available_features.add("crash-recovery")
+
+# ANSI escape sequences in non-dumb terminal
+if platform.system() not in ["Windows"]:
+    config.available_features.add("ansi-escape-sequences")
+
+# Capability to print utf8 to the terminal.
+# Windows expects codepage, unless Wide API.
+if platform.system() not in ["Windows"]:
+    config.available_features.add("utf8-capable-terminal")
+
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ["Darwin", "Fuchsia"]:
+    config.available_features.add("libgcc")
+
+# Case-insensitive file system
+
+
+def is_filesystem_case_insensitive():
+    os.makedirs(config.test_exec_root, exist_ok=True)
+    handle, path = tempfile.mkstemp(prefix="case-test", 
dir=config.test_exec_root)
+    isInsensitive = os.path.exists(
+        os.path.join(os.path.dirname(path), os.path.basename(path).upper())
+    )
+    os.close(handle)
+    os.remove(path)
+    return isInsensitive
+
+
+if is_filesystem_case_insensitive():
+    config.available_features.add("case-insensitive-filesystem")
+
+# Tests that require the /dev/fd filesystem.
+if os.path.exists("/dev/fd/0") and sys.platform not in ["cygwin"]:
+    config.available_features.add("dev-fd-fs")
+
+# Set on native MS environment.
+if re.match(r".*-(windows-msvc)$", config.target_triple):
+    config.available_features.add("ms-sdk")
+
+# [PR8833] LLP64-incompatible tests
+if not re.match(
+    r"^(aarch64|arm64ec|x86_64).*-(windows-msvc|windows-gnu)$", 
config.target_triple
+):
+    config.available_features.add("LP64")
+
+# Tests that are specific to the Apple Silicon macOS.
+if re.match(r"^arm64(e)?-apple-(macos|darwin)", config.target_triple):
+    config.available_features.add("apple-silicon-mac")
+
+# [PR18856] Depends to remove opened file. On win32, a file could be removed
+# only if all handles were closed.
+if platform.system() not in ["Windows"]:
+    config.available_features.add("can-remove-opened-file")
+
+# Features
+known_arches = ["x86_64", "mips64", "ppc64", "aarch64"]
+if any(config.target_triple.startswith(x) for x in known_arches):
+    config.available_features.add("clang-target-64-bits")
+
+
+def calculate_arch_features(arch_string):
+    features = []
+    for arch in arch_string.split():
+        features.append(arch.lower() + "-registered-target")
+    return features
+
+
+llvm_config.feature_config(
+    [
+        ("--assertion-mode", {"ON": "asserts"}),
+        ("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),
+        ("--targets-built", calculate_arch_features),
+    ]
+)
+
+if lit.util.which("xmllint"):
+    config.available_features.add("xmllint")
+
+if config.enable_backtrace:
+    config.available_features.add("backtrace")
+
+if config.enable_threads:
+    config.available_features.add("thread_support")
+
+# Check if we should allow outputs to console.
+run_console_tests = int(lit_config.params.get("enable_console", "0"))
+if run_console_tests != 0:
+    config.available_features.add("console")
+
+lit.util.usePlatformSdkOnDarwin(config, lit_config)
+macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
+if macOSSDKVersion is not None:
+    config.available_features.add("macos-sdk-" + str(macOSSDKVersion))
+
+if os.path.exists("/etc/gentoo-release"):
+    config.available_features.add("gentoo")
+
+if config.enable_shared:
+    config.available_features.add("enable_shared")
+
+# Add a vendor-specific feature.
+if config.clang_vendor_uti:
+    config.available_features.add("clang-vendor=" + config.clang_vendor_uti)
+
+if config.have_llvm_driver:
+    config.available_features.add("llvm-driver")
+
+
+# Some tests perform deep recursion, which requires a larger pthread stack size
+# than the relatively low default of 192 KiB for 64-bit processes on AIX. The
+# `AIXTHREAD_STK` environment variable provides a non-intrusive way to request
+# a larger pthread stack size for the tests. Various applications and runtime
+# libraries on AIX use a default pthread stack size of 4 MiB, so we will use
+# that as a default value here.
+if "AIXTHREAD_STK" in os.environ:
+    config.environment["AIXTHREAD_STK"] = os.environ["AIXTHREAD_STK"]
+elif platform.system() == "AIX":
+    config.environment["AIXTHREAD_STK"] = "4194304"
+
+# Some tools support an environment variable "OBJECT_MODE" on AIX OS, which
+# controls the kind of objects they will support. If there is no "OBJECT_MODE"
+# environment variable specified, the default behaviour is to support 32-bit
+# objects only. In order to not affect most test cases, which expect to support
+# 32-bit and 64-bit objects by default, set the environment variable
+# "OBJECT_MODE" to "any" by default on AIX OS.
+
+if "system-aix" in config.available_features:
+   config.substitutions.append(("llvm-nm", "env OBJECT_MODE=any llvm-nm"))
+   config.substitutions.append(("llvm-ar", "env OBJECT_MODE=any llvm-ar"))
+   config.substitutions.append(("llvm-ranlib", "env OBJECT_MODE=any 
llvm-ranlib"))
+
+# It is not realistically possible to account for all options that could
+# possibly be present in system and user configuration files, so disable
+# default configs for the test runs.
+config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
+
+if lit_config.update_tests:
+    import sys
+    import os
+
+    utilspath = os.path.join(config.llvm_src_root, "utils")
+    sys.path.append(utilspath)
+    from update_any_test_checks import utc_lit_plugin
+
+    lit_config.test_updaters.append(utc_lit_plugin)

>From 608ee13a646dacbb83393f8d75611c8105289432 Mon Sep 17 00:00:00 2001
From: Priyanshu Kumar <[email protected]>
Date: Thu, 11 Dec 2025 19:27:20 +0000
Subject: [PATCH 10/10] Update test

---
 .../CodeGenBuiltins/X86/cir-convert-half.c    | 99 ++++++++-----------
 1 file changed, 41 insertions(+), 58 deletions(-)

diff --git a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c 
b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
index 09c08ef06a133..29ed56e154a7b 100644
--- a/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
+++ b/clang/test/CIR/CodeGenBuiltins/X86/cir-convert-half.c
@@ -1,84 +1,67 @@
-// Test X86-specific convert_half builtins
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-cir %s -o - | FileCheck 
%s --check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -emit-llvm %s -o - | FileCheck %s 
--check-prefix=LLVM
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -emit-llvm %s -o - | FileCheck %s 
--check-prefix=OGCG
 
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -fclangir -emit-llvm %s -o %t-cir.ll
-// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -emit-llvm %s -o %t.ll
-// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
+// REQUIRES: avx512fp16
+// REQUIRES: avx512bf16
+
+#include <stdint.h>
+#ifndef __bf16
+typedef uint16_t __bf16;
+#endif
 
 typedef float __m512 __attribute__((__vector_size__(64), __aligned__(64)));
 typedef float __m256 __attribute__((__vector_size__(32), __aligned__(32)));
 typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
-typedef int __m256i __attribute__((__vector_size__(32), __aligned__(32)));
-typedef int __m128i __attribute__((__vector_size__(16), __aligned__(16)));
 typedef int __mmask16;
-typedef unsigned char __mmask8;
-typedef __bf16 __m256bh __attribute__((__vector_size__(32), __aligned__(32)));
-typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
+typedef int __mmask8;
+typedef short __m256i __attribute__((__vector_size__(32), __aligned__(32)));
+typedef short __m128i __attribute__((__vector_size__(16), __aligned__(16)));
 
-// Test __builtin_ia32_vcvtph2ps512_mask
+// CIR-LABEL: test_vcvtph2ps512_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.512"
+// LLVM-LABEL: test_vcvtph2ps512_mask
+// OGCG-LABEL: test_vcvtph2ps512_mask
 __m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k) {
   return __builtin_ia32_vcvtph2ps512_mask(a, src, k, 4);
 }
-// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps512_mask
-// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.512"
-// LLVM-LABEL: define {{.*}} @test_vcvtph2ps512_mask
-// LLVM: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
-// OGCG-LABEL: define {{.*}} @test_vcvtph2ps512_mask
-// OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512
 
-// Test __builtin_ia32_vcvtph2ps256_mask
+// CIR-LABEL: test_vcvtph2ps256_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.256"
+// LLVM-LABEL: test_vcvtph2ps256_mask
+// OGCG-LABEL: test_vcvtph2ps256_mask
 __m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k) {
   return __builtin_ia32_vcvtph2ps256_mask(a, src, k);
 }
-// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps256_mask
-// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.256"
-// LLVM-LABEL: define {{.*}} @test_vcvtph2ps256_mask
-// LLVM: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
-// OGCG-LABEL: define {{.*}} @test_vcvtph2ps256_mask
-// OGCG: call <8 x float> @llvm.x86.avx512.mask.vcvtph2ps.256
 
-// Test __builtin_ia32_vcvtph2ps_mask
+// CIR-LABEL: test_vcvtph2ps_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.128"
+// LLVM-LABEL: test_vcvtph2ps_mask
+// OGCG-LABEL: test_vcvtph2ps_mask
 __m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) {
   return __builtin_ia32_vcvtph2ps_mask(a, src, k);
 }
-// CIR-LABEL: cir.func {{.*}}@test_vcvtph2ps_mask
-// CIR: cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.128"
-// LLVM-LABEL: define {{.*}} @test_vcvtph2ps_mask
-// LLVM: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
-// OGCG-LABEL: define {{.*}} @test_vcvtph2ps_mask
-// OGCG: call <4 x float> @llvm.x86.avx512.mask.vcvtph2ps.128
 
-// Test __builtin_ia32_cvtneps2bf16_512_mask
-__m256bh test_cvtneps2bf16_512_mask(__m512 a, __m256bh w, __mmask16 u) {
+// CIR-LABEL: test_cvtneps2bf16_512_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512bf16.cvtneps2bf16.512"
+// LLVM-LABEL: test_cvtneps2bf16_512_mask
+// OGCG-LABEL: test_cvtneps2bf16_512_mask
+__bf16 test_cvtneps2bf16_512_mask(__m512 a, __bf16 w, __mmask16 u) {
   return __builtin_ia32_cvtneps2bf16_512_mask(a, w, u);
 }
-// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_512_mask
-// CIR: cir.call_llvm_intrinsic "x86.avx512bf16.cvtneps2bf16.512"
-// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
-// LLVM: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
-// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_512_mask
-// OGCG: call <32 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512
 
-// Test __builtin_ia32_cvtneps2bf16_256_mask
-__m128bh test_cvtneps2bf16_256_mask(__m256 a, __m128bh w, __mmask8 u) {
+// CIR-LABEL: test_cvtneps2bf16_256_mask
+// CIR: cir.call_llvm_intrinsic "x86.avx512bf16.cvtneps2bf16.256"
+// LLVM-LABEL: test_cvtneps2bf16_256_mask
+// OGCG-LABEL: test_cvtneps2bf16_256_mask
+__bf16 test_cvtneps2bf16_256_mask(__m256 a, __bf16 w, __mmask8 u) {
   return __builtin_ia32_cvtneps2bf16_256_mask(a, w, u);
 }
-// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_256_mask
-// CIR: cir.call_llvm_intrinsic "x86.avx512bf16.cvtneps2bf16.256"
-// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
-// LLVM: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
-// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_256_mask
-// OGCG: call <16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256
 
-// Test __builtin_ia32_cvtneps2bf16_128_mask
-__m128bh test_cvtneps2bf16_128_mask(__m128 a, __m128bh w, __mmask8 u) {
-  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u);
-}
-// CIR-LABEL: cir.func {{.*}}@test_cvtneps2bf16_128_mask
+// CIR-LABEL: test_cvtneps2bf16_128_mask
 // CIR: cir.call_llvm_intrinsic "x86.avx512bf16.mask.cvtneps2bf16.128"
-// LLVM-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
-// LLVM: call <8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
-// OGCG-LABEL: define {{.*}} @test_cvtneps2bf16_128_mask
-// OGCG: call <8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
\ No newline at end of file
+// LLVM-LABEL: test_cvtneps2bf16_128_mask
+// OGCG-LABEL: test_cvtneps2bf16_128_mask
+__bf16 test_cvtneps2bf16_128_mask(__m128 a, __bf16 w, __mmask8 u) {
+  return __builtin_ia32_cvtneps2bf16_128_mask(a, w, u);
+}
\ No newline at end of file

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

Reply via email to