From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30903 invoked by alias); 10 May 2007 03:07:00 -0000 Received: (qmail 30875 invoked by uid 48); 10 May 2007 03:06:48 -0000 Date: Thu, 10 May 2007 03:07:00 -0000 Subject: [Bug c/31886] New: (different from bug report c/31077 and 29241) C handling of always_inline attribute error and a solution X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "zhouyi04 at ios dot cn" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-05/txt/msg00734.txt.bz2 When compiling following code with no optimize flags given, gcc will complain: 1 __attribute__((always_inline)) unsigned int 2 alloc_null_binding1(void) 3 { 4 return 1; 5 } 6 7 static inline __attribute__((always_inline)) int ip_nat_initialized1(void) 8 { 9 10 return 2; 11 } 12 13 int ip_nat_rule_find1(void) 14 { 15 int ret; 16 if (!ip_nat_initialized1()){ 17 ret = alloc_null_binding1(); 18 } 19 return ret; 20 } /*************************************************************** **************************************************************** ***************************************************************/ [root@zzy inline]gcc -S hello.c hello.c: In function 'ip_nat_rule_find1': hello.c:3: sorry, unimplemented: inlining failed in call to 'alloc_null_binding1': function body not available hello.c:17: sorry, unimplemented: called from here /*************************************************************** **************************************************************** ***************************************************************/ solutions: Solution 1: --- gcc-4.1.0/gcc/tree-optimize.c.back 2007-05-09 22:38:58.000000000 -0400 +++ gcc-4.1.0/gcc/tree-optimize.c 2007-05-09 22:38:31.000000000 -0400 @@ -389,9 +389,15 @@ break; if (e) { - timevar_push (TV_INTEGRATION); - optimize_inline_calls (fndecl); - timevar_pop (TV_INTEGRATION); + for (e = node->callees; e; e = e->next_callee) + if (e->inline_failed && !warn_inline) + break; + if (!e) + { + timevar_push (TV_INTEGRATION); + optimize_inline_calls (fndecl); + timevar_pop (TV_INTEGRATION); + } } } /* We are not going to maintain the cgraph edges up to date. /*************************************************************** **************************************************************** ***************************************************************/ Solution 2: --- gcc-4.1.0/gcc/cgraphunit.c.back 2007-05-09 22:41:35.000000000 -0400 +++ gcc-4.1.0/gcc/cgraphunit.c 2007-05-09 22:24:21.000000000 -0400 @@ -1206,7 +1206,7 @@ if (dump_enabled_p (TDI_tree_all)) return true; if (!cgraph_global_info_ready) - return (DECL_INLINE (decl) && !flag_really_no_inline); + return ((DECL_INLINE (decl) && !flag_really_no_inline)||lookup_attribute ("always_inline", DECL_ATTRIBUTES (decl))); /* Look if there is any clone around. */ for (node = cgraph_node (decl); node; node = node->next_clone) if (node->global.inlined_to) --- gcc-4.1.0/gcc/tree-inline.c.back 2007-05-09 22:41:18.000000000 -0400 +++ gcc-4.1.0/gcc/tree-inline.c 2007-05-09 22:35:12.000000000 -0400 @@ -1594,6 +1594,8 @@ } /* Squirrel away the result so that we don't have to check again. */ + if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))) + inlinable = true; DECL_UNINLINABLE (fn) = !inlinable; return inlinable; /*************************************************************** **************************************************************** ***************************************************************/ Sincerely yours Zhouyi Zhou -- Summary: (different from bug report c/31077 and 29241) C handling of always_inline attribute error and a solution Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: zhouyi04 at ios dot cn GCC build triplet: Linux i686 GNU/Linux GCC host triplet: Linux i686 GNU/Linux GCC target triplet: Linux i686 GNU/Linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31886