[cfe-commits] r69687 - /cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
Chris Lattner
sabre at nondot.org
Tue Apr 21 10:59:24 PDT 2009
Author: lattner
Date: Tue Apr 21 12:59:23 2009
New Revision: 69687
URL: http://llvm.org/viewvc/llvm-project?rev=69687&view=rev
Log:
don't bother emitting a zero byte memset at all. We used to get them
in cases like this:
typedef struct {
short instance;
char name[0];
} ATTR_LIST_ENTRY2;
void test() {
ATTR_LIST_ENTRY2 X = (ATTR_LIST_ENTRY2) { .instance = 7, };
}
While it is safe to emit them, it is pretty silly.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=69687&r1=69686&r2=69687&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Apr 21 12:59:23 2009
@@ -396,8 +396,7 @@
return LabelIDs.insert(std::make_pair(L, LabelIDs.size())).first->second;
}
-void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty)
-{
+void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty) {
const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
if (DestPtr->getType() != BP)
DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
@@ -405,6 +404,10 @@
// Get size and alignment info for this aggregate.
std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty);
+ // Don't bother emitting a zero-byte memset.
+ if (TypeInfo.first == 0)
+ return;
+
// FIXME: Handle variable sized types.
const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth);
More information about the cfe-commits
mailing list