[clang] [clang][bytecode][NFC] Avoid a getIntWidth() call in pushInteger() (PR #202873)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 10 00:11:01 PDT 2026
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?= <tbaeder at redhat.com>
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)); });
}
}
More information about the cfe-commits
mailing list