diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /llvm/lib/CodeGen/DwarfEHPrepare.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'llvm/lib/CodeGen/DwarfEHPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/DwarfEHPrepare.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp index af347fd7e73d..c75c957bff8a 100644 --- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp +++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp @@ -48,6 +48,7 @@ namespace { // RewindFunction - _Unwind_Resume or the target equivalent. FunctionCallee RewindFunction = nullptr; + CodeGenOpt::Level OptLevel; DominatorTree *DT = nullptr; const TargetLowering *TLI = nullptr; @@ -61,7 +62,8 @@ namespace { public: static char ID; // Pass identification, replacement for typeid. - DwarfEHPrepare() : FunctionPass(ID) {} + DwarfEHPrepare(CodeGenOpt::Level OptLevel = CodeGenOpt::Default) + : FunctionPass(ID), OptLevel(OptLevel) {} bool runOnFunction(Function &Fn) override; @@ -89,12 +91,15 @@ INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) INITIALIZE_PASS_END(DwarfEHPrepare, DEBUG_TYPE, "Prepare DWARF exceptions", false, false) -FunctionPass *llvm::createDwarfEHPass() { return new DwarfEHPrepare(); } +FunctionPass *llvm::createDwarfEHPass(CodeGenOpt::Level OptLevel) { + return new DwarfEHPrepare(OptLevel); +} void DwarfEHPrepare::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<TargetPassConfig>(); AU.addRequired<TargetTransformInfoWrapperPass>(); - AU.addRequired<DominatorTreeWrapperPass>(); + if (OptLevel != CodeGenOpt::None) + AU.addRequired<DominatorTreeWrapperPass>(); } /// GetExceptionObject - Return the exception object from the value passed into @@ -202,7 +207,10 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls(Function &Fn) { LLVMContext &Ctx = Fn.getContext(); - size_t ResumesLeft = pruneUnreachableResumes(Fn, Resumes, CleanupLPads); + size_t ResumesLeft = Resumes.size(); + if (OptLevel != CodeGenOpt::None) + ResumesLeft = pruneUnreachableResumes(Fn, Resumes, CleanupLPads); + if (ResumesLeft == 0) return true; // We pruned them all. @@ -259,7 +267,8 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls(Function &Fn) { bool DwarfEHPrepare::runOnFunction(Function &Fn) { const TargetMachine &TM = getAnalysis<TargetPassConfig>().getTM<TargetMachine>(); - DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); + DT = OptLevel != CodeGenOpt::None + ? &getAnalysis<DominatorTreeWrapperPass>().getDomTree() : nullptr; TLI = TM.getSubtargetImpl(Fn)->getTargetLowering(); bool Changed = InsertUnwindResumeCalls(Fn); DT = nullptr; |