This is a patch to fix bug 34908 which avoids an assertion being tripped when an assume intrinsic is called on a constant value.
Details
Diff Detail
Event Timeline
Suggesting a slightly different fix.
lib/Transforms/Scalar/GVN.cpp | ||
---|---|---|
1368 | At this point, if V is a constant, you should return false. There is nothing useful we can do: Every other constant is equivalent to assume(true). That leaves two options:
Either seems reasonable. As an aside, it's mentioned this came from a rust issue. If so, *that* should be filed as a bug, as that propagation lost valuable information. |
Sure thing, updated!
Unfortunately the original Rust issue is sort of hard to reproduce. It only came up during ThinLTO passes which I didn't find easy to run from the LLVM CLI tools, but I can always provide the original IR (it's quite large) if desired!
test/Transforms/GVN/no-crash-on-undef-assume.ll | ||
---|---|---|
1 | check the output? |
test/Transforms/GVN/no-crash-on-undef-assume.ll | ||
---|---|---|
1 | Oh I wasn't quite sure what this should be checking, this is basically just asserting it doesn't crash (today this test case crashes w/ asserts enabled) |
test/Transforms/GVN/no-crash-on-undef-assume.ll | ||
---|---|---|
1 | you could probably just pipe the output to FileCheck %s and insert some check lines (please see any other test in tree).
Thanks! |
test/Transforms/GVN/no-crash-on-undef-assume.ll | ||
---|---|---|
1 | Yeah, pipe it to filecheck. For example, to update newgvn tests, i usually use: from the tests/Transforms/NewGVN directory |
Okay if you address the remaining comments.
Thanks!
lib/Transforms/Scalar/GVN.cpp | ||
---|---|---|
1365 | Can you add a comment saying "if it's not false, and constant, it must evaluate to true. This means our assume is assume(true), and thus, pointless, and we don't want to do anything more here" or something similar. |
Ok thanks for the help! I've updated with some CHECK directives now. Mind helping me land the patch as well?
LGTM once you address last Danny's concern (i.e. adding a comment :)
Alex, do you have commit access or you want me to commit that on your behalf? Thanks!
Oops sorry about that! Missed that last request, but should be taken care of now.
Also yeah if you could commit on my behalf that'd be great, thanks!
In trunk now.
git svn dcommit --interactive Committing to https://llvm.org/svn/llvm-project/llvm/trunk ... commit 9bafdc0fb7038b1729d180b7306bae1f068c7785 Author: Davide Italiano <dccitaliano@gmail.com> Date: Tue Oct 10 21:20:54 2017 -0700 [GVN] Don't replace constants with constants. This fixes PR34908. Patch by Alex Crichton! Differential Revision: https://reviews.llvm.org/D38765 create mode 100644 test/Transforms/GVN/pr34908.ll Commit this patch to SVN? ([y]es (default)|[n]o|[q]uit|[a]ll): y A test/Transforms/GVN/pr34908.ll M lib/Transforms/Scalar/GVN.cpp Committed r315429
Can you add a comment saying "if it's not false, and constant, it must evaluate to true. This means our assume is assume(true), and thus, pointless, and we don't want to do anything more here"
or something similar.