[cfe-commits] r102912 - in /cfe/trunk: lib/CodeGen/CGExprCXX.cpp test/CodeGenCXX/new.cpp
Anders Carlsson
andersca at mac.com
Mon May 3 08:09:17 PDT 2010
Author: andersca
Date: Mon May 3 10:09:17 2010
New Revision: 102912
URL: http://llvm.org/viewvc/llvm-project?rev=102912&view=rev
Log:
Don't build an aggregate constructor loop when the constructor is trivial.
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/new.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=102912&r1=102911&r2=102912&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Mon May 3 10:09:17 2010
@@ -465,11 +465,13 @@
llvm::Value *NewPtr,
llvm::Value *NumElements) {
if (E->isArray()) {
- if (CXXConstructorDecl *Ctor = E->getConstructor())
- CGF.EmitCXXAggrConstructorCall(Ctor, NumElements, NewPtr,
- E->constructor_arg_begin(),
- E->constructor_arg_end());
- return;
+ if (CXXConstructorDecl *Ctor = E->getConstructor()) {
+ if (!Ctor->getParent()->hasTrivialConstructor())
+ CGF.EmitCXXAggrConstructorCall(Ctor, NumElements, NewPtr,
+ E->constructor_arg_begin(),
+ E->constructor_arg_end());
+ return;
+ }
}
QualType AllocType = E->getAllocatedType();
Modified: cfe/trunk/test/CodeGenCXX/new.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/new.cpp?rev=102912&r1=102911&r2=102912&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/new.cpp Mon May 3 10:09:17 2010
@@ -96,3 +96,13 @@
// CHECK: call void @llvm.memset.p0i8.i64(
B* b = new B();
}
+
+struct Empty { };
+
+// We don't need to initialize an empty class.
+void t12() {
+ // CHECK: define void @_Z3t12v
+ // CHECK-NOT: br label
+ // CHECK: ret void
+ (void)new Empty[10];
+}
More information about the cfe-commits
mailing list