Index: lib/CodeGen/CGDecl.cpp =================================================================== --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -1897,4 +1897,6 @@ if (D.hasAttr()) EmitVarAnnotations(&D, DeclPtr.getPointer()); + + MarkWriteOnceWrittenRAII MWO(*this, &D); } 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: 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) {