[DynInst_API:] [dyninst/dyninst] 7c8812: amdgpu: fix short-branch off-by-one (S_BRANCH PC+4...


Date: Tue, 07 Jul 2026 03:46:27 -0700
From: bbiiggppiigg <noreply@xxxxxxxxxx>
Subject: [DynInst_API:] [dyninst/dyninst] 7c8812: amdgpu: fix short-branch off-by-one (S_BRANCH PC+4...
  Branch: refs/heads/bbiiggppiigg/amdgpu-hostcall-multiwave-scratch
  Home:   https://github.com/dyninst/dyninst
  Commit: 7c8812ee6a418f59425d01740017d7c4f29df89c
      https://github.com/dyninst/dyninst/commit/7c8812ee6a418f59425d01740017d7c4f29df89c
  Author: wuxx1279 <bbiiggppiigg@xxxxxxxxx>
  Date:   2026-07-07 (Tue, 07 Jul 2026)

  Changed paths:
    A amdgpu-hostcall-poc/divergent_mutatee/divergent.cpp
    M dyninstAPI/src/codegen/codegen-amdgpu.C

  Log Message:
  -----------
  amdgpu: fix short-branch off-by-one (S_BRANCH PC+4); add divergent-EXEC test

gfx908 S_BRANCH/s_cbranch_* (SOPP) compute their destination as
target = (PC_of_branch + 4) + SIMM16*4 â measured from the instruction AFTER
the branch. The short-jump emitters set SIMM16 = disp/4 without the -1, so every
displacement-computed short branch landed one instruction (4 bytes) past its
target. Fixed modifyJcc (the jump-to-target in the conditional-branch
expansion), generateBranch (short path), and modifyJump to use disp/4 - 1. The
-1 is direction-agnostic (it is +4 in dword units): verified for forward and
backward jumps. emitLongJump already accounts for this (fromAddress + 4), and
the literal emitShortJump(1) skip-jumps are correct as-is.

Latent before because straight-line kernels only use long jumps (springboard,
inter-module call); only loops/if-else emit short intra-function branches. A
relocated loop back-edge landed on loop-head+1, excluding the loop head's first
instruction (here the induction-variable decrement) from the loop -> counter
frozen, EXEC never narrowed, infinite loop, result never stored.

divergent_mutatee/: a divergent-EXEC test (same kernel name/signature/result as
vectoradd, C=A+B, but a real s_and_saveexec/execz divergent body) that exercises
this path and the EXEC-safe register spill under narrowed EXEC. PASSES at
N=64/128/256/512 after the fix.

Co-Authored-By: Claude Opus 4.8 <noreply@xxxxxxxxxxxxx>



To unsubscribe from these emails, change your notification settings at https://github.com/dyninst/dyninst/settings/notifications

[← Prev in Thread] Current Thread [Next in Thread→]
  • [DynInst_API:] [dyninst/dyninst] 7c8812: amdgpu: fix short-branch off-by-one (S_BRANCH PC+4..., bbiiggppiigg <=