<div dir="ltr"><div><div>It looks like this commit caused a miscompile regression (with -O1 or greater), reduced to this example:</div><div><br></div><div>namespace {</div><div>template <typename T1, typename T2></div><div>bool Same(const T1& v1, const T2& v2) {</div><div>  return v1 == v2;</div><div>}</div><div><br></div><div>class Thing {</div><div> public:</div><div>  enum Color { kPurple, kYellow };</div><div>  enum Numbers { kZero };</div><div><br></div><div>  static bool CheckFoo(int x, Color color) {</div><div>    if (!Same(kZero, x)) __builtin_abort();</div><div>    if (color == kPurple) __builtin_printf("color is purple\n");</div><div>    return true;</div><div>  }</div><div>};</div><div><br></div><div>class SomeThing : public Thing {</div><div> public:</div><div>  static void DoBar() {</div><div>    if (!CheckFoo(0, kPurple)) {</div><div>      __builtin_printf("This should never happen\n");</div><div>    }</div><div>  }</div><div>};</div><div><br></div><div>class OtherThing : public Thing {</div><div> public:</div><div>  static void DoBar() {</div><div>    if (!CheckFoo(0, kYellow)) {</div><div>      __builtin_printf("This should never happen\n");</div><div>    }</div><div>  }</div><div>};</div><div>}  // namespace</div><div><br></div><div>int main(int argc, char** argv) {</div><div>  SomeThing::DoBar();</div><div>  OtherThing::DoBar();</div><div>  return 0;</div><div>}</div><div><br></div><div>Output:</div><div>$ <clang built @r336098> -O1 regression.cc && ./a.out</div><div>color is purple</div><div>This should never happen</div><div>This should never happen</div><div>$ <clang built @r336097> -O1 regression.cc && ./a.out</div><div>color is purple</div><div>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?</div><div><br></div></div>(I also left this comment on <a href="https://reviews.llvm.org/rL336098">https://reviews.llvm.org/rL336098</a>, reposting here for visibility)<br></div>