You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Full device debug puts #[unroll] and #[nounroll] attribute lines in the line table #1676
Follow-up named on #1530: "under --device-debug the goto that replaces the marker should take the artificial location the other markers use".
What happens
#[kernel] and #[device] put a marker call at the start of each loop annotated with #[unroll], #[unroll(N)], #[unroll(never)] or #[nounroll]. The importer removes that call. It plants a hint op and replaces the call with a goto to the call's return block, in the __unroll_config and __nounroll_config branches of mir-importer/src/translator/terminator/mod.rs. Both the hint op and the goto take the call's location, and that location is the attribute:
The kernel metadata markers (__launch_bounds_config and the rest of KERNEL_METADATA_MARKERS) have avoided this since #1125. Their replacement edge takes llvm_export::artificial_debug_location(), because "the replacement control-flow edge must also stay off the attribute line which caused the macro to inject them".
I measured on main (76ac1021) with cargo oxide build <example> --device-debug. All 38 loop-hint attributes in unroll_smoke get a .loc entry, and so do all 8 in nounroll. Each one sits on a branch inside the annotated loop:
A line-tables build (CUDA_OXIDE_DEBUG=line-tables) has none of them, because the branch doesn't survive optimization. Full debug skips the optimizer, so the branch and its location survive into the line table, and a debugger stepping through the loop can stop on the #[unroll] line.
Fix
Give that goto the artificial location in both branches. The hint op keeps the attribute's location, because that is where the not-unrolled warnings point.
For the guard, I'll extend examples/debug/verify-code-shape.sh. It already enforces this contract for the kernel prologue, and the compile-only sweep runs it on a --device-debug build. The debug example gets a kernel with one loop per spelling, and the script rejects any line-table entry on those attribute lines, in LLVM IR and in PTX.
Activity
fix(mir-importer): keep loop-hint marker branches off the attribute l…