From: Vitaly Buka Date: Thu, 27 Jun 2019 02:08:15 +0000 (+0000) Subject: [NFC] Return early for types with size zero X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b084edc7af5db800e1b190f2977014abde123ee;p=clang [NFC] Return early for types with size zero git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364495 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index a09b8fc584..43c962d32e 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -1145,6 +1145,10 @@ static void emitStoresForConstant(CodeGenModule &CGM, const VarDecl &D, CGBuilderTy &Builder, llvm::Constant *constant) { auto *Ty = constant->getType(); + uint64_t ConstantSize = CGM.getDataLayout().getTypeAllocSize(Ty); + if (!ConstantSize) + return; + bool canDoSingleStore = Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy() || Ty->isFPOrFPVectorTy(); if (canDoSingleStore) { @@ -1152,9 +1156,6 @@ static void emitStoresForConstant(CodeGenModule &CGM, const VarDecl &D, return; } - uint64_t ConstantSize = CGM.getDataLayout().getTypeAllocSize(Ty); - if (!ConstantSize) - return; auto *SizeVal = llvm::ConstantInt::get(CGM.IntPtrTy, ConstantSize); // If the initializer is all or mostly the same, codegen with bzero / memset