Skip to content

Commit

Permalink
[RDF] Add phis for entry block live-ins (in addition to function live…
Browse files Browse the repository at this point in the history
…-ins)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293491 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Krzysztof Parzyszek committed Jan 30, 2017
1 parent f24bf5a commit 10d8cea
Showing 3 changed files with 22 additions and 14 deletions.
16 changes: 12 additions & 4 deletions lib/Target/Hexagon/RDFGraph.cpp
Original file line number Diff line number Diff line change
@@ -764,7 +764,7 @@ void RegisterAggr::print(raw_ostream &OS) const {
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 Options) {
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);
}
16 changes: 9 additions & 7 deletions lib/Target/Hexagon/RDFGraph.h
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 1 addition & 3 deletions lib/Target/Hexagon/RDFLiveness.cpp
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 10d8cea

Please sign in to comment.