Skip to content

Commit b206513

Browse files
committedJun 20, 2019
[clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline
This fixes CodeGen/x86_64-instrument-functions.c when running under the new pass manager. The pass should go before any other pass to prevent `__cyg_profile_func_enter/exit()` from not being emitted by inlined functions. Differential Revision: https://reviews.llvm.org/D63577 llvm-svn: 363969
1 parent f2f7d72 commit b206513

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎clang/lib/CodeGen/BackendUtil.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include "llvm/Transforms/Scalar/GVN.h"
6868
#include "llvm/Transforms/Utils.h"
6969
#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
70+
#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
7071
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
7172
#include "llvm/Transforms/Utils/SymbolRewriter.h"
7273
#include <memory>
@@ -1131,6 +1132,11 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
11311132
// configure the pipeline.
11321133
PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
11331134

1135+
PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) {
1136+
MPM.addPass(createModuleToFunctionPassAdaptor(
1137+
EntryExitInstrumenterPass(/*PostInlining=*/false)));
1138+
});
1139+
11341140
// Register callbacks to schedule sanitizer passes at the appropriate part of
11351141
// the pipeline.
11361142
// FIXME: either handle asan/the remaining sanitizers or error out

‎clang/test/CodeGen/x86_64-instrument-functions.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// REQUIRES: x86-registered-target
2-
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
3-
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
2+
// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
3+
// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
4+
5+
// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
6+
// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
47

58
// It's not so nice having asm tests in Clang, but we need to check that we set
69
// up the pipeline correctly in order to have the instrumentation inserted.

0 commit comments

Comments
 (0)
Please sign in to comment.