@@ -691,6 +691,12 @@ bool TargetOperandInfo::isFixedReg(const MachineInstr &In, unsigned OpNum)
691
691
const {
692
692
if (In.isCall () || In.isReturn () || In.isInlineAsm ())
693
693
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
+
694
700
const MCInstrDesc &D = In.getDesc ();
695
701
if (!D.getImplicitDefs () && !D.getImplicitUses ())
696
702
return false ;
@@ -1168,6 +1174,17 @@ NodeAddr<RefNode*> DataFlowGraph::getNextShadow(NodeAddr<InstrNode*> IA,
1168
1174
void DataFlowGraph::buildStmt (NodeAddr<BlockNode*> BA, MachineInstr &In) {
1169
1175
auto SA = newStmt (BA, &In);
1170
1176
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
+
1171
1188
// Collect a set of registers that this instruction implicitly uses
1172
1189
// or defines. Implicit operands from an instruction will be ignored
1173
1190
// unless they are listed here.
@@ -1179,8 +1196,7 @@ void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
1179
1196
while (uint16_t R = *ImpU++)
1180
1197
ImpUses.insert ({R, 0 });
1181
1198
1182
- bool IsCall = In.isCall (), IsReturn = In.isReturn ();
1183
- bool IsInlineAsm = In.isInlineAsm ();
1199
+ bool NeedsImplicit = isCall (In) || In.isInlineAsm () || In.isReturn ();
1184
1200
bool IsPredicated = TII.isPredicated (In);
1185
1201
unsigned NumOps = In.getNumOperands ();
1186
1202
@@ -1214,7 +1230,7 @@ void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
1214
1230
if (!Op.isReg () || !Op.isDef () || !Op.isImplicit ())
1215
1231
continue ;
1216
1232
RegisterRef RR = { Op.getReg (), Op.getSubReg () };
1217
- if (!IsCall && !IsInlineAsm && !ImpDefs.count (RR))
1233
+ if (!NeedsImplicit && !ImpDefs.count (RR))
1218
1234
continue ;
1219
1235
if (DoneDefs.count (RR))
1220
1236
continue ;
@@ -1239,7 +1255,7 @@ void DataFlowGraph::buildStmt(NodeAddr<BlockNode*> BA, MachineInstr &In) {
1239
1255
// instructions regardless of whether or not they appear in the instruction
1240
1256
// descriptor's list.
1241
1257
bool Implicit = Op.isImplicit ();
1242
- bool TakeImplicit = IsReturn || IsCall || IsInlineAsm || IsPredicated;
1258
+ bool TakeImplicit = NeedsImplicit || IsPredicated;
1243
1259
if (Implicit && !TakeImplicit && !ImpUses.count (RR))
1244
1260
continue ;
1245
1261
uint16_t Flags = NodeAttrs::None;
0 commit comments