Comments
Patch
===================================================================
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O1" } */
+
+static inline void
+inline_death ()
+{
+ __asm__ (""); /* { dg-error "asm not allowed" } */
+}
+
+void
+tranfunction ()
+{
+ __transaction
+ {
+ inline_death ();
+ }
+}
===================================================================
@@ -3929,6 +3929,13 @@ ipa_tm_diagnose_transaction (struct cgra
gimple stmt = gsi_stmt (gsi);
tree fndecl;
+ if (gimple_code (stmt) == GIMPLE_ASM)
+ {
+ error_at (gimple_location (stmt),
+ "asm not allowed in atomic transaction");
+ continue;
+ }
+
if (!is_gimple_call (stmt))
continue;
fndecl = gimple_call_fndecl (stmt);
In the following test, we correctly error at -O0 because inline_death() has an unsafe construct and is being called from an atomic transaction. This error is triggered at ipa_tm_diagnose_transaction() because the diagnostic machinery (diagnose_tm*) has marked inline_death() as possibly entering irrevocable mode. However, at any optimization level, we don't error because we no longer have an irrevocable function call, instead the ASM has been inlined into the transaction. Since the asm complaining code gets run before inlining (diagnose_tm*), we don't notice the asm that ends up inside the transaction. static inline void inline_death () { __asm__ (""); } void tranfunction () { __transaction { inline_death (); } } My fix is to notice ASMs that have been inlined into transactions at IPA time, since we're iterating over the transaction code anyhow. OK for branch? * trans-mem.c (ipa_tm_diagnose_transaction): Do not allow asms in atomic transactions.