[llvm] r178130 - Improve performance of LinkModules when linking with modules with large numbers of functions which link lazily. Instead of creating and destroying function prototypes irrespective of if they are used, only create them if they are used.

Duncan Sands baldrick at free.fr
Wed Mar 27 06:00:09 PDT 2013


Hi James,

On 27/03/13 11:23, James Molloy wrote:
> Author: jamesm
> Date: Wed Mar 27 05:23:32 2013
> New Revision: 178130
>
> URL: http://llvm.org/viewvc/llvm-project?rev=178130&view=rev
> Log:
> Improve performance of LinkModules when linking with modules with large numbers of functions which link lazily. Instead of creating and destroying function prototypes irrespective of if they are used, only create them if they are used.
>
> Modified:
>      llvm/trunk/lib/Linker/LinkModules.cpp
...

> --- llvm/trunk/lib/Linker/LinkModules.cpp (original)
> +++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Mar 27 05:23:32 2013
> @@ -801,6 +806,18 @@ bool ModuleLinker::linkFunctionProto(Fun
>       }
>     }
>
> +  // If the function is to be lazily linked, don't create it just yet.
> +  // Instead, remember its current set of uses to diff against later.
> +  if (!DGV && (SF->hasLocalLinkage() || SF->hasLinkOnceLinkage() ||
> +               SF->hasAvailableExternallyLinkage())) {
> +    LazyLinkEntry LLE;
> +    LLE.Fn = SF;
> +    LLE.Uses.insert(SF->use_begin(), SF->use_end());
> +    LazilyLinkFunctions.push_back(LLE);

I think this makes a copy of LLE, i.e. of all those "use" entries you just
pushed into it, which might be a lot.  Maybe you can first grow the vector,
then directly access the last element and push the uses into it, avoiding
the copy.

> +    DoNotLinkFromSource.insert(SF);
> +    return false;
> +  }
> +
>     // If there is no linkage to be performed or we are linking from the source,
>     // bring SF over.
>     Function *NewDF = Function::Create(TypeMap.get(SF->getFunctionType()),

Ciao, Duncan.




More information about the llvm-commits mailing list