Skip to content

[SPIR-V] Backend emits invalid types in OpPhi #109401

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

Closed
VyacheslavLevytskyy opened this issue Sep 20, 2024 · 0 comments · Fixed by #109660
Closed

[SPIR-V] Backend emits invalid types in OpPhi #109401

VyacheslavLevytskyy opened this issue Sep 20, 2024 · 0 comments · Fixed by #109660
Assignees

Comments

@VyacheslavLevytskyy
Copy link
Contributor

SPIR-V Backend emits invalid types in OpPhi in the following reproducer:

define ptr @foo(i1 %arg) {
entry:
  br i1 %arg, label %if.then.i, label %if.end.i

if.then.i:
  %r1 = tail call ptr @f1()
  br label %exit

if.end.i:
  %r2 = tail call ptr @f2()
  br label %exit

exit:
  %ret = phi ptr [ %r1, %if.then.i ], [ %r2, %if.end.i ]
  ret ptr %ret
}

define ptr @f1() {
entry:
  %p = alloca i8
  store i8 8, ptr %p
  ret ptr %p
}

define ptr @f2() {
entry:
  %p = alloca i32
  store i32 32, ptr %p
  ret ptr %p
}

spirv-val output:

$ spirv-val 1.spv
error: line 41: OpPhi's result type <id> '4[%_ptr_Function_uchar]' does not match incoming value <id> '15[%r2]' type <id> '8[%_ptr_Function_uint]'.
  %ret = OpPhi %_ptr_Function_uchar %r1 %22 %r2 %23
@VyacheslavLevytskyy VyacheslavLevytskyy self-assigned this Sep 20, 2024
puja2196 pushed a commit to puja2196/LLVM-tutorial that referenced this issue Oct 2, 2024
… a pointer and function's return type (#109660)

This PR improves type inference and fixes inconsistency between
previously deduced element type of a pointer and function's return type.
It fixes llvm/llvm-project#109401 by ensuring
that OpPhi is consistent with respect to operand types.
Sterling-Augustine pushed a commit to Sterling-Augustine/llvm-project that referenced this issue Oct 3, 2024
… a pointer and function's return type (llvm#109660)

This PR improves type inference and fixes inconsistency between
previously deduced element type of a pointer and function's return type.
It fixes llvm#109401 by ensuring
that OpPhi is consistent with respect to operand types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants