Index: testsuite/gcc.dg/tm/pr45985.c
===================================================================
--- testsuite/gcc.dg/tm/pr45985.c	(revision 0)
+++ testsuite/gcc.dg/tm/pr45985.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+__attribute__((transaction_unsafe))
+void illegal();
+
+static int a = 0;
+void func()
+{
+  __transaction [[relaxed]] {
+    if( a == 0)
+      illegal();
+  }
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 166180)
+++ trans-mem.c	(working copy)
@@ -4021,7 +4021,10 @@ ipa_tm_insert_irr_call (struct cgraph_no
 
   cgraph_create_edge (node,
 		      cgraph_node (built_in_decls[BUILT_IN_TM_IRREVOCABLE]),
-		      g, 0, 0, bb->loop_depth);
+		      g, 0,
+		      compute_call_stmt_bb_frequency (node->decl,
+						      gimple_bb (g)),
+		      bb->loop_depth);
 }
 
 /* Construct a call to TM_GETTMCLONE and insert it before GSI.  */
