[Lldb-commits] [lldb] fcf4e25 - [LLDB][NFC] Create variable for hardcoded alignment/size constants in materializer

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 22 00:02:49 PDT 2022


Author: Michael Buch
Date: 2022-07-22T08:02:07+01:00
New Revision: fcf4e252f4d992cade4bdfe5aed10ff96fa40202

URL: https://github.com/llvm/llvm-project/commit/fcf4e252f4d992cade4bdfe5aed10ff96fa40202
DIFF: https://github.com/llvm/llvm-project/commit/fcf4e252f4d992cade4bdfe5aed10ff96fa40202.diff

LOG: [LLDB][NFC] Create variable for hardcoded alignment/size constants in materializer

Added: 
    

Modified: 
    lldb/source/Expression/Materializer.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index 965a96b7f909d..8c7e74b6e51e5 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -27,6 +27,14 @@
 
 using namespace lldb_private;
 
+// FIXME: these should be retrieved from the target
+//        instead of being hard-coded. Currently we
+//        assume that persistent vars are materialized
+//        as references, and thus pick the size of a
+//        64-bit pointer.
+static constexpr uint32_t g_default_var_alignment = 8;
+static constexpr uint32_t g_default_var_byte_size = 8;
+
 uint32_t Materializer::AddStructMember(Entity &entity) {
   uint32_t size = entity.GetSize();
   uint32_t alignment = entity.GetAlignment();
@@ -54,8 +62,8 @@ class EntityPersistentVariable : public Materializer::Entity {
         m_delegate(delegate) {
     // Hard-coding to maximum size of a pointer since persistent variables are
     // materialized by reference
-    m_size = 8;
-    m_alignment = 8;
+    m_size = g_default_var_byte_size;
+    m_alignment = g_default_var_alignment;
   }
 
   void MakeAllocation(IRMemoryMap &map, Status &err) {
@@ -418,8 +426,8 @@ class EntityVariable : public Materializer::Entity {
       : Entity(), m_variable_sp(variable_sp) {
     // Hard-coding to maximum size of a pointer since all variables are
     // materialized by reference
-    m_size = 8;
-    m_alignment = 8;
+    m_size = g_default_var_byte_size;
+    m_alignment = g_default_var_alignment;
     m_is_reference =
         m_variable_sp->GetType()->GetForwardCompilerType().IsReferenceType();
   }
@@ -772,8 +780,8 @@ class EntityResultVariable : public Materializer::Entity {
         m_keep_in_memory(keep_in_memory), m_delegate(delegate) {
     // Hard-coding to maximum size of a pointer since all results are
     // materialized by reference
-    m_size = 8;
-    m_alignment = 8;
+    m_size = g_default_var_byte_size;
+    m_alignment = g_default_var_alignment;
   }
 
   void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
@@ -1050,8 +1058,8 @@ class EntitySymbol : public Materializer::Entity {
 public:
   EntitySymbol(const Symbol &symbol) : Entity(), m_symbol(symbol) {
     // Hard-coding to maximum size of a symbol
-    m_size = 8;
-    m_alignment = 8;
+    m_size = g_default_var_byte_size;
+    m_alignment = g_default_var_alignment;
   }
 
   void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,


        


More information about the lldb-commits mailing list