[clang] [MSVC] work-around for compile time issue 102513 (PR #110986)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 3 04:38:43 PDT 2024


https://github.com/bd1976bris created https://github.com/llvm/llvm-project/pull/110986

Disable optimizations when building with Microsoft's compiler as it has a bug that causes excessive build times. We do this only when NDEBUG is not defined on the assumption that building without asserts indicates that a user is strongly invested in runtime performance.

Partially addresses: https://github.com/llvm/llvm-project/issues/102513.

Once the bug is addressed in the Microsoft compiler this can be removed.

>From 2579ce88f4e757e068621e1763d3aabb5352a223 Mon Sep 17 00:00:00 2001
From: bd1976bris <bd1976llvm at gmail.com>
Date: Thu, 3 Oct 2024 12:33:18 +0100
Subject: [PATCH] [MSVC] work-around for compile time issue 102513

Disable optimizations when building with Microsoft's compiler as it has a bug that causes excessive build times. We do this only when NDEBUG is not defined on the assumption that building without asserts indicates that a user is strongly invested in runtime performance.

Partially addresses: https://github.com/llvm/llvm-project/issues/102513.

Once the bug is addressed in the Microsoft compiler this can be removed.
---
 clang/lib/AST/ByteCode/Interp.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index fd9a256843a0ec..38d52e93181fbc 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1406,6 +1406,10 @@ bool handleFixedPointOverflow(InterpState &S, CodePtr OpPC,
   return S.noteUndefinedBehavior();
 }
 
+// https://github.com/llvm/llvm-project/issues/102513
+#if defined(_WIN32) && !defined(__clang__) && !defined(NDEBUG)
+#pragma optimize("", off)
+#endif
 bool Interpret(InterpState &S, APValue &Result) {
   // The current stack frame when we started Interpret().
   // This is being used by the ops to determine wheter
@@ -1430,6 +1434,10 @@ bool Interpret(InterpState &S, APValue &Result) {
     }
   }
 }
+// https://github.com/llvm/llvm-project/issues/102513
+#if defined (_MSC_VER)
+#pragma optimize("", on)
+#endif
 
 } // namespace interp
 } // namespace clang



More information about the cfe-commits mailing list