LLVMReactor: Cache llvm::TargetMachines.
LLVMReactor: Cache llvm::TargetMachines.

We previously created and held a TargetMachine per JITRoutine as the routine could be created with different optimization levels, which is a property used to create the TargetMachine.

However, a llvm::TargetMachine instance can consume a lot of memory and JITRoutines can accumulate in caches, causing dEQP test batches of 1000 to fail as all the system memory is exhausted on low-memory devices.

Optimization level is the only varying property of each TargetMachine, so simply cache these by optimization level on the JITGlobals. Until we start using compiling with different optimization levels, this will ensure a single TargetMachine is shared across all JITRoutines.

Bug: b/137524292
Change-Id: I97298708ea4ed14a81aa8026a51926f571d37148
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/34128
Kokoro-Presubmit: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Reviewed-by: Nicolas Capens <51edc787c30f24c4904e8ffbb5523c3a9f7a451d@google.com>
Reviewed-by: Chris Forbes <c3279c50043e18e9442c1ae071cafa0e7a4ca967@google.com>
Tested-by: Ben Clayton <1f693eb7158dc33015048c09d6712f74dabddf79@google.com>

google/swiftshader,google/swiftshader,bkaradzic/SwiftShader,bkaradzic/SwiftShader,google/swiftshader,bkaradzic/SwiftShader,bkaradzic/SwiftShader,bkaradzic/SwiftShader