Fix two @synchronized bugs found by inspection: the expression to sychronize on should only be evaluated once, and it is evaluated outside the cleanup scope.
Also, lift SyncEnter and SyncExit up in nervous anticipation of x86-64
zero cost EH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65362 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenObjC/synchronized.m b/test/CodeGenObjC/synchronized.m
index c74a83e..3e59449 100644
--- a/test/CodeGenObjC/synchronized.m
+++ b/test/CodeGenObjC/synchronized.m
@@ -1,5 +1,6 @@
-// RUN: clang -emit-llvm -triple=i686-apple-darwin8 -o %t %s
-// RUNX: clang -emit-llvm -o %t %s
+// RUN: clang -emit-llvm -triple=i686-apple-darwin8 -o %t %s -O2 &&
+// RUN: grep 'ret i32' %t | count 1 &&
+// RUN: grep 'ret i32 1' %t | count 1
#include <stdio.h>
@@ -28,5 +29,17 @@
}
}
+int f0(id a) {
+ int x = 0;
+ @synchronized((x++, a)) {
+ }
+ return x; // ret i32 1
+}
-
+void f1(id a) {
+ // The trick here is that the return shouldn't go through clean up,
+ // but there isn't a simple way to check this property.
+ @synchronized(({ return; }), a) {
+ return;
+ }
+}