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

[KnownBits] Remove hasConflict() assertions #94436

Closed
nikic opened this issue Jun 5, 2024 · 5 comments · Fixed by #94568
Closed

[KnownBits] Remove hasConflict() assertions #94436

nikic opened this issue Jun 5, 2024 · 5 comments · Fixed by #94568
Labels
code-cleanup good first issue https://github.com/llvm/llvm-project/contribute llvm Umbrella label for LLVM issues

Comments

@nikic
Copy link
Contributor

nikic commented Jun 5, 2024

The KnownBits infrastructure currently has pervasive !hasConflict() assertions, which ensure that KnownBits don't claim that a bit is both zero and one at the same time. However, these kinds of conflicts can naturally arise whenever the value is known to be poison. At this point, these assertions no longer provide value and just result in a steady stream of compiler crashes.

We should remove these assertions. Once that is done, we may also make use of conflicting KnownBits to fold values to poison.

@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2024

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. Check that no other contributor has already been assigned to this issue. If you believe that no one is actually working on it despite an assignment, ping the person. After one week without a response, the assignee may be changed.
  2. In the comments of this issue, request for it to be assigned to you, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
  3. Fix the issue locally.
  4. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  5. Create a Git commit.
  6. Run git clang-format HEAD~1 to format your changes.
  7. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2024

@llvm/issue-subscribers-good-first-issue

Author: Nikita Popov (nikic)

The KnownBits infrastructure currently has pervasive !hasConflict() assertions, which ensure that KnownBits don't claim that a bit is both zero *and* one at the same time. However, these kinds of conflicts can naturally arise whenever the value is known to be poison. At this point, these assertions no longer provide value and just result in a steady stream of compiler crashes.

We should remove these assertions. Once that is done, we may also make use of conflicting KnownBits to fold values to poison.

@CedricSwa
Copy link
Contributor

I would like to tackle this issue

@jayfoad
Copy link
Contributor

jayfoad commented Jun 6, 2024

We should remove these assertions. Once that is done, we may also make use of conflicting KnownBits to fold values to poison.

An obvious next step would be to remove all instances of this from KnownBits.cpp:

  if (Known.hasConflict())
    Known.setAllZero();

That will result in KnownBits returning conflict more often, so callers may need to be fixed to handle it correctly.

@CedricSwa
Copy link
Contributor

Ok I'm building it right now with the changes of #94568 and the change to KnownBits.cpp is there something I should check about testing it?

@CedricSwa CedricSwa removed their assignment Jun 7, 2024
nikic pushed a commit that referenced this issue Jun 7, 2024
Allow KnownBits to represent "always poison" values via conflict.

close: #94436
@EugeneZelenko EugeneZelenko added llvm Umbrella label for LLVM issues and removed llvm:instcombine labels Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-cleanup good first issue https://github.com/llvm/llvm-project/contribute llvm Umbrella label for LLVM issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants