Minimize usage of global constructors in Reactor
A few const bools are easily replaced with constexprs. Other global
constructors are left as is for now.
llvm_shutdown_obj is necessary for cleaning up LLVM at program exit and
is necessarily used every time SwiftShader is invoked.
We could replace CPUID::SSE4_1 with a call to a singleton function.
However, I believe this increases code complexity for little benefit.
Because it's a bool, there's no deconstructor associated with it, it's
cleaned up when global memory is deallocated.
Bug: b/175073772
Change-Id: I25635fda0878e30668cbfc6982877b5d2d924789
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/56708
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Sean Risser <srisser@google.com>
Commit-Queue: Sean Risser <srisser@google.com>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index db23dc5..e87eb76 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -165,7 +165,7 @@
// Wrapper for calls on C functions with Ice types
template<typename Return, typename... CArgs, typename... RArgs>
-Ice::Variable *Call(Ice::Cfg *function, Ice::CfgNode *basicBlock, Return(fptr)(CArgs...), RArgs &&...args)
+Ice::Variable *Call(Ice::Cfg *function, Ice::CfgNode *basicBlock, Return(fptr)(CArgs...), RArgs &&... args)
{
static_assert(sizeof...(CArgs) == sizeof...(RArgs), "Expected number of args don't match");
@@ -309,7 +309,7 @@
#endif
}
- static bool detectARM()
+ constexpr static bool detectARM()
{
#if defined(__arm__) || defined(__aarch64__)
return true;
@@ -334,10 +334,10 @@
}
};
-const bool CPUID::ARM = CPUID::detectARM();
+constexpr bool CPUID::ARM = CPUID::detectARM();
const bool CPUID::SSE4_1 = CPUID::detectSSE4_1();
-const bool emulateIntrinsics = false;
-const bool emulateMismatchedBitCast = CPUID::ARM;
+constexpr bool emulateIntrinsics = false;
+constexpr bool emulateMismatchedBitCast = CPUID::ARM;
constexpr bool subzeroDumpEnabled = false;
constexpr bool subzeroEmitTextAsm = false;