[clang] [clang] [Sema] Check argument range for prefetchi* intrinsics (PR #149745)

Timothy Herchen via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 20 16:29:19 PDT 2025


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

Fixes https://github.com/llvm/llvm-project/issues/144857 . I can create a test if desired, but I think the fix is trivial enough.

<img width="805" height="105" alt="image" src="https://github.com/user-attachments/assets/aaee8e5f-6e65-4f04-b8b9-e4ae1434d958" />


>From d36dcec834f1846f050b89650b31bee4e138ddc3 Mon Sep 17 00:00:00 2001
From: Timothy Herchen <timothy.herchen at gmail.com>
Date: Sun, 20 Jul 2025 16:11:22 -0700
Subject: [PATCH] [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



More information about the cfe-commits mailing list