Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 93971d9

Browse files
author
Krzysztof Parzyszek
committed
[RDF] Add option to keep dead phi nodes in DFG
Dead phi nodes are needed for code motion (such as copy propagation), where a new use would be placed in a location that would be dominated by a dead phi. Such a transformation is not legal for copy propagation, and the existence of the phi would prevent it, but if the phi is not there, it may appear to be valid. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267932 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c5b250a commit 93971d9

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

lib/Target/Hexagon/HexagonRDFOpt.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ bool HexagonRDFOpt::runOnMachineFunction(MachineFunction &MF) {
289289
HexagonRegisterAliasInfo HAI(HRI);
290290
TargetOperandInfo TOI(HII);
291291
DataFlowGraph G(MF, HII, HRI, *MDT, MDF, HAI, TOI);
292-
G.build();
292+
// Dead phi nodes are necessary for copy propagation: we can add a use
293+
// of a register in a block where it would need a phi node, but which
294+
// was dead (and removed) during the graph build time.
295+
G.build(BuildOptions::KeepDeadPhis);
293296

294297
if (RDFDump)
295298
dbgs() << "Starting copy propagation on: " << MF.getName() << '\n'

lib/Target/Hexagon/RDFGraph.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ NodeAddr<FuncNode*> DataFlowGraph::newFunc(MachineFunction *MF) {
919919
}
920920

921921
// Build the data flow graph.
922-
void DataFlowGraph::build() {
922+
void DataFlowGraph::build(unsigned Options) {
923923
reset();
924924
Func = newFunc(&MF);
925925

@@ -964,7 +964,8 @@ void DataFlowGraph::build() {
964964
linkBlockRefs(DM, EA);
965965

966966
// Finally, remove all unused phi nodes.
967-
removeUnusedPhis();
967+
if (!(Options & BuildOptions::KeepDeadPhis))
968+
removeUnusedPhis();
968969
}
969970

970971
// For each stack in the map DefM, push the delimiter for block B on it.

lib/Target/Hexagon/RDFGraph.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ namespace rdf {
287287
}
288288
};
289289

290+
struct BuildOptions {
291+
enum : unsigned {
292+
None = 0x00,
293+
KeepDeadPhis = 0x01, // Do not remove dead phis during build.
294+
};
295+
};
296+
290297
template <typename T> struct NodeAddr {
291298
NodeAddr() : Addr(nullptr), Id(0) {}
292299
NodeAddr(T A, NodeId I) : Addr(A), Id(I) {}
@@ -677,7 +684,7 @@ namespace rdf {
677684

678685
typedef std::map<RegisterRef,DefStack> DefStackMap;
679686

680-
void build();
687+
void build(unsigned Options = BuildOptions::None);
681688
void pushDefs(NodeAddr<InstrNode*> IA, DefStackMap &DM);
682689
void markBlock(NodeId B, DefStackMap &DefM);
683690
void releaseBlock(NodeId B, DefStackMap &DefM);

0 commit comments

Comments
 (0)