]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tm/memopt-11.c
Merge from transactional-memory branch.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / tm / memopt-11.c
1 /* { dg-do compile } */
2 /* { dg-options "-fgnu-tm -O -fdump-tree-tmmark" } */
3
4 extern int something(void) __attribute__((transaction_safe));
5 extern void *malloc (__SIZE_TYPE__) __attribute__((malloc,transaction_safe));
6
7 int f()
8 {
9 int *p;
10
11 p = malloc (sizeof (*p) * 100);
12 foo(p[5]);
13
14 __transaction_atomic {
15 /* p[5] is thread private, however the SSA_NAME that holds the
16 address dominates the entire transaction (transaction
17 invariant) so we can use a save/restore pair. */
18 p[5] = 123;
19
20 if (something())
21 __transaction_cancel;
22 }
23 return p[5];
24 }
25
26 /* { dg-final { scan-tree-dump-times "ITM_LU" 0 "tmmark" } } */
27 /* { dg-final { scan-tree-dump-times "ITM_WU" 0 "tmmark" } } */
28 /* { dg-final { scan-tree-dump-times "tm_save" 1 "tmmark" } } */
29 /* { dg-final { cleanup-tree-dump "tmmark" } } */