llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-nvptx Author: Matt Arsenault (arsenm) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/176380.diff 6 Files Affected: - (modified) llvm/lib/CodeGen/DwarfEHPrepare.cpp (+39-15) - (modified) llvm/test/CodeGen/AArch64/dwarf-eh-prepare-dbg.ll (+1-1) - (modified) llvm/test/CodeGen/X86/dwarf-eh-prepare-dbg.ll (+1-1) - (modified) llvm/test/CodeGen/X86/dwarf-eh-prepare.ll (+1-1) - (modified) llvm/test/CodeGen/X86/dwarf_eh_resume.ll (+1-1) - (added) llvm/test/Transforms/DwarfEHPrepare/missing-analysis.ll (+7) ``````````diff diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp index 74b9b093adcca..8244435bd78d5 100644 --- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp +++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp @@ -57,7 +57,7 @@ class DwarfEHPrepare { CodeGenOptLevel OptLevel; Function &F; - const TargetLowering &TLI; + const LibcallLoweringInfo &Libcalls; DomTreeUpdater *DTU; const TargetTransformInfo *TTI; const Triple &TargetTriple; @@ -79,9 +79,9 @@ class DwarfEHPrepare { public: DwarfEHPrepare(CodeGenOptLevel OptLevel_, Function &F_, - const TargetLowering &TLI_, DomTreeUpdater *DTU_, + const LibcallLoweringInfo &Libcalls_, DomTreeUpdater *DTU_, const TargetTransformInfo *TTI_, const Triple &TargetTriple_) - : OptLevel(OptLevel_), F(F_), TLI(TLI_), DTU(DTU_), TTI(TTI_), + : OptLevel(OptLevel_), F(F_), Libcalls(Libcalls_), DTU(DTU_), TTI(TTI_), TargetTriple(TargetTriple_) {} bool run(); @@ -216,21 +216,22 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() { FunctionCallee RewindFunction; CallingConv::ID RewindFunctionCallingConv; FunctionType *FTy; - const char *RewindName; + StringRef RewindName; bool DoesRewindFunctionNeedExceptionObject; if ((Pers == EHPersonality::GNU_CXX || Pers == EHPersonality::GNU_CXX_SjLj) && TargetTriple.isTargetEHABICompatible()) { - RewindName = TLI.getLibcallName(RTLIB::CXA_END_CLEANUP); + RewindName = Libcalls.getLibcallName(RTLIB::CXA_END_CLEANUP); FTy = FunctionType::get(Type::getVoidTy(Ctx), false); RewindFunctionCallingConv = - TLI.getLibcallCallingConv(RTLIB::CXA_END_CLEANUP); + Libcalls.getLibcallCallingConv(RTLIB::CXA_END_CLEANUP); DoesRewindFunctionNeedExceptionObject = false; } else { - RewindName = TLI.getLibcallName(RTLIB::UNWIND_RESUME); + RewindName = Libcalls.getLibcallName(RTLIB::UNWIND_RESUME); FTy = FunctionType::get(Type::getVoidTy(Ctx), PointerType::getUnqual(Ctx), false); - RewindFunctionCallingConv = TLI.getLibcallCallingConv(RTLIB::UNWIND_RESUME); + RewindFunctionCallingConv = + Libcalls.getLibcallCallingConv(RTLIB::UNWIND_RESUME); DoesRewindFunctionNeedExceptionObject = true; } RewindFunction = F.getParent()->getOrInsertFunction(RewindName, FTy); @@ -318,12 +319,12 @@ bool DwarfEHPrepare::run() { } static bool prepareDwarfEH(CodeGenOptLevel OptLevel, Function &F, - const TargetLowering &TLI, DominatorTree *DT, - const TargetTransformInfo *TTI, + const LibcallLoweringInfo &Libcalls, + DominatorTree *DT, const TargetTransformInfo *TTI, const Triple &TargetTriple) { DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy); - return DwarfEHPrepare(OptLevel, F, TLI, DT ? &DTU : nullptr, TTI, + return DwarfEHPrepare(OptLevel, F, Libcalls, DT ? &DTU : nullptr, TTI, TargetTriple) .run(); } @@ -343,7 +344,12 @@ class DwarfEHPrepareLegacyPass : public FunctionPass { bool runOnFunction(Function &F) override { const TargetMachine &TM = getAnalysis<TargetPassConfig>().getTM<TargetMachine>(); - const TargetLowering &TLI = *TM.getSubtargetImpl(F)->getTargetLowering(); + const TargetSubtargetInfo *Subtarget = TM.getSubtargetImpl(F); + + const LibcallLoweringInfo &Libcalls = + getAnalysis<LibcallLoweringInfoWrapper>().getLibcallLowering( + *F.getParent(), *Subtarget); + DominatorTree *DT = nullptr; const TargetTransformInfo *TTI = nullptr; if (auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>()) @@ -353,10 +359,11 @@ class DwarfEHPrepareLegacyPass : public FunctionPass { DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F); } - return prepareDwarfEH(OptLevel, F, TLI, DT, TTI, TM.getTargetTriple()); + return prepareDwarfEH(OptLevel, F, Libcalls, DT, TTI, TM.getTargetTriple()); } void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.addRequired<LibcallLoweringInfoWrapper>(); AU.addRequired<TargetPassConfig>(); AU.addRequired<TargetTransformInfoWrapperPass>(); if (OptLevel != CodeGenOptLevel::None) { @@ -375,17 +382,33 @@ class DwarfEHPrepareLegacyPass : public FunctionPass { 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(); + + auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F); + + const LibcallLoweringModuleAnalysisResult *LibcallLowering = + MAMProxy.getCachedResult<LibcallLoweringModuleAnalysis>(*F.getParent()); + + if (!LibcallLowering) { + F.getContext().emitError("'" + LibcallLoweringModuleAnalysis::name() + + "' analysis required"); + return PreservedAnalyses::all(); + } + if (OptLevel != CodeGenOptLevel::None) { if (!DT) DT = &FAM.getResult<DominatorTreeAnalysis>(F); TTI = &FAM.getResult<TargetIRAnalysis>(F); } + + const TargetSubtargetInfo *Subtarget = TM->getSubtargetImpl(F); + const LibcallLoweringInfo &Libcalls = + LibcallLowering->getLibcallLowering(*Subtarget); + bool Changed = - prepareDwarfEH(OptLevel, F, TLI, DT, TTI, TM->getTargetTriple()); + prepareDwarfEH(OptLevel, F, Libcalls, DT, TTI, TM->getTargetTriple()); if (!Changed) return PreservedAnalyses::all(); @@ -399,6 +422,7 @@ char DwarfEHPrepareLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(DwarfEHPrepareLegacyPass, DEBUG_TYPE, "Prepare DWARF exceptions", false, false) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) +INITIALIZE_PASS_DEPENDENCY(LibcallLoweringInfoWrapper) INITIALIZE_PASS_DEPENDENCY(TargetPassConfig) INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) INITIALIZE_PASS_END(DwarfEHPrepareLegacyPass, DEBUG_TYPE, diff --git a/llvm/test/CodeGen/AArch64/dwarf-eh-prepare-dbg.ll b/llvm/test/CodeGen/AArch64/dwarf-eh-prepare-dbg.ll index 020a10f278ed6..5ad348d746f52 100644 --- a/llvm/test/CodeGen/AArch64/dwarf-eh-prepare-dbg.ll +++ b/llvm/test/CodeGen/AArch64/dwarf-eh-prepare-dbg.ll @@ -1,5 +1,5 @@ ; RUN: opt -S -mtriple=aarch64-unknown-linux-gnu -dwarf-eh-prepare < %s | FileCheck %s -; RUN: opt -S -mtriple=aarch64-unknown-linux-gnu -passes=dwarf-eh-prepare < %s | FileCheck %s +; RUN: opt -S -mtriple=aarch64-unknown-linux-gnu -passes='require<libcall-lowering-info>,dwarf-eh-prepare' < %s | FileCheck %s ; If _Unwind_Resume is defined in the same module and we have debug ; info, then the inserted _Unwind_Resume calls also need to have a dummy debug diff --git a/llvm/test/CodeGen/X86/dwarf-eh-prepare-dbg.ll b/llvm/test/CodeGen/X86/dwarf-eh-prepare-dbg.ll index 0345b736e9e60..0636b83383369 100644 --- a/llvm/test/CodeGen/X86/dwarf-eh-prepare-dbg.ll +++ b/llvm/test/CodeGen/X86/dwarf-eh-prepare-dbg.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-linux-gnu -dwarf-eh-prepare < %s | FileCheck %s -; RUN: opt -S -mtriple=x86_64-linux-gnu -passes=dwarf-eh-prepare < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-linux-gnu -passes='require<libcall-lowering-info>,dwarf-eh-prepare' < %s | FileCheck %s ; PR57469: If _Unwind_Resume is defined in the same module and we have debug ; info, then the inserted _Unwind_Resume calls also need to have a dummy debug diff --git a/llvm/test/CodeGen/X86/dwarf-eh-prepare.ll b/llvm/test/CodeGen/X86/dwarf-eh-prepare.ll index dd27e7fe14117..7d3069f5198ba 100644 --- a/llvm/test/CodeGen/X86/dwarf-eh-prepare.ll +++ b/llvm/test/CodeGen/X86/dwarf-eh-prepare.ll @@ -1,5 +1,5 @@ ; RUN: opt -mtriple=x86_64-linux-gnu -dwarf-eh-prepare -simplifycfg-require-and-preserve-domtree=1 -run-twice < %s -S | FileCheck %s -; RUN: opt -mtriple=x86_64-linux-gnu -passes=dwarf-eh-prepare -codegen-opt-level=2 -simplifycfg-require-and-preserve-domtree=1 -run-twice < %s -S | FileCheck %s +; RUN: opt -mtriple=x86_64-linux-gnu -passes='require<libcall-lowering-info>,dwarf-eh-prepare' -codegen-opt-level=2 -simplifycfg-require-and-preserve-domtree=1 -run-twice < %s -S | FileCheck %s ; Check basic functionality of IR-to-IR DWARF EH preparation. This should ; eliminate resumes. This pass requires a TargetMachine, so we put it under X86 diff --git a/llvm/test/CodeGen/X86/dwarf_eh_resume.ll b/llvm/test/CodeGen/X86/dwarf_eh_resume.ll index d66d89d16a394..f07be957685bb 100644 --- a/llvm/test/CodeGen/X86/dwarf_eh_resume.ll +++ b/llvm/test/CodeGen/X86/dwarf_eh_resume.ll @@ -1,5 +1,5 @@ ; RUN: opt -mtriple=x86_64-linux-gnu -dwarf-eh-prepare -S %s | FileCheck %s -; RUN: opt -mtriple=x86_64-linux-gnu -passes=dwarf-eh-prepare -S %s | FileCheck %s +; RUN: opt -mtriple=x86_64-linux-gnu -passes='require<libcall-lowering-info>,dwarf-eh-prepare' -S %s | FileCheck %s declare i32 @hoge(...) diff --git a/llvm/test/Transforms/DwarfEHPrepare/missing-analysis.ll b/llvm/test/Transforms/DwarfEHPrepare/missing-analysis.ll new file mode 100644 index 0000000000000..62325f8c7091e --- /dev/null +++ b/llvm/test/Transforms/DwarfEHPrepare/missing-analysis.ll @@ -0,0 +1,7 @@ +; REQUIRES: x86-registered-target +; RUN: not opt -mtriple=x86_64-- -passes=dwarf-eh-prepare -disable-output %s 2>&1 | FileCheck %s + +; CHECK: 'LibcallLoweringModuleAnalysis' analysis required +define void @empty() { + ret void +} `````````` </details> https://github.com/llvm/llvm-project/pull/176380 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
