Skip to content

Commit 62b21c6

Browse files
authored
[CodeGen] Port JMCInstrumenter to new pass manager (#75049)
1 parent a8ef9c0 commit 62b21c6

File tree

10 files changed

+48
-9
lines changed

10 files changed

+48
-9
lines changed

llvm/include/llvm/CodeGen/CodeGenPassBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/CodeGen/DwarfEHPrepare.h"
2727
#include "llvm/CodeGen/ExpandReductions.h"
2828
#include "llvm/CodeGen/InterleavedAccess.h"
29+
#include "llvm/CodeGen/JMCInstrumenter.h"
2930
#include "llvm/CodeGen/MachinePassManager.h"
3031
#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
3132
#include "llvm/CodeGen/ReplaceWithVeclib.h"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- llvm/CodeGen/JMCInstrumenter------------------------ ----*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CODEGEN_JMCINSTRUMENTER_H
10+
#define LLVM_CODEGEN_JMCINSTRUMENTER_H
11+
12+
#include "llvm/IR/PassManager.h"
13+
14+
namespace llvm {
15+
16+
class JMCInstrumenterPass : public PassInfoMixin<JMCInstrumenterPass> {
17+
public:
18+
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
19+
};
20+
21+
} // namespace llvm
22+
23+
#endif // LLVM_CODEGEN_JMCINSTRUMENTER_H

llvm/include/llvm/CodeGen/MachinePassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis, (PIC))
2323
#define MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)
2424
#endif
2525
MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass, ())
26+
MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass, ())
2627
#undef MODULE_PASS
2728

2829
#ifndef FUNCTION_ANALYSIS

llvm/lib/CodeGen/JMCInstrumenter.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// weak symbol.
2121
//===----------------------------------------------------------------------===//
2222

23+
#include "llvm/CodeGen/JMCInstrumenter.h"
2324
#include "llvm/ADT/SmallString.h"
2425
#include "llvm/ADT/StringExtras.h"
2526
#include "llvm/CodeGen/Passes.h"
@@ -39,19 +40,25 @@
3940

4041
using namespace llvm;
4142

42-
#define DEBUG_TYPE "jmc-instrument"
43+
#define DEBUG_TYPE "jmc-instrumenter"
4344

45+
static bool runImpl(Module &M);
4446
namespace {
4547
struct JMCInstrumenter : public ModulePass {
4648
static char ID;
4749
JMCInstrumenter() : ModulePass(ID) {
4850
initializeJMCInstrumenterPass(*PassRegistry::getPassRegistry());
4951
}
50-
bool runOnModule(Module &M) override;
52+
bool runOnModule(Module &M) override { return runImpl(M); }
5153
};
5254
char JMCInstrumenter::ID = 0;
5355
} // namespace
5456

57+
PreservedAnalyses JMCInstrumenterPass::run(Module &M, ModuleAnalysisManager &) {
58+
bool Changed = runImpl(M);
59+
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
60+
}
61+
5562
INITIALIZE_PASS(
5663
JMCInstrumenter, DEBUG_TYPE,
5764
"Instrument function entry with call to __CheckForDebuggerJustMyCode",
@@ -143,7 +150,7 @@ Function *createDefaultCheckFunction(Module &M, bool UseX86FastCall) {
143150
}
144151
} // namespace
145152

146-
bool JMCInstrumenter::runOnModule(Module &M) {
153+
bool runImpl(Module &M) {
147154
bool Changed = false;
148155
LLVMContext &Ctx = M.getContext();
149156
Triple ModuleTriple(M.getTargetTriple());

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "llvm/CodeGen/ExpandLargeFpConvert.h"
7979
#include "llvm/CodeGen/HardwareLoops.h"
8080
#include "llvm/CodeGen/InterleavedAccess.h"
81+
#include "llvm/CodeGen/JMCInstrumenter.h"
8182
#include "llvm/CodeGen/SafeStack.h"
8283
#include "llvm/CodeGen/TypePromotion.h"
8384
#include "llvm/CodeGen/WasmEHPrepare.h"

llvm/lib/Passes/PassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ MODULE_PASS("instrprof", InstrProfilingLoweringPass())
8181
MODULE_PASS("internalize", InternalizePass())
8282
MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
8383
MODULE_PASS("iroutliner", IROutlinerPass())
84+
MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass())
8485
MODULE_PASS("lower-global-dtors", LowerGlobalDtorsPass())
8586
MODULE_PASS("lower-ifunc", LowerIFuncPass())
8687
MODULE_PASS("lowertypetests", LowerTypeTestsPass())

llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
; RUN: opt -jmc-instrument -mtriple=x86_64-unknown-linux-gnu -S < %s | FileCheck %s
1+
; RUN: opt -jmc-instrumenter -mtriple=x86_64-unknown-linux-gnu -S < %s | FileCheck %s
2+
; RUN: opt -passes=jmc-instrumenter -mtriple=x86_64-unknown-linux-gnu -S < %s | FileCheck %s
23

34
; CHECK: @"__7DF23CF5_x@c" = internal unnamed_addr global i8 1, section ".data.just.my.code", align 1, !dbg !0
45
; CHECK: @"__A8764FDD_x@c" = internal unnamed_addr global i8 1, section ".data.just.my.code", align 1, !dbg !5

llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
; RUN: opt -jmc-instrument -S < %s | FileCheck %s
1+
; RUN: opt -jmc-instrumenter -S < %s | FileCheck %s
2+
; RUN: opt -passes=jmc-instrumenter -S < %s | FileCheck %s
23

34
; CHECK: $_JustMyCode_Default = comdat any
45

llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
; RUN: opt -jmc-instrument -mtriple=x86_64-pc-windows-msvc -S < %s | FileCheck %s
2-
; RUN: opt -jmc-instrument -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
3-
; RUN: opt -jmc-instrument -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
1+
; RUN: opt -jmc-instrumenter -mtriple=x86_64-pc-windows-msvc -S < %s | FileCheck %s
2+
; RUN: opt -jmc-instrumenter -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
3+
; RUN: opt -jmc-instrumenter -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
4+
; RUN: opt -passes=jmc-instrumenter -mtriple=x86_64-pc-windows-msvc -S < %s | FileCheck %s
5+
; RUN: opt -passes=jmc-instrumenter -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
6+
; RUN: opt -passes=jmc-instrumenter -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
47

58
; CHECK: $__JustMyCode_Default = comdat any
69

llvm/tools/opt/opt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
364364
"polyhedral-info",
365365
"print-polyhedral-info",
366366
"replace-with-veclib",
367-
"jmc-instrument",
367+
"jmc-instrumenter",
368368
"dot-regions",
369369
"dot-regions-only",
370370
"view-regions",

0 commit comments

Comments
 (0)