[Lldb-commits] [lldb] r369198 - [lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariable

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Sat Aug 17 14:57:51 PDT 2019


Author: teemperor
Date: Sat Aug 17 14:57:51 2019
New Revision: 369198

URL: http://llvm.org/viewvc/llvm-project?rev=369198&view=rev
Log:
[lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariable

Modified:
    lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
    lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=369198&r1=369197&r2=369198&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Sat Aug 17 14:57:51 2019
@@ -1180,71 +1180,6 @@ bool IRForTarget::RewritePersistentAlloc
   return true;
 }
 
-bool IRForTarget::MaterializeInitializer(uint8_t *data, Constant *initializer) {
-  if (!initializer)
-    return true;
-
-  lldb_private::Log *log(
-      lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
-  LLDB_LOGV(log, "  MaterializeInitializer({0}, {1})", (void *)data,
-            PrintValue(initializer));
-
-  Type *initializer_type = initializer->getType();
-
-  if (ConstantInt *int_initializer = dyn_cast<ConstantInt>(initializer)) {
-    size_t constant_size = m_target_data->getTypeStoreSize(initializer_type);
-    lldb_private::Scalar scalar = int_initializer->getValue().zextOrTrunc(
-        llvm::NextPowerOf2(constant_size) * 8);
-
-    lldb_private::Status get_data_error;
-    return scalar.GetAsMemoryData(data, constant_size,
-                                  lldb_private::endian::InlHostByteOrder(),
-                                  get_data_error) != 0;
-  } else if (ConstantDataArray *array_initializer =
-                 dyn_cast<ConstantDataArray>(initializer)) {
-    if (array_initializer->isString()) {
-      std::string array_initializer_string = array_initializer->getAsString();
-      memcpy(data, array_initializer_string.c_str(),
-             m_target_data->getTypeStoreSize(initializer_type));
-    } else {
-      ArrayType *array_initializer_type = array_initializer->getType();
-      Type *array_element_type = array_initializer_type->getElementType();
-
-      size_t element_size = m_target_data->getTypeAllocSize(array_element_type);
-
-      for (unsigned i = 0; i < array_initializer->getNumOperands(); ++i) {
-        Value *operand_value = array_initializer->getOperand(i);
-        Constant *operand_constant = dyn_cast<Constant>(operand_value);
-
-        if (!operand_constant)
-          return false;
-
-        if (!MaterializeInitializer(data + (i * element_size),
-                                    operand_constant))
-          return false;
-      }
-    }
-    return true;
-  } else if (ConstantStruct *struct_initializer =
-                 dyn_cast<ConstantStruct>(initializer)) {
-    StructType *struct_initializer_type = struct_initializer->getType();
-    const StructLayout *struct_layout =
-        m_target_data->getStructLayout(struct_initializer_type);
-
-    for (unsigned i = 0; i < struct_initializer->getNumOperands(); ++i) {
-      if (!MaterializeInitializer(data + struct_layout->getElementOffset(i),
-                                  struct_initializer->getOperand(i)))
-        return false;
-    }
-    return true;
-  } else if (isa<ConstantAggregateZero>(initializer)) {
-    memset(data, 0, m_target_data->getTypeStoreSize(initializer_type));
-    return true;
-  }
-  return false;
-}
-
 // This function does not report errors; its callers are responsible.
 bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
   lldb_private::Log *log(

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h?rev=369198&r1=369197&r2=369198&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h Sat Aug 17 14:57:51 2019
@@ -332,27 +332,6 @@ private:
   /// a call to a function pointer whose value is the address of the function
   /// in the target process.
 
-  /// Write an initializer to a memory array of assumed sufficient size.
-  ///
-  /// \param[in] data
-  ///     A pointer to the data to write to.
-  ///
-  /// \param[in] initializer
-  ///     The initializer itself.
-  ///
-  /// \return
-  ///     True on success; false otherwise
-  bool MaterializeInitializer(uint8_t *data, llvm::Constant *initializer);
-
-  /// Move an internal variable into the static allocation section.
-  ///
-  /// \param[in] global_variable
-  ///     The variable.
-  ///
-  /// \return
-  ///     True on success; false otherwise
-  bool MaterializeInternalVariable(llvm::GlobalVariable *global_variable);
-
   /// Handle a single externally-defined variable
   ///
   /// \param[in] value




More information about the lldb-commits mailing list