Author: Timm Baeder
Date: 2024-10-08T13:30:40+02:00
New Revision: 235067b222e4734839b963e152b6554e20413d11

URL: 
https://github.com/llvm/llvm-project/commit/235067b222e4734839b963e152b6554e20413d11
DIFF: 
https://github.com/llvm/llvm-project/commit/235067b222e4734839b963e152b6554e20413d11.diff

LOG: [clang][bytecode] Make sure ia32_bzhi input is an integer (#111505)

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/InterpBuiltin.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 72c94e6fad3e0d..98381254886e29 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;
 }
 
@@ -1223,7 +1227,7 @@ static bool interp__builtin_ia32_tzcnt(InterpState &S, 
CodePtr OpPC,
     return false;
 
   APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
-  pushInteger(S, Val.countTrailingZeros(), Call->getType());
+  pushInteger(S, Val.countTrailingZeros(), CallType);
   return true;
 }
 


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

Reply via email to