Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing definition for SSA value (v6) #51

Closed
greenhat opened this issue Oct 31, 2023 · 1 comment
Closed

Missing definition for SSA value (v6) #51

greenhat opened this issue Oct 31, 2023 · 1 comment
Assignees
Labels
bug Something isn't working frontend

Comments

@greenhat
Copy link
Contributor

#[no_mangle]
pub fn fib(n: u32) -> u32 {
    let mut a = 2;
    while a < n {
        a = a * 3;
    }
    a
}

Compiles to the following Wasm:

(module
  (type (;0;) (func (param i32) (result i32)))
  (func $fib (;0;) (type 0) (param i32) (result i32)
    (local i32)
    i32.const 2
    local.set 1
    loop (result i32) ;; label = @1
      block ;; label = @2
        local.get 1
        local.get 0
        i32.lt_u
        br_if 0 (;@2;)
        local.get 1
        return
      end
      local.get 1
      i32.const 3
      i32.mul
      local.set 1
      br 0 (;@1;)
    end
  )
  (memory (;0;) 16)
  (global $__stack_pointer (;0;) (mut i32) i32.const 1048576)
  (global (;1;) i32 i32.const 1048576)
  (global (;2;) i32 i32.const 1048576)
  (export "memory" (memory 0))
  (export "fib" (func $fib))
  (export "__data_end" (global 1))
  (export "__heap_base" (global 2))
)

Which translates to the following IR:

module noname

const $0 = 0x00100000;

global external @__stack_pointer : i32 = $0 { id = 0 };
global external @gv1 : i32 = $0 { id = 1 };
global external @gv2 : i32 = $0 { id = 2 };

pub fn fib(i32) -> i32 {
block0(v0: i32):
    v2 = const.i32 0 : i32;
    v3 = const.i32 2 : i32;
    br block2(v3);

block1(v1: i32):

block2(v5: i32):
    v7 = cast v5 : u32;
    v8 = cast v6 : u32;
    v9 = lt v7, v8 : i1;
    v10 = cast v9 : i32;
    v11 = neq v10, 0 : i1;
    condbr v11, block4, block5;

block3(v4: i32):

block4:
    v12 = const.i32 3 : i32;
    v13 = mul.wrapping v5, v12 : i32;
    br block2(v13);

block5:
    ret v5;
}

v6 is undefined.

@greenhat greenhat added bug Something isn't working frontend labels Oct 31, 2023
@greenhat greenhat self-assigned this Oct 31, 2023
greenhat added a commit that referenced this issue Nov 7, 2023
…alue

when looking for the value definition in the predecessors. #51

This removes the remnants of the previously removed `ValueData::Alias` variant.
It does not matter if we find the definition in the predecessors since we cannot
swap all sentinel value uses with it. So this fix always makes the sentinel value into a
block argument.
greenhat added a commit that referenced this issue Nov 16, 2023
…alue

when looking for the value definition in the predecessors. #51

This removes the remnants of the previously removed `ValueData::Alias` variant.
It does not matter if we find the definition in the predecessors since we cannot
swap all sentinel value uses with it. So this fix always makes the sentinel value into a
block argument.
greenhat added a commit that referenced this issue Nov 16, 2023
…alue

when looking for the value definition in the predecessors. #51

This removes the remnants of the previously removed `ValueData::Alias` variant.
It does not matter if we find the definition in the predecessors since we cannot
swap all sentinel value uses with it. So this fix always makes the sentinel value into a
block argument.
greenhat added a commit that referenced this issue Nov 17, 2023
…alue

when looking for the value definition in the predecessors. #51

This removes the remnants of the previously removed `ValueData::Alias` variant.
It does not matter if we find the definition in the predecessors since we cannot
swap all sentinel value uses with it. So this fix always makes the sentinel value into a
block argument.
bitwalker pushed a commit that referenced this issue Nov 17, 2023
…alue

when looking for the value definition in the predecessors. #51

This removes the remnants of the previously removed `ValueData::Alias` variant.
It does not matter if we find the definition in the predecessors since we cannot
swap all sentinel value uses with it. So this fix always makes the sentinel value into a
block argument.
greenhat added a commit that referenced this issue Nov 17, 2023
…alue

when looking for the value definition in the predecessors. #51

This removes the remnants of the previously removed `ValueData::Alias` variant.
It does not matter if we find the definition in the predecessors since we cannot
swap all sentinel value uses with it. So this fix always makes the sentinel value into a
block argument.
@greenhat
Copy link
Contributor Author

Fixed in #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend
Projects
None yet
Development

No branches or pull requests

1 participant