@@ -99,6 +99,27 @@ LimitFPPrecision("limit-float-precision",
99
99
// store [4096 x i8] %data, [4096 x i8]* %buffer
100
100
static const unsigned MaxParallelChains = 64 ;
101
101
102
+ // True if the Value passed requires ABI mangling as it is a parameter to a
103
+ // function or a return value from a function which is not an intrinsic.
104
+ static bool isABIRegCopy (const Value * V) {
105
+ const bool IsRetInst = V && isa<ReturnInst>(V);
106
+ const bool IsCallInst = V && isa<CallInst>(V);
107
+ const bool IsInLineAsm =
108
+ IsCallInst && static_cast <const CallInst *>(V)->isInlineAsm ();
109
+ const bool IsIndirectFunctionCall =
110
+ IsCallInst && !IsInLineAsm &&
111
+ !static_cast <const CallInst *>(V)->getCalledFunction ();
112
+ // It is possible that the call instruction is an inline asm statement or an
113
+ // indirect function call in which case the return value of
114
+ // getCalledFunction() would be nullptr.
115
+ const bool IsInstrinsicCall =
116
+ IsCallInst && !IsInLineAsm && !IsIndirectFunctionCall &&
117
+ static_cast <const CallInst *>(V)->getCalledFunction ()->getIntrinsicID () !=
118
+ Intrinsic::not_intrinsic;
119
+
120
+ return IsRetInst || (IsCallInst && (!IsInLineAsm && !IsInstrinsicCall));
121
+ }
122
+
102
123
static SDValue getCopyFromPartsVector (SelectionDAG &DAG, const SDLoc &DL,
103
124
const SDValue *Parts, unsigned NumParts,
104
125
MVT PartVT, EVT ValueVT, const Value *V,
@@ -1026,13 +1047,9 @@ SDValue SelectionDAGBuilder::getCopyFromRegs(const Value *V, Type *Ty) {
1026
1047
1027
1048
if (It != FuncInfo.ValueMap .end ()) {
1028
1049
unsigned InReg = It->second ;
1029
- bool IsABIRegCopy =
1030
- V && ((isa<CallInst>(V) &&
1031
- !(static_cast <const CallInst *>(V))->isInlineAsm ()) ||
1032
- isa<ReturnInst>(V));
1033
1050
1034
1051
RegsForValue RFV (*DAG.getContext (), DAG.getTargetLoweringInfo (),
1035
- DAG.getDataLayout (), InReg, Ty, IsABIRegCopy );
1052
+ DAG.getDataLayout (), InReg, Ty, isABIRegCopy (V) );
1036
1053
SDValue Chain = DAG.getEntryNode ();
1037
1054
Result = RFV.getCopyFromRegs (DAG, FuncInfo, getCurSDLoc (), Chain, nullptr ,
1038
1055
V);
@@ -1221,13 +1238,9 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
1221
1238
// If this is an instruction which fast-isel has deferred, select it now.
1222
1239
if (const Instruction *Inst = dyn_cast<Instruction>(V)) {
1223
1240
unsigned InReg = FuncInfo.InitializeRegForValue (Inst);
1224
- bool IsABIRegCopy =
1225
- V && ((isa<CallInst>(V) &&
1226
- !(static_cast <const CallInst *>(V))->isInlineAsm ()) ||
1227
- isa<ReturnInst>(V));
1228
1241
1229
1242
RegsForValue RFV (*DAG.getContext (), TLI, DAG.getDataLayout (), InReg,
1230
- Inst->getType (), IsABIRegCopy );
1243
+ Inst->getType (), isABIRegCopy (V) );
1231
1244
SDValue Chain = DAG.getEntryNode ();
1232
1245
return RFV.getCopyFromRegs (DAG, FuncInfo, getCurSDLoc (), Chain, nullptr , V);
1233
1246
}
@@ -8281,13 +8294,9 @@ SelectionDAGBuilder::CopyValueToVirtualRegister(const Value *V, unsigned Reg) {
8281
8294
const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
8282
8295
// If this is an InlineAsm we have to match the registers required, not the
8283
8296
// notional registers required by the type.
8284
- bool IsABIRegCopy =
8285
- V && ((isa<CallInst>(V) &&
8286
- !(static_cast <const CallInst *>(V))->isInlineAsm ()) ||
8287
- isa<ReturnInst>(V));
8288
8297
8289
8298
RegsForValue RFV (V->getContext (), TLI, DAG.getDataLayout (), Reg,
8290
- V->getType (), IsABIRegCopy );
8299
+ V->getType (), isABIRegCopy (V) );
8291
8300
SDValue Chain = DAG.getEntryNode ();
8292
8301
8293
8302
ISD::NodeType ExtendType = (FuncInfo.PreferredExtendType .find (V) ==
0 commit comments