[clang] [clang][bytecode] Make sure ia32_bzhi input is an integer (PR #111505)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 01:58:57 PDT 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/111505
None
>From 0194defe73dc816fa3993235eac84cb5571e4582 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 8 Oct 2024 10:57:14 +0200
Subject: [PATCH] [clang][bytecode] Make sure ia32_bzhi input is an integer
---
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 72c94e6fad3e0d..c328466703841f 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1184,6 +1184,10 @@ static bool interp__builtin_ia32_bzhi(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
const CallExpr *Call) {
+ QualType CallType = Call->getType();
+ if (!CallType->isIntegerType())
+ return false;
+
PrimType ValT = *S.Ctx.classify(Call->getArg(0));
PrimType IndexT = *S.Ctx.classify(Call->getArg(1));
@@ -1197,7 +1201,7 @@ static bool interp__builtin_ia32_bzhi(InterpState &S, CodePtr OpPC,
if (Index < BitWidth)
Val.clearHighBits(BitWidth - Index);
- pushInteger(S, Val, Call->getType());
+ pushInteger(S, Val, CallType);
return true;
}
@@ -1210,7 +1214,7 @@ static bool interp__builtin_ia32_lzcnt(InterpState &S, CodePtr OpPC,
return false;
APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
- pushInteger(S, Val.countLeadingZeros(), Call->getType());
+ pushInteger(S, Val.countLeadingZeros(), CallType);
return true;
}
More information about the cfe-commits
mailing list