[PATCH] D43762: [IPSCCP] Use constant range information for comparisons of parameters.

Jordan Rupprecht via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 11 15:38:28 PDT 2018


It looks like this commit caused a miscompile regression (with -O1 or
greater), reduced to this example:

namespace {
template <typename T1, typename T2>
bool Same(const T1& v1, const T2& v2) {
  return v1 == v2;
}

class Thing {
 public:
  enum Color { kPurple, kYellow };
  enum Numbers { kZero };

  static bool CheckFoo(int x, Color color) {
    if (!Same(kZero, x)) __builtin_abort();
    if (color == kPurple) __builtin_printf("color is purple\n");
    return true;
  }
};

class SomeThing : public Thing {
 public:
  static void DoBar() {
    if (!CheckFoo(0, kPurple)) {
      __builtin_printf("This should never happen\n");
    }
  }
};

class OtherThing : public Thing {
 public:
  static void DoBar() {
    if (!CheckFoo(0, kYellow)) {
      __builtin_printf("This should never happen\n");
    }
  }
};
}  // namespace

int main(int argc, char** argv) {
  SomeThing::DoBar();
  OtherThing::DoBar();
  return 0;
}

Output:
$ <clang built @r336098> -O1 regression.cc && ./a.out
color is purple
This should never happen
This should never happen
$ <clang built @r336097> -O1 regression.cc && ./a.out
color is purple
It looks like this might just be uncovering a bug in an earlier revision
(r335588), but we're not sure yet. Mind if we revert this change until we
figure out what's going on?

(I also left this comment on https://reviews.llvm.org/rL336098, reposting
here for visibility)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180711/0a25a7a5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4849 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180711/0a25a7a5/attachment-0001.bin>


More information about the llvm-commits mailing list