Fix -warn-stack-size command line option for LLVM 12
The -warn-stack-size command line option won't be deprecated until the
LLVM 13 release.
This change also produces a compile-time error when LLVM 13+ is used so
we won't fail to notice that the the stack size checking functionality
has to be implemented using the per-function "warn-stack-size" attribute
introduced by https://reviews.llvm.org/D104342. Note that development
builds of LLVM use LLVM_MAJOR_VERSION=9999.
Bug: b/191193823
Change-Id: I044d576a6dcd73354710783a7f7e042cb43254c5
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/55188
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Reactor/LLVMJIT.cpp b/src/Reactor/LLVMJIT.cpp
index bb5ffcc..3f25295 100644
--- a/src/Reactor/LLVMJIT.cpp
+++ b/src/Reactor/LLVMJIT.cpp
@@ -151,10 +151,14 @@
#if defined(__i386__) || defined(__x86_64__)
"-x86-asm-syntax=intel", // Use Intel syntax rather than the default AT&T
#endif
+#if LLVM_VERSION_MAJOR <= 12
+ "-warn-stack-size=524288" // Warn when a function uses more than 512 KiB of stack memory
+#else
// TODO(b/191193823): TODO(ndesaulniers): Update this after
// go/compilers/fc018ebb608ee0c1239b405460e49f1835ab6175
-#if LLVM_VERSION_MAJOR <= 11
- "-warn-stack-size=524288" // Warn when a function uses more than 512 KiB of stack memory
+# if LLVM_VERSION_MAJOR < 9999
+# error Implement stack size checks using the "warn-stack-size" function attribute.
+# endif
#endif
};