aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/InterpBuiltin.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-28 17:44:19 +0200
committerGitHub <noreply@github.com>2025-04-28 17:44:19 +0200
commitc52fdbe697eb0eee2484c5bf1aeb17d678430830 (patch)
treeb8243d82e1da751810b37085b70ca5849dbf92d2 /clang/lib/AST/ByteCode/InterpBuiltin.cpp
parentd7e631c7cd6d9c13b9519991ec6becf08bc6b8aa (diff)
downloadllvm-c52fdbe697eb0eee2484c5bf1aeb17d678430830.zip
llvm-c52fdbe697eb0eee2484c5bf1aeb17d678430830.tar.gz
llvm-c52fdbe697eb0eee2484c5bf1aeb17d678430830.tar.bz2
[clang][bytecode] Fix ia32_addcarry/subborrow (#137642)
RHS is followed by another Pointer.
Diffstat (limited to 'clang/lib/AST/ByteCode/InterpBuiltin.cpp')
-rw-r--r--clang/lib/AST/ByteCode/InterpBuiltin.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 34baae1..e3d7632 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;