fix(asan): 并行 llc 任务在 ASan 模式下改用插桩后的 .asan.ll 作输入

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 分支命令逐字不变。
This commit is contained in:
TermiNexus committed 2026-09-15 20:47:14 +08:00
1 parent 8312e653e8
commit 592400a1ea
1 file changed
+15 -9
+15 -9
View File
@@ -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