[llvm] r219335 - Inliner: Non-local functions in COMDATs shouldn't be dropped
Rafael EspĂndola
rafael.espindola at gmail.com
Wed Oct 8 12:49:32 PDT 2014
Thanks!
On 8 October 2014 15:32, David Majnemer <david.majnemer at gmail.com> wrote:
> Author: majnemer
> Date: Wed Oct 8 14:32:32 2014
> New Revision: 219335
>
> URL: http://llvm.org/viewvc/llvm-project?rev=219335&view=rev
> Log:
> Inliner: Non-local functions in COMDATs shouldn't be dropped
>
> A function with discardable linkage cannot be discarded if its a member
> of a COMDAT group without considering all the other COMDAT members as
> well. This sort of thing is already handled by GlobalOpt/GlobalDCE.
>
> This fixes PR21206.
>
> Added:
> llvm/trunk/test/Transforms/Inline/pr21206.ll
> Modified:
> llvm/trunk/lib/Transforms/IPO/Inliner.cpp
>
> Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=219335&r1=219334&r2=219335&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Wed Oct 8 14:32:32 2014
> @@ -669,6 +669,13 @@ bool Inliner::removeDeadFunctions(CallGr
>
> if (!F->isDefTriviallyDead())
> continue;
> +
> + // It is unsafe to drop a function with discardable linkage from a COMDAT
> + // without also dropping the other members of the COMDAT.
> + // The inliner doesn't visit non-function entities which are in COMDAT
> + // groups so it is unsafe to do so *unless* the linkage is local.
> + if (!F->hasLocalLinkage() && F->hasComdat())
> + continue;
>
> // Remove any call graph edges from the function to its callees.
> CGN->removeAllCalledFunctions();
>
> Added: llvm/trunk/test/Transforms/Inline/pr21206.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/pr21206.ll?rev=219335&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/Inline/pr21206.ll (added)
> +++ llvm/trunk/test/Transforms/Inline/pr21206.ll Wed Oct 8 14:32:32 2014
> @@ -0,0 +1,18 @@
> +; RUN: opt < %s -inline -S | FileCheck %s
> +
> +$c = comdat any
> +; CHECK: $c = comdat any
> +
> +define linkonce_odr void @foo() comdat $c {
> + ret void
> +}
> +; CHECK: define linkonce_odr void @foo() comdat $c
> +
> +define linkonce_odr void @bar() comdat $c {
> + ret void
> +}
> +; CHECK: define linkonce_odr void @bar() comdat $c
> +
> +define void()* @zed() {
> + ret void()* @foo
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list