aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tm/pr47530.C
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/g++.dg/tm/pr47530.C
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/tm/pr47530.C')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tm/pr47530.C80
1 files changed, 80 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tm/pr47530.C b/gcc-4.9/gcc/testsuite/g++.dg/tm/pr47530.C
new file mode 100644
index 000000000..6a9fb1b00
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tm/pr47530.C
@@ -0,0 +1,80 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O2 -fdump-tree-optimized" }
+
+typedef __SIZE_TYPE__ size_t;
+extern void *malloc(size_t);
+
+namespace bench
+{
+ class LLNode
+ {
+ LLNode* next;
+ int data;
+
+ public:
+ __attribute__((transaction_safe))
+ LLNode(int val, LLNode* m_next)
+ {
+ data = val;
+ next = m_next;
+ }
+ __attribute__((transaction_safe))
+ ~LLNode(){}
+ __attribute__((transaction_safe))
+ int get_val() {return data;}
+ __attribute__((transaction_safe))
+ LLNode* get_next() {return next;}
+ __attribute__((transaction_safe))
+ void set_val(int val) {data = val;}
+ __attribute__((transaction_safe))
+ void set_next(LLNode* n) {next = n;}
+ __attribute__((transaction_safe))
+ void *operator new(size_t size);
+ };
+
+ class LinkedList
+ {
+ LLNode* head;
+ public:
+ LinkedList();
+ void insert(int val);
+ };
+}
+
+using bench::LinkedList;
+using bench::LLNode;
+
+
+__attribute__((transaction_safe))
+void* LLNode::operator new(size_t size)
+{
+ return malloc(size);
+}
+
+LinkedList::LinkedList() : head(new LLNode(-1, 0)) { }
+
+void LinkedList::insert(int val)
+{
+ __transaction_atomic {
+ LLNode* prev = head;
+ LLNode* curr = head->get_next();
+
+ while (curr != 0) {
+ if (curr->get_val() >= val)
+ break;
+ prev = curr;
+ curr = prev->get_next();
+ }
+
+ if (!curr || (curr->get_val() > val)){
+ LLNode* tmp = new LLNode(val,curr);
+ prev->set_next(tmp);
+ }
+ }
+}
+
+// Make sure we don't do tail optimization on the commit, except on
+// the uninstrumented code path.
+// { dg-final { scan-tree-dump-times "commitTransaction...; .tail call" 1 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }
+