[PATCH] D96803: EntryExitInstrumenter: Enable at all optimization levels (PR49143)
Adhemerval Zanella via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 19 09:04:43 PST 2021
zatrazz updated this revision to Diff 325004.
zatrazz retitled this revision from "EntryExitInstrumenter: Move to a module pass and enable at all optimization levels (PR49143)" to "EntryExitInstrumenter: Enable at all optimization levels (PR49143)".
zatrazz edited the summary of this revision.
zatrazz added a comment.
Updated patch based on previous comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96803/new/
https://reviews.llvm.org/D96803
Files:
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
Index: llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
===================================================================
--- llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
+++ llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
@@ -1,4 +1,7 @@
-; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
+; RUN: opt --O0 --ee-instrument --inline --post-inline-ee-instrument -S < %s | FileCheck %s
+
+; Check if the pass is enabbled on both -O0 and higher optimization levels
+; RUN: opt --O2 --ee-instrument --post-inline-ee-instrument -S < %s | FileCheck --check-prefix=OPT %s
; Running the passes twice should not result in more instrumentation.
; RUN: opt -passes="function(ee-instrument),function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
@@ -18,6 +21,15 @@
; CHECK-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %1)
; CHECK-NEXT: ret void
+
+; OPT-LABEL: define void @leaf_function()
+; OPT: entry:
+; OPT-NEXT: call void @mcount()
+; OPT-NEXT: %0 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* @leaf_function to i8*), i8* %0)
+; OPT-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %1)
+; OPT-NEXT: ret void
}
@@ -42,6 +54,16 @@
; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @root_function to i8*), i8* %3)
; CHECK-NEXT: ret void
+
+; OPT-LABEL: define void @root_function()
+; OPT: entry:
+; OPT-NEXT: call void @mcount()
+
+; OPT-NEXT: %0 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* @root_function to i8*), i8* %0)
+; OPT-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @root_function to i8*), i8* %1)
+; OPT-NEXT: ret void
}
Index: llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
+++ llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
@@ -19,8 +19,6 @@
namespace llvm {
-class Function;
-
struct EntryExitInstrumenterPass
: public PassInfoMixin<EntryExitInstrumenterPass> {
EntryExitInstrumenterPass(bool PostInlining) : PostInlining(PostInlining) {}
@@ -28,6 +26,8 @@
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
bool PostInlining;
+
+ static bool isRequired() { return true; }
};
} // namespace llvm
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1312,7 +1312,9 @@
/*DropTypeTests=*/true));
});
- if (Level != PassBuilder::OptimizationLevel::O0) {
+ if (CodeGenOpts.InstrumentFunctions ||
+ CodeGenOpts.InstrumentFunctionsAfterInlining ||
+ CodeGenOpts.InstrumentFunctionEntryBare) {
PB.registerPipelineStartEPCallback(
[](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
MPM.addPass(createModuleToFunctionPassAdaptor(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96803.325004.patch
Type: text/x-patch
Size: 3485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210219/16992b6b/attachment.bin>
More information about the cfe-commits
mailing list