[llvm] [llvm] Optimize print-on-crash serialization (PR #205682)
Miguel A. Arroyo via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 31 15:48:26 PDT 2026
================
@@ -324,6 +325,70 @@ void unwrapAndPrint(raw_ostream &OS, IRUnitRef IR) {
llvm_unreachable("Unknown wrapped IR type");
}
+static std::unique_ptr<Module>
+cloneFunctionsIntoNewModule(ArrayRef<const Function *> FunctionsToClone) {
+ if (FunctionsToClone.empty()) {
+ return nullptr;
+ }
+
+ auto &Context = FunctionsToClone.front()->getContext();
+ auto M = std::make_unique<Module>("temp", Context);
+
+ for (auto *F : FunctionsToClone) {
+ SmallVector<ReturnInst *, 8> Returns;
+ ValueToValueMapTy VMap;
+ auto *NewF = cast<Function>(
+ M->getOrInsertFunction(F->getName(), F->getFunctionType()).getCallee());
+ CloneFunctionInto(NewF, F, VMap, CloneFunctionChangeType::DifferentModule,
+ Returns);
+ }
+
+ return std::move(M);
----------------
mayanez wrote:
Done.
https://github.com/llvm/llvm-project/pull/205682
More information about the llvm-commits
mailing list