diff options
author | Karl-Johan Karlsson <karl-johan.karlsson@ericsson.com> | 2018-06-07 07:20:33 +0000 |
---|---|---|
committer | Karl-Johan Karlsson <karl-johan.karlsson@ericsson.com> | 2018-06-07 07:20:33 +0000 |
commit | abb11f805f3a2297a3968c5daf625cd882ca0fb3 (patch) | |
tree | 9e962937f5f9cb74a4028c52f9de3be7ec50ec5f /llvm/lib/CodeGen/BranchFolding.cpp | |
parent | 203cdee0ecac826499245aa407b98b7a355ab0c0 (diff) | |
download | bcm5719-llvm-abb11f805f3a2297a3968c5daf625cd882ca0fb3.tar.gz bcm5719-llvm-abb11f805f3a2297a3968c5daf625cd882ca0fb3.zip |
[BranchFolding] Fix live-in's when hoisting code
Summary:
When the branch folder hoist code into a predecessor it adjust live-in's
in the blocks it hoist code from. However it fail to handle hoisted code
that contain a defed register that originally is live-in in the block
through a super register.
This is fixed by replacing the live-in handling code with calls to
utility functions in LivePhysRegs.
Reviewers: kparzysz, gberry, MatzeB, uweigand, aprantl
Reviewed By: kparzysz
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D47529
llvm-svn: 334163
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 254c8579b22..0787ca552d8 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -2007,7 +2007,6 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { return false; bool HasDups = false; - SmallVector<unsigned, 4> LocalDefs, LocalKills; SmallSet<unsigned, 4> ActiveDefsSet, AllDefsSet; MachineBasicBlock::iterator TIB = TBB->begin(); MachineBasicBlock::iterator FIB = FBB->begin(); @@ -2090,7 +2089,6 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { if (!Reg) continue; if (!AllDefsSet.count(Reg)) { - LocalKills.push_back(Reg); continue; } if (TargetRegisterInfo::isPhysicalRegister(Reg)) { @@ -2108,7 +2106,6 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { unsigned Reg = MO.getReg(); if (!Reg || TargetRegisterInfo::isVirtualRegister(Reg)) continue; - LocalDefs.push_back(Reg); addRegAndItsAliases(Reg, TRI, ActiveDefsSet); addRegAndItsAliases(Reg, TRI, AllDefsSet); } @@ -2124,25 +2121,9 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { MBB->splice(Loc, TBB, TBB->begin(), TIB); FBB->erase(FBB->begin(), FIB); - // Update livein's. - bool ChangedLiveIns = false; - for (unsigned i = 0, e = LocalDefs.size(); i != e; ++i) { - unsigned Def = LocalDefs[i]; - if (ActiveDefsSet.count(Def)) { - TBB->addLiveIn(Def); - FBB->addLiveIn(Def); - ChangedLiveIns = true; - } - } - for (unsigned K : LocalKills) { - TBB->removeLiveIn(K); - FBB->removeLiveIn(K); - ChangedLiveIns = true; - } - - if (ChangedLiveIns) { - TBB->sortUniqueLiveIns(); - FBB->sortUniqueLiveIns(); + if (UpdateLiveIns) { + recomputeLiveIns(*TBB); + recomputeLiveIns(*FBB); } ++NumHoist; |