-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CodeGen] Port DwarfEHPrepare to new pass manager #72500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===------------------- llvm/CodeGen/DwarfEHPrepare.h ----------*- 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This pass mulches exception handling code into a form adapted to code | ||
// generation. Required if using dwarf exception handling. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CODEGEN_DWARFEHPREPARE_H | ||
#define LLVM_CODEGEN_DWARFEHPREPARE_H | ||
|
||
#include "llvm/IR/PassManager.h" | ||
|
||
namespace llvm { | ||
|
||
class TargetMachine; | ||
|
||
class DwarfEHPreparePass : public PassInfoMixin<DwarfEHPreparePass> { | ||
const TargetMachine *TM; | ||
|
||
public: | ||
explicit DwarfEHPreparePass(const TargetMachine *TM_) : TM(TM_) {} | ||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); | ||
}; | ||
|
||
} // namespace llvm | ||
|
||
#endif // LLVM_CODEGEN_DWARFEHPREPARE_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/CodeGen/DwarfEHPrepare.h" | ||
#include "llvm/ADT/BitVector.h" | ||
#include "llvm/ADT/SmallVector.h" | ||
#include "llvm/ADT/Statistic.h" | ||
|
@@ -365,6 +366,27 @@ class DwarfEHPrepareLegacyPass : public FunctionPass { | |
|
||
} // end anonymous namespace | ||
|
||
PreservedAnalyses DwarfEHPreparePass::run(Function &F, | ||
FunctionAnalysisManager &FAM) { | ||
const auto &TLI = *TM->getSubtargetImpl(F)->getTargetLowering(); | ||
auto *DT = FAM.getCachedResult<DominatorTreeAnalysis>(F); | ||
const TargetTransformInfo *TTI = nullptr; | ||
auto OptLevel = TM->getOptLevel(); | ||
if (OptLevel != CodeGenOptLevel::None) { | ||
if (!DT) | ||
DT = &FAM.getResult<DominatorTreeAnalysis>(F); | ||
TTI = &FAM.getResult<TargetIRAnalysis>(F); | ||
} | ||
bool Changed = | ||
prepareDwarfEH(OptLevel, F, TLI, DT, TTI, TM->getTargetTriple()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take the triple from the module instead of the TM? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The getTargetTriple method in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot about that wart, it should really store the parsed form |
||
|
||
if (!Changed) | ||
return PreservedAnalyses::all(); | ||
PreservedAnalyses PA; | ||
PA.preserve<DominatorTreeAnalysis>(); | ||
return PA; | ||
} | ||
|
||
char DwarfEHPrepareLegacyPass::ID = 0; | ||
|
||
INITIALIZE_PASS_BEGIN(DwarfEHPrepareLegacyPass, DEBUG_TYPE, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DwarfEHPass
orDwarfEHPreparePass
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DwarfEHPreparePass, we have some inconsistently named pass/file combinations and it's kind of annoying