This patch fixes a crash when generating IRGen for armv7 which has ABI of
implicit return of 'this' for constructors. Please review.
- fariborz


Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp      (revision 196116)
+++ lib/CodeGen/CGStmt.cpp      (working copy)
@@ -820,7 +820,7 @@
     // that the cleanup code should not destroy the variable.
     if (llvm::Value *NRVOFlag = NRVOFlags[S.getNRVOCandidate()])
       Builder.CreateStore(Builder.getTrue(), NRVOFlag);
-  } else if (!ReturnValue) {
+  } else if (!ReturnValue  || (RV && RV->getType()->isVoidType())) {
     // Make sure not to return anything, but evaluate the expression
     // for side effects.
     if (RV)
Index: test/CodeGenCXX/constructor-return-void.cpp
===================================================================
--- test/CodeGenCXX/constructor-return-void.cpp (revision 0)
+++ test/CodeGenCXX/constructor-return-void.cpp (working copy)
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple=thumbv7-unknown-unknown -emit-llvm -o -  | 
FileCheck %s
+// rdar://15366494
+// pr17759
+
+void f() {}
+struct S { S() { return f(); } } s;
+
+// CHECK: [[THISADDR:%.*]] = alloca %struct.S*, align 4
+// CHECK:   store %struct.S* [[THIS:%.*]], %struct.S** [[THISADDR]], align 4
+// CHECK:   [[THIS1:%.*]] = load %struct.S** [[THISADDR]]
+// CHECK:   call arm_aapcscc void @_Z1fv()
+// CHECK:   ret %struct.S* [[THIS1]]
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to