This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Is "optimize" attribute on fndecl handled differently?

Iâm trying to get the Fortran front-end to add function-specific optimization flags to certain functions (those that request IEEE compliance through use of the specific Fortran module). It seems simple enough, adding the attribute to the fndecl, but though Iâve tried to do so at two different places (when we first build the function decl, and when we later call it), both fail with:

Warning: âoptimizeâ attribute directive ignored [-Wattributes]

Iâm getting the feeling that maybe itâs because I gave the attribute a string value, and itâs expecting a tree alreadyâ but the functions to do so are not generic, theyâre in c-family, which probably means I canât use them.

Any idea how I could get to the result I want? (setting options from the Fortran front-end)


Index: trans-decl.c
--- trans-decl.c	(revision 215668)
+++ trans-decl.c	(working copy)
@@ -1961,6 +1961,13 @@
     TREE_USED (fndecl) = 1;
   attributes = add_attributes_to_decl (attr, NULL_TREE);
+#define OPT "fno-unsafe-math-optimizations"
+  tree opt = build_tree_list (NULL_TREE, build_string (strlen (OPT), OPT));
+  attributes = tree_cons (get_identifier ("optimize"), opt, attributes);
+#undef OPT
   decl_attributes (&fndecl, attributes, 0);
   /* Figure out the return type of the declared function, and build a
@@ -5760,8 +5767,19 @@
      the floating point state.  */
   ieee = is_ieee_module_used (ns);
   if (ieee)
-    fpstate = save_fp_state (&init);
+    {
+      tree attributes;
+      fpstate = save_fp_state (&init);
+#define OPT "fno-unsafe-math-optimizations"
+      tree opt = build_tree_list (NULL_TREE, build_string (strlen (OPT), OPT));
+      attributes = tree_cons (get_identifier ("optimize"), opt, NULL_TREE);
+      decl_attributes (&fndecl, attributes, 0);
+#undef OPT
+    }
   /* Now generate the code for the body of this function.  */
   gfc_init_block (&body);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]