ScalarPair product types missing `noundef` in LLVM return types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
We do set noundef on scalar return types, but for a pair like (u16, bool) -- which can't have any undef in the LLVM immediate pair type even though it can in memory -- we're currently not:
#[unsafe(no_mangle)]
pub unsafe fn demo_pair(num: u16) -> (u16, bool) {
unsafe {
let r = num.unchecked_mul(256);
(r, num < 256)
}
}
We just generate https://rust.godbolt.org/z/W154v8xhW
define { i16, i1 } @demo_pair(i16 noundef %num) unnamed_addr {
start:
%r = mul nuw i16 %num, 256
%_3 = icmp ult i16 %num, 256
%0 = insertvalue { i16, i1 } poison, i16 %r, 0
%1 = insertvalue { i16, i1 } %0, i1 %_3, 1
ret { i16, i1 } %1
}
It should be
-define { i16, i1 } @demo_pair(i16 noundef %num) unnamed_addr {
+define noundef { i16, i1 } @demo_pair(i16 noundef %num) unnamed_addr {
If it's easier, it looks like we're not setting it for things that don't have undef in memory either (https://rust.godbolt.org/z/rez44Kx58) so could start with that part.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Rust example and inspecting the generated LLVM IR shown in the issue, then trace the compiler’s handling of scalar versus pair return types. Done means the pair return declaration includes the noundef attribute, including cases whose immediate LLVM type has no undef in memory; verify both examples against the expected IR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100