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

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


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

>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 1/2] [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

>From 3324e0ecd6ec113f79ec0e586cd0cc705dba5c63 Mon Sep 17 00:00:00 2001
From: bd1976bris <bd1976llvm at gmail.com>
Date: Thu, 3 Oct 2024 12:50:39 +0100
Subject: [PATCH 2/2] Make clang-format happy

---
 clang/lib/AST/ByteCode/Interp.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 38d52e93181fbc..acfa2fd212f5c0 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1435,7 +1435,7 @@ bool Interpret(InterpState &S, APValue &Result) {
   }
 }
 // https://github.com/llvm/llvm-project/issues/102513
-#if defined (_MSC_VER)
+#if defined(_MSC_VER)
 #pragma optimize("", on)
 #endif
 



More information about the cfe-commits mailing list