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

Commit 53c317f

Browse files
author
Krzysztof Parzyszek
committed
[RDF] Recognize tail calls in graph creation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267939 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8f5959b commit 53c317f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lib/Target/Hexagon/RDFGraph.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,12 @@ bool TargetOperandInfo::isFixedReg(const MachineInstr &In, unsigned OpNum)
691691
const {
692692
if (In.isCall() || In.isReturn() || In.isInlineAsm())
693693
return true;
694+
// Check for a tail call.
695+
if (In.isBranch())
696+
for (auto &O : In.operands())
697+
if (O.isGlobal() || O.isSymbol())
698+
return true;
699+
694700
const MCInstrDesc &D = In.getDesc();
695701
if (!D.getImplicitDefs() && !D.getImplicitUses())
696702
return false;
@@ -1168,6 +1174,17 @@ NodeAddr<RefNode*> DataFlowGraph::getNextShadow(NodeAddr<InstrNode*> IA,
11681174
void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
11691175
auto SA = newStmt(BA, &In);
11701176

1177+
auto isCall = [] (const MachineInstr &In) -> bool {
1178+
if (In.isCall())
1179+
return true;
1180+
// Is tail call?
1181+
if (In.isBranch())
1182+
for (auto &Op : In.operands())
1183+
if (Op.isGlobal() || Op.isSymbol())
1184+
return true;
1185+
return false;
1186+
};
1187+
11711188
// Collect a set of registers that this instruction implicitly uses
11721189
// or defines. Implicit operands from an instruction will be ignored
11731190
// unless they are listed here.
@@ -1179,8 +1196,7 @@ void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
11791196
while (uint16_t R = *ImpU++)
11801197
ImpUses.insert({R, 0});
11811198

1182-
bool IsCall = In.isCall(), IsReturn = In.isReturn();
1183-
bool IsInlineAsm = In.isInlineAsm();
1199+
bool NeedsImplicit = isCall(In) || In.isInlineAsm() || In.isReturn();
11841200
bool IsPredicated = TII.isPredicated(In);
11851201
unsigned NumOps = In.getNumOperands();
11861202

@@ -1214,7 +1230,7 @@ void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
12141230
if (!Op.isReg() || !Op.isDef() || !Op.isImplicit())
12151231
continue;
12161232
RegisterRef RR = { Op.getReg(), Op.getSubReg() };
1217-
if (!IsCall && !IsInlineAsm && !ImpDefs.count(RR))
1233+
if (!NeedsImplicit && !ImpDefs.count(RR))
12181234
continue;
12191235
if (DoneDefs.count(RR))
12201236
continue;
@@ -1239,7 +1255,7 @@ void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
12391255
// instructions regardless of whether or not they appear in the instruction
12401256
// descriptor's list.
12411257
bool Implicit = Op.isImplicit();
1242-
bool TakeImplicit = IsReturn || IsCall || IsInlineAsm || IsPredicated;
1258+
bool TakeImplicit = NeedsImplicit || IsPredicated;
12431259
if (Implicit && !TakeImplicit && !ImpUses.count(RR))
12441260
continue;
12451261
uint16_t Flags = NodeAttrs::None;

0 commit comments

Comments
 (0)