Bugzilla – Bug 182
[llvmgcc] C front-end does not compile "extern inline" into linkonce
Last modified: 2004-01-08 11:16:51
You need to log in before you can comment on or make changes to this bug.
llvmgcc currently compiles "extern inline" functions into "weak" linkage, instead of linkonce linkage, preventing the optimizer from deleting the bodies of unreferenced functions. Testcase here: test/Regression/CFrontend/2003-12-14-ExternInlineSupport.c.tr Another testcase: --- test.c #include <gmp.h> --- $ llvmgcc test.c -c -o - | llvm-dis -Chris
Here's a fix: $ diff -u llvm-expand.c~ llvm-expand.c --- llvm-expand.c~ 2003-12-14 12:25:33.000000000 -0600 +++ llvm-expand.c 2004-01-08 10:53:45.000000000 -0600 @@ -6164,7 +6164,7 @@ if (!TREE_PUBLIC(subr) || lang_hooks.llvm_is_in_anon(subr)) Fn->Linkage = L_Internal; else if (DECL_COMDAT(subr) || - /* Are these two necessary?? */ + (DECL_DECLARED_INLINE_P(subr) && DECL_EXTERNAL(subr)) || (DECL_DECLARED_INLINE_P(subr) && DECL_ONE_ONLY(subr))) { Fn->Linkage = L_LinkOnce; } else if (DECL_WEAK(subr) || DECL_DECLARED_INLINE_P(subr) ||