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()) { Index: llvm/test/ExecutionEngine/test-interp-target-ext-type.ll =================================================================== --- /dev/null +++ llvm/test/ExecutionEngine/test-interp-target-ext-type.ll @@ -0,0 +1,9 @@ +; RUN: %lli -jit-kind=mcjit -force-interpreter=true %s > /dev/null + +define i32 @main() { + %event = alloca target("spirv.Event"), align 8 + store target("spirv.Event") zeroinitializer, ptr %event, align 8 + %e = load target("spirv.Event"), ptr %event, align 8 + + ret i32 0 +}