diff options
| author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2016-04-28 20:40:08 +0000 |
|---|---|---|
| committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2016-04-28 20:40:08 +0000 |
| commit | bf90d5a3b37dc7833f51cb29df14ac8ad0d84b64 (patch) | |
| tree | a47203c2758c4c2765b85801622d2c1feaf47793 /llvm/lib/Target/Hexagon | |
| parent | 5575d079a553fa0e0c88b33db019ab5ca0f0271f (diff) | |
| download | bcm5719-llvm-bf90d5a3b37dc7833f51cb29df14ac8ad0d84b64.tar.gz bcm5719-llvm-bf90d5a3b37dc7833f51cb29df14ac8ad0d84b64.zip | |
[RDF] Recognize tail calls in graph creation
llvm-svn: 267939
Diffstat (limited to 'llvm/lib/Target/Hexagon')
| -rw-r--r-- | llvm/lib/Target/Hexagon/RDFGraph.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/llvm/lib/Target/Hexagon/RDFGraph.cpp b/llvm/lib/Target/Hexagon/RDFGraph.cpp index 0240bfdd645..029d1e9c24e 100644 --- a/llvm/lib/Target/Hexagon/RDFGraph.cpp +++ b/llvm/lib/Target/Hexagon/RDFGraph.cpp @@ -691,6 +691,12 @@ bool TargetOperandInfo::isFixedReg(const MachineInstr &In, unsigned OpNum) 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::getNextShadow(NodeAddr<InstrNode*> IA, 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<BlockNode*> BA, MachineInstr &In) { 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<BlockNode*> BA, MachineInstr &In) { 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<BlockNode*> BA, MachineInstr &In) { // 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; |

