Yiran Le
2026
Beyond Surface-Level Pattern Trap: LLM Agents for Faster and Smarter Cross-Architecture Code Migration
Weijia Li | KE Gao | Pengfei Chen | Jiajie Li | Xinyu Wang | Yiran Le | Yize Wu | Ling Li
Findings of the Association for Computational Linguistics: ACL 2026
Weijia Li | KE Gao | Pengfei Chen | Jiajie Li | Xinyu Wang | Yiran Le | Yize Wu | Ling Li
Findings of the Association for Computational Linguistics: ACL 2026
The problem of surface-level pattern mapping represents a critical yet underexplored failure mode in large language model (LLM) reasoning, and is particularly acute in cross-architecture code migration of high-performance libraries. On low-resource, low-level code, insufficient coverage in pretraining data often leads LLMs to rely on superficial name- or type-based correspondences, rather than principled refactorization and reasoning grounded in core functional semantics and architecture-specific optimization intents. This tendency severely hampers the effectiveness of LLMs in complex migration scenarios.To address these challenges, we propose FSCM, a multi-agent framework for cross-architecture migration. FSCM decouples complex implementation details through functional mining and code refactoring, guiding LLMs to focus on invariant semantic anchors across architectures. By mitigating surface-level pattern traps, FSCM improves both functional correctness and performance when targeting emerging architectures. Extensive experiments on the challenging real-world OpenCV library migration tasks demonstrate substantial improvements over state-of-the-art baselines, achieving up to 22% higher correctness rates over Copilot and 43.04x speedup on RISC-V platforms. Code and data are available at: https://anonymous.4open.science/r/code-F8D4.