[llvm-commits] [llvm-gcc-4.2] r72619 - in /llvm-gcc-4.2/trunk/gcc: cgraph.c cgraph.h cgraphunit.c cp/semantics.c ipa.c llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Sat May 30 06:55:55 PDT 2009
Author: baldrick
Date: Sat May 30 08:55:54 2009
New Revision: 72619
URL: http://llvm.org/viewvc/llvm-project?rev=72619&view=rev
Log:
Output bodies for "extern inline" functions with
available_externally linkage, rather than just a
declaration with no body. Fixes PR4262.
Modified:
llvm-gcc-4.2/trunk/gcc/cgraph.c
llvm-gcc-4.2/trunk/gcc/cgraph.h
llvm-gcc-4.2/trunk/gcc/cgraphunit.c
llvm-gcc-4.2/trunk/gcc/cp/semantics.c
llvm-gcc-4.2/trunk/gcc/ipa.c
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/cgraph.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraph.c?rev=72619&r1=72618&r2=72619&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cgraph.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cgraph.c Sat May 30 08:55:54 2009
@@ -601,7 +601,7 @@
if (!n->next_clone && !n->global.inlined_to
&& (cgraph_global_info_ready
/* LLVM LOCAL extern inline */
- && (TREE_ASM_WRITTEN (n->decl) || IS_EXTERN_INLINE (n->decl))))
+ && (TREE_ASM_WRITTEN (n->decl) || OMIT_FUNCTION_BODY (n->decl))))
kill_body = true;
}
@@ -1185,7 +1185,7 @@
else if (!(*targetm.binds_local_p) (node->decl)
/* LLVM LOCAL extern inline */
- && !DECL_COMDAT (node->decl) && !IS_EXTERN_INLINE (node->decl))
+ && !DECL_COMDAT (node->decl) && !OMIT_FUNCTION_BODY (node->decl))
avail = AVAIL_OVERWRITABLE;
else avail = AVAIL_AVAILABLE;
Modified: llvm-gcc-4.2/trunk/gcc/cgraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraph.h?rev=72619&r1=72618&r2=72619&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cgraph.h (original)
+++ llvm-gcc-4.2/trunk/gcc/cgraph.h Sat May 30 08:55:54 2009
@@ -335,14 +335,12 @@
bool cgraph_default_inline_p (struct cgraph_node *, const char **);
/* LLVM LOCAL begin 6501843 */
-/* We're no longer running gcc's inliner at all, so the bodies of
- used extern always-inline functions must be passed down to the LLVM BE.
+/* Make sure bodies of "extern inline" functions are output to LLVM IR.
cgraph used to remove these. (gcc "extern inline" == c99 "inline") */
#ifdef ENABLE_LLVM
-#define IS_EXTERN_INLINE(f) (DECL_EXTERNAL(f) && \
- !lookup_attribute("always_inline", DECL_ATTRIBUTES(f)))
+#define OMIT_FUNCTION_BODY(f) (false)
#else
-#define IS_EXTERN_INLINE(f) (DECL_EXTERNAL(f))
+#define OMIT_FUNCTION_BODY(f) (DECL_EXTERNAL(f))
#endif
/* LLVM LOCAL end */
#endif /* GCC_CGRAPH_H */
Modified: llvm-gcc-4.2/trunk/gcc/cgraphunit.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraphunit.c?rev=72619&r1=72618&r2=72619&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cgraphunit.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cgraphunit.c Sat May 30 08:55:54 2009
@@ -385,7 +385,7 @@
if (!n->global.inlined_to
&& !n->alias
/* LLVM LOCAL extern inline */
- && !IS_EXTERN_INLINE (n->decl))
+ && !OMIT_FUNCTION_BODY (n->decl))
{
cgraph_expand_function (n);
output = true;
@@ -849,7 +849,7 @@
if (node->analyzed
&& DECL_SAVED_TREE (node->decl) && !TREE_ASM_WRITTEN (node->decl)
/* LLVM LOCAL extern inline */
- && (!IS_EXTERN_INLINE (node->decl) || node->global.inlined_to))
+ && (!OMIT_FUNCTION_BODY (node->decl) || node->global.inlined_to))
{
if (this_cfun->cfg)
{
@@ -942,7 +942,10 @@
if (!TREE_ASM_WRITTEN (decl)
&& !node->alias
- && !DECL_EXTERNAL (decl)
+ /* LLVM LOCAL begin extern inline */
+ && (!DECL_EXTERNAL (decl) ||
+ (TREE_CODE (decl) == FUNCTION_DECL && !OMIT_FUNCTION_BODY(decl)))
+ /* LLVM LOCAL end extern inline */
&& (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl)))
{
assemble_variable (decl, 0, 1, 0);
@@ -1295,7 +1298,7 @@
|| (e && node->reachable))
&& !TREE_ASM_WRITTEN (decl)
/* LLVM LOCAL extern inline */
- && !IS_EXTERN_INLINE (decl))
+ && !OMIT_FUNCTION_BODY (decl))
node->output = 1;
else
{
@@ -1303,7 +1306,7 @@
#ifdef ENABLE_CHECKING
if (!node->global.inlined_to && DECL_SAVED_TREE (decl)
/* LLVM LOCAL extern inline */
- && !IS_EXTERN_INLINE (decl))
+ && !OMIT_FUNCTION_BODY (decl))
{
dump_cgraph_node (stderr, node);
internal_error ("failed to reclaim unneeded function");
@@ -1311,7 +1314,7 @@
#endif
/* LLVM LOCAL extern inline */
gcc_assert (node->global.inlined_to || !DECL_SAVED_TREE (decl)
- || IS_EXTERN_INLINE (decl));
+ || OMIT_FUNCTION_BODY (decl));
}
}
Modified: llvm-gcc-4.2/trunk/gcc/cp/semantics.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/semantics.c?rev=72619&r1=72618&r2=72619&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/semantics.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/semantics.c Sat May 30 08:55:54 2009
@@ -3223,14 +3223,18 @@
`-fexternal-templates'; we instantiate the function, even though
we're not planning on emitting it, in case we get a chance to
inline it. */
- if (DECL_EXTERNAL (fn))
+ /* LLVM LOCAL extern inline */
+ if (OMIT_FUNCTION_BODY (fn))
return;
/* ??? When is this needed? */
saved_function = current_function_decl;
/* Emit any thunks that should be emitted at the same time as FN. */
- emit_associated_thunks (fn);
+ /* LLVM LOCAL begin extern inline */
+ if (!DECL_EXTERNAL (fn))
+ emit_associated_thunks (fn);
+ /* LLVM LOCAL end extern inline */
/* This function is only called from cgraph, or recursively from
emit_associated_thunks. In neither case should we be currently
Modified: llvm-gcc-4.2/trunk/gcc/ipa.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ipa.c?rev=72619&r1=72618&r2=72619&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/ipa.c (original)
+++ llvm-gcc-4.2/trunk/gcc/ipa.c Sat May 30 08:55:54 2009
@@ -113,7 +113,7 @@
for (node = cgraph_nodes; node; node = node->next)
if (node->needed && !node->global.inlined_to
/* LLVM LOCAL extern inline */
- && ((!IS_EXTERN_INLINE (node->decl))
+ && ((!OMIT_FUNCTION_BODY (node->decl))
|| !node->analyzed
|| before_inlining_p))
{
@@ -137,7 +137,7 @@
&& node->analyzed
&& (!e->inline_failed || !e->callee->analyzed
/* LLVM LOCAL extern inline */
- || !IS_EXTERN_INLINE(e->callee->decl)
+ || !OMIT_FUNCTION_BODY(e->callee->decl)
|| before_inlining_p))
{
e->callee->aux = first;
@@ -169,7 +169,7 @@
if (file)
fprintf (file, " %s", cgraph_node_name (node));
/* LLVM LOCAL extern inline */
- if (!node->analyzed || !IS_EXTERN_INLINE(node->decl)
+ if (!node->analyzed || !OMIT_FUNCTION_BODY(node->decl)
|| before_inlining_p)
cgraph_remove_node (node);
else
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=72619&r1=72618&r2=72619&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sat May 30 08:55:54 2009
@@ -465,19 +465,12 @@
// The function should not already have a body.
assert(Fn->empty() && "Function expanded multiple times!");
-
+
// Compute the linkage that the function should get.
- // Functions declared "always inline" should not have a body
- // emitted; hack this by pretending they're static. That will either
- // make them go away or emit a static definition that won't collide with
- // anything.
if (DECL_LLVM_PRIVATE(FnDecl)) {
Fn->setLinkage(Function::PrivateLinkage);
} else if (!TREE_PUBLIC(FnDecl) /*|| lang_hooks.llvm_is_in_anon(subr)*/) {
Fn->setLinkage(Function::InternalLinkage);
- } else if (DECL_EXTERNAL(FnDecl) &&
- lookup_attribute ("always_inline", DECL_ATTRIBUTES (FnDecl))) {
- Fn->setLinkage(Function::InternalLinkage);
} else if (DECL_COMDAT(FnDecl)) {
Fn->setLinkage(Function::getLinkOnceLinkage(flag_odr));
} else if (DECL_WEAK(FnDecl)) {
@@ -485,6 +478,8 @@
Fn->setLinkage(Function::WeakAnyLinkage);
} else if (DECL_ONE_ONLY(FnDecl)) {
Fn->setLinkage(Function::getWeakLinkage(flag_odr));
+ } else if (DECL_EXTERNAL(FnDecl)) {
+ Fn->setLinkage(Function::AvailableExternallyLinkage);
}
#ifdef TARGET_ADJUST_LLVM_LINKAGE
More information about the llvm-commits
mailing list