[clang] [clang][bytecode] Check ia32_{pext, pdep} builtins for integer args (PR #113091)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 20 09:13:01 PDT 2024


https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/113091

>From e947bb4ef9a80f2ba730238e668d9ea732bf40fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sun, 20 Oct 2024 18:08:08 +0200
Subject: [PATCH] [clang][bytecode] Check ia32_{pext,pdep} builtins for integer
 args

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index d4a8e6c2035ee5..0db03714f128ba 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1331,6 +1331,9 @@ static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC,
                                       const InterpFrame *Frame,
                                       const Function *Func,
                                       const CallExpr *Call) {
+  if (!Call->getArg(0)->isIntegerType() || !Call->getArg(1)->isIntegerType())
+    return false;
+
   PrimType ValT = *S.Ctx.classify(Call->getArg(0));
   PrimType MaskT = *S.Ctx.classify(Call->getArg(1));
 
@@ -1352,6 +1355,9 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC,
                                       const InterpFrame *Frame,
                                       const Function *Func,
                                       const CallExpr *Call) {
+  if (!Call->getArg(0)->isIntegerType() || !Call->getArg(1)->isIntegerType())
+    return false;
+
   PrimType ValT = *S.Ctx.classify(Call->getArg(0));
   PrimType MaskT = *S.Ctx.classify(Call->getArg(1));
 



More information about the cfe-commits mailing list