@@ -2220,24 +2220,27 @@ bool SelectionDAGISel::CheckOrMask(SDValue LHS, ConstantSDNode *RHS,
2220
2220
// / by tblgen. Others should not call it.
2221
2221
void SelectionDAGISel::SelectInlineAsmMemoryOperands (std::vector<SDValue> &Ops,
2222
2222
const SDLoc &DL) {
2223
- std:: vector< SDValue> InOps;
2224
- std::swap (InOps, Ops);
2223
+ // Change the vector of SDValue into a list of SDNodeHandle for x86 might call
2224
+ // replaceAllUses when matching address.
2225
2225
2226
- Ops.push_back (InOps[InlineAsm::Op_InputChain]); // 0
2227
- Ops.push_back (InOps[InlineAsm::Op_AsmString]); // 1
2228
- Ops.push_back (InOps[InlineAsm::Op_MDNode]); // 2, !srcloc
2229
- Ops.push_back (InOps[InlineAsm::Op_ExtraInfo]); // 3 (SideEffect, AlignStack)
2226
+ std::list<HandleSDNode> Handles;
2230
2227
2231
- unsigned i = InlineAsm::Op_FirstOperand, e = InOps.size ();
2232
- if (InOps[e-1 ].getValueType () == MVT::Glue)
2228
+ Handles.emplace_back (Ops[InlineAsm::Op_InputChain]); // 0
2229
+ Handles.emplace_back (Ops[InlineAsm::Op_AsmString]); // 1
2230
+ Handles.emplace_back (Ops[InlineAsm::Op_MDNode]); // 2, !srcloc
2231
+ Handles.emplace_back (
2232
+ Ops[InlineAsm::Op_ExtraInfo]); // 3 (SideEffect, AlignStack)
2233
+
2234
+ unsigned i = InlineAsm::Op_FirstOperand, e = Ops.size ();
2235
+ if (Ops[e - 1 ].getValueType () == MVT::Glue)
2233
2236
--e; // Don't process a glue operand if it is here.
2234
2237
2235
2238
while (i != e) {
2236
- InlineAsm::Flag Flags (InOps [i]->getAsZExtVal ());
2239
+ InlineAsm::Flag Flags (Ops [i]->getAsZExtVal ());
2237
2240
if (!Flags.isMemKind () && !Flags.isFuncKind ()) {
2238
2241
// Just skip over this operand, copying the operands verbatim.
2239
- Ops .insert (Ops .end (), InOps .begin () + i,
2240
- InOps .begin () + i + Flags.getNumOperandRegisters () + 1 );
2242
+ Handles .insert (Handles .end (), Ops .begin () + i,
2243
+ Ops .begin () + i + Flags.getNumOperandRegisters () + 1 );
2241
2244
i += Flags.getNumOperandRegisters () + 1 ;
2242
2245
} else {
2243
2246
assert (Flags.getNumOperandRegisters () == 1 &&
@@ -2247,18 +2250,18 @@ void SelectionDAGISel::SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops,
2247
2250
if (Flags.isUseOperandTiedToDef (TiedToOperand)) {
2248
2251
// We need the constraint ID from the operand this is tied to.
2249
2252
unsigned CurOp = InlineAsm::Op_FirstOperand;
2250
- Flags = InlineAsm::Flag (InOps [CurOp]->getAsZExtVal ());
2253
+ Flags = InlineAsm::Flag (Ops [CurOp]->getAsZExtVal ());
2251
2254
for (; TiedToOperand; --TiedToOperand) {
2252
2255
CurOp += Flags.getNumOperandRegisters () + 1 ;
2253
- Flags = InlineAsm::Flag (InOps [CurOp]->getAsZExtVal ());
2256
+ Flags = InlineAsm::Flag (Ops [CurOp]->getAsZExtVal ());
2254
2257
}
2255
2258
}
2256
2259
2257
2260
// Otherwise, this is a memory operand. Ask the target to select it.
2258
2261
std::vector<SDValue> SelOps;
2259
2262
const InlineAsm::ConstraintCode ConstraintID =
2260
2263
Flags.getMemoryConstraintID ();
2261
- if (SelectInlineAsmMemoryOperand (InOps[i+ 1 ], ConstraintID, SelOps))
2264
+ if (SelectInlineAsmMemoryOperand (Ops[i + 1 ], ConstraintID, SelOps))
2262
2265
report_fatal_error (" Could not match memory address. Inline asm"
2263
2266
" failure!" );
2264
2267
@@ -2267,15 +2270,19 @@ void SelectionDAGISel::SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops,
2267
2270
: InlineAsm::Kind::Func,
2268
2271
SelOps.size ());
2269
2272
Flags.setMemConstraint (ConstraintID);
2270
- Ops. push_back (CurDAG->getTargetConstant (Flags, DL, MVT::i32 ));
2271
- llvm::append_range (Ops , SelOps);
2273
+ Handles. emplace_back (CurDAG->getTargetConstant (Flags, DL, MVT::i32 ));
2274
+ Handles. insert (Handles. end () , SelOps. begin (), SelOps. end () );
2272
2275
i += 2 ;
2273
2276
}
2274
2277
}
2275
2278
2276
2279
// Add the glue input back if present.
2277
- if (e != InOps.size ())
2278
- Ops.push_back (InOps.back ());
2280
+ if (e != Ops.size ())
2281
+ Handles.emplace_back (Ops.back ());
2282
+
2283
+ Ops.clear ();
2284
+ for (auto &handle : Handles)
2285
+ Ops.push_back (handle.getValue ());
2279
2286
}
2280
2287
2281
2288
// / findGlueUse - Return use of MVT::Glue value produced by the specified
0 commit comments