[llvm] r293491 - [RDF] Add phis for entry block live-ins (in addition to function live-ins)
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 08:20:30 PST 2017
Author: kparzysz
Date: Mon Jan 30 10:20:30 2017
New Revision: 293491
URL: http://llvm.org/viewvc/llvm-project?rev=293491&view=rev
Log:
[RDF] Add phis for entry block live-ins (in addition to function live-ins)
Modified:
llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp
llvm/trunk/lib/Target/Hexagon/RDFGraph.h
llvm/trunk/lib/Target/Hexagon/RDFLiveness.cpp
Modified: llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp?rev=293491&r1=293490&r2=293491&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp Mon Jan 30 10:20:30 2017
@@ -764,7 +764,7 @@ void RegisterAggr::print(raw_ostream &OS
DataFlowGraph::DataFlowGraph(MachineFunction &mf, const TargetInstrInfo &tii,
const TargetRegisterInfo &tri, const MachineDominatorTree &mdt,
const MachineDominanceFrontier &mdf, const TargetOperandInfo &toi)
- : MF(mf), TII(tii), TRI(tri), MDT(mdt), MDF(mdf), TOI(toi) {
+ : MF(mf), TII(tii), TRI(tri), MDT(mdt), MDF(mdf), TOI(toi), LiveIns(TRI) {
}
// The implementation of the definition stack.
@@ -1010,12 +1010,20 @@ void DataFlowGraph::build(unsigned Optio
BlockRefsMap RefM;
buildBlockRefs(EA, RefM);
- // Add function-entry phi nodes.
+ // Collect function live-ins and entry block live-ins.
MachineRegisterInfo &MRI = MF.getRegInfo();
- for (auto I = MRI.livein_begin(), E = MRI.livein_end(); I != E; ++I) {
+ MachineBasicBlock &EntryB = *EA.Addr->getCode();
+ assert(EntryB.pred_empty() && "Function entry block has predecessors");
+ for (auto I = MRI.livein_begin(), E = MRI.livein_end(); I != E; ++I)
+ LiveIns.insert(RegisterRef(I->first));
+ for (auto I : EntryB.liveins())
+ LiveIns.insert(RegisterRef(I.PhysReg, I.LaneMask));
+
+ // Add function-entry phi nodes for the live-in registers.
+ for (std::pair<RegisterId,LaneBitmask> P : LiveIns) {
NodeAddr<PhiNode*> PA = newPhi(EA);
- RegisterRef RR = RegisterRef(I->first);
uint16_t PhiFlags = NodeAttrs::PhiRef | NodeAttrs::Preserving;
+ RegisterRef RR(P.first, P.second);
NodeAddr<DefNode*> DA = newDef(PA, RR, PhiFlags);
PA.Addr->addMember(DA, *this);
}
Modified: llvm/trunk/lib/Target/Hexagon/RDFGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/RDFGraph.h?rev=293491&r1=293490&r2=293491&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/RDFGraph.h (original)
+++ llvm/trunk/lib/Target/Hexagon/RDFGraph.h Mon Jan 30 10:20:30 2017
@@ -763,6 +763,7 @@ namespace rdf {
const TargetRegisterInfo &getTRI() const { return TRI; }
const MachineDominatorTree &getDT() const { return MDT; }
const MachineDominanceFrontier &getDF() const { return MDF; }
+ const RegisterAggr &getLiveIns() const { return LiveIns; }
struct DefStack {
DefStack() = default;
@@ -957,19 +958,20 @@ namespace rdf {
return BlockNodes[BB];
}
- NodeAddr<FuncNode*> Func;
- NodeAllocator Memory;
- // Local map: MachineBasicBlock -> NodeAddr<BlockNode*>
- std::map<MachineBasicBlock*,NodeAddr<BlockNode*>> BlockNodes;
- // Lane mask map.
- LaneMaskIndex LMI;
-
MachineFunction &MF;
const TargetInstrInfo &TII;
const TargetRegisterInfo &TRI;
const MachineDominatorTree &MDT;
const MachineDominanceFrontier &MDF;
const TargetOperandInfo &TOI;
+
+ RegisterAggr LiveIns;
+ NodeAddr<FuncNode*> Func;
+ NodeAllocator Memory;
+ // Local map: MachineBasicBlock -> NodeAddr<BlockNode*>
+ std::map<MachineBasicBlock*,NodeAddr<BlockNode*>> BlockNodes;
+ // Lane mask map.
+ LaneMaskIndex LMI;
}; // struct DataFlowGraph
template <typename Predicate>
Modified: llvm/trunk/lib/Target/Hexagon/RDFLiveness.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/RDFLiveness.cpp?rev=293491&r1=293490&r2=293491&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/RDFLiveness.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/RDFLiveness.cpp Mon Jan 30 10:20:30 2017
@@ -684,9 +684,7 @@ void Liveness::computeLiveIns() {
traverse(&MF.front(), LiveIn);
// Add function live-ins to the live-in set of the function entry block.
- auto &EntryIn = LiveMap[&MF.front()];
- for (auto I = MRI.livein_begin(), E = MRI.livein_end(); I != E; ++I)
- EntryIn.insert(RegisterRef(I->first));
+ LiveMap[&MF.front()].insert(DFG.getLiveIns());
if (Trace) {
// Dump the liveness map
More information about the llvm-commits
mailing list