[llvm] r267939 - [RDF] Recognize tail calls in graph creation
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 13:40:08 PDT 2016
Author: kparzysz
Date: Thu Apr 28 15:40:08 2016
New Revision: 267939
URL: http://llvm.org/viewvc/llvm-project?rev=267939&view=rev
Log:
[RDF] Recognize tail calls in graph creation
Modified:
llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp
Modified: llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp?rev=267939&r1=267938&r2=267939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/RDFGraph.cpp Thu Apr 28 15:40:08 2016
@@ -691,6 +691,12 @@ bool TargetOperandInfo::isFixedReg(const
const {
if (In.isCall() || In.isReturn() || In.isInlineAsm())
return true;
+ // Check for a tail call.
+ if (In.isBranch())
+ for (auto &O : In.operands())
+ if (O.isGlobal() || O.isSymbol())
+ return true;
+
const MCInstrDesc &D = In.getDesc();
if (!D.getImplicitDefs() && !D.getImplicitUses())
return false;
@@ -1168,6 +1174,17 @@ NodeAddr<RefNode*> DataFlowGraph::getNex
void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
auto SA = newStmt(BA, &In);
+ auto isCall = [] (const MachineInstr &In) -> bool {
+ if (In.isCall())
+ return true;
+ // Is tail call?
+ if (In.isBranch())
+ for (auto &Op : In.operands())
+ if (Op.isGlobal() || Op.isSymbol())
+ return true;
+ return false;
+ };
+
// Collect a set of registers that this instruction implicitly uses
// or defines. Implicit operands from an instruction will be ignored
// unless they are listed here.
@@ -1179,8 +1196,7 @@ void DataFlowGraph::buildStmt(NodeAddr<B
while (uint16_t R = *ImpU++)
ImpUses.insert({R, 0});
- bool IsCall = In.isCall(), IsReturn = In.isReturn();
- bool IsInlineAsm = In.isInlineAsm();
+ bool NeedsImplicit = isCall(In) || In.isInlineAsm() || In.isReturn();
bool IsPredicated = TII.isPredicated(In);
unsigned NumOps = In.getNumOperands();
@@ -1214,7 +1230,7 @@ void DataFlowGraph::buildStmt(NodeAddr<B
if (!Op.isReg() || !Op.isDef() || !Op.isImplicit())
continue;
RegisterRef RR = { Op.getReg(), Op.getSubReg() };
- if (!IsCall && !IsInlineAsm && !ImpDefs.count(RR))
+ if (!NeedsImplicit && !ImpDefs.count(RR))
continue;
if (DoneDefs.count(RR))
continue;
@@ -1239,7 +1255,7 @@ void DataFlowGraph::buildStmt(NodeAddr<B
// instructions regardless of whether or not they appear in the instruction
// descriptor's list.
bool Implicit = Op.isImplicit();
- bool TakeImplicit = IsReturn || IsCall || IsInlineAsm || IsPredicated;
+ bool TakeImplicit = NeedsImplicit || IsPredicated;
if (Implicit && !TakeImplicit && !ImpUses.count(RR))
continue;
uint16_t Flags = NodeAttrs::None;
More information about the llvm-commits
mailing list