diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -973,15 +973,10 @@ if (GlobalSize <= SizeLimit) return nullptr; - if (!MFB.Value) { - // We don't know most frequent byte, we may still completely initialize it - // with small number of stores. - // TODO: Use llvm::UndefValue::get. If we get here and later we decide - // that number of stores is small enough to use memset+store then store are - // going to replace entire bzeroed range. With UndefValue we can skip that - // bogus memset. I will do that as a separate patch. - MFB.Value = llvm::ConstantInt::get(CGM.Int8Ty, 0); - } + // We don't know most frequent byte, we may still completely initialize it + // with small number of stores. + if (!MFB.Value) + MFB.Value = llvm::UndefValue::get(CGM.Int8Ty); unsigned StoreBudget = 6; return canEmitStoresForInitAfterMemset(CGM, Init, MFB.Value, StoreBudget) diff --git a/clang/test/CodeGen/init-memset.c b/clang/test/CodeGen/init-memset.c --- a/clang/test/CodeGen/init-memset.c +++ b/clang/test/CodeGen/init-memset.c @@ -49,7 +49,7 @@ void test_pointers() { // CHECK-LABEL: define void @test_pointers() void *a[] = {&use, &use, &use, &use, &use, &use}; - // CHECK: call void @llvm.memset.{{.*}} + // CHECK-NOT: @llvm.memset. // CHECK: store i8* // CHECK: store i8* // CHECK: store i8*