mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
Moving UniqueInternalLinkageNamesPass to the start of IR pipelines.
`UniqueInternalLinkageNamesPass` is useful to CSSPGO, especially when pseudo probe is used. It solves naming conflict for static functions which otherwise will share a merged profile and likely have a profile quality issue with mismatched CFG checksums. Since the pseudo probe instrumentation happens very early in the pipeline, I'm moving `UniqueInternalLinkageNamesPass` right before it. This is being done only to the new pass manager. Reviewed By: dblaikie, aeubanks Differential Revision: https://reviews.llvm.org/D93656
This commit is contained in:
parent
ed0f2ce728
commit
44ed003650
@ -127,6 +127,9 @@ public:
|
||||
/// Tuning option to enable/disable function merging. Its default value is
|
||||
/// false.
|
||||
bool MergeFunctions;
|
||||
|
||||
/// Uniquefy function linkage name. Its default value is false.
|
||||
bool UniqueLinkageNames;
|
||||
};
|
||||
|
||||
/// This class provides access to building LLVM's passes.
|
||||
|
@ -285,6 +285,7 @@ PipelineTuningOptions::PipelineTuningOptions() {
|
||||
LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
|
||||
CallGraphProfile = true;
|
||||
MergeFunctions = false;
|
||||
UniqueLinkageNames = false;
|
||||
}
|
||||
|
||||
extern cl::opt<bool> EnableConstraintElimination;
|
||||
@ -1003,6 +1004,11 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
|
||||
ThinLTOPhase Phase) {
|
||||
ModulePassManager MPM(DebugLogging);
|
||||
|
||||
// Add UniqueInternalLinkageNames Pass which renames internal linkage
|
||||
// symbols with unique names.
|
||||
if (PTO.UniqueLinkageNames)
|
||||
MPM.addPass(UniqueInternalLinkageNamesPass());
|
||||
|
||||
// Place pseudo probe instrumentation as the first pass of the pipeline to
|
||||
// minimize the impact of optimization changes.
|
||||
if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
|
||||
@ -1773,6 +1779,11 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
|
||||
|
||||
ModulePassManager MPM(DebugLogging);
|
||||
|
||||
// Add UniqueInternalLinkageNames Pass which renames internal linkage
|
||||
// symbols with unique names.
|
||||
if (PTO.UniqueLinkageNames)
|
||||
MPM.addPass(UniqueInternalLinkageNamesPass());
|
||||
|
||||
if (PGOOpt && (PGOOpt->Action == PGOOptions::IRInstr ||
|
||||
PGOOpt->Action == PGOOptions::IRUse))
|
||||
addPGOInstrPassesForO0(
|
||||
|
12
test/Other/new-pm-pseudo-probe.ll
Normal file
12
test/Other/new-pm-pseudo-probe.ll
Normal file
@ -0,0 +1,12 @@
|
||||
; RUN: opt -S -passes='default<O1>' -new-pm-pseudo-probe-for-profiling -debug-pass-manager < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -S -passes='default<O2>' -new-pm-pseudo-probe-for-profiling -debug-pass-manager < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -S -passes='thinlto-pre-link<O1>' -new-pm-pseudo-probe-for-profiling -debug-pass-manager < %s 2>&1 | FileCheck %s
|
||||
; RUN: opt -S -passes='thinlto-pre-link<O2>' -new-pm-pseudo-probe-for-profiling -debug-pass-manager < %s 2>&1 | FileCheck %s
|
||||
|
||||
define void @foo() {
|
||||
ret void
|
||||
}
|
||||
|
||||
;; Check the SampleProfileProbePass is enabled under the -new-pm-pseudo-probe-for-profiling switch.
|
||||
;; The switch can be used to test a specific pass order in a particular setup, e.g, in unique-internal-linkage-names.ll
|
||||
; CHECK: Running pass: SampleProfileProbePass
|
@ -0,0 +1,24 @@
|
||||
; RUN: opt -S -passes='default<O0>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O0 --check-prefix=UNIQUE
|
||||
; RUN: opt -S -passes='default<O1>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
|
||||
; RUN: opt -S -passes='default<O2>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
|
||||
; RUN: opt -S -passes='thinlto-pre-link<O1>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
|
||||
; RUN: opt -S -passes='thinlto-pre-link<O2>' -new-pm-pseudo-probe-for-profiling -new-pm-unique-internal-linkage-names -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefix=O2 --check-prefix=UNIQUE
|
||||
|
||||
define internal i32 @foo() {
|
||||
entry:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define dso_local i32 (...)* @bar() {
|
||||
entry:
|
||||
ret i32 (...)* bitcast (i32 ()* @foo to i32 (...)*)
|
||||
}
|
||||
|
||||
; O0: Running pass: UniqueInternalLinkageNamesPass
|
||||
|
||||
;; Check UniqueInternalLinkageNamesPass is scheduled before SampleProfileProbePass.
|
||||
; O2: Running pass: UniqueInternalLinkageNamesPass
|
||||
; O2: Running pass: SampleProfileProbePass
|
||||
|
||||
; UNIQUE: define internal i32 @foo.__uniq.{{[0-9a-f]+}}()
|
||||
; UNIQUE: ret {{.*}} @foo.__uniq.{{[0-9a-f]+}} {{.*}}
|
@ -134,6 +134,13 @@ static cl::opt<std::string>
|
||||
static cl::opt<bool> DebugInfoForProfiling(
|
||||
"new-pm-debug-info-for-profiling", cl::init(false), cl::Hidden,
|
||||
cl::desc("Emit special debug info to enable PGO profile generation."));
|
||||
static cl::opt<bool> PseudoProbeForProfiling(
|
||||
"new-pm-pseudo-probe-for-profiling", cl::init(false), cl::Hidden,
|
||||
cl::desc("Emit pseudo probes to enable PGO profile generation."));
|
||||
static cl::opt<bool> UniqueInternalLinkageNames(
|
||||
"new-pm-unique-internal-linkage-names", cl::init(false), cl::Hidden,
|
||||
cl::desc("Uniqueify Internal Linkage Symbol Names by appending the MD5 "
|
||||
"hash of the module path."));
|
||||
/// @}}
|
||||
|
||||
template <typename PassManagerT>
|
||||
@ -247,6 +254,9 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
||||
if (DebugInfoForProfiling)
|
||||
P = PGOOptions("", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
|
||||
true);
|
||||
else if (PseudoProbeForProfiling)
|
||||
P = PGOOptions("", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
|
||||
false, true);
|
||||
else
|
||||
P = None;
|
||||
}
|
||||
@ -282,6 +292,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
|
||||
// option has been enabled.
|
||||
PTO.LoopUnrolling = !DisableLoopUnrolling;
|
||||
PTO.Coroutines = Coroutines;
|
||||
PTO.UniqueLinkageNames = UniqueInternalLinkageNames;
|
||||
PassBuilder PB(DebugPM, TM, PTO, P, &PIC);
|
||||
registerEPCallbacks(PB);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user