[Comgr][hotswap] Add code-object metadata parsing#2437
Conversation
81e6053 to
d1a05c9
Compare
2675e92 to
3831ee0
Compare
d1a05c9 to
8be9478
Compare
|
Thanks for putting this up. Two main pieces of feedback, both around the AGENT_CONVENTIONS "Comgr first, LLVM second, custom never" rule. The below is obv Claude's thoughts. But in general, we can beef up the existing Comgr metadata API implementations if we need to support Hotswap's needs. I think that could benefit both "sub-projects". Reuse existing Comgr metadata APIs
Switching to
The Comgr internal helpers take The one piece that's genuinely new is Reuse existing LLVM facilitiesA few hand-rolled bits that already exist in
Most of these collapse into the Comgr reuse above (the note iteration disappears entirely if you go through |
|
We really really really need to pull out common functionality that is shared between the transpiler and the translator into a singular module. We will have to suffer from a lot of code duplication later otherwise. |
3831ee0 to
9f6c2ed
Compare
8be9478 to
6ab4011
Compare
9f6c2ed to
ec69509
Compare
6ab4011 to
dd6bb68
Compare
ec69509 to
3b59a99
Compare
94e24d0 to
d6f97c5
Compare
7fde156 to
2c6f5a2
Compare
2c6f5a2 to
73d12ca
Compare
cb7ba8d to
ccdfadc
Compare
ccdfadc to
9bc71b6
Compare
| @@ -0,0 +1,344 @@ | |||
| //===- code-object-utils.cpp - Hotswap transpiler -------------------------===// | |||
| // | |||
| // Part of Comgr, under the Apache License v2.0 with LLVM Exceptions. See | |||
There was a problem hiding this comment.
Likely needs to be redirected beyond the PR author, but why this is not just "part of LLVM project". If there is intention to contribute this to LLVM, are we we expecting to have to update all files?
ftynse
left a comment
There was a problem hiding this comment.
The overall concern is the error flow. This code mostly just dumps stuff to errs without telling errors and warnings apart, sometimes suppressing things later. There is also no consistent error propagation mechanism, sometimes it's random booleans (LLVM had a huge discussion on whether true because error or success), sometimes it's empty containers (which could be valid!), sometimes it's some intermediate field.
9bc71b6 to
9880187
Compare
|
more in f68dd49, but irrelevant for the current PR |
e20dd25 to
877df15
Compare
… in raiser
Adds the AMDGPU code-object metadata extraction surface that the rest of
the raiser pipeline depends on:
* `extractTextSection`, `listKernelNames`, `extractKernelMeta`,
`findKernelSymbolOffset`, and `detectIsaFromElf` in
`hotswap/code_object_utils.{h,cpp}`.
* `KernelMeta` populated with both MsgPack-derived fields (kernarg/group/
private segment sizes, args) and the raw kernel-descriptor register
bytes (`compute_pgm_rsrc{1,2}`, `kernel_code_properties`,
`kernarg_preload`) read from `<name>.kd` in `.rodata`.
Reuses comgr's existing parsing infrastructure rather than duplicating
it: each helper wraps the input ELF bytes in an
`AMD_COMGR_DATA_KIND_EXECUTABLE` data object via a small
`ScopedDataObject` RAII helper and routes through
`metadata::getMetadataRoot` / `metadata::getElfIsaName` for the metadata
walk and ISA-name extraction.
Also adopts llvm::Error / llvm::Expected for the raiser scaffolding
entry point (mirrors upstream rocm commit f68dd49): raiseToIR
returns Expected<RaiseResult>, validation failures surface as
HotswapError values via the existing hotswap-error.h, and the
handrolled raise-failure.h is removed. An empty-input scaffolding
mode bypass is added so test scaffolding can stub the raiser without
standing up a real ISA + metadata pair. The KD-bytes lookup comments
reflect partial-success (MsgPack-derived fields are returned even if
.rodata KD parse fails).
No MC stack, no disassembler, no opcode canonicalisation yet -- those
land in subsequent commits.
Co-Authored-By: Tim Gymnich <tim@gymni.ch>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Alex Zinenko <git@ozinenko.com>
877df15 to
9428a8b
Compare
Adds the ELF/MsgPack metadata parser that the rest of the raiser pipeline
depends on. Public surface is
extractTextSection,listKernelNames,extractKernelMeta,findKernelSymbolOffset, anddetectIsaFromElf.No MC stack, no disassembler, no opcode canonicalisation yet — those land
in subsequent commits. The kernel-descriptor fields on
KernelMeta(kernelcode properties, kernarg preload, compute_pgm_rsrc1/2) are populated here
so later layers (
UserSgprLayout, kernarg layout) have the metadata theyexpect; the raiser itself does not consume them yet.
Includes a small focused gtest covering the empty-input and malformed-ELF
guards on the public API.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com