[comgr][hotswap] Bound finite external PC call targets - #3606
Closed
harsh-amd wants to merge 1 commit into
Closed
Conversation
harsh-amd
force-pushed
the
users/harsh/hotswap-upstream-draft-04a-external-targets
branch
2 times, most recently
from
July 26, 2026 00:02
f84293d to
c570b29
Compare
harsh-amd
force-pushed
the
users/harsh/hotswap-upstream-draft-04a-external-targets
branch
from
July 26, 2026 03:44
c570b29 to
f82d55c
Compare
This was referenced Jul 26, 2026
nirmie
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 27, 2026
Fix three soundness holes in the reusable PC-materialized call analysis and tighten the surrounding code and tests, per review on ROCm#3576: - Fail closed when the reaching-value worklist reaches an undecoded slot; previously the finite target set flowed through unknown bytes that could clobber the target pair or divert control flow. - Recompute Resolved[I] on every reusable-call visit so a reconvergent path that makes the call Unknown clears an earlier finite result instead of leaving it stale. - Insert each bounded s_set_pc_i64 return continuation into Info.Targets so the return's landing sites are protected from relocation, matching the forward call path (and ROCm#3606). - Read the carry-form first addend through the MC operand (evaluateAbsoluteUint32Operand) instead of peeking at raw .text bytes; the disassembler already exposes the SOP2 literal as an immediate. Drop the now-unused Text parameter from the two inner helpers and the Endian.h include. - Log the shared far-dispatch dispatcher-prefix overflow instead of returning false silently. Tests: add undecoded_gap and reconverge_reload fail-closed cases to hotswap-reusable-pc-call-targets.s; add plain and inline-immediate carry materialization unit tests; update BoundsCanonicalSetPcReturn to expect the now-protected return continuation. Full corpus is byte-identical before and after (the bugs are only reachable by malformed or hand-crafted input, not compiled output); all unit and lit suites pass.
nirmie
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 27, 2026
Fix three soundness holes in the reusable PC-materialized call analysis and tighten the surrounding code and tests, per review on ROCm#3576: - Fail closed when the reaching-value worklist reaches an undecoded slot; previously the finite target set flowed through unknown bytes that could clobber the target pair or divert control flow. - Recompute Resolved[I] on every reusable-call visit so a reconvergent path that makes the call Unknown clears an earlier finite result instead of leaving it stale. - Insert each bounded s_set_pc_i64 return continuation into Info.Targets so the return's landing sites are protected from relocation, matching the forward call path (and ROCm#3606). - Read the carry-form first addend through the MC operand (evaluateAbsoluteUint32Operand) instead of peeking at raw .text bytes; the disassembler already exposes the SOP2 literal as an immediate. Drop the now-unused Text parameter from the two inner helpers and the Endian.h include. - Log the shared far-dispatch dispatcher-prefix overflow instead of returning false silently. Tests: add undecoded_gap and reconverge_reload fail-closed cases to hotswap-reusable-pc-call-targets.s; add plain and inline-immediate carry materialization unit tests; update BoundsCanonicalSetPcReturn to expect the now-protected return continuation. Full corpus is byte-identical before and after (the bugs are only reachable by malformed or hand-crafted input, not compiled output); all unit and lit suites pass.
nirmie
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 27, 2026
Fix three soundness holes in the reusable PC-materialized call analysis and tighten the surrounding code and tests, per review on ROCm#3576: - Fail closed when the reaching-value worklist reaches an undecoded slot; previously the finite target set flowed through unknown bytes that could clobber the target pair or divert control flow. - Recompute Resolved[I] on every reusable-call visit so a reconvergent path that makes the call Unknown clears an earlier finite result instead of leaving it stale. - Insert each bounded s_set_pc_i64 return continuation into Info.Targets so the return's landing sites are protected from relocation, matching the forward call path (and ROCm#3606). - Read the carry-form first addend through the MC operand (evaluateAbsoluteUint32Operand) instead of peeking at raw .text bytes; the disassembler already exposes the SOP2 literal as an immediate. Drop the now-unused Text parameter from the two inner helpers and the Endian.h include. - Log the shared far-dispatch dispatcher-prefix overflow instead of returning false silently. Tests: add undecoded_gap and reconverge_reload fail-closed cases to hotswap-reusable-pc-call-targets.s; add plain and inline-immediate carry materialization unit tests; update BoundsCanonicalSetPcReturn to expect the now-protected return continuation. Full corpus is byte-identical before and after (the bugs are only reachable by malformed or hand-crafted input, not compiled output); all unit and lit suites pass.
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
Preserve Harsh Menon�[27m's original ROCm#3610 commit and apply the validated rebase delta as one follow-up commit.
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
Preserve Harsh Menon�[27m's original ROCm#3610 commit and apply the validated rebase delta as one follow-up commit.
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
Preserve Harsh Menon�[27m's original ROCm#3610 commit and apply the validated rebase delta as one follow-up commit.
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
Preserve Harsh Menon�[27m's original ROCm#3610 commit and apply the validated rebase delta as one follow-up commit.
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
Preserve Harsh Menon�[27m's original ROCm#3610 commit and apply the validated rebase delta as one follow-up commit.
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
Preserve Harsh Menon�[27m's original ROCm#3610 commit and apply the validated rebase delta as one follow-up commit.
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
SourishW
added a commit
to harsh-amd/llvm-project
that referenced
this pull request
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Bound calls whose complete target is proven but lies outside this object's
.text. The external address is not added to the local target set; the localreturn continuation is protected. Proven register transfers are recorded
separately so unrelated instructions in the containing function remain
eligible for safe source relocation.
The bounded-return proof also treats an external call continuation entering a
helper's fallthrough chain as a second link-register provenance and rejects
that return conservatively. Immediate absolute, PC-relative, and canonical
get-PC/add register-call forms are covered. A returning finite call fails
closed unless its continuation is aligned and strictly inside
.text; thisprevents
TextSizeor malformed/overflowed offsets from entering the localtarget set.
Review range
amd-stagingat50d16abb44335104f1f3b8ad8123d0b6aaa7f7d5f82d55cf79e6de8215445957e7169f06b7a79af8snapshot.
Validation
HotswapMCTests --gtest_filter=CollectDirectBranchTargets.*: 26/26 passed.HotswapMCTests: 130/130 passed.detect_leaks=1:halt_on_error=1:abort_on_error=1; no sanitizer findings.continuation == TextSizeformaterialized-register, immediate-absolute, and PC-relative external calls,
plus misalignment and continuation overflow.
absence of unresolved-target fallback, and byte-level idempotency.
clang-format, no-added-auto, andgit diff --check: clean.Full corpus comparison
amd-staging: 2,558SUCCESS -> SUCCESS, 127FAILURE -> FAILURE, zero regressions and zero improvements.mi300x:/home/harsh/hotswap-corpus-20260725-pr3606-f82d55cf-full2685libamd_comgr.soSHA-256:fe81571b39fd14c052fa5519be8eb7004adedd1c830389339992496d588799e1076ea013ba466139e76074fcbb31905a5041298e7644f6e8f590bf9353e4f5b967ff61bdcd3553047280f7381dea0ac6d8782eef9ca545724685a7c543122c18f51826f8183ae5b1c5de6b47ad9a88c4f0a25cca0b73c7cc9433a0d2b91aa300ef79a3b151b11a5f44d5ba811ed03b3b2da60c33ac792bc7e4c26c5658155841mi400-3smokehotswap-pr-review-rootonctheliosr-rck-g02-j19-13; four gfx1250 GPUs visible./opt/therock/lib/libamd_comgr.so.3.3.0resolved to theexact candidate with SHA-256
fe81571b39fd14c052fa5519be8eb7004adedd1c830389339992496d588799e1.ROCR_VISIBLE_DEVICES=0,HSA_HOTSWAP_VERBOSE=1,AMD_COMGR_HOTSWAP_ENTRY_TRAMPOLINES=0.merge_key_value.hip): 1/1 passed; embedded gtests:16/16 passed; 7.01 seconds.
/home/harmenon/logs/hotswap-pr-review-20260725/rocthrust_test64_pr3606_f82d55cf.loga3bd0d429be826d4e961298e0474497b5cff2b01eeeab9cfe3a2c33cfdb3605eCI classification
The formatter, primary Linux and Windows builds, Linux and Windows COMGR tests,
SPIR-V translator tests, LLVM SPIR-V codegen tests, compiler/runtime stages,
and documentation build are green.
Linux::release / Test rocm-examplesfailed outside this COMGR change: HIP-Basic built and its 23 tests passed,
then the SPIR-V
Applications/monte_carlo_pibuild could not findhipcub/iterator/counting_input_iterator.hpp. The larger multi-architecturematrix is still running.
Remaining draft gate
Publish the instrumented source-coverage report, finish the required CI
classification, and demonstrate this correctness prerequisite's value through
a separately reviewed dependent corpus-reducing slice. Keep this PR draft
until those gates are recorded.