From 06d43684289bfcf3b2dbaf081aa861f76933d891 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 27 Aug 2012 22:07:02 +0000 Subject: [PATCH] CodeGen: Hoist check from recursive function to its only callsite. Suggested by Roman Divacky. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162702 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDecl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 8543ca8eef..35d1a623a8 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -704,9 +704,8 @@ static bool canEmitInitWithFewStoresAfterMemset(llvm::Constant *Init, /// stores that would be required. static void emitStoresForInitAfterMemset(llvm::Constant *Init, llvm::Value *Loc, bool isVolatile, CGBuilderTy &Builder) { - // Zero doesn't require a store. - if (Init->isNullValue() || isa(Init)) - return; + assert(!Init->isNullValue() && !isa(Init) && + "called emitStoresForInitAfterMemset for zero or undef value."); if (isa(Init) || isa(Init) || isa(Init) || isa(Init) || @@ -1062,7 +1061,8 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { CGM.getTargetData().getTypeAllocSize(constant->getType()))) { Builder.CreateMemSet(Loc, llvm::ConstantInt::get(Int8Ty, 0), SizeVal, alignment.getQuantity(), isVolatile); - if (!constant->isNullValue()) { + // Zero and undef don't require a stores. + if (!constant->isNullValue() && !isa(constant)) { Loc = Builder.CreateBitCast(Loc, constant->getType()->getPointerTo()); emitStoresForInitAfterMemset(constant, Loc, isVolatile, Builder); } -- 2.40.0