thakis created this revision.

MSVC2017 update 3 produces a clang that crashes when compiling clang. Disabling 
optimizations for StmtProfiler::VisitCXXOperatorCallExpr() makes the crash go 
away.

Patch from Bruce Dawson <brucedaw...@chromium.org>!


https://reviews.llvm.org/D35757

Files:
  lib/AST/StmtProfile.cpp


Index: lib/AST/StmtProfile.cpp
===================================================================
--- lib/AST/StmtProfile.cpp
+++ lib/AST/StmtProfile.cpp
@@ -1364,6 +1364,13 @@
   llvm_unreachable("Invalid overloaded operator expression");
 }
 
+#if defined(_MSC_VER) && _MSC_VER == 1911
+// Work around 
https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
+// MSVC 2017 update 3 miscompiles this function, and a clang built with it
+// will crash in stage 2 of a bootstrap build.
+#pragma optimize("", off)
+#endif
+
 void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
   if (S->isTypeDependent()) {
     // Type-dependent operator calls are profiled like their underlying
@@ -1396,6 +1403,10 @@
   ID.AddInteger(S->getOperator());
 }
 
+#if defined(_MSC_VER) && _MSC_VER == 1911
+#pragma optimize("", on)
+#endif
+
 void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
   VisitCallExpr(S);
 }


Index: lib/AST/StmtProfile.cpp
===================================================================
--- lib/AST/StmtProfile.cpp
+++ lib/AST/StmtProfile.cpp
@@ -1364,6 +1364,13 @@
   llvm_unreachable("Invalid overloaded operator expression");
 }
 
+#if defined(_MSC_VER) && _MSC_VER == 1911
+// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
+// MSVC 2017 update 3 miscompiles this function, and a clang built with it
+// will crash in stage 2 of a bootstrap build.
+#pragma optimize("", off)
+#endif
+
 void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
   if (S->isTypeDependent()) {
     // Type-dependent operator calls are profiled like their underlying
@@ -1396,6 +1403,10 @@
   ID.AddInteger(S->getOperator());
 }
 
+#if defined(_MSC_VER) && _MSC_VER == 1911
+#pragma optimize("", on)
+#endif
+
 void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
   VisitCallExpr(S);
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to