[llvm] r269660 - [PM] Port indirect call promotion pass to new pass manager

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 14:01:40 PDT 2016


Xinliang David Li via llvm-commits <llvm-commits at lists.llvm.org> writes:
> Author: davidxl
> Date: Mon May 16 11:31:07 2016
> New Revision: 269660
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269660&view=rev
> Log:
> [PM] Port indirect call promotion pass to new pass manager
>
> Modified:
>     llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h
>     llvm/trunk/lib/Passes/PassRegistry.def
>     llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
>     llvm/trunk/test/Transforms/PGOProfile/icp_covariant_call_return.ll
>     llvm/trunk/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
>     llvm/trunk/test/Transforms/PGOProfile/icp_invoke.ll
>     llvm/trunk/test/Transforms/PGOProfile/icp_mismatch_msg.ll
>     llvm/trunk/test/Transforms/PGOProfile/icp_vararg.ll
>     llvm/trunk/test/Transforms/PGOProfile/indirect_call_promotion.ll
>
> Modified: llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h (original)
> +++ llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h Mon May 16 11:31:07 2016
> @@ -35,5 +35,15 @@ private:
>    std::string ProfileFileName;
>  };
>  
> +/// The indirect function call promotion pass.
> +class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> {
> +public:
> +  PGOIndirectCallPromotion() : InLTO(false) {}
> +  PreservedAnalyses run(Module &M, AnalysisManager<Module> &AM);
> +  void setInLTO() { InLTO = true; }

Why a separate setter, rather than making this a parameter to the
constructor?

> +private:
> +  bool InLTO;
> +};
> +
>  } // End llvm namespace
>  #endif
>
> Modified: llvm/trunk/lib/Passes/PassRegistry.def
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassRegistry.def?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Passes/PassRegistry.def (original)
> +++ llvm/trunk/lib/Passes/PassRegistry.def Mon May 16 11:31:07 2016
> @@ -47,6 +47,7 @@ MODULE_PASS("instrprof", InstrProfiling(
>  MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
>  MODULE_PASS("ipsccp", IPSCCPPass())
>  MODULE_PASS("no-op-module", NoOpModulePass())
> +MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion())
>  MODULE_PASS("pgo-instr-gen", PGOInstrumentationGen())
>  MODULE_PASS("pgo-instr-use", PGOInstrumentationUse())
>  MODULE_PASS("print", PrintModulePass(dbgs()))
>
> Modified: llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp Mon May 16 11:31:07 2016
> @@ -31,6 +31,7 @@
>  #include "llvm/ProfileData/InstrProfReader.h"
>  #include "llvm/Support/Debug.h"
>  #include "llvm/Transforms/Instrumentation.h"
> +#include "llvm/Transforms/PGOInstrumentation.h"
>  #include "llvm/Transforms/Utils/BasicBlockUtils.h"
>  #include <string>
>  #include <utility>
> @@ -693,3 +694,11 @@ bool PGOIndirectCallPromotionLegacyPass:
>    InLTO |= ICPLTOMode;
>    return promoteIndirectCalls(M, InLTO);
>  }
> +
> +PreservedAnalyses PGOIndirectCallPromotion::run(Module &M, AnalysisManager<Module> &AM) {
> +  InLTO |= ICPLTOMode;

I guess this is also how the legacy version works, but it seems really
strange to change the member variable based on the cl::opt. Wouldn't it
be more normal to just call the function with `InLTO || ICPLTOMode`
below?

> +  if (!promoteIndirectCalls(M, InLTO))
> +    return PreservedAnalyses::all();
> +
> +  return PreservedAnalyses::none();
> +}
>
> Modified: llvm/trunk/test/Transforms/PGOProfile/icp_covariant_call_return.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/icp_covariant_call_return.ll?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/PGOProfile/icp_covariant_call_return.ll (original)
> +++ llvm/trunk/test/Transforms/PGOProfile/icp_covariant_call_return.ll Mon May 16 11:31:07 2016
> @@ -1,4 +1,5 @@
>  ; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
> +; RUN: opt < %s -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
>  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>  target triple = "x86_64-unknown-linux-gnu"
>  
>
> Modified: llvm/trunk/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll (original)
> +++ llvm/trunk/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll Mon May 16 11:31:07 2016
> @@ -1,4 +1,5 @@
>  ; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
> +; RUN: opt < %s -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
>  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>  target triple = "x86_64-unknown-linux-gnu"
>  %struct.D = type { %struct.B }
>
> Modified: llvm/trunk/test/Transforms/PGOProfile/icp_invoke.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/icp_invoke.ll?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/PGOProfile/icp_invoke.ll (original)
> +++ llvm/trunk/test/Transforms/PGOProfile/icp_invoke.ll Mon May 16 11:31:07 2016
> @@ -1,4 +1,5 @@
>  ; RUN: opt < %s -icp-lto -pgo-icall-prom -S -icp-count-threshold=0 | FileCheck %s --check-prefix=ICP
> +; RUN: opt < %s -icp-lto -passes=pgo-icall-prom -S -icp-count-threshold=0 | FileCheck %s --check-prefix=ICP
>  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>  target triple = "x86_64-unknown-linux-gnu"
>  
>
> Modified: llvm/trunk/test/Transforms/PGOProfile/icp_mismatch_msg.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/icp_mismatch_msg.ll?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/PGOProfile/icp_mismatch_msg.ll (original)
> +++ llvm/trunk/test/Transforms/PGOProfile/icp_mismatch_msg.ll Mon May 16 11:31:07 2016
> @@ -1,4 +1,5 @@
>  ; RUN: opt < %s -pgo-icall-prom -pass-remarks-missed=PGOIndirectCallPromotion -S 2>& 1 | FileCheck %s
> +; RUN: opt < %s -passes=pgo-icall-prom -pass-remarks-missed=PGOIndirectCallPromotion -S 2>& 1 | FileCheck %s
>  
>  ; CHECK: remark: <unknown>:0:0: Cannot promote indirect call to func4 with count of 1234: The number of arguments mismatch
>  ; CHECK: remark: <unknown>:0:0: Cannot promote indirect call to 11517462787082255043 with count of 2345: Cannot find the target
>
> Modified: llvm/trunk/test/Transforms/PGOProfile/icp_vararg.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/icp_vararg.ll?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/PGOProfile/icp_vararg.ll (original)
> +++ llvm/trunk/test/Transforms/PGOProfile/icp_vararg.ll Mon May 16 11:31:07 2016
> @@ -1,4 +1,5 @@
>  ; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
> +; RUN: opt < %s -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
>  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>  target triple = "x86_64-unknown-linux-gnu"
>  
>
> Modified: llvm/trunk/test/Transforms/PGOProfile/indirect_call_promotion.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/indirect_call_promotion.ll?rev=269660&r1=269659&r2=269660&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/PGOProfile/indirect_call_promotion.ll (original)
> +++ llvm/trunk/test/Transforms/PGOProfile/indirect_call_promotion.ll Mon May 16 11:31:07 2016
> @@ -1,5 +1,7 @@
>  ; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
> +; RUN: opt < %s -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
>  ; RUN: opt < %s -pgo-icall-prom -S -pass-remarks=PGOIndirectCallPromotion -icp-count-threshold=0 -icp-percent-threshold=0 -icp-max-prom=4 2>&1 | FileCheck %s --check-prefix=PASS-REMARK
> +; RUN: opt < %s -passes=pgo-icall-prom -S -pass-remarks=PGOIndirectCallPromotion -icp-count-threshold=0 -icp-percent-threshold=0 -icp-max-prom=4 2>&1 | FileCheck %s --check-prefix=PASS-REMARK
>  ; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func4 with count 1030 out of 1600
>  ; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func2 with count 410 out of 570
>  ; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func3 with count 150 out of 160
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list