+2018-11-29 Andi Kleen <ak@linux.intel.com>
+
+ * config/i386/i386.c (current_fentry_section): Add.
+ (x86_function_profiler): Handle fentry section.
+ (ix86_attribute_table): Add fentry section.
+ * config/i386/i386.opt: Add -mfentry-section.
+ * doc/extend.texi: Document fentry_section attribute.
+ * doc/invoke.texi: Document -mfentry-section.
+
2018-11-29 Andi Kleen <ak@linux.intel.com>
* config/i386/i386.c (x86_print_call_or_nop): Handle nop name.
return true;
}
+static bool
+current_fentry_section (const char **name)
+{
+ tree attr = lookup_attribute ("fentry_section",
+ DECL_ATTRIBUTES (current_function_decl));
+ if (!attr)
+ return false;
+ *name = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)));
+ return true;
+}
+
/* Output assembler code to FILE to increment profiler label # LABELNO
for profiling a function entry. */
void
x86_print_call_or_nop (file, mcount_name);
}
- if (flag_record_mcount)
+ if (flag_record_mcount
+ || lookup_attribute ("fentry_section",
+ DECL_ATTRIBUTES (current_function_decl)))
{
- fprintf (file, "\t.section __mcount_loc, \"a\",@progbits\n");
+ const char *sname = "__mcount_loc";
+
+ if (current_fentry_section (&sname))
+ ;
+ else if (fentry_section)
+ sname = fentry_section;
+
+ fprintf (file, "\t.section %s, \"a\",@progbits\n", sname);
fprintf (file, "\t.%s 1b\n", TARGET_64BIT ? "quad" : "long");
fprintf (file, "\t.previous\n");
}
emit_move_insn (op0, res);
}
-/* Handle fentry_name attribute. */
+/* Handle fentry_name / fentry_section attribute. */
static tree
ix86_handle_fentry_name (tree *node, tree name, tree args,
NULL, NULL },
{ "fentry_name", 1, 1, true, false, false, false,
ix86_handle_fentry_name, NULL },
+ { "fentry_section", 1, 1, true, false, false, false,
+ ix86_handle_fentry_name, NULL },
/* End element. */
{ NULL, 0, 0, false, false, false, false, NULL, NULL }
};
Target RejectNegative Joined Var(fentry_name)
Set name of __fentry__ symbol called at function entry.
+mfentry-section=
+Target RejectNegative Joined Var(fentry_section)
+Set name of section to record mrecord-mcount calls.
+
mskip-rax-setup
Target Report Var(flag_skip_rax_setup)
Skip setting up RAX register when passing variable arguments.
with @option{-pg -mfentry}. When @var{name} is nop then a 5 byte
nop sequence is generated.
+@item fentry_section("@var{name}")
+@cindex @code{fentry_section} function attribute, x86
+On x86 targets, the @code{fentry_section} attribute sets the name
+of the section to record function entry instrumentation calls in when
+enabled with @option{-pg -mrecord-mcount}
+
@end table
On the x86, the inliner does not inline a
-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
--minstrument-return=@var{type} -mfentry-name=@var{name} @gol
+-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
-mstack-protector-guard-reg=@var{reg} @gol
@opindex mfentry-name
Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
+@item -mfentry-section=@var{name}
+@opindex mfentry-section
+Set name of section to record -mrecord-mcount calls (default __mcount_loc).
+
@item -mskip-rax-setup
@itemx -mno-skip-rax-setup
@opindex mskip-rax-setup
+2018-11-29 Andi Kleen <ak@linux.intel.com>
+
+ * gcc.target/i386/fentryname2.c: New test.
+ * gcc.target/i386/fentryname3.c: New test.
+
2018-11-29 Andi Kleen <ak@linux.intel.com>
* gcc.target/i386/fentryname1.c: New test.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-pg -mfentry -mrecord-mcount -mfentry-section=foo" } */
+/* { dg-final { scan-assembler "section.*foo" } } */
+/* { dg-final { scan-assembler "section.*bar" } } */
+
+int func(int a)
+{
+ return a+1;
+}
+
+__attribute__((fentry_section("bar")))
+int func2(int a)
+{
+ return a+1;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-pg -mfentry" } */
+/* { dg-final { scan-assembler "section.*__entry_loc" } } */
+/* { dg-final { scan-assembler "0x0f, 0x1f, 0x44, 0x00, 0x00" } } */
+/* { dg-final { scan-assembler-not "__fentry__" } } */
+
+__attribute__((fentry_name("nop"), fentry_section("__entry_loc")))
+void foo(void)
+{
+}