[PATCH] D13614: [Extension] Optimizing passed by-value const objects.

Larisse Voufo via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 17:41:34 PDT 2015


lvoufo updated this revision to Diff 37012.
lvoufo added a comment.

Update patch (Wrong patch submitted earlier).


http://reviews.llvm.org/D13614

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGenCXX/const-invariant.cpp
  test/CodeGenObjCXX/arc.mm

Index: test/CodeGenObjCXX/arc.mm
===================================================================
--- test/CodeGenObjCXX/arc.mm
+++ test/CodeGenObjCXX/arc.mm
@@ -43,9 +43,11 @@
 @interface Test1 @end
 @implementation Test1 { Test1_helper x; } @end
 // CHECK: define internal i8* @"\01-[Test1 .cxx_construct]"(
+// CHECK:      call {{.*}}@llvm.invariant.start(
 // CHECK:      call void @_ZN12Test1_helperC1Ev(
 // CHECK-NEXT: load
 // CHECK-NEXT: bitcast
+// CHECK-NEXT: call {{.*}}@llvm.invariant.end(
 // CHECK-NEXT: ret i8*
 
 void test34(int cond) {
Index: test/CodeGenCXX/const-invariant.cpp
===================================================================
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -398,5 +398,17 @@
   // CHECK-L-CO: call {{.*}}@llvm.invariant.end({{.*}}, i64 {{[0-9]+}}, i8*
 }
 
+#ifdef LOCAL
+void ex1_parms(Const Type i) {
+  // CHECK: @_Z9ex1_parms1A(
+  // CHECK-L-CO: store {{.*}} %i
+  // CHECK-L-CO: call {{.*}}@llvm.invariant.start(
+  bar(i);
+  foo(&i);  // May change i.
+  bar(i);
+  // CHECK-L-CO: call {{.*}}@llvm.invariant.end(
+}
+#endif
+
 // CHECK-G-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL1j to i8*))
 // CHECK-G-CO-INT: store {{.*}}, {{.*}}* @_ZL1j
Index: lib/CodeGen/CGDecl.cpp
===================================================================
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1897,4 +1897,6 @@
 
   if (D.hasAttr<AnnotateAttr>())
     EmitVarAnnotations(&D, DeclPtr.getPointer());
+
+  MarkWriteOnceWrittenRAII MWO(*this, &D);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13614.37012.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151010/efb45109/attachment.bin>


More information about the cfe-commits mailing list