================ @@ -888,6 +888,69 @@ void CIRGenModule::updateCompletedType(const TagDecl *td) { genTypes.updateCompletedType(td); } +void CIRGenModule::addReplacement(StringRef name, mlir::Operation *op) { + replacements[name] = op; +} + +void CIRGenModule::replacePointerTypeArgs(cir::FuncOp oldF, cir::FuncOp newF) { + std::optional<mlir::SymbolTable::UseRange> optionalUseRange = + oldF.getSymbolUses(theModule); + if (!optionalUseRange) + return; + + for (const mlir::SymbolTable::SymbolUse &u : *optionalUseRange) { + // CallTryOp only shows up after FlattenCFG. + auto call = mlir::dyn_cast<cir::CallOp>(u.getUser()); + if (!call) + continue; + + mlir::OperandRange argOps = call.getArgs(); + mlir::ArrayRef<mlir::Type> funcArgTypes = + newF.getFunctionType().getInputs(); + // In the case of variadic functions, the call may have more arguments that + // the function type, so we can't use llvm::enumerate here. ---------------- andykaylor wrote:
In the full implementation from the incubator, the index is needed to replace the call arg with a bitcast if one is needed. However, I've convinced myself that we never hit the bitcast case, so I guess as long as this is just a check of that assumption, I can use llvm::zip. https://github.com/llvm/llvm-project/pull/145792 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits