https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/202873
We only need to get the bitwdith in the IntAP/IntAPS case, so avoid it in the others. >From 7e110356e4eae092bff7098beeccc9f602b93de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Wed, 10 Jun 2026 09:08:53 +0200 Subject: [PATCH] [clang][bytecode][NFC] Avoid a getIntWidth() call in pushInteger() We only need to get the bitwdith in the IntAP/IntAPS case, so avoid it in the others. --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 7bb1372ff202c..08fc8252d0708 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -94,11 +94,11 @@ static bool isReadable(const Pointer &P) { static void pushInteger(InterpState &S, const APSInt &Val, QualType QT) { assert(QT->isSignedIntegerOrEnumerationType() || QT->isUnsignedIntegerOrEnumerationType()); - OptPrimType T = S.getContext().classify(QT); + OptPrimType T = *S.getContext().classify(QT); assert(T); - unsigned BitWidth = S.getASTContext().getIntWidth(QT); if (T == PT_IntAPS) { + unsigned BitWidth = S.getASTContext().getIntWidth(QT); auto Result = S.allocAP<IntegralAP<true>>(BitWidth); Result.copy(Val); S.Stk.push<IntegralAP<true>>(Result); @@ -106,6 +106,7 @@ static void pushInteger(InterpState &S, const APSInt &Val, QualType QT) { } if (T == PT_IntAP) { + unsigned BitWidth = S.getASTContext().getIntWidth(QT); auto Result = S.allocAP<IntegralAP<false>>(BitWidth); Result.copy(Val); S.Stk.push<IntegralAP<false>>(Result); @@ -114,11 +115,11 @@ static void pushInteger(InterpState &S, const APSInt &Val, QualType QT) { if (QT->isSignedIntegerOrEnumerationType()) { int64_t V = Val.getSExtValue(); - INT_TYPE_SWITCH(*T, { S.Stk.push<T>(T::from(V, BitWidth)); }); + INT_TYPE_SWITCH(*T, { S.Stk.push<T>(T::from(V)); }); } else { assert(QT->isUnsignedIntegerOrEnumerationType()); uint64_t V = Val.getZExtValue(); - INT_TYPE_SWITCH(*T, { S.Stk.push<T>(T::from(V, BitWidth)); }); + INT_TYPE_SWITCH(*T, { S.Stk.push<T>(T::from(V)); }); } } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
