]> granicus.if.org Git - clang/commitdiff
[NFC] Return early for types with size zero
authorVitaly Buka <vitalybuka@google.com>
Thu, 27 Jun 2019 02:08:15 +0000 (02:08 +0000)
committerVitaly Buka <vitalybuka@google.com>
Thu, 27 Jun 2019 02:08:15 +0000 (02:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364495 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDecl.cpp

index a09b8fc5842d109cb9449f8312c2952663b22ead..43c962d32ef58da86c157a98e26cc6f3b6f1bb76 100644 (file)
@@ -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