https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/137642
RHS is followed by another Pointer. >From c2ac52ac1ec9abd64576c92a2a2ea7780ab59f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Mon, 28 Apr 2025 16:44:52 +0200 Subject: [PATCH] [clang][bytecode] Fix ia32_addcarry/subborrow RHS is followed by another Pointer. --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 34baae1986c35..e3d76326db44b 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1413,6 +1413,7 @@ static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, return true; } +/// (CarryIn, LHS, RHS, Result) static bool interp__builtin_ia32_addcarry_subborrow(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, @@ -1423,16 +1424,17 @@ static bool interp__builtin_ia32_addcarry_subborrow(InterpState &S, !Call->getArg(2)->getType()->isIntegerType()) return false; - APSInt CarryIn = peekToAPSInt( - S.Stk, *S.getContext().classify(Call->getArg(0)), - align(primSize(*S.getContext().classify(Call->getArg(2)))) + - align(primSize(*S.getContext().classify(Call->getArg(1)))) + - align(primSize(*S.getContext().classify(Call->getArg(0))))); + PrimType CarryInT = *S.getContext().classify(Call->getArg(0)); + PrimType LHST = *S.getContext().classify(Call->getArg(1)); + PrimType RHST = *S.getContext().classify(Call->getArg(2)); + unsigned PtrSize = align(primSize(PT_Ptr)); + APSInt CarryIn = + peekToAPSInt(S.Stk, CarryInT, + PtrSize + align(primSize(RHST)) + align(primSize(LHST)) + + align(primSize(CarryInT))); APSInt LHS = peekToAPSInt( - S.Stk, *S.getContext().classify(Call->getArg(1)), - align(primSize(*S.getContext().classify(Call->getArg(2)))) + - align(primSize(*S.getContext().classify(Call->getArg(1))))); - APSInt RHS = peekToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(2))); + S.Stk, LHST, PtrSize + align(primSize(RHST)) + align(primSize(LHST))); + APSInt RHS = peekToAPSInt(S.Stk, RHST, PtrSize + align(primSize(RHST))); bool IsAdd = BuiltinOp == clang::X86::BI__builtin_ia32_addcarryx_u32 || BuiltinOp == clang::X86::BI__builtin_ia32_addcarryx_u64; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits