From 8f571ebe4b2103a9bc1d687af0ae41e06ab9984f Mon Sep 17 00:00:00 2001 From: Jin Date: Fri, 4 Sep 2026 22:22:28 -0400 Subject: [PATCH] Fix missing DedupTable definition in ddisasm runner declarations --- .../ir/codegen/cuda/complete_runner.py | 3 +++ tests/test_integration_ddisasm.py | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/srdatalog/ir/codegen/cuda/complete_runner.py b/src/srdatalog/ir/codegen/cuda/complete_runner.py index 8748dd1..d8401a6 100644 --- a/src/srdatalog/ir/codegen/cuda/complete_runner.py +++ b/src/srdatalog/ir/codegen/cuda/complete_runner.py @@ -1097,6 +1097,9 @@ def gen_complete_runner( "", ) decl += decl_aliases + if node.dedup_hash: + # LaunchParams stores the table by value, so main needs its full definition. + decl += _gen_dedup_table_struct(node) decl += _gen_launch_params_struct( len(node.dest_specs), is_fused_eligible, diff --git a/tests/test_integration_ddisasm.py b/tests/test_integration_ddisasm.py index 38051b5..71c4a15 100644 --- a/tests/test_integration_ddisasm.py +++ b/tests/test_integration_ddisasm.py @@ -18,8 +18,11 @@ import sys from pathlib import Path +import pytest from integration_helpers import FIXTURES, diff_hir, diff_mir +from srdatalog import build_project + sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "examples")) from ddisasm import build_ddisasmdb_program @@ -37,6 +40,26 @@ def test_ddisasm_mir(): diff_mir(build_ddisasm(), "ddisasm") +@pytest.mark.parametrize("layout", ["split", "sharded", "unity"]) +def test_ddisasm_dedup_type_defined_before_use(tmp_path, layout): + project = build_project( + build_ddisasm(), + "DdisasmPlan", + cache_base=str(tmp_path), + shard_step_bodies=layout == "sharded", + unity=layout == "unity", + ) + checked = 0 + for path in [project["main"], *project["batches"]]: + cpp = Path(path).read_text() + if "DedupTable dedup_table{};" not in cpp: + continue + assert cpp.count("struct DedupTable {") == 1, path + assert cpp.index("struct DedupTable {") < cpp.index("DedupTable dedup_table{};"), path + checked += 1 + assert checked > 0 + + if __name__ == "__main__": test_ddisasm_hir() test_ddisasm_mir()