Skip to content

Conversation

@JonathanBrouwer
Copy link
Contributor

Successful merges:

r? @ghost

Create a similar rollup

Flakebi and others added 8 commits January 9, 2026 10:41
Add a rustc intrinsic `amdgpu_dispatch_ptr` to access the kernel
dispatch packet on amdgpu.
The HSA kernel dispatch packet contains important information like the
launch size and workgroup size.

The Rust intrinsic lowers to the `llvm.amdgcn.dispatch.ptr` LLVM
intrinsic, which returns a `ptr addrspace(4)`, plus an addrspacecast to
`addrspace(0)`, so it can be returned as a Rust reference.

The returned pointer/reference is valid for the whole program lifetime,
and is therefore `'static`.

The return type of the intrinsic (`*const ()`) does not mention the
struct so that rustc does not need to know the exact struct type.
An alternative would be to define the struct as lang item or add a
generic argument to the function.

Short version:
```rust
#[cfg(target_arch = "amdgpu")]
pub fn amdgpu_dispatch_ptr() -> *const ();
```
Co-authored-by: ericinB <ericbncer@gmail.com>
…ubilee

Add amdgpu_dispatch_ptr intrinsic

There is an ongoing discussion in rust-lang#150452 about using address spaces from the Rust language in some way.
As that discussion will likely not conclude soon, this PR adds one rustc_intrinsic with an addrspacecast to unblock getting basic information like launch and workgroup size and make it possible to implement something like `core::gpu`.

Add a rustc intrinsic `amdgpu_dispatch_ptr` to access the kernel dispatch packet on amdgpu.
The HSA kernel dispatch packet contains important information like the launch size and workgroup size.

The Rust intrinsic lowers to the `llvm.amdgcn.dispatch.ptr` LLVM intrinsic, which returns a `ptr addrspace(4)`, plus an addrspacecast to `addrspace(0)`, so it can be returned as a Rust reference.
The returned pointer/reference is valid for the whole program lifetime, and is therefore `'static`.
The return type of the intrinsic (`&'static ()`) does not mention the struct so that rustc does not need to know the exact struct type. An alternative would be to define the struct as lang item or add a generic argument to the function.
Is this ok or is there a better way (also, should it return a pointer instead of a reference)?

Short version:
```rust
#[cfg(target_arch = "amdgpu")]
pub fn amdgpu_dispatch_ptr() -> *const ();
```

Tracking issue: rust-lang#135024
Unify and deduplicate From<T> float tests

cc rust-lang#141726

Unify the From<bool> tests from f16.rs and f128.rs into a single float_test! in mod.rs.
THIR patterns: Always use type `str` for string-constant-value nodes

Historically, constants and literals of type `&str` have been represented in THIR patterns as `PatKind::Const` nodes with type `&str`.

That's fine for stable Rust, but `feature(deref_patterns)` also created a need to have string literal patterns of type `str` in some cases, which resulted in a number of additional special cases and inconsistencies in typechecking and in HIR-to-THIR-to-MIR lowering of patterns.

We can avoid several of those special cases by having THIR treat string-constant-values as fundamentally being of type `str`, and then using `PatKind::Deref` to represent the additional `&` layer in the common case where it is needed. This allows bare `str` patterns to require very little special treatment.

Existing tests should already do a good job of demonstrating that this implementation change does not affect the stable language.
@rust-bors rust-bors bot added the rollup A PR which is a rollup label Jan 15, 2026
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 15, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 15, 2026
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/imports/ambiguous-6.rs ... ok
test [ui] tests/ui/imports/ambiguous-4.rs ... ok
test [ui] tests/ui/imports/ambiguous-7.rs ... ok
test [ui] tests/ui/imports/ambiguous-9.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-glob-vs-multiouter.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-globvsglob.rs ... ok
test [ui] tests/ui/imports/ambiguous-8.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-no-implicit-prelude.rs ... ok
test [ui] tests/ui/imports/ambiguous-glob-vs-expanded-extern.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-core-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-std-glob.rs ... ok
---
Saved the actual stdout to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/thir-print/str-patterns/str-patterns.stdout`
diff of stdout:

33             },
34             guard: None,
35             body: e3,
-             lint_level: Explicit(
-                 HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).9),
-             ),
+             hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).9),
39             scope: Node(9),
40             span: $DIR/str-patterns.rs:11:9: 11:22 (#0),
41         },

78             },
79             guard: None,
80             body: e5,
-             lint_level: Explicit(
-                 HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).15),
-             ),
+             hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).15),
84             scope: Node(15),
85             span: $DIR/str-patterns.rs:12:9: 12:23 (#0),
86         },

93             },
94             guard: None,
95             body: e7,
-             lint_level: Explicit(
-                 HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).19),
-             ),
+             hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).19),
99             scope: Node(19),
100             span: $DIR/str-patterns.rs:13:9: 13:16 (#0),
101         },

150         Expr {
151             kind: Scope {
152                 region_scope: Node(5),
-                 lint_level: Explicit(
-                     HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).5),
-                 ),
+                 hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).5),
156                 value: e0,
157             },
158             ty: &'{erased} str,

170         Expr {
171             kind: Scope {
172                 region_scope: Node(10),
-                 lint_level: Explicit(
-                     HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).10),
-                 ),
+                 hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).10),
176                 value: e2,
177             },
178             ty: (),

190         Expr {
191             kind: Scope {
192                 region_scope: Node(16),
-                 lint_level: Explicit(
-                     HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).16),
-                 ),
+                 hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).16),
196                 value: e4,
197             },
198             ty: (),

210         Expr {
211             kind: Scope {
212                 region_scope: Node(20),
-                 lint_level: Explicit(
-                     HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).20),
-                 ),
+                 hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).20),
216                 value: e6,
217             },
218             ty: (),

236         Expr {
237             kind: Scope {
238                 region_scope: Node(4),
-                 lint_level: Explicit(
-                     HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).4),
-                 ),
+                 hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).4),
242                 value: e8,
243             },
244             ty: (),

256         Expr {
257             kind: Scope {
258                 region_scope: Node(22),
-                 lint_level: Explicit(
-                     HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).22),
-                 ),
+                 hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).22),
262                 value: e10,
263             },
264             ty: (),

328         Expr {
329             kind: Scope {
330                 region_scope: Node(5),
-                 lint_level: Explicit(
-                     HirId(DefId(0:4 ~ str_patterns[fc71]::CONSTANT).5),
-                 ),
+                 hir_id: HirId(DefId(0:4 ~ str_patterns[fc71]::CONSTANT).5),
334                 value: e0,
335             },
336             ty: &'{erased} str,


The actual stdout differed from the expected stdout
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args thir-print/str-patterns.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/thir-print/str-patterns.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/thir-print/str-patterns" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2024" "-Zunpretty=thir-flat"
--- stdout -------------------------------
DefId(0:3 ~ str_patterns[fc71]::hello_world):
Thir {
    body_type: Fn(
        fn(&'{erased} str),
    ),
    arms: [
        Arm {
            pattern: Pat {
                ty: &'{erased} str,
                span: /checkout/tests/ui/thir-print/str-patterns.rs:11:9: 11:16 (#0),
                extra: None,
                kind: Deref {
                    subpattern: Pat {
                        ty: str,
                        span: /checkout/tests/ui/thir-print/str-patterns.rs:11:9: 11:16 (#0),
                        extra: None,
                        kind: Constant {
                            value: Value {
                                ty: str,
                                valtree: Branch(
                                    [
                                        104_u8,
                                        101_u8,
                                        108_u8,
                                        108_u8,
---
                        },
                    },
                },
            },
            guard: None,
            body: e3,
            hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).9),
            scope: Node(9),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:9: 11:22 (#0),
        },
        Arm {
            pattern: Pat {
                ty: &'{erased} str,
                span: /checkout/tests/ui/thir-print/str-patterns.rs:12:9: 12:17 (#0),
                extra: Some(
                    PatExtra {
                        expanded_const: Some(
                            DefId(0:4 ~ str_patterns[fc71]::CONSTANT),
                        ),
                        ascriptions: [],
                    },
                ),
                kind: Deref {
---
                        },
                    },
                },
            },
            guard: None,
            body: e5,
            hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).15),
            scope: Node(15),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:12:9: 12:23 (#0),
        },
        Arm {
            pattern: Pat {
                ty: &'{erased} str,
                span: /checkout/tests/ui/thir-print/str-patterns.rs:13:9: 13:10 (#0),
                extra: None,
                kind: Wild,
            },
            guard: None,
            body: e7,
            hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).19),
            scope: Node(19),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:13:9: 13:16 (#0),
        },
    ],
    blocks: [
        Block {
            targeted_by_break: false,
            region_scope: Node(11),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:20: 11:22 (#0),
            stmts: [],
            expr: None,
            safety_mode: Safe,
        },
        Block {
            targeted_by_break: false,
            region_scope: Node(17),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:12:21: 12:23 (#0),
            stmts: [],
            expr: None,
            safety_mode: Safe,
        },
        Block {
            targeted_by_break: false,
            region_scope: Node(21),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:13:14: 13:16 (#0),
            stmts: [],
            expr: None,
            safety_mode: Safe,
        },
        Block {
            targeted_by_break: false,
            region_scope: Node(3),
            span: /checkout/tests/ui/thir-print/str-patterns.rs:9:29: 15:2 (#0),
            stmts: [],
            expr: Some(
                e9,
            ),
            safety_mode: Safe,
        },
    ],
    exprs: [
        Expr {
            kind: VarRef {
                id: LocalVarId(
                    HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).2),
                ),
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:10:11: 10:12 (#0),
        },
        Expr {
            kind: Scope {
                region_scope: Node(5),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).5),
                value: e0,
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:10:11: 10:12 (#0),
        },
        Expr {
            kind: Block {
                block: b0,
            },
            ty: (),
            temp_scope_id: 10,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:20: 11:22 (#0),
        },
        Expr {
            kind: Scope {
                region_scope: Node(10),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).10),
                value: e2,
            },
            ty: (),
            temp_scope_id: 10,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:11:20: 11:22 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(16),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).16),
                value: e4,
            },
            ty: (),
            temp_scope_id: 16,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:12:21: 12:23 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(20),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).20),
                value: e6,
            },
            ty: (),
            temp_scope_id: 20,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:13:14: 13:16 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(4),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).4),
                value: e8,
            },
            ty: (),
            temp_scope_id: 4,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:10:5: 14:6 (#0),
        },
---
        },
        Expr {
            kind: Scope {
                region_scope: Node(22),
                hir_id: HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).22),
                value: e10,
            },
            ty: (),
            temp_scope_id: 22,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:9:29: 15:2 (#0),
        },
    ],
    stmts: [],
    params: [
        Param {
            pat: Some(
                Pat {
                    ty: &'{erased} str,
                    span: /checkout/tests/ui/thir-print/str-patterns.rs:9:20: 9:21 (#0),
                    extra: None,
                    kind: Binding {
                        name: "x",
                        mode: BindingMode(
                            No,
                            Not,
                        ),
                        var: LocalVarId(
                            HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).2),
                        ),
                        ty: &'{erased} str,
                        subpattern: None,
                        is_primary: true,
                        is_shorthand: false,
                    },
                },
            ),
            ty: &'{erased} str,
            ty_span: Some(
                /checkout/tests/ui/thir-print/str-patterns.rs:9:23: 9:27 (#0),
            ),
            self_kind: None,
            hir_id: Some(
                HirId(DefId(0:3 ~ str_patterns[fc71]::hello_world).1),
            ),
        },
    ],
}

DefId(0:4 ~ str_patterns[fc71]::CONSTANT):
Thir {
    body_type: Const(
        &'{erased} str,
    ),
    arms: [],
    blocks: [],
    exprs: [
        Expr {
---
                    span: /checkout/tests/ui/thir-print/str-patterns.rs:17:24: 17:34 (#0),
                },
                neg: false,
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:17:24: 17:34 (#0),
        },
        Expr {
            kind: Scope {
                region_scope: Node(5),
                hir_id: HirId(DefId(0:4 ~ str_patterns[fc71]::CONSTANT).5),
                value: e0,
            },
            ty: &'{erased} str,
            temp_scope_id: 5,
            span: /checkout/tests/ui/thir-print/str-patterns.rs:17:24: 17:34 (#0),
        },
    ],
    stmts: [],
    params: [],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. rollup A PR which is a rollup T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants