LLVM 7.0 dEQP fixes

dEQP using SwiftShader with LLVM 7.0 has a number of failures. Most
of them were cause either by using unsafe floating point math or by
a "__chkstk not found" error.

Change-Id: I16f14b3aee6f24717ec90ce2ea5bae8b4439620a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 04c9ab8..d50c9ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -255,6 +255,7 @@
 
 if(WIN32)
     add_definitions(-DWINVER=0x501 -DNOMINMAX -DSTRICT)
+    set_cpp_flag("-DDEBUGGER_WAIT_DIALOG" DEBUG)
     set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib")
 endif()
 
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index ba4aeb9..2164ec1 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -550,10 +550,7 @@
 			llvm::JITSymbol symbol = compileLayer.findSymbolIn(moduleKey, name, false);
 
 			llvm::Expected<llvm::JITTargetAddress> expectAddr = symbol.getAddress();
-			if (!expectAddr)
-			{
-				return nullptr;
-			}
+			assert(expectAddr);
 
 			void *addr = reinterpret_cast<void *>(static_cast<intptr_t>(expectAddr.get()));
 			return new LLVMRoutine(addr, releaseRoutineCallback, this, moduleKey);
@@ -767,7 +764,7 @@
 		// llvm::NoNaNsFPMath = true;
 #else
 		llvm::TargetOptions targetOpts;
-		targetOpts.UnsafeFPMath = true;
+		targetOpts.UnsafeFPMath = false;
 		// targetOpts.NoInfsFPMath = true;
 		// targetOpts.NoNaNsFPMath = true;
 #endif
@@ -920,6 +917,11 @@
 		::function->setCallingConv(llvm::CallingConv::C);
 
 		::builder->SetInsertPoint(llvm::BasicBlock::Create(*::context, "", ::function));
+
+#if SWIFTSHADER_LLVM_VERSION >= 7
+	// This fixes the "__chkstk not found" error
+	::function->addFnAttr("stack-probe-size", "1048576");
+#endif
 	}
 
 	Value *Nucleus::getArgument(unsigned int index)
diff --git a/src/Reactor/Routine.cpp b/src/Reactor/Routine.cpp
index df82ab8..0dbaab2 100644
--- a/src/Reactor/Routine.cpp
+++ b/src/Reactor/Routine.cpp
@@ -14,25 +14,22 @@
 
 #include "Routine.hpp"
 
-#include "../Common/Thread.hpp"
-
 #include <cassert>
 
 namespace sw
 {
-	Routine::Routine()
+	Routine::Routine() : bindCount(0)
 	{
-		bindCount = 0;
 	}
 
 	void Routine::bind()
 	{
-		atomicIncrement(&bindCount);
+		++bindCount;
 	}
 
 	void Routine::unbind()
 	{
-		long count = atomicDecrement(&bindCount);
+		int count = bindCount--;
 
 		if(count == 0)
 		{
diff --git a/src/Reactor/Routine.hpp b/src/Reactor/Routine.hpp
index b3ad7f5..d8c745c 100644
--- a/src/Reactor/Routine.hpp
+++ b/src/Reactor/Routine.hpp
@@ -15,6 +15,8 @@
 #ifndef sw_Routine_hpp
 #define sw_Routine_hpp
 
+#include "../Common/Thread.hpp"
+
 namespace sw
 {
 	class Routine
@@ -31,7 +33,7 @@
 		void unbind();
 
 	private:
-		volatile int bindCount;
+		AtomicInt bindCount;
 	};
 }