OSDN Git Service

PR middle-end/52141
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Feb 2012 23:43:31 +0000 (23:43 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Feb 2012 23:43:31 +0000 (23:43 +0000)
        * trans-mem.c (ipa_tm_scan_irr_block): Error out on GIMPLE_ASM's
        in a transaction safe function.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184417 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/gcc.dg/tm/pr52141.c [new file with mode: 0644]
gcc/trans-mem.c

index c579214..e12e596 100644 (file)
@@ -1,3 +1,9 @@
+2012-02-20  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR middle-end/52141
+       * trans-mem.c (ipa_tm_scan_irr_block): Error out on GIMPLE_ASM's
+       in a transaction safe function.
+
 2012-02-20  Kai Tietz  <ktietz@redhat.com>
 
        PR target/52238
diff --git a/gcc/testsuite/gcc.dg/tm/pr52141.c b/gcc/testsuite/gcc.dg/tm/pr52141.c
new file mode 100644 (file)
index 0000000..0dabf76
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O0 -w" } */
+
+__attribute__((always_inline))
+static void asmfunc(void)
+{
+  __asm__ (""); /* { dg-error "asm not allowed in .transaction_safe" } */
+}
+
+__attribute__((transaction_safe))
+static void f(void)
+{
+  asmfunc();
+}
+
+int main()
+{
+  __transaction_atomic {
+    f();
+  }
+  return 0;
+}
+
+/* { dg-message "inlined from \'f\'" "" { target *-*-* } 0 } */
index d760db3..aa330dd 100644 (file)
@@ -3736,6 +3736,13 @@ ipa_tm_scan_irr_block (basic_block bb)
             assembly statement is not relevant to the transaction
             is to wrap it in a __tm_waiver block.  This is not
             yet implemented, so we can't check for it.  */
+         if (is_tm_safe (current_function_decl))
+           {
+             tree t = build1 (NOP_EXPR, void_type_node, size_zero_node);
+             SET_EXPR_LOCATION (t, gimple_location (stmt));
+             TREE_BLOCK (t) = gimple_block (stmt);
+             error ("%Kasm not allowed in %<transaction_safe%> function", t);
+           }
          return true;
 
        default: