Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp =================================================================== --- llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -878,6 +878,12 @@ report_fatal_error(OS.str()); } + if (auto *TETy = dyn_cast(C->getType())) { + assert(TETy->hasProperty(TargetExtType::HasZeroInit) && C->isNullValue() && + "TargetExtType only supports null constant value"); + C = Constant::getNullValue(TETy->getLayoutType()); + } + // Otherwise, we have a simple constant. GenericValue Result; switch (C->getType()->getTypeID()) { @@ -1017,6 +1023,9 @@ void ExecutionEngine::StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, Type *Ty) { + if (auto *TETy = dyn_cast(Ty)) + Ty = TETy->getLayoutType(); + const unsigned StoreBytes = getDataLayout().getTypeStoreSize(Ty); switch (Ty->getTypeID()) { @@ -1068,6 +1077,9 @@ void ExecutionEngine::LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr, Type *Ty) { + if (auto *TETy = dyn_cast(Ty)) + Ty = TETy->getLayoutType(); + const unsigned LoadBytes = getDataLayout().getTypeStoreSize(Ty); switch (Ty->getTypeID()) {