Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anematode
Copy link
Contributor

Fixes #144857 . I can create a test if desired, but I think the fix is trivial enough.

image

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 20, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 20, 2025

@llvm/pr-subscribers-clang

Author: Timothy Herchen (anematode)

Changes

Fixes #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" />


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

1 Files Affected:

  • (modified) clang/lib/Sema/SemaX86.cpp (+5)
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

@llvmbot
Copy link
Member

llvmbot commented Jul 20, 2025

@llvm/pr-subscribers-backend-x86

Author: Timothy Herchen (anematode)

Changes

Fixes #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" />


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

1 Files Affected:

  • (modified) clang/lib/Sema/SemaX86.cpp (+5)
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

@phoebewang
Copy link
Contributor

Thanks for the patch! You can add a test case for it like clang/test/CodeGen/X86/sm3-error.c

@RKSimon RKSimon requested a review from phoebewang July 21, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[llvm] LLVM backend crashes when using __builtin_ia32_prefetchi
3 participants