2 // { dg-options "-fgnu-tm -O2 -fdump-tree-optimized" }
4 typedef __SIZE_TYPE__ size_t;
5 extern void *malloc(size_t);
15 __attribute__((transaction_safe))
16 LLNode(int val, LLNode* m_next)
21 __attribute__((transaction_safe))
23 __attribute__((transaction_safe))
24 int get_val() {return data;}
25 __attribute__((transaction_safe))
26 LLNode* get_next() {return next;}
27 __attribute__((transaction_safe))
28 void set_val(int val) {data = val;}
29 __attribute__((transaction_safe))
30 void set_next(LLNode* n) {next = n;}
31 __attribute__((transaction_safe))
32 void *operator new(size_t size);
44 using bench::LinkedList;
48 __attribute__((transaction_safe))
49 void* LLNode::operator new(size_t size)
54 LinkedList::LinkedList() : head(new LLNode(-1, 0)) { }
56 void LinkedList::insert(int val)
58 __transaction_atomic {
60 LLNode* curr = head->get_next();
63 if (curr->get_val() >= val)
66 curr = prev->get_next();
69 if (!curr || (curr->get_val() > val)){
70 LLNode* tmp = new LLNode(val,curr);
76 // Make sure we don't do tail optimization on the commit.
77 // { dg-final { scan-tree-dump-times "commitTransaction...; .tail call" 0 "optimized" } }
78 // { dg-final { cleanup-tree-dump "optimized" } }