forked from OSchip/llvm-project
NewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.
Using a new extension point in the new PM, register GCOV at the start of the pipeline rather than the end. llvm-svn: 323167
This commit is contained in:
parent
0c64f5a2eb
commit
ac904d0e3a
|
@ -909,6 +909,9 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
|
||||||
bool IsLTO = CodeGenOpts.PrepareForLTO;
|
bool IsLTO = CodeGenOpts.PrepareForLTO;
|
||||||
|
|
||||||
if (CodeGenOpts.OptimizationLevel == 0) {
|
if (CodeGenOpts.OptimizationLevel == 0) {
|
||||||
|
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts))
|
||||||
|
MPM.addPass(GCOVProfilerPass(*Options));
|
||||||
|
|
||||||
// Build a minimal pipeline based on the semantics required by Clang,
|
// Build a minimal pipeline based on the semantics required by Clang,
|
||||||
// which is just that always inlining occurs.
|
// which is just that always inlining occurs.
|
||||||
MPM.addPass(AlwaysInlinerPass());
|
MPM.addPass(AlwaysInlinerPass());
|
||||||
|
@ -932,6 +935,10 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
|
||||||
[](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
|
[](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
|
||||||
FPM.addPass(BoundsCheckingPass());
|
FPM.addPass(BoundsCheckingPass());
|
||||||
});
|
});
|
||||||
|
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts))
|
||||||
|
PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) {
|
||||||
|
MPM.addPass(GCOVProfilerPass(*Options));
|
||||||
|
});
|
||||||
|
|
||||||
if (IsThinLTO) {
|
if (IsThinLTO) {
|
||||||
MPM = PB.buildThinLTOPreLinkDefaultPipeline(
|
MPM = PB.buildThinLTOPreLinkDefaultPipeline(
|
||||||
|
@ -945,9 +952,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
|
||||||
CodeGenOpts.DebugPassManager);
|
CodeGenOpts.DebugPassManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts)) {
|
|
||||||
MPM.addPass(GCOVProfilerPass(*Options));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: We still use the legacy pass manager to do code generation. We
|
// FIXME: We still use the legacy pass manager to do code generation. We
|
||||||
|
|
|
@ -3,9 +3,15 @@
|
||||||
// RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data -coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix GCOV_FILE_INFO
|
// RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data -coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix GCOV_FILE_INFO
|
||||||
|
|
||||||
// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -femit-coverage-data %s 2>&1 | FileCheck --check-prefix=NEWPM %s
|
// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -femit-coverage-data %s 2>&1 | FileCheck --check-prefix=NEWPM %s
|
||||||
|
// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -femit-coverage-data -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s
|
||||||
|
|
||||||
|
// NEWPM-NOT: Running pass
|
||||||
// NEWPM: Running pass: GCOVProfilerPass
|
// NEWPM: Running pass: GCOVProfilerPass
|
||||||
|
|
||||||
|
// NEWPM-O3-NOT: Running pass
|
||||||
|
// NEWPM-O3: Running pass: ForceFunctionAttrsPass
|
||||||
|
// NEWPM-O3: Running pass: GCOVProfilerPass
|
||||||
|
|
||||||
|
|
||||||
int test1(int a) {
|
int test1(int a) {
|
||||||
switch (a % 2) {
|
switch (a % 2) {
|
||||||
|
|
Loading…
Reference in New Issue