Repository navigation
feat(unroll): point not-unrolled warnings at the #[unroll] attribute - #1530
Merged
Merged
Conversation
Signed-off-by: midagedev <midagedev@gmail.com>
pliron 0.20 removed the Located trait and Operation::loc() now returns a borrowed Location, so the match binds the source path key by reference. Drop the trait import in the pass and its tests and pass the key by value to uniqued_any::get, which has always taken it by value. Signed-off-by: nihalpasham <nihalp@nvidia.com>
The #[unroll] marker now carries the attribute's span so not-unrolled warnings point at the attribute. Giving that span to the braces around a literal factor made rustc's unused_braces lint report every #[unroll(N)] in the user's crate, with a fix-it that deletes the attribute, and failed the per-example clippy gate on four examples. Build the braced const argument with the macro's own span and give only the call the attribute's span. The marker text and position are unchanged, so the warning positions and the const-eval note still land on the attribute. A trybuild pass case under #![deny(unused_braces)] with literal factors guards it. Signed-off-by: nihalpasham <nihalp@nvidia.com>
…bute Each warning about a loop that was not unrolled now carries the file, line and column of its #[unroll] attribute on a --> line. Add one sentence to the two book pages that describe those warnings. Signed-off-by: nihalpasham <nihalp@nvidia.com>
Collaborator
|
/ok to test fdcb343 |
Collaborator
|
Thanks, the attribute is the right anchor and the pass only reads the location the importer already attaches. Three things on top before merging:
At |
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.
What this adds
A not-unrolled warning now says where the request was. The
#[kernel],#[device]and#[cuda_module]macros give the hidden__unroll_configmarker the span of the#[unroll]attribute instead of the span of the outer macro, and the unroll pass prints the position the importer attached to that marker as a second line in rustc's-->form. A kernel with several annotated loops shows which one was left alone.What we fixed
Span::call_site(), the whole#[kernel]attribute, so neither the pass nor rustc had a useful position for anything about the loop.#[unroll(Invalid::UNROLL)], pointed at#[kernel]with a macro-backtrace hint; it now points at the attribute.#[unroll(N)]tripped rustc'sunused_braceslint and failed the per-example clippy lane on four examples.Warning contract
warning: #[unroll] requested but the loop was not unrolled: <reason>, or#[unroll(N)]for a partial request.--> file:line:columnof the#[unroll]attribute, 1-based, with the path as rustc prints it for the crate.Implementation
cuda-macros:take_unroll_factorreturns the factor together withattr.span();marker_stmtbuilds the call withparse_quote_spanned!at that span and interpolates the braced factor with the macro's span. One visitor serves all three entry points.mir-importer: untouched. It already sets the hint op'sLocationfrom the call terminator's span, so the position is available without debug info.mir-transforms:hint_locationreadsLocation::SrcPos { Source::File, pos }and returnsNonefor every other variant;take_loop_hintsunlinks a loop's hints and returns the first located one;not_unrolled_warningis the single text source for the seven emission sites.while,forandloopat different indents, two unit tests for a located and an unlocated hint, the updated trybuild snapshot, and a trybuild pass case under#![deny(unused_braces)]with literal factors.Verification
Checked at
fdcb34315(nightly-2026-10-11, RTX 5090):cargo test -p cuda-macros --all-targets: the unit tests and every trybuild case pass, including the new span test, the newdeny(unused_braces)pass case and thepolicy_config_invalid_unrollsnapshot at the attribute (15:5).cargo test -p mir-transforms --all-targets: 35 unit tests, two of them new, plus the integration suites pass.cargo oxide run unroll_smokeon sm_120a: PASS; the four deliberate negatives print positions 249:13, 273:13, 504:9 and 508:9; zerounused_braceswarnings; memcheck 0 errors.--lineinfoline tables identical.unroll_smoke,unroll_bounds_check,gemm_solandgemm_sol_final; fmt, clippy and rustdoc with warnings as errors on both crates, the 18 guards, the lock check and the book build are clean.Caveats
-D warningsdoes not see it. Routing it like the launch-bounds spill warning is a follow-up.--device-debugthe goto that replaces the marker carries the attribute's line instead of the#[kernel]line;--lineinfotables and PTX are unchanged. Follow-up.