[llvm] [CodeGen] Update DwarfEHPreparePass references in `CodeGenPassBuilder.h` (PR #74068)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 19:30:45 PST 2023
https://github.com/paperchalice updated https://github.com/llvm/llvm-project/pull/74068
>From f391d5fb6d7f473c714b82e859dc2b925a5f362b Mon Sep 17 00:00:00 2001
From: PaperChalice <29250197+paperchalice at users.noreply.github.com>
Date: Sat, 2 Dec 2023 10:21:43 +0800
Subject: [PATCH 1/2] [CodeGen] Rename CallBrPrepare -> CallBrPrepareLegacy
---
llvm/include/llvm/InitializePasses.h | 2 +-
llvm/lib/CodeGen/CallBrPrepare.cpp | 18 ++++++++++--------
llvm/lib/CodeGen/CodeGen.cpp | 2 +-
llvm/tools/opt/opt.cpp | 2 +-
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 66177f9b9f774f4..4fddc7228d45977 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -70,7 +70,7 @@ void initializeCFGuardPass(PassRegistry&);
void initializeCFGuardLongjmpPass(PassRegistry&);
void initializeCFIFixupPass(PassRegistry&);
void initializeCFIInstrInserterPass(PassRegistry&);
-void initializeCallBrPreparePass(PassRegistry &);
+void initializeCallBrPrepareLegacyPass(PassRegistry &);
void initializeCallGraphDOTPrinterPass(PassRegistry&);
void initializeCallGraphViewerPass(PassRegistry&);
void initializeCallGraphWrapperPassPass(PassRegistry&);
diff --git a/llvm/lib/CodeGen/CallBrPrepare.cpp b/llvm/lib/CodeGen/CallBrPrepare.cpp
index fddc4d74b2da918..44fc8545b998a3b 100644
--- a/llvm/lib/CodeGen/CallBrPrepare.cpp
+++ b/llvm/lib/CodeGen/CallBrPrepare.cpp
@@ -63,9 +63,9 @@ static SmallVector<CallBrInst *, 2> FindCallBrs(Function &Fn);
namespace {
-class CallBrPrepare : public FunctionPass {
+class CallBrPrepareLegacy : public FunctionPass {
public:
- CallBrPrepare() : FunctionPass(ID) {}
+ CallBrPrepareLegacy() : FunctionPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool runOnFunction(Function &Fn) override;
static char ID;
@@ -93,14 +93,16 @@ PreservedAnalyses CallBrPreparePass::run(Function &Fn,
return PA;
}
-char CallBrPrepare::ID = 0;
-INITIALIZE_PASS_BEGIN(CallBrPrepare, DEBUG_TYPE, "Prepare callbr", false, false)
+char CallBrPrepareLegacy::ID = 0;
+INITIALIZE_PASS_BEGIN(CallBrPrepareLegacy, DEBUG_TYPE, "Prepare callbr", false,
+ false)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
-INITIALIZE_PASS_END(CallBrPrepare, DEBUG_TYPE, "Prepare callbr", false, false)
+INITIALIZE_PASS_END(CallBrPrepareLegacy, DEBUG_TYPE, "Prepare callbr", false,
+ false)
-FunctionPass *llvm::createCallBrPass() { return new CallBrPrepare(); }
+FunctionPass *llvm::createCallBrPass() { return new CallBrPrepareLegacy(); }
-void CallBrPrepare::getAnalysisUsage(AnalysisUsage &AU) const {
+void CallBrPrepareLegacy::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<DominatorTreeWrapperPass>();
}
@@ -217,7 +219,7 @@ void UpdateSSA(DominatorTree &DT, CallBrInst *CBR, CallInst *Intrinsic,
}
}
-bool CallBrPrepare::runOnFunction(Function &Fn) {
+bool CallBrPrepareLegacy::runOnFunction(Function &Fn) {
bool Changed = false;
SmallVector<CallBrInst *, 2> CBRs = FindCallBrs(Fn);
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index 79a95ee0d747a1c..2a8124a21740611 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -25,7 +25,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeBranchFolderPassPass(Registry);
initializeBranchRelaxationPass(Registry);
initializeBreakFalseDepsPass(Registry);
- initializeCallBrPreparePass(Registry);
+ initializeCallBrPrepareLegacyPass(Registry);
initializeCFGuardLongjmpPass(Registry);
initializeCFIFixupPass(Registry);
initializeCFIInstrInserterPass(Registry);
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 5e5e5ce233f310a..7d2bdadd086ad21 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -425,7 +425,7 @@ int main(int argc, char **argv) {
initializeExpandMemCmpPassPass(Registry);
initializeScalarizeMaskedMemIntrinLegacyPassPass(Registry);
initializeSelectOptimizePass(Registry);
- initializeCallBrPreparePass(Registry);
+ initializeCallBrPrepareLegacyPass(Registry);
initializeCodeGenPreparePass(Registry);
initializeAtomicExpandPass(Registry);
initializeWinEHPreparePass(Registry);
>From 516c32655c3bdcbb26563e9f813d5af7541886b1 Mon Sep 17 00:00:00 2001
From: PaperChalice <29250197+paperchalice at users.noreply.github.com>
Date: Fri, 1 Dec 2023 19:56:05 +0800
Subject: [PATCH 2/2] [CodeGen] Update DwarfEHPreparePass references in
CodeGenPassBuilder.h
---
llvm/include/llvm/CodeGen/CodeGenPassBuilder.h | 5 +++--
llvm/include/llvm/CodeGen/MachinePassRegistry.def | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
index 0a12f4210998627..9b60101bf4369a8 100644
--- a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
@@ -23,6 +23,7 @@
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
#include "llvm/CodeGen/CallBrPrepare.h"
+#include "llvm/CodeGen/DwarfEHPrepare.h"
#include "llvm/CodeGen/ExpandReductions.h"
#include "llvm/CodeGen/MachinePassManager.h"
#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
@@ -675,14 +676,14 @@ void CodeGenPassBuilder<Derived>::addPassesToHandleExceptions(
case ExceptionHandling::DwarfCFI:
case ExceptionHandling::ARM:
case ExceptionHandling::AIX:
- addPass(DwarfEHPass(getOptLevel()));
+ addPass(DwarfEHPreparePass(&TM));
break;
case ExceptionHandling::WinEH:
// We support using both GCC-style and MSVC-style exceptions on Windows, so
// add both preparation passes. Each pass will only actually run if it
// recognizes the personality function.
addPass(WinEHPass());
- addPass(DwarfEHPass(getOptLevel()));
+ addPass(DwarfEHPreparePass(&TM));
break;
case ExceptionHandling::Wasm:
// Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
diff --git a/llvm/include/llvm/CodeGen/MachinePassRegistry.def b/llvm/include/llvm/CodeGen/MachinePassRegistry.def
index fc2d07fd6616fce..724278277fdef76 100644
--- a/llvm/include/llvm/CodeGen/MachinePassRegistry.def
+++ b/llvm/include/llvm/CodeGen/MachinePassRegistry.def
@@ -38,6 +38,7 @@ FUNCTION_ANALYSIS("targetir", TargetIRAnalysis,
#endif
FUNCTION_PASS("callbrprepare", CallBrPreparePass, ())
FUNCTION_PASS("consthoist", ConstantHoistingPass, ())
+FUNCTION_PASS("dwarfehprepare", DwarfEHPreparePass, (TM))
FUNCTION_PASS("ee-instrument", EntryExitInstrumenterPass, (false))
FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass, ())
FUNCTION_PASS("expand-large-fp-convert", ExpandLargeFpConvertPass, ())
@@ -120,7 +121,6 @@ DUMMY_FUNCTION_PASS("atomic-expand", AtomicExpandPass, ())
DUMMY_FUNCTION_PASS("cfguard-check", CFGuardCheckPass, ())
DUMMY_FUNCTION_PASS("cfguard-dispatch", CFGuardDispatchPass, ())
DUMMY_FUNCTION_PASS("codegenprepare", CodeGenPreparePass, ())
-DUMMY_FUNCTION_PASS("dwarfehprepare", DwarfEHPass, ())
DUMMY_FUNCTION_PASS("expandmemcmp", ExpandMemCmpPass, ())
DUMMY_FUNCTION_PASS("gc-info-printer", GCInfoPrinterPass, ())
DUMMY_FUNCTION_PASS("gc-lowering", GCLoweringPass, ())
More information about the llvm-commits
mailing list