From 592400a1eaa1b5fa8c8aa59a49878a6dca6af843 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 15 Sep 2026 20:47:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(asan):=20=E5=B9=B6=E8=A1=8C=20llc=20?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=9C=A8=20ASan=20=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E6=94=B9=E7=94=A8=E6=8F=92=E6=A1=A9=E5=90=8E=E7=9A=84?= =?UTF-8?q?=20.asan.ll=20=E4=BD=9C=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase B 的 init_llc_task 先前用未插桩的 ir_path 拼 LlcCmd,opt 产出的 .asan.ll 只写进 OptCmd,worker 先跑 opt 再跑 llc 却读回原 .ll,导致 App 侧 76/76 个 obj 无 __asan 符号(ASan 内存排查半盲)。现将 llc 输入统一为 compile_input,与串行路径 compile_ll_to_obj 及 TransPyC 参考实现同口径;非 ASan 分支命令逐字不变。 --- App/lib/Phase/BuildPipeline.vp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/App/lib/Phase/BuildPipeline.vp b/App/lib/Phase/BuildPipeline.vp index cfd015d..91c470c 100644 --- a/App/lib/Phase/BuildPipeline.vp +++ b/App/lib/Phase/BuildPipeline.vp @@ -439,15 +439,12 @@ def init_llc_task(task: LlcTask | t.CPtr, ir_path: str, output_dir: str, if task.ModuleSha1 is None: return 1 string.strcpy(task.ModuleSha1, module_name) - # llc 命令 - cmd_len: sizet = len(cc_cmd) + len(cc_flags) \ - + len(obj_path) + len(ir_path) + 64 - task.LlcCmd = stdlib.malloc(cmd_len) - if task.LlcCmd is None: - return 1 - viperlib.snprintf(task.LlcCmd, cmd_len, "%s %s -o %s %s", - cc_cmd, cc_flags, obj_path, ir_path) - # ASan 模式:opt 插桩命令(worker 先跑,失败即置 Result) + # llc 输入选择:ASan 模式必须喂插桩后的 .asan.ll,与串行路径 + # compile_ll_to_obj 的 compile_input 同口径(否则 opt 生成了插桩产物 + # 却被 llc 忽略,App 侧 obj 里 0 处 __asan,内存排查半盲) + compile_input: str = ir_path + # ASan 模式:opt 插桩命令(worker 先跑 opt 再跑 llc,故 LlcCmd 的输入 + # 必须指向 asan_path;失败即置 Result) if _asan_mode != 0: asan_path: str = build_sliced_path(output_dir, module_name, "asan.ll") if asan_path is None: @@ -460,6 +457,15 @@ def init_llc_task(task: LlcTask | t.CPtr, ir_path: str, output_dir: str, "opt -passes=forceattrs,asan -force-attribute=sanitize_address" " -asan-globals=false -o %s %s", asan_path, ir_path) + compile_input = asan_path + # llc 命令(输入 = compile_input:非 ASan 为 .ll,ASan 为 .asan.ll) + cmd_len: sizet = len(cc_cmd) + len(cc_flags) \ + + len(obj_path) + len(compile_input) + 64 + task.LlcCmd = stdlib.malloc(cmd_len) + if task.LlcCmd is None: + return 1 + viperlib.snprintf(task.LlcCmd, cmd_len, "%s %s -o %s %s", + cc_cmd, cc_flags, obj_path, compile_input) return 0