summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-08-27 22:07:02 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-08-27 22:07:02 +0000
commit29f9a00732f5a0d3f147d71b2d51270bcfe02f16 (patch)
treefa3d2ca3d4197b5b632288729db5257da325cf9a /clang/lib/CodeGen/CGDecl.cpp
parent46cbe77b4936b275f59aef171cd2b0ffe02e154c (diff)
downloadbcm5719-llvm-29f9a00732f5a0d3f147d71b2d51270bcfe02f16.tar.gz
bcm5719-llvm-29f9a00732f5a0d3f147d71b2d51270bcfe02f16.zip
CodeGen: Hoist check from recursive function to its only callsite.
Suggested by Roman Divacky. llvm-svn: 162702
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 8543ca8eef4..35d1a623a83 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/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<llvm::UndefValue>(Init))
- return;
+ assert(!Init->isNullValue() && !isa<llvm::UndefValue>(Init) &&
+ "called emitStoresForInitAfterMemset for zero or undef value.");
if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(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<llvm::UndefValue>(constant)) {
Loc = Builder.CreateBitCast(Loc, constant->getType()->getPointerTo());
emitStoresForInitAfterMemset(constant, Loc, isVolatile, Builder);
}
OpenPOWER on IntegriCloud