aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2012-01-24 13:38:10 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2012-01-24 13:38:10 +0000
commit1aa5d1c74aa0ed61c1d3e4067dd291efa41b1cf8 (patch)
tree62ff220c08d544c8a6b59e2524b1fa34f424a684
parentc5c90089e6f24e5c3d31a1e70edbe1bbe14a2a61 (diff)
downloadgcc-1aa5d1c74aa0ed61c1d3e4067dd291efa41b1cf8.zip
gcc-1aa5d1c74aa0ed61c1d3e4067dd291efa41b1cf8.tar.gz
gcc-1aa5d1c74aa0ed61c1d3e4067dd291efa41b1cf8.tar.bz2
+ * trans-mem.c (requires_barrier): Do not instrument thread local + variables and emit save/restore for them.
+ * trans-mem.c (requires_barrier): Do not instrument thread local + variables and emit save/restore for them. Co-Authored-By: Patrick Marlier <patrick.marlier@gmail.com> From-SVN: r183476
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/tm/threadlocal-1.c17
-rw-r--r--gcc/trans-mem.c34
3 files changed, 44 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ebbb8d0..4fb5057 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-24 Aldy Hernandez <aldyh@redhat.com>
+ Patrick Marlier <patrick.marlier@gmail.com>
+
+ * trans-mem.c (requires_barrier): Do not instrument thread local
+ variables and emit save/restore for them.
+
2012-01-24 Jason Merrill <jason@redhat.com>
PR c++/51812
diff --git a/gcc/testsuite/gcc.dg/tm/threadlocal-1.c b/gcc/testsuite/gcc.dg/tm/threadlocal-1.c
new file mode 100644
index 0000000..83a90ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tm/threadlocal-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O -fdump-tree-tmedge" } */
+__thread int notshared = 0;
+int shared = 0;
+
+int main()
+{
+ __transaction_atomic
+ {
+ notshared++;
+ shared++;
+ }
+ return notshared + shared;
+}
+/* { dg-final { scan-tree-dump-times "tm_save.\[0-9_\]+ = notshared" 1 "tmedge" } } */
+/* { dg-final { scan-tree-dump-times "notshared = tm_save" 1 "tmedge" } } */
+/* { dg-final { cleanup-tree-dump "tmedge" } } */
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index de7a913..06b1d81 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -1,5 +1,5 @@
/* Passes for transactional memory support.
- Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
This file is part of GCC.
@@ -1488,7 +1488,18 @@ requires_barrier (basic_block entry_block, tree x, gimple stmt)
}
if (is_global_var (x))
- return !TREE_READONLY (x);
+ {
+ if (DECL_THREAD_LOCAL_P (x))
+ goto thread_local;
+ if (DECL_HAS_VALUE_EXPR_P (x))
+ {
+ tree value = get_base_address (DECL_VALUE_EXPR (x));
+
+ if (value && DECL_P (value) && DECL_THREAD_LOCAL_P (value))
+ goto thread_local;
+ }
+ return !TREE_READONLY (x);
+ }
if (/* FIXME: This condition should actually go below in the
tm_log_add() call, however is_call_clobbered() depends on
aliasing info which is not available during
@@ -1498,17 +1509,14 @@ requires_barrier (basic_block entry_block, tree x, gimple stmt)
lower_sequence_tm altogether. */
needs_to_live_in_memory (x))
return true;
- else
- {
- /* For local memory that doesn't escape (aka thread private
- memory), we can either save the value at the beginning of
- the transaction and restore on restart, or call a tm
- function to dynamically save and restore on restart
- (ITM_L*). */
- if (stmt)
- tm_log_add (entry_block, orig, stmt);
- return false;
- }
+ thread_local:
+ /* For local memory that doesn't escape (aka thread private memory),
+ we can either save the value at the beginning of the transaction and
+ restore on restart, or call a tm function to dynamically save and
+ restore on restart (ITM_L*). */
+ if (stmt)
+ tm_log_add (entry_block, orig, stmt);
+ return false;
default:
return false;