From c1dc267258e06bb69e1ca217d1d8ce2d15b8757f Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Tue, 11 May 2021 09:57:18 +0100 Subject: MachineBasicBlock: add liveout iterator aware of which liveins are defined by the runtime. Using this in RegAlloc fast reduces register pressure, and in some cases allows x86 code to compile that wouldn't before. --- llvm/lib/CodeGen/MachineBasicBlock.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp') diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index d792ad4..1011f52 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -21,6 +21,7 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SlotIndexes.h" #include "llvm/CodeGen/TargetInstrInfo.h" +#include "llvm/CodeGen/TargetLowering.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/Config/llvm-config.h" @@ -1629,6 +1630,23 @@ MachineBasicBlock::livein_iterator MachineBasicBlock::livein_begin() const { return LiveIns.begin(); } +MachineBasicBlock::liveout_iterator MachineBasicBlock::liveout_begin() const { + const MachineFunction &MF = *getParent(); + assert(MF.getProperties().hasProperty( + MachineFunctionProperties::Property::TracksLiveness) && + "Liveness information is accurate"); + + const TargetLowering &TLI = *MF.getSubtarget().getTargetLowering(); + MCPhysReg ExceptionPointer = 0, ExceptionSelector = 0; + if (MF.getFunction().hasPersonalityFn()) { + auto PersonalityFn = MF.getFunction().getPersonalityFn(); + ExceptionPointer = TLI.getExceptionPointerRegister(PersonalityFn); + ExceptionSelector = TLI.getExceptionSelectorRegister(PersonalityFn); + } + + return liveout_iterator(*this, ExceptionPointer, ExceptionSelector, false); +} + const MBBSectionID MBBSectionID::ColdSectionID(MBBSectionID::SectionType::Cold); const MBBSectionID MBBSectionID::ExceptionSectionID(MBBSectionID::SectionType::Exception); -- cgit v1.1