Author: leonardchan Date: Thu Jun 20 12:35:25 2019 New Revision: 363969 URL: http://llvm.org/viewvc/llvm-project?rev=363969&view=rev Log: [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 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/x86_64-instrument-functions.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363969&r1=363968&r2=363969&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 20 12:35:25 2019 @@ -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::EmitAssemblyWit // 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 Modified: cfe/trunk/test/CodeGen/x86_64-instrument-functions.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-instrument-functions.c?rev=363969&r1=363968&r2=363969&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/x86_64-instrument-functions.c (original) +++ cfe/trunk/test/CodeGen/x86_64-instrument-functions.c Thu Jun 20 12:35:25 2019 @@ -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. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits