How to extend LLVM's ExecutionEngine::LoadValueFromMemory to support loading aggregate types like structs?

Hi,
I’m working with LLVM’s ExecutionEngine and encountering a fatal error when trying to load a struct value from memory using LoadValueFromMemory. The error message is something like “Cannot load value of type %struct.MyStruct!”, which points to the default case in the switch statement.

Looking at the source code (from LLVM’s lib/ExecutionEngine/Interpreter/Execution.cpp or similar), the function handles basic types like integers, floats, doubles, pointers, and fixed vectors, but doesn’t support aggregate types such as structs. Here’s the relevant part of the switch:

switch (Ty->getTypeID()) {
case Type::IntegerTyID:
  // ... loads int
  break;
case Type::FloatTyID:
  // ... loads float
  break;
// ... other cases for Double, Pointer, X86_FP80, ScalableVector, FixedVector
default:
  SmallString<256> Msg;
  raw_svector_ostream OS(Msg);
  OS << "Cannot load value of type " << *Ty << "!";
  report_fatal_error(OS.str());
}

The LoadBytes is calculated correctly via getDataLayout().getTypeStoreSize(Ty), but the loading logic skips aggregates.

What would be the best way to extend this function to handle structs?