[llvm] 62b21c6 - [CodeGen] Port `JMCInstrumenter` to new pass manager (#75049)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 17:01:11 PST 2023
Author: paperchalice
Date: 2023-12-12T09:00:44+08:00
New Revision: 62b21c6ced918c7fec97b557e3087e3ffdf71494
URL: https://github.com/llvm/llvm-project/commit/62b21c6ced918c7fec97b557e3087e3ffdf71494
DIFF: https://github.com/llvm/llvm-project/commit/62b21c6ced918c7fec97b557e3087e3ffdf71494.diff
LOG: [CodeGen] Port `JMCInstrumenter` to new pass manager (#75049)
Added:
llvm/include/llvm/CodeGen/JMCInstrumenter.h
Modified:
llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
llvm/include/llvm/CodeGen/MachinePassRegistry.def
llvm/lib/CodeGen/JMCInstrumenter.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll
llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
llvm/tools/opt/opt.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
index bb139ef2eb3510..4e704411270c51 100644
--- a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
@@ -26,6 +26,7 @@
#include "llvm/CodeGen/DwarfEHPrepare.h"
#include "llvm/CodeGen/ExpandReductions.h"
#include "llvm/CodeGen/InterleavedAccess.h"
+#include "llvm/CodeGen/JMCInstrumenter.h"
#include "llvm/CodeGen/MachinePassManager.h"
#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
#include "llvm/CodeGen/ReplaceWithVeclib.h"
diff --git a/llvm/include/llvm/CodeGen/JMCInstrumenter.h b/llvm/include/llvm/CodeGen/JMCInstrumenter.h
new file mode 100644
index 00000000000000..addac1654826cb
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/JMCInstrumenter.h
@@ -0,0 +1,23 @@
+//===-- llvm/CodeGen/JMCInstrumenter------------------------ ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_JMCINSTRUMENTER_H
+#define LLVM_CODEGEN_JMCINSTRUMENTER_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class JMCInstrumenterPass : public PassInfoMixin<JMCInstrumenterPass> {
+public:
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
+};
+
+} // namespace llvm
+
+#endif // LLVM_CODEGEN_JMCINSTRUMENTER_H
diff --git a/llvm/include/llvm/CodeGen/MachinePassRegistry.def b/llvm/include/llvm/CodeGen/MachinePassRegistry.def
index e6e979a4582c7a..6b720736c3e53b 100644
--- a/llvm/include/llvm/CodeGen/MachinePassRegistry.def
+++ b/llvm/include/llvm/CodeGen/MachinePassRegistry.def
@@ -23,6 +23,7 @@ MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis, (PIC))
#define MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)
#endif
MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass, ())
+MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass, ())
#undef MODULE_PASS
#ifndef FUNCTION_ANALYSIS
diff --git a/llvm/lib/CodeGen/JMCInstrumenter.cpp b/llvm/lib/CodeGen/JMCInstrumenter.cpp
index a1f0a50406643e..62a38191887524 100644
--- a/llvm/lib/CodeGen/JMCInstrumenter.cpp
+++ b/llvm/lib/CodeGen/JMCInstrumenter.cpp
@@ -20,6 +20,7 @@
// weak symbol.
//===----------------------------------------------------------------------===//
+#include "llvm/CodeGen/JMCInstrumenter.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/CodeGen/Passes.h"
@@ -39,19 +40,25 @@
using namespace llvm;
-#define DEBUG_TYPE "jmc-instrument"
+#define DEBUG_TYPE "jmc-instrumenter"
+static bool runImpl(Module &M);
namespace {
struct JMCInstrumenter : public ModulePass {
static char ID;
JMCInstrumenter() : ModulePass(ID) {
initializeJMCInstrumenterPass(*PassRegistry::getPassRegistry());
}
- bool runOnModule(Module &M) override;
+ bool runOnModule(Module &M) override { return runImpl(M); }
};
char JMCInstrumenter::ID = 0;
} // namespace
+PreservedAnalyses JMCInstrumenterPass::run(Module &M, ModuleAnalysisManager &) {
+ bool Changed = runImpl(M);
+ return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
+}
+
INITIALIZE_PASS(
JMCInstrumenter, DEBUG_TYPE,
"Instrument function entry with call to __CheckForDebuggerJustMyCode",
@@ -143,7 +150,7 @@ Function *createDefaultCheckFunction(Module &M, bool UseX86FastCall) {
}
} // namespace
-bool JMCInstrumenter::runOnModule(Module &M) {
+bool runImpl(Module &M) {
bool Changed = false;
LLVMContext &Ctx = M.getContext();
Triple ModuleTriple(M.getTargetTriple());
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index f26450e9418700..0608e1b2201ba6 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -78,6 +78,7 @@
#include "llvm/CodeGen/ExpandLargeFpConvert.h"
#include "llvm/CodeGen/HardwareLoops.h"
#include "llvm/CodeGen/InterleavedAccess.h"
+#include "llvm/CodeGen/JMCInstrumenter.h"
#include "llvm/CodeGen/SafeStack.h"
#include "llvm/CodeGen/TypePromotion.h"
#include "llvm/CodeGen/WasmEHPrepare.h"
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 56449906eb6562..d49e35db87222b 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -81,6 +81,7 @@ MODULE_PASS("instrprof", InstrProfilingLoweringPass())
MODULE_PASS("internalize", InternalizePass())
MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
MODULE_PASS("iroutliner", IROutlinerPass())
+MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass())
MODULE_PASS("lower-global-dtors", LowerGlobalDtorsPass())
MODULE_PASS("lower-ifunc", LowerIFuncPass())
MODULE_PASS("lowertypetests", LowerTypeTestsPass())
diff --git a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll b/llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll
index 12ca42703732e2..f2889db2b56d16 100644
--- a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll
+++ b/llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll
@@ -1,4 +1,5 @@
-; RUN: opt -jmc-instrument -mtriple=x86_64-unknown-linux-gnu -S < %s | FileCheck %s
+; RUN: opt -jmc-instrumenter -mtriple=x86_64-unknown-linux-gnu -S < %s | FileCheck %s
+; RUN: opt -passes=jmc-instrumenter -mtriple=x86_64-unknown-linux-gnu -S < %s | FileCheck %s
; CHECK: @"__7DF23CF5_x at c" = internal unnamed_addr global i8 1, section ".data.just.my.code", align 1, !dbg !0
; CHECK: @"__A8764FDD_x at c" = internal unnamed_addr global i8 1, section ".data.just.my.code", align 1, !dbg !5
diff --git a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll b/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
index c884395bea49ba..8a2318eee5e550 100644
--- a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
+++ b/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
@@ -1,4 +1,5 @@
-; RUN: opt -jmc-instrument -S < %s | FileCheck %s
+; RUN: opt -jmc-instrumenter -S < %s | FileCheck %s
+; RUN: opt -passes=jmc-instrumenter -S < %s | FileCheck %s
; CHECK: $_JustMyCode_Default = comdat any
diff --git a/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll b/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
index 098ff1b2a958a3..acbcc2917ae9e9 100644
--- a/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
+++ b/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
@@ -1,6 +1,9 @@
-; RUN: opt -jmc-instrument -mtriple=x86_64-pc-windows-msvc -S < %s | FileCheck %s
-; RUN: opt -jmc-instrument -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
-; RUN: opt -jmc-instrument -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -jmc-instrumenter -mtriple=x86_64-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -jmc-instrumenter -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -jmc-instrumenter -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -passes=jmc-instrumenter -mtriple=x86_64-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -passes=jmc-instrumenter -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -passes=jmc-instrumenter -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
; CHECK: $__JustMyCode_Default = comdat any
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 50b36dc7426777..8d26580d8f381e 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -364,7 +364,7 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
"polyhedral-info",
"print-polyhedral-info",
"replace-with-veclib",
- "jmc-instrument",
+ "jmc-instrumenter",
"dot-regions",
"dot-regions-only",
"view-regions",
More information about the llvm-commits
mailing list