https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/142720

None

>From 22f7f0a3b1a5b740377ce56ea0532b6d4a866aa0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com>
Date: Wed, 4 Jun 2025 07:05:29 +0200
Subject: [PATCH] [clang][bytecode][NFC] Cache more integer type sizes

---
 clang/lib/AST/ByteCode/Context.cpp | 12 ++++++++++++
 clang/lib/AST/ByteCode/Context.h   |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Context.cpp 
b/clang/lib/AST/ByteCode/Context.cpp
index 6b8f4e31e4ff9..d73705b6126fe 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -22,8 +22,10 @@ using namespace clang;
 using namespace clang::interp;
 
 Context::Context(ASTContext &Ctx) : Ctx(Ctx), P(new Program(*this)) {
+  this->ShortWidth = Ctx.getTargetInfo().getShortWidth();
   this->IntWidth = Ctx.getTargetInfo().getIntWidth();
   this->LongWidth = Ctx.getTargetInfo().getLongWidth();
+  this->LongLongWidth = Ctx.getTargetInfo().getLongLongWidth();
   assert(Ctx.getTargetInfo().getCharWidth() == 8 &&
          "We're assuming 8 bit chars");
 }
@@ -265,6 +267,11 @@ std::optional<PrimType> Context::classify(QualType T) 
const {
       return PT_MemberPtr;
 
     // Just trying to avoid the ASTContext::getIntWidth call below.
+    if (Kind == BuiltinType::Short)
+      return integralTypeToPrimTypeS(this->ShortWidth);
+    if (Kind == BuiltinType::UShort)
+      return integralTypeToPrimTypeU(this->ShortWidth);
+
     if (Kind == BuiltinType::Int)
       return integralTypeToPrimTypeS(this->IntWidth);
     if (Kind == BuiltinType::UInt)
@@ -273,6 +280,11 @@ std::optional<PrimType> Context::classify(QualType T) 
const {
       return integralTypeToPrimTypeS(this->LongWidth);
     if (Kind == BuiltinType::ULong)
       return integralTypeToPrimTypeU(this->LongWidth);
+    if (Kind == BuiltinType::LongLong)
+      return integralTypeToPrimTypeS(this->LongLongWidth);
+    if (Kind == BuiltinType::ULongLong)
+      return integralTypeToPrimTypeU(this->LongLongWidth);
+
     if (Kind == BuiltinType::SChar || Kind == BuiltinType::Char_S)
       return integralTypeToPrimTypeS(8);
     if (Kind == BuiltinType::UChar || Kind == BuiltinType::Char_U ||
diff --git a/clang/lib/AST/ByteCode/Context.h b/clang/lib/AST/ByteCode/Context.h
index 9a604ce8ebbe9..5898ab5e54599 100644
--- a/clang/lib/AST/ByteCode/Context.h
+++ b/clang/lib/AST/ByteCode/Context.h
@@ -138,8 +138,10 @@ class Context final {
   /// ID identifying an evaluation.
   unsigned EvalID = 0;
   /// Cached widths (in bits) of common types, for a faster classify().
+  unsigned ShortWidth;
   unsigned IntWidth;
   unsigned LongWidth;
+  unsigned LongLongWidth;
 };
 
 } // namespace interp

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

Reply via email to