{
if (insn == BB_END (bb))
{
- /* This must be a basic block with only a label:
+ /* This must be the beginning basic block:
+
+ (note 4 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
+ (note 2 4 26 2 NOTE_INSN_FUNCTION_BEG)
+
+ or a basic block with only a label:
(code_label 78 11 77 3 14 (nil) [1 uses])
(note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
*/
gcc_assert (NOTE_P (insn)
- && NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK);
+ && (NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG
+ || NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK));
insn = NULL;
break;
}
}
else
{
- /* Emit the TLS call after NOTE_INSN_BASIC_BLOCK in a
- basic block with only a label:
+ /* Emit the TLS call after NOTE_INSN_FUNCTION_BEG in the
+ beginning basic block:
+
+ (note 4 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
+ (note 2 4 26 2 NOTE_INSN_FUNCTION_BEG)
+
+ or after NOTE_INSN_BASIC_BLOCK a basic block with only
+ a label:
(code_label 78 11 77 3 14 (nil) [1 uses])
(note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
--- /dev/null
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu" } */
+
+extern int get_cordz_mean_interval ();
+extern thread_local long cordz_next_sample, kIntervalIfDisabled;
+extern bool cordz_should_profile_slow (void);
+inline bool
+cordz_should_profile (void)
+{
+ return cordz_should_profile_slow ();
+}
+bool
+cordz_should_profile_slow (void)
+{
+ int mean_interval = get_cordz_mean_interval ();
+ if (mean_interval)
+ cordz_next_sample = kIntervalIfDisabled;
+ return cordz_next_sample || cordz_should_profile ();
+}
+
+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 2 { target { ! ia32 } } } } */
--- /dev/null
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu2" } */
+
+#include "pr121635-1a.c"
+
+/* { dg-final { scan-assembler-times "call\[ \t\]\\*cordz_next_sample@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "call\[ \t\]\\*kIntervalIfDisabled@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */