rust/tests
Flakebi cde7e805ad
Cast allocas to default address space
Pointers for variables all need to be in the same address space for
correct compilation. Therefore ensure that even if an `alloca` is
created in a different address space, it is casted to the default
address space before its value is used.

This is necessary for the amdgpu target and others where the default
address space for `alloca`s is not 0.

For example the following code compiles incorrectly when not casting the
address space to the default one:

```rust
fn f(p: *const i8 /* addrspace(0) */) -> *const i8 /* addrspace(0) */ {
    let local = 0i8; /* addrspace(5) */
    let res = if cond { p } else { &raw const local };
    res
}
```

results in

```llvm
    %local = alloca addrspace(5) i8
    %res = alloca addrspace(5) ptr

if:
    ; Store 64-bit flat pointer
    store ptr %p, ptr addrspace(5) %res

else:
    ; Store 32-bit scratch pointer
    store ptr addrspace(5) %local, ptr addrspace(5) %res

ret:
    ; Load and return 64-bit flat pointer
    %res.load = load ptr, ptr addrspace(5) %res
    ret ptr %res.load
```

For amdgpu, `addrspace(0)` are 64-bit pointers, `addrspace(5)` are
32-bit pointers.
The above code may store a 32-bit pointer and read it back as a 64-bit
pointer, which is obviously wrong and cannot work. Instead, we need to
`addrspacecast %local to ptr addrspace(0)`, then we store and load the
correct type.
2025-02-10 21:38:44 +01:00
..
assembly tests/assembly/asm: Remove uses of rustc_attrs and lang_items features by using minicore 2024-12-18 02:59:07 +09:00
auxiliary tests/assembly/asm: Remove uses of rustc_attrs and lang_items features by using minicore 2024-12-18 02:59:07 +09:00
codegen Cast allocas to default address space 2025-02-10 21:38:44 +01:00
codegen-units Use field init shorthand where possible 2024-12-17 14:33:10 -08:00
coverage Add a test for coverage attr on trait function 2024-12-24 00:09:38 +11:00
coverage-run-rustdoc
crashes Fix ICE when opaque captures a duplicated/invalid lifetime 2025-01-01 19:32:51 +00:00
debuginfo Begin to implement type system layer of unsafe binders 2024-12-22 21:57:57 +00:00
incremental Add more info on type/trait mismatches for different crate versions 2024-12-07 18:18:08 +00:00
mir-opt MatchBranchSimplification: Consider empty-unreachable otherwise branch 2024-12-27 10:57:46 +00:00
pretty Update tests to use new proc-macro header 2024-11-27 07:18:25 -08:00
run-make Rollup merge of #134829 - jieyouxu:migrate-libs-through-symlinks, r=lqd 2024-12-28 16:50:38 +11:00
rustdoc chore: fix typos 2024-12-31 23:46:39 +08:00
rustdoc-gui Add GUI test for item info elements color 2024-12-28 20:54:00 +01:00
rustdoc-js Rollup merge of #134277 - notriddle:notriddle/inline-into, r=GuillaumeGomez 2024-12-16 20:00:20 +01:00
rustdoc-js-std Adjust test for slightly changed inlining behavior 2024-12-26 18:31:55 -07:00
rustdoc-json Remove rustc::existing_doc_keyword lint. 2024-12-17 13:56:10 +11:00
rustdoc-ui chore: fix some typos 2024-12-31 15:11:18 +08:00
ui Rollup merge of #135000 - compiler-errors:opaque-captures-dupe, r=lqd 2025-01-01 22:04:18 +01:00
ui-fulldeps Rollup merge of #134834 - dtolnay:unnamedcall, r=compiler-errors 2024-12-27 18:43:05 -08:00
COMPILER_TESTS.md