summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2019-06-20 19:35:25 +0000
committerLeonard Chan <leonardchan@google.com>2019-06-20 19:35:25 +0000
commitb206513e459b9d441af8467efab504d691dbad1b (patch)
tree7cf46e781d934716941adf39ca3bee98d909c746
parentf2f7d72f0052b169433790d79e06b5160325c538 (diff)
downloadbcm5719-llvm-b206513e459b9d441af8467efab504d691dbad1b.tar.gz
bcm5719-llvm-b206513e459b9d441af8467efab504d691dbad1b.zip
[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
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp6
-rw-r--r--clang/test/CodeGen/x86_64-instrument-functions.c7
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 2a904d54346..a7c778bc711 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -67,6 +67,7 @@
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
#include "llvm/Transforms/Utils/SymbolRewriter.h"
#include <memory>
@@ -1131,6 +1132,11 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
// configure the pipeline.
PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
+ PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) {
+ MPM.addPass(createModuleToFunctionPassAdaptor(
+ EntryExitInstrumenterPass(/*PostInlining=*/false)));
+ });
+
// Register callbacks to schedule sanitizer passes at the appropriate part of
// the pipeline.
// FIXME: either handle asan/the remaining sanitizers or error out
diff --git a/clang/test/CodeGen/x86_64-instrument-functions.c b/clang/test/CodeGen/x86_64-instrument-functions.c
index 686d9aa14ca..ab87fe375ff 100644
--- a/clang/test/CodeGen/x86_64-instrument-functions.c
+++ b/clang/test/CodeGen/x86_64-instrument-functions.c
@@ -1,6 +1,9 @@
// REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// 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
+
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// 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
// It's not so nice having asm tests in Clang, but we need to check that we set
// up the pipeline correctly in order to have the instrumentation inserted.
OpenPOWER on IntegriCloud