https://github.com/anematode updated 
https://github.com/llvm/llvm-project/pull/149745

>From d36dcec834f1846f050b89650b31bee4e138ddc3 Mon Sep 17 00:00:00 2001
From: Timothy Herchen <timothy.herc...@gmail.com>
Date: Sun, 20 Jul 2025 16:11:22 -0700
Subject: [PATCH 1/2] [clang] [Sema] Check argument range for prefetchi*
 intrinsics

---
 clang/lib/Sema/SemaX86.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaX86.cpp b/clang/lib/Sema/SemaX86.cpp
index 5c149bdec7073..6bb3558972126 100644
--- a/clang/lib/Sema/SemaX86.cpp
+++ b/clang/lib/Sema/SemaX86.cpp
@@ -954,6 +954,11 @@ bool SemaX86::CheckBuiltinFunctionCall(const TargetInfo 
&TI, unsigned BuiltinID,
     l = 0;
     u = 15;
     break;
+  case X86::BI__builtin_ia32_prefetchi:
+    i = 1;
+    l = 2; // _MM_HINT_T1
+    u = 3; // _MM_HINT_T0
+    break;
   }
 
   // Note that we don't force a hard error on the range check here, allowing

>From fd1bba66a01ca74dbeb215486d3b2294708db5cc Mon Sep 17 00:00:00 2001
From: Timothy Herchen <timothy.herc...@gmail.com>
Date: Mon, 21 Jul 2025 21:20:03 -0700
Subject: [PATCH 2/2] add test

---
 clang/test/CodeGen/X86/prefetchi-error.c | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 clang/test/CodeGen/X86/prefetchi-error.c

diff --git a/clang/test/CodeGen/X86/prefetchi-error.c 
b/clang/test/CodeGen/X86/prefetchi-error.c
new file mode 100644
index 0000000000000..31494f7cff152
--- /dev/null
+++ b/clang/test/CodeGen/X86/prefetchi-error.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown 
-target-feature +prefetchi  -fsyntax-only -verify
+
+#include <immintrin.h>
+
+void test_invalid_prefetchi(void* p) {
+  __builtin_ia32_prefetchi(p, 1); // expected-error {{argument value 1 is 
outside the valid range [2, 3]}}
+}

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

Reply via email to