[Comgr] Add end-to-end LIT coverage for amd_comgr_hotswap_rewrite#2291
Conversation
6614457 to
dfce3c4
Compare
| # Each LLVM backend built into the in-tree tools becomes a | ||
| # `<target>-registered-target` feature, matching the upstream LLVM lit.cfg | ||
| # convention. Tests that need a specific backend (e.g. the HotSwap LIT | ||
| # harness driving clang with --offload-arch=gfx*) can gate on these rather | ||
| # than fail noisily on builds that omit AMDGPU / X86 / etc. | ||
| for target in config.llvm_targets_to_build.split(";"): | ||
| target = target.strip() | ||
| if target: | ||
| config.available_features.add(target.lower() + "-registered-target") | ||
|
|
There was a problem hiding this comment.
Don't think we actually have a way to exercise the case where AMDGPU target is omitted. We'd fail on the Comgr link, so probably not worth to add here.
There was a problem hiding this comment.
If we drop this, the config.llvm_targets_to_build = r'@LLVM_TARGETS_TO_BUILD@' addition in lit.site.cfg.py.in and the REQUIRES: in the test can also go.
There was a problem hiding this comment.
You're right. Comgr calls LLVMInitializeAMDGPU*() unconditionally so libamd_comgr.so wouldn't link without AMDGPU in the first place -- the REQUIRES: gate was defensive code that can never fire. Dropped all three pieces in 5f1e46a7:
REQUIRES: amdgpu-registered-targetfromhotswap-rewrite-e2e.hip- the
<target>-registered-targetfeature loop inlit.cfg.py - the
config.llvm_targets_to_build = r'@LLVM_TARGETS_TO_BUILD@'plumbing inlit.site.cfg.py.in
Net: -17 lines. I originally added it because I'd promised it in the #2203 follow-up plan, but the promise was overblown; happy to drop it here and note the reasoning inline on the #2203 thread if that makes the audit trail cleaner. If a future LIT test genuinely needs backend-gating (e.g. an x86-only stanza), we can re-add the feature machinery then.
|
[2026-04-22T18:39:19.249Z] PASS: Comgr :: hotswap-rewrite.c (8 of 25) Cool. I do think we should probably create a hotswap/ directory to keep things organized, but we can do that later. |
dfce3c4 to
5f1e46a
Compare
|
Agreed on the |
Adds test-lit/hotswap-rewrite-e2e.hip: drives the full compile -> hotswap-rewrite -> verify chain on a real clang-produced gfx1250 code object. Uses the in-tree %clang / %llvm-readelf / %llvm-objdump / %FileCheck substitutions so the test runs out of the LLVM monorepo build without any external toolchain. Current assertions (weak patch stubs in PR ROCm#2203 keep the output bytewise-identical to the input, so we check what we can verify today): - Input is a gfx1250 ELF (e_flags carries gfx1250, AMDHSA metadata note records amdhsa.target = amdgcn-amd-amdhsa--gfx1250). - amd_comgr_hotswap_rewrite returns AMD_COMGR_STATUS_SUCCESS. - Output ELF preserves the gfx1250 identity on both channels. - .text is still present and marked PROGBITS. - llvm-objdump recognizes the output as elf64-amdgpu and disassembles at least through s_endpgm. Future per-patch PRs (in-place / trampoline / WMMA / scratch) will layer their own `llvm-objdump | FileCheck` stanzas on top of this harness to assert their specific opcode / trampoline changes. Supporting changes: - amd/comgr/test-lit/lit.cfg.py: add %llvm-readelf substitution (only %llvm-objdump was wired up previously). - amd/comgr/test-lit/comgr-sources/hotswap-rewrite.c: optional --output <path> flag to write the rewrite output to a file so LIT tests can inspect it with llvm-readelf / llvm-objdump. Existing --zero-size negative-path coverage is unchanged. Made-with: Cursor
5f1e46a to
2b0a8f6
Compare
Summary
End-to-end LIT coverage for
amd_comgr_hotswap_rewrite. Drives the full compile -> hotswap-rewrite -> verify chain on a real clang-produced gfx1250 code object, using the in-tree%clang/%llvm-readelf/%llvm-objdump/%FileChecksubstitutions -- no external toolchain required.Follow-up to #2203. Implements part (A) of the testing-infrastructure plan laid out in that PR's comment thread: the dedicated infra-PR that goes in before any real-patch PR lands.
Changes
test-lit/hotswap-rewrite-e2e.hip(new): compiles a tiny kernel with%clang --offload-arch=gfx1250 --offload-device-only, pipes the resulting code object throughhotswap-rewrite, and verifies the output with%llvm-readelf -h/%llvm-readelf --notes/%llvm-readelf --section-headers/%llvm-objdump -d.test-lit/lit.cfg.py: add%llvm-readelfsubstitution (only%llvm-objdumpwas wired up previously).test-lit/comgr-sources/hotswap-rewrite.c: optional--output <path>flag to write the rewrite output to a file so LIT tests can inspect it. Existing--zero-sizenegative-path coverage and the NULL-args / unsupported-ISA / malformed-ELF stanzas are unchanged.What this covers today
Patches in
comgr-hotswap-b0a0.cppare weak stubs returning 0 in #2203, so the dispatcher currently emits an output that is bytewise-identical to the input. Even with no patches applied we assert:e_flagscontainsgfx1250, AMDHSA metadata note recordsamdhsa.target: amdgcn-amd-amdhsa--gfx1250).amd_comgr_hotswap_rewritereturnsAMD_COMGR_STATUS_SUCCESS.e_flags+ AMDHSA note)..textsection is still present andPROGBITS.llvm-objdumprecognizes the output aself64-amdgpuand disassembles throughs_endpgm.Future per-patch PRs
Each subsequent real-patch PR (in-place / trampoline / WMMA / scratch) will layer its own
llvm-objdump | FileCheckstanza on top of this harness to assert the specific opcode changes / trampolines its policy introduces. No further infra PRs needed -- part (B) of the plan in #2203 is a per-PR convention rather than a dedicated PR.Test plan
cc @lamb-j @chinmaydd
Made with Cursor