+2016-11-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gcc/bb-reorder.c: Remove 'toplev.h' include.
+ (pass_partition_blocks::gate): No longer check
+ user_defined_section_attribute, instead check the function decl
+ for a section attribute.
+ * gcc/c-family/c-attribs.c (handle_section_attribute): No longer
+ set user_defined_section_attribute.
+ * gcc/final.c (rest_of_handle_final): Likewise.
+ * gcc/toplev.c: Remove definition of user_defined_section_attribute.
+ * gcc/toplev.h: Remove declaration of
+ user_defined_section_attribute.
+
2016-11-16 Maciej W. Rozycki <macro@imgtec.com>
* config/mips/mips.md (casesi_internal_mips16_<mode>):
#include "output.h"
#include "expr.h"
#include "params.h"
-#include "toplev.h" /* user_defined_section_attribute */
#include "tree-pass.h"
#include "cfgrtl.h"
#include "cfganal.h"
we are going to omit the reordering. */
&& optimize_function_for_speed_p (fun)
&& !DECL_COMDAT_GROUP (current_function_decl)
- && !user_defined_section_attribute);
+ && !lookup_attribute ("section", DECL_ATTRIBUTES (fun->decl)));
}
unsigned
goto fail;
}
- user_defined_section_attribute = true;
-
if (!VAR_OR_FUNCTION_DECL_P (decl))
{
error ("section attribute not allowed for %q+D", *node);
assemble_end_function (current_function_decl, fnname);
- user_defined_section_attribute = false;
-
/* Free up reg info memory. */
free_reg_info ();
+2016-11-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gcc.dg/tree-prof/section-attr-1.c: New file.
+ * gcc.dg/tree-prof/section-attr-2.c: New file.
+ * gcc.dg/tree-prof/section-attr-3.c: New file.
+
2016-11-16 Maciej W. Rozycki <macro@imgtec.com>
* gcc.target/mips/code-readable-4.c (dg-final): Expect `dla'
--- /dev/null
+/* Checks for a bug where a function with a section attribute would prevent
+ all later functions from being partitioned into hot and cold blocks. */
+/* { dg-require-effective-target freorder } */
+/* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */
+
+#define SIZE 10000
+
+#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))
+
+const char *sarr[SIZE];
+const char *buf_hot;
+const char *buf_cold;
+
+void foo (int path);
+
+__attribute__((section(".text")))
+int
+main (int argc, char *argv[])
+{
+ int i;
+ buf_hot = "hello";
+ buf_cold = "world";
+ for (i = 0; i < 1000000; i++)
+ foo (argc);
+ return 0;
+}
+
+
+void NOINLINE
+foo (int path)
+{
+ int i;
+ if (path)
+ {
+ for (i = 0; i < SIZE; i++)
+ sarr[i] = buf_hot;
+ }
+ else
+ {
+ for (i = 0; i < SIZE; i++)
+ sarr[i] = buf_cold;
+ }
+}
+
+/* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */
--- /dev/null
+/* Checks for a bug where static data with a section attribute within a
+ function would stop the function being partitioned into hot and cold
+ blocks. */
+/* { dg-require-effective-target freorder } */
+/* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */
+
+#define SIZE 10000
+
+#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))
+
+const char *sarr[SIZE];
+const char *buf_hot;
+const char *buf_cold;
+
+void foo (int path);
+
+int
+main (int argc, char *argv[])
+{
+ int i;
+ buf_hot = "hello";
+ buf_cold = "world";
+ for (i = 0; i < 1000000; i++)
+ foo (argc);
+ return 0;
+}
+
+void NOINLINE
+foo (int path)
+{
+ static int i __attribute__((section(".data")));
+ if (path)
+ {
+ for (i = 0; i < SIZE; i++)
+ sarr[i] = buf_hot;
+ }
+ else
+ {
+ for (i = 0; i < SIZE; i++)
+ sarr[i] = buf_cold;
+ }
+}
+
+/* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */
--- /dev/null
+/* Checks for a bug where static data with a section attribute within a
+ function would stop the function being partitioned into hot and cold
+ blocks. */
+/* { dg-require-effective-target freorder } */
+/* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */
+
+#define SIZE 10000
+
+#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))
+
+const char *sarr[SIZE];
+const char *buf_hot __attribute__ ((section (".data")));
+const char *buf_cold;
+
+void foo (int path);
+
+int
+main (int argc, char *argv[])
+{
+ int i;
+ buf_hot = "hello";
+ buf_cold = "world";
+ for (i = 0; i < 1000000; i++)
+ foo (argc);
+ return 0;
+}
+
+
+void NOINLINE
+foo (int path)
+{
+ int i;
+ if (path)
+ {
+ for (i = 0; i < SIZE; i++)
+ sarr[i] = buf_hot;
+ }
+ else
+ {
+ for (i = 0; i < SIZE; i++)
+ sarr[i] = buf_cold;
+ }
+}
+
+/* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */
the support provided depends on the backend. */
rtx stack_limit_rtx;
-/* True if the user has tagged the function with the 'section'
- attribute. */
-
-bool user_defined_section_attribute = false;
-
struct target_flag_state default_target_flag_state;
#if SWITCHABLE_TARGET
struct target_flag_state *this_target_flag_state = &default_target_flag_state;
/* A unique local time stamp, might be zero if none is available. */
extern unsigned local_tick;
-/* True if the user has tagged the function with the 'section'
- attribute. */
-
-extern bool user_defined_section_attribute;
-
/* See toplev.c. */
extern int flag_rerun_cse_after_global_opts;