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

[IR Verifier] didn't check if switch case is constant #58583

Closed
DataCorrupted opened this issue Oct 25, 2022 · 2 comments
Closed

[IR Verifier] didn't check if switch case is constant #58583

DataCorrupted opened this issue Oct 25, 2022 · 2 comments
Assignees

Comments

@DataCorrupted
Copy link
Member

DataCorrupted commented Oct 25, 2022

define void @foo(i16 %0, i16 %1) {
entry:
  switch i16 %0, label %default [
    i16 %1, label %on_one
    i16 2, label %on_two
  ]

default:                                          ; preds = %entry
  br label %exit

on_one:                                           ; preds = %entry
  br label %exit

on_two:                                           ; preds = %entry
  br label %exit

exit:                                             ; preds = %on_one, %on_two, %default
  ret void
}

The program is illegal but can pass IR Verifier. (`LLParser' will still report error)

However, if the programmer incorrectly setOperand of a switch in memory, IR Verifier won't report error.

Will update a patch to align tests in IR Verifier and LLParser for switch testing.

P.S> Should we add sanitization when Switch->setOperand(...) ? Currently, it only tests out of bound, should we also test for type consistency?

@DataCorrupted DataCorrupted added the llvm Umbrella label for LLVM issues label Oct 25, 2022
@DataCorrupted DataCorrupted self-assigned this Oct 25, 2022
@EugeneZelenko EugeneZelenko added llvm:core and removed llvm Umbrella label for LLVM issues labels Oct 25, 2022
@DataCorrupted
Copy link
Member Author

See patch https://reviews.llvm.org/D136656

@DataCorrupted
Copy link
Member Author

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

No branches or pull requests

2 participants