diff options
author | Tim Northover <t.p.northover@gmail.com> | 2021-05-11 09:57:18 +0100 |
---|---|---|
committer | Tim Northover <t.p.northover@gmail.com> | 2021-05-19 11:00:24 +0100 |
commit | c1dc267258e06bb69e1ca217d1d8ce2d15b8757f (patch) | |
tree | 10d529c26b7d863886276e773208a37aa748215c /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 4f86aa650c40196754df22c421d551d129c9149a (diff) | |
download | llvm-c1dc267258e06bb69e1ca217d1d8ce2d15b8757f.zip llvm-c1dc267258e06bb69e1ca217d1d8ce2d15b8757f.tar.gz llvm-c1dc267258e06bb69e1ca217d1d8ce2d15b8757f.tar.bz2 |
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.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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); |