llvm.org GIT mirror llvm / 4b1511b
Add EngineBuilder to ExecutionEngine in favor of the five optional argument EE::create(). Also a test commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76276 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 10 years ago
22 changed file(s) with 251 addition(s) and 95 deletion(s). Raw diff Collapse all Expand all
8888 module provider [mp] if successful. Creates a JIT if possible, else falls
8989 back to an interpreter. Raises [Error msg] if an error occurrs. The
9090 execution engine is not garbage collected and must be destroyed with
91 [dispose ee]. See the function [llvm::ExecutionEngine::create]. *)
91 [dispose ee]. See the function [llvm::EngineBuilder::create]. *)
9292 val create: Llvm.llmoduleprovider -> t
9393
9494 (** [create_interpreter mp] creates a new interpreter, taking ownership of the
9595 module provider [mp] if successful. Raises [Error msg] if an error
9696 occurrs. The execution engine is not garbage collected and must be
9797 destroyed with [dispose ee].
98 See the function [llvm::ExecutionEngine::create]. *)
98 See the function [llvm::EngineBuilder::create]. *)
9999 val create_interpreter: Llvm.llmoduleprovider -> t
100100
101101 (** [create_jit mp] creates a new JIT (just-in-time compiler), taking
103103 a JIT which favors code quality over compilation speed. Raises [Error msg]
104104 if an error occurrs. The execution engine is not garbage collected and
105105 must be destroyed with [dispose ee].
106 See the function [llvm::ExecutionEngine::create]. *)
106 See the function [llvm::EngineBuilder::create]. *)
107107 val create_jit: Llvm.llmoduleprovider -> t
108108
109109 (** [create_fast_jit mp] creates a new JIT (just-in-time compiler) which
111111 module provider [mp] if successful. Raises [Error msg] if an error
112112 occurrs. The execution engine is not garbage collected and must be
113113 destroyed with [dispose ee].
114 See the function [llvm::ExecutionEngine::create]. *)
114 See the function [llvm::EngineBuilder::create]. *)
115115 val create_fast_jit: Llvm.llmoduleprovider -> t
116116
117117 (** [dispose ee] releases the memory used by the execution engine and must be
351351
352352

to your linker options. This is required for adding the relevant

353353 LLVM object code to the executable. Not doing this will result on
354 some methods returning NULL (ExecutionEngine::create, for
354 some methods returning NULL (EngineBuilder::create, for
355355 instance).

356356
357357
298298 int main() {
299299 ..
300300 // Create the JIT.
301 TheExecutionEngine = ExecutionEngine::create(TheModule);
301 TheExecutionEngine = EngineBuilder(TheModule).create();
302302 ..
303303 }
304304
10771077 TheModule = new Module("my cool jit", getGlobalContext());
10781078
10791079 // Create the JIT.
1080 TheExecutionEngine = ExecutionEngine::create(TheModule);
1080 TheExecutionEngine = EngineBuilder(TheModule).create();
10811081
10821082 {
10831083 ExistingModuleProvider OurModuleProvider(TheModule);
17111711 TheModule = new Module("my cool jit", getGlobalContext());
17121712
17131713 // Create the JIT.
1714 TheExecutionEngine = ExecutionEngine::create(TheModule);
1714 TheExecutionEngine = EngineBuilder(TheModule).create();
17151715
17161716 {
17171717 ExistingModuleProvider OurModuleProvider(TheModule);
17501750 TheModule = new Module("my cool jit", getGlobalContext());
17511751
17521752 // Create the JIT.
1753 TheExecutionEngine = ExecutionEngine::create(TheModule);
1753 TheExecutionEngine = EngineBuilder(TheModule).create();
17541754
17551755 {
17561756 ExistingModuleProvider OurModuleProvider(TheModule);
21022102 TheModule = new Module("my cool jit", getGlobalContext());
21032103
21042104 // Create the JIT.
2105 TheExecutionEngine = ExecutionEngine::create(TheModule);
2105 TheExecutionEngine = EngineBuilder(TheModule).create();
21062106
21072107 {
21082108 ExistingModuleProvider OurModuleProvider(TheModule);
140140 InitializeNativeTarget();
141141
142142 std::cout << "------- Running JIT -------\n";
143 ExistingModuleProvider *mp = new ExistingModuleProvider(mod);
144 ExecutionEngine *ee = ExecutionEngine::create(mp, false);
143 ExecutionEngine *ee = EngineBuilder(mod).create();
145144 std::vector args;
146145 Function *brainf_func = mod->getFunction("brainf");
147146 GenericValue gv = ee->runFunction(brainf_func, args);
9999 Function *FibF = CreateFibFunction(M, Context);
100100
101101 // Now we going to create JIT
102 ExistingModuleProvider *MP = new ExistingModuleProvider(M);
103 ExecutionEngine *EE = ExecutionEngine::create(MP, false);
102 ExecutionEngine *EE = EngineBuilder(M).create();
104103
105104 errs() << "verifying... ";
106105 if (verifyModule(*M)) {
103103 ReturnInst::Create(Add1CallRes, BB);
104104
105105 // Now we create the JIT.
106 ExistingModuleProvider* MP = new ExistingModuleProvider(M);
107 ExecutionEngine* EE = ExecutionEngine::create(MP, false);
106 ExecutionEngine* EE = EngineBuilder(M).create();
108107
109108 outs() << "We just constructed this LLVM module:\n\n" << *M;
110109 outs() << "\n\nRunning foo: ";
11021102 TheModule = new Module("my cool jit", Context);
11031103
11041104 // Create the JIT.
1105 TheExecutionEngine = ExecutionEngine::create(TheModule);
1105 TheExecutionEngine = EngineBuilder(TheModule).create();
11061106
11071107 {
11081108 ExistingModuleProvider OurModuleProvider(TheModule);
11371137
11381138 return 0;
11391139 }
1140
241241 Function* fibF = CreateFibFunction( M );
242242
243243 // Now we create the JIT.
244 ExistingModuleProvider* MP = new ExistingModuleProvider(M);
245 ExecutionEngine* EE = ExecutionEngine::create(MP, false);
244 ExecutionEngine* EE = EngineBuilder(M).create();
246245
247246 //~ std::cout << "We just constructed this LLVM module:\n\n" << *M;
248247 //~ std::cout << "\n\nRunning foo: " << std::flush;
7070 bool SymbolSearchingDisabled;
7171 bool DlsymStubsEnabled;
7272
73 friend class EngineBuilder; // To allow access to JITCtor and InterpCtor.
74
7375 protected:
7476 /// Modules - This is a list of ModuleProvider's that we are JIT'ing from. We
7577 /// use a smallvector to optimize for the case where there is only one module.
8587 // To avoid having libexecutionengine depend on the JIT and interpreter
8688 // libraries, the JIT and Interpreter set these functions to ctor pointers
8789 // at startup time if they are linked in.
88 typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*, std::string*,
89 CodeGenOpt::Level OptLevel,
90 bool GVsWithCode);
91 static EECtorFn JITCtor, InterpCtor;
90 static ExecutionEngine *(*JITCtor)(ModuleProvider *MP,
91 std::string *ErrorStr,
92 JITMemoryManager *JMM,
93 CodeGenOpt::Level OptLevel,
94 bool GVsWithCode);
95 static ExecutionEngine *(*InterpCtor)(ModuleProvider *MP,
96 std::string *ErrorStr);
9297
9398 /// LazyFunctionCreator - If an unknown function is needed, this function
9499 /// pointer is invoked to create it. If this returns null, the JIT will abort.
371376 const Type *Ty);
372377 };
373378
379 namespace EngineKind {
380 // These are actually bitmasks that get or-ed together.
381 enum Kind {
382 JIT = 0x1,
383 Interpreter = 0x2
384 };
385 const static Kind Either = (Kind)(JIT | Interpreter);
386 }
387
388 /// EngineBuilder - Builder class for ExecutionEngines. Use this by
389 /// stack-allocating a builder, chaining the various set* methods, and
390 /// terminating it with a .create() call.
391 class EngineBuilder {
392
393 private:
394 ModuleProvider *MP;
395 EngineKind::Kind WhichEngine;
396 std::string *ErrorStr;
397 CodeGenOpt::Level OptLevel;
398 JITMemoryManager *JMM;
399 bool AllocateGVsWithCode;
400
401 /// InitEngine - Does the common initialization of default options.
402 ///
403 void InitEngine() {
404 WhichEngine = EngineKind::Either;
405 ErrorStr = NULL;
406 OptLevel = CodeGenOpt::Default;
407 JMM = NULL;
408 AllocateGVsWithCode = false;
409 }
410
411 public:
412 /// EngineBuilder - Constructor for EngineBuilder. If create() is called and
413 /// is successful, the created engine takes ownership of the module
414 /// provider.
415 EngineBuilder(ModuleProvider *mp) : MP(mp) {
416 InitEngine();
417 }
418
419 /// EngineBuilder - Overloaded constructor that automatically creates an
420 /// ExistingModuleProvider for an existing module.
421 EngineBuilder(Module *m);
422
423 /// setEngineKind - Controls whether the user wants the interpreter, the JIT,
424 /// or whichever engine works. This option defaults to EngineKind::Either.
425 EngineBuilder &setEngineKind(EngineKind::Kind w) {
426 WhichEngine = w;
427 return *this;
428 }
429
430 /// setJITMemoryManager - Sets the memory manager to use. This allows
431 /// clients to customize their memory allocation policies. If create() is
432 /// called and is successful, the created engine takes ownership of the
433 /// memory manager. This option defaults to NULL.
434 EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) {
435 JMM = jmm;
436 return *this;
437 }
438
439 /// setErrorStr - Set the error string to write to on error. This option
440 /// defaults to NULL.
441 EngineBuilder &setErrorStr(std::string *e) {
442 ErrorStr = e;
443 return *this;
444 }
445
446 /// setOptLevel - Set the optimization level for the JIT. This option
447 /// defaults to CodeGenOpt::Default.
448 EngineBuilder &setOptLevel(CodeGenOpt::Level l) {
449 OptLevel = l;
450 return *this;
451 }
452
453 /// setAllocateGVsWithCode - Sets whether global values should be allocated
454 /// into the same buffer as code. For most applications this should be set
455 /// to false. Allocating globals with code breaks freeMachineCodeForFunction
456 /// and is probably unsafe and bad for performance. However, we have clients
457 /// who depend on this behavior, so we must support it. This option defaults
458 /// to false so that users of the new API can safely use the new memory
459 /// manager and free machine code.
460 EngineBuilder &setAllocateGVsWithCode(bool a) {
461 AllocateGVsWithCode = a;
462 return *this;
463 }
464
465 ExecutionEngine *create();
466
467 };
468
374469 } // End llvm namespace
375470
376471 #endif
3434 STATISTIC(NumInitBytes, "Number of bytes of global vars initialized");
3535 STATISTIC(NumGlobals , "Number of global vars initialized");
3636
37 ExecutionEngine::EECtorFn ExecutionEngine::JITCtor = 0;
38 ExecutionEngine::EECtorFn ExecutionEngine::InterpCtor = 0;
37 ExecutionEngine *(*ExecutionEngine::JITCtor)(ModuleProvider *MP,
38 std::string *ErrorStr,
39 JITMemoryManager *JMM,
40 CodeGenOpt::Level OptLevel,
41 bool GVsWithCode) = 0;
42 ExecutionEngine *(*ExecutionEngine::InterpCtor)(ModuleProvider *MP,
43 std::string *ErrorStr) = 0;
3944 ExecutionEngine::EERegisterFn ExecutionEngine::ExceptionTableRegister = 0;
4045
4146
381386 std::string *ErrorStr,
382387 CodeGenOpt::Level OptLevel,
383388 bool GVsWithCode) {
384 ExecutionEngine *EE = 0;
385
389 return EngineBuilder(MP)
390 .setEngineKind(ForceInterpreter
391 ? EngineKind::Interpreter
392 : EngineKind::JIT)
393 .setErrorStr(ErrorStr)
394 .setOptLevel(OptLevel)
395 .setAllocateGVsWithCode(GVsWithCode)
396 .create();
397 }
398
399 ExecutionEngine *ExecutionEngine::create(Module *M) {
400 return EngineBuilder(M).create();
401 }
402
403 /// EngineBuilder - Overloaded constructor that automatically creates an
404 /// ExistingModuleProvider for an existing module.
405 EngineBuilder::EngineBuilder(Module *m) : MP(new ExistingModuleProvider(m)) {
406 InitEngine();
407 }
408
409 ExecutionEngine *EngineBuilder::create() {
386410 // Make sure we can resolve symbols in the program as well. The zero arg
387411 // to the function tells DynamicLibrary to load the program, not a library.
388412 if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
389413 return 0;
390414
391 // Unless the interpreter was explicitly selected, try making a JIT.
392 if (!ForceInterpreter && JITCtor)
393 EE = JITCtor(MP, ErrorStr, OptLevel, GVsWithCode);
394
395 // If we can't make a JIT, make an interpreter instead.
396 if (EE == 0 && InterpCtor)
397 EE = InterpCtor(MP, ErrorStr, OptLevel, GVsWithCode);
415 // If the user specified a memory manager but didn't specify which engine to
416 // create, we assume they only want the JIT, and we fail if they only want
417 // the interpreter.
418 if (JMM) {
419 if (WhichEngine & EngineKind::JIT) {
420 WhichEngine = EngineKind::JIT;
421 } else {
422 *ErrorStr = "Cannot create an interpreter with a memory manager.";
423 }
424 }
425
426 ExecutionEngine *EE = 0;
427
428 // Unless the interpreter was explicitly selected or the JIT is not linked,
429 // try making a JIT.
430 if (WhichEngine & EngineKind::JIT && ExecutionEngine::JITCtor) {
431 EE = ExecutionEngine::JITCtor(MP, ErrorStr, JMM, OptLevel,
432 AllocateGVsWithCode);
433 }
434
435 // If we can't make a JIT and we didn't request one specifically, try making
436 // an interpreter instead.
437 if (WhichEngine & EngineKind::Interpreter && EE == 0 &&
438 ExecutionEngine::InterpCtor) {
439 EE = ExecutionEngine::InterpCtor(MP, ErrorStr);
440 }
398441
399442 return EE;
400 }
401
402 ExecutionEngine *ExecutionEngine::create(Module *M) {
403 return create(new ExistingModuleProvider(M));
404443 }
405444
406445 /// getPointerToGlobal - This returns the address of the specified global
9090 LLVMModuleProviderRef MP,
9191 char **OutError) {
9292 std::string Error;
93 if (ExecutionEngine *EE = ExecutionEngine::create(unwrap(MP), false, &Error)){
93 EngineBuilder builder(unwrap(MP));
94 builder.setEngineKind(EngineKind::Either)
95 .setErrorStr(&Error);
96 if (ExecutionEngine *EE = builder.create()){
9497 *OutEE = wrap(EE);
9598 return 0;
9699 }
102105 LLVMModuleProviderRef MP,
103106 char **OutError) {
104107 std::string Error;
105 if (ExecutionEngine *Interp =
106 ExecutionEngine::create(unwrap(MP), true, &Error)) {
108 EngineBuilder builder(unwrap(MP));
109 builder.setEngineKind(EngineKind::Interpreter)
110 .setErrorStr(&Error);
111 if (ExecutionEngine *Interp = builder.create()) {
107112 *OutInterp = wrap(Interp);
108113 return 0;
109114 }
116121 unsigned OptLevel,
117122 char **OutError) {
118123 std::string Error;
119 if (ExecutionEngine *JIT =
120 ExecutionEngine::create(unwrap(MP), false, &Error,
121 (CodeGenOpt::Level)OptLevel)) {
124 EngineBuilder builder(unwrap(MP));
125 builder.setEngineKind(EngineKind::JIT)
126 .setErrorStr(&Error)
127 .setOptLevel((CodeGenOpt::Level)OptLevel);
128 if (ExecutionEngine *JIT = builder.create()) {
122129 *OutJIT = wrap(JIT);
123130 return 0;
124131 }
3232
3333 /// create - Create a new interpreter object. This can never fail.
3434 ///
35 ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr,
36 CodeGenOpt::Level OptLevel, /*unused*/
37 bool GVsWithCode /* unused */) {
35 ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr) {
3836 // Tell this ModuleProvide to materialize and release the module
3937 if (!MP->materializeModule(ErrStr))
4038 // We got an error, just return 0
107107
108108 /// create - Create an interpreter ExecutionEngine. This can never fail.
109109 ///
110 static ExecutionEngine *create(ModuleProvider *M, std::string *ErrorStr = 0,
111 CodeGenOpt::Level = CodeGenOpt::Default,
112 bool GVsWithCode = true);
110 static ExecutionEngine *create(ModuleProvider *M, std::string *ErrorStr = 0);
113111
114112 /// run - Start execution with the specified function and arguments.
115113 ///
198198 JITMemoryManager *JMM,
199199 CodeGenOpt::Level OptLevel,
200200 bool GVsWithCode) {
201 ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM, OptLevel,
202 GVsWithCode);
203 if (!EE) return 0;
204
201 return JIT::createJIT(MP, ErrorStr, JMM, OptLevel, GVsWithCode);
202 }
203
204 ExecutionEngine *JIT::createJIT(ModuleProvider *MP,
205 std::string *ErrorStr,
206 JITMemoryManager *JMM,
207 CodeGenOpt::Level OptLevel,
208 bool GVsWithCode) {
205209 // Make sure we can resolve symbols in the program as well. The zero arg
206210 // to the function tells DynamicLibrary to load the program, not a library.
207 sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr);
208 return EE;
211 if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
212 return 0;
213
214 // Pick a target either via -march or by guessing the native arch.
215 TargetMachine *TM = JIT::selectTarget(MP, ErrorStr);
216 if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
217
218 // If the target supports JIT code generation, create a the JIT.
219 if (TargetJITInfo *TJ = TM->getJITInfo()) {
220 return new JIT(MP, *TM, *TJ, JMM, OptLevel, GVsWithCode);
221 } else {
222 if (ErrorStr)
223 *ErrorStr = "target does not support JIT code generation";
224 return 0;
225 }
209226 }
210227
211228 JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
7878 /// create - Create an return a new JIT compiler if there is one available
7979 /// for the current target. Otherwise, return null.
8080 ///
81 static ExecutionEngine *create(ModuleProvider *MP, std::string *Err,
81 static ExecutionEngine *create(ModuleProvider *MP,
82 std::string *Err,
83 JITMemoryManager *JMM,
8284 CodeGenOpt::Level OptLevel =
8385 CodeGenOpt::Default,
84 bool AllocateGVsWithCode = true) {
85 return createJIT(MP, Err, 0, OptLevel, AllocateGVsWithCode);
86 bool GVsWithCode = true) {
87 return ExecutionEngine::createJIT(MP, Err, JMM, OptLevel, GVsWithCode);
8688 }
8789
8890 virtual void addModuleProvider(ModuleProvider *MP);
151153 /// addPendingFunction - while jitting non-lazily, a called but non-codegen'd
152154 /// function was encountered. Add it to a pending list to be processed after
153155 /// the current function.
154 ///
156 ///
155157 void addPendingFunction(Function *F);
156
158
157159 /// getCodeEmitter - Return the code emitter this JIT is emitting into.
160 ///
158161 JITCodeEmitter *getCodeEmitter() const { return JCE; }
159
162
163 /// selectTarget - Pick a target either via -march or by guessing the native
164 /// arch. Add any CPU features specified via -mcpu or -mattr.
165 static TargetMachine *selectTarget(ModuleProvider *MP, std::string *Err);
166
160167 static ExecutionEngine *createJIT(ModuleProvider *MP,
161 std::string *Err,
168 std::string *ErrorStr,
162169 JITMemoryManager *JMM,
163170 CodeGenOpt::Level OptLevel,
164 bool AllocateGVsWithCode);
165
171 bool GVsWithCode);
166172
167173 // Run the JIT on F and return information about the generated code
168174 void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0);
3737 cl::desc("Target specific attributes (-mattr=help for details)"),
3838 cl::value_desc("a1,+a2,-a3,..."));
3939
40 /// createInternal - Create an return a new JIT compiler if there is one
41 /// available for the current target. Otherwise, return null.
42 ///
43 ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
44 JITMemoryManager *JMM,
45 CodeGenOpt::Level OptLevel,
46 bool AllocateGVsWithCode) {
40 /// selectTarget - Pick a target either via -march or by guessing the native
41 /// arch. Add any CPU features specified via -mcpu or -mattr.
42 TargetMachine *JIT::selectTarget(ModuleProvider *MP, std::string *ErrorStr) {
4743 const Target *TheTarget = 0;
4844 if (MArch.empty()) {
4945 std::string Error;
8985 TargetMachine *Target =
9086 TheTarget->createTargetMachine(*MP->getModule(), FeaturesStr);
9187 assert(Target && "Could not allocate target machine!");
92
93 // If the target supports JIT code generation, return a new JIT now.
94 if (TargetJITInfo *TJ = Target->getJITInfo())
95 return new JIT(MP, *Target, *TJ, JMM, OptLevel, AllocateGVsWithCode);
96
97 if (ErrorStr)
98 *ErrorStr = "target does not support JIT code generation";
99 return 0;
88 return Target;
10089 }
130130 exit(1);
131131 }
132132
133 EngineBuilder builder(MP);
134 builder.setErrorStr(&ErrorMsg)
135 .setEngineKind(ForceInterpreter
136 ? EngineKind::Interpreter
137 : EngineKind::JIT);
138
133139 // If we are supposed to override the target triple, do so now.
134140 if (!TargetTriple.empty())
135141 Mod->setTargetTriple(TargetTriple);
145151 case '2': OLvl = CodeGenOpt::Default; break;
146152 case '3': OLvl = CodeGenOpt::Aggressive; break;
147153 }
148
149 EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl);
154 builder.setOptLevel(OLvl);
155
156 EE = builder.create();
150157 if (!EE) {
151158 if (!ErrorMsg.empty())
152159 errs() << argv[0] << ": error creating EE: " << ErrorMsg << "\n";
6565 protected:
6666 JITEventListenerTest()
6767 : M(new Module("module", getGlobalContext())),
68 EE(ExecutionEngine::createJIT(new ExistingModuleProvider(M))) {
68 EE(EngineBuilder(M)
69 .setEngineToCreate(EngineBuilder::ENG_JIT)
70 .create()) {
6971 }
7072
7173 Module *M;
231233
232234 class JITEnvironment : public testing::Environment {
233235 virtual void SetUp() {
234 // Required for ExecutionEngine::createJIT to create a JIT.
236 // Required to create a JIT.
235237 InitializeNativeTarget();
236238 }
237239 };
None //===- JITEmitter.cpp - Unit tests for the JIT code emitter ---------------===//
0 //===- JITTest.cpp - Unit tests for the JIT -------------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1717 #include "llvm/Function.h"
1818 #include "llvm/GlobalValue.h"
1919 #include "llvm/GlobalVariable.h"
20 #include "llvm/LLVMContext.h"
2021 #include "llvm/Module.h"
2122 #include "llvm/ModuleProvider.h"
2223 #include "llvm/Support/IRBuilder.h"
5960 // memory is more easily tested.
6061 MemMgr->setPoisonMemory(true);
6162 std::string Error;
62 OwningPtr JIT(ExecutionEngine::createJIT(
63 MP,
64 &Error,
65 MemMgr,
66 CodeGenOpt::Default,
67 false)); // This last argument enables the fix.
63 OwningPtr JIT(EngineBuilder(MP)
64 .setEnginePreference(EngineBuilder::JITONLY)
65 .setErrorStr(&Error)
66 .setJITMemoryManager(MemMgr)
67 // The next line enables the fix:
68 .setAllocateGVsWithCode(false)
69 .create());
6870 ASSERT_EQ(Error, "");
6971
7072 // Create a global variable.
114116 EXPECT_EQ(3, *GPtr);
115117 }
116118
117 // TODO(rnk): This seems to only run once for both tests, which is unexpected.
118 // That works just fine, but we shouldn't duplicate the code.
119 // This code is copied from JITEventListenerTest, but it only runs once for all
120 // the tests in this directory. Everything seems fine, but that's strange
121 // behavior.
119122 class JITEnvironment : public testing::Environment {
120123 virtual void SetUp() {
121 // Required for ExecutionEngine::createJIT to create a JIT.
124 // Required to create a JIT.
122125 InitializeNativeTarget();
123126 }
124127 };