From 2de2d84ed0b2e7cd27f4de9b98f5f8a38b1e6e57 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Fri, 29 Jan 2021 00:45:04 +0300 Subject: [PATCH] [NFC][EntryExitInstrumenter] Mark Dominator Tree as preserved in legacy-PM too This is correctly handled in new-PM wrappers, but not in old-PM. --- .../lib/Transforms/Utils/EntryExitInstrumenter.cpp | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp index 26f8e21..31d03e1 100644 --- a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp +++ b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp @@ -9,6 +9,7 @@ #include "llvm/Transforms/Utils/EntryExitInstrumenter.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/IR/DebugInfoMetadata.h" +#include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Intrinsics.h" @@ -17,6 +18,7 @@ #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils.h" + using namespace llvm; static void insertCall(Function &CurFn, StringRef Func, @@ -123,6 +125,7 @@ struct EntryExitInstrumenter : public FunctionPass { } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addPreserved(); + AU.addPreserved(); } bool runOnFunction(Function &F) override { return ::runOnFunction(F, false); } }; @@ -136,20 +139,34 @@ struct PostInlineEntryExitInstrumenter : public FunctionPass { } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addPreserved(); + AU.addPreserved(); } bool runOnFunction(Function &F) override { return ::runOnFunction(F, true); } }; char PostInlineEntryExitInstrumenter::ID = 0; } -INITIALIZE_PASS( +INITIALIZE_PASS_BEGIN( + EntryExitInstrumenter, "ee-instrument", + "Instrument function entry/exit with calls to e.g. mcount() (pre inlining)", + false, false) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) +INITIALIZE_PASS_END( EntryExitInstrumenter, "ee-instrument", "Instrument function entry/exit with calls to e.g. mcount() (pre inlining)", false, false) -INITIALIZE_PASS(PostInlineEntryExitInstrumenter, "post-inline-ee-instrument", - "Instrument function entry/exit with calls to e.g. mcount() " - "(post inlining)", - false, false) + +INITIALIZE_PASS_BEGIN( + PostInlineEntryExitInstrumenter, "post-inline-ee-instrument", + "Instrument function entry/exit with calls to e.g. mcount() " + "(post inlining)", + false, false) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) +INITIALIZE_PASS_END( + PostInlineEntryExitInstrumenter, "post-inline-ee-instrument", + "Instrument function entry/exit with calls to e.g. mcount() " + "(post inlining)", + false, false) FunctionPass *llvm::createEntryExitInstrumenterPass() { return new EntryExitInstrumenter(); -- 2.7.4