[PATCH] D96945: [InstCombine] Add simplification of two logical and/ors
Jordan Rupprecht via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 31 19:48:09 PDT 2021
rupprecht added a comment.
Here's a repro for the issue we're seeing. It only seems to be happening with msan enabled, so I'm not sure if this is just an msan bug, or a general miscompile that *happens* to trigger in this test when msan is enabled.
The source:
#include <string>
#include <variant>
struct a {
double b;
double c;
std::string d;
};
std::variant<std::pair<int, int>, std::string> e(a f) {
double g = f.b, h = f.c;
if (f.d == "y") {
g *= 2.0;
h *= 2.0;
}
int i(g);
int k(h);
if (i == 0) i = h;
if (k == 0) k = i;
if (k < i || i < 0) {
std::string j;
return j;
}
return std::make_pair(i, k);
}
int main() {
auto j = e({1, 0, "x"});
std::get<0>(j);
}
To build/run it:
$ clang++ \
-O2 \
-msse4.2 \
-fsanitize=memory \
-std=gnu++17 \
-stdlib=libc++ \
repro.cc \
-o bug
$ ./bug
terminating with uncaught exception of type std::bad_variant_access: bad_variant_access
Thoughts on this example? If I follow correctly, at the `if (k < i || i < 0) {` check, both `k` and `i` should be 1, and that check should not trigger. Instead, it evaluates to true: the `std::get<0>(j)` triggers an exception, because the method return a `std::string`, not a `std::pair` after this patch.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96945/new/
https://reviews.llvm.org/D96945
More information about the llvm-commits
mailing list