mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-26 23:38:31 +00:00
[DwarfEHPrepare] Don't prune unreachable resumes at optnone
Disable pruning of unreachable resumes in the DwarfEHPrepare pass at optnone. While I expect the pruning itself to be essentially free, this does require a dominator tree calculation, that is not used for anything else. Saving this DT construction makes for a 0.4% O0 compile-time improvement. Differential Revision: https://reviews.llvm.org/D80400
This commit is contained in:
parent
3909a36379
commit
9ec2cd3569
@ -14,6 +14,7 @@
|
||||
#ifndef LLVM_CODEGEN_PASSES_H
|
||||
#define LLVM_CODEGEN_PASSES_H
|
||||
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
@ -340,7 +341,7 @@ namespace llvm {
|
||||
|
||||
/// createDwarfEHPass - This pass mulches exception handling code into a form
|
||||
/// adapted to code generation. Required if using dwarf exception handling.
|
||||
FunctionPass *createDwarfEHPass();
|
||||
FunctionPass *createDwarfEHPass(CodeGenOpt::Level OptLevel);
|
||||
|
||||
/// createWinEHPass - Prepares personality functions used by MSVC on Windows,
|
||||
/// in addition to the Itanium LSDA based personalities.
|
||||
|
@ -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;
|
||||
|
@ -729,14 +729,14 @@ void TargetPassConfig::addPassesToHandleExceptions() {
|
||||
LLVM_FALLTHROUGH;
|
||||
case ExceptionHandling::DwarfCFI:
|
||||
case ExceptionHandling::ARM:
|
||||
addPass(createDwarfEHPass());
|
||||
addPass(createDwarfEHPass(getOptLevel()));
|
||||
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(createWinEHPass());
|
||||
addPass(createDwarfEHPass());
|
||||
addPass(createDwarfEHPass(getOptLevel()));
|
||||
break;
|
||||
case ExceptionHandling::Wasm:
|
||||
// Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
|
||||
|
@ -27,7 +27,6 @@
|
||||
; CHECK-NEXT: AArch64 Stack Tagging
|
||||
; CHECK-NEXT: Rewrite Symbols
|
||||
; CHECK-NEXT: FunctionPass Manager
|
||||
; CHECK-NEXT: Dominator Tree Construction
|
||||
; CHECK-NEXT: Exception handling preparation
|
||||
; CHECK-NEXT: Safe Stack instrumentation pass
|
||||
; CHECK-NEXT: Insert stack protectors
|
||||
|
@ -29,7 +29,6 @@
|
||||
; CHECK-NEXT: Expand indirectbr instructions
|
||||
; CHECK-NEXT: Rewrite Symbols
|
||||
; CHECK-NEXT: FunctionPass Manager
|
||||
; CHECK-NEXT: Dominator Tree Construction
|
||||
; CHECK-NEXT: Exception handling preparation
|
||||
; CHECK-NEXT: Safe Stack instrumentation pass
|
||||
; CHECK-NEXT: Insert stack protectors
|
||||
|
Loading…
x
Reference in New Issue
Block a user