diff options
-rw-r--r-- | lib/SPIRV/SPIRVWriter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp index 906a8a8..94f9e86 100644 --- a/lib/SPIRV/SPIRVWriter.cpp +++ b/lib/SPIRV/SPIRVWriter.cpp @@ -909,7 +909,8 @@ SPIRVValue *LLVMToSPIRV::transValueWithoutDecoration(Value *V, // Though variables with common linkage type are initialized by 0, // they can be represented in SPIR-V as uninitialized variables with // 'Export' linkage type, just as tentative definitions look in C - llvm::Value *Init = GV->hasInitializer() && !GV->hasCommonLinkage() + llvm::Value *Init = GV->hasInitializer() && !GV->hasCommonLinkage() && + !isa<UndefValue>(GV->getInitializer()) ? GV->getInitializer() : nullptr; StructType *ST = Init ? dyn_cast<StructType>(Init->getType()) : nullptr; |