[Beignet] [PATCH] GBE: reorder the LLVM pass to reduce the compilation time.

Yan Wang yan.wang at linux.intel.com
Mon Dec 26 06:04:49 UTC 2016


LGTM.
Thanks.

Yan Wang

On Fri, 2016-12-16 at 16:38 +0800, Yang Rong wrote:
> Set all function's linkage to LinkOnceAnyLinkage, then Inlining pass
> could delete the inlined functions.
> And reorder createFunctionInliningPass before
> createStripAttributesPass
> can reduce the compilation time significant, but haven't found the
> root
> casue.
> 
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
>  backend/src/llvm/StripAttributes.cpp | 6 ++++--
>  backend/src/llvm/llvm_to_gen.cpp     | 6 +++---
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/backend/src/llvm/StripAttributes.cpp
> b/backend/src/llvm/StripAttributes.cpp
> index 3bf3853..9d07c29 100644
> --- a/backend/src/llvm/StripAttributes.cpp
> +++ b/backend/src/llvm/StripAttributes.cpp
> @@ -89,10 +89,12 @@ namespace {
>  char StripAttributes::ID = 0;
>  
>  bool StripAttributes::runOnFunction(Function &Func) {
> -  if (!gbe::isKernelFunction(Func))
> -    Func.addFnAttr(Attribute::AlwaysInline);
>    Func.setCallingConv(CallingConv::C);
>    Func.setLinkage(GlobalValue::ExternalLinkage);
> +  if (!gbe::isKernelFunction(Func)) {
> +    Func.addFnAttr(Attribute::AlwaysInline);
> +    Func.setLinkage(GlobalValue::LinkOnceAnyLinkage);
> +  }
>  
>    for (Function::iterator BB = Func.begin(), E = Func.end();
>         BB != E; ++BB) {
> diff --git a/backend/src/llvm/llvm_to_gen.cpp
> b/backend/src/llvm/llvm_to_gen.cpp
> index e108810..a889c56 100644
> --- a/backend/src/llvm/llvm_to_gen.cpp
> +++ b/backend/src/llvm/llvm_to_gen.cpp
> @@ -136,6 +136,9 @@ namespace gbe
>      MPM.add(createBasicAliasAnalysisPass());
>  #endif
>      MPM.add(createIntrinsicLoweringPass());
> +    MPM.add(createBarrierNodupPass(false));   // remove noduplicate
> fnAttr before inlining.
> +    MPM.add(createFunctionInliningPass(20000));
> +    MPM.add(createBarrierNodupPass(true));    // restore noduplicate
> fnAttr after inlining.
>      MPM.add(createStripAttributesPass());     // Strip unsupported
> attributes and calling conventions.
>      MPM.add(createSamplerFixPass());
>      MPM.add(createGlobalOptimizerPass());     // Optimize out global
> vars
> @@ -146,9 +149,6 @@ namespace gbe
>      MPM.add(createInstructionCombiningPass());// Clean up after IPCP
> & DAE
>      MPM.add(createCFGSimplificationPass());   // Clean up after IPCP
> & DAE
>      MPM.add(createPruneEHPass());             // Remove dead EH info
> -    MPM.add(createBarrierNodupPass(false));   // remove noduplicate
> fnAttr before inlining.
> -    MPM.add(createFunctionInliningPass(20000));
> -    MPM.add(createBarrierNodupPass(true));    // restore noduplicate
> fnAttr after inlining.
>  #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9
>      MPM.add(createPostOrderFunctionAttrsLegacyPass());
>  #elif LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8


More information about the Beignet mailing list