Revert "Make Reactor buildable with LLVM 18"

This reverts commit 90d72a29c0cb1f624c0a7fd46eb70f50bcc069fc.

Reason for revert: Breaks build on roll to Android and ANGLE.

Change-Id: Ie93177376f7e5e71b1a39cb32611eda492005604
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/75408
Commit-Queue: Shahbaz Youssefi <syoussefi@google.com>
Reviewed-by: Geoff Lang <geofflang@google.com>
Tested-by: Shahbaz Youssefi <syoussefi@google.com>
diff --git a/src/Reactor/LLVMJIT.cpp b/src/Reactor/LLVMJIT.cpp
index 1f0e325..262c69e 100644
--- a/src/Reactor/LLVMJIT.cpp
+++ b/src/Reactor/LLVMJIT.cpp
@@ -47,7 +47,7 @@
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/TargetParser/Host.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
@@ -103,12 +103,6 @@
 #if __has_feature(memory_sanitizer)
 #	include "sanitizer/msan_interface.h"
 
-#if LLVM_VERSION_MAJOR < 18
-using LLVMOptLevel = llvm::CodeGenOpt::Level;
-#else
-using LLVMOptLevel = llvm::CodeGenOptLevel;
-#endif
-
 // MemorySanitizer uses thread-local storage (TLS) data arrays for passing around
 // the 'shadow' values of function arguments and return values. The LLVM JIT can't
 // access TLS directly, but it calls __emutls_get_address() to obtain the address.
@@ -196,7 +190,7 @@
 private:
 	JITGlobals(llvm::orc::JITTargetMachineBuilder &&jitTargetMachineBuilder, llvm::DataLayout &&dataLayout);
 
-	static LLVMOptLevel toLLVM(int level);
+	static llvm::CodeGenOpt::Level toLLVM(int level);
 
 	const llvm::orc::JITTargetMachineBuilder jitTargetMachineBuilder;
 	const llvm::DataLayout dataLayout;
@@ -309,30 +303,26 @@
 {
 }
 
-LLVMOptLevel JITGlobals::toLLVM(int level)
+llvm::CodeGenOpt::Level JITGlobals::toLLVM(int level)
 {
-#if LLVM_VERSION_MAJOR < 18
-#define CodeGenOptLevel CodeGenOpt
-#endif
 	// TODO(b/173257647): MemorySanitizer instrumentation produces IR which takes
 	// a lot longer to process by the machine code optimization passes. Disabling
 	// them has a negligible effect on code quality but compiles much faster.
 	if(__has_feature(memory_sanitizer))
 	{
-		return llvm::CodeGenOptLevel::None;
+		return llvm::CodeGenOpt::None;
 	}
 
 	switch(level)
 	{
-	case 0: return llvm::CodeGenOptLevel::None;
-	case 1: return llvm::CodeGenOptLevel::Less;
-	case 2: return llvm::CodeGenOptLevel::Default;
-	case 3: return llvm::CodeGenOptLevel::Aggressive;
+	case 0: return llvm::CodeGenOpt::None;
+	case 1: return llvm::CodeGenOpt::Less;
+	case 2: return llvm::CodeGenOpt::Default;
+	case 3: return llvm::CodeGenOpt::Aggressive;
 	default: UNREACHABLE("Unknown Optimization Level %d", int(level));
 	}
 
-	return llvm::CodeGenOptLevel::Default;
-#undef CodeGenOptLevel
+	return llvm::CodeGenOpt::Default;
 }
 
 class MemoryMapper final : public llvm::SectionMemoryManager::MemoryMapper
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 08d0c3e..dda6d91 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -59,12 +59,6 @@
 }  // namespace llvm
 #endif
 
-#if LLVM_VERSION_MAJOR >= 18
-constexpr static auto &our_getInt8PtrTy = llvm::PointerType::getUnqual;
-#else
-constexpr static auto &our_getInt8PtrTy = llvm::Type::getInt8PtrTy;
-#endif
-
 namespace {
 
 // Used to automatically invoke llvm_shutdown() when driver is unloaded
@@ -3788,7 +3782,7 @@
 void VPrintf(const std::vector<Value *> &vals)
 {
 	auto i32Ty = llvm::Type::getInt32Ty(*jit->context);
-	auto i8PtrTy = our_getInt8PtrTy(*jit->context);
+	auto i8PtrTy = llvm::Type::getInt8PtrTy(*jit->context);
 	auto funcTy = llvm::FunctionType::get(i32Ty, { i8PtrTy }, true);
 	auto func = jit->module->getOrInsertFunction("rr::DebugPrintf", funcTy);
 	jit->builder->CreateCall(func, V(vals));
@@ -3857,7 +3851,7 @@
 	auto i1Ty = llvm::Type::getInt1Ty(*jit->context);
 	auto i8Ty = llvm::Type::getInt8Ty(*jit->context);
 	auto i32Ty = llvm::Type::getInt32Ty(*jit->context);
-	auto i8PtrTy = our_getInt8PtrTy(*jit->context);
+	auto i8PtrTy = llvm::Type::getInt8PtrTy(*jit->context);
 	auto promiseTy = jit->coroutine.yieldType;
 	auto promisePtrTy = promiseTy->getPointerTo();
 
@@ -4022,7 +4016,7 @@
 	// coroutine.
 	auto voidTy = llvm::Type::getVoidTy(*jit->context);
 	auto i1Ty = llvm::Type::getInt1Ty(*jit->context);
-	auto i8PtrTy = our_getInt8PtrTy(*jit->context);
+	auto i8PtrTy = llvm::Type::getInt8PtrTy(*jit->context);
 	auto handleTy = i8PtrTy;
 	auto boolTy = i1Ty;
 	auto promiseTy = T(YieldType);