@@ -431,74 +431,6 @@ void FuncOp::print(OpAsmPrinter &p) {
431
431
getArgAttrsAttrName (), getResAttrsAttrName ());
432
432
}
433
433
434
- // / Clone the internal blocks from this function into dest and all attributes
435
- // / from this function to dest.
436
- void FuncOp::cloneInto (FuncOp dest, IRMapping &mapper) {
437
- // Add the attributes of this function to dest.
438
- llvm::MapVector<StringAttr, Attribute> newAttrMap;
439
- for (const auto &attr : dest->getAttrs ())
440
- newAttrMap.insert ({attr.getName (), attr.getValue ()});
441
- for (const auto &attr : (*this )->getAttrs ())
442
- newAttrMap.insert ({attr.getName (), attr.getValue ()});
443
-
444
- auto newAttrs = llvm::to_vector (llvm::map_range (
445
- newAttrMap, [](std::pair<StringAttr, Attribute> attrPair) {
446
- return NamedAttribute (attrPair.first , attrPair.second );
447
- }));
448
- dest->setAttrs (DictionaryAttr::get (getContext (), newAttrs));
449
-
450
- // Clone the body.
451
- getBody ().cloneInto (&dest.getBody (), mapper);
452
- }
453
-
454
- // / Create a deep copy of this function and all of its blocks, remapping
455
- // / any operands that use values outside of the function using the map that is
456
- // / provided (leaving them alone if no entry is present). Replaces references
457
- // / to cloned sub-values with the corresponding value that is copied, and adds
458
- // / those mappings to the mapper.
459
- FuncOp FuncOp::clone (IRMapping &mapper) {
460
- // Create the new function.
461
- FuncOp newFunc = cast<FuncOp>(getOperation ()->cloneWithoutRegions ());
462
-
463
- // If the function has a body, then the user might be deleting arguments to
464
- // the function by specifying them in the mapper. If so, we don't add the
465
- // argument to the input type vector.
466
- if (!isExternal ()) {
467
- FunctionType oldType = getFunctionType ();
468
-
469
- unsigned oldNumArgs = oldType.getNumInputs ();
470
- SmallVector<Type, 4 > newInputs;
471
- newInputs.reserve (oldNumArgs);
472
- for (unsigned i = 0 ; i != oldNumArgs; ++i)
473
- if (!mapper.contains (getArgument (i)))
474
- newInputs.push_back (oldType.getInput (i));
475
-
476
- // / If any of the arguments were dropped, update the type and drop any
477
- // / necessary argument attributes.
478
- if (newInputs.size () != oldNumArgs) {
479
- newFunc.setType (FunctionType::get (oldType.getContext (), newInputs,
480
- oldType.getResults ()));
481
-
482
- if (ArrayAttr argAttrs = getAllArgAttrs ()) {
483
- SmallVector<Attribute> newArgAttrs;
484
- newArgAttrs.reserve (newInputs.size ());
485
- for (unsigned i = 0 ; i != oldNumArgs; ++i)
486
- if (!mapper.contains (getArgument (i)))
487
- newArgAttrs.push_back (argAttrs[i]);
488
- newFunc.setAllArgAttrs (newArgAttrs);
489
- }
490
- }
491
- }
492
-
493
- // / Clone the current function into the new one and return it.
494
- cloneInto (newFunc, mapper);
495
- return newFunc;
496
- }
497
- FuncOp FuncOp::clone () {
498
- IRMapping mapper;
499
- return clone (mapper);
500
- }
501
-
502
434
LogicalResult FuncOp::verify () {
503
435
if (getNumResults () > 1 )
504
436
return emitOpError (" requires zero or exactly one result, but has " )
0 commit comments